/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd) { global $ilCtrl, $lng, $ilAccess, $lng; parent::__construct($a_parent_obj, $a_parent_cmd); $this->setTitle($lng->txt("usr_settings_header_profile")); $this->setDescription($lng->txt("usr_settings_explanation_profile")); $this->setLimit(9999); //$this->addColumn($this->lng->txt("usrs_group"), ""); $this->addColumn("", ""); $this->addColumn($this->lng->txt("user_field"), ""); $this->addColumn($this->lng->txt("access"), ""); $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search"), ""); $this->addColumn($this->lng->txt("default"), ""); $this->setEnableHeader(true); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User"); $this->disable("footer"); $this->setEnableTitle(true); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipField("username"); $fds = $up->getStandardFields(); foreach ($fds as $k => $f) { $fds[$k]["key"] = $k; } $this->setData($fds); $this->addCommandButton("saveGlobalUserSettings", $lng->txt("save")); }
function saveGlobalUserSettingsObject($action = "") { include_once 'Services/Search/classes/class.ilUserSearchOptions.php'; include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; global $ilias, $ilSetting; // see ilUserFieldSettingsTableGUI include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipField("username"); $field_properties = $up->getStandardFields(); $profile_fields = array_keys($field_properties); $valid = true; foreach ($profile_fields as $field) { if ($_POST["chb"]["required_" . $field] && !(int) $_POST['chb']['visib_reg_' . $field]) { $valid = false; break; } } if (!$valid) { global $lng; ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected')); $this->confirm_change = 1; $this->settingsObject(); return; } // For the following fields, the required state can not be changed $fixed_required_fields = array("firstname" => 1, "lastname" => 1, "upload" => 0, "password" => 0, "language" => 0, "skin_style" => 0, "hits_per_page" => 0, "show_users_online" => 0, "hide_own_online_status" => 0); // check if a course export state of any field has been added $privacy = ilPrivacySettings::_getInstance(); if ($privacy->enabledCourseExport() == true && $privacy->courseConfirmationRequired() == true && $action != "save") { foreach ($profile_fields as $field) { if (!$ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1") { #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export')); #$this->confirm_change = 1; #$this->settingsObject(); #return; } } } // Reset user confirmation if ($action == 'save') { include_once 'Services/Membership/classes/class.ilMemberAgreement.php'; ilMemberAgreement::_reset(); } foreach ($profile_fields as $field) { // Enable disable searchable if (ilUserSearchOptions::_isSearchable($field)) { ilUserSearchOptions::_saveStatus($field, (bool) $_POST['chb']['searchable_' . $field]); } if (!$_POST["chb"]["visible_" . $field] && !$field_properties[$field]["visible_hide"]) { $ilias->setSetting("usr_settings_hide_" . $field, "1"); } else { $ilias->deleteSetting("usr_settings_hide_" . $field); } if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"]) { $ilias->setSetting("usr_settings_disable_" . $field, "1"); } else { $ilias->deleteSetting("usr_settings_disable_" . $field); } // registration visible if ((int) $_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"]) { $ilSetting->set('usr_settings_visib_reg_' . $field, '1'); } else { $ilSetting->set('usr_settings_visib_reg_' . $field, '0'); } if ((int) $_POST['chb']['visib_lua_' . $field]) { $ilSetting->set('usr_settings_visib_lua_' . $field, '1'); } else { $ilSetting->set('usr_settings_visib_lua_' . $field, '0'); } if ((int) $_POST['chb']['changeable_lua_' . $field]) { $ilSetting->set('usr_settings_changeable_lua_' . $field, '1'); } else { $ilSetting->set('usr_settings_changeable_lua_' . $field, '0'); } if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"]) { $ilias->setSetting("usr_settings_export_" . $field, "1"); } else { $ilias->deleteSetting("usr_settings_export_" . $field); } // Course export/visibility if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"]) { $ilias->setSetting("usr_settings_course_export_" . $field, "1"); } else { $ilias->deleteSetting("usr_settings_course_export_" . $field); } // Group export/visibility if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"]) { $ilias->setSetting("usr_settings_group_export_" . $field, "1"); } else { $ilias->deleteSetting("usr_settings_group_export_" . $field); } $is_fixed = array_key_exists($field, $fixed_required_fields); if ($is_fixed && $fixed_required_fields[$field] || !$is_fixed && $_POST["chb"]["required_" . $field]) { $ilias->setSetting("require_" . $field, "1"); } else { $ilias->deleteSetting("require_" . $field); } } if ($_POST["select"]["default_hits_per_page"]) { $ilias->setSetting("hits_per_page", $_POST["select"]["default_hits_per_page"]); } if ($_POST["select"]["default_show_users_online"]) { $ilias->setSetting("show_users_online", $_POST["select"]["default_show_users_online"]); } if ($_POST["chb"]["export_preferences"]) { $ilias->setSetting("usr_settings_export_preferences", $_POST["chb"]["export_preferences"]); } else { $ilias->deleteSetting("usr_settings_export_preferences"); } $ilias->setSetting('mail_incoming_mail', (int) $_POST['select']['default_mail_incoming_mail']); ilUtil::sendSuccess($this->lng->txt("usr_settings_saved")); $this->settingsObject(); }
/** * Get profile fields (DEPRECATED, use ilUserProfile() instead) * * @return array of fieldnames */ static function &getProfileFields() { include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipField("username"); $up->skipField("roles"); $up->skipGroup("preferences"); $fds = $up->getStandardFields(); foreach ($fds as $k => $f) { $profile_fields[] = $k; } return $profile_fields; }
static function setMode($mode) { global $lng; if (in_array($mode, array(self::MODE_DESKTOP, self::MODE_REGISTRATION))) { self::$mode = $mode; return true; } return false; }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { global $ilSetting, $ilUser; //echo $a_entity; //var_dump($a_rec); switch ($a_entity) { case "personal_data": // only users themselves import their profiles! // thus we can map the import id of the dataset to the current user $a_mapping->addMapping("Services/User", "usr", $a_rec["Id"], $ilUser->getId()); break; case "usr_profile": $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["Id"]); if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") { if (!isset($this->users[$usr_id])) { $this->users[$usr_id] = new ilObjUser($usr_id); } $user = $this->users[$usr_id]; include_once "./Services/User/classes/class.ilUserProfile.php"; $prof = new ilUserProfile(); $prof->skipField("username"); $prof->skipField("password"); $prof->skipField("roles"); $prof->skipGroup("settings"); $fields = $prof->getStandardFields(); foreach ($fields as $k => $f) { $up_k = $this->convertToLeadingUpper($k); // only change fields, when it is possible in profile if (ilUserProfile::userSettingVisible($k) && !$ilSetting->get("usr_settings_disable_" . $k) && $f["method"] != "" && isset($a_rec[$up_k])) { $set_method = "set" . substr($f["method"], 3); $user->{$set_method}($a_rec[$up_k]); // echo "<br>-setting-".$set_method."-".$a_rec[$up_k]."-"; } } $user->update(); // personal picture $pic_dir = $this->getImportDirectory() . "/" . str_replace("..", "", $a_rec["Picture"]); if ($pic_dir != "" && is_dir($pic_dir)) { $upload_file = $pic_dir . "/upload_" . $a_rec["Id"] . "pic"; if (is_file($upload_file)) { ilObjUser::_uploadPersonalPicture($upload_file, $user->getId()); } } } break; case "usr_setting": $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]); if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") { if (!isset($this->users[$usr_id])) { $this->users[$usr_id] = new ilObjUser($usr_id); } $user = $this->users[$usr_id]; $user->writePref($a_rec["Keyword"], $a_rec["Value"]); } break; case "usr_multi": $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]); if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") { $this->multi[$usr_id][$a_rec["FieldId"]][] = $a_rec["Value"]; } break; } }
/** * Save personal data form * */ public function savePersonalData() { global $tpl, $lng, $ilCtrl, $ilUser, $ilSetting, $ilAuth; $this->initPersonalDataForm(); if ($this->form->checkInput()) { $form_valid = true; // if form field name differs from setter $map = array("firstname" => "FirstName", "lastname" => "LastName", "title" => "UTitle", "sel_country" => "SelectedCountry", "phone_office" => "PhoneOffice", "phone_home" => "PhoneHome", "phone_mobile" => "PhoneMobile", "referral_comment" => "Comment", "interests_general" => "GeneralInterests", "interests_help_offered" => "OfferingHelp", "interests_help_looking" => "LookingForHelp"); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); foreach ($up->getStandardFields() as $f => $p) { // if item is part of form, it is currently valid (if not disabled) $item = $this->form->getItemByPostVar("usr_" . $f); if ($item && !$item->getDisabled()) { $value = $this->form->getInput("usr_" . $f); switch ($f) { case "birthday": if (is_array($value)) { if (is_array($value['date'])) { if ($value['d'] > 0 && $value['m'] > 0 && $value['y'] > 0) { $ilUser->setBirthday(sprintf("%04d-%02d-%02d", $value['y'], $value['m'], $value['d'])); } else { $ilUser->setBirthday(""); } } else { $ilUser->setBirthday($value['date']); } } break; default: $m = ucfirst($f); if (isset($map[$f])) { $m = $map[$f]; } $ilUser->{"set" . $m}($value); break; } } } $ilUser->setFullname(); // set instant messengers if ($this->workWithUserSetting("instant_messengers")) { $ilUser->setInstantMessengerId('icq', $this->form->getInput("usr_im_icq")); $ilUser->setInstantMessengerId('yahoo', $this->form->getInput("usr_im_yahoo")); $ilUser->setInstantMessengerId('msn', $this->form->getInput("usr_im_msn")); $ilUser->setInstantMessengerId('aim', $this->form->getInput("usr_im_aim")); $ilUser->setInstantMessengerId('skype', $this->form->getInput("usr_im_skype")); $ilUser->setInstantMessengerId('jabber', $this->form->getInput("usr_im_jabber")); $ilUser->setInstantMessengerId('voip', $this->form->getInput("usr_im_voip")); } // check map activation include_once "./Services/Maps/classes/class.ilMapUtil.php"; if (ilMapUtil::isActivated()) { $location = $this->form->getInput("location"); $ilUser->setLatitude(ilUtil::stripSlashes($location["latitude"])); $ilUser->setLongitude(ilUtil::stripSlashes($location["longitude"])); $ilUser->setLocationZoom(ilUtil::stripSlashes($location["zoom"])); } // Set user defined data $defs = $this->user_defined_fields->getVisibleDefinitions(); $udf = array(); foreach ($defs as $definition) { $f = "udf_" . $definition['field_id']; $item = $this->form->getItemByPostVar($f); if ($item && !$item->getDisabled()) { $udf[$definition['field_id']] = $this->form->getInput($f); } } $ilUser->setUserDefinedData($udf); // if loginname is changeable -> validate $un = $this->form->getInput('username'); if ((int) $ilSetting->get('allow_change_loginname') && $un != $ilUser->getLogin()) { if (!strlen($un) || !ilUtil::isLogin($un)) { ilUtil::sendFailure($lng->txt('form_input_not_valid')); $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('login_invalid')); $form_valid = false; } else { if (ilObjUser::_loginExists($un, $ilUser->getId())) { ilUtil::sendFailure($lng->txt('form_input_not_valid')); $this->form->getItemByPostVar('username')->setAlert($this->lng->txt('loginname_already_exists')); $form_valid = false; } else { $ilUser->setLogin($un); try { $ilUser->updateLogin($ilUser->getLogin()); $ilAuth->setAuth($ilUser->getLogin()); $ilAuth->start(); } catch (ilUserException $e) { ilUtil::sendFailure($lng->txt('form_input_not_valid')); $this->form->getItemByPostVar('username')->setAlert($e->getMessage()); $form_valid = false; } } } } // everthing's ok. save form data if ($form_valid) { $this->uploadUserPicture(); // profile ok $ilUser->setProfileIncomplete(false); // save user data & object_data $ilUser->setTitle($ilUser->getFullname()); $ilUser->setDescription($ilUser->getEmail()); $ilUser->update(); ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true); if (ilSession::get('orig_request_target')) { $target = ilSession::get('orig_request_target'); ilSession::set('orig_request_target', ''); ilUtil::redirect($target); } else { if ($redirect = $_SESSION['profile_complete_redirect']) { unset($_SESSION['profile_complete_redirect']); ilUtil::redirect($redirect); } else { $ilCtrl->redirect($this, "showPersonalData"); } } } } $this->form->setValuesByPost(); $this->showPersonalData(true); }
/** * Check if profile is incomplete * Will set the usr_data field profile_incomplete if any required field is missing * * * @access private * */ private function checkProfileIncomplete($user_obj) { include_once "Services/User/classes/class.ilUserProfile.php"; return ilUserProfile::isProfileIncomplete($user_obj); }
protected function getSelectableUserColumns($a_in_course = false, $a_in_group = false) { global $lng, $ilSetting; $cols = $privacy_fields = array(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("interests"); $ufs = $up->getStandardFields(); // default fields $cols["login"] = array("txt" => $lng->txt("login"), "default" => true); if (!$this->anonymized) { $cols["firstname"] = array("txt" => $lng->txt("firstname"), "default" => true); $cols["lastname"] = array("txt" => $lng->txt("lastname"), "default" => true); } // show only if extended data was activated in lp settings include_once 'Services/Tracking/classes/class.ilObjUserTracking.php'; $tracking = new ilObjUserTracking(); if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) { $cols["first_access"] = array("txt" => $lng->txt("trac_first_access"), "default" => true); $cols["last_access"] = array("txt" => $lng->txt("trac_last_access"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) { $cols["read_count"] = array("txt" => $lng->txt("trac_read_count"), "default" => true); } if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) { $cols["spent_seconds"] = array("txt" => $lng->txt("trac_spent_seconds"), "default" => true); } if ($this->isPercentageAvailable($this->obj_id)) { $cols["percentage"] = array("txt" => $lng->txt("trac_percentage"), "default" => true); } // do not show status if learning progress is deactivated $olp = ilObjectLP::getInstance($this->obj_id); if ($olp->isActive()) { $cols["status"] = array("txt" => $lng->txt("trac_status"), "default" => true); $cols['status_changed'] = array('txt' => $lng->txt('trac_status_changed'), 'default' => false); } if ($this->type != "lm") { $cols["mark"] = array("txt" => $lng->txt("trac_mark"), "default" => true); } $cols["u_comment"] = array("txt" => $lng->txt("trac_comment"), "default" => false); $cols["create_date"] = array("txt" => $lng->txt("create_date"), "default" => false); $cols["language"] = array("txt" => $lng->txt("language"), "default" => false); // add user data only if object is [part of] course if (!$this->anonymized && ($a_in_course || $a_in_group)) { // only show if export permission is granted include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if (ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) { // other user profile fields foreach ($ufs as $f => $fd) { if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"]) { if ($a_in_course && !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_" . $f))) { continue; } if ($a_in_group && !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_" . $f))) { continue; } $cols[$f] = array("txt" => $lng->txt($f), "default" => false); $privacy_fields[] = $f; } } // additional defined user data fields include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); if ($a_in_course) { $user_defined_fields = $user_defined_fields->getCourseExportableFields(); } else { $user_defined_fields = $user_defined_fields->getGroupExportableFields(); } foreach ($user_defined_fields as $definition) { if ($definition["field_type"] != UDF_TYPE_WYSIWYG) { $f = "udf_" . $definition["field_id"]; $cols[$f] = array("txt" => $definition["field_name"], "default" => false); $privacy_fields[] = $f; } } } } return array($cols, $privacy_fields); }
/** * Called after successful login * @return * @param array $a_username * @param object $a_auth */ protected function loginObserver($a_username, $a_auth) { global $ilLog, $ilAppEventHandler, $ilSetting; if ($this->getContainer()->loginObserver($a_username, $a_auth)) { // validate user include_once "Services/User/classes/class.ilObjUser.php"; $user_id = ilObjUser::_loginExists($a_auth->getUsername()); if ($user_id != ANONYMOUS_USER_ID) { $user = new ilObjUser($user_id); // check if profile is complete include_once "Services/User/classes/class.ilUserProfile.php"; if (ilUserProfile::isProfileIncomplete($user) and ilAuthFactory::getContext() != ilAuthFactory::CONTEXT_ECS) { $user->setProfileIncomplete(true); $user->update(); } // --- extended user validation // // we only have a single status, so abort after each one // order from highest priority to lowest // active? if (!$user->getActive()) { $this->status = AUTH_USER_INACTIVE; $a_auth->logout(); return; } // time limit if (!$user->checkTimeLimit()) { $this->status = AUTH_USER_TIME_LIMIT_EXCEEDED; // #16327 $this->exceeded_user_name = $this->getUserName(); $a_auth->logout(); return; } // check client ip $clientip = $user->getClientIP(); if (trim($clientip) != "") { $clientip = preg_replace("/[^0-9.?*,:]+/", "", $clientip); $clientip = str_replace(".", "\\.", $clientip); $clientip = str_replace(array("?", "*", ","), array("[0-9]", "[0-9]*", "|"), $clientip); if (!preg_match("/^" . $clientip . "\$/", $_SERVER["REMOTE_ADDR"])) { $this->status = AUTH_USER_WRONG_IP; $a_auth->logout(); return; } } // simultaneous login if ($ilSetting->get('ps_prevent_simultaneous_logins') && ilObjUser::hasActiveSession($user_id)) { $this->status = AUTH_USER_SIMULTANEOUS_LOGIN; $a_auth->logout(); return; } include_once 'Services/Tracking/classes/class.ilOnlineTracking.php'; ilOnlineTracking::addUser($user_id); include_once 'Modules/Forum/classes/class.ilObjForum.php'; ilObjForum::_updateOldAccess($user_id); require_once 'Services/PrivacySecurity/classes/class.ilSecuritySettings.php'; $security_settings = ilSecuritySettings::_getInstance(); // determine first login of user for setting an indicator // which still is available in PersonalDesktop, Repository, ... // (last login date is set to current date in next step) if ($security_settings->isPasswordChangeOnFirstLoginEnabled() && $user->getLastLogin() == null) { $user->resetLastPasswordChange(); } $user->refreshLogin(); // reset counter for failed logins ilObjUser::_resetLoginAttempts($user_id); } // --- anonymous/registered user $ilLog->write(__METHOD__ . ': logged in as ' . $a_auth->getUsername() . ', remote:' . $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER['REMOTE_PORT'] . ', server:' . $_SERVER['SERVER_ADDR'] . ':' . $_SERVER['SERVER_PORT']); ilSessionControl::handleLoginEvent($a_auth->getUsername(), $a_auth); $ilAppEventHandler->raise('Services/Authentication', 'afterLogin', array('username' => $a_auth->getUsername())); } }
protected function __createUser($a_role) { global $ilSetting, $rbacadmin; $this->userObj = new ilObjUser(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->setMode(ilUserProfile::MODE_REGISTRATION); $map = array(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("instant_messengers"); $up->skipField("password"); $up->skipField("birthday"); $up->skipField("upload"); foreach ($up->getStandardFields() as $k => $v) { if ($v["method"]) { $method = "set" . substr($v["method"], 3); if (method_exists($this->userObj, $method)) { if ($k != "username") { $k = "usr_" . $k; } $field_obj = $this->form->getItemByPostVar($k); if ($field_obj) { $this->userObj->{$method}($this->form->getInput($k)); } } } } $this->userObj->setFullName(); $birthday_obj = $this->form->getItemByPostVar("usr_birthday"); if ($birthday_obj) { $birthday = $this->form->getInput("usr_birthday"); $birthday = $birthday["date"]; // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui if (!is_array($birthday)) { $this->userObj->setBirthday($birthday); } } // messenger $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip"); foreach ($map as $client) { $field = "usr_im_" . $client; $field_obj = $this->form->getItemByPostVar($field); if ($field_obj) { $this->userObj->setInstantMessengerId($client, $this->form->getInput($field)); } } $this->userObj->setTitle($this->userObj->getFullname()); $this->userObj->setDescription($this->userObj->getEmail()); if ($this->registration_settings->passwordGenerationEnabled()) { $password = ilUtil::generatePasswords(1); $password = $password[0]; } else { $password = $this->form->getInput("usr_password"); } $this->userObj->setPasswd($password); // Set user defined data include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields =& ilUserDefinedFields::_getInstance(); $defs = $user_defined_fields->getRegistrationDefinitions(); $udf = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 4) == "udf_") { $f = substr($k, 4); $udf[$f] = $v; } } $this->userObj->setUserDefinedData($udf); $this->userObj->setTimeLimitOwner(7); $this->code_was_used = false; if ($this->code_enabled) { // #10853 - could be optional $code = $this->form->getInput('usr_registration_code'); if ($code) { // set code to used include_once './Services/Registration/classes/class.ilRegistrationCode.php'; ilRegistrationCode::useCode($code); $this->code_was_used = true; } } // something went wrong with the form validation if (!$a_role) { global $ilias; $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL); } if ($this->registration_settings->getAccessLimitation()) { include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php'; $access_limitations_obj = new ilRegistrationRoleAccessLimitations(); $access_limit_mode = $access_limitations_obj->getMode($a_role); if ($access_limit_mode == 'absolute') { $access_limit = $access_limitations_obj->getAbsolute($a_role); $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } elseif ($access_limit_mode == 'relative') { $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd'); $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm'); $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y'); $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time(); $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } $this->userObj->setTimeLimitFrom(time()); $this->userObj->create(); if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) { $this->userObj->setActive(1, 0); } else { if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) { $this->userObj->setActive(0, 0); } else { $this->userObj->setActive(0, 0); } } $this->userObj->updateOwner(); // set a timestamp for last_password_change // this ts is needed by the ACCOUNT_SECURITY_MODE_CUSTOMIZED // in ilSecuritySettings $this->userObj->setLastPasswordChangeTS(time()); //insert user data in table user_data $this->userObj->saveAsNew(); // store acceptance of user agreement $this->userObj->writeAccepted(); // setup user preferences $this->userObj->setLanguage($this->form->getInput('usr_language')); $hits_per_page = $ilSetting->get("hits_per_page"); if ($hits_per_page < 10) { $hits_per_page = 10; } $this->userObj->setPref("hits_per_page", $hits_per_page); $show_online = $ilSetting->get("show_users_online"); if ($show_online == "") { $show_online = "y"; } $this->userObj->setPref("show_users_online", $show_online); $this->userObj->writePrefs(); $rbacadmin->assignUser((int) $a_role, $this->userObj->getId(), true); return $password; }
/** * Get selectable columns * * @param * @return */ function getSelectableColumns() { global $lng; include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->skipGroup("preferences"); $up->skipGroup("interests"); $up->skipGroup("settings"); // default fields $cols = array(); // first and last name cannot be hidden $cols["firstname"] = array("txt" => $lng->txt("firstname"), "default" => true); $cols["lastname"] = array("txt" => $lng->txt("lastname"), "default" => true); if ($this->getMode() == self::MODE_USER_FOLDER) { $ufs = $up->getStandardFields(); $cols["access_until"] = array("txt" => $lng->txt("access_until"), "default" => true); $cols["last_login"] = array("txt" => $lng->txt("last_login"), "default" => true); // #13967 $cols["create_date"] = array("txt" => $lng->txt("create_date")); $cols["approve_date"] = array("txt" => $lng->txt("approve_date")); $cols["agree_date"] = array("txt" => $lng->txt("agree_date")); } else { $ufs = $up->getLocalUserAdministrationFields(); } // email should be the 1st "optional" field (can be hidden) if (isset($ufs["email"])) { $cols["email"] = array("txt" => $lng->txt("email"), "default" => true); } // other user profile fields foreach ($ufs as $f => $fd) { if (!isset($cols[$f]) && !$fd["lists_hide"]) { $cols[$f] = array("txt" => $lng->txt($f), "default" => false); } } // fields that are always shown unset($cols["username"]); return $cols; }
protected function __createUser($a_role) { /** * @var $ilSetting ilSetting * @var $rbacadmin ilRbacAdmin * @var $lng ilLanguage */ global $ilSetting, $rbacadmin, $lng; // something went wrong with the form validation if (!$a_role) { global $ilias; $ilias->raiseError("Invalid role selection in registration" . ", IP: " . $_SERVER["REMOTE_ADDR"], $ilias->error_obj->FATAL); } $this->userObj = new ilObjUser(); include_once "./Services/User/classes/class.ilUserProfile.php"; $up = new ilUserProfile(); $up->setMode(ilUserProfile::MODE_REGISTRATION); $map = array(); $up->skipGroup("preferences"); $up->skipGroup("settings"); $up->skipGroup("instant_messengers"); $up->skipField("password"); $up->skipField("birthday"); $up->skipField("upload"); foreach ($up->getStandardFields() as $k => $v) { if ($v["method"]) { $method = "set" . substr($v["method"], 3); if (method_exists($this->userObj, $method)) { if ($k != "username") { $k = "usr_" . $k; } $field_obj = $this->form->getItemByPostVar($k); if ($field_obj) { $this->userObj->{$method}($this->form->getInput($k)); } } } } $this->userObj->setFullName(); $birthday_obj = $this->form->getItemByPostVar("usr_birthday"); if ($birthday_obj) { $birthday = $this->form->getInput("usr_birthday"); $birthday = $birthday["date"]; // when birthday was not set, array will not be substituted with string by ilBirthdayInputGui if (!is_array($birthday)) { $this->userObj->setBirthday($birthday); } } // messenger $map = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip"); foreach ($map as $client) { $field = "usr_im_" . $client; $field_obj = $this->form->getItemByPostVar($field); if ($field_obj) { $this->userObj->setInstantMessengerId($client, $this->form->getInput($field)); } } $this->userObj->setTitle($this->userObj->getFullname()); $this->userObj->setDescription($this->userObj->getEmail()); if ($this->registration_settings->passwordGenerationEnabled()) { $password = ilUtil::generatePasswords(1); $password = $password[0]; } else { $password = $this->form->getInput("usr_password"); } $this->userObj->setPasswd($password); // Set user defined data include_once './Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields =& ilUserDefinedFields::_getInstance(); $defs = $user_defined_fields->getRegistrationDefinitions(); $udf = array(); foreach ($_POST as $k => $v) { if (substr($k, 0, 4) == "udf_") { $f = substr($k, 4); $udf[$f] = $v; } } $this->userObj->setUserDefinedData($udf); $this->userObj->setTimeLimitOwner(7); $access_limit = null; $this->code_was_used = false; if ($this->code_enabled) { $code_local_roles = $code_has_access_limit = null; // #10853 - could be optional $code = $this->form->getInput('usr_registration_code'); if ($code) { include_once './Services/Registration/classes/class.ilRegistrationCode.php'; // set code to used ilRegistrationCode::useCode($code); $this->code_was_used = true; // handle code attached local role(s) and access limitation $code_data = ilRegistrationCode::getCodeData($code); if ($code_data["role_local"]) { // need user id before we can assign role(s) $code_local_roles = explode(";", $code_data["role_local"]); } if ($code_data["alimit"]) { // see below $code_has_access_limit = true; switch ($code_data["alimit"]) { case "absolute": $abs = date_parse($code_data["alimitdt"]); $access_limit = mktime(23, 59, 59, $abs['month'], $abs['day'], $abs['year']); break; case "relative": $rel = unserialize($code_data["alimitdt"]); $access_limit = $rel["d"] * 86400 + $rel["m"] * 2592000 + $rel["y"] * 31536000 + time(); break; } } } } // code access limitation will override any other access limitation setting if (!($this->code_was_used && $code_has_access_limit) && $this->registration_settings->getAccessLimitation()) { include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php'; $access_limitations_obj = new ilRegistrationRoleAccessLimitations(); switch ($access_limitations_obj->getMode($a_role)) { case 'absolute': $access_limit = $access_limitations_obj->getAbsolute($a_role); break; case 'relative': $rel_d = (int) $access_limitations_obj->getRelative($a_role, 'd'); $rel_m = (int) $access_limitations_obj->getRelative($a_role, 'm'); $rel_y = (int) $access_limitations_obj->getRelative($a_role, 'y'); $access_limit = $rel_d * 86400 + $rel_m * 2592000 + $rel_y * 31536000 + time(); break; } } if ($access_limit) { $this->userObj->setTimeLimitUnlimited(0); $this->userObj->setTimeLimitUntil($access_limit); } else { $this->userObj->setTimeLimitUnlimited(1); $this->userObj->setTimeLimitUntil(time()); } $this->userObj->setTimeLimitFrom(time()); $this->userObj->create(); if ($this->registration_settings->getRegistrationType() == IL_REG_DIRECT || $this->registration_settings->getRegistrationType() == IL_REG_CODES || $this->code_was_used) { $this->userObj->setActive(1, 0); } else { if ($this->registration_settings->getRegistrationType() == IL_REG_ACTIVATION) { $this->userObj->setActive(0, 0); } else { $this->userObj->setActive(0, 0); } } $this->userObj->updateOwner(); // set a timestamp for last_password_change // this ts is needed by ilSecuritySettings $this->userObj->setLastPasswordChangeTS(time()); $this->userObj->setIsSelfRegistered(true); //insert user data in table user_data $this->userObj->saveAsNew(); try { require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php'; ilTermsOfServiceHelper::trackAcceptance($this->userObj, ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng)); } catch (ilTermsOfServiceNoSignableDocumentFoundException $e) { } // setup user preferences $this->userObj->setLanguage($this->form->getInput('usr_language')); $hits_per_page = $ilSetting->get("hits_per_page"); if ($hits_per_page < 10) { $hits_per_page = 10; } $this->userObj->setPref("hits_per_page", $hits_per_page); $show_online = $ilSetting->get("show_users_online"); if ($show_online == "") { $show_online = "y"; } $this->userObj->setPref("show_users_online", $show_online); $this->userObj->writePrefs(); $rbacadmin->assignUser((int) $a_role, $this->userObj->getId()); // local roles from code if ($this->code_was_used && is_array($code_local_roles)) { foreach (array_unique($code_local_roles) as $local_role_obj_id) { // is given role (still) valid? if (ilObject::_lookupType($local_role_obj_id) == "role") { $rbacadmin->assignUser($local_role_obj_id, $this->userObj->getId()); } } } return $password; }
/** * Read info about exportable fields * * @access private * */ private function read() { include_once './Services/User/classes/class.ilUserProfile.php'; $profile = new ilUserProfile(); $profile->skipGroup('settings'); foreach ($profile->getStandardFields() as $key => $data) { if ($this->getType() == 'crs') { if (!$data['course_export_hide']) { if (isset($data['course_export_fix_value']) and $data['course_export_fix_value']) { $this->possible_fields[$key] = $data['course_export_fix_value']; } else { $this->possible_fields[$key] = 0; } } } elseif ($this->getType() == 'grp') { if (!$data['group_export_hide']) { if (isset($data['group_export_fix_value']) and $data['group_export_fix_value']) { $this->possible_fields[$key] = $data['group_export_fix_value']; } else { $this->possible_fields[$key] = 0; } } } } $settings_all = $this->settings->getAll(); $field_part_limit = 5; switch ($this->getType()) { case 'crs': $field_prefix = 'usr_settings_course_export_'; $field_part_limit = 5; break; case 'grp': $field_prefix = 'usr_settings_group_export_'; $field_part_limit = 5; break; } foreach ($settings_all as $key => $value) { if (stristr($key, $field_prefix) and $value) { // added limit for mantis 11096 $field_parts = explode('_', $key, $field_part_limit); $field = $field_parts[count($field_parts) - 1]; if (array_key_exists($field, $this->possible_fields)) { $this->possible_fields[$field] = 1; } } } return true; }
/** * * Handles ignored required fields by changing the required flag of form elements * * @access protected * @return boolean A flag whether the user profile is maybe incomplete after saving the form data * */ protected function handleIgnoredRequiredFields() { $profileMaybeIncomplete = false; require_once 'Services/User/classes/class.ilUserProfile.php'; foreach (ilUserProfile::getIgnorableRequiredSettings() as $fieldName) { $elm = $this->form_gui->getItemByPostVar($fieldName); if (!$elm) { continue; } if ($elm->getRequired()) { $profileMaybeIncomplete = true; // Flag as optional $elm->setRequired(false); } } include_once 'Services/User/classes/class.ilUserDefinedFields.php'; $user_defined_fields = ilUserDefinedFields::_getInstance(); foreach ($user_defined_fields->getDefinitions() as $field_id => $definition) { $elm = $this->form_gui->getItemByPostVar('udf_' . $definition['field_id']); if (!$elm) { continue; } if ($elm->getRequired() && $definition['changeable'] && $definition['required'] && $definition['visible']) { $profileMaybeIncomplete = true; // Flag as optional $elm->setRequired(false); } } return $profileMaybeIncomplete; }