コード例 #1
0
 /**
  * @return boolean
  */
 public function adjust()
 {
     if (defined('IL_CERT_SSO')) {
         return false;
     } else {
         if (!ilContext::supportsRedirects()) {
             return false;
         } else {
             if ($this->ctrl->isAsynch()) {
                 return false;
             } else {
                 if (in_array(basename($_SERVER['PHP_SELF']), array('logout.php'))) {
                     return false;
                 } else {
                     if (!$this->user->getId() || $this->user->isAnonymous()) {
                         return false;
                     }
                 }
             }
         }
     }
     foreach ($this->cases as $case) {
         if ($case->isInFulfillment()) {
             return false;
         }
         if ($case->shouldAdjustRequest()) {
             if ($case->shouldStoreRequestTarget()) {
                 $this->storeRequest();
             }
             $case->adjust();
             return true;
         }
     }
     return false;
 }
コード例 #2
0
 /**
  * Returns Ilias User ID. If user is anonymous, a random negative User ID
  * is created, stored in SESSION, and returned.
  *
  * @param ilObjUser $user
  * @return integer
  */
 public function getUserId()
 {
     $user_id = $this->user->getId();
     if ($this->user->isAnonymous()) {
         if (isset($_SESSION['chat'][$this->room->getRoomId()]['user_id'])) {
             return $_SESSION['chat'][$this->room->getRoomId()]['user_id'];
         } else {
             $user_id = mt_rand(-99999, -20);
             $_SESSION['chat'][$this->room->getRoomId()]['user_id'] = $user_id;
             return $user_id;
         }
     } else {
         return $user_id;
     }
 }
コード例 #3
0
 /**
  * Generate Users
  *
  * @param
  * @return
  */
 function generateUsers($a_login_base = "learner", $a_start = 1, $a_end = 1000, $a_firstname = "John", $a_lastname_base = "Learner", $a_pw = "learnerpw", $a_email = "*****@*****.**", $a_gender = "m", $a_lang = "en")
 {
     global $rbacadmin;
     // new users
     $this->log("Creating Users");
     for ($i = $a_start; $i <= $a_end; $i++) {
         $this->log($a_login_base . $i);
         $user = new ilObjUser();
         $user->setLogin($a_login_base . $i);
         $user->setFirstname($a_firstname);
         $user->setLastname($a_lastname_base . " " . $i);
         $user->setGender($a_gender);
         $user->setEmail($a_email);
         $user->setAgreeDate(ilUtil::now());
         $user->setPasswd($a_pw, IL_PASSWD_PLAIN);
         $user->setTitle($user->getFullname());
         $user->setDescription($user->getEmail());
         $user->setLastPasswordChangeTS(time());
         $user->setActive(true);
         $user->setTimeLimitUnlimited(true);
         $user->create();
         $user->setLanguage($a_lang);
         $user->saveAsNew(false);
         $user->writePrefs();
         $rbacadmin->assignUser(4, $user->getId(), true);
     }
 }
コード例 #4
0
 /**
  * @param $a_parent_obj
  * @param string $a_parent_cmd
  * @param ilObjUser $user The user from whom the certificates are displayed
  * @param array $options
  */
 public function __construct($a_parent_obj, $a_parent_cmd = "", ilObjUser $user, array $options = array())
 {
     $this->_user = $user;
     $options['user_id'] = $user->getId();
     $options['columns'] = isset($options['columns']) ? $options['columns'] : $this->columns;
     parent::__construct($a_parent_obj, $a_parent_cmd, $options);
 }
コード例 #5
0
 public static function checkIfReminderMailShouldBeSend(ilObjUser $user, $reminderTime)
 {
     global $ilDB;
     $query = "SELECT ts FROM " . self::TABLE_NAME . " WHERE usr_id = %s";
     $res = $ilDB->queryF($query, array('integer'), array($user->getId()));
     $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
     if ($row->ts == null) {
         self::sendReminder($user, $reminderTime);
         return true;
     }
     return false;
 }
コード例 #6
0
 /**
  */
 protected function initUserInstance()
 {
     if ($this->authorEntity instanceof ilObjUser && $this->authorEntity->getId()) {
         $this->author = $this->authorEntity;
     } else {
         if (is_numeric($this->authorEntity) && $this->authorEntity) {
             // Try to read user instance from preloaded cache array
             $this->author = ilForumAuthorInformationCache::getUserObjectById($this->authorEntity);
             if (!$this->author) {
                 // Get a user instance from forum module's cache method
                 $this->author = ilObjForumAccess::getCachedUserInstance($this->authorEntity);
             }
         }
     }
     if (!$this->author) {
         $this->author = new ilObjUser();
         $this->author->setId(0);
         $this->author->setPref('public_profile', 'n');
         $this->author->setGender('');
     }
 }
コード例 #7
0
 /**
  * Update access time
  * @param ilObjUser $user
  * @return bool
  * @static
  */
 public static function updateAccess(ilObjUser $user)
 {
     /**
      * @var $ilDB      ilDB
      * @var $ilSetting ilSetting
      */
     global $ilDB, $ilSetting;
     if (null === self::$last_access_time) {
         $query = 'SELECT access_time FROM ut_online WHERE usr_id = ' . $ilDB->quote($user->getId(), 'integer');
         $res = $ilDB->query($query);
         if (!$ilDB->numRows($res)) {
             return false;
         }
         $row = $ilDB->fetchAssoc($res);
         self::$last_access_time = $row['access_time'];
     }
     $time_span = (int) $ilSetting->get('tracking_time_span', 300);
     if (($diff = time() - self::$last_access_time) <= $time_span) {
         $ilDB->manipulateF('UPDATE ut_online SET online_time = online_time + %s, access_time = %s WHERE usr_id = %s', array('integer', 'integer', 'integer'), array($diff, time(), $user->getId()));
     } else {
         $ilDB->manipulateF('UPDATE ut_online SET access_time = %s WHERE usr_id = %s', array('integer', 'integer'), array(time(), $user->getId()));
     }
     return true;
 }
コード例 #8
0
 /**
  * Create object in database. Also invokes creating of translation objects.
  *
  * @throws ilOrgUnitTypeException
  */
 public function create()
 {
     $default_lang = $this->getDefaultLang();
     $title = $this->getTranslation('title', $default_lang);
     if (!$default_lang || !$title) {
         throw new ilOrgUnitTypeException($this->lng->txt('orgu_type_msg_missing_title_default_language'));
     }
     $this->id = $this->db->nextId(self::TABLE_NAME);
     $this->db->insert(self::TABLE_NAME, array('id' => array('integer', $this->getId()), 'default_lang' => array('text', $this->getDefaultLang()), 'owner' => array('integer', $this->user->getId()), 'icon' => array('text', $this->getIcon()), 'create_date' => array('text', date('Y-m-d H:i:s')), 'last_update' => array('text', date('Y-m-d H:i:s'))));
     // Create translation(s)
     /** @var $trans ilOrgUnitTypeTranslation */
     foreach ($this->translations as $lang => $trans) {
         $trans->setOrguTypeId($this->getId());
         $trans->create();
     }
 }
コード例 #9
0
 /**
  * @param ilObjUser                        $user
  * @param ilTermsOfServiceSignableDocument $document
  */
 public static function trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
 {
     if (self::isEnabled()) {
         $entity = self::getEntityFactory()->getByName('ilTermsOfServiceAcceptanceEntity');
         $data_gateway = self::getDataGatewayFactory()->getByName('ilTermsOfServiceAcceptanceDatabaseGateway');
         $entity->setUserId($user->getId());
         $entity->setTimestamp(time());
         $entity->setIso2LanguageCode($document->getIso2LanguageCode());
         $entity->setSource($document->getSource());
         $entity->setSourceType($document->getSourceType());
         $entity->setText($document->getContent());
         $entity->setHash(md5($document->getContent()));
         $data_gateway->trackAcceptance($entity);
         $user->writeAccepted();
         // <- Has to be refactored in future releases
         $user->hasToAcceptTermsOfServiceInSession(false);
     }
 }
コード例 #10
0
 /**
  * Access Permissions Table Data
  * @return array
  */
 function getAccessPermissionTableData()
 {
     global $ilAccess, $ilObjDataCache, $objDefinition;
     // get all possible operation of current object
     $ops_list = ilRbacReview::_getOperationList($this->object->getType());
     $counter = 0;
     $result_set = array();
     // check permissions of user
     foreach ($ops_list as $ops) {
         $access = $ilAccess->doRBACCheck($ops['operation'], "info", $this->object->getRefId(), $this->user->getId(), $this->object->getType());
         $result_set[$counter]["img"] = $access ? self::IMG_OK : self::IMG_NOT_OK;
         if (substr($ops['operation'], 0, 7) == "create_" && $objDefinition->isPlugin(substr($ops['operation'], 7))) {
             $result_set[$counter]["operation"] = ilPlugin::lookupTxt("rep_robj", substr($ops['operation'], 7), 'rbac_' . $ops['operation']);
         } else {
             if ($objDefinition->isPlugin($this->object->getType())) {
                 $result_set[$counter]["operation"] = ilPlugin::lookupTxt("rep_robj", $this->object->getType(), $this->object->getType() . "_" . $ops['operation']);
             } elseif (substr($ops['operation'], 0, 7) == 'create_') {
                 $result_set[$counter]["operation"] = $this->lng->txt('rbac_' . $ops['operation']);
             } else {
                 $result_set[$counter]["operation"] = $this->lng->txt($this->object->getType() . "_" . $ops['operation']);
             }
         }
         $list_role = "";
         // Check ownership
         if ($this->user->getId() == $ilObjDataCache->lookupOwner($this->object->getId())) {
             if (substr($ops['operation'], 0, 7) != 'create_' and $ops['operation'] != 'edit_permission' and $ops['operation'] != 'edit_leanring_progress') {
                 $list_role[] = $this->lng->txt('info_owner_of_object');
             }
         }
         // get operations on object for each assigned role to user
         foreach ($this->getAssignedValidRoles() as $role) {
             if (in_array($ops['ops_id'], $role['ops'])) {
                 $list_role[] = $role['translation'];
             }
         }
         if (empty($list_role)) {
             $list_role[] = $this->lng->txt('none');
         }
         $result_set[$counter]["role_ownership"] = $list_role;
         ++$counter;
     }
     return $result_set;
 }
