/** * saves the submitted form-data as a new language, oder updates the corresponding language * * @throws class_exception * @return string, "" in case of success * @permissions edit */ protected function actionSaveLanguage() { $strOldLang = ""; if ($this->getParam("mode") == "new") { $objLanguage = new class_module_languages_language(); } else { $objLanguage = new class_module_languages_language($this->getSystemid()); $strOldLang = $objLanguage->getStrName(); if (!$objLanguage->rightEdit()) { return $this->getLang("commons_error_permissions"); } } $objForm = $this->getAdminForm($objLanguage); if (!$objForm->validateForm()) { return $this->actionNew($this->getParam("mode"), $objForm); } $objForm->updateSourceObject(); if ($this->getParam("mode") == "new") { //language already existing? if (class_module_languages_language::getLanguageByName($objLanguage->getStrName()) !== false) { return $this->getLang("language_existing"); } } elseif ($this->getParam("mode") == "edit") { $objTestLang = class_module_languages_language::getLanguageByName($objLanguage->getStrName()); if ($objTestLang !== false && $objTestLang->getSystemid() != $objLanguage->getSystemid()) { return $this->getLang("language_existing"); } } if (!$objLanguage->updateObjectToDb()) { throw new class_exception("Error creating new language", class_exception::$level_ERROR); } if ($this->getParam("mode") == "edit") { //move contents to a new language if ($strOldLang != $objLanguage->getStrName()) { if (!$objLanguage->moveContentsToCurrentLanguage($strOldLang)) { throw new class_exception("Error moving contents to new language", class_exception::$level_ERROR); } } } $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"))); }