/** * Returns a list of users belonging to a specified group * * @param class_admin_formgenerator $objForm * * @return string * @permissions edit */ protected function actionGroupMember(class_admin_formgenerator $objForm = null) { $strReturn = ""; if ($this->getSystemid() != "") { $objGroup = new class_module_user_group($this->getSystemid()); //validate possible blocked groups $bitRenderEdit = $this->isGroupEditable($objGroup); $objSourceGroup = $objGroup->getObjSourceGroup(); $strReturn .= $this->objToolkit->formHeadline($this->getLang("group_memberlist") . "\"" . $objGroup->getStrName() . "\""); $objUsersources = new class_module_user_sourcefactory(); if ($objUsersources->getUsersource($objGroup->getStrSubsystem())->getMembersEditable() && $bitRenderEdit) { if ($objForm == null) { $objForm = $this->getGroupMemberForm($objGroup); } $arrFolder = $this->objToolkit->getLayoutFolder($objForm->renderForm(getLinkAdminHref($this->getArrModule("modul"), "addUserToGroup")), $this->getLang("group_add_user")); $strReturn .= $this->objToolkit->getFieldset($arrFolder[1], $arrFolder[0]); } $objIterator = new class_array_section_iterator($objSourceGroup->getNumberOfMembers()); $objIterator->setPageNumber((int) ($this->getParam("pv") != "" ? $this->getParam("pv") : 1)); $objIterator->setArraySection($objSourceGroup->getUserIdsForGroup($objIterator->calculateStartPos(), $objIterator->calculateEndPos())); $strReturn .= $this->objToolkit->listHeader(); $intI = 0; foreach ($objIterator as $strSingleMemberId) { $objSingleMember = new class_module_user_user($strSingleMemberId); $strAction = ""; if ($objUsersources->getUsersource($objGroup->getStrSubsystem())->getMembersEditable() && $bitRenderEdit) { $strAction .= $this->objToolkit->listDeleteButton($objSingleMember->getStrUsername() . " (" . $objSingleMember->getStrForename() . " " . $objSingleMember->getStrName() . ")", $this->getLang("mitglied_loeschen_frage"), class_link::getLinkAdminHref($this->getArrModule("modul"), "groupMemberDelete", "&groupid=" . $objGroup->getSystemid() . "&userid=" . $objSingleMember->getSystemid())); } $strReturn .= $this->objToolkit->genericAdminList($objSingleMember->getSystemid(), $objSingleMember->getStrDisplayName(), getImageAdmin("icon_user"), $strAction, $intI++); } $strReturn .= $this->objToolkit->listFooter() . $this->objToolkit->getPageview($objIterator, "user", "groupMember", "systemid=" . $this->getSystemid()); } return $strReturn; }
public function testLockBetweenUsers() { $objAspect = new class_module_system_aspect(); $objAspect->setStrName("test"); $objAspect->updateObjectToDb(); $strAspectId = $objAspect->getSystemid(); $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue(!$objAspect->getLockManager()->isLocked()); $objUser1 = new class_module_user_user(); $objUser1->setStrUsername(generateSystemid()); $objUser1->setIntActive(1); $objUser1->updateObjectToDb(); $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser1)); $objAspect->getLockManager()->lockRecord(); $this->assertEquals($objUser1->getSystemid(), $objAspect->getLockManager()->getLockId()); $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue($objAspect->getLockManager()->isLocked()); $this->assertTrue($objAspect->getLockManager()->isLockedByCurrentUser()); $objUser2 = new class_module_user_user(); $objUser2->setStrUsername(generateSystemid()); $objUser2->setIntActive(1); $objUser2->updateObjectToDb(); $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser2)); $this->assertTrue(!$objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue($objAspect->getLockManager()->isLocked()); $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser()); //updates should release the lock $objException = null; try { $objAspect->updateObjectToDb(); } catch (class_exception $objEx) { $objException = $objEx; } $this->assertNotNull($objException); //lock should remain $this->assertTrue(!$objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue($objAspect->getLockManager()->isLocked()); $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser()); $this->assertEquals($objUser1->getSystemid(), $objAspect->getLockManager()->getLockId()); //unlocking is not allowed for user 2 $this->assertTrue(!$objAspect->getLockManager()->unlockRecord()); //force unlock not allowed since user is not in admin group $this->assertTrue($objAspect->getLockManager()->unlockRecord(true)); //lock should remain $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue(!$objAspect->getLockManager()->isLocked()); $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser()); //add user 2 to admin group $objGroup = new class_module_user_group(class_module_system_setting::getConfigValue("_admins_group_id_")); $this->assertTrue($objGroup->getObjSourceGroup()->addMember($objUser2->getObjSourceUser())); //relogin $this->flushDBCache(); $objUser2 = new class_module_user_user($objUser2->getSystemid()); $this->assertTrue(class_carrier::getInstance()->getObjSession()->loginUser($objUser2)); //force unlock now allowed since user is not in admin group $this->assertTrue($objAspect->getLockManager()->unlockRecord(true)); //lock should be gone $this->assertTrue($objAspect->getLockManager()->isAccessibleForCurrentUser()); $this->assertTrue(!$objAspect->getLockManager()->isLocked()); $this->assertTrue(!$objAspect->getLockManager()->isLockedByCurrentUser()); class_carrier::getInstance()->getObjSession()->logout(); $objAspect = new class_module_system_aspect($strAspectId); $objAspect->deleteObjectFromDatabase(); $objUser1->deleteObjectFromDatabase(); $objUser2->deleteObjectFromDatabase(); }
/** * Returns the fully featured user-instance created by the matching subsystem. * * @param class_module_user_user $objLeightweightUser * * @throws class_exception * @return interface_usersources_user */ public function getSourceUser(class_module_user_user $objLeightweightUser) { if ($objLeightweightUser->getIntDeleted() == 1) { throw new class_exception("User was deleted, source user no longer available", class_exception::$level_ERROR); } $objSubsystem = $this->getUsersource($objLeightweightUser->getStrSubsystem()); $objPlainUser = $objSubsystem->getUserById($objLeightweightUser->getSystemid()); return $objPlainUser; }
/** * 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 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(); }
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"); } }
/** * 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; }