コード例 #11
0
 /**
  * Called after login and successful call of fetch data
  * @return 
  * @param object $a_username
  * @param object $a_auth
  */
 public function loginObserver($a_username, $a_auth)
 {
     global $ilias, $rbacadmin, $lng, $ilSetting;
     $GLOBALS['ilLog']->write(__METHOD__ . ': SOAP login observer called');
     // TODO: handle passed credentials via GET
     /*
     if (empty($_GET["ext_uid"]) || empty($_GET["soap_pw"]))
     {
     	$this->status = AUTH_WRONG_LOGIN;
     	return;
     }
     */
     // Not required anymore
     /*
     $validation_data = $this->validateSoapUser($_GET["ext_uid"], $_GET["soap_pw"]);
     
     if (!$validation_data["valid"])
     {
     	$this->status = AUTH_WRONG_LOGIN;
     	return;
     }
     */
     $local_user = $this->response["local_user"];
     if ($local_user != "") {
         // to do: handle update of user
         $a_auth->setAuth($local_user);
         return true;
     }
     if (!$ilSetting->get("soap_auth_create_users")) {
         $a_auth->status = AUTH_SOAP_NO_ILIAS_USER;
         $a_auth->logout();
         return false;
     }
     //echo "1";
     // try to map external user via e-mail to ILIAS user
     if ($this->response["email"] != "") {
         //echo "2";
         //var_dump ($_POST);
         $email_user = ilObjUser::_getLocalAccountsForEmail($this->response["email"]);
         // check, if password has been provided in user mapping screen
         // (see ilStartUpGUI::showUserMappingSelection)
         // FIXME
         if ($_POST["LoginMappedUser"] != "") {
             if (count($email_user) > 0) {
                 $user = ilObjectFactory::getInstanceByObjId($_POST["usr_id"]);
                 require_once 'Services/User/classes/class.ilUserPasswordManager.php';
                 if (ilUserPasswordManager::getInstance()->verifyPassword($user, ilUtil::stripSlashes($_POST["password"]))) {
                     // password is correct -> map user
                     //$this->setAuth($local_user); (use login not id)
                     ilObjUser::_writeExternalAccount($_POST["usr_id"], $_GET["ext_uid"]);
                     ilObjUser::_writeAuthMode($_POST["usr_id"], "soap");
                     $_GET["cmd"] = $_POST["cmd"] = $_GET["auth_stat"] = "";
                     $local_user = ilObjUser::_lookupLogin($_POST["usr_id"]);
                     $a_auth->status = '';
                     $a_auth->setAuth($local_user);
                     return true;
                 } else {
                     //echo "6"; exit;
                     $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
                     $a_auth->setSubStatus(AUTH_WRONG_LOGIN);
                     $a_auth->logout();
                     return false;
                 }
             }
         }
         if (count($email_user) > 0 && $_POST["CreateUser"] == "") {
             $_GET["email"] = $this->response["email"];
             $a_auth->status = AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL;
             $a_auth->logout();
             return false;
         }
     }
     $userObj = new ilObjUser();
     $local_user = ilAuthUtils::_generateLogin($a_username);
     $newUser["firstname"] = $this->response["firstname"];
     $newUser["lastname"] = $this->response["lastname"];
     $newUser["email"] = $this->response["email"];
     $newUser["login"] = $local_user;
     // to do: set valid password and send mail
     $newUser["passwd"] = "";
     $newUser["passwd_type"] = IL_PASSWD_CRYPTED;
     // generate password, if local authentication is allowed
     // and account mail is activated
     $pw = "";
     if ($ilSetting->get("soap_auth_allow_local") && $ilSetting->get("soap_auth_account_mail")) {
         $pw = ilUtil::generatePasswords(1);
         $pw = $pw[0];
         $newUser["passwd"] = $pw;
         $newUser["passwd_type"] = IL_PASSWD_PLAIN;
     }
     //$newUser["gender"] = "m";
     $newUser["auth_mode"] = "soap";
     $newUser["ext_account"] = $a_username;
     $newUser["profile_incomplete"] = 1;
     // system data
     $userObj->assignData($newUser);
     $userObj->setTitle($userObj->getFullname());
     $userObj->setDescription($userObj->getEmail());
     // set user language to system language
     $userObj->setLanguage($lng->lang_default);
     // Time limit
     $userObj->setTimeLimitOwner(7);
     $userObj->setTimeLimitUnlimited(1);
     $userObj->setTimeLimitFrom(time());
     $userObj->setTimeLimitUntil(time());
     // Create user in DB
     $userObj->setOwner(0);
     $userObj->create();
     $userObj->setActive(1);
     $userObj->updateOwner();
     //insert user data in table user_data
     $userObj->saveAsNew(false);
     // setup user preferences
     $userObj->writePrefs();
     // to do: test this
     $rbacadmin->assignUser($ilSetting->get('soap_auth_user_default_role'), $userObj->getId(), true);
     // send account mail
     if ($ilSetting->get("soap_auth_account_mail")) {
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($ilSetting->get("language"));
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             include_once "Services/Mail/classes/class.ilAccountMail.php";
             $acc_mail = new ilAccountMail();
             if ($pw != "") {
                 $acc_mail->setUserPassword($pw);
             }
             $acc_mail->setUser($userObj);
             $acc_mail->send();
         }
     }
     unset($userObj);
     $a_auth->setAuth($local_user);
     return true;
 }
