public function storeRightGroup(RightGroup $rightGroup) { $stmntMutate = $this->db->prepare("\n\t\t\tINSERT INTO rightgroup SET\n\t\t\t\tID = ?, groupname = ?, groupkey = ?, root = ?\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tgroupname = ?, groupkey = ?, root = ?\n\t\t"); $newRgID = $this->db->insert($stmntMutate, array($rightGroup->getID(), $rightGroup->getGroupName(), $rightGroup->getGroupKey(), (int) $rightGroup->isRoot(), $rightGroup->getGroupName(), $rightGroup->getGroupKey(), (int) $rightGroup->isRoot())); $rgID = $rightGroup->getID() !== null ? $rightGroup->getID() : $newRgID; $removeRights = $this->db->prepare("DELETE FROM cms_rightgroup_has_right WHERE rightgroup_IDFK = ?"); $this->db->delete($removeRights, array($rgID)); $stmntInsertRight = $this->db->prepare("\n\t\t\tINSERT INTO cms_rightgroup_has_right\n\t\t\tSET rightgroup_IDFK = ?, cms_right = ?, date_from = NOW()\n\t\t"); foreach ($rightGroup->getRights() as $r) { $this->db->insert($stmntInsertRight, array($rgID, $r)); } }
/** * @param RightGroup $rightGroup */ protected function prepareEditRightGroupForm(RightGroup $rightGroup) { if ($this->form instanceof CmsForm) { return; } $lang = $this->cmsController->getLocaleHandler()->getLanguage(); $checkOptionsRights = array(); $options = array(); $allModules = $this->moduleModel->getAllModules(); foreach ($allModules as $mod) { if (isset($mod->manifest_content->rights) === false || count((array) $mod->manifest_content->rights) === 0) { continue; } $optionsTemp = array(); foreach ($mod->manifest_content->rights as $key => $label) { $checkOptionsRights[$key] = $key; $optionsTemp[$key] = isset($label->{$lang}) ? $label->{$lang} : $label->en; } $options[isset($mod->manifest_content->name->{$lang}) ? $mod->manifest_content->name->{$lang} : $mod->manifest_content->name->en] = $optionsTemp; } $this->form = new CmsForm(); $this->form->setInputData(array_merge($_POST, $_GET)); $fldName = new InputField('name', 'Name'); $fldName->setValue($rightGroup->getGroupName()); $fldName->addRule(new RequiredRule($this->translator->_d('backend', 'Please insert a group name'))); $fldKey = new InputField('key', 'Key'); $fldKey->setValue($rightGroup->getGroupKey()); $fldKey->addRule(new RequiredRule($this->translator->_d('backend', 'Please insert a group key'))); $fldRoot = new OptionsField('root', 'Root', array(1 => $this->translator->_d('backend', 'This group has root rights'))); $fldRoot->setValue(array((int) $rightGroup->isRoot())); $fldRoot->setOptionsFieldRenderer(new CheckboxOptionsFieldRenderer()); $fldRights = new OptionsField('rights', 'Rights', $checkOptionsRights); $fldRights->setOptionsFieldRenderer(new RightsOptionsFieldRenderer($options)); $fldRights->setValue($rightGroup->getRights()); $this->form->addFields(array($fldName, $fldKey, $fldRoot, $fldRights)); }