コード例 #1
0
 /**
  * Creates a form to edit systemsettings or updates them
  *
  * @return string "" in case of success
  * @autoTestable
  * @permissions right1
  */
 protected function actionSystemSettings()
 {
     $strReturn = "";
     //Check for needed rights
     if ($this->getParam("save") != "true") {
         //Create a warning before doing s.th.
         $strReturn .= $this->objToolkit->warningBox($this->getLang("warnung_settings"));
         $arrTabs = array();
         $arrSettings = class_module_system_setting::getAllConfigValues();
         /** @var class_module_system_module $objCurrentModule */
         $objCurrentModule = null;
         $strRows = "";
         foreach ($arrSettings as $objOneSetting) {
             if ($objCurrentModule === null || $objCurrentModule->getIntNr() != $objOneSetting->getIntModule()) {
                 $objTemp = $this->getModuleDataID($objOneSetting->getIntModule(), true);
                 if ($objTemp !== null) {
                     //In the first loop, ignore the output
                     if ($objCurrentModule !== null) {
                         //Build a form to return
                         $strTabContent = $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "systemSettings"));
                         $strTabContent .= $strRows;
                         $strTabContent .= $this->objToolkit->formInputHidden("save", "true");
                         $strTabContent .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
                         $strTabContent .= $this->objToolkit->formClose();
                         $arrTabs[$this->getLang("modul_titel", $objCurrentModule->getStrName())] = $strTabContent;
                     }
                     $strRows = "";
                     $objCurrentModule = $objTemp;
                 }
             }
             //Build the rows
             //Print a help-text?
             $strHelper = $this->getLang($objOneSetting->getStrName() . "hint", $objCurrentModule->getStrName());
             if ($strHelper != "!" . $objOneSetting->getStrName() . "hint!") {
                 $strRows .= $this->objToolkit->formTextRow($strHelper);
             }
             //The input element itself
             if ($objOneSetting->getIntType() == 0) {
                 $arrDD = array();
                 $arrDD["true"] = $this->getLang("commons_yes");
                 $arrDD["false"] = $this->getLang("commons_no");
                 $strRows .= $this->objToolkit->formInputDropdown("set[" . $objOneSetting->getSystemid() . "]", $arrDD, $this->getLang($objOneSetting->getStrName(), $objCurrentModule->getStrName()), $objOneSetting->getStrValue());
             } elseif ($objOneSetting->getIntType() == 3) {
                 $strRows .= $this->objToolkit->formInputPageSelector("set[" . $objOneSetting->getSystemid() . "]", $this->getLang($objOneSetting->getStrName(), $objCurrentModule->getStrName()), $objOneSetting->getStrValue());
             } else {
                 $strRows .= $this->objToolkit->formInputText("set[" . $objOneSetting->getSystemid() . "]", $this->getLang($objOneSetting->getStrName(), $objCurrentModule->getStrName()), $objOneSetting->getStrValue());
             }
         }
         //Build a form to return -> include the last module
         $strTabContent = $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "systemSettings"));
         $strTabContent .= $strRows;
         $strTabContent .= $this->objToolkit->formInputHidden("save", "true");
         $strTabContent .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
         $strTabContent .= $this->objToolkit->formClose();
         $arrTabs[$this->getLang("modul_titel", $objCurrentModule->getStrName())] = $strTabContent;
         $strReturn .= $this->objToolkit->getTabbedContent($arrTabs);
     } else {
         //Seems we have to update a few records
         $arrSettings = $this->getAllParams();
         foreach ($arrSettings["set"] as $strKey => $strValue) {
             $objSetting = new class_module_system_setting($strKey);
             $objSetting->setStrValue($strValue);
             $objSetting->updateObjectToDb();
         }
         $strReturn .= $this->objToolkit->warningBox($this->getLang("settings_updated"));
     }
     return $strReturn;
 }