コード例 #12
0
 /**
  * Get skill presentation HTML
  *
  * @return
  */
 function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false, $a_tref_id = 0)
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting;
     $this->tooltips = array();
     if ($a_user_id == 0) {
         $user = $ilUser;
     } else {
         $user = new ilObjUser($a_user_id);
     }
     $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     $stree = new ilSkillTree();
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     // general settings for the action drop down
     include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $act_list = new ilAdvancedSelectionListGUI();
     $act_list->setListTitle($lng->txt("actions"));
     $act_list->setSelectionHeaderClass("small");
     //		$act_list->setLinksMode("il_ContainerItemCommand2");
     $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
     $act_list->setUseImages(false);
     $b_skills = ilSkillTreeNode::getSkillTreeNodes($a_top_skill_id, true, $a_tref_id);
     foreach ($b_skills as $bs) {
         $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         reset($path);
         $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
         $level_data = $skill->getLevelData();
         if ($this->mode == "gap") {
             if ($this->getProfileId() > 0) {
                 $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
             $this->renderActualLevelsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             $this->renderGapSelfEvalRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             $this->renderSuggestedResources($tpl, $level_data, $bs["id"], $bs["tref"]);
         } else {
             if ($this->getProfileId() > 0) {
                 $this->renderProfileTargetRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
             $this->renderMaterialsRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             // get date of self evaluation
             $se_date = ilPersonalSkill::getSelfEvaluationDate($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
             $se_rendered = $se_date == "" ? true : false;
             // get all object triggered entries and render them
             foreach ($skill->getAllLevelEntriesOfUser($bs["tref"], $user->getId()) as $level_entry) {
                 // render the self evaluation at the correct position within the list of object triggered entries
                 if ($se_date > $level_entry["status_date"] && !$se_rendered) {
                     $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
                     $se_rendered = true;
                 }
                 $this->renderObjectEvalRow($tpl, $level_data, $level_entry);
             }
             // if not rendered yet, render self evaluation now
             if (!$se_rendered) {
                 $this->renderSelfEvaluationRow($tpl, $level_data, $a_top_skill_id, $bs["id"], $bs["tref"]);
             }
         }
         $too_low = true;
         $current_target_level = 0;
         foreach ($level_data as $k => $v) {
             // level
             $tpl->setCurrentBlock("level_td");
             $tpl->setVariable("VAL_LEVEL", $v["title"]);
             $tt_id = "skmg_skl_tt_" . self::$skill_tt_cnt;
             self::$skill_tt_cnt++;
             $tpl->setVariable("TT_ID", $tt_id);
             if ($v["description"] != "") {
                 ilTooltipGUI::addTooltip($tt_id, $v["description"]);
             }
             $tpl->parseCurrentBlock();
             // profile targel level
             /*
             				foreach ($this->profile_levels as $pl)
             				{
             					if ($pl["level_id"] == $v["id"] &&
             						$pl["base_skill_id"] == $v["skill_id"])
             					{
             						$too_low = true;
             						$current_target_level = $v["id"];
             					}
             				}
             				else
             				{
             					$tpl->setVariable("VAL_SELF_EVAL", " ");
             				}
             				$tpl->parseCurrentBlock();
             				if ($v["id"] == $se_level)
             				{
             					$found = true;
             				}
             
             				// assigned materials
             				if ($this->use_materials)
             				{
             
             					$mat_cnt = ilPersonalSkill::countAssignedMaterial($user->getId(),
             						$bs["tref"], $v["id"]);
             					if ($mat_cnt == 0)
             					{
             						$tpl->setCurrentBlock("material_td");
             						$tpl->setVariable("VAL_MATERIAL", " ");
             						$tpl->parseCurrentBlock();
             					}
             					else
             					{					
             						// links to material files
             						$tpl->setCurrentBlock("material_links");
             											
             						$mat_tt = array();
             						$cnt = 1;
             						foreach(ilPersonalSkill::getAssignedMaterial($user->getId(),
             							$bs["tref"], $v["id"]) as $item)
             						{												
             							$mat_data = $this->getMaterialInfo($item["wsp_id"]);
             							$tpl->setVariable("URL_MATERIAL", $mat_data[1]);
             							$tpl->setVariable("TXT_MATERIAL", $cnt);
             							
             							// tooltip
             							$mat_tt_id = "skmg_skl_tt_mat_".self::$skill_tt_cnt;
             							self::$skill_tt_cnt++;
             							$tpl->setVariable("TOOLTIP_MATERIAL_ID", $mat_tt_id);
             							
             							if(!$this->offline_mode)
             							{
             								ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
             							}
             							else
             							{							
             								$this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
             							}
             							
             							$tpl->parseCurrentBlock();
             							$cnt++;
             						}																	
             						
             						$tpl->setCurrentBlock("material_td");
             						$tpl->setVariable("CLASS_MAT", "ilSkillMat");
             						$tpl->parseCurrentBlock();
             					}
             				}
             */
         }
         $title = $sep = "";
         $found = false;
         foreach ($path as $p) {
             if ($found) {
                 $title .= $sep . $p["title"];
                 $sep = " > ";
             }
             if ($a_top_skill_id == $p["child"]) {
                 $found = true;
             }
         }
         $tpl->setCurrentBlock("skill");
         $tpl->setVariable("BSKILL_TITLE", $title);
         /*			$tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
         			$tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
         			if ($this->use_materials)
         			{
         				$tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
         			}*/
         $tpl->setVariable("TXT_TARGET", $lng->txt("skmg_target_level"));
         $tpl->setVariable("TXT_360_SURVEY", $lng->txt("skmg_360_survey"));
         if ($a_edit) {
             $act_list->flush();
             $act_list->setId("act_" . $a_top_skill_id . "_" . $bs["id"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
             if ($this->use_materials) {
                 $act_list->addItem($lng->txt('skmg_assign_materials'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
             }
             $act_list->addItem($lng->txt('skmg_self_evaluation'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
             $tpl->setVariable("ACTIONS2", $act_list->getHTML());
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($a_top_skill_id));
     if ($a_edit) {
         $act_list->flush();
         $act_list->setId("act_" . $a_top_skill_id);
         $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
         //			$act_list->addItem($lng->txt('skmg_assign_materials'), "",
         //				$ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
         $act_list->addItem($lng->txt('skmg_remove_skill'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
         $tpl->setVariable("ACTIONS1", $act_list->getHTML());
     }
     return $tpl->get();
 }
コード例 #13
0
ファイル: ilObjUserTest.php プロジェクト: arlendotcn/ilias
 /**
  * Clipboard
  * @group IL_Init
  */
 public function testClipboard()
 {
     $value = "";
     // creation
     $user = new ilObjUser();
     $d = array("login" => "aatestuser3", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "f", "firstname" => "Heidi", "lastname" => "Kabel", "email" => "*****@*****.**");
     $user->assignData($d);
     $user->setActive(true);
     $user->create();
     $user->saveAsNew();
     $user->setLanguage("de");
     $user->writePrefs();
     $id = $user->getId();
     $user->addObjectToClipboard($id, "user", "aatestuser");
     $user->addObjectToClipboard(56, "mump", "mumpitz");
     if ($user->clipboardHasObjectsOfType("user")) {
         $value .= "clip1-";
     }
     $user->clipboardDeleteObjectsOfType("user");
     if ($user->clipboardHasObjectsOfType("mump") && !$user->clipboardHasObjectsOfType("user")) {
         $value .= "clip2-";
     }
     $objs = $user->getClipboardObjects("mump");
     if (is_array($objs) && count($objs) == 1 && $objs[0]["id"] == 56) {
         $value .= "clip3-";
     }
     $objs = $user->getClipboardChilds(56, "2008-10-10");
     $us = ilObjUser::_getUsersForClipboadObject("mump", 56);
     if (is_array($us) && count($us) == 1 && $us[0] == $id) {
         $value .= "clip4-";
     }
     $user->delete();
     $this->assertEquals("clip1-clip2-clip3-clip4-", $value);
 }
コード例 #14
0
 /**
  * @see ilAuthContainerBase::loginObserver()
  */
 public function loginObserver($a_username, $a_auth)
 {
     global $ilias, $rbacadmin, $ilSetting, $ilLog, $PHPCAS_CLIENT;
     $ilLog->write(__METHOD__ . ': Successful CAS login.');
     // Radius with ldap as data source
     include_once './Services/LDAP/classes/class.ilLDAPServer.php';
     if (ilLDAPServer::isDataSourceActive(AUTH_CAS)) {
         return $this->handleLDAPDataSource($a_auth, $a_username);
     }
     include_once "./Services/CAS/lib/CAS.php";
     if ($PHPCAS_CLIENT->getUser() != "") {
         $username = $PHPCAS_CLIENT->getUser();
         $ilLog->write(__METHOD__ . ': Username: '******'./Services/User/classes/class.ilObjUser.php';
         $local_user = ilObjUser::_checkExternalAuthAccount("cas", $username);
         if ($local_user != "") {
             $a_auth->setAuth($local_user);
         } else {
             if (!$ilSetting->get("cas_create_users")) {
                 $a_auth->status = AUTH_CAS_NO_ILIAS_USER;
                 $a_auth->logout();
                 return false;
             }
             $userObj = new ilObjUser();
             $local_user = ilAuthUtils::_generateLogin($username);
             $newUser["firstname"] = $local_user;
             $newUser["lastname"] = "";
             $newUser["login"] = $local_user;
             // set "plain md5" password (= no valid password)
             $newUser["passwd"] = "";
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             //$newUser["gender"] = "m";
             $newUser["auth_mode"] = "cas";
             $newUser["ext_account"] = $username;
             $newUser["profile_incomplete"] = 1;
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             // set user language to system language
             $userObj->setLanguage($ilSetting->get("language"));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Create user in DB
             $userObj->setOwner(0);
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // setup user preferences
             $userObj->writePrefs();
             // to do: test this
             $rbacadmin->assignUser($ilSetting->get('cas_user_default_role'), $userObj->getId(), true);
             unset($userObj);
             $a_auth->setAuth($local_user);
             return true;
         }
     } else {
         $ilLog->write(__METHOD__ . ': Login failed.');
         // This should never occur unless CAS is not configured properly
         $a_auth->status = AUTH_WRONG_LOGIN;
         return false;
     }
     return false;
 }
コード例 #15
0
 /**
  * Get skill presentation HTML
  *
  * @return
  */
 function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false)
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting;
     $this->tooltips = array();
     if ($a_user_id == 0) {
         $user = $ilUser;
     } else {
         $user = new ilObjUser($a_user_id);
     }
     $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     $stree = new ilSkillTree();
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     // general settings for the action drop down
     include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $act_list = new ilAdvancedSelectionListGUI();
     $act_list->setListTitle($lng->txt("actions"));
     $act_list->setSelectionHeaderClass("small");
     //		$act_list->setLinksMode("il_ContainerItemCommand2");
     $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
     $act_list->setUseImages(false);
     $b_skills = ilSkillTreeNode::getSkillTreeNodes($a_top_skill_id, true);
     foreach ($b_skills as $bs) {
         $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         reset($path);
         $se_level = ilPersonalSkill::getSelfEvaluation($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
         $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
         $level_data = $skill->getLevelData();
         // check, if current self eval level is in current level data
         $valid_sel_level = false;
         if ($se_level > 0) {
             foreach ($level_data as $k => $v) {
                 if ($v["id"] == $se_level) {
                     $valid_sel_level = true;
                 }
             }
         }
         reset($level_data);
         $found = false;
         foreach ($level_data as $k => $v) {
             // level
             $tpl->setCurrentBlock("level_td");
             $tpl->setVariable("VAL_LEVEL", $v["title"]);
             $tt_id = "skmg_skl_tt_" . self::$skill_tt_cnt;
             self::$skill_tt_cnt++;
             $tpl->setVariable("TT_ID", $tt_id);
             if ($v["description"] != "") {
                 ilTooltipGUI::addTooltip($tt_id, $v["description"]);
             }
             $tpl->parseCurrentBlock();
             // self evaluation
             $tpl->setCurrentBlock("self_eval_td");
             if ($valid_sel_level && !$found) {
                 $tpl->setVariable("VAL_SELF_EVAL", "x");
                 $tpl->setVariable("CLASS_SELF_EVAL", "ilSkillSelf");
             } else {
                 $tpl->setVariable("VAL_SELF_EVAL", " ");
             }
             $tpl->parseCurrentBlock();
             if ($v["id"] == $se_level) {
                 $found = true;
             }
             // assigned materials
             if ($this->use_materials) {
                 $mat_cnt = ilPersonalSkill::countAssignedMaterial($user->getId(), $bs["tref"], $v["id"]);
                 if ($mat_cnt == 0) {
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("VAL_MATERIAL", " ");
                     $tpl->parseCurrentBlock();
                 } else {
                     // links to material files
                     $tpl->setCurrentBlock("material_links");
                     $mat_tt = array();
                     $cnt = 1;
                     foreach (ilPersonalSkill::getAssignedMaterial($user->getId(), $bs["tref"], $v["id"]) as $item) {
                         $mat_data = $this->getMaterialInfo($item["wsp_id"]);
                         $tpl->setVariable("URL_MATERIAL", $mat_data[1]);
                         $tpl->setVariable("TXT_MATERIAL", $cnt);
                         // tooltip
                         $mat_tt_id = "skmg_skl_tt_mat_" . self::$skill_tt_cnt;
                         self::$skill_tt_cnt++;
                         $tpl->setVariable("TOOLTIP_MATERIAL_ID", $mat_tt_id);
                         if (!$this->offline_mode) {
                             ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
                         } else {
                             $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
                         }
                         $tpl->parseCurrentBlock();
                         $cnt++;
                     }
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("CLASS_MAT", "ilSkillMat");
                     $tpl->parseCurrentBlock();
                 }
             }
         }
         $title = $sep = "";
         $found = false;
         foreach ($path as $p) {
             if ($found) {
                 $title .= $sep . $p["title"];
                 $sep = " > ";
             }
             if ($a_top_skill_id == $p["child"]) {
                 $found = true;
             }
         }
         $tpl->setCurrentBlock("skill");
         $tpl->setVariable("BSKILL_TITLE", $title);
         $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
         $tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
         if ($this->use_materials) {
             $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
         }
         if ($a_edit) {
             $act_list->flush();
             $act_list->setId("act_" . $a_top_skill_id . "_" . $bs["id"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
             if ($this->use_materials) {
                 $act_list->addItem($lng->txt('skmg_assign_materials'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
             }
             $act_list->addItem($lng->txt('skmg_self_evaluation'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
             $tpl->setVariable("ACTIONS2", $act_list->getHTML());
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($a_top_skill_id));
     if ($a_edit) {
         $act_list->flush();
         $act_list->setId("act_" . $a_top_skill_id);
         $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
         //			$act_list->addItem($lng->txt('skmg_assign_materials'), "",
         //				$ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
         $act_list->addItem($lng->txt('skmg_remove_skill'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
         $tpl->setVariable("ACTIONS1", $act_list->getHTML());
     }
     return $tpl->get();
 }
コード例 #16
0
 /**
  * Check user agreement for every request
  * 
  * @param ilObjUser $a_user
  */
 protected static function checkUserAgreement(ilObjUser $a_user)
 {
     // are we currently in user agreement acceptance?
     if (strtolower($_GET["cmdClass"]) == "ilstartupgui" && (strtolower($_GET["cmd"]) == "getacceptance" || is_array($_POST["cmd"]) && key($_POST["cmd"]) == "getAcceptance")) {
         return;
     }
     if (!$a_user->hasAcceptedUserAgreement() && $a_user->getId() != ANONYMOUS_USER_ID && $a_user->checkTimeLimit()) {
         if (!defined('IL_CERT_SSO')) {
             self::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=' . $_GET['target'] . '&cmd=getAcceptance', 'User Agreement not accepted.');
         }
     }
 }
コード例 #17
0
 /**
  * Update enrolment status
  * @param type $a_obj_id
  * @param ilObjUser $user
  * @param type $a_status
  * @return boolean
  */
 protected static function updateEnrolmentStatus($a_obj_id, ilObjUser $user, $a_status)
 {
     include_once './Services/WebServices/ECS/classes/class.ilECSRemoteUser.php';
     $remote = ilECSRemoteUser::factory($user->getId());
     if (!$remote instanceof ilECSRemoteUser) {
         return FALSE;
     }
     include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatus.php';
     $enrol = new ilECSEnrolmentStatus();
     $enrol->setId('il_' . $GLOBALS['ilSetting']->get('inst_id', 0) . '_' . ilObject::_lookupType($a_obj_id) . '_' . $a_obj_id);
     $enrol->setPersonId($remote->getRemoteUserId());
     $enrol->setPersonIdType(ilECSEnrolmentStatus::ID_UID);
     $enrol->setStatus($a_status);
     try {
         include_once './Services/WebServices/ECS/classes/Connectors/class.ilECSEnrolmentStatusConnector.php';
         $con = new ilECSEnrolmentStatusConnector(ilECSSetting::getInstanceByServerId(1));
         $con->addEnrolmentStatus($enrol, $remote->getMid());
     } catch (ilECSConnectorException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': update enrolment status faild with message: ' . $e->getMessage());
         return false;
     }
 }
コード例 #18
0
 public static function _createRandomUserAccount($keyarray)
 {
     global $ilDB, $ilUser, $ilSetting, $rbacadmin;
     if ($_SESSION['create_user_account'] != NULL) {
         $obj_user = new ilObjUser($_SESSION['create_user_account']);
         return $obj_user;
     } else {
         $userLogin = array();
         $res = $ilDB->query('SELECT sequence FROM object_data_seq');
         $row = $ilDB->fetchAssoc($res);
         $temp_user_id = (int) $row['sequence'] + 1;
         $userLogin['login'] = '******' . $temp_user_id;
         $userLogin['passwd'] = ilUtil::generatePasswords(1);
         require_once 'Services/User/classes/class.ilObjUser.php';
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         $obj_user = new ilObjUser();
         $obj_user->setId($temp_user_id);
         $obj_user->setLogin($userLogin['login']);
         $obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
         $_SESSION['tmp_user_account']['login'] = $userLogin['login'];
         $_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
         $obj_user->setFirstname($keyarray['first_name']);
         $obj_user->setLastname($keyarray['last_name']);
         $obj_user->setEmail($keyarray['payer_email']);
         #	$obj_user->setEmail('*****@*****.**');
         $obj_user->setGender('f');
         $obj_user->setLanguage($ilSetting->get("language"));
         $obj_user->setActive(true);
         $obj_user->setTimeLimitUnlimited(true);
         $obj_user->setTitle($obj_user->getFullname());
         $obj_user->setDescription($obj_user->getEmail());
         $obj_user->setTimeLimitOwner(7);
         $obj_user->setTimeLimitUnlimited(1);
         $obj_user->setTimeLimitMessage(0);
         $obj_user->setApproveDate(date("Y-m-d H:i:s"));
         // Set default prefs
         $obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
         $obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
         $obj_user->writePrefs();
         // at the first login the user must complete profile
         $obj_user->setProfileIncomplete(true);
         $obj_user->create();
         $obj_user->saveAsNew();
         $user_role = ilObject::_exists(4, false);
         if (!$user_role) {
             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
             $reg_allowed = ilObjRole::_lookupRegisterAllowed();
             $user_role = $reg_allowed[0]['id'];
         } else {
             $user_role = 4;
         }
         $rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
         include_once "Services/Mail/classes/class.ilMimeMail.php";
         global $ilias, $lng;
         $settings = $ilias->getAllSettings();
         $mmail = new ilMimeMail();
         $mmail->autoCheck(false);
         $mmail->From($settings["admin_email"]);
         $mmail->To($obj_user->getEmail());
         // mail subject
         $subject = $lng->txt("reg_mail_subject");
         // mail body
         $body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
         $body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
         $body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
         $body .= "\n";
         $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
         $body .= $obj_user->getProfileAsString($lng);
         $mmail->Subject($subject);
         $mmail->Body($body);
         $mmail->Send();
         $_SESSION['create_user_account'] = $obj_user->getId();
         return $obj_user;
     }
 }
コード例 #19
0
 public static function applyRoleAssignments(ilObjUser $user, $code)
 {
     include_once './Services/Registration/classes/class.ilRegistrationCode.php';
     $grole = ilRegistrationCode::getCodeRole($code);
     if ($grole) {
         $GLOBALS['rbacadmin']->assignUser($grole, $user->getId());
     }
     $code_data = ilRegistrationCode::getCodeData($code);
     if ($code_data["role_local"]) {
         $code_local_roles = explode(";", $code_data["role_local"]);
         foreach ((array) $code_local_roles as $role_id) {
             $GLOBALS['rbacadmin']->assignUser($role_id, $user->getId());
             // patch to remove for 45 due to mantis 21953
             $role_obj = $GLOBALS['rbacreview']->getObjectOfRole($role_id);
             switch (ilObject::_lookupType($role_obj)) {
                 case 'crs':
                 case 'grp':
                     $role_refs = ilObject::_getAllReferences($role_obj);
                     $role_ref = end($role_refs);
                     ilObjUser::_addDesktopItem($user->getId(), $role_ref, ilObject::_lookupType($role_obj));
                     break;
             }
         }
     }
     return true;
 }
コード例 #20
0
 /**
  * @param      $a_username
  * @param      $password
  * @param bool $isChallengeResponse
  * @return bool|void
  * @throws ilLDAPQueryException
  */
 function fetchData($a_username, $password, $isChallengeResponse = false)
 {
     /**
      * @var $ilDB      ilDB
      * @var $ilSetting ilSetting
      * @var $rbacadmin ilRbacAdmin
      */
     global $ilDB, $ilSetting, $rbacadmin;
     $settings = new ilSetting('apache_auth');
     if (!$settings->get('apache_enable_auth')) {
         return false;
     }
     if (!$settings->get('apache_auth_indicator_name') || !$settings->get('apache_auth_indicator_value')) {
         return false;
     }
     if (!ilUtil::isLogin($a_username)) {
         return false;
     }
     if ($a_username == 'anonymous' && $password == 'anonymous') {
         $query = 'SELECT * FROM usr_data WHERE login = %s';
         $qres = $ilDB->queryF($query, array('text'), array($a_username));
         $userRow = $ilDB->fetchAssoc($qres);
         if (is_array($userRow) && $userRow['usr_id']) {
             // user as a local account...
             // fetch logindata
             $this->activeUser = $userRow['login'];
             foreach ($userRow as $key => $value) {
                 if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                     continue;
                 }
                 // Use reference to the auth object if exists
                 // This is because the auth session variable can change so a static call to setAuthData does not make sense
                 $this->_auth_obj->setAuthData($key, $value);
             }
             $this->_auth_obj->setAuth($userRow['login']);
             return true;
         }
         return false;
     }
     if (!$_SESSION['login_invalid'] && in_array($_SERVER[$settings->get('apache_auth_indicator_name')], array_filter(array_map('trim', str_getcsv($settings->get('apache_auth_indicator_value')))))) {
         // we have a valid apache auth
         $list = array($ilSetting->get('auth_mode'));
         // Respect the auth method sequence
         include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
         $det = ilAuthModeDetermination::_getInstance();
         if (!$det->isManualSelection() && $det->getCountActiveAuthModes() > 1) {
             $list = array();
             foreach (ilAuthModeDetermination::_getInstance()->getAuthModeSequence() as $auth_mode) {
                 $list[] = $auth_mode;
             }
         }
         foreach ($list as $auth_mode) {
             if (AUTH_LDAP == $auth_mode) {
                 // if no local user has been found AND ldap lookup is enabled
                 if ($settings->get('apache_enable_ldap')) {
                     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
                     $this->server = new ilLDAPServer(ilLDAPServer::_getFirstActiveServer());
                     $this->server->doConnectionCheck();
                     $config = $this->server->toPearAuthArray();
                     $query = new ilLDAPQuery($this->server);
                     $query->bind();
                     $ldapUser = $query->fetchUser($a_username);
                     if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][$config['userattr']] == $a_username) {
                         $ldapUser[$a_username]['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                         $user_data = $ldapUser[$a_username];
                         //array_change_key_case($a_auth->getAuthData(),CASE_LOWER);
                         if ($this->server->enabledSyncOnLogin()) {
                             if (!$user_data['ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !self::$force_creation) {
                                 $this->_auth_obj->logout();
                                 $_SESSION['tmp_auth_mode'] = 'ldap';
                                 $_SESSION['tmp_external_account'] = $a_username;
                                 $_SESSION['tmp_pass'] = $_POST['password'];
                                 include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
                                 $roles = ilLDAPRoleAssignmentRules::getAssignmentsForCreation($a_username, $user_data);
                                 $_SESSION['tmp_roles'] = array();
                                 foreach ($roles as $info) {
                                     if ($info['action'] == ilLDAPRoleAssignmentRules::ROLE_ACTION_ASSIGN) {
                                         $_SESSION['tmp_roles'][] = $info['id'];
                                     }
                                 }
                                 ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
                             }
                             if ($this->updateRequired($a_username)) {
                                 $this->initLDAPAttributeToUser();
                                 $this->ldap_attr_to_user->setUserData($ldapUser);
                                 $this->ldap_attr_to_user->refresh();
                                 $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                             } else {
                                 // User exists and no update required
                                 $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                             }
                         }
                         if ($user_data['ilInternalAccount']) {
                             $this->_auth_obj->setAuth($user_data['ilInternalAccount']);
                             $this->_auth_obj->username = $user_data['ilInternalAccount'];
                             return true;
                         }
                     }
                 }
             } else {
                 if (AUTH_APACHE != $auth_mode && $settings->get('apache_enable_local')) {
                     $condition = '';
                     if ($ilSetting->get("auth_mode") && $ilSetting->get("auth_mode") == 'ldap') {
                         $condition = " AND auth_mode != " . $ilDB->quote('default', 'text') . " ";
                     }
                     $query = "SELECT * FROM usr_data WHERE login = %s AND auth_mode != %s {$condition}";
                     $qres = $ilDB->queryF($query, array('text', 'text'), array($a_username, 'ldap'));
                     $userRow = $ilDB->fetchAssoc($qres);
                     if (is_array($userRow) && $userRow['usr_id']) {
                         // user as a local account...
                         // fetch logindata
                         $this->activeUser = $userRow['login'];
                         foreach ($userRow as $key => $value) {
                             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                                 continue;
                             }
                             // Use reference to the auth object if exists
                             // This is because the auth session variable can change so a static call to setAuthData does not make sense
                             $this->_auth_obj->setAuthData($key, $value);
                         }
                         $this->_auth_obj->setAuth($userRow['login']);
                         return true;
                     }
                 }
             }
         }
         if ($settings->get('apache_enable_local') && $settings->get('apache_local_autocreate')) {
             if ($_GET['r']) {
                 $_SESSION['profile_complete_redirect'] = $_GET['r'];
             }
             $user = new ilObjUser();
             $user->setLogin($a_username);
             $user->setExternalAccount($a_username);
             $user->setProfileIncomplete(true);
             $user->create();
             $user->setAuthMode('apache');
             // set a timestamp for last_password_change
             // this ts is needed by ilSecuritySettings
             $user->setLastPasswordChangeTS(time());
             $user->setTimeLimitUnlimited(1);
             $user->setActive(1);
             //insert user data in table user_data
             $user->saveAsNew();
             $user->writePrefs();
             $rbacadmin->assignUser($settings->get('apache_default_role', 4), $user->getId(), true);
             return true;
         }
     } else {
         if (defined('IL_CERT_SSO') && IL_CERT_SSO) {
             define('APACHE_ERRORCODE', AUTH_APACHE_FAILED);
         }
     }
     return false;
 }
コード例 #21
0
 /**
  * @param ilChatRoom $room
  * @param int        $scope
  * @param ilObjUser  $inviter
  * @param int        $invited_id
  * @return array
  */
 public function inviteToPrivateRoom(ilChatRoom $room, $scope, ilObjUser $inviter, $invited_id)
 {
     $chat_user = new ilChatroomUser($inviter, $room);
     $user_id = $chat_user->getUserId();
     if ($scope) {
         $room->inviteUserToPrivateRoom($invited_id, $scope);
         $message = json_encode(array('type' => 'private_room_created', 'users' => $invited_id, 'timestamp' => date('c'), 'public' => 0, 'title' => ilChatroom::lookupPrivateRoomTitle($scope), 'proom_id' => $scope, 'message' => array('public' => '0', 'user' => 'system', 'owner' => $user_id)));
         $this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
     }
     if ($room->isSubscribed($user_id)) {
         $message = json_encode(array('type' => 'user_invited', 'title' => ilChatroom::lookupPrivateRoomTitle($scope), 'proom_id' => $scope, 'inviter' => $inviter->getId(), 'invited' => $invited_id));
         $this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
     }
     return array('success' => true, 'message' => 'users invited');
 }
コード例 #22
0
 /**
  * migrate account
  *
  * @access public
  * 
  */
 public function migrateAccount()
 {
     global $lng, $ilClientIniFile, $ilLog, $rbacadmin;
     $lng->loadLanguageModule('auth');
     if (!isset($_POST['account_migration'])) {
         $this->showAccountMigration($lng->txt('err_choose_migration_type'));
         return false;
     }
     if ($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password']))) {
         $this->showAccountMigration($lng->txt('err_wrong_login'));
         return false;
     }
     if ($_POST['account_migration'] == 1) {
         if (!($user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))) {
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $_POST['username'] = $_POST['mig_username'];
         $_POST['password'] = $_POST['mig_password'];
         include_once './Services/Authentication/classes/class.ilAuthFactory.php';
         include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
         $ilAuth = ilAuthFactory::factory(new ilAuthContainerMDB2());
         $ilAuth->start();
         if (!$ilAuth->checkAuth()) {
             $ilAuth->logout();
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $user = new ilObjUser($user_id);
         $user->setAuthMode(ilSession::get('tmp_auth_mode'));
         $user->setExternalAccount(ilSession::get('tmp_external_account'));
         $user->setActive(true);
         $user->update();
         // Assign to default role
         if (is_array(ilSession::get('tmp_roles'))) {
             foreach (ilSession::get('tmp_roles') as $role) {
                 $rbacadmin->assignUser((int) $role, $user->getId());
             }
         }
         // Log migration
         $ilLog->write(__METHOD__ . ': Migrated ' . ilSession::get('tmp_external_account') . ' to ILIAS account ' . $user->getLogin() . '.');
     } elseif ($_POST['account_migration'] == 2) {
         switch (ilSession::get('tmp_auth_mode')) {
             case 'apache':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/AuthApache/classes/class.ilAuthContainerApache.php';
                 $container = new ilAuthContainerApache();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'ldap':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/LDAP/classes/class.ilAuthContainerLDAP.php';
                 $container = new ilAuthContainerLDAP();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'radius':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
                 $container = new ilAuthContainerRadius();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'openid':
                 $_POST['username'] = ilSession::get('dummy');
                 $_POST['password'] = ilSession::get('dummy');
                 $_POST['oid_username'] = ilSession::get('tmp_oid_username');
                 $_POST['oid_provider'] = ilSession::get('tmp_oid_provider');
                 //ilSession::set('force_creation', true);
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
                 $container = new ilAuthContainerOpenId();
                 $container->forceCreation(true);
                 ilAuthFactory::setContext(ilAuthFactory::CONTEXT_OPENID);
                 include_once './Services/OpenId/classes/class.ilAuthOpenId.php';
                 $ilAuth = ilAuthFactory::factory($container);
                 // logout first to initiate a new login session
                 $ilAuth->logout();
                 ilSession::_destroy(session_id());
                 ilSession::set('force_creation', true);
                 $ilAuth->start();
         }
         // Redirect to acceptance
         ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=" . $_GET["target"] . "&cmd=getAcceptance");
     }
     // show personal desktop
     ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
 }
コード例 #23
0
 function initIlias($context = "web")
 {
     global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile, $ilSetting, $ilias, $https, $ilObjDataCache, $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp, $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
     // remove unsafe characters
     $this->removeUnsafeCharacters();
     // error reporting
     // remove notices from error reporting
     if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
         error_reporting(ini_get("error_reporting") & ~E_NOTICE & ~E_DEPRECATED);
     } else {
         error_reporting(ini_get('error_reporting') & ~E_NOTICE);
     }
     // include common code files
     $this->requireCommonIncludes();
     global $ilBench;
     // set error handler (to do: check preconditions for error handler to work)
     $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
     $ilErr = new ilErrorHandling();
     $GLOBALS['ilErr'] =& $ilErr;
     $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, 'errorHandler'));
     $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
     // prepare file access to work with safe mode (has been done in class ilias before)
     umask(0117);
     // set cookie params
     $this->setCookieParams();
     // $ilIliasIniFile initialisation
     $this->initIliasIniFile();
     // CLIENT_ID determination
     $this->determineClient();
     // $ilAppEventHandler initialisation
     $this->initEventHandling();
     // $ilClientIniFile initialisation
     $this->initClientIniFile();
     // removed redirection madness the service should respond with SERVICE UNAVAILABLE
     // $ilDB initialisation
     $this->initDatabase();
     // init plugin admin class
     include_once "Services/Component/classes/class.ilPluginAdmin.php";
     $ilPluginAdmin = new ilPluginAdmin();
     $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
     // set session handler
     $this->setSessionHandler();
     // $ilSetting initialisation
     $this->initSettings();
     // $ilLog initialisation
     $this->initLog();
     // $https initialisation
     require_once 'classes/class.ilHTTPS.php';
     $https = new ilHTTPS();
     $GLOBALS['https'] =& $https;
     $https->enableSecureCookies();
     $https->checkPort();
     if ($this->returnBeforeAuth()) {
         return;
     }
     $ilCtrl = new ilCtrl2();
     $GLOBALS['ilCtrl'] =& $ilCtrl;
     // $ilAuth initialisation
     include_once "Services/Authentication/classes/class.ilAuthUtils.php";
     ilAuthUtils::_initAuth();
     global $ilAuth;
     $this->includePhp5Compliance();
     // Do not accept external session ids
     if (!ilSession::_exists(session_id())) {
         // $_GET["PHPSESSID"] = "";
         session_regenerate_id();
     }
     // $ilias initialisation
     global $ilias, $ilBench;
     $ilBench->start("Core", "HeaderInclude_GetILIASObject");
     $ilias = new ILIAS();
     $GLOBALS['ilias'] =& $ilias;
     $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
     // $ilObjDataCache initialisation
     $ilObjDataCache = new ilObjectDataCache();
     $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
     // workaround: load old post variables if error handler 'message' was called
     if (isset($_SESSION["message"]) && $_SESSION["message"]) {
         $_POST = $_SESSION["post_vars"];
     }
     // put debugging functions here
     require_once "include/inc.debug.php";
     // $objDefinition initialisation
     $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
     $objDefinition = new ilObjectDefinition();
     $GLOBALS['objDefinition'] =& $objDefinition;
     // $objDefinition->startParsing();
     $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
     // init tree
     $tree = new ilTree(ROOT_FOLDER_ID);
     $GLOBALS['tree'] =& $tree;
     // $ilAccess and $rbac... initialisation
     $this->initAccessHandling();
     // authenticate & start session
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
     $ilBench->start("Core", "HeaderInclude_Authentication");
     //var_dump($_SESSION);
     ////require_once('Log.php');
     ////$ilAuth->logger = Log::singleton('error_log',PEAR_LOG_TYPE_SYSTEM,'TEST');
     ////$ilAuth->enableLogging = true;
     if (!defined("IL_PHPUNIT_TEST")) {
         $oldSid = session_id();
         $ilAuth->start();
         $newSid = session_id();
         include_once 'Services/Payment/classes/class.ilPaymentShoppingCart.php';
         ilPaymentShoppingCart::_migrateShoppingCart($oldSid, $newSid);
     }
     //var_dump($_SESSION);
     $ilias->setAuthError($ilErr->getLastError());
     $ilBench->stop("Core", "HeaderInclude_Authentication");
     // workaround: force login
     if (!empty($_GET["cmd"]) && $_GET["cmd"] == "force_login" || $this->script == "login.php") {
         $ilAuth->logout();
         if (!isset($_GET['forceShoppingCartRedirect'])) {
             $_SESSION = array();
         }
         $_SESSION["AccountId"] = "";
         $ilAuth->start();
         $ilias->setAuthError($ilErr->getLastError());
     }
     // check correct setup
     if (!$ilias->getSetting("setup_ok")) {
         die("Setup is not completed. Please run setup routine again.");
     }
     // $ilUser initialisation (1)
     $ilBench->start("Core", "HeaderInclude_getCurrentUser");
     $ilUser = new ilObjUser();
     $ilias->account =& $ilUser;
     $GLOBALS['ilUser'] =& $ilUser;
     $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
     // $ilCtrl initialisation
     //$ilCtrl = new ilCtrl();
     // determin current script and up-path to main directory
     // (sets $this->script and $this->updir)
     $this->determineScriptAndUpDir();
     // $styleDefinition initialisation and style handling for login and co.
     $this->initStyle();
     if (in_array($this->script, array("login.php", "register.php", "view_usr_agreement.php")) || $_GET["baseClass"] == "ilStartUpGUI") {
         $this->handleStyle();
     }
     // init locale
     $this->initLocale();
     // handle ILIAS 2 imported users:
     // check ilias 2 password, if authentication failed
     // only if AUTH_LOCAL
     //echo "A";
     if (AUTH_CURRENT == AUTH_LOCAL && !$ilAuth->getAuth() && $this->script == "login.php" && $_POST["username"] != "") {
         if (ilObjUser::_lookupHasIlias2Password(ilUtil::stripSlashes($_POST["username"]))) {
             if (ilObjUser::_switchToIlias3Password(ilUtil::stripSlashes($_POST["username"]), ilUtil::stripSlashes($_POST["password"]))) {
                 $ilAuth->start();
                 $ilias->setAuthError($ilErr->getLastError());
                 ilUtil::redirect("index.php");
             }
         }
     }
     //
     // SUCCESSFUL AUTHENTICATION
     //
     if ($ilAuth->getStatus() == '' && $ilias->account->isCurrentUserActive() || defined("IL_PHPUNIT_TEST") && DEVMODE) {
         //echo "C"; exit;
         $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
         //var_dump($_SESSION);
         // get user data
         $this->initUserAccount();
         //var_dump($_SESSION);
         // differentiate account security mode
         require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
         $security_settings = ilSecuritySettings::_getInstance();
         if ($security_settings->getAccountSecurityMode() == ilSecuritySettings::ACCOUNT_SECURITY_MODE_CUSTOMIZED) {
             // reset counter for failed logins
             ilObjUser::_resetLoginAttempts($ilUser->getId());
         }
         $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
     } else {
         if (!$ilAuth->getAuth()) {
             require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
             // differentiate account security mode
             $security = ilSecuritySettings::_getInstance();
             if ($security->getAccountSecurityMode() == ilSecuritySettings::ACCOUNT_SECURITY_MODE_CUSTOMIZED) {
                 if (isset($_POST['username']) && $_POST['username'] && $ilUser->getId() == 0) {
                     $username = ilUtil::stripSlashes($_POST['username']);
                     $usr_id = ilObjUser::_lookupId($username);
                     if ($usr_id != ANONYMOUS_USER_ID) {
                         ilObjUser::_incrementLoginAttempts($usr_id);
                         $login_attempts = ilObjUser::_getLoginAttempts($usr_id);
                         $max_attempts = $security->getLoginMaxAttempts();
                         if ($login_attempts >= $max_attempts && $usr_id != SYSTEM_USER_ID && $max_attempts > 0) {
                             ilObjUser::_setUserInactive($usr_id);
                         }
                     }
                 }
             }
         }
     }
     //
     // SUCCESSFUL AUTHENTICATED or NON-AUTH-AREA (Login, Registration, ...)
     //
     // $lng initialisation
     $this->initLanguage();
     // store user language in tree
     $GLOBALS['tree']->initLangCode();
     // ### AA 03.10.29 added new LocatorGUI class ###
     // when locator data array does not exist, initialise
     if (!isset($_SESSION["locator_level"])) {
         $_SESSION["locator_data"] = array();
         $_SESSION["locator_level"] = -1;
     }
     // initialise global ilias_locator object
     // ECS Tasks
     include_once 'Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php';
     $scheduler = ilECSTaskScheduler::start();
     $ilBench->stop("Core", "HeaderInclude");
 }
コード例 #24
0
 /**
  * Login function
  *
  * @access private
  * @return void
  */
 function login()
 {
     global $ilias, $rbacadmin, $ilSetting;
     if (!empty($_SERVER[$ilias->getSetting('shib_login')])) {
         // Store user's Shibboleth sessionID for logout
         $this->session['shibboleth_session_id'] = $_SERVER['Shib-Session-ID'];
         // Get loginname of user, new login name is generated if user is new
         $username = $this->generateLogin();
         // Authorize this user
         $this->setAuth($username);
         $userObj = new ilObjUser();
         // Check wether this account exists already, if not create it
         if (!ilObjUser::getUserIdByLogin($username)) {
             $newUser["firstname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]);
             $newUser["lastname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]);
             $newUser["login"] = $username;
             // Password must be random to prevent users from manually log in using the login data from Shibboleth users
             $newUser["passwd"] = md5(end(ilUtil::generatePasswords(1)));
             $newUser["passwd_type"] = IL_PASSWD_MD5;
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $newUser["gender"] = $_SERVER[$ilias->getSetting('shib_gender')];
             }
             // Save mapping between ILIAS user and Shibboleth uniqueID
             $newUser["ext_account"] = $_SERVER[$ilias->getSetting('shib_login')];
             // other data
             $newUser["title"] = $_SERVER[$ilias->getSetting('shib_title')];
             $newUser["institution"] = $_SERVER[$ilias->getSetting('shib_institution')];
             $newUser["department"] = $_SERVER[$ilias->getSetting('shib_department')];
             $newUser["street"] = $_SERVER[$ilias->getSetting('shib_street')];
             $newUser["city"] = $_SERVER[$ilias->getSetting('shib_city')];
             $newUser["zipcode"] = $_SERVER[$ilias->getSetting('shib_zipcode')];
             $newUser["country"] = $_SERVER[$ilias->getSetting('shib_country')];
             $newUser["phone_office"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]);
             $newUser["phone_home"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]);
             $newUser["phone_mobile"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]);
             $newUser["fax"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_fax')]);
             $newUser["matriculation"] = $_SERVER[$ilias->getSetting('shib_matriculation')];
             $newUser["email"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]);
             $newUser["hobby"] = $_SERVER[$ilias->getSetting('shib_hobby')];
             $newUser["auth_mode"] = "shibboleth";
             // system data
             $userObj->assignData($newUser);
             $userObj->setTitle($userObj->getFullname());
             $userObj->setDescription($userObj->getEmail());
             $userObj->setLanguage($this->getFirstString($_SERVER[$ilias->getSetting('shib_language')]));
             // Time limit
             $userObj->setTimeLimitOwner(7);
             $userObj->setTimeLimitUnlimited(1);
             $userObj->setTimeLimitFrom(time());
             $userObj->setTimeLimitUntil(time());
             // Modify user data before creating the user
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             // Create use in DB
             $userObj->create();
             $userObj->setActive(1);
             $userObj->updateOwner();
             //insert user data in table user_data
             $userObj->saveAsNew();
             // store acceptance of user agreement
             //$userObj->writeAccepted();
             // Default prefs
             $userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
             $userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
             // setup user preferences
             $userObj->writePrefs();
             //set role entries
             #$rbacadmin->assignUser($ilias->getSetting('shib_user_default_role'), $userObj->getId(),true);
             // New role assignment
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::doAssignments($userObj->getId(), $_SERVER);
             // Authorize this user
             $this->setAuth($userObj->getLogin());
         } else {
             // Update user account
             $uid = $userObj->checkUserId();
             $userObj->setId($uid);
             $userObj->read($uid);
             if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
                 $userObj->setGender($_SERVER[$ilias->getSetting('shib_gender')]);
             }
             if ($ilias->getSetting('shib_update_title')) {
                 $userObj->setTitle($_SERVER[$ilias->getSetting('shib_title')]);
             }
             $userObj->setFirstname($this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]));
             $userObj->setLastname($this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]));
             $userObj->setFullname();
             if ($ilias->getSetting('shib_update_institution')) {
                 $userObj->setInstitution($_SERVER[$ilias->getSetting('shib_institution')]);
             }
             if ($ilias->getSetting('shib_update_department')) {
                 $userObj->setDepartment($_SERVER[$ilias->getSetting('shib_department')]);
             }
             if ($ilias->getSetting('shib_update_street')) {
                 $userObj->setStreet($_SERVER[$ilias->getSetting('shib_street')]);
             }
             if ($ilias->getSetting('shib_update_city')) {
                 $userObj->setCity($_SERVER[$ilias->getSetting('shib_city')]);
             }
             if ($ilias->getSetting('shib_update_zipcode')) {
                 $userObj->setZipcode($_SERVER[$ilias->getSetting('shib_zipcode')]);
             }
             if ($ilias->getSetting('shib_update_country')) {
                 $userObj->setCountry($_SERVER[$ilias->getSetting('shib_country')]);
             }
             if ($ilias->getSetting('shib_update_phone_office')) {
                 $userObj->setPhoneOffice($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]));
             }
             if ($ilias->getSetting('shib_update_phone_home')) {
                 $userObj->setPhoneHome($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]));
             }
             if ($ilias->getSetting('shib_update_phone_mobile')) {
                 $userObj->setPhoneMobile($this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]));
             }
             if ($ilias->getSetting('shib_update_fax')) {
                 $userObj->setFax($_SERVER[$ilias->getSetting('shib_fax')]);
             }
             if ($ilias->getSetting('shib_update_matriculation')) {
                 $userObj->setMatriculation($_SERVER[$ilias->getSetting('shib_matriculation')]);
             }
             if ($ilias->getSetting('shib_update_email')) {
                 $userObj->setEmail($this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]));
             }
             if ($ilias->getSetting('shib_update_hobby')) {
                 $userObj->setHobby($_SERVER[$ilias->getSetting('shib_hobby')]);
             }
             if ($ilias->getSetting('shib_update_language')) {
                 $userObj->setLanguage($_SERVER[$ilias->getSetting('shib_language')]);
             }
             // Include custom code that can be used to further modify
             // certain Shibboleth user attributes
             if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
                 include $ilias->getSetting('shib_data_conv');
             }
             $userObj->update();
             // Update role assignments
             include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
             ilShibbolethRoleAssignmentRules::updateAssignments($userObj->getId(), $_SERVER);
         }
         // we are authenticated: redirect, if possible
         if ($_GET["target"] != "") {
             ilUtil::redirect("goto.php?target=" . $_GET["target"] . "&client_id=" . CLIENT_ID);
         }
     } else {
         // This should never occur unless Shibboleth is not configured properly
         $this->status = AUTH_WRONG_LOGIN;
     }
 }
