public function getAdminForm() { $arrGroups = class_module_user_group::getObjectList(); $arrGroupsDD = array(); $arrGroupsDD[0] = $this->getLang("userlist_all"); if (count($arrGroups) > 0) { foreach ($arrGroups as $objOneGroup) { $arrGroupsDD[$objOneGroup->getSystemid()] = $objOneGroup->getStrName(); } } $objForm = parent::getAdminForm(); $objForm->getField("char2")->setArrKeyValues($arrGroupsDD); return $objForm; }
public function getAdminForm() { $objForm = parent::getAdminForm(); $arrGroups = class_module_user_group::getObjectList(); $arrGroupsDD = array(); foreach ($arrGroups as $objOneGroup) { if ($objOneGroup->getStrSubsystem() == "kajona") { $arrGroupsDD[$objOneGroup->getSystemid()] = $objOneGroup->getStrName(); } } $objForm->getField("group")->setArrKeyValues($arrGroupsDD); $objForm->addField(new class_formentry_textrow("hint"))->setStrValue($this->getLang("portalregistration_hint")); $objForm->setFieldToPosition("hint", 1); return $objForm; }
/** * Returns a form to modify the rights * * @return string * @permissions right */ protected function actionChange() { $strReturn = ""; $strSystemID = $this->getParam("systemid"); $objTargetRecord = null; if ($strSystemID == "") { $strSystemID = "0"; } //Determine the systemid if ($strSystemID != "") { $objTargetRecord = class_objectfactory::getInstance()->getObject($strSystemID); } //Edit a module? if ($this->getParam("changemodule") != "") { $objTargetRecord = class_module_system_module::getModuleByName($this->getParam("changemodule")); $strSystemID = $objTargetRecord->getSystemid(); } if ($objTargetRecord == null) { return $this->getLang("commons_error_permissions"); } $objRights = class_carrier::getInstance()->getObjRights(); if ($objTargetRecord->rightRight()) { //Get Rights $arrRights = $objRights->getArrayRights($objTargetRecord->getSystemid()); //Get groups $arrGroups = class_module_user_group::getObjectList(); //Determine name of the record if ($objTargetRecord instanceof class_module_system_module) { $strTitle = class_carrier::getInstance()->getObjLang()->getLang("modul_titel", $objTargetRecord->getStrName()) . " (" . $objTargetRecord->getStrDisplayName() . ")"; } else { if ($objTargetRecord->getStrDisplayName() == "") { $strTitle = $this->getLang("titel_leer"); } else { $strTitle = $objTargetRecord->getStrDisplayName() . " "; } } //Load the rights header-row if ($objTargetRecord->getIntModuleNr() == 0) { $strModule = "system"; } else { if ($objTargetRecord instanceof class_module_system_module) { $strModule = $objTargetRecord->getStrName(); } else { if (defined("_pages_folder_id_") && $objTargetRecord->getIntModuleNr() == _pages_folder_id_) { $strModule = "pages"; } else { $strModule = $objTargetRecord->getArrModule("modul"); } } } $arrHeaderRow = $this->getLang("permissions_header", $strModule); $arrDefaultHeader = $this->getLang("permissions_default_header", "system"); if ($arrHeaderRow == "!permissions_header!") { $arrHeaderRow = $arrDefaultHeader; } if ($strSystemID == "0") { $arrHeaderRow = $this->getLang("permissions_root_header", "system"); } $arrTitles = $arrHeaderRow; $arrTemplateTotal = array(); $arrTemplateTotal["title0"] = $arrTitles[0]; $arrTemplateTotal["title1"] = $arrTitles[1]; $arrTemplateTotal["title2"] = $arrTitles[2]; $arrTemplateTotal["title3"] = $arrTitles[3]; $arrTemplateTotal["title4"] = $arrTitles[4]; $arrTemplateTotal["title5"] = $arrTitles[5]; $arrTemplateTotal["title6"] = $arrTitles[6]; $arrTemplateTotal["title7"] = $arrTitles[7]; $arrTemplateTotal["title8"] = $arrTitles[8]; if (class_module_system_setting::getConfigValue("_system_changehistory_enabled_") == "true") { if (!isset($arrTitles[9])) { //fallback for pre 4.3.2 systems $arrTitles[9] = $arrDefaultHeader[9]; } $arrTemplateTotal["title9"] = $arrTitles[9]; } //Read the template $strTemplateRowID = $this->objTemplate->readTemplate("/elements.tpl", "rights_form_row"); $arrTemplateTotal["rows"] = ""; //Inserting Rows foreach ($arrGroups as $objSingleGroup) { $arrTemplateRow = array(); $arrSingleGroup = array(); $arrTemplateRow["group"] = $objSingleGroup->getStrName(); $arrSingleGroup["group_id"] = $objSingleGroup->getSystemid(); //hide the superglobal admin-row from non-members if ($objSingleGroup->getSystemid() == class_module_system_setting::getConfigValue("_admins_group_id_") && !in_array(class_module_system_setting::getConfigValue("_admins_group_id_"), $this->objSession->getGroupIdsAsArray())) { continue; } //Building Checkboxes $arrTemplateRow["box0"] = "<input title=\"" . $arrTitles[0] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"1," . $arrSingleGroup["group_id"] . "\" id=\"1," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["view"]) ? " checked=\"checked\" " : "") . " />"; $arrTemplateRow["box1"] = "<input title=\"" . $arrTitles[1] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"2," . $arrSingleGroup["group_id"] . "\" id=\"2," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["edit"]) ? " checked=\"checked\" " : "") . " />"; $arrTemplateRow["box2"] = "<input title=\"" . $arrTitles[2] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"3," . $arrSingleGroup["group_id"] . "\" id=\"3," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["delete"]) ? " checked=\"checked\" " : "") . " />"; $arrTemplateRow["box3"] = "<input title=\"" . $arrTitles[3] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"4," . $arrSingleGroup["group_id"] . "\" id=\"4," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["right"]) ? " checked=\"checked\" " : "") . " />"; //loop the module specific permissions for ($intI = 1; $intI <= 5; $intI++) { if ($arrTemplateTotal["title" . ($intI + 3)] != "") { $arrTemplateRow["box" . ($intI + 3)] = "<input title=\"" . $arrTitles[$intI + 3] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"" . ($intI + 4) . "," . $arrSingleGroup["group_id"] . "\" id=\"" . ($intI + 4) . "," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["right" . $intI]) ? " checked=\"checked\" " : "") . " />"; } else { $arrTemplateRow["box" . ($intI + 3)] = "<input type=\"hidden\" name=\"" . ($intI + 4) . "," . $arrSingleGroup["group_id"] . "\" id=\"" . ($intI + 4) . "," . $arrSingleGroup["group_id"] . "\" value=\"1\" />"; } } if (class_module_system_setting::getConfigValue("_system_changehistory_enabled_") == "true") { $arrTemplateRow["box9"] = "<input title=\"" . $arrTitles[9] . "\" rel=\"tooltip\" type=\"checkbox\" name=\"10," . $arrSingleGroup["group_id"] . "\" id=\"10," . $arrSingleGroup["group_id"] . "\" value=\"1\" " . (in_array($arrSingleGroup["group_id"], $arrRights["changelog"]) ? " checked=\"checked\" " : "") . " />"; } //And Print it to template $arrTemplateTotal["rows"] .= $this->objTemplate->fillTemplate($arrTemplateRow, $strTemplateRowID); } //Build the inherit-box $strTemplateInheritID = $this->objTemplate->readTemplate("/elements.tpl", "rights_form_inherit"); $arrTemplateInherit = array(); $arrTemplateInherit["title"] = $this->getLang("titel_erben"); $arrTemplateInherit["name"] = "inherit"; if (isset($arrRights["inherit"]) && $arrRights["inherit"] == 1) { $arrTemplateInherit["checked"] = "checked=\"checked\""; } else { $arrTemplateInherit["checked"] = ""; } $arrTemplateTotal["inherit"] = $this->objTemplate->fillTemplate($arrTemplateInherit, $strTemplateInheritID); //Creating the output, starting with the header $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "rights_form_header"); $arrTemplate = array(); $arrTemplate["record"] = $strTitle; //Backlink $strUrlHistory = $this->getHistory(0); //Buliding the right-matrix $arrHistory = explode("&", $strUrlHistory); if (isset($arrHistory[0]) && isset($arrHistory[1])) { $arrTemplate["backlink"] = class_link::getLinkAdminManual("href=\"" . $arrHistory[0] . "&" . $arrHistory[1] . "\"", $this->getLang("commons_back")); } $arrTemplate["desc"] = $this->getLang("desc"); $strReturn .= $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID); //Followed by the form $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "saverights"), "rightsForm", "", "KAJONA.admin.permissions.submitForm(); return false;"); $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "rights_form_form"); $strReturn .= $this->objTemplate->fillTemplate($arrTemplateTotal, $strTemplateID); $strReturn .= $this->objToolkit->formInputHidden("systemid", $strSystemID); //place all inheritance-rights as hidden-fields to support the change-js script $strPrevId = $objTargetRecord->getPrevId(); $arrRightsInherited = $objRights->getArrayRights($strPrevId); foreach ($arrRightsInherited as $strRightName => $arrRightsPerAction) { if ($strRightName != "inherit") { $intRightCounter = 0; if ($strRightName == "view") { $intRightCounter = 1; } if ($strRightName == "edit") { $intRightCounter = 2; } if ($strRightName == "delete") { $intRightCounter = 3; } if ($strRightName == "right") { $intRightCounter = 4; } if ($strRightName == "right1") { $intRightCounter = 5; } if ($strRightName == "right2") { $intRightCounter = 6; } if ($strRightName == "right3") { $intRightCounter = 7; } if ($strRightName == "right4") { $intRightCounter = 8; } if ($strRightName == "right5") { $intRightCounter = 9; } if ($strRightName == "changelog") { $intRightCounter = 10; } foreach ($arrRightsPerAction as $strOneGroupId) { //place hidden field $strReturn .= $this->objToolkit->formInputHidden("inherit," . $intRightCounter . "," . $strOneGroupId, "1"); } } } //Close the form $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save")); $strReturn .= $this->objToolkit->formClose(); $strReturn .= "<script type=\"text/javascript\">\n KAJONA.admin.permissions.checkRightMatrix();\n KAJONA.admin.permissions.toggleEmtpyRows('" . $this->getLang("permissions_toggle_visible") . "', '" . $this->getLang("permissions_toggle_hidden") . "', '#rightsForm tr');\n </script>"; } else { $strReturn .= $this->getLang("commons_error_permissions"); } return $strReturn; }
/** * Saves a post to the databases * * @permissions right1 * @return string */ protected function actionPostComment() { if (!$this->validateForm()) { return $this->actionList(); } $strSystemidfilter = ""; if ($this->getSystemid() != "") { $strSystemidfilter = $this->getSystemid(); } if (class_module_pages_page::getPageByName($this->getPagename()) !== null) { $strPagefilter = class_module_pages_page::getPageByName($this->getPagename())->getSystemid(); } else { $strPagefilter = ""; } $objPost = new class_module_postacomment_post(); $objPost->setStrUsername($this->getParam("comment_name")); $objPost->setStrTitle($this->getParam("comment_subject")); $objPost->setStrComment($this->getParam("comment_message")); $objPost->setStrAssignedPage($strPagefilter); $objPost->setStrAssignedSystemid($strSystemidfilter); $objPost->setStrAssignedLanguage($this->getStrPortalLanguage()); $objPost->updateObjectToDb(); $this->flushPageFromPagesCache($this->getPagename()); $strMailtext = $this->getLang("new_comment_mail") . "\r\n\r\n" . $objPost->getStrComment() . "\r\n"; $strMailtext .= class_link::getLinkAdminHref("postacomment", "edit", "&systemid=" . $objPost->getSystemid(), false); $objMessageHandler = new class_module_messaging_messagehandler(); $arrGroups = array(); $allGroups = class_module_user_group::getObjectList(); foreach ($allGroups as $objOneGroup) { if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) { $arrGroups[] = $objOneGroup; } } $objMessage = new class_module_messaging_message(); $objMessage->setStrBody($strMailtext); $objMessage->setObjMessageProvider(new class_messageprovider_postacomment()); $objMessageHandler->sendMessageObject($objMessage, $arrGroups); $this->portalReload(_indexpath_ . "?" . $this->getHistory(1)); return ""; }
/** * saves a post in the database and returns the post as html. * In case of missing fields, the form is returned again * * @return string * @permissons right1 */ protected function actionSavePost() { $strXMLContent = ""; //validate needed fields if (!$this->validateForm()) { //Create form to reenter values $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_form"); $arrForm = array(); $arrForm["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "postComment", "", $this->getSystemid()); $arrForm["comment_name"] = $this->getParam("comment_name"); $arrForm["comment_subject"] = $this->getParam("comment_subject"); $arrForm["comment_message"] = $this->getParam("comment_message"); $arrForm["comment_template"] = $this->getParam("comment_template"); $arrForm["comment_systemid"] = $this->getParam("comment_systemid"); $arrForm["comment_page"] = $this->getParam("comment_page"); $arrForm["validation_errors"] = $this->strErrors; foreach ($arrForm as $strKey => $strValue) { if (uniStrpos($strKey, "comment_") !== false) { $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false); } } //texts $arrForm["postacomment_write_new"] = $this->getLang("postacomment_write_new"); $arrForm["form_name_label"] = $this->getLang("form_name_label"); $arrForm["form_subject_label"] = $this->getLang("form_subject_label"); $arrForm["form_message_label"] = $this->getLang("form_message_label"); $arrForm["form_captcha_label"] = $this->getLang("commons_captcha"); $arrForm["form_captcha_reload_label"] = $this->getLang("commons_captcha_reload"); $arrForm["form_submit_label"] = $this->getLang("form_submit_label"); $strXMLContent .= $this->fillTemplate($arrForm, $strTemplateID); } else { //save the post to the db //pageid or systemid to filter? $strSystemidfilter = $this->getParam("comment_systemid"); if (class_module_pages_page::getPageByName($this->getParam("comment_page")) !== null) { $strPagefilter = class_module_pages_page::getPageByName($this->getParam("comment_page"))->getSystemid(); } else { $strPagefilter = ""; } $objPost = new class_module_postacomment_post(); $objPost->setStrUsername($this->getParam("comment_name")); $objPost->setStrTitle($this->getParam("comment_subject")); $objPost->setStrComment($this->getParam("comment_message")); $objPost->setStrAssignedPage($strPagefilter); $objPost->setStrAssignedSystemid($strSystemidfilter); $objPost->setStrAssignedLanguage($this->getStrPortalLanguage()); $objPost->updateObjectToDb(); $this->flushPageFromPagesCache($this->getPagename()); $strMailtext = $this->getLang("new_comment_mail") . "\r\n\r\n" . $objPost->getStrComment() . "\r\n"; $strMailtext .= class_link::getLinkAdminHref("postacomment", "edit", "&systemid=" . $objPost->getSystemid(), false); $objMessageHandler = new class_module_messaging_messagehandler(); $arrGroups = array(); $allGroups = class_module_user_group::getObjectList(); foreach ($allGroups as $objOneGroup) { if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) { $arrGroups[] = $objOneGroup; } } $objMessageHandler->sendMessage($strMailtext, $arrGroups, new class_messageprovider_postacomment()); //reinit post -> encoded entities $objPost->initObject(); //load the post as a new post to add it at top of the list $arrOnePost = array(); $arrOnePost["postacomment_post_name"] = $objPost->getStrUsername(); $arrOnePost["postacomment_post_subject"] = $objPost->getStrTitle(); $arrOnePost["postacomment_post_message"] = $objPost->getStrComment(); $arrOnePost["postacomment_post_systemid"] = $objPost->getSystemid(); $arrOnePost["postacomment_post_date"] = timeToString($objPost->getIntDate(), true); $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_post"); $strXMLContent .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID); } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return $strXMLContent; }
/** * Creates a browser-like view of the users available * * @return string */ protected function actionUserBrowser() { $this->setArrModuleEntry("template", "/folderview.tpl"); $strReturn = ""; $strFormElement = $this->getParam("form_element"); if ($this->getSystemid() == "") { //show groups $arrUsers = class_module_user_group::getObjectList(); $strReturn .= $this->objToolkit->listHeader(); $intI = 0; foreach ($arrUsers as $objSingleGroup) { $strAction = ""; $strAction .= $this->objToolkit->listButton(class_link::getLinkAdmin("user", "userBrowser", "&form_element=" . $this->getParam("form_element") . "&systemid=" . $objSingleGroup->getSystemid() . "&filter=" . $this->getParam("filter") . "&checkid=" . $this->getParam("checkid"), $this->getLang("user_browser_show"), $this->getLang("user_browser_show"), "icon_folderActionOpen")); if ($this->getParam("allowGroup") == "1") { $strAction .= $this->objToolkit->listButton("<a href=\"#\" title=\"" . $this->getLang("group_accept") . "\" rel=\"tooltip\" onclick=\"KAJONA.admin.folderview.selectCallback([['" . strFormElement . "', '" . addslashes($objSingleGroup->getStrName()) . "'], ['" . $strFormElement . "_id', '" . $objSingleGroup->getSystemid() . "']]);\">" . getImageAdmin("icon_accept")); } $strReturn .= $this->objToolkit->simpleAdminList($objSingleGroup, $strAction, $intI++); } } else { //show members of group $objGroup = new class_module_user_group($this->getSystemid()); $arrUsers = $objGroup->getObjSourceGroup()->getUserIdsForGroup(); $strReturn .= $this->objToolkit->listHeader(); $intI = 0; $strReturn .= $this->objToolkit->genericAdminList(generateSystemid(), "", "", $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "userBrowser", "&form_element=" . $this->getParam("form_element") . "&filter=" . $this->getParam("filter") . "&allowGroup=" . $this->getParam("allowGroup") . "&checkid=" . $this->getParam("checkid"), $this->getLang("user_list_parent"), $this->getLang("user_list_parent"), "icon_folderActionLevelup")), $intI++); $strCheckId = $this->getParam("checkid"); $arrCheckIds = json_decode($strCheckId); foreach ($arrUsers as $strSingleUser) { $objSingleUser = new class_module_user_user($strSingleUser); $bitRenderAcceptLink = true; if (!empty($arrCheckIds) && is_array($arrCheckIds)) { foreach ($arrCheckIds as $strCheckId) { if (!$this->hasUserViewPermissions($strCheckId, $objSingleUser)) { $bitRenderAcceptLink = false; break; } } } $strAction = ""; if (!$bitRenderAcceptLink || $objSingleUser->getIntActive() == 0 || $this->getParam("filter") == "current" && $objSingleUser->getSystemid() == $this->objSession->getUserID()) { $strAction .= $this->objToolkit->listButton(getImageAdmin("icon_acceptDisabled")); } else { $strAction .= $this->objToolkit->listButton("<a href=\"#\" title=\"" . $this->getLang("user_accept") . "\" rel=\"tooltip\" onclick=\"KAJONA.admin.folderview.selectCallback([['" . $strFormElement . "', '" . addslashes($objSingleUser->getStrUsername()) . "'], ['" . $strFormElement . "_id', '" . $objSingleUser->getSystemid() . "']]);\">" . getImageAdmin("icon_accept")); } $strReturn .= $this->objToolkit->simpleAdminList($objSingleUser, $strAction, $intI++); } } return $strReturn; }
/** * @return bool */ protected function onInsertToDb() { //send a message to all registered editors $objEvent = new class_module_eventmanager_event($this->getStrPrevId()); $strMailtext = $this->getLang("new_participant_mail") . "\n\n"; $strMailtext .= $this->getLang("new_participant_participant") . " " . $this->getStrDisplayName() . "\n"; $strMailtext .= $this->getLang("new_participant_event") . " " . $objEvent->getStrDisplayName() . "\n"; $strMailtext .= $this->getLang("new_participant_details") . " " . class_link::getLinkAdminHref("eventmanager", "listParticipant", "&systemid=" . $this->getStrPrevId(), false); $objMessageHandler = new class_module_messaging_messagehandler(); $arrGroups = array(); $allGroups = class_module_user_group::getObjectList(); foreach ($allGroups as $objOneGroup) { if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getSystemid())) { $arrGroups[] = $objOneGroup; } } $objMessage = new class_module_messaging_message(); $objMessage->setStrBody(strip_tags($strMailtext)); $objMessage->setObjMessageProvider(new class_messageprovider_eventmanager()); $objMessageHandler->sendMessageObject($objMessage, $arrGroups); return true; }
/** * Saves the passed values to db * * @throws class_exception * @return string "" in case of success */ protected function actionSaveGuestbook() { $strReturn = ""; if (!$this->validateData()) { $this->setParam("eintragen_fehler", $this->getLang("eintragen_fehler")); return $this->actionInsertGuestbook($this->getAllParams()); } $objBook = new class_module_guestbook_guestbook($this->arrElementData["guestbook_id"]); //check rights if ($objBook->rightRight1()) { //create a post-object $objPost = new class_module_guestbook_post(); $objPost->setStrGuestbookPostName($this->getParam("gb_post_name")); $objPost->setStrGuestbookPostEmail($this->getParam("gb_post_email")); $objPost->setStrGuestbookPostPage($this->getParam("gb_post_page")); $objPost->setStrGuestbookPostText($this->getParam("gb_post_text")); $objPost->setIntGuestbookPostDate(time()); //save obj to db if (!$objPost->updateObjectToDb($objBook->getSystemid())) { throw new class_exception("Error saving entry", class_exception::$level_ERROR); } $strMailtext = $this->getLang("new_post_mail"); $strMailtext .= getLinkAdminHref("guestbook", "edit", "&systemid=" . $objPost->getSystemid(), false); $objMessageHandler = new class_module_messaging_messagehandler(); $arrGroups = array(); $allGroups = class_module_user_group::getObjectList(); foreach ($allGroups as $objOneGroup) { if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) { $arrGroups[] = $objOneGroup; } } $objMessageHandler->sendMessage($strMailtext, $arrGroups, new class_messageprovider_guestbook()); //Flush the page from cache $this->flushPageFromPagesCache($this->getPagename()); $this->portalReload(getLinkPortalHref($this->getPagename())); } else { $strReturn = $this->getLang("commons_error_permissions"); } return $strReturn; }
public function test() { $objDB = class_carrier::getInstance()->getObjDB(); echo "\tmodul_user...\n"; //blank system - one user should have been created echo "\tcheck number of users installed...\n"; $arrUserInstalled = class_module_user_user::getObjectList(); $intStartUsers = count($arrUserInstalled); echo "\t ...found " . $intStartUsers . " users.\n"; echo "\tcheck number of groups installed...\n"; $arrGroupsInstalled = class_module_user_group::getObjectList(); $intStartGroups = count($arrGroupsInstalled); echo "\t ...found " . $intStartUsers . " users.\n"; echo "\tcreate 10 users using the model...\n"; $arrUsersCreated = array(); for ($intI = 0; $intI < 10; $intI++) { $objUser = new class_module_user_user(); //$objUser->setStrEmail(generateSystemid()."@".generateSystemid()."de"); $strUsername = "******" . generateSystemid(); $objUser->setStrUsername($strUsername); $objUser->updateObjectToDb(); $arrUsersCreated[] = $objUser->getSystemid(); $strID = $objUser->getSystemid(); $objDB->flushQueryCache(); $objUser = new class_module_user_user($strID); $this->assertEquals($objUser->getStrUsername(), $strUsername, __FILE__ . " checkNameOfUserCreated"); } $arrUserInstalled = class_module_user_user::getObjectList(); $this->assertEquals(count($arrUserInstalled), 10 + $intStartUsers, __FILE__ . " checkNrOfUsersCreatedByModel"); echo "\tcreate 10 groups using the model...\n"; $arrGroupsCreated = array(); for ($intI = 0; $intI < 10; $intI++) { $objGroup = new class_module_user_group(); $strName = "name_" . generateSystemid(); $objGroup->setStrName($strName); $objGroup->updateObjectToDb(); $strID = $objGroup->getSystemid(); $arrGroupsCreated[] = $objGroup->getSystemid(); $objDB->flushQueryCache(); $objGroup = new class_module_user_group($strID); $this->assertEquals($objGroup->getStrName(), $strName, __FILE__ . " checkNameOfGroupCreated"); } $arrGroupsInstalled = class_module_user_group::getObjectList(); $this->assertEquals(count($arrGroupsInstalled), 10 + $intStartGroups, __FILE__ . " checkNrOfGroupsByModel"); echo "\tdeleting users created...\n"; foreach ($arrUsersCreated as $strOneUser) { echo "\t\tdeleting user " . $strOneUser . "...\n"; $objUser = new class_module_user_user($strOneUser); $objUser->deleteObjectFromDatabase(); } $objDB->flushQueryCache(); echo "\tcheck number of users installed...\n"; $arrUserInstalled = class_module_user_user::getObjectList(); $this->assertEquals(count($arrUserInstalled), $intStartUsers, __FILE__ . " checkNrOfUsers"); echo "\tdeleting groups created...\n"; foreach ($arrGroupsCreated as $strOneGroup) { $objOneGroup = new class_module_user_group($strOneGroup); $objOneGroup->deleteObjectFromDatabase(); } $objDB->flushQueryCache(); echo "\tcheck number of groups installed...\n"; $arrGroupsInstalled = class_module_user_group::getObjectList(); $this->assertEquals(count($arrGroupsInstalled), $intStartGroups, __FILE__ . " checkNrOfGroups"); echo "\ttest group membership handling...\n"; $objGroup = new class_module_user_group(); $objGroup->setStrName("AUTOTESTGROUP"); $objGroup->updateObjectToDb(); echo "\tadding 10 members to group...\n"; for ($intI = 0; $intI <= 10; $intI++) { $objUser = new class_module_user_user(); $objUser->setStrUsername("AUTOTESTUSER_" . $intI); //$objUser->setStrEmail("autotest_".$intI."@kajona.de"); $objUser->updateObjectToDb(); //add user to group $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser()); $arrUsersInGroup = $objGroup->getObjSourceGroup()->getUserIdsForGroup(); $this->assertTrue(in_array($objUser->getSystemid(), $arrUsersInGroup), __FILE__ . " checkUserInGroup"); $this->assertEquals(count($arrUsersInGroup), 1 + $intI, __FILE__ . " checkNrOfUsersInGroup"); $objDB->flushQueryCache(); } echo "\tdeleting groups & users\n"; foreach ($objGroup->getObjSourceGroup()->getUserIdsForGroup() as $strOneUser) { $objOneUser = new class_module_user_user($strOneUser); $objOneUser->deleteObjectFromDatabase(); } $objGroup->deleteObjectFromDatabase(); $objDB->flushQueryCache(); echo "\tcheck number of users installed is same as at beginning...\n"; $arrUserInstalled = class_module_user_user::getObjectList(); $this->assertEquals(count($arrUserInstalled), $intStartUsers, __FILE__ . " checkNrOfUsersAtEnd"); echo "\tcheck number of groups installed is same as at beginning...\n"; $arrGroupsInstalled = class_module_user_group::getObjectList(); $this->assertEquals(count($arrGroupsInstalled), $intStartGroups, __FILE__ . " checkNrOfGrpupsAtEnd"); }
/** * @see interface_admin_systemtask::getAdminForm() * @return string */ public function getAdminForm() { $strFormName = "permissions"; $objForm = new class_admin_formgenerator($strFormName, new class_module_system_common()); $arrGroups = array(); foreach (class_module_user_group::getObjectList() as $objOneGroup) { $arrGroups[$objOneGroup->getSystemid()] = $objOneGroup->getStrDisplayName(); } $objForm->addField(new class_formentry_plaintext())->setStrValue($this->objToolkit->warningBox($this->getLang("systemtask_permissions_hint"))); $objForm->addField(new class_formentry_dropdown("", "groupid"))->setStrLabel($this->getLang("systemtask_permissions_groupid"))->setBitMandatory(true)->setArrKeyValues($arrGroups); $objForm->addField(new class_formentry_text("", "recordid"))->setStrLabel($this->getLang("systemtask_permissions_systemid"))->setBitMandatory(true); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_VIEW))->setStrLabel(class_rights::$STR_RIGHT_VIEW); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_EDIT))->setStrLabel(class_rights::$STR_RIGHT_EDIT); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_DELETE))->setStrLabel(class_rights::$STR_RIGHT_DELETE); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT))->setStrLabel(class_rights::$STR_RIGHT_RIGHT); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT1))->setStrLabel(class_rights::$STR_RIGHT_RIGHT1); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT2))->setStrLabel(class_rights::$STR_RIGHT_RIGHT2); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT3))->setStrLabel(class_rights::$STR_RIGHT_RIGHT3); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT4))->setStrLabel(class_rights::$STR_RIGHT_RIGHT4); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_RIGHT5))->setStrLabel(class_rights::$STR_RIGHT_RIGHT5); $objForm->addField(new class_formentry_checkbox("", class_rights::$STR_RIGHT_CHANGELOG))->setStrLabel(class_rights::$STR_RIGHT_CHANGELOG); return $objForm; }