Пример #1
0
 /**
  * Validates the passed chunk of data.
  * In most cases, this'll be a string-object.
  *
  * @param string $objValue
  * @return bool
  */
 public function validate($objValue)
 {
     if (!parent::validate($objValue)) {
         return false;
     }
     //check if the user or usergroup exists
     $objUser = new class_module_user_user($objValue);
     $objUserGroup = new class_module_user_group($objValue);
     if ($objUser->getStrUsername() == "" && $objUserGroup->getStrName() == "") {
         return false;
     }
     if ($objUser->getIntDeleted() == 1) {
         return false;
     }
     return true;
 }
 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;
 }
Пример #4
0
 public function testUnreadCount()
 {
     $strText = generateSystemid() . " autotest";
     $objMessageHandler = new class_module_messaging_messagehandler();
     $objMessageHandler->sendMessage($strText, new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")), new class_messageprovider_exceptions());
     $bitFound = false;
     $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_"));
     $arrUsers = $objGroup->getObjSourceGroup()->getUserIdsForGroup();
     $arrMessages = class_module_messaging_message::getObjectList($arrUsers[0]);
     $intUnread = class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true);
     $this->assertTrue($intUnread > 0);
     $this->flushDBCache();
     foreach ($arrMessages as $objOneMessage) {
         if ($objOneMessage->getStrBody() == $strText && $objOneMessage->getStrMessageProvider() == "class_messageprovider_exceptions") {
             $bitFound = true;
             $objOneMessage->setBitRead(true);
             $objOneMessage->updateObjectToDb();
             $this->assertEquals($intUnread - 1, class_module_messaging_message::getNumberOfMessagesForUser($arrUsers[0], true));
             $objOneMessage->deleteObjectFromDatabase();
         }
     }
     $this->assertTrue($bitFound);
     $this->flushDBCache();
 }
 /**
  * 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;
 }
 /**
  * Creates the form to perform the current workflow-step
  *
  * @return string
  * @permissions view
  */
 protected function actionShowUi()
 {
     $strReturn = "";
     $objWorkflow = new class_module_workflows_workflow($this->getSystemid());
     if ($objWorkflow->getIntState() != class_module_workflows_workflow::$INT_STATE_SCHEDULED || !$objWorkflow->getObjWorkflowHandler()->providesUserInterface()) {
         return $this->getLang("commons_error_permissions");
     }
     $arrIdsToCheck = array_merge(array($this->objSession->getUserID()), $this->objSession->getGroupIdsAsArray());
     $arrIdsOfTask = explode(",", $objWorkflow->getStrResponsible());
     //ui given? current user responsible?
     //magic: the difference of the tasks' ids and the users' ids should be less than the count of the task-ids - then at least one id matches
     if ($objWorkflow->getObjWorkflowHandler()->providesUserInterface() && ($objWorkflow->getStrResponsible() == "" || count(array_diff($arrIdsOfTask, $arrIdsToCheck)) < count($arrIdsOfTask))) {
         $strCreator = "";
         if (validateSystemid($objWorkflow->getStrOwner())) {
             $objUser = new class_module_user_user($objWorkflow->getStrOwner(), false);
             $strCreator .= $objUser->getStrUsername();
         }
         $strInfo = $this->objToolkit->getTextRow($this->getLang("workflow_owner") . " " . $strCreator);
         $strResponsible = "";
         foreach (explode(",", $objWorkflow->getStrResponsible()) as $strOneId) {
             if (validateSystemid($strOneId)) {
                 if ($strResponsible != "") {
                     $strResponsible .= ", ";
                 }
                 $objUser = new class_module_user_user($strOneId, false);
                 if ($objUser->getStrUsername() != "") {
                     $strResponsible .= $objUser->getStrUsername();
                 } else {
                     $objGroup = new class_module_user_group($strOneId);
                     $strResponsible .= $objGroup->getStrName();
                 }
             }
         }
         $arrHeader = array($this->getLang("workflow_general"), "");
         $arrRow1 = array($this->getLang("workflow_owner"), $strCreator);
         $arrRow2 = array($this->getLang("workflow_responsible"), $strResponsible);
         $strReturn .= $this->objToolkit->dataTable($arrHeader, array($arrRow1, $arrRow2));
         $strForm = $objWorkflow->getObjWorkflowHandler()->getUserInterface();
         if ($strForm instanceof class_admin_formgenerator) {
             $strForm->addField(new class_formentry_hidden(null, null), "workflowid")->setStrValue($objWorkflow->getSystemid());
             $strReturn .= $strForm->renderForm(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveUI"));
         } else {
             $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveUI"));
             $strReturn .= $strForm;
             $strReturn .= $this->objToolkit->formInputHidden("systemid", $objWorkflow->getSystemid());
             $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save"));
             $strReturn .= $this->objToolkit->formClose();
         }
     } else {
         $strReturn .= $this->getLang("commons_error_permissions");
     }
     return $strReturn;
 }
 /**
  * This method is queried when the config-view is rendered.
  * It controls whether a message-provider is shown in the config-view or not.
  *
  * @return mixed
  * @since 4.5
  */
 public function isVisibleInConfigView()
 {
     $objAdminGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_"));
     return in_array(class_carrier::getInstance()->getObjSession()->getUserID(), $objAdminGroup->getObjSourceGroup()->getUserIdsForGroup());
 }
 /**
  * Returns the fully featured group-instance created by the matching subsystem.
  *
  * @param class_module_user_group $objLeightweightGroup
  *
  * @return interface_usersources_group
  */
 public function getSourceGroup(class_module_user_group $objLeightweightGroup)
 {
     $objSubsystem = $this->getUsersource($objLeightweightGroup->getStrSubsystem());
     $objPlainGroup = $objSubsystem->getGroupById($objLeightweightGroup->getSystemid());
     return $objPlainGroup;
 }
 /**
  * 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;
 }
Пример #12
0
 /**
  * Removes the elements / modules handled by the current installer.
  * Use the reference param to add a human readable logging.
  *
  * @param string &$strReturn
  *
  * @return bool
  */
 public function remove(&$strReturn)
 {
     //remove the workflow
     if (class_module_system_module::getModuleByName("workflows") !== null) {
         foreach (class_module_workflows_workflow::getWorkflowsForClass("class_workflow_ldap_sync") as $objOneWorkflow) {
             if (!$objOneWorkflow->deleteObjectFromDatabase()) {
                 $strReturn .= "Error deleting workflow, aborting.\n";
                 return false;
             }
         }
         $objHandler = class_module_workflows_handler::getHandlerByClass("class_workflow_ldap_sync");
         if (!$objHandler->deleteObjectFromDatabase()) {
             $strReturn .= "Error deleting workflow handler, aborting.\n";
             return false;
         }
     }
     //fetch associated users
     foreach ($this->objDB->getPArray("SELECT * FROM " . _dbprefix_ . "user_ldap", array()) as $arrOneRow) {
         $objOneUser = new class_module_user_user($arrOneRow["user_ldap_id"]);
         echo "Deleting ldap user " . $objOneUser->getStrDisplayName() . "...\n";
         $objOneUser->deleteObjectFromDatabase();
     }
     //fetch associated groups
     foreach ($this->objDB->getPArray("SELECT * FROM " . _dbprefix_ . "user_group_ldap", array()) as $arrOneRow) {
         $objOneUser = new class_module_user_group($arrOneRow["group_ldap_id"]);
         echo "Deleting ldap group " . $objOneUser->getStrDisplayName() . "...\n";
         $objOneUser->deleteObjectFromDatabase();
     }
     //delete the module-node
     $strReturn .= "Deleting the module-registration...\n";
     $objModule = class_module_system_module::getModuleByName($this->objMetadata->getStrTitle(), true);
     if (!$objModule->deleteObjectFromDatabase()) {
         $strReturn .= "Error deleting module, aborting.\n";
         return false;
     }
     //delete the tables
     foreach (array("user_group_ldap", "user_ldap") as $strOneTable) {
         $strReturn .= "Dropping table " . $strOneTable . "...\n";
         if (!$this->objDB->_pQuery("DROP TABLE " . $this->objDB->encloseTableName(_dbprefix_ . $strOneTable) . "", array())) {
             $strReturn .= "Error deleting table, aborting.\n";
             return false;
         }
     }
     return true;
 }
 /**
  * Creates a form to collect a users data
  *
  * @return string
  */
 private function editUserData()
 {
     $arrErrors = array();
     $bitForm = true;
     //what to do?
     if ($this->getParam("submitUserForm") != "") {
         $objTextValidator = new class_text_validator();
         $objEmailValidator = new class_email_validator();
         if ($this->getParam("password") == "" || $this->getParam("password") != $this->getParam("password2")) {
             $arrErrors[] = $this->getLang("pr_passwordsUnequal");
         }
         if (!$objTextValidator->validate($this->getParam("username"))) {
             $arrErrors[] = $this->getLang("pr_noUsername");
         }
         //username already existing?
         if ($objTextValidator->validate($this->getParam("username")) && count(class_module_user_user::getAllUsersByName($this->getParam("username"))) > 0) {
             $arrErrors[] = $this->getLang("pr_usernameGiven");
         }
         if (!$objEmailValidator->validate($this->getParam("email"))) {
             $arrErrors[] = $this->getLang("pr_invalidEmailadress");
         }
         //Check captachcode
         if ($this->getParam("form_captcha") == "" || $this->getParam("form_captcha") != $this->objSession->getCaptchaCode()) {
             $arrErrors[] = $this->getLang("pr_captcha");
         }
         if (count($arrErrors) == 0) {
             $bitForm = false;
         }
     }
     if ($bitForm) {
         $strTemplateID = $this->objTemplate->readTemplate("/element_portalregistration/" . $this->arrElementData["portalregistration_template"], "portalregistration_userdataform");
         $arrTemplate = array();
         $arrTemplate["username"] = $this->getParam("username");
         $arrTemplate["email"] = $this->getParam("email");
         $arrTemplate["forename"] = $this->getParam("forename");
         $arrTemplate["name"] = $this->getParam("name");
         $arrTemplate["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "portalCreateAccount");
         $arrTemplate["formErrors"] = "";
         if (count($arrErrors) > 0) {
             foreach ($arrErrors as $strOneError) {
                 $strErrTemplate = $this->objTemplate->readTemplate("/element_portalregistration/" . $this->arrElementData["portalregistration_template"], "errorRow");
                 $arrTemplate["formErrors"] .= "" . $this->fillTemplate(array("error" => $strOneError), $strErrTemplate);
             }
         }
         return $this->fillTemplate($arrTemplate, $strTemplateID);
     } else {
         //create new user, inactive
         $objUser = new class_module_user_user();
         $objUser->setStrUsername($this->getParam("username"));
         $objUser->setIntActive(0);
         $objUser->setIntAdmin(0);
         $objUser->setIntPortal(1);
         $objUser->setStrSubsystem("kajona");
         $strAuthcode = generateSystemid();
         $objUser->setStrAuthcode($strAuthcode);
         if ($objUser->updateObjectToDb()) {
             $objSourceuser = $objUser->getObjSourceUser();
             $objSourceuser->setStrEmail($this->getParam("email"));
             $objSourceuser->setStrForename($this->getParam("forename"));
             $objSourceuser->setStrName($this->getParam("name"));
             $objSourceuser->setStrPass($this->getParam("password"));
             $objSourceuser->updateObjectToDb();
             //group assignments
             $objGroup = new class_module_user_group($this->arrElementData["portalregistration_group"]);
             $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser());
             //and to the guests to avoid conflicts
             $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_guests_group_id_"));
             $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser());
             //create a mail to allow the user to activate itself
             $strMailContent = $this->getLang("pr_email_body");
             $strTemp = getLinkPortalHref($this->getPagename(), "", "portalCompleteRegistration", "&authcode=" . $strAuthcode, $objUser->getSystemid());
             $strMailContent .= html_entity_decode("<a href=\"" . $strTemp . "\">" . $strTemp . "</a>");
             $strMailContent .= $this->getLang("pr_email_footer");
             $objScriptlets = new class_scriptlet_helper();
             $strMailContent = $objScriptlets->processString($strMailContent);
             $objMail = new class_mail();
             $objMail->setSubject($this->getLang("pr_email_subject"));
             $objMail->setHtml($strMailContent);
             $objMail->addTo($this->getParam("email"));
             $objMail->sendMail();
         }
         return $this->getLang("pr_register_suc");
     }
 }
 /**
  * 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 "";
 }
 /**
  * @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;
 }
Пример #16
0
 public function testInheritanceForObjects()
 {
     if (class_module_system_module::getModuleByName("pages") === null) {
         return;
     }
     echo "\tRIGHTS INHERITANCE...\n";
     $objRights = class_carrier::getInstance()->getObjRights();
     $this->objRights = class_carrier::getInstance()->getObjRights();
     //create a new user & group to be used during testing
     echo "\tcreating a test user\n";
     $objUser = new class_module_user_user();
     $strUsername = "******" . generateSystemid();
     $objUser->setStrUsername($strUsername);
     $objUser->updateObjectToDb();
     echo "\tid of user: "******"\n";
     $this->strUserId = $objUser->getSystemid();
     echo "\tcreating a test group\n";
     $objGroup = new class_module_user_group();
     $strName = "name_" . generateSystemid();
     $objGroup->setStrName($strName);
     $objGroup->updateObjectToDb();
     echo "\tid of group: " . $objGroup->getSystemid() . "\n";
     echo "\tadding user to group\n";
     $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser());
     $strModuleId = $this->createObject("class_module_system_module", "0")->getSystemid();
     class_carrier::getInstance()->flushCache(class_carrier::INT_CACHE_TYPE_MODULES);
     class_module_system_module::getAllModules();
     echo "\tcreating node-tree\n";
     $strRootId = $this->createObject("class_module_pages_page", $strModuleId)->getSystemid();
     echo "\tid of root-node: " . $strRootId . "\n";
     echo "\tcreating child nodes...\n";
     $strSecOne = $this->createObject("class_module_pages_page", $strRootId)->getSystemid();
     $strSecTwo = $this->createObject("class_module_pages_page", $strRootId)->getSystemid();
     $strThirdOne1 = $this->createObject("class_module_pages_page", $strSecOne)->getSystemid();
     $strThirdOne2 = $this->createObject("class_module_pages_page", $strSecOne)->getSystemid();
     $strThirdTwo1 = $this->createObject("class_module_pages_page", $strSecTwo)->getSystemid();
     $strThirdTwo2 = $this->createObject("class_module_pages_page", $strSecTwo)->getSystemid();
     $strThird111 = $this->createObject("class_module_pages_page", $strThirdOne1)->getSystemid();
     $strThird112 = $this->createObject("class_module_pages_page", $strThirdOne1)->getSystemid();
     $strThird121 = $this->createObject("class_module_pages_page", $strThirdOne2)->getSystemid();
     $strThird122 = $this->createObject("class_module_pages_page", $strThirdOne2)->getSystemid();
     $strThird211 = $this->createObject("class_module_pages_page", $strThirdTwo1)->getSystemid();
     $strThird212 = $this->createObject("class_module_pages_page", $strThirdTwo1)->getSystemid();
     $strThird221 = $this->createObject("class_module_pages_page", $strThirdTwo2)->getSystemid();
     $strThird222 = $this->createObject("class_module_pages_page", $strThirdTwo2)->getSystemid();
     $arrThirdLevelNodes = array($strThird111, $strThird112, $strThird121, $strThird122, $strThird211, $strThird212, $strThird221, $strThird222);
     echo "\tchecking leaf nodes for initial rights\n";
     foreach ($arrThirdLevelNodes as $strOneRootNode) {
         $this->checkNodeRights($strOneRootNode, false, false);
     }
     echo "\tadding group with right view & edit\n";
     $objRights->addGroupToRight($objGroup->getSystemid(), $strModuleId, "view");
     $objRights->addGroupToRight($objGroup->getSystemid(), $strModuleId, "edit");
     echo "\tchecking leaf nodes for inherited rights\n";
     foreach ($arrThirdLevelNodes as $strOneRootNode) {
         $this->checkNodeRights($strOneRootNode, true, true);
     }
     echo "\tremoving right view from node secTwo\n";
     $objRights->removeGroupFromRight($objGroup->getSystemid(), $strSecTwo, "view");
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, true, true);
     $this->checkNodeRights($strSecTwo, false, true);
     $this->checkNodeRights($strThirdOne1, true, true);
     $this->checkNodeRights($strThirdOne2, true, true);
     $this->checkNodeRights($strThirdTwo1, false, true);
     $this->checkNodeRights($strThirdTwo2, false, true);
     $this->checkNodeRights($strThird111, true, true);
     $this->checkNodeRights($strThird112, true, true);
     $this->checkNodeRights($strThird121, true, true);
     $this->checkNodeRights($strThird122, true, true);
     $this->checkNodeRights($strThird211, false, true);
     $this->checkNodeRights($strThird212, false, true);
     $this->checkNodeRights($strThird221, false, true);
     $this->checkNodeRights($strThird222, false, true);
     echo "\tmove SecOne as child to 221\n";
     $objTempCommons = class_objectfactory::getInstance()->getObject($strSecOne);
     $objTempCommons->setStrPrevId($strThird221);
     $objTempCommons->updateObjectToDb();
     //$objSystemCommon->setPrevId($strThird221, $strSecOne);
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, false, true);
     $this->checkNodeRights($strSecTwo, false, true);
     $this->checkNodeRights($strThirdOne1, false, true);
     $this->checkNodeRights($strThirdOne2, false, true);
     $this->checkNodeRights($strThirdTwo1, false, true);
     $this->checkNodeRights($strThirdTwo2, false, true);
     $this->checkNodeRights($strThird111, false, true);
     $this->checkNodeRights($strThird112, false, true);
     $this->checkNodeRights($strThird121, false, true);
     $this->checkNodeRights($strThird122, false, true);
     $this->checkNodeRights($strThird211, false, true);
     $this->checkNodeRights($strThird212, false, true);
     $this->checkNodeRights($strThird221, false, true);
     $this->checkNodeRights($strThird222, false, true);
     echo "\tsetting rights of third21 to only view\n";
     $objRights->removeGroupFromRight($objGroup->getSystemid(), $strThirdTwo1, "edit");
     $objRights->addGroupToRight($objGroup->getSystemid(), $strThirdTwo1, "view");
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, false, true);
     $this->checkNodeRights($strSecTwo, false, true);
     $this->checkNodeRights($strThirdOne1, false, true);
     $this->checkNodeRights($strThirdOne2, false, true);
     $this->checkNodeRights($strThirdTwo1, true);
     $this->checkNodeRights($strThirdTwo2, false, true);
     $this->checkNodeRights($strThird111, false, true);
     $this->checkNodeRights($strThird112, false, true);
     $this->checkNodeRights($strThird121, false, true);
     $this->checkNodeRights($strThird122, false, true);
     $this->checkNodeRights($strThird211, true);
     $this->checkNodeRights($strThird212, true);
     $this->checkNodeRights($strThird221, false, true);
     $this->checkNodeRights($strThird222, false, true);
     echo "\tsetting 211 as parent node for third11\n";
     $objTempCommons = class_objectfactory::getInstance()->getObject($strThirdOne1);
     $objTempCommons->setStrPrevId($strThird211);
     $objTempCommons->updateObjectToDb();
     //$objSystemCommon->setPrevId($strThird211, $strThirdOne1);
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, false, true);
     $this->checkNodeRights($strSecTwo, false, true);
     $this->checkNodeRights($strThirdOne1, true);
     $this->checkNodeRights($strThirdOne2, false, true);
     $this->checkNodeRights($strThirdTwo1, true);
     $this->checkNodeRights($strThirdTwo2, false, true);
     $this->checkNodeRights($strThird111, true);
     $this->checkNodeRights($strThird112, true);
     $this->checkNodeRights($strThird121, false, true);
     $this->checkNodeRights($strThird122, false, true);
     $this->checkNodeRights($strThird211, true);
     $this->checkNodeRights($strThird212, true);
     $this->checkNodeRights($strThird221, false, true);
     $this->checkNodeRights($strThird222, false, true);
     echo "\trebuilding initial tree structure\n";
     $objTempCommons = class_objectfactory::getInstance()->getObject($strSecOne);
     $objTempCommons->setStrPrevId($strRootId);
     $objTempCommons->updateObjectToDb();
     //$objSystemCommon->setPrevId($strRootId, $strSecOne); //SecOne still inheriting
     $objTempCommons = class_objectfactory::getInstance()->getObject($strThirdOne1);
     $objTempCommons->setStrPrevId($strSecOne);
     $objTempCommons->updateObjectToDb();
     //$objSystemCommon->setPrevId($strSecOne, $strThirdOne1);
     $objRights->setInherited(true, $strThirdOne1);
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, true, true);
     $this->checkNodeRights($strSecTwo, false, true);
     $this->checkNodeRights($strThirdOne1, true, true);
     $this->checkNodeRights($strThirdOne2, true, true);
     $this->checkNodeRights($strThirdTwo1, true);
     $this->checkNodeRights($strThirdTwo2, false, true);
     $this->checkNodeRights($strThird111, true, true);
     $this->checkNodeRights($strThird112, true, true);
     $this->checkNodeRights($strThird121, true, true);
     $this->checkNodeRights($strThird122, true, true);
     $this->checkNodeRights($strThird211, true);
     $this->checkNodeRights($strThird212, true);
     $this->checkNodeRights($strThird221, false, true);
     $this->checkNodeRights($strThird222, false, true);
     echo "\trebuilding initial inheritance structure\n";
     $objRights->setInherited(true, $strSecTwo);
     $objRights->setInherited(true, $strThirdTwo1);
     echo "\tchecking node rights\n";
     $this->checkNodeRights($strRootId, true, true);
     $this->checkNodeRights($strSecOne, true, true);
     $this->checkNodeRights($strSecTwo, true, true);
     $this->checkNodeRights($strThirdOne1, true, true);
     $this->checkNodeRights($strThirdOne2, true, true);
     $this->checkNodeRights($strThirdTwo1, true, true);
     $this->checkNodeRights($strThirdTwo2, true, true);
     $this->checkNodeRights($strThird111, true, true);
     $this->checkNodeRights($strThird112, true, true);
     $this->checkNodeRights($strThird121, true, true);
     $this->checkNodeRights($strThird122, true, true);
     $this->checkNodeRights($strThird211, true, true);
     $this->checkNodeRights($strThird212, true, true);
     $this->checkNodeRights($strThird221, true, true);
     $this->checkNodeRights($strThird222, true, true);
     echo "\tdeleting systemnodes\n";
     class_objectfactory::getInstance()->getObject($strThird111)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird112)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird121)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird122)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird211)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird212)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird221)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThird222)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThirdOne1)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThirdOne2)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThirdTwo1)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strThirdTwo2)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strSecOne)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strSecTwo)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strRootId)->deleteObjectFromDatabase();
     class_objectfactory::getInstance()->getObject($strModuleId)->deleteObjectFromDatabase();
     echo "\tdeleting the test user\n";
     $objUser->deleteObjectFromDatabase();
     echo "\tdeleting the test group\n";
     $objGroup->deleteObjectFromDatabase();
 }
Пример #17
0
 public function install()
 {
     $strReturn = "";
     $objManager = new class_orm_schemamanager();
     // System table ---------------------------------------------------------------------------------
     $strReturn .= "Installing table system...\n";
     $arrFields = array();
     $arrFields["system_id"] = array("char20", false);
     $arrFields["system_prev_id"] = array("char20", false);
     $arrFields["system_module_nr"] = array("int", false);
     $arrFields["system_sort"] = array("int", true);
     $arrFields["system_owner"] = array("char20", true);
     $arrFields["system_create_date"] = array("long", true);
     $arrFields["system_lm_user"] = array("char20", true);
     $arrFields["system_lm_time"] = array("int", true);
     $arrFields["system_lock_id"] = array("char20", true);
     $arrFields["system_lock_time"] = array("int", true);
     $arrFields["system_status"] = array("int", true);
     $arrFields["system_class"] = array("char254", true);
     $arrFields["system_comment"] = array("char254", true);
     $arrFields["system_deleted"] = array("int", true);
     if (!$this->objDB->createTable("system", $arrFields, array("system_id"), array("system_prev_id", "system_module_nr", "system_sort", "system_owner", "system_create_date", "system_status", "system_lm_time", "system_lock_time", "system_deleted"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     //Rights table ----------------------------------------------------------------------------------
     $strReturn .= "Installing table system_right...\n";
     $arrFields = array();
     $arrFields["right_id"] = array("char20", false);
     $arrFields["right_inherit"] = array("int", true);
     $arrFields["right_view"] = array("text", true);
     $arrFields["right_edit"] = array("text", true);
     $arrFields["right_delete"] = array("text", true);
     $arrFields["right_right"] = array("text", true);
     $arrFields["right_right1"] = array("text", true);
     $arrFields["right_right2"] = array("text", true);
     $arrFields["right_right3"] = array("text", true);
     $arrFields["right_right4"] = array("text", true);
     $arrFields["right_right5"] = array("text", true);
     $arrFields["right_changelog"] = array("text", true);
     if (!$this->objDB->createTable("system_right", $arrFields, array("right_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // Modul table ----------------------------------------------------------------------------------
     $strReturn .= "Installing table system_module...\n";
     $objManager->createTable("class_module_system_module");
     // Date table -----------------------------------------------------------------------------------
     $strReturn .= "Installing table system_date...\n";
     $arrFields = array();
     $arrFields["system_date_id"] = array("char20", false);
     $arrFields["system_date_start"] = array("long", true);
     $arrFields["system_date_end"] = array("long", true);
     $arrFields["system_date_special"] = array("long", true);
     if (!$this->objDB->createTable("system_date", $arrFields, array("system_date_id"), array("system_date_start", "system_date_end", "system_date_special"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // Config table ---------------------------------------------------------------------------------
     $strReturn .= "Installing table system_config...\n";
     $arrFields = array();
     $arrFields["system_config_id"] = array("char20", false);
     $arrFields["system_config_name"] = array("char254", true);
     $arrFields["system_config_value"] = array("char254", true);
     $arrFields["system_config_type"] = array("int", true);
     $arrFields["system_config_module"] = array("int", true);
     if (!$this->objDB->createTable("system_config", $arrFields, array("system_config_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // User table -----------------------------------------------------------------------------------
     $strReturn .= "Installing table user...\n";
     $arrFields = array();
     $arrFields["user_id"] = array("char20", false);
     $arrFields["user_username"] = array("char254", true);
     $arrFields["user_subsystem"] = array("char254", true);
     $arrFields["user_logins"] = array("int", true);
     $arrFields["user_lastlogin"] = array("int", true);
     $arrFields["user_active"] = array("int", true);
     $arrFields["user_admin"] = array("int", true);
     $arrFields["user_portal"] = array("int", true);
     $arrFields["user_deleted"] = array("int", true);
     $arrFields["user_admin_skin"] = array("char254", true);
     $arrFields["user_admin_language"] = array("char254", true);
     $arrFields["user_admin_module"] = array("char254", true);
     $arrFields["user_authcode"] = array("char20", true);
     $arrFields["user_items_per_page"] = array("int", true);
     if (!$this->objDB->createTable("user", $arrFields, array("user_id"), array("user_username", "user_subsystem", "user_active", "user_deleted"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // User table kajona subsystem  -----------------------------------------------------------------
     $strReturn .= "Installing table user_kajona...\n";
     $arrFields = array();
     $arrFields["user_id"] = array("char20", false);
     $arrFields["user_pass"] = array("char254", true);
     $arrFields["user_salt"] = array("char20", true);
     $arrFields["user_email"] = array("char254", true);
     $arrFields["user_forename"] = array("char254", true);
     $arrFields["user_name"] = array("char254", true);
     $arrFields["user_street"] = array("char254", true);
     $arrFields["user_postal"] = array("char254", true);
     $arrFields["user_city"] = array("char254", true);
     $arrFields["user_tel"] = array("char254", true);
     $arrFields["user_mobile"] = array("char254", true);
     $arrFields["user_date"] = array("long", true);
     if (!$this->objDB->createTable("user_kajona", $arrFields, array("user_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // User group table -----------------------------------------------------------------------------
     $strReturn .= "Installing table user_group...\n";
     $arrFields = array();
     $arrFields["group_id"] = array("char20", false);
     $arrFields["group_name"] = array("char254", true);
     $arrFields["group_subsystem"] = array("char254", true);
     if (!$this->objDB->createTable("user_group", $arrFields, array("group_id"), array("group_name", "group_subsystem"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     $strReturn .= "Installing table user_group_kajona...\n";
     $arrFields = array();
     $arrFields["group_id"] = array("char20", false);
     $arrFields["group_desc"] = array("char254", true);
     if (!$this->objDB->createTable("user_group_kajona", $arrFields, array("group_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // User group_members table ---------------------------------------------------------------------
     $strReturn .= "Installing table user_kajona_members...\n";
     $arrFields = array();
     $arrFields["group_member_group_kajona_id"] = array("char20", false);
     $arrFields["group_member_user_kajona_id"] = array("char20", false);
     if (!$this->objDB->createTable("user_kajona_members", $arrFields, array("group_member_group_kajona_id", "group_member_user_kajona_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // User log table -------------------------------------------------------------------------------
     $strReturn .= "Installing table user_log...\n";
     $arrFields = array();
     $arrFields["user_log_id"] = array("char20", false);
     $arrFields["user_log_userid"] = array("char254", true);
     $arrFields["user_log_date"] = array("long", true);
     $arrFields["user_log_status"] = array("int", true);
     $arrFields["user_log_ip"] = array("char20", true);
     $arrFields["user_log_sessid"] = array("char20", true);
     $arrFields["user_log_enddate"] = array("long", true);
     if (!$this->objDB->createTable("user_log", $arrFields, array("user_log_id"), array("user_log_sessid"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // Sessionmgtm ----------------------------------------------------------------------------------
     $strReturn .= "Installing table session...\n";
     $arrFields = array();
     $arrFields["session_id"] = array("char20", false);
     $arrFields["session_phpid"] = array("char254", true);
     $arrFields["session_userid"] = array("char20", true);
     $arrFields["session_groupids"] = array("text", true);
     $arrFields["session_releasetime"] = array("int", true);
     $arrFields["session_loginstatus"] = array("char254", true);
     $arrFields["session_loginprovider"] = array("char20", true);
     $arrFields["session_lasturl"] = array("char500", true);
     if (!$this->objDB->createTable("session", $arrFields, array("session_id"), array("session_phpid", "session_releasetime", "session_userid"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     // caching --------------------------------------------------------------------------------------
     $strReturn .= "Installing table cache...\n";
     $arrFields = array();
     $arrFields["cache_id"] = array("char20", false);
     $arrFields["cache_source"] = array("char254", true);
     $arrFields["cache_hash1"] = array("char254", true);
     $arrFields["cache_hash2"] = array("char254", true);
     $arrFields["cache_language"] = array("char20", true);
     $arrFields["cache_content"] = array("longtext", true);
     $arrFields["cache_leasetime"] = array("int", true);
     $arrFields["cache_hits"] = array("int", true);
     if (!$this->objDB->createTable("cache", $arrFields, array("cache_id"), array("cache_source", "cache_hash1", "cache_leasetime", "cache_language"), false)) {
         $strReturn .= "An error occurred! ...\n";
     }
     //languages -------------------------------------------------------------------------------------
     $strReturn .= "Installing table languages...\n";
     $objManager->createTable("class_module_languages_language");
     $strReturn .= "Installing table languages_languageset...\n";
     $arrFields = array();
     $arrFields["languageset_id"] = array("char20", false);
     $arrFields["languageset_language"] = array("char20", true);
     $arrFields["languageset_systemid"] = array("char20", true);
     if (!$this->objDB->createTable("languages_languageset", $arrFields, array("languageset_id", "languageset_systemid"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     //aspects --------------------------------------------------------------------------------------
     $strReturn .= "Installing table aspects...\n";
     $objManager->createTable("class_module_system_aspect");
     //changelog -------------------------------------------------------------------------------------
     $strReturn .= "Installing table changelog...\n";
     $this->installChangeTables();
     //messages
     $strReturn .= "Installing table messages...\n";
     $objManager->createTable("class_module_messaging_message");
     $objManager->createTable("class_module_messaging_config");
     //Now we have to register module by module
     //The Systemkernel
     $this->registerModule("system", _system_modul_id_, "", "class_module_system_admin.php", $this->objMetadata->getStrVersion(), true, "", "class_module_system_admin_xml.php");
     //The Rightsmodule
     $this->registerModule("right", _system_modul_id_, "", "class_module_right_admin.php", $this->objMetadata->getStrVersion(), false);
     //The Usermodule
     $this->registerModule("user", _user_modul_id_, "", "class_module_user_admin.php", $this->objMetadata->getStrVersion(), true);
     //languages
     $this->registerModule("languages", _languages_modul_id_, "class_modul_languages_portal.php", "class_module_languages_admin.php", $this->objMetadata->getStrVersion(), true);
     //messaging
     $this->registerModule("messaging", _messaging_module_id_, "", "class_module_messaging_admin.php", $this->objMetadata->getStrVersion(), true);
     //Registering a few constants
     $strReturn .= "Registering system-constants...\n";
     //And the default skin
     $this->registerConstant("_admin_skin_default_", "kajona_v4", class_module_system_setting::$int_TYPE_STRING, _user_modul_id_);
     //and a few system-settings
     $this->registerConstant("_system_portal_disable_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_);
     $this->registerConstant("_system_portal_disablepage_", "", class_module_system_setting::$int_TYPE_PAGE, _system_modul_id_);
     //New in 3.0: Number of db-dumps to hold
     $this->registerConstant("_system_dbdump_amount_", 5, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     //new in 3.0: mod-rewrite on / off
     $this->registerConstant("_system_mod_rewrite_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_);
     //New Constant: Max time to lock records
     $this->registerConstant("_system_lock_maxtime_", 7200, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     //Email to send error-reports
     $this->registerConstant("_system_admin_email_", $this->objSession->getSession("install_email"), class_module_system_setting::$int_TYPE_STRING, _system_modul_id_);
     $this->registerConstant("_system_email_defaultsender_", $this->objSession->getSession("install_email"), class_module_system_setting::$int_TYPE_STRING, _system_modul_id_);
     $this->registerConstant("_system_email_forcesender_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_);
     //3.0.2: user are allowed to change their settings?
     $this->registerConstant("_user_selfedit_", "true", class_module_system_setting::$int_TYPE_BOOL, _user_modul_id_);
     //3.1: nr of rows in admin
     $this->registerConstant("_admin_nr_of_rows_", 15, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     $this->registerConstant("_admin_only_https_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_);
     //3.1: remoteloader max cachtime --> default 60 min
     $this->registerConstant("_remoteloader_max_cachetime_", 60 * 60, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     //3.2: max session duration
     $this->registerConstant("_system_release_time_", 3600, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     //3.4: cache buster to be able to flush the browsers cache (JS and CSS files)
     $this->registerConstant("_system_browser_cachebuster_", 0, class_module_system_setting::$int_TYPE_INT, _system_modul_id_);
     //3.4: Adding constant _system_graph_type_ indicating the chart-engine to use
     $this->registerConstant("_system_graph_type_", "jqplot", class_module_system_setting::$int_TYPE_STRING, _system_modul_id_);
     //3.4: Enabling or disabling the internal changehistory
     $this->registerConstant("_system_changehistory_enabled_", "false", class_module_system_setting::$int_TYPE_BOOL, _system_modul_id_);
     $this->registerConstant("_system_timezone_", "", class_module_system_setting::$int_TYPE_STRING, _system_modul_id_);
     //Creating the admin & guest groups
     $objAdminGroup = new class_module_user_group();
     $objAdminGroup->setStrName("Admins");
     $objAdminGroup->updateObjectToDb();
     $strReturn .= "Registered Group Admins...\n";
     $objGuestGroup = new class_module_user_group();
     $objGuestGroup->setStrName("Guests");
     $objGuestGroup->updateObjectToDb();
     $strReturn .= "Registered Group Guests...\n";
     //Systemid of guest-user & admin group
     $strGuestID = $objGuestGroup->getSystemid();
     $strAdminID = $objAdminGroup->getSystemid();
     $this->registerConstant("_guests_group_id_", $strGuestID, class_module_system_setting::$int_TYPE_STRING, _user_modul_id_);
     $this->registerConstant("_admins_group_id_", $strAdminID, class_module_system_setting::$int_TYPE_STRING, _user_modul_id_);
     //Create an root-record for the tree
     //So, lets generate the record
     $strQuery = "INSERT INTO " . _dbprefix_ . "system\n                     ( system_id, system_prev_id, system_module_nr, system_create_date, system_lm_time, system_status, system_sort, system_class) VALUES\n                     (?, ?, ?, ?, ?, ?, ?, ?)";
     //Send the query to the db
     $this->objDB->_pQuery($strQuery, array(0, 0, _system_modul_id_, class_date::getCurrentTimestamp(), time(), 1, 1, "class_module_system_common"));
     //BUT: We have to modify the right-record of the root node, too
     $strGroupsAll = $strGuestID . "," . $strAdminID;
     $strGroupsAdmin = $strAdminID;
     $strQuery = "INSERT INTO " . _dbprefix_ . "system_right\n            (right_id, right_inherit, right_view, right_edit, right_delete, right_right, right_right1, right_right2, right_right3, right_right4, right_right5, right_changelog) VALUES\n            (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $this->objDB->_pQuery($strQuery, array(0, 0, $strGroupsAll, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin, $strGroupsAdmin));
     $this->objDB->flushQueryCache();
     $strReturn .= "Modified root-rights....\n";
     class_carrier::getInstance()->getObjRights()->rebuildRightsStructure();
     $strReturn .= "Rebuilt rights structures...\n";
     //Creating an admin-user
     $strUsername = "******";
     $strPassword = "******";
     $strEmail = "";
     //Login-Data given from installer?
     if ($this->objSession->getSession("install_username") !== false && $this->objSession->getSession("install_username") != "" && $this->objSession->getSession("install_password") !== false && $this->objSession->getSession("install_password") != "") {
         $strUsername = $this->objSession->getSession("install_username");
         $strPassword = $this->objSession->getSession("install_password");
         $strEmail = $this->objSession->getSession("install_email");
     }
     //create a default language
     $strReturn .= "Creating new default-language\n";
     $objLanguage = new class_module_languages_language();
     if ($this->strContentLanguage == "de") {
         $objLanguage->setStrName("de");
     } else {
         $objLanguage->setStrName("en");
     }
     $objLanguage->setBitDefault(true);
     $objLanguage->updateObjectToDb();
     $strReturn .= "ID of new language: " . $objLanguage->getSystemid() . "\n";
     //the admin-language
     $strAdminLanguage = $this->objSession->getAdminLanguage();
     //creating a new default-aspect
     $strReturn .= "Registering new default aspects...\n";
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("content");
     $objAspect->setBitDefault(true);
     $objAspect->updateObjectToDb();
     class_module_system_aspect::setCurrentAspectId($objAspect->getSystemid());
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("management");
     $objAspect->updateObjectToDb();
     $objUser = new class_module_user_user();
     $objUser->setStrUsername($strUsername);
     $objUser->setIntActive(1);
     $objUser->setIntAdmin(1);
     $objUser->setStrAdminlanguage($strAdminLanguage);
     $objUser->updateObjectToDb();
     $objUser->getObjSourceUser()->setStrPass($strPassword);
     $objUser->getObjSourceUser()->setStrEmail($strEmail);
     $objUser->getObjSourceUser()->updateObjectToDb();
     $strReturn .= "Created User Admin: <strong>Username: "******", Password: ***********</strong> ...\n";
     //The Admin should belong to the admin-Group
     $objAdminGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser());
     $strReturn .= "Registered Admin in Admin-Group...\n";
     $strReturn .= "Assigning modules to default aspects...\n";
     $objModule = class_module_system_module::getModuleByName("system");
     $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid());
     $objModule->updateObjectToDb();
     $objModule = class_module_system_module::getModuleByName("user");
     $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid());
     $objModule->updateObjectToDb();
     $objModule = class_module_system_module::getModuleByName("languages");
     $objModule->setStrAspect(class_module_system_aspect::getAspectByName("management")->getSystemid());
     $objModule->updateObjectToDb();
     $strReturn .= "Trying to copy the *.root files to top-level...\n";
     $arrFiles = array("index.php", "image.php", "xml.php", ".htaccess", "v3_v4_postupdate.php");
     foreach ($arrFiles as $strOneFile) {
         if (!file_exists(_realpath_ . "/" . $strOneFile) && is_file(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/" . $strOneFile . ".root")) {
             if (!copy(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/" . $strOneFile . ".root", _realpath_ . "/" . $strOneFile)) {
                 $strReturn .= "<b>Copying " . $strOneFile . ".root to top level failed!!!</b>";
             }
         }
     }
     $strReturn .= "Setting messaging to pos 1 in navigation.../n";
     $objModule = class_module_system_module::getModuleByName("messaging");
     $objModule->setAbsolutePosition(1);
     return $strReturn;
 }
Пример #18
0
 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");
 }
 /**
  * @return class_module_user_user[]
  */
 private function loadUserlist()
 {
     //load all users given
     $arrUser = array();
     if (validateSystemid($this->arrElementData["char2"])) {
         $objGroup = new class_module_user_group($this->arrElementData["char2"]);
         $arrUserId = $objGroup->getObjSourceGroup()->getUserIdsForGroup();
         foreach ($arrUserId as $strOneUser) {
             $arrUser[] = new class_module_user_user($strOneUser);
         }
     } else {
         $arrUser = class_module_user_user::getObjectList();
     }
     //filter against inactive?
     $arrUserFinal = array();
     if ($this->arrElementData["int1"] == "1") {
         foreach ($arrUser as $objOneUser) {
             if ($objOneUser->getIntActive() == "1") {
                 $arrUserFinal[] = $objOneUser;
             }
         }
     } else {
         if ($this->arrElementData["int1"] == "2") {
             foreach ($arrUser as $objOneUser) {
                 if ($objOneUser->getIntActive() == "0") {
                     $arrUserFinal[] = $objOneUser;
                 }
             }
         } else {
             $arrUserFinal = $arrUser;
         }
     }
     return $arrUserFinal;
 }
 /**
  * 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;
 }
Пример #21
0
 public function testLockBetweenUsers()
 {
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("test");
     $objAspect->updateObjectToDb();
     $strAspectId = $objAspect->getSystemid();
     $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue(!$objAspect->getLockManager()->isLocked());
     $objUser1 = new class_module_user_user();
     $objUser1->setStrUsername(generateSystemid());
     $objUser1->setIntActive(1);
     $objUser1->updateObjectToDb();
     $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser1));
     $objAspect->getLockManager()->lockRecord();
     $this->assertEquals($objUser1->getSystemid(), $objAspect->getLockManager()->getLockId());
     $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue($objAspect->getLockManager()->isLocked());
     $this->assertTrue($objAspect->getLockManager()->isLockedByCurrentUser());
     $objUser2 = new class_module_user_user();
     $objUser2->setStrUsername(generateSystemid());
     $objUser2->setIntActive(1);
     $objUser2->updateObjectToDb();
     $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser2));
     $this->assertTrue(!$objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue($objAspect->getLockManager()->isLocked());
     $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser());
     //updates should release the lock
     $objException = null;
     try {
         $objAspect->updateObjectToDb();
     } catch (class_exception $objEx) {
         $objException = $objEx;
     }
     $this->assertNotNull($objException);
     //lock should remain
     $this->assertTrue(!$objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue($objAspect->getLockManager()->isLocked());
     $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser());
     $this->assertEquals($objUser1->getSystemid(), $objAspect->getLockManager()->getLockId());
     //unlocking is not allowed for user 2
     $this->assertTrue(!$objAspect->getLockManager()->unlockRecord());
     //force unlock not allowed since user is not in admin group
     $this->assertTrue($objAspect->getLockManager()->unlockRecord(true));
     //lock should remain
     $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue(!$objAspect->getLockManager()->isLocked());
     $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser());
     //add user 2 to admin group
     $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_"));
     $this->assertTrue($objGroup->getObjSourceGroup()->addMember($objUser2->getObjSourceUser()));
     //relogin
     $this->flushDBCache();
     $objUser2 = new class_module_user_user($objUser2->getSystemid());
     $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser2));
     //force unlock now allowed since user is not in admin group
     $this->assertTrue($objAspect->getLockManager()->unlockRecord(true));
     //lock should be gone
     $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser());
     $this->assertTrue(!$objAspect->getLockManager()->isLocked());
     $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser());
     class_carrier::getInstance()->getObjSession()->logout();
     $objAspect = new class_module_system_aspect($strAspectId);
     $objAspect->deleteObjectFromDatabase();
     $objUser1->deleteObjectFromDatabase();
     $objUser2->deleteObjectFromDatabase();
 }