コード例 #25
0
ファイル: class.ilChatroom.php プロジェクト: bheyser/qplskl
 /**
  * Returns an multidimensional array containing userdata from users
  * having an entry in banTable with matching roomId.
  *
  * @global ilDBMySQL $ilDB
  * @return array
  */
 public function getBannedUsers()
 {
     global $ilDB;
     $query = 'SELECT * FROM ' . self::$banTable . ' WHERE room_id = %s ';
     $types = array('integer');
     $values = array($this->getRoomId());
     $rset = $ilDB->queryF($query, $types, $values);
     $result = array();
     if ($rset) {
         while ($row = $ilDB->fetchAssoc($rset)) {
             if ($row['user_id'] > 0) {
                 $user = new ilObjUser($row['user_id']);
                 $userdata = array('user_id' => $user->getId(), 'firstname' => $user->getFirstname(), 'lastname' => $user->getLastname(), 'login' => $user->getLogin(), 'remark' => $row['remark']);
                 $result[] = $userdata;
             } else {
                 //@todo anonymous user
             }
         }
     }
     return $result;
 }
コード例 #26
0
 /**
  * update existing user
  *
  * @access protected
  */
 protected function updateUser(ilECSUser $user, $a_local_user_id)
 {
     global $ilClientIniFile, $ilLog, $rbacadmin;
     $user_obj = new ilObjUser($a_local_user_id);
     $user_obj->setFirstname($user->getFirstname());
     $user_obj->setLastname($user->getLastname());
     $user_obj->setEmail($user->getEmail());
     $user_obj->setInstitution($user->getInstitution());
     $user_obj->setActive(true);
     $until = $user_obj->getTimeLimitUntil();
     $user_obj->setTimeLimitFrom(time() - 5);
     if ($until < time() + $ilClientIniFile->readVariable('session', 'expire')) {
         $user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
     }
     $user_obj->update();
     $user_obj->refreshLogin();
     if ($global_role = $this->getCurrentServer()->getGlobalRole()) {
         $rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $user_obj->getId(), true);
     }
     $ilLog->write(__METHOD__ . ': Finished update of remote user with usr_id: ' . $user->getImportId());
     return $user_obj->getLogin();
 }
