diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index e1a386113f733adcef45fc480781324f937bc394..e2a0ccb297e1c41aa62ed7c6469e5b156f672a32 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -113,6 +113,12 @@ class project extends base { */ protected $oMessenger = false; + /** + * collected errors + * @var array + */ + protected $_errors = []; + // ---------------------------------------------------------------------- // constructor // ---------------------------------------------------------------------- @@ -868,7 +874,7 @@ class project extends base { * @return string */ public function getLabel() { - return $this->_aPrjConfig["label"]; + return isset($this->_aPrjConfig["label"]) ? $this->_aPrjConfig["label"] : ''; } /** @@ -876,7 +882,7 @@ class project extends base { * @return string */ public function getDescription() { - return $this->_aPrjConfig["description"]; + return isset($this->_aPrjConfig["description"]) ? $this->_aPrjConfig["description"] : ''; } /** @@ -884,7 +890,7 @@ class project extends base { * @return string */ public function getId(){ - return $this->_aConfig["id"]; + return isset($this->_aConfig["id"]) ? $this->_aConfig["id"] : ''; } /** * get deploy and queue infos for all phases @@ -1481,16 +1487,21 @@ class project extends base { echo "ERROR: invalid syntax in project ID: $sId<br>"; return false; } - $this->_aPrjConfig = array(); + $this->_aPrjConfig = []; $this->_aConfig["id"] = $sId; - + $this->_errors = []; if (isset($this->_aConfig['projects']['json']['active']) && $this->_aConfig['projects']['json']['active']) { $sCfgfile=$this->_getConfigFile($sId); if (!$sCfgfile || !file_exists($sCfgfile)){ return false; } - $this->_aPrjConfig = json_decode(file_get_contents($this->_getConfigFile($sId)), true); + $_aPrjConfigTmp=json_decode(file_get_contents($this->_getConfigFile($sId)), true); + if(!$_aPrjConfigTmp){ + $this->_errors[]="ERROR in configuration of project [$sId]: this is mot valid JSON file: ".$this->_getConfigFile($sId); + return false; + } + $this->_aPrjConfig = $_aPrjConfigTmp; } if (isset($this->_aConfig['projects']['ldap']['active']) && $this->_aConfig['projects']['ldap']['active']) { // TODO: read project after saving it - @see $this->saveConfig() @@ -2748,6 +2759,19 @@ class project extends base { return $sReturn; } + /** + * return html code for current project errors by rendering a box per error in $this->_errors + * @return string + */ + public function renderErrorBoxes(){ + $sReturn=''; + if(count($this->_errors)){ + foreach($this->_errors as $sError){ + $sReturn.=$this->_oHtml->getBox("error", $sError); + } + } + return $sReturn; + } /** * render html for a colored link to any project action * @param string $sFunction name of the action; one of accept|build|cleanup|deploy|new|overview|phase|rollback|setup diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php index c3629eeb9dd863a5a8c8c8f09b4c8cd72c6166db..3819504cfae8c1686d270ee00c849d28eb2ace68 100644 --- a/public_html/deployment/classes/projectlist.class.php +++ b/public_html/deployment/classes/projectlist.class.php @@ -75,6 +75,8 @@ class projectlist extends base{ $sDivInprogress='<div class="progressinprogress" title="'.t("progress-inprogress").'">'.$oHtml->getIcon('refresh').t("progress-inprogress").'</div>'; $sDivHasqueue='<div class="progresshasqueue" title="'.t("progress-hasqueue").'">'.$oHtml->getIcon('waiting').t("progress-hasqueue").'</div>'; + $sErrors=''; + // foreach (array_keys($this->_aPhases) as $sPhase) { foreach (array_keys($oPrj1->getPhases()) as $sPhase) { $sPhaseFilter.='<option value="' . $sPhase . '" >' . $sPhase . '</option>'; @@ -132,6 +134,8 @@ class projectlist extends base{ } + $sErrors.=$oPrj->renderErrorBoxes(); + $sOut2 .= '<div class="' . $sClasses . ' prjbox"><div class="title">' .$oHtml->getLink(array( 'href'=>'#', @@ -534,6 +538,7 @@ class projectlist extends base{ </div> <br> + '.$sErrors.' <div class="view viewsimple"> ' . $sOut2 . ' diff --git a/public_html/deployment/pages/act_setup.php b/public_html/deployment/pages/act_setup.php index 8d9f8f4c20eb7211f7dc8199de394be4f71b0f0a..ddee084763fda8da636672e5cbe514a5522a0971 100644 --- a/public_html/deployment/pages/act_setup.php +++ b/public_html/deployment/pages/act_setup.php @@ -345,8 +345,8 @@ if ($aParams["prj"] == "all") { $sOut.=$oHtml->getBox("error", t("page-setup-error-settings-were-not-saved")); } } - - $sOut.=$oPrj->renderProjectSetup(); + $sErrors=$oPrj->renderErrorBoxes(); + $sOut.= $sErrors ? $oPrj->renderErrorBoxes() : $oPrj->renderProjectSetup(); } $sOut.= '<div id="navbuttom">' . aPrjHome() . '</div>';