Beispiel #1
0
 /**
  * Called after successful login
  * @return 
  * @param array $a_username
  * @param object $a_auth
  */
 protected function loginObserver($a_username, $a_auth)
 {
     global $ilLog, $ilAppEventHandler, $ilSetting;
     if ($this->getContainer()->loginObserver($a_username, $a_auth)) {
         // validate user
         include_once "Services/User/classes/class.ilObjUser.php";
         $user_id = ilObjUser::_loginExists($a_auth->getUsername());
         if ($user_id != ANONYMOUS_USER_ID) {
             $user = new ilObjUser($user_id);
             // check if profile is complete
             include_once "Services/User/classes/class.ilUserProfile.php";
             if (ilUserProfile::isProfileIncomplete($user) and ilAuthFactory::getContext() != ilAuthFactory::CONTEXT_ECS) {
                 $user->setProfileIncomplete(true);
                 $user->update();
             }
             // --- extended user validation
             //
             // we only have a single status, so abort after each one
             // order from highest priority to lowest
             // active?
             if (!$user->getActive()) {
                 $this->status = AUTH_USER_INACTIVE;
                 $a_auth->logout();
                 return;
             }
             // time limit
             if (!$user->checkTimeLimit()) {
                 $this->status = AUTH_USER_TIME_LIMIT_EXCEEDED;
                 // #16327
                 $this->exceeded_user_name = $this->getUserName();
                 $a_auth->logout();
                 return;
             }
             // check client ip
             $clientip = $user->getClientIP();
             if (trim($clientip) != "") {
                 $clientip = preg_replace("/[^0-9.?*,:]+/", "", $clientip);
                 $clientip = str_replace(".", "\\.", $clientip);
                 $clientip = str_replace(array("?", "*", ","), array("[0-9]", "[0-9]*", "|"), $clientip);
                 if (!preg_match("/^" . $clientip . "\$/", $_SERVER["REMOTE_ADDR"])) {
                     $this->status = AUTH_USER_WRONG_IP;
                     $a_auth->logout();
                     return;
                 }
             }
             // simultaneous login
             if ($ilSetting->get('ps_prevent_simultaneous_logins') && ilObjUser::hasActiveSession($user_id)) {
                 $this->status = AUTH_USER_SIMULTANEOUS_LOGIN;
                 $a_auth->logout();
                 return;
             }
             include_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
             ilOnlineTracking::addUser($user_id);
             include_once 'Modules/Forum/classes/class.ilObjForum.php';
             ilObjForum::_updateOldAccess($user_id);
             require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
             $security_settings = ilSecuritySettings::_getInstance();
             // determine first login of user for setting an indicator
             // which still is available in PersonalDesktop, Repository, ...
             // (last login date is set to current date in next step)
             if ($security_settings->isPasswordChangeOnFirstLoginEnabled() && $user->getLastLogin() == null) {
                 $user->resetLastPasswordChange();
             }
             $user->refreshLogin();
             // reset counter for failed logins
             ilObjUser::_resetLoginAttempts($user_id);
         }
         // --- anonymous/registered user
         $ilLog->write(__METHOD__ . ': logged in as ' . $a_auth->getUsername() . ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] . ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']);
         ilSessionControl::handleLoginEvent($a_auth->getUsername(), $a_auth);
         $ilAppEventHandler->raise('Services/Authentication', 'afterLogin', array('username' => $a_auth->getUsername()));
     }
 }
 /**
  * Check if profile is incomplete
  * Will set the usr_data field profile_incomplete if any required field is missing
  *
  *
  * @access private
  *
  */
 private function checkProfileIncomplete($user_obj)
 {
     include_once "Services/User/classes/class.ilUserProfile.php";
     return ilUserProfile::isProfileIncomplete($user_obj);
 }
 /**
  * Update user
  */
 public function updateObject()
 {
     global $tpl, $rbacsystem, $ilias, $ilUser, $ilSetting;
     // User folder
     if ($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write', $this->usrf_ref_id)) {
         $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
     }
     // if called from local administration $this->usrf_ref_id is category id
     // Todo: this has to be fixed. Do not mix user folder id and category id
     if ($this->usrf_ref_id != USER_FOLDER_ID) {
         // check if user is assigned to category
         if (!$rbacsystem->checkAccess('cat_administrate_users', $this->object->getTimeLimitOwner())) {
             $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"), $this->ilias->error_obj->MESSAGE);
         }
     }
     $this->initForm("edit");
     // we do not want to store this dates, they are only printed out
     unset($_POST['approve_date']);
     $_POST['agree_date'] = $this->object->getAgreeDate();
     unset($_POST['last_login']);
     // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
     $profileMaybeIncomplete = false;
     if ($this->form_gui->getInput('ignore_rf', false)) {
         $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
     }
     if ($this->form_gui->checkInput()) {
         // @todo: external account; time limit
         // if not allowed or empty -> do no change password
         if (ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['auth_mode'])) && trim($_POST['passwd']) != "") {
             $this->object->setPasswd($_POST['passwd'], IL_PASSWD_PLAIN);
         }
         /*
          * reset counter for failed logins
          * if $_POST['active'] is set to 1
          */
         if ($_POST['active'] == 1) {
             ilObjUser::_resetLoginAttempts($this->object->getId());
         }
         #$this->object->assignData($_POST);
         $this->loadValuesFromForm('update');
         $udf = array();
         foreach ($_POST as $k => $v) {
             if (substr($k, 0, 4) == "udf_") {
                 $udf[substr($k, 4)] = $v;
             }
         }
         $this->object->setUserDefinedData($udf);
         try {
             $this->object->updateLogin($_POST['login']);
         } catch (ilUserException $e) {
             ilUtil::sendFailure($e->getMessage());
             $this->form_gui->setValuesByPost();
             return $tpl->setContent($this->form_gui->getHtml());
         }
         $this->object->setTitle($this->object->getFullname());
         $this->object->setDescription($this->object->getEmail());
         if ($this->isSettingChangeable('language')) {
             $this->object->setLanguage($this->form_gui->getInput('language'));
         }
         require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
         if (ilDiskQuotaActivationChecker::_isActive()) {
             // set disk quota
             $this->object->setPref("disk_quota", $_POST["disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
         }
         if (ilDiskQuotaActivationChecker::_isPersonalWorkspaceActive()) {
             // set personal workspace disk quota
             $this->object->setPref("wsp_disk_quota", $_POST["wsp_disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
         }
         if ($this->isSettingChangeable('skin_style')) {
             //set user skin and style
             $sknst = explode(":", $_POST["skin_style"]);
             if ($this->object->getPref("style") != $sknst[1] || $this->object->getPref("skin") != $sknst[0]) {
                 $this->object->setPref("skin", $sknst[0]);
                 $this->object->setPref("style", $sknst[1]);
             }
         }
         if ($this->isSettingChangeable('hits_per_page')) {
             $this->object->setPref("hits_per_page", $_POST["hits_per_page"]);
         }
         if ($this->isSettingChangeable('show_users_online')) {
             $this->object->setPref("show_users_online", $_POST["show_users_online"]);
         }
         if ($this->isSettingChangeable('hide_own_online_status')) {
             $this->object->setPref("hide_own_online_status", $_POST["hide_own_online_status"] ? 'y' : 'n');
         }
         // set a timestamp for last_password_change
         // this ts is needed by ilSecuritySettings
         $this->object->setLastPasswordChangeTS(time());
         global $ilSetting;
         if ((int) $ilSetting->get('session_reminder_enabled')) {
             $this->object->setPref('session_reminder_enabled', (int) $_POST['session_reminder_enabled']);
         }
         // #10054 - profile may have been completed, check below is only for incomplete
         $this->object->setProfileIncomplete(false);
         $this->update = $this->object->update();
         // If the current user is editing its own user account,
         // we update his preferences.
         if ($ilUser->getId() == $this->object->getId()) {
             $ilUser->readPrefs();
         }
         $ilUser->setPref('send_info_mails', $_POST['send_mail'] == 'y' ? 'y' : 'n');
         $ilUser->writePrefs();
         $mail_message = $this->__sendProfileMail();
         $msg = $this->lng->txt('saved_successfully') . $mail_message;
         // same personal image
         if ($this->isSettingChangeable('upload')) {
             $this->uploadUserPictureObject();
         }
         if ($profileMaybeIncomplete) {
             include_once 'Services/User/classes/class.ilUserProfile.php';
             if (ilUserProfile::isProfileIncomplete($this->object)) {
                 $this->object->setProfileIncomplete(true);
                 $this->object->update();
             }
         }
         // feedback
         ilUtil::sendSuccess($msg, true);
         if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
             $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
         } else {
             $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
         }
     } else {
         $this->form_gui->setValuesByPost();
         $tpl->setContent($this->form_gui->getHtml());
     }
 }