コード例 #27
0
 function fetchData($a_username, $password, $isChallengeResponse = false)
 {
     //var_dump(func_get_args());
     //var_dump($_SERVER);
     global $lng;
     $settings = new ilSetting('apache_auth');
     if (!$settings->get('apache_enable_auth')) {
         return false;
     }
     if (!$settings->get('apache_auth_indicator_name') || !$settings->get('apache_auth_indicator_value')) {
         return false;
     }
     if (!ilUtil::isLogin($a_username)) {
         return false;
     }
     if ($a_username == 'anonymous' && $password == 'anonymous') {
         global $ilDB;
         $query = 'SELECT * FROM usr_data WHERE login = %s';
         $qres = $ilDB->queryF($query, array('text'), array($a_username));
         $userRow = $ilDB->fetchAssoc($qres);
         if (is_array($userRow) && $userRow['usr_id']) {
             // user as a local account...
             // fetch logindata
             $this->activeUser = $userRow['login'];
             foreach ($userRow as $key => $value) {
                 if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                     continue;
                 }
                 // Use reference to the auth object if exists
                 // This is because the auth session variable can change so a static call to setAuthData does not make sense
                 $this->_auth_obj->setAuthData($key, $value);
             }
             //var_dump($userRow);
             $this->_auth_obj->setAuth($userRow['login']);
             return true;
         }
         return false;
     }
     if (!$_SESSION['login_invalid'] && $_SERVER[$settings->get('apache_auth_indicator_name')] == $settings->get('apache_auth_indicator_value')) {
         // we have a valid apache auth
         global $ilDB;
         if ($settings->get('apache_enable_local')) {
             $query = 'SELECT * FROM usr_data WHERE login = %s OR (auth_mode = %s AND ext_account = %s)';
             $qres = $ilDB->queryF($query, array('text', 'text', 'text'), array($a_username, 'apache', $a_username));
             $userRow = $ilDB->fetchAssoc($qres);
             if (is_array($userRow) && $userRow['usr_id']) {
                 // user as a local account...
                 // fetch logindata
                 $this->activeUser = $userRow['login'];
                 foreach ($userRow as $key => $value) {
                     if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                         continue;
                     }
                     // Use reference to the auth object if exists
                     // This is because the auth session variable can change so a static call to setAuthData does not make sense
                     $this->_auth_obj->setAuthData($key, $value);
                 }
                 //var_dump($userRow);
                 $this->_auth_obj->setAuth($userRow['login']);
                 return true;
             }
         }
         // if no local user has been found AND ldap lookup is enabled
         if ($settings->get('apache_enable_ldap')) {
             include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
             $this->server = new ilLDAPServer(ilLDAPServer::_getFirstActiveServer());
             $this->server->doConnectionCheck();
             $config = $this->server->toPearAuthArray();
             $query = new ilLDAPQuery($this->server);
             $ldapUser = $query->fetchUser($a_username);
             if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][$config['userattr']] == $a_username) {
                 $ldapUser[$a_username]['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                 $user_data = $ldapUser[$a_username];
                 //array_change_key_case($a_auth->getAuthData(),CASE_LOWER);
                 if ($this->server->enabledSyncOnLogin()) {
                     if (!$user_data['ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !self::$force_creation) {
                         $this->_auth_obj->logout();
                         $_SESSION['tmp_auth_mode'] = 'apache';
                         $_SESSION['tmp_external_account'] = $a_username;
                         $_SESSION['tmp_pass'] = $_POST['password'];
                         include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
                         $roles = ilLDAPRoleAssignmentRules::getAssignmentsForCreation($a_username, $user_data);
                         $_SESSION['tmp_roles'] = array();
                         foreach ($roles as $info) {
                             if ($info['action'] == ilLDAPRoleAssignmentRules::ROLE_ACTION_ASSIGN) {
                                 $_SESSION['tmp_roles'][] = $info['id'];
                             }
                         }
                         ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
                         exit;
                     }
                     if ($this->updateRequired($a_username)) {
                         $this->initLDAPAttributeToUser();
                         $this->ldap_attr_to_user->setUserData($ldapUser);
                         $this->ldap_attr_to_user->refresh();
                         $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                     } else {
                         // User exists and no update required
                         $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                     }
                 }
                 if ($user_data['ilInternalAccount']) {
                     $this->_auth_obj->setAuth($user_data['ilInternalAccount']);
                     return true;
                 }
             }
         }
         if ($settings->get('apache_enable_local') && $settings->get('apache_local_autocreate')) {
             // no local user, no ldap match or ldap not activated
             //				if (!self::$force_creation)
             //				{
             //					$_SESSION['tmp_auth_mode'] = 'apache';
             //					$_SESSION['tmp_external_account'] = $a_username;
             //					$_SESSION['tmp_pass'] = $_POST['password'];
             //ilUtil::redirect('https://lernwelt.janposselt.de/ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
             //				}
             //				else
             //				{
             global $ilIliasIniFile;
             if ($_GET['r']) {
                 $_SESSION['profile_complete_redirect'] = $_GET['r'];
             }
             $user = new ilObjUser();
             $user->setLogin($a_username);
             $user->setExternalAccount($a_username);
             $user->setProfileIncomplete(true);
             $user->create();
             $user->setAuthMode('apache');
             // set a timestamp for last_password_change
             // this ts is needed by ilSecuritySettings
             $user->setLastPasswordChangeTS(time());
             $user->setTimeLimitUnlimited(1);
             $user->setActive(1);
             //insert user data in table user_data
             $user->saveAsNew();
             $user->writePrefs();
             global $rbacadmin;
             $rbacadmin->assignUser($settings->get('apache_default_role', 4), $user->getId(), true);
             return true;
             //				}
         }
     } else {
         if (defined('IL_CERT_SSO') && IL_CERT_SSO) {
             define('APACHE_ERRORCODE', AUTH_APACHE_FAILED);
         }
     }
     return false;
 }
