/**
  * Stores the submitted data to the backend / the loginprovider
  *
  * @return string
  */
 protected function actionSaveUser()
 {
     $strReturn = "";
     $bitSelfedit = false;
     $objUsersources = new class_module_user_sourcefactory();
     if ($this->getParam("mode") == "new") {
         if (!$this->getObjModule()->rightEdit()) {
             return $this->getLang("commons_error_permissions");
         }
         $objSubsystem = $objUsersources->getUsersource($this->getParam("usersource"));
         $objBlankUser = $objSubsystem->getNewUser();
         $objForm = $this->getUserForm($objBlankUser, false, "new");
     } else {
         if (!$this->getObjModule()->rightEdit()) {
             if ($this->getSystemid() == $this->objSession->getUserID() && class_module_system_setting::getConfigValue("_user_selfedit_") == "true") {
                 $bitSelfedit = true;
             } else {
                 return $this->getLang("commons_error_permissions");
             }
         }
         $objUser = new class_module_user_user($this->getSystemid());
         $objSourceUser = $objUsersources->getSourceUser($objUser);
         $objForm = $this->getUserForm($objSourceUser, $bitSelfedit, "edit");
     }
     if (($this->getParam("mode") == "new" && !$this->checkAdditionalNewData($objForm)) | ($this->getParam("mode") == "edit" && !$this->checkAdditionalEditData($objForm)) | !$objForm->validateForm()) {
         return $this->actionNewUser($this->getParam("mode"), $objForm);
     }
     $objUser = null;
     if ($this->getParam("mode") == "new") {
         //create a new user and pass all relevant data
         $objUser = new class_module_user_user();
         $objUser->setStrSubsystem($this->getParam("usersource"));
         $objUser->setStrUsername($this->getParam("user_username"));
         $objUser->setIntActive($this->getParam("user_active") != "" && $this->getParam("user_active") == "checked" ? 1 : 0);
         $objUser->setIntAdmin($this->getParam("user_adminlogin") != "" && $this->getParam("user_adminlogin") == "checked" ? 1 : 0);
         $objUser->setIntPortal($this->getParam("user_portal") != "" && $this->getParam("user_portal") == "checked" ? 1 : 0);
     } else {
         if ($this->getParam("mode") == "edit") {
             //create a new user and pass all relevant data
             $objUser = new class_module_user_user($this->getSystemid());
             if (!$bitSelfedit) {
                 $objUser->setStrUsername($this->getParam("user_username"));
                 $objUser->setIntActive($this->getParam("user_active") != "" && $this->getParam("user_active") == "checked" ? 1 : 0);
                 $objUser->setIntAdmin($this->getParam("user_adminlogin") != "" && $this->getParam("user_adminlogin") == "checked" ? 1 : 0);
                 $objUser->setIntPortal($this->getParam("user_portal") != "" && $this->getParam("user_portal") == "checked" ? 1 : 0);
             }
         }
     }
     $objUser->setStrAdminskin($this->getParam("user_skin"));
     $objUser->setStrAdminlanguage($this->getParam("user_language"));
     $objUser->setStrAdminModule($this->getParam("user_startmodule"));
     $objUser->setIntItemsPerPage($this->getParam("user_items_per_page"));
     $objUser->updateObjectToDb();
     $objSourceUser = $objUser->getObjSourceUser();
     $objForm = $this->getUserForm($objSourceUser, $bitSelfedit, $this->getParam("mode"));
     $objForm->updateSourceObject();
     $objSourceUser->updateObjectToDb();
     // assign user to the same groups if we have an user where we inherit the group settings
     if ($this->getParam("mode") == "new") {
         $strInheritUserId = $this->getParam("user_inherit_permissions_id");
         if (!empty($strInheritUserId)) {
             $objInheritUser = new class_module_user_user($strInheritUserId);
             $arrGroupIds = $objInheritUser->getArrGroupIds();
             foreach ($arrGroupIds as $strGroupId) {
                 $objGroup = new class_module_user_group($strGroupId);
                 $objSourceGroup = $objGroup->getObjSourceGroup();
                 $objSourceGroup->addMember($objUser->getObjSourceUser());
             }
             $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "editMemberships", "&systemid=" . $objUser->getStrSystemid()));
             return "";
         }
     }
     if ($this->getParam("mode") == "edit") {
         //Reset the admin-skin cookie to force the new skin
         $objCookie = new class_cookie();
         //flush the db-cache
         class_carrier::getInstance()->getObjDB()->flushQueryCache();
         $this->objSession->resetUser();
         //and update the cookie
         $objCookie->setCookie("adminskin", $this->objSession->getAdminSkin(false, true));
         //update language set before
         $objCookie->setCookie("adminlanguage", $this->objSession->getAdminLanguage(false, true));
     }
     //flush the navigation cache in order to get new items for a possible updated list
     class_admin_helper::flushActionNavigationCache();
     if ($this->getObjModule()->rightView()) {
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"));
     } else {
         $this->adminReload(class_link::getLinkAdminHref($objUser->getStrAdminModule()));
     }
     return $strReturn;
 }
 /**
  * @param DOMElement $objElement
  * @param $objParent
  * @param $strClassName
  * @param $arrParameters
  * @param $strName
  * @return class_model
  */
 private function createFixtureUser(DOMElement $objElement, $objParent, $strClassName, $arrParameters, $strName)
 {
     $strUserName = $arrParameters["strUsername"];
     $objUser = new class_module_user_user();
     $objUser->setIntActive(1);
     $objUser->setIntAdmin(1);
     $objUser->setStrUsername($strUserName);
     $objUser->updateObjectToDb();
     $objSourceUser = $objUser->getObjSourceUser();
     $objSourceUser->setStrPass($strUserName);
     $objSourceUser->setStrEmail("{$strUserName}@example");
     $objSourceUser->setStrForename($strUserName . "_Forname");
     $objSourceUser->setStrName($strUserName . "Lastname");
     $objSourceUser->updateObjectToDb();
     return $objUser;
 }
 /**
  * Creates a form to enter the new password of the account to reset.
  *
  * @return string
  */
 private function newPwdForm()
 {
     $strReturn = "";
     if ($this->getParam("reset") != "" && getPost("reset") != "") {
         //try to load the user
         $objUser = new class_module_user_user($this->getParam("systemid"));
         if ($objUser->getStrAuthcode() != "" && $objUser->getStrAuthcode() == $this->getParam("authcode") && $objUser->getStrUsername() != "") {
             //check the submitted passwords.
             $strPass1 = trim($this->getParam("portallogin_password1"));
             $strPass2 = trim($this->getParam("portallogin_password2"));
             $objValidator = new class_text_validator();
             if ($strPass1 == $strPass2 && $objValidator->validate($strPass1)) {
                 if ($objUser->getObjSourceUser()->isPasswordResettable() && method_exists($objUser->getObjSourceUser(), "setStrPass")) {
                     $objUser->getObjSourceUser()->setStrPass($strPass1);
                     $objUser->getObjSourceUser()->updateObjectToDb();
                 }
                 $objUser->setStrAuthcode("");
                 $objUser->updateObjectToDb();
                 class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("changed password of user " . $objUser->getStrUsername(), class_logger::$levelInfo);
                 $strReturn .= $this->getLang("resetSuccess");
             } else {
                 $strReturn .= $this->getLang("resetError");
             }
         } else {
             $strReturn .= $this->getLang("resetError");
         }
     } else {
         $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_newpwdform");
         $arrTemplate = array();
         //check sysid & authcode
         $objUser = new class_module_user_user($this->getParam("systemid"));
         if ($objUser->getStrAuthcode() != "" && $objUser->getStrAuthcode() == $this->getParam("authcode")) {
             $arrTemplate["portallogin_action"] = "portalResetPwd";
             $arrTemplate["portallogin_systemid"] = $this->getParam("systemid");
             $arrTemplate["portallogin_authcode"] = $this->getParam("authcode");
             $arrTemplate["portallogin_resetHint"] = "portalLoginReset";
             $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"];
             $arrTemplate["action"] = class_link::getLinkPortalHref($this->getPagename());
             $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
         } else {
             $strReturn .= "Permission Error";
         }
     }
     return $strReturn;
 }
 /**
  * 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;
 }
 public function testLockExceptionOnSort()
 {
     $objAspect = new class_module_system_aspect();
     $objAspect->setStrName("test");
     $objAspect->updateObjectToDb();
     $strAspectId = $objAspect->getSystemid();
     $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->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()->isLockedByCurrentUser());
     $intSort = $objAspect->getIntSort();
     $objException = null;
     try {
         $objAspect->setAbsolutePosition(4);
     } catch (class_exception $objEx) {
         $objException = $objEx;
     }
     $this->assertNotNull($objException);
     $this->assertEquals($intSort, $objAspect->getIntSort());
     class_carrier::getInstance()->getObjSession()->logout();
     $objAspect = new class_module_system_aspect($strAspectId);
     $objAspect->deleteObjectFromDatabase();
     $objUser1->deleteObjectFromDatabase();
     $objUser2->deleteObjectFromDatabase();
 }
 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();
 }
 /**
  * Returns an array of user-ids associated with the current group.
  * If possible, pageing should be supported
  *
  * @param int $intStart
  * @param int $intEnd
  *
  * @return array
  */
 public function getUserIdsForGroup($intStart = null, $intEnd = null)
 {
     $arrReturn = array();
     //load all members from ldap
     $objLdap = class_ldap::getInstance($this->intCfg);
     $arrMembers = $objLdap->getMembersOfGroup($this->getStrDn());
     $objSource = new class_usersources_source_ldap();
     foreach ($arrMembers as $strOneMemberDn) {
         //check if the user exists in the kajona-database
         $objUser = $objSource->getUserByDn($strOneMemberDn);
         if ($objUser != null) {
             $arrReturn[] = $objUser->getSystemid();
         } else {
             //import the user into the system transparently
             $arrSingleUser = $objLdap->getUserDetailsByDN($strOneMemberDn);
             $objUser = new class_module_user_user();
             $objUser->setStrUsername($arrSingleUser["username"]);
             $objUser->setStrSubsystem("ldap");
             $objUser->setIntActive(1);
             $objUser->setIntAdmin(1);
             $objUser->updateObjectToDb();
             $objSourceUser = $objUser->getObjSourceUser();
             if ($objSourceUser instanceof class_usersources_user_ldap) {
                 $objSourceUser->setStrDN($arrSingleUser["identifier"]);
                 $objSourceUser->setStrFamilyname($arrSingleUser["familyname"]);
                 $objSourceUser->setStrGivenname($arrSingleUser["givenname"]);
                 $objSourceUser->setStrEmail($arrSingleUser["mail"]);
                 $objSourceUser->updateObjectToDb();
                 $this->objDB->flushQueryCache();
             }
             $arrReturn[] = $objUser->getSystemid();
         }
     }
     return $arrReturn;
 }
 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;
 }
 /**
  * Loads the user identified by the passed name.
  * This method may be called during the authentication of users and may be used as a hook
  * in order to create new users in the central database not yet existing.
  *
  * @param string $strUsername
  *
  * @return interface_usersources_user or null
  */
 public function getUserByUsername($strUsername)
 {
     $strQuery = "SELECT user_id FROM " . _dbprefix_ . "user WHERE user_username = ? AND user_subsystem = 'ldap'";
     $arrIds = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($strUsername));
     if (isset($arrIds["user_id"]) && validateSystemid($arrIds["user_id"])) {
         return new class_usersources_user_ldap($arrIds["user_id"]);
     }
     //user not found. search for a matching user in the ldap and add a possible match to the system
     foreach (class_ldap::getAllInstances() as $objSingleLdap) {
         $arrDetails = $objSingleLdap->getUserdetailsByName($strUsername);
         if ($arrDetails !== false && count($arrDetails) == 1) {
             $arrSingleUser = $arrDetails[0];
             $objUser = new class_module_user_user();
             $objUser->setStrUsername($strUsername);
             $objUser->setStrSubsystem("ldap");
             $objUser->setIntActive(1);
             $objUser->setIntAdmin(1);
             $objUser->updateObjectToDb();
             /** @var $objSourceUser class_usersources_user_ldap */
             $objSourceUser = $objUser->getObjSourceUser();
             if ($objSourceUser instanceof class_usersources_user_ldap) {
                 $objSourceUser->setStrDN($arrSingleUser["identifier"]);
                 $objSourceUser->setStrFamilyname($arrSingleUser["familyname"]);
                 $objSourceUser->setStrGivenname($arrSingleUser["givenname"]);
                 $objSourceUser->setStrEmail($arrSingleUser["mail"]);
                 $objSourceUser->setIntCfg($objSingleLdap->getIntCfgNr());
                 $objSourceUser->updateObjectToDb();
                 $this->objDB->flushQueryCache();
                 return $objSourceUser;
             }
         }
     }
     return null;
 }
Beispiel #10
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");
 }
 /**
  * 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");
     }
 }
Beispiel #12
0
 /**
  * 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;
 }