コード例 #1
0
 /**
  * Saves the memberships passed by param
  *
  * @return string "" in case of success
  * @permissions edit
  */
 protected function actionSaveMembership()
 {
     $objUser = new class_module_user_user($this->getSystemid());
     $objUsersources = new class_module_user_sourcefactory();
     $objSourcesytem = $objUsersources->getUsersource($objUser->getStrSubsystem());
     $arrGroups = $objSourcesytem->getAllGroupIds();
     $arrUserGroups = $objUser->getArrGroupIds();
     //validate possible blocked groups
     $objConfig = class_config::getInstance("blockedgroups.php");
     $arrBlockedGroups = explode(",", $objConfig->getConfig("blockedgroups"));
     //Searching for groups to enter
     foreach ($arrGroups as $strSingleGroup) {
         $objGroup = new class_module_user_group($strSingleGroup);
         //skipped for blocked groups, those won't be updated
         if (!$this->isGroupEditable($objGroup)) {
             continue;
         }
         if ($this->getParam($strSingleGroup) != "") {
             //add the user to this group
             if (!in_array($strSingleGroup, $arrUserGroups)) {
                 $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser());
             } else {
                 //user is already in the group, remove the marker
                 foreach ($arrUserGroups as $strKey => $strValue) {
                     if ($strValue == $strSingleGroup) {
                         $arrUserGroups[$strKey] = null;
                     }
                 }
             }
         }
     }
     //check, if the current user is member of the admin-group.
     //if not, remain the admin-group as-is
     if (!class_carrier::getInstance()->getObjSession()->isSuperAdmin()) {
         $intKey = array_search(class_module_system_setting::getConfigValue("_admins_group_id_"), $arrUserGroups);
         if ($intKey !== false) {
             $arrUserGroups[$intKey] = null;
         }
         foreach ($arrBlockedGroups as $strOneGroup) {
             $intKey = array_search($strOneGroup, $arrUserGroups);
             if ($intKey !== false) {
                 $arrUserGroups[$intKey] = null;
             }
         }
     }
     //loop the users' list in order to remove unwanted relations
     foreach ($arrUserGroups as $strValue) {
         if (validateSystemid($strValue)) {
             $objGroup = new class_module_user_group($strValue);
             $objGroup->getObjSourceGroup()->removeMember($objUser->getObjSourceUser());
         }
     }
     if ($this->getParam("folderview")) {
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list", "&peClose=1&blockAction=1"));
     } else {
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"));
     }
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * Creates a form to edit a users data
  *
  * @return string
  */
 private function editUserData()
 {
     $arrErrors = array();
     $bitForm = true;
     //what to do?
     if ($this->getParam("submitUserForm") != "") {
         if ($this->getParam("password") != "") {
             if ($this->getParam("password") != $this->getParam("password2")) {
                 $arrErrors[] = $this->getLang("passwordsUnequal");
             }
         }
         $objValidator = new class_email_validator();
         if (!$objValidator->validate($this->getParam("email"))) {
             $arrErrors[] = $this->getLang("invalidEmailadress");
         }
         if (count($arrErrors) == 0) {
             $bitForm = false;
         }
     }
     if ($bitForm) {
         if ($this->arrElementData["portallogin_editmode"] == 1) {
             $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_complete");
         } else {
             $strTemplateID = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "portallogin_userdataform_minimal");
         }
         $arrTemplate = array();
         $objUser = new class_module_user_user($this->objSession->getUserID());
         if ($objUser->getObjSourceUser()->isEditable() && $objUser->getStrSubsystem() == "kajona" && $objUser->getObjSourceUser() instanceof class_usersources_user_kajona) {
             $arrTemplate["username"] = $objUser->getStrUsername();
             $arrTemplate["email"] = $objUser->getObjSourceUser()->getStrEmail();
             $arrTemplate["forename"] = $objUser->getObjSourceUser()->getStrForename();
             $arrTemplate["name"] = $objUser->getObjSourceUser()->getStrName();
             $arrTemplate["street"] = $objUser->getObjSourceUser()->getStrStreet();
             $arrTemplate["postal"] = $objUser->getObjSourceUser()->getStrPostal();
             $arrTemplate["city"] = $objUser->getObjSourceUser()->getStrCity();
             $arrTemplate["phone"] = $objUser->getObjSourceUser()->getStrTel();
             $arrTemplate["mobile"] = $objUser->getObjSourceUser()->getStrMobile();
             $arrTemplate["portallogin_elsystemid"] = $this->arrElementData["content_id"];
             $objDate = new class_date($objUser->getObjSourceUser()->getLongDate());
             $arrTemplate["date_day"] = $objDate->getIntDay();
             $arrTemplate["date_month"] = $objDate->getIntMonth();
             $arrTemplate["date_year"] = $objDate->getIntYear();
             $arrTemplate["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "portalEditProfile");
             $arrTemplate["formErrors"] = "";
             if (count($arrErrors) > 0) {
                 foreach ($arrErrors as $strOneError) {
                     $strErrTemplate = $this->objTemplate->readTemplate("/element_portallogin/" . $this->arrElementData["portallogin_template"], "errorRow");
                     $arrTemplate["formErrors"] .= "" . $this->fillTemplate(array("error" => $strOneError), $strErrTemplate);
                 }
             }
             return $this->fillTemplate($arrTemplate, $strTemplateID);
         } else {
             return "Login provider not supported.";
         }
     } else {
         $objUser = new class_module_user_user($this->objSession->getUserID());
         if ($objUser->getObjSourceUser() instanceof class_usersources_user_kajona) {
             $objUser->getObjSourceUser()->setStrEmail($this->getParam("email"));
             $objUser->getObjSourceUser()->setStrForename($this->getParam("forename"));
             $objUser->getObjSourceUser()->setStrName($this->getParam("name"));
             $objUser->getObjSourceUser()->setStrPass($this->getParam("password"));
             if ($this->arrElementData["portallogin_editmode"] == 1) {
                 $objUser->getObjSourceUser()->setStrStreet($this->getParam("street"));
                 $objUser->getObjSourceUser()->setStrPostal($this->getParam("postal"));
                 $objUser->getObjSourceUser()->setStrCity($this->getParam("city"));
                 $objUser->getObjSourceUser()->setStrTel($this->getParam("phone"));
                 $objUser->getObjSourceUser()->setStrMobile($this->getParam("mobile"));
                 $objDate = new class_date();
                 $objDate->setIntDay($this->getParam("date_day"));
                 $objDate->setIntMonth($this->getParam("date_month"));
                 $objDate->setIntYear($this->getParam("date_year"));
                 $objUser->getObjSourceUser()->setLongDate($objDate->getLongTimestamp());
             }
             $objUser->getObjSourceUser()->updateObjectToDb();
         }
         $this->portalReload(class_link::getLinkPortalHref($this->getPagename()));
     }
     return "";
 }
コード例 #4
0
ファイル: class_session.php プロジェクト: jinshana/kajonacms
 /**
  * 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;
 }