コード例 #28
0
 /**
  * @param integer $obj_id
  * @param string $title
  * @param string $description
  * @param ilDateTime $start_date
  * @param ilDateTime $end_date
  * @param string $instructions
  * @param string $contact_info
  * @param integer $permanent_room
  * @param string $access_level
  * @param integer $read_contents
  * @param integer $read_records
  * @param integer $folder_id
  * @throws ilException
  */
 public function publishCreationAC($obj_id, $title, $description, $start_date, $end_date, $instructions, $contact_info, $permanent_room, $access_level = self::ACCESS_LEVEL_PROTECTED, $read_contents, $read_records, $folder_id)
 {
     /**
      * @var $ilDB   ilDB
      * */
     global $ilDB;
     $owner_id = ilObject::_lookupOwner($obj_id);
     $ownerObj = new ilObjUser($owner_id);
     // receive breeze session
     $session = $this->xmlApi->getBreezeSession();
     if (!$session) {
         throw new ilException('xavc_connection_error');
     }
     // access check
     if (!$this->xmlApi->login($this->adminLogin, $this->adminPass, $session)) {
         throw new ilException('xavc_authentication_error');
     }
     // receive folder id
     $this->externalLogin = $this->checkExternalUser($ownerObj->getId());
     $folder_id = $this->getFolderIdByLogin($this->externalLogin);
     if (!$folder_id) {
         throw new ilException('xavc_folder_not_available');
     }
     $obj_title_suffix_enabled = ilAdobeConnectServer::getSetting('obj_title_suffix');
     if ($obj_title_suffix_enabled) {
         $title = $title . '_' . CLIENT_ID . '_' . $obj_id;
     }
     // create meeting room
     $arr_meeting = $this->xmlApi->addMeeting($title, $description, date('Y-m-d', $start_date->getUnixTime()), date('H:i', $start_date->getUnixTime()), date('Y-m-d', $end_date->getUnixTime()), date('H:i', $end_date->getUnixTime()), $folder_id, $session);
     $meeting_id = $arr_meeting['meeting_id'];
     $meeting_url = $arr_meeting['meeting_url'];
     if (!$meeting_id) {
         throw new ilException('xavc_meeting_creation_error');
     }
     if (ilAdobeConnectServer::getSetting('user_assignment_mode') != ilAdobeConnectServer::ASSIGN_USER_SWITCH) {
         //Normal Case (not SWITCH aai)
         if ($this->externalLogin == NULL) {
             throw new ilException('xavc_external_login_error');
         } else {
             $this->xmlApi->addUser($this->externalLogin, $ownerObj->getEmail(), $ownerObj->getPasswd(), $ownerObj->getFirstName(), $ownerObj->getLastName(), $session);
         }
         $this->xmlApi->updateMeetingParticipant($meeting_id, $this->externalLogin, $session, 'host');
     } else {
         //In the SWITCH aai case, every user already exists thanks to "cave"
         //Add ILIAS-user himself
         $this->xmlApi->addMeetingHost($meeting_id, $ownerObj->getEmail(), $session);
         //Add technical user
         $this->xmlApi->updateMeetingParticipant($meeting_id, ilAdobeConnectServer::getSetting('login'), $session, 'host');
     }
     $this->xmlApi->updatePermission($meeting_id, $session, $access_level);
     $ilDB->insert('rep_robj_xavc_data', array('id' => array('integer', $obj_id), 'sco_id' => array('integer', $meeting_id), 'start_date' => array('integer', $start_date->getUnixTime()), 'end_date' => array('integer', $end_date->getUnixTime()), 'instructions' => array('text', $instructions), 'contact_info' => array('text', $contact_info), 'permanent_room' => array('integer', (int) $permanent_room), 'perm_read_contents' => array('integer', (int) $this->getReadContents()), 'perm_read_records' => array('integer', (int) $this->getReadRecords()), 'folder_id' => array('integer', $folder_id), 'url_path' => array('text', $meeting_url)));
 }
コード例 #29
0
 /**
  * Check permissions
  */
 protected function checkPermission()
 {
     $allowed_roles = ilCertificateConfig::get('roles_administrate_certificate_types');
     return $this->rbac->isAssignedToAtLeastOneGivenRole($this->user->getId(), json_decode($allowed_roles, true));
 }
コード例 #30
0
 /**
  * handler for end of element when in import user mode.
  */
 function importEndTag($a_xml_parser, $a_name)
 {
     global $ilias, $rbacadmin, $rbacreview, $ilUser, $lng, $ilSetting;
     switch ($a_name) {
         case "Role":
             $this->roles[$this->current_role_id]["name"] = $this->cdata;
             $this->roles[$this->current_role_id]["type"] = $this->current_role_type;
             $this->roles[$this->current_role_id]["action"] = $this->current_role_action;
             break;
         case "PersonalPicture":
             switch ($this->personalPicture["encoding"]) {
                 case "Base64":
                     $this->personalPicture["content"] = base64_decode($this->cdata);
                     break;
                 case "UUEncode":
                     // this only works with PHP >= 5
                     if (version_compare(PHP_VERSION, '5', '>=')) {
                         $this->personalPicture["content"] = convert_uudecode($this->cdata);
                     }
                     break;
             }
             break;
         case "User":
             $this->userObj->setFullname();
             // Fetch the user_id from the database, if we didn't have it in xml file
             // fetch as well, if we are trying to insert -> recognize duplicates!
             if ($this->user_id == -1 || $this->action == "Insert") {
                 $user_id = ilObjUser::getUserIdByLogin($this->userObj->getLogin());
             } else {
                 $user_id = $this->user_id;
             }
             //echo $user_id.":".$this->userObj->getLogin();
             // Handle conflicts
             switch ($this->conflict_rule) {
                 case IL_FAIL_ON_CONFLICT:
                     // do not change action
                     break;
                 case IL_UPDATE_ON_CONFLICT:
                     switch ($this->action) {
                         case "Insert":
                             if ($user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_replaced"), "Insert", "Update"));
                                 $this->action = "Update";
                             }
                             break;
                         case "Update":
                             if (!$user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_replaced"), "Update", "Insert"));
                                 $this->action = "Insert";
                             }
                             break;
                         case "Delete":
                             if (!$user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Delete"));
                                 $this->action = "Ignore";
                             }
                             break;
                     }
                     break;
                 case IL_IGNORE_ON_CONFLICT:
                     switch ($this->action) {
                         case "Insert":
                             if ($user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Insert"));
                                 $this->action = "Ignore";
                             }
                             break;
                         case "Update":
                             if (!$user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Update"));
                                 $this->action = "Ignore";
                             }
                             break;
                         case "Delete":
                             if (!$user_id) {
                                 $this->logWarning($this->userObj->getLogin(), sprintf($lng->txt("usrimport_action_ignored"), "Delete"));
                                 $this->action = "Ignore";
                             }
                             break;
                     }
                     break;
             }
             // check external account conflict (if external account is already used)
             // note: we cannot apply conflict rules in the same manner as to logins here
             // so we ignore records with already existing external accounts.
             //echo $this->userObj->getAuthMode().'h';
             $am = $this->userObj->getAuthMode() == "default" || $this->userObj->getAuthMode() == "" ? ilAuthUtils::_getAuthModeName($ilSetting->get('auth_mode')) : $this->userObj->getAuthMode();
             $loginForExternalAccount = $this->userObj->getExternalAccount() == "" ? "" : ilObjUser::_checkExternalAuthAccount($am, $this->userObj->getExternalAccount());
             switch ($this->action) {
                 case "Insert":
                     if ($loginForExternalAccount != "") {
                         $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_insert_ext_account_exists") . " (" . $this->userObj->getExternalAccount() . ")");
                         $this->action = "Ignore";
                     }
                     break;
                 case "Update":
                     // this variable describes the ILIAS login which belongs to the given external account!!!
                     // it is NOT nescessarily the ILIAS login of the current user record !!
                     // so if we found an ILIAS login according to the authentication method
                     // check if the ILIAS login belongs to the current user record, otherwise somebody else is using it!
                     if ($loginForExternalAccount != "") {
                         // check if we changed the value!
                         $externalAccountHasChanged = $this->userObj->getExternalAccount() != ilObjUser::_lookupExternalAccount($this->user_id);
                         // if it has changed and the external login
                         if ($externalAccountHasChanged && trim($loginForExternalAccount) != trim($this->userObj->getLogin())) {
                             $this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_no_update_ext_account_exists") . " (" . $this->userObj->getExternalAccount() . ")");
                             $this->action = "Ignore";
                         }
                     }
                     break;
             }
             // Perform the action
             switch ($this->action) {
                 case "Insert":
                     if ($user_id) {
                         $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_insert"));
                     } else {
                         if (!strlen($this->currPassword) == 0) {
                             switch ($this->currPasswordType) {
                                 case "ILIAS2":
                                     $this->userObj->setPasswd($this->currPassword, IL_PASSWD_CRYPT);
                                     break;
                                 case "ILIAS3":
                                     $this->userObj->setPasswd($this->currPassword, IL_PASSWD_MD5);
                                     break;
                                 case "PLAIN":
                                     $this->userObj->setPasswd($this->currPassword, IL_PASSWD_PLAIN);
                                     $this->acc_mail->setUserPassword($this->currPassword);
                                     break;
                             }
                         } else {
                             // this does the trick for empty passwords
                             // since a MD5 string has always 32 characters,
                             // no hashed password combination will ever equal to
                             // an empty string
                             $this->userObj->setPasswd("", IL_PASSWD_MD5);
                         }
                         $this->userObj->setTitle($this->userObj->getFullname());
                         $this->userObj->setDescription($this->userObj->getEmail());
                         if (!$this->time_limit_owner_set) {
                             $this->userObj->setTimeLimitOwner($this->getFolderId());
                         }
                         // default time limit settings
                         if (!$this->time_limit_set) {
                             $this->userObj->setTimeLimitUnlimited(1);
                             $this->userObj->setTimeLimitMessage(0);
                             if (!$this->approve_date_set) {
                                 $this->userObj->setApproveDate(date("Y-m-d H:i:s"));
                             }
                         }
                         $this->userObj->setActive($this->currActive == 'true' || is_null($this->currActive));
                         // Finally before saving new user.
                         // Check if profile is incomplete
                         // #8759
                         if (count($this->udf_data)) {
                             $this->userObj->setUserDefinedData($this->udf_data);
                         }
                         $this->userObj->setProfileIncomplete($this->checkProfileIncomplete($this->userObj));
                         $this->userObj->create();
                         //insert user data in table user_data
                         $this->userObj->saveAsNew(false);
                         // Set default prefs
                         $this->userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
                         $this->userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
                         if (count($this->prefs)) {
                             foreach ($this->prefs as $key => $value) {
                                 if ($key != "mail_incoming_type" && $key != "mail_signature" && $key != "mail_linebreak") {
                                     $this->userObj->setPref($key, $value);
                                 }
                             }
                         }
                         $this->userObj->writePrefs();
                         // update mail preferences, to be extended
                         $this->updateMailPreferences($this->userObj->getId());
                         if (is_array($this->personalPicture)) {
                             if (strlen($this->personalPicture["content"])) {
                                 $extension = "jpg";
                                 if (preg_match("/.*(png|jpg|gif|jpeg)\$/", $this->personalPicture["imagetype"], $matches)) {
                                     $extension = $matches[1];
                                 }
                                 $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".{$extension}");
                                 if (strlen($tmp_name)) {
                                     ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId());
                                     unlink($tmp_name);
                                 }
                             }
                         }
                         if ($this->ilincdata["id"]) {
                             include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php';
                             $ilinc_user = new ilObjiLincUser($this->userObj);
                             $ilinc_user->setVar("id", $this->ilincdata["id"]);
                             $ilinc_user->setVar("login", $this->ilincdata["login"]);
                             $ilinc_user->setVar("passwd", $this->ilincdata["password"]);
                             $ilinc_user->update();
                         }
                         //set role entries
                         foreach ($this->roles as $role_id => $role) {
                             if ($this->role_assign[$role_id]) {
                                 $this->assignToRole($this->userObj, $this->role_assign[$role_id]);
                             }
                         }
                         if (count($this->udf_data)) {
                             include_once './Services/User/classes/class.ilUserDefinedData.php';
                             $udd = new ilUserDefinedData($this->userObj->getId());
                             foreach ($this->udf_data as $field => $value) {
                                 $udd->set("f_" . $field, $value);
                             }
                             $udd->update();
                         }
                         $this->sendAccountMail();
                         $this->logSuccess($this->userObj->getLogin(), $this->userObj->getId(), "Insert");
                         // reset account mail object
                         $this->acc_mail->reset();
                     }
                     break;
                 case "Update":
                     if (!$user_id) {
                         $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_update"));
                     } else {
                         $updateUser = new ilObjUser($user_id);
                         $updateUser->read();
                         $updateUser->readPrefs();
                         if ($this->currPassword != null) {
                             switch ($this->currPasswordType) {
                                 case "ILIAS2":
                                     $updateUser->setPasswd($this->currPassword, IL_PASSWD_CRYPT);
                                     break;
                                 case "ILIAS3":
                                     $updateUser->setPasswd($this->currPassword, IL_PASSWD_MD5);
                                     break;
                                 case "PLAIN":
                                     $updateUser->setPasswd($this->currPassword, IL_PASSWD_PLAIN);
                                     $this->acc_mail->setUserPassword($this->currPassword);
                                     break;
                             }
                         }
                         if (!is_null($this->userObj->getFirstname())) {
                             $updateUser->setFirstname($this->userObj->getFirstname());
                         }
                         if (!is_null($this->userObj->getLastname())) {
                             $updateUser->setLastname($this->userObj->getLastname());
                         }
                         if (!is_null($this->userObj->getUTitle())) {
                             $updateUser->setUTitle($this->userObj->getUTitle());
                         }
                         if (!is_null($this->userObj->getGender())) {
                             $updateUser->setGender($this->userObj->getGender());
                         }
                         if (!is_null($this->userObj->getEmail())) {
                             $updateUser->setEmail($this->userObj->getEmail());
                         }
                         if (!is_null($this->userObj->getBirthday())) {
                             $updateUser->setBirthday($this->userObj->getBirthday());
                         }
                         if (!is_null($this->userObj->getInstitution())) {
                             $updateUser->setInstitution($this->userObj->getInstitution());
                         }
                         if (!is_null($this->userObj->getStreet())) {
                             $updateUser->setStreet($this->userObj->getStreet());
                         }
                         if (!is_null($this->userObj->getCity())) {
                             $updateUser->setCity($this->userObj->getCity());
                         }
                         if (!is_null($this->userObj->getZipCode())) {
                             $updateUser->setZipCode($this->userObj->getZipCode());
                         }
                         if (!is_null($this->userObj->getCountry())) {
                             $updateUser->setCountry($this->userObj->getCountry());
                         }
                         if (!is_null($this->userObj->getPhoneOffice())) {
                             $updateUser->setPhoneOffice($this->userObj->getPhoneOffice());
                         }
                         if (!is_null($this->userObj->getPhoneHome())) {
                             $updateUser->setPhoneHome($this->userObj->getPhoneHome());
                         }
                         if (!is_null($this->userObj->getPhoneMobile())) {
                             $updateUser->setPhoneMobile($this->userObj->getPhoneMobile());
                         }
                         if (!is_null($this->userObj->getFax())) {
                             $updateUser->setFax($this->userObj->getFax());
                         }
                         if (!is_null($this->userObj->getHobby())) {
                             $updateUser->setHobby($this->userObj->getHobby());
                         }
                         if (!is_null($this->userObj->getComment())) {
                             $updateUser->setComment($this->userObj->getComment());
                         }
                         if (!is_null($this->userObj->getDepartment())) {
                             $updateUser->setDepartment($this->userObj->getDepartment());
                         }
                         if (!is_null($this->userObj->getMatriculation())) {
                             $updateUser->setMatriculation($this->userObj->getMatriculation());
                         }
                         if (!is_null($this->currActive)) {
                             $updateUser->setActive($this->currActive == "true", is_object($ilUser) ? $ilUser->getId() : 0);
                         }
                         if (!is_null($this->userObj->getClientIP())) {
                             $updateUser->setClientIP($this->userObj->getClientIP());
                         }
                         if (!is_null($this->userObj->getTimeLimitUnlimited())) {
                             $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited());
                         }
                         if (!is_null($this->userObj->getTimeLimitFrom())) {
                             $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom());
                         }
                         if (!is_null($this->userObj->getTimeLimitUntil())) {
                             $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil());
                         }
                         if (!is_null($this->userObj->getTimeLimitMessage())) {
                             $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage());
                         }
                         if (!is_null($this->userObj->getApproveDate())) {
                             $updateUser->setApproveDate($this->userObj->getApproveDate());
                         }
                         if (!is_null($this->userObj->getAgreeDate())) {
                             $updateUser->setAgreeDate($this->userObj->getAgreeDate());
                         }
                         if (!is_null($this->userObj->getLanguage())) {
                             $updateUser->setLanguage($this->userObj->getLanguage());
                         }
                         if (!is_null($this->userObj->getExternalAccount())) {
                             $updateUser->setExternalAccount($this->userObj->getExternalAccount());
                         }
                         // Fixed: if auth_mode is not set, it was always overwritten with auth_default
                         #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
                         if ($this->auth_mode_set) {
                             $updateUser->setAuthMode($this->userObj->getAuthMode());
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("aim"))) {
                             $updateUser->setInstantMessengerId("aim", $this->userObj->getInstantMessengerId("aim"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("msn"))) {
                             $updateUser->setInstantMessengerId("msn", $this->userObj->getInstantMessengerId("msn"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("icq"))) {
                             $updateUser->setInstantMessengerId("icq", $this->userObj->getInstantMessengerId("icq"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("yahoo"))) {
                             $updateUser->setInstantMessengerId("yahoo", $this->userObj->getInstantMessengerId("yahoo"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("skype"))) {
                             $updateUser->setInstantMessengerId("skype", $this->userObj->getInstantMessengerId("skype"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("jabber"))) {
                             $updateUser->setInstantMessengerId("jabber", $this->userObj->getInstantMessengerId("jabber"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("voip"))) {
                             $updateUser->setInstantMessengerId("voip", $this->userObj->getInstantMessengerId("voip"));
                         }
                         // Special handlin since it defaults to 7 (USER_FOLDER_ID)
                         if ($this->time_limit_owner_set) {
                             $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner());
                         }
                         if (count($this->prefs)) {
                             foreach ($this->prefs as $key => $value) {
                                 if ($key != "mail_incoming_type" && $key != "mail_signature" && $key != "mail_linebreak") {
                                     $updateUser->setPref($key, $value);
                                 }
                             }
                         }
                         // save user preferences (skin and style)
                         if ($this->updateLookAndSkin) {
                             $updateUser->setPref("skin", $this->userObj->getPref("skin"));
                             $updateUser->setPref("style", $this->userObj->getPref("style"));
                         }
                         $updateUser->writePrefs();
                         // update mail preferences, to be extended
                         $this->updateMailPreferences($updateUser->getId());
                         // #8759
                         if (count($this->udf_data)) {
                             $updateUser->setUserDefinedData($this->udf_data);
                         }
                         $updateUser->setProfileIncomplete($this->checkProfileIncomplete($updateUser));
                         $updateUser->setTitle($updateUser->getFullname());
                         $updateUser->setDescription($updateUser->getEmail());
                         $updateUser->update();
                         if ($this->ilincdata["id"]) {
                             include_once 'Modules/ILinc/classes/class.ilObjiLincUser.php';
                             $ilinc_user = new ilObjiLincUser($updateUser);
                             $ilinc_user->setVar("id", $this->ilincdata["id"]);
                             $ilinc_user->setVar("login", $this->ilincdata["login"]);
                             $ilinc_user->setVar("passwd", $this->ilincdata["password"]);
                             $ilinc_user->update();
                         }
                         if (count($this->udf_data)) {
                             include_once './Services/User/classes/class.ilUserDefinedData.php';
                             $udd = new ilUserDefinedData($updateUser->getId());
                             foreach ($this->udf_data as $field => $value) {
                                 $udd->set("f_" . $field, $value);
                             }
                             $udd->update();
                         }
                         // update login
                         if (!is_null($this->userObj->getLogin()) && $this->user_id != -1) {
                             try {
                                 $updateUser->updateLogin($this->userObj->getLogin());
                             } catch (ilUserException $e) {
                             }
                         }
                         // if language has changed
                         if (is_array($this->personalPicture)) {
                             if (strlen($this->personalPicture["content"])) {
                                 $extension = "jpg";
                                 if (preg_match("/.*(png|jpg|gif|jpeg)\$/", $this->personalPicture["imagetype"], $matches)) {
                                     $extension = $matches[1];
                                 }
                                 $tmp_name = $this->saveTempImage($this->personalPicture["content"], ".{$extension}");
                                 if (strlen($tmp_name)) {
                                     ilObjUser::_uploadPersonalPicture($tmp_name, $this->userObj->getId());
                                     unlink($tmp_name);
                                 }
                             }
                         }
                         //update role entries
                         //-------------------
                         foreach ($this->roles as $role_id => $role) {
                             if ($this->role_assign[$role_id]) {
                                 switch ($role["action"]) {
                                     case "Assign":
                                         $this->assignToRole($updateUser, $this->role_assign[$role_id]);
                                         break;
                                     case "AssignWithParents":
                                         $this->assignToRoleWithParents($updateUser, $this->role_assign[$role_id]);
                                         break;
                                     case "Detach":
                                         $this->detachFromRole($updateUser, $this->role_assign[$role_id]);
                                         break;
                                 }
                             }
                         }
                         $this->logSuccess($updateUser->getLogin(), $user_id, "Update");
                     }
                     break;
                 case "Delete":
                     if (!$user_id) {
                         $this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_cant_delete"));
                     } else {
                         $deleteUser = new ilObjUser($user_id);
                         $deleteUser->delete();
                         $this->logSuccess($this->userObj->getLogin(), $user_id, "Delete");
                     }
                     break;
             }
             // init role array for next user
             $this->roles = array();
             break;
         case "Login":
             $this->userObj->setLogin($this->cdata);
             break;
         case "Password":
             $this->currPassword = $this->cdata;
             break;
         case "Firstname":
             $this->userObj->setFirstname($this->cdata);
             break;
         case "Lastname":
             $this->userObj->setLastname($this->cdata);
             break;
         case "Title":
             $this->userObj->setUTitle($this->cdata);
             break;
         case "Gender":
             $this->userObj->setGender($this->cdata);
             break;
         case "Email":
             $this->userObj->setEmail($this->cdata);
             break;
         case "Birthday":
             $timestamp = strtotime($this->cdata);
             if ($timestamp !== false) {
                 $this->userObj->setBirthday($this->cdata);
             }
             break;
         case "Institution":
             $this->userObj->setInstitution($this->cdata);
             break;
         case "Street":
             $this->userObj->setStreet($this->cdata);
             break;
         case "City":
             $this->userObj->setCity($this->cdata);
             break;
         case "PostalCode":
             $this->userObj->setZipCode($this->cdata);
             break;
         case "Country":
             $this->userObj->setCountry($this->cdata);
             break;
         case "PhoneOffice":
             $this->userObj->setPhoneOffice($this->cdata);
             break;
         case "PhoneHome":
             $this->userObj->setPhoneHome($this->cdata);
             break;
         case "PhoneMobile":
             $this->userObj->setPhoneMobile($this->cdata);
             break;
         case "Fax":
             $this->userObj->setFax($this->cdata);
             break;
         case "Hobby":
             $this->userObj->setHobby($this->cdata);
             break;
         case "Comment":
             $this->userObj->setComment($this->cdata);
             break;
         case "Department":
             $this->userObj->setDepartment($this->cdata);
             break;
         case "Matriculation":
             $this->userObj->setMatriculation($this->cdata);
             break;
         case "Active":
             $this->currActive = $this->cdata;
             break;
         case "ClientIP":
             $this->userObj->setClientIP($this->cdata);
             break;
         case "TimeLimitOwner":
             $this->time_limit_owner_set = true;
             $this->userObj->setTimeLimitOwner($this->cdata);
             break;
         case "TimeLimitUnlimited":
             $this->time_limit_set = true;
             $this->userObj->setTimeLimitUnlimited($this->cdata);
             break;
         case "TimeLimitFrom":
             if (is_numeric($this->cdata)) {
                 // Treat cdata as a unix timestamp
                 $this->userObj->setTimeLimitFrom($this->cdata);
             } else {
                 // Try to convert cdata into unix timestamp, or ignore it
                 $timestamp = strtotime($this->cdata);
                 if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") {
                     $this->userObj->setTimeLimitFrom($timestamp);
                 } elseif ($this->cdata == "0000-00-00 00:00:00") {
                     $this->userObj->setTimeLimitFrom(null);
                 }
             }
             break;
         case "TimeLimitUntil":
             if (is_numeric($this->cdata)) {
                 // Treat cdata as a unix timestamp
                 $this->userObj->setTimeLimitUntil($this->cdata);
             } else {
                 // Try to convert cdata into unix timestamp, or ignore it
                 $timestamp = strtotime($this->cdata);
                 if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") {
                     $this->userObj->setTimeLimitUntil($timestamp);
                 } elseif ($this->cdata == "0000-00-00 00:00:00") {
                     $this->userObj->setTimeLimitUntil(null);
                 }
             }
             break;
         case "TimeLimitMessage":
             $this->userObj->setTimeLimitMessage($this->cdata);
             break;
         case "ApproveDate":
             $this->approve_date_set = true;
             if (is_numeric($this->cdata)) {
                 // Treat cdata as a unix timestamp
                 $tmp_date = new ilDateTime($this->cdata, IL_CAL_UNIX);
                 $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME));
             } else {
                 // Try to convert cdata into unix timestamp, or ignore it
                 $timestamp = strtotime($this->cdata);
                 if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") {
                     $tmp_date = new ilDateTime($timestamp, IL_CAL_UNIX);
                     $this->userObj->setApproveDate($tmp_date->get(IL_CAL_DATETIME));
                 } elseif ($this->cdata == "0000-00-00 00:00:00") {
                     $this->userObj->setApproveDate(null);
                 }
             }
             break;
         case "AgreeDate":
             if (is_numeric($this->cdata)) {
                 // Treat cdata as a unix timestamp
                 $tmp_date = new ilDateTime($this->cdata, IL_CAL_UNIX);
                 $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME));
             } else {
                 // Try to convert cdata into unix timestamp, or ignore it
                 $timestamp = strtotime($this->cdata);
                 if ($timestamp !== false && trim($this->cdata) != "0000-00-00 00:00:00") {
                     $tmp_date = new ilDateTime($timestamp, IL_CAL_UNIX);
                     $this->userObj->setAgreeDate($tmp_date->get(IL_CAL_DATETIME));
                 } elseif ($this->cdata == "0000-00-00 00:00:00") {
                     $this->userObj->setAgreeDate(null);
                 }
             }
             break;
         case "iLincID":
             $this->ilincdata["id"] = $this->cdata;
             break;
         case "iLincLogin":
             $this->{$ilincdata}["login"] = $this->cdata;
             break;
         case "iLincPasswd":
             $this->{$ilincdata}["password"] = $this->cdata;
             //$this->userObj->setiLincData($this->ilincdata);
             break;
         case "ExternalAccount":
             $this->userObj->setExternalAccount($this->cdata);
             break;
         case "Look":
             $this->updateLookAndSkin = false;
             if (!$this->hideSkin) {
                 // TODO: what to do with disabled skins? is it possible to change the skin via import?
                 if (strlen($this->skin) > 0 && strlen($this->style) > 0) {
                     if (is_array($this->userStyles)) {
                         if (in_array($this->skin . ":" . $this->style, $this->userStyles)) {
                             $this->userObj->setPref("skin", $this->skin);
                             $this->userObj->setPref("style", $this->style);
                             $this->updateLookAndSkin = true;
                         }
                     }
                 }
             }
             break;
         case 'UserDefinedField':
             include_once './Services/User/classes/class.ilUserDefinedFields.php';
             $udf = ilUserDefinedFields::_getInstance();
             if ($field_id = $udf->fetchFieldIdFromImportId($this->tmp_udf_id)) {
                 $this->udf_data[$field_id] = $this->cdata;
             } elseif ($field_id = $udf->fetchFieldIdFromName($this->tmp_udf_name)) {
                 $this->udf_data[$field_id] = $this->cdata;
             }
             break;
         case 'AccountInfo':
             if ($this->current_messenger_type == "delicious") {
                 $this->userObj->setDelicious($this->cdata);
             } elseif ($this->current_messenger_type == "external") {
                 $this->userObj->setExternalAccount($this->cdata);
             } else {
                 $this->userObj->setInstantMessengerId($this->current_messenger_type, $this->cdata);
             }
             break;
         case 'Pref':
             if ($this->currentPrefKey != null && strlen(trim($this->cdata)) > 0 && ilUserXMLWriter::isPrefExportable($this->currentPrefKey)) {
                 $this->prefs[$this->currentPrefKey] = trim($this->cdata);
             }
             $this->currentPrefKey = null;
             break;
     }
 }