From 9030de496c8e12b893c00bfd4b8bb2ba8820786f Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Mon, 2 Aug 2021 14:25:47 +0200 Subject: [PATCH] update project ressources to save config from cli --- .../deployment/classes/actionlog.class.php | 2 +- .../deployment/classes/messenger.class.php | 2 +- .../deployment/classes/project.class.php | 4 ++-- .../convert_projects_2_rollout-plugins.php | 24 ++++++++----------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/public_html/deployment/classes/actionlog.class.php b/public_html/deployment/classes/actionlog.class.php index 8ae8693b..e09d1da9 100644 --- a/public_html/deployment/classes/actionlog.class.php +++ b/public_html/deployment/classes/actionlog.class.php @@ -58,7 +58,7 @@ class Actionlog { $this->_sProject = $sProject; $oUser=new user(); if ($oUser->getUsername()) { - $this->_sIP = $_SERVER["REMOTE_ADDR"]; + $this->_sIP = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : 'local'; $this->_sUser = $oUser->getUsername() . " (web)"; } else { $this->_sIP = 'local'; diff --git a/public_html/deployment/classes/messenger.class.php b/public_html/deployment/classes/messenger.class.php index 91eda6c5..589183a8 100644 --- a/public_html/deployment/classes/messenger.class.php +++ b/public_html/deployment/classes/messenger.class.php @@ -61,7 +61,7 @@ class messenger { */ private function _sendToSlack(){ if (array_key_exists('slack', $this->_aCfg)) { - require_once('./../vendor/shooker/shooker.php'); + require_once(__DIR__ . '/../../vendor/shooker/shooker.php'); $shkr = new Shooker(); $shkr->setupIncoming($this->_aCfg['slack']['incomingurl']); $sUser=(array_key_exists('user', $this->_aCfg['slack'])? $this->_aCfg['slack']['user']: false); diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 1667747f..054c8af5 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -155,7 +155,7 @@ class project extends base { $sSlack=$this->_aPrjConfig['messenger']['slack']; $aConfig['slack']=array('incomingurl'=>$sSlack); foreach(array('user', 'icon') as $sKey){ - if (array_key_exists($sKey, $this->_aConfig['messenger']['slack']['presets'][$sSlack])){ + if (isset($this->_aConfig['messenger']['slack']['presets'][$sSlack][$sKey])){ $aConfig['slack'][$sKey]=$this->_aConfig['messenger']['slack']['presets'][$sSlack][$sKey]; } } @@ -2342,7 +2342,7 @@ class project extends base { require_once("ldap.class.php"); $oLdapIML = new imlldap($this->_aConfig['projects']['ldap']); - // $oLdapIML->debugOn(); + //$oLdapIML->debugOn(); if (!$oLdapIML->DnExists($sDn)) { if ($oLdapIML->objAdd($sDn, $aItem)) { echo 'OK, created in LDAP.<br>'; diff --git a/shellscripts/convert_projects_2_rollout-plugins.php b/shellscripts/convert_projects_2_rollout-plugins.php index 18be679d..48535893 100644 --- a/shellscripts/convert_projects_2_rollout-plugins.php +++ b/shellscripts/convert_projects_2_rollout-plugins.php @@ -88,25 +88,21 @@ foreach ($oPrj1->getProjects() as $sPrj) { } if($bSave){ - echo "TODO: save new config\n"; + echo "INFO: save new config\n"; + $aCfg['id']=$sPrj; + if ($oPrj->saveConfig($aCfg)) { + echo " OK, config was saved \n"; + } else { + echo " ERROR: config was NOT saved :-/ \n"; + die(" Aborting\n\n"); + } } else { echo "SKIP: do NOT saving config.\n"; $aSkipped[]=$sPrj; } - // print_r($aCfg); exit; - /* - // convert - - // ... and save - if ($oPrj->saveConfig($aConfig)) { - echo "OK, config was saved \n"; - } else { - echo "ERROR: config was NOT saved :-/ \n"; - die("Aborting"); - } - * - */ + + } -- GitLab