/** * Creates a form in order to change the password - if the authcode is valid * * @return string */ protected function actionPwdReset() { $strReturn = ""; if (!validateSystemid($this->getParam("systemid"))) { return $this->getLang("login_change_error", "user"); } $objUser = new class_module_user_user($this->getParam("systemid")); if ($objUser->getStrAuthcode() != "" && $this->getParam("authcode") == $objUser->getStrAuthcode() && $objUser->getStrUsername() != "") { if ($this->getParam("reset") == "") { //Loading a small form to change the password $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "login_form"); $arrTemplate = array(); $strForm = ""; $strForm .= $this->objToolkit->getTextRow($this->getLang("login_password_form_intro", "user")); $strForm .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "pwdReset")); $strForm .= $this->objToolkit->formInputText("username", $this->getLang("login_loginUser", "user"), "", "inputTextShort"); $strForm .= $this->objToolkit->formInputPassword("password1", $this->getLang("login_loginPass", "user"), "", "inputTextShort"); $strForm .= $this->objToolkit->formInputPassword("password2", $this->getLang("login_loginPass2", "user"), "", "inputTextShort"); $strForm .= $this->objToolkit->formInputSubmit($this->getLang("login_changeButton", "user"), "", "", "inputSubmitShort"); $strForm .= $this->objToolkit->formInputHidden("reset", "reset"); $strForm .= $this->objToolkit->formInputHidden("authcode", $this->getParam("authcode")); $strForm .= $this->objToolkit->formInputHidden("systemid", $this->getParam("systemid")); $strForm .= $this->objToolkit->formClose(); $arrTemplate["form"] = $strForm; $arrTemplate["loginTitle"] = $this->getLang("login_loginTitle", "user"); $arrTemplate["loginJsInfo"] = $this->getLang("login_loginJsInfo", "user"); $arrTemplate["loginCookiesInfo"] = $this->getLang("login_loginCookiesInfo", "user"); //An error occurred? if ($this->getParam("loginerror") == 1) { $arrTemplate["error"] = $this->getLang("login_loginError", "user"); } $strReturn = $this->objTemplate->fillTemplate($arrTemplate, $strTemplateID); } else { //check the submitted passwords. $strPass1 = trim($this->getParam("password1")); $strPass2 = trim($this->getParam("password2")); if ($strPass1 == $strPass2 && checkText($strPass1, 3, 200) && $objUser->getStrUsername() == $this->getParam("username")) { if ($objUser->getObjSourceUser()->isPasswordResettable() && method_exists($objUser->getObjSourceUser(), "setStrPass")) { $objUser->getObjSourceUser()->setStrPass($strPass1); $objUser->getObjSourceUser()->updateObjectToDb(); } $objUser->setStrAuthcode(""); $objUser->updateObjectToDb(); class_logger::getInstance()->addLogRow("changed password of user " . $objUser->getStrUsername(), class_logger::$levelInfo); $strReturn .= $this->getLang("login_change_success", "user"); } else { $strReturn .= $this->getLang("login_change_error", "user"); } } } else { $strReturn .= $this->getLang("login_change_error", "user"); } return $strReturn; }
/** * 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 user exists and if it is the logged in user $objUser = new class_module_user_user($objValue); if ($objUser->getStrUsername() != "" && $objValue == class_carrier::getInstance()->getObjSession()->getUserID()) { return false; } return true; }
/** * 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; }
/** * @param array $arrErrors * * @return string * @permissions view,right1 */ protected function actionRegisterForEvent($arrErrors = array()) { $strReturn = ""; $objEvent = new class_module_eventmanager_event($this->getSystemid()); if ($objEvent->getIntLimitGiven() == "1" && $objEvent->getIntParticipantsLimit() <= class_module_eventmanager_participant::getActiveParticipantsCount($this->getSystemid())) { $strMessage = $this->getLang("participantLimitReached"); $strWrapperID = $this->objTemplate->readTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_register_message"); $strReturn = $this->objTemplate->fillTemplate(array("title" => $objEvent->getStrTitle(), "message" => $strMessage), $strWrapperID); return $strReturn; } $bitIsLoggedin = false; if ($this->objSession->isLoggedin() && $this->objTemplate->containsSection($this->objTemplate->readTemplate("/module_eventmanager/" . $this->arrElementData["char1"]), "event_register_loggedin")) { $bitIsLoggedin = true; if ($objEvent->isParticipant($this->objSession->getUserID())) { $objParticpant = class_module_eventmanager_participant::getParticipantByUserid($this->objSession->getUserID(), $objEvent->getSystemid()); $this->setParam("comment", $objParticpant->getStrComment()); $this->setParam("participant_status", $objParticpant->getIntParticipationStatus()); } } $objMapper = new class_template_mapper($objEvent); $objMapper->addPlaceholder("forename", $this->getParam("forename")); $objMapper->addPlaceholder("lastname", $this->getParam("lastname")); $objMapper->addPlaceholder("phone", $this->getParam("phone")); $objMapper->addPlaceholder("comment", $this->getParam("comment")); $objMapper->addPlaceholder("email", $this->getParam("email")); $objMapper->addPlaceholder("participant_status", $this->getParam("participant_status")); $objMapper->addPlaceholder("title", $objEvent->getStrTitle()); $objMapper->addPlaceholder("dateTimeFrom", dateToString($objEvent->getObjStartDate(), true)); $objMapper->addPlaceholder("dateFrom", dateToString($objEvent->getObjStartDate(), false)); $objMapper->addPlaceholder("dateTimeUntil", dateToString($objEvent->getObjEndDate(), true)); $objMapper->addPlaceholder("dateUntil", dateToString($objEvent->getObjEndDate(), false)); $objMapper->addPlaceholder("formaction", class_link::getLinkPortalHref($this->getPagename(), "", "saveRegisterForEvent", "", $this->getSystemid(), "", $objEvent->getStrTitle())); if ($bitIsLoggedin) { $objUser = new class_module_user_user($this->objSession->getUserID()); $objMapper->addPlaceholder("username", $objUser->getStrUsername()); } $strErrors = ""; if (count($arrErrors) > 0) { $strErrTemplate = $this->objTemplate->readTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "error_row"); foreach ($arrErrors as $strOneError) { $strErrors .= "" . $this->objTemplate->fillTemplate(array("error" => $strOneError), $strErrTemplate); } } $objMapper->addPlaceholder("formErrors", $strErrors); $strReturn .= $objMapper->writeToTemplate("/module_eventmanager/" . $this->arrElementData["char1"], "event_register" . ($bitIsLoggedin ? "_loggedin" : "")); class_module_pages_portal::registerAdditionalTitle($objEvent->getStrTitle()); return $strReturn; }
/** * Creates a table filled with the sessions currently registered. * Returned structure: * <sessions> * <session> * <username></username> * <loginstatus></loginstatus> * <releasetime></releasetime> * <activity></activity> * </session> * </sessions> * * @return string * @permissions right1 */ protected function actionSystemSessions() { $strReturn = ""; //check needed rights $arrSessions = class_module_system_session::getAllActiveSessions(); $strReturn .= "<sessions>"; foreach ($arrSessions as $objOneSession) { $strReturn .= "<session>"; $strUsername = ""; if ($objOneSession->getStrUserid() != "") { $objUser = new class_module_user_user($objOneSession->getStrUserid()); $strUsername = $objUser->getStrUsername(); } $strLoginStatus = ""; if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $strLoginStatus = $this->getLang("session_loggedin"); } else { $strLoginStatus = $this->getLang("session_loggedout"); } //find out what the user is doing... $strLastUrl = $objOneSession->getStrLasturl(); if (uniStrpos($strLastUrl, "?") !== false) { $strLastUrl = uniSubstr($strLastUrl, uniStrpos($strLastUrl, "?")); } $strActivity = ""; if (uniStrpos($strLastUrl, "admin=1") !== false) { $strActivity .= $this->getLang("session_admin"); foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "module") { $strActivity .= $arrUrlParam[1]; } } } else { $strActivity .= $this->getLang("session_portal"); if ($strLastUrl == "") { $strActivity .= class_module_system_setting::getConfigValue("_pages_indexpage_"); } else { foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "page") { $strActivity .= $arrUrlParam[1]; } } if ($strActivity == $this->getLang("session_portal") && uniSubstr($strLastUrl, 0, 5) == "image") { $strActivity .= $this->getLang("session_portal_imagegeneration"); } } } $strReturn .= "<username>" . xmlSafeString($strUsername) . "</username>"; $strReturn .= "<loginstatus>" . xmlSafeString($strLoginStatus) . "</loginstatus>"; $strReturn .= "<releasetime>" . xmlSafeString(timeToString($objOneSession->getIntReleasetime())) . "</releasetime>"; $strReturn .= "<activity>" . xmlSafeString($strActivity) . "</activity>"; $strReturn .= "</session>"; } $strReturn .= "</sessions>"; return $strReturn; }
/** * Shows a form to manage memberships of a user in groups * * @return string * @permissions edit */ protected function actionEditMemberships() { $strReturn = ""; //open the form $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveMembership")); //Create a list of checkboxes $objUser = new class_module_user_user($this->getSystemid()); $strReturn .= $this->objToolkit->formHeadline($this->getLang("user_memberships") . "\"" . $objUser->getStrUsername() . "\""); //Collect groups from the same source $objUsersources = new class_module_user_sourcefactory(); $objSourcesytem = $objUsersources->getUsersource($objUser->getStrSubsystem()); $arrGroups = $objSourcesytem->getAllGroupIds(); $arrUserGroups = $objUser->getArrGroupIds(); $arrRows = array(); foreach ($arrGroups as $strSingleGroup) { //to avoid privilege escalation, the admin-group has to be treated in a special manner //only render the group, if the current user is member of this group $objSingleGroup = new class_module_user_group($strSingleGroup); if (!$this->isGroupEditable($objSingleGroup)) { continue; } $strCheckbox = $this->objToolkit->formInputCheckbox($objSingleGroup->getSystemid(), "", in_array($strSingleGroup, $arrUserGroups)); $strCheckbox = uniSubstr($strCheckbox, uniStrpos($strCheckbox, "<input")); $strCheckbox = uniSubstr($strCheckbox, 0, uniStrpos($strCheckbox, ">") + 1); $arrRows[] = array($strCheckbox, $objSingleGroup->getStrName()); // $strReturn .= $this->objToolkit->formInputCheckbox($objSingleGroup->getSystemid(), $objSingleGroup->getStrName(), in_array($strSingleGroup, $arrUserGroups)); } $strReturn .= <<<HTML <a href="javascript:KAJONA.admin.permissions.toggleEmtpyRows('[lang,permissions_toggle_visible,system]', '[lang,permissions_toggle_hidden,system]', 'table.kajona-data-table tr');" id="rowToggleLink" class="rowsVisible">[lang,permissions_toggle_visible,system]</a><br /><br /> HTML; $strReturn .= $this->objToolkit->dataTable(null, $arrRows); $strReturn .= "<script type=\"text/javascript\">\r\n KAJONA.admin.permissions.toggleEmtpyRows('" . $this->getLang("permissions_toggle_visible", "system") . "', '" . $this->getLang("permissions_toggle_hidden", "system") . "', 'table.kajona-data-table tr');\r\n </script>"; $strReturn .= $this->objToolkit->formInputHidden("systemid", $this->getSystemid()); $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save")); $strReturn .= $this->objToolkit->formClose(); return $strReturn; }
/** * Creates a form to edit a users data * * @return string */ private function editUserData() { $arrErrors = array(); $bitForm = true; //what to do? if ($this->getParam("submitUserForm") != "") { if ($this->getParam("password") != "") { if ($this->getParam("password") != $this->getParam("password2")) { $arrErrors[] = $this->getLang("passwordsUnequal"); } } $objValidator = new class_email_validator(); if (!$objValidator->validate($this->getParam("email"))) { $arrErrors[] = $this->getLang("invalidEmailadress"); } if (count($arrErrors) == 0) { $bitForm = false; } } if ($bitForm) { if ($this->arrElementData["portallogin_editmode"] == 1) { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_complete"); } else { $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_minimal"); } $arrTemplate = array(); $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser()->isEditable() && $objUser->getStrSubsystem() == "kajona" && $objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $arrTemplate["username"] = $objUser->getStrUsername(); $arrTemplate["email"] = $objUser->getObjSourceUser()->getStrEmail(); $arrTemplate["forename"] = $objUser->getObjSourceUser()->getStrForename(); $arrTemplate["name"] = $objUser->getObjSourceUser()->getStrName(); $arrTemplate["street"] = $objUser->getObjSourceUser()->getStrStreet(); $arrTemplate["postal"] = $objUser->getObjSourceUser()->getStrPostal(); $arrTemplate["city"] = $objUser->getObjSourceUser()->getStrCity(); $arrTemplate["phone"] = $objUser->getObjSourceUser()->getStrTel(); $arrTemplate["mobile"] = $objUser->getObjSourceUser()->getStrMobile(); $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"]; $objDate = new class_date($objUser->getObjSourceUser()->getLongDate()); $arrTemplate["date_day"] = $objDate->getIntDay(); $arrTemplate["date_month"] = $objDate->getIntMonth(); $arrTemplate["date_year"] = $objDate->getIntYear(); $arrTemplate["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "portalEditProfile"); $arrTemplate["formErrors"] = ""; if (count($arrErrors) > 0) { foreach ($arrErrors as $strOneError) { $strErrTemplate = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "errorRow"); $arrTemplate["formErrors"] .= "" . $this->fillTemplate(array("error" => $strOneError), $strErrTemplate); } } return $this->fillTemplate($arrTemplate, $strTemplateID); } else { return "Login provider not supported."; } } else { $objUser = new class_module_user_user($this->objSession->getUserID()); if ($objUser->getObjSourceUser() instanceof class_usersources_user_kajona) { $objUser->getObjSourceUser()->setStrEmail($this->getParam("email")); $objUser->getObjSourceUser()->setStrForename($this->getParam("forename")); $objUser->getObjSourceUser()->setStrName($this->getParam("name")); $objUser->getObjSourceUser()->setStrPass($this->getParam("password")); if ($this->arrElementData["portallogin_editmode"] == 1) { $objUser->getObjSourceUser()->setStrStreet($this->getParam("street")); $objUser->getObjSourceUser()->setStrPostal($this->getParam("postal")); $objUser->getObjSourceUser()->setStrCity($this->getParam("city")); $objUser->getObjSourceUser()->setStrTel($this->getParam("phone")); $objUser->getObjSourceUser()->setStrMobile($this->getParam("mobile")); $objDate = new class_date(); $objDate->setIntDay($this->getParam("date_day")); $objDate->setIntMonth($this->getParam("date_month")); $objDate->setIntYear($this->getParam("date_year")); $objUser->getObjSourceUser()->setLongDate($objDate->getLongTimestamp()); } $objUser->getObjSourceUser()->updateObjectToDb(); } $this->portalReload(class_link::getLinkPortalHref($this->getPagename())); } return ""; }
/** * 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; }
/** * Prints a file as a detailed-view * and generates forward / backward links + a strip of prev / next files * * @param bool $bitRegisterAdditionalTitle * @return string */ protected function actionFileDetails($bitRegisterAdditionalTitle = true) { if (!$this->checkIfRequestedIdIsInElementsTree()) { return $this->actionList(); } $bitIsImage = false; //Load record $objFile = new class_module_mediamanager_file($this->getSystemid()); //common fields $arrDetailsTemplate = array(); $arrDetailsTemplate["file_name"] = $objFile->getStrName(); $arrDetailsTemplate["file_description"] = $objFile->getStrDescription(); $arrDetailsTemplate["file_subtitle"] = $objFile->getStrSubtitle(); $arrDetailsTemplate["file_filename"] = $objFile->getStrFilename(); $arrDetailsTemplate["file_size"] = bytesToString($objFile->getIntFileSize()); $arrDetailsTemplate["file_hits"] = $objFile->getIntHits(); $arrDetailsTemplate["file_systemid"] = $objFile->getSystemid(); $arrDetailsTemplate["file_elementid"] = $this->arrElementData["content_id"]; $arrDetailsTemplate["file_lmtime"] = timeToString(filemtime(_realpath_ . $objFile->getStrFilename())); if (validateSystemid($objFile->getOwnerId())) { $objUser = new class_module_user_user($objFile->getOwnerId()); $arrDetailsTemplate["file_owner"] = $objUser->getStrUsername(); } if ($objFile->rightRight2()) { $arrDetailsTemplate["file_link_href"] = _webpath_ . "/download.php?systemid=" . $objFile->getSystemid(); $arrDetailsTemplate["file_link"] = "<a href=\"" . _webpath_ . "/download.php?systemid=" . $objFile->getSystemid() . "\">" . $this->getLang("download_link") . "</a>"; } //if its an image, provide additional information $strSuffix = uniStrtolower(uniSubstr($objFile->getStrFilename(), uniStrrpos($objFile->getStrFilename(), "."))); if (in_array($strSuffix, $this->arrImageTypes) && isset($this->arrElementData["gallery_maxh_d"]) && isset($this->arrElementData["gallery_maxw_d"])) { $bitIsImage = true; $arrDetailsTemplate["image_src"] = $this->getImageUrl($objFile->getStrFilename(), $this->arrElementData["gallery_maxh_d"], $this->arrElementData["gallery_maxw_d"], $this->arrElementData["gallery_text"], $this->arrElementData["gallery_overlay"], $objFile->getSystemid(), $this->arrElementData["content_id"]); } $arrStripIds = $this->getNextPrevIds(); $arrDetailsTemplate["backlink"] = $arrStripIds["backward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_back"), "fileDetails", "", $arrStripIds["backward_1"]) : ""; $arrDetailsTemplate["forwardlink"] = $arrStripIds["forward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_next"), "fileDetails", "", $arrStripIds["forward_1"]) : ""; //next /prev 3 files for ($intI = 1; $intI <= 3; $intI++) { if ($arrStripIds["forward_" . $intI] != "") { $objCurFile = new class_module_mediamanager_file($arrStripIds["forward_" . $intI]); $arrDetailsTemplate["forwardlink_" . $intI] = $this->renderFileStripEntry($objCurFile); } if ($arrStripIds["backward_" . $intI] != "") { $objCurFile = new class_module_mediamanager_file($arrStripIds["backward_" . $intI]); $arrDetailsTemplate["backlink_" . $intI] = $this->renderFileStripEntry($objCurFile); } } //current file $arrDetailsTemplate["filestrip_current"] = $this->renderFileStripEntry($objFile); $arrDetailsTemplate["overview"] = getLinkPortal($this->getPagename(), "", "", $this->getLang("overview"), "mediaFolder", "", $objFile->getPrevId()); $arrDetailsTemplate["pathnavigation"] = $this->generatePathnavi(true); //ratings available? if ($objFile->getFloatRating() !== null) { /** @var $objRating class_module_rating_portal */ $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule(); $arrDetailsTemplate["file_rating"] = $objRating->buildRatingBar($objFile->getFloatRating(), $objFile->getIntRatingHits(), $objFile->getSystemid(), $objFile->isRateableByUser(), $objFile->rightRight3()); } $strTemplateID = $this->objTemplate->readTemplate("/module_mediamanager/" . $this->arrElementData["repo_template"], "filedetail"); $strReturn = $this->fillTemplate($arrDetailsTemplate, $strTemplateID); //Add pe code $arrPeConfig = array("pe_module" => "mediamanager", "pe_action_edit" => "editFile", "pe_action_edit_params" => "&systemid=" . $objFile->getSystemid()); $strReturn = class_element_portal::addPortalEditorCode($strReturn, $objFile->getSystemid(), $arrPeConfig); //set the name of the current image to the page title via class_pages if ($bitRegisterAdditionalTitle) { class_module_pages_portal::registerAdditionalTitle($objFile->getStrName()); } //Update view counter if ($bitIsImage) { $objFile->increaseHits(); } return $this->addPortaleditorCode($strReturn); }
/** * Creates a table filled with the sessions currently registered * * @autoTestable * @return string * @permissions right1 */ protected function actionSystemSessions() { $strReturn = ""; //react on commands? if ($this->getParam("logout") == "true") { $objSession = new class_module_system_session($this->getSystemid()); $objSession->setStrLoginstatus(class_module_system_session::$LOGINSTATUS_LOGGEDOUT); $objSession->updateObjectToDb(); class_carrier::getInstance()->getObjDB()->flushQueryCache(); } //showing a list using the pageview $objArraySectionIterator = new class_array_section_iterator(class_module_system_session::getNumberOfActiveSessions()); $objArraySectionIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objArraySectionIterator->setArraySection(class_module_system_session::getAllActiveSessions($objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos())); $arrData = array(); $arrHeader = array(); $arrHeader[0] = ""; $arrHeader[1] = $this->getLang("session_username"); $arrHeader[2] = $this->getLang("session_valid"); $arrHeader[3] = $this->getLang("session_status"); $arrHeader[4] = $this->getLang("session_activity"); $arrHeader[5] = ""; /** @var $objOneSession class_module_system_session */ foreach ($objArraySectionIterator as $objOneSession) { $arrRowData = array(); $strUsername = ""; if ($objOneSession->getStrUserid() != "") { $objUser = new class_module_user_user($objOneSession->getStrUserid()); $strUsername = $objUser->getStrUsername(); } $arrRowData[0] = class_adminskin_helper::getAdminImage("icon_user"); $arrRowData[1] = $strUsername; $arrRowData[2] = timeToString($objOneSession->getIntReleasetime()); if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $arrRowData[3] = $this->getLang("session_loggedin"); } else { $arrRowData[3] = $this->getLang("session_loggedout"); } //find out what the user is doing... $strLastUrl = $objOneSession->getStrLasturl(); if (uniStrpos($strLastUrl, "?") !== false) { $strLastUrl = uniSubstr($strLastUrl, uniStrpos($strLastUrl, "?")); } $strActivity = ""; if (uniStrpos($strLastUrl, "admin=1") !== false) { $strActivity .= $this->getLang("session_admin"); foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "module") { $strActivity .= $arrUrlParam[1]; } } } else { $strActivity .= $this->getLang("session_portal"); if ($strLastUrl == "") { $strActivity .= class_module_system_setting::getConfigValue("_pages_indexpage_") != "" ? class_module_system_setting::getConfigValue("_pages_indexpage_") : ""; } else { foreach (explode("&", $strLastUrl) as $strOneParam) { $arrUrlParam = explode("=", $strOneParam); if ($arrUrlParam[0] == "page") { $strActivity .= $arrUrlParam[1]; } } if ($strActivity == $this->getLang("session_portal") && uniSubstr($strLastUrl, 0, 5) == "image") { $strActivity .= $this->getLang("session_portal_imagegeneration"); } } } $arrRowData[4] = $strActivity; if ($objOneSession->getStrLoginstatus() == class_module_system_session::$LOGINSTATUS_LOGGEDIN) { $arrRowData[5] = class_link::getLinkAdmin("system", "systemSessions", "&logout=true&systemid=" . $objOneSession->getSystemid(), "", $this->getLang("session_logout"), "icon_delete"); } else { $arrRowData[5] = class_adminskin_helper::getAdminImage("icon_deleteDisabled"); } $arrData[] = $arrRowData; } $strReturn .= $this->objToolkit->dataTable($arrHeader, $arrData); $strReturn .= $this->objToolkit->getPageview($objArraySectionIterator, "system", "systemSessions"); 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"); }
/** * Does all the internal login-handling * * @param class_module_user_user $objUser * * @return bool */ private function internalLoginHelper(class_module_user_user $objUser) { if ($objUser->getIntActive() == 1) { $this->getObjInternalSession()->setStrLoginstatus(class_module_system_session::$LOGINSTATUS_LOGGEDIN); $this->getObjInternalSession()->setStrUserid($objUser->getSystemid()); $strGroups = implode(",", $objUser->getArrGroupIds()); $this->getObjInternalSession()->setStrGroupids($strGroups); $this->getObjInternalSession()->updateObjectToDb(); $this->objUser = $objUser; //trigger listeners on first login if ($objUser->getIntLogins() == 0) { class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_USERFIRSTLOGIN, array($objUser->getSystemid())); } $objUser->setIntLogins($objUser->getIntLogins() + 1); $objUser->setIntLastLogin(time()); $objUser->updateObjectToDb(); //Drop a line to the logger class_logger::getInstance()->addLogRow("User: "******" successfully logged in, login provider: " . $objUser->getStrSubsystem(), class_logger::$levelInfo); class_module_user_log::generateLog(); //right now we have the time to do a few cleanups... class_module_system_session::deleteInvalidSessions(); //call listeners class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_USERLOGIN, array($objUser->getSystemid())); //Login successful, quit $bitReturn = true; } else { //User is inactive $bitReturn = false; } return $bitReturn; }