protected function checkNotConfirmedUserAccounts()
 {
     global $ilDB;
     $this->log->write('Cron: Start ' . __METHOD__);
     require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
     $oRegSettigs = new ilRegistrationSettings();
     $query = 'SELECT usr_id FROM usr_data ' . 'WHERE reg_hash IS NOT NULL ' . 'AND active = %s ' . 'AND create_date < %s';
     $res = $ilDB->queryF($query, array('integer', 'timestamp'), array(0, date('Y-m-d H:i:s', time() - (int) $oRegSettigs->getRegistrationHashLifetime())));
     while ($row = $ilDB->fetchAssoc($res)) {
         $oUser = ilObjectFactory::getInstanceByObjId((int) $row['usr_id']);
         $oUser->delete();
         $this->log->write('Cron: Deleted ' . $oUser->getLogin() . ' [' . $oUser->getId() . '] ' . __METHOD__);
     }
     $this->log->write('Cron: End ' . __METHOD__);
 }
Пример #2
0
 /**
  * set all template variables (images, scripts, target frames, ...)
  */
 function setTemplateVars()
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilPluginAdmin;
     if ($this->logo_only) {
         $this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
         return;
     }
     // get user interface plugins
     $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
     if ($this->getMode() != self::MODE_TOPBAR_REDUCED && $this->getMode() != self::MODE_TOPBAR_MEMBERVIEW) {
         // search
         include_once 'Services/Search/classes/class.ilSearchSettings.php';
         if ($rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
             include_once './Services/Search/classes/class.ilMainMenuSearchGUI.php';
             $main_search = new ilMainMenuSearchGUI();
             $html = "";
             // user interface plugin slot + default rendering
             include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
             $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_search", array("main_menu_gui" => $this, "main_menu_search_gui" => $main_search));
             if (!$uip->replaced()) {
                 $html = $main_search->getHTML();
             }
             $html = $uip->getHTML($html);
             if (strlen($html)) {
                 $this->tpl->setVariable('SEARCHBOX', $html);
             }
         }
         $this->renderStatusBox($this->tpl);
         // online help
         $this->renderHelpButtons();
     }
     if ($this->getMode() == self::MODE_FULL) {
         $mmle_html = "";
         // user interface plugin slot + default rendering
         include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
         $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_list_entries", array("main_menu_gui" => $this));
         if (!$uip->replaced()) {
             $mmle_tpl = new ilTemplate("tpl.main_menu_list_entries.html", true, true, "Services/MainMenu");
             $mmle_html = $this->renderMainMenuListEntries($mmle_tpl);
         }
         $mmle_html = $uip->getHTML($mmle_html);
         $this->tpl->setVariable("MAIN_MENU_LIST_ENTRIES", $mmle_html);
     }
     if ($this->getMode() != self::MODE_TOPBAR_MEMBERVIEW) {
         $link_dir = defined("ILIAS_MODULE") ? "../" : "";
         // login stuff
         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
             include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
             if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED) {
                 $this->tpl->setCurrentBlock("registration_link");
                 $this->tpl->setVariable("TXT_REGISTER", $lng->txt("register"));
                 $this->tpl->setVariable("LINK_REGISTER", $link_dir . "register.php?client_id=" . rawurlencode(CLIENT_ID) . "&lang=" . $ilias->account->getCurrentLanguage());
                 $this->tpl->parseCurrentBlock();
             }
             // language selection
             $selection = self::getLanguageSelection();
             if ($selection) {
                 // bs-patch start
                 global $ilUser, $lng;
                 $this->tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
                 // bs-patch end
                 $this->tpl->setVariable("LANG_SELECT", $selection);
             }
             $this->tpl->setCurrentBlock("userisanonymous");
             $this->tpl->setVariable("TXT_NOT_LOGGED_IN", $lng->txt("not_logged_in"));
             $this->tpl->setVariable("TXT_LOGIN", $lng->txt("log_in"));
             // #13058
             $target_str = $this->getLoginTargetPar() != "" ? $this->getLoginTargetPar() : ilTemplate::buildLoginTarget();
             $this->tpl->setVariable("LINK_LOGIN", $link_dir . "login.php?target=" . $target_str . "&client_id=" . rawurlencode(CLIENT_ID) . "&cmd=force_login&lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->parseCurrentBlock();
         } else {
             if ($this->getMode() != self::MODE_TOPBAR_REDUCED) {
                 $notificationSettings = new ilSetting('notifications');
                 $chatSettings = new ilSetting('chatroom');
                 /**
                  * @var $tpl ilTemplate
                  */
                 global $tpl;
                 if ($chatSettings->get('chat_enabled') && $notificationSettings->get('enable_osd')) {
                     $this->tpl->touchBlock('osd_enabled');
                     $this->tpl->touchBlock('osd_container');
                     include_once "Services/jQuery/classes/class.iljQueryUtil.php";
                     iljQueryUtil::initjQuery();
                     include_once 'Services/MediaObjects/classes/class.ilPlayerUtil.php';
                     ilPlayerUtil::initMediaElementJs();
                     $tpl->addJavaScript('Services/Notifications/templates/default/notifications.js');
                     $tpl->addCSS('Services/Notifications/templates/default/osd.css');
                     require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
                     require_once 'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
                     $notifications = ilNotificationOSDHandler::getNotificationsForUser($ilUser->getId());
                     $this->tpl->setVariable('NOTIFICATION_CLOSE_HTML', json_encode(ilGlyphGUI::get(ilGlyphGUI::CLOSE, $lng->txt('close'))));
                     $this->tpl->setVariable('INITIAL_NOTIFICATIONS', json_encode($notifications));
                     $this->tpl->setVariable('OSD_POLLING_INTERVALL', $notificationSettings->get('osd_polling_intervall') ? $notificationSettings->get('osd_polling_intervall') : '5');
                     $this->tpl->setVariable('OSD_PLAY_SOUND', $chatSettings->get('play_invitation_sound') && $ilUser->getPref('chat_play_invitation_sound') ? 'true' : 'false');
                     foreach ($notifications as $notification) {
                         if ($notification['type'] == 'osd_maint') {
                             continue;
                         }
                         $this->tpl->setCurrentBlock('osd_notification_item');
                         $this->tpl->setVariable('NOTIFICATION_ICON_PATH', $notification['data']->iconPath);
                         $this->tpl->setVariable('NOTIFICATION_TITLE', $notification['data']->title);
                         $this->tpl->setVariable('NOTIFICATION_LINK', $notification['data']->link);
                         $this->tpl->setVariable('NOTIFICATION_LINKTARGET', $notification['data']->linktarget);
                         $this->tpl->setVariable('NOTIFICATION_ID', $notification['notification_osd_id']);
                         $this->tpl->setVariable('NOTIFICATION_SHORT_DESCRIPTION', $notification['data']->shortDescription);
                         $this->tpl->parseCurrentBlock();
                     }
                 }
             }
             $this->tpl->setCurrentBlock("userisloggedin");
             $this->tpl->setVariable("TXT_LOGIN_AS", $lng->txt("login_as"));
             $user_img_src = $ilias->account->getPersonalPicturePath("small", true);
             $user_img_alt = $ilias->account->getFullname();
             $this->tpl->setVariable("USER_IMG", ilUtil::img($user_img_src, $user_img_alt));
             $this->tpl->setVariable("USR_LINK_PROFILE", "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToProfile");
             $this->tpl->setVariable("USR_TXT_PROFILE", $lng->txt("personal_profile"));
             $this->tpl->setVariable("USR_LINK_SETTINGS", "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSettings");
             $this->tpl->setVariable("USR_TXT_SETTINGS", $lng->txt("personal_settings"));
             $this->tpl->setVariable("TXT_LOGOUT2", $lng->txt("logout"));
             $this->tpl->setVariable("LINK_LOGOUT2", $link_dir . "logout.php?lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->setVariable("USERNAME", $ilias->account->getFullname());
             $this->tpl->setVariable("LOGIN", $ilias->account->getLogin());
             $this->tpl->setVariable("MATRICULATION", $ilias->account->getMatriculation());
             $this->tpl->setVariable("EMAIL", $ilias->account->getEmail());
             $this->tpl->parseCurrentBlock();
         }
     } else {
         // member view info
         $this->tpl->setVariable("TOPBAR_CLASS", " ilMemberViewMainHeader");
         $this->tpl->setVariable("MEMBER_VIEW_INFO", $lng->txt("mem_view_long"));
     }
     if (!$this->topbar_back_url) {
         include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
         $header_top_title = ilObjSystemFolder::_getHeaderTitle();
         if (trim($header_top_title) != "" && $this->tpl->blockExists("header_top_title")) {
             $this->tpl->setCurrentBlock("header_top_title");
             $this->tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
             $this->tpl->parseCurrentBlock();
         }
     } else {
         $this->tpl->setCurrentBlock("header_back_bl");
         $this->tpl->setVariable("URL_HEADER_BACK", $this->topbar_back_url);
         $this->tpl->setVariable("TXT_HEADER_BACK", $this->topbar_back_caption ? $this->topbar_back_caption : $lng->txt("back"));
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     if ($this->getMode() == self::MODE_FULL) {
         // $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
         $this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
     }
     include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
     // set link to return to desktop, not depending on a specific position in the hierarchy
     //$this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
     /*
     else
     {
     	$this->tpl->setVariable("HEADER_URL", $this->getHeaderURL());
     	$this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.svg"));
     }
     */
     $this->tpl->setVariable("TXT_MAIN_MENU", $lng->txt("main_menu"));
     $this->tpl->parseCurrentBlock();
 }
 /**
  * set all template variables (images, scripts, target frames, ...)
  */
 function setTemplateVars()
 {
     global $rbacsystem, $lng, $ilias, $tree, $ilUser, $ilSetting, $ilPluginAdmin;
     if ($this->logo_only) {
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
         return;
     }
     // get user interface plugins
     $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
     // search
     include_once 'Services/Search/classes/class.ilSearchSettings.php';
     if ($rbacsystem->checkAccess('search', ilSearchSettings::_getSearchSettingRefId())) {
         include_once './Services/Search/classes/class.ilMainMenuSearchGUI.php';
         $main_search = new ilMainMenuSearchGUI();
         $html = "";
         // user interface plugin slot + default rendering
         include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
         $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_search", array("main_menu_gui" => $this, "main_menu_search_gui" => $main_search));
         if (!$uip->replaced()) {
             $html = $main_search->getHTML();
         }
         $html = $uip->getHTML($html);
         if (strlen($html)) {
             $this->tpl->setVariable('SEARCHBOX', $html);
         }
     }
     $this->renderStatusBox($this->tpl);
     // online help
     $this->renderHelpButtons();
     $mmle_html = "";
     // user interface plugin slot + default rendering
     include_once "./Services/UIComponent/classes/class.ilUIHookProcessor.php";
     $uip = new ilUIHookProcessor("Services/MainMenu", "main_menu_list_entries", array("main_menu_gui" => $this));
     if (!$uip->replaced()) {
         $mmle_tpl = new ilTemplate("tpl.main_menu_list_entries.html", true, true, "Services/MainMenu");
         $mmle_html = $this->renderMainMenuListEntries($mmle_tpl);
     }
     $mmle_html = $uip->getHTML($mmle_html);
     $this->tpl->setVariable("MAIN_MENU_LIST_ENTRIES", $mmle_html);
     $link_dir = defined("ILIAS_MODULE") ? "../" : "";
     if (!$this->small) {
         // login stuff
         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID) {
             include_once 'Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
             if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED) {
                 $this->tpl->setCurrentBlock("registration_link");
                 $this->tpl->setVariable("TXT_REGISTER", $lng->txt("register"));
                 $this->tpl->setVariable("LINK_REGISTER", $link_dir . "register.php?client_id=" . rawurlencode(CLIENT_ID) . "&lang=" . $ilias->account->getCurrentLanguage());
                 $this->tpl->parseCurrentBlock();
             }
             // language selection
             $selection = self::getLanguageSelection();
             if ($selection) {
                 $this->tpl->setVariable("LANG_SELECT", $selection);
             }
             $this->tpl->setCurrentBlock("userisanonymous");
             $this->tpl->setVariable("TXT_NOT_LOGGED_IN", $lng->txt("not_logged_in"));
             $this->tpl->setVariable("TXT_LOGIN", $lng->txt("log_in"));
             $target_str = "";
             if ($this->getLoginTargetPar() != "") {
                 $target_str = $this->getLoginTargetPar();
             } else {
                 if ($_GET["ref_id"] != "") {
                     if ($tree->isInTree($_GET["ref_id"]) && $_GET["ref_id"] != $tree->getRootId()) {
                         $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
                         $type = ilObject::_lookupType($obj_id);
                         $target_str = $type . "_" . $_GET["ref_id"];
                     }
                 }
             }
             $this->tpl->setVariable("LINK_LOGIN", $link_dir . "login.php?target=" . $target_str . "&client_id=" . rawurlencode(CLIENT_ID) . "&cmd=force_login&lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->parseCurrentBlock();
         } else {
             $notificationSettings = new ilSetting('notifications');
             $chatSettings = new ilSetting('chatroom');
             /**
              * @var $tpl ilTemplate
              */
             global $tpl;
             if ($chatSettings->get('chat_enabled') && $notificationSettings->get('enable_osd')) {
                 $this->tpl->touchBlock('osd_enabled');
                 $this->tpl->touchBlock('osd_container');
                 include_once "Services/jQuery/classes/class.iljQueryUtil.php";
                 iljQueryUtil::initjQuery();
                 include_once 'Services/MediaObjects/classes/class.ilPlayerUtil.php';
                 ilPlayerUtil::initMediaElementJs();
                 $tpl->addJavaScript('Services/Notifications/templates/default/notifications.js');
                 $tpl->addCSS('Services/Notifications/templates/default/osd.css');
                 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
                 $notifications = ilNotificationOSDHandler::getNotificationsForUser($ilUser->getId());
                 $this->tpl->setVariable('INITIAL_NOTIFICATIONS', json_encode($notifications));
                 $this->tpl->setVariable('OSD_POLLING_INTERVALL', $notificationSettings->get('osd_polling_intervall') ? $notificationSettings->get('osd_polling_intervall') : '5');
                 $this->tpl->setVariable('OSD_PLAY_SOUND', $chatSettings->get('play_invitation_sound') ? 'true' : 'false');
                 foreach ($notifications as $notification) {
                     if ($notification['type'] == 'osd_maint') {
                         continue;
                     }
                     $this->tpl->setCurrentBlock('osd_notification_item');
                     $this->tpl->setVariable('NOTIFICATION_ICON_PATH', $notification['data']->iconPath);
                     $this->tpl->setVariable('NOTIFICATION_TITLE', $notification['data']->title);
                     $this->tpl->setVariable('NOTIFICATION_LINK', $notification['data']->link);
                     $this->tpl->setVariable('NOTIFICATION_LINKTARGET', $notification['data']->linktarget);
                     $this->tpl->setVariable('NOTIFICATION_ID', $notification['notification_osd_id']);
                     $this->tpl->setVariable('NOTIFICATION_SHORT_DESCRIPTION', $notification['data']->shortDescription);
                     $this->tpl->parseCurrentBlock();
                 }
             }
             $this->tpl->setCurrentBlock("userisloggedin");
             $this->tpl->setVariable("TXT_LOGIN_AS", $lng->txt("login_as"));
             $this->tpl->setVariable("TXT_LOGOUT2", $lng->txt("logout"));
             $this->tpl->setVariable("LINK_LOGOUT2", $link_dir . "logout.php?lang=" . $ilias->account->getCurrentLanguage());
             $this->tpl->setVariable("USERNAME", $ilias->account->getFullname());
             $this->tpl->parseCurrentBlock();
         }
         include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
         $header_top_title = ilObjSystemFolder::_getHeaderTitle();
         if (trim($header_top_title) != "" && $this->tpl->blockExists("header_top_title")) {
             $this->tpl->setCurrentBlock("header_top_title");
             $this->tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
             $this->tpl->parseCurrentBlock();
         }
         $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
         $this->tpl->setVariable("TXT_LOGOUT", $lng->txt("logout"));
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
         $this->tpl->setVariable("HEADER_BG_IMAGE", ilUtil::getImagePath("HeaderBackground.png"));
         include_once "./Modules/SystemFolder/classes/class.ilObjSystemFolder.php";
         // set link to return to desktop, not depending on a specific position in the hierarchy
         //$this->tpl->setVariable("SCRIPT_START", $this->getScriptTarget("start.php"));
     } else {
         $this->tpl->setVariable("HEADER_ICON", ilUtil::getImagePath("HeaderIcon.png"));
     }
     $this->tpl->setVariable("TXT_MAIN_MENU", $lng->txt("main_menu"));
     $this->tpl->parseCurrentBlock();
 }
Пример #4
0
 /**
  * Add standard fields to form
  */
 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
 {
     global $ilSetting, $lng, $rbacreview, $ilias;
     // custom registration settings
     if (self::$mode == self::MODE_REGISTRATION) {
         include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $registration_settings = new ilRegistrationSettings();
         self::$user_field["username"]["group"] = "login_data";
         self::$user_field["password"]["group"] = "login_data";
         self::$user_field["language"]["default"] = $lng->lang_key;
         // different position for role
         $roles = self::$user_field["roles"];
         unset(self::$user_field["roles"]);
         self::$user_field["roles"] = $roles;
         self::$user_field["roles"]["group"] = "settings";
     }
     $fields = $this->getStandardFields();
     $current_group = "";
     $custom_fields_done = false;
     foreach ($fields as $f => $p) {
         // next group? -> diplay subheader
         if ($p["group"] != $current_group && ilUserProfile::userSettingVisible($f)) {
             if (is_array($custom_fields) && !$custom_fields_done) {
                 // should be appended to "other" or at least before "settings"
                 if ($current_group == "other" || $p["group"] == "settings") {
                     // add "other" subheader
                     if ($current_group != "other") {
                         $sh = new ilFormSectionHeaderGUI();
                         $sh->setTitle($lng->txt("other"));
                         $a_form->addItem($sh);
                     }
                     foreach ($custom_fields as $custom_field) {
                         $a_form->addItem($custom_field);
                     }
                     $custom_fields_done = true;
                 }
             }
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt($p["group"]));
             $a_form->addItem($sh);
             $current_group = $p["group"];
         }
         $m = "";
         if (isset($p["method"])) {
             $m = $p["method"];
         }
         $lv = isset($p["lang_var"]) && $p["lang_var"] != "" ? $p["lang_var"] : $f;
         switch ($p["input"]) {
             case "login":
                 if ((int) $ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION) {
                     $val = new ilTextInputGUI($lng->txt('username'), 'username');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                     $val->setMaxLength(32);
                     $val->setSize(40);
                     $val->setRequired(true);
                 } else {
                     // user account name
                     $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                 }
                 $a_form->addItem($val);
                 break;
             case "text":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ti);
                 }
                 break;
             case "sel_country":
                 if (ilUserProfile::userSettingVisible($f)) {
                     include_once "./Services/Form/classes/class.ilCountrySelectInputGUI.php";
                     $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ci->setValue($a_user->{$m}());
                     }
                     $ci->setRequired($ilSetting->get("require_" . $f));
                     if (!$ci->getRequired() || $ci->getValue()) {
                         $ci->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ci);
                 }
                 break;
             case "birthday":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_" . $f);
                     include_once "./Services/Calendar/classes/class.ilDateTime.php";
                     $date = null;
                     if ($a_user && strlen($a_user->{$m}())) {
                         $date = new ilDateTime($a_user->{$m}(), IL_CAL_DATE);
                         $bi->setDate($date);
                     }
                     $bi->setShowEmpty(true);
                     $bi->setStartYear(1900);
                     $bi->setRequired($ilSetting->get("require_" . $f));
                     if (!$bi->getRequired() || $date) {
                         $bi->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($bi);
                 }
                 break;
             case "radio":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $rg->setValue($a_user->{$m}());
                     }
                     foreach ($p["values"] as $k => $v) {
                         $op = new ilRadioOption($lng->txt($v), $k);
                         $rg->addOption($op);
                     }
                     $rg->setRequired($ilSetting->get("require_" . $f));
                     if (!$rg->getRequired() || $rg->getValue()) {
                         $rg->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($rg);
                 }
                 break;
             case "picture":
                 if (ilUserProfile::userSettingVisible("upload") && $a_user) {
                     $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
                     $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
                     $upload = $a_form->getFileUpload("userfile");
                     if ($upload["name"]) {
                         $ii->setPending($upload["name"]);
                     } else {
                         $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true, true);
                         if ($im != "") {
                             $ii->setImage($im);
                             $ii->setAlt($lng->txt("personal_picture"));
                         }
                     }
                     // ilinc link as info
                     if (ilUserProfile::userSettingVisible("upload") and $ilSetting->get("ilinc_active")) {
                         include_once './Modules/ILinc/classes/class.ilObjiLincUser.php';
                         $ilinc_user = new ilObjiLincUser($a_user);
                         if ($ilinc_user->id) {
                             include_once './Modules/ILinc/classes/class.ilnetucateXMLAPI.php';
                             $ilincAPI = new ilnetucateXMLAPI();
                             $ilincAPI->uploadPicture($ilinc_user);
                             $response = $ilincAPI->sendRequest("uploadPicture");
                             // return URL to user's personal page
                             $url = trim($response->data['url']['cdata']);
                             $desc = $lng->txt("ilinc_upload_pic_text") . " " . '<a href="' . $url . '">' . $lng->txt("ilinc_upload_pic_linktext") . '</a>';
                             $ii->setInfo($desc);
                         }
                     }
                     $a_form->addItem($ii);
                 }
                 break;
             case "roles":
                 if (self::$mode == self::MODE_DESKTOP) {
                     if (ilUserProfile::userSettingVisible("roles")) {
                         $global_roles = $rbacreview->getGlobalRoles();
                         foreach ($global_roles as $role_id) {
                             if (in_array($role_id, $rbacreview->assignedRoles($a_user->getId()))) {
                                 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
                                 $role_names .= $roleObj->getTitle() . ", ";
                                 unset($roleObj);
                             }
                         }
                         $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
                         $dr->setValue(substr($role_names, 0, -2));
                         $a_form->addItem($dr);
                     }
                 } else {
                     if (self::$mode == self::MODE_REGISTRATION) {
                         if ($registration_settings->roleSelectionEnabled()) {
                             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
                             $options = array();
                             foreach (ilObjRole::_lookupRegisterAllowed() as $role) {
                                 $options[$role["id"]] = $role["title"];
                             }
                             // registration form validation will take care of missing field / value
                             if ($options) {
                                 if (sizeof($options) > 1) {
                                     $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f);
                                     $ta->setOptions($options);
                                     $ta->setRequired($ilSetting->get("require_" . $f));
                                     if (!$ta->getRequired()) {
                                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                                     }
                                 } else {
                                     $ta = new ilHiddenInputGUI("usr_" . $f);
                                     $ta->setValue(array_shift(array_keys($options)));
                                 }
                                 $a_form->addItem($ta);
                             }
                         }
                     }
                 }
                 break;
             case "email":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $em->setValue($a_user->{$m}());
                     }
                     $em->setRequired($ilSetting->get("require_" . $f));
                     if (!$em->getRequired() || $em->getValue()) {
                         $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if (self::MODE_REGISTRATION == self::$mode) {
                         $em->setRetype(true);
                     }
                     $a_form->addItem($em);
                 }
                 break;
             case "textarea":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $ta->setRows($p["rows"]);
                     $ta->setCols($p["cols"]);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "messenger":
                 if (ilUserProfile::userSettingVisible("instant_messengers")) {
                     $im_arr = $p["types"];
                     foreach ($im_arr as $im_name) {
                         $im = new ilTextInputGUI($lng->txt("im_" . $im_name), "usr_im_" . $im_name);
                         if ($a_user) {
                             $im->setValue($a_user->getInstantMessengerId($im_name));
                         }
                         $im->setMaxLength($p["maxlength"]);
                         $im->setSize($p["size"]);
                         $im->setRequired($ilSetting->get("require_" . "instant_messengers"));
                         if (!$im->getRequired() || $im->getValue()) {
                             $im->setDisabled($ilSetting->get("usr_settings_disable_" . "instant_messengers"));
                         }
                         $a_form->addItem($im);
                     }
                 }
                 break;
             case "password":
                 if (self::$mode == self::MODE_REGISTRATION) {
                     if (!$registration_settings->passwordGenerationEnabled()) {
                         $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_" . $f);
                         $ta->setRequired(true);
                         // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
                     } else {
                         $ta = new ilNonEditableValueGUI($lng->txt($lv));
                         $ta->setValue($lng->txt("reg_passwd_via_mail"));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "language":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilSelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $options = array();
                     $lng->loadLanguageModule("meta");
                     foreach ($lng->getInstalledLanguages() as $lang_key) {
                         $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
                     }
                     asort($options);
                     // #9728
                     $ta->setOptions($options);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "multitext":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     $ti->setMulti(true);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if ($this->ajax_href) {
                         // add field to ajax call
                         $ti->setDataSource($this->ajax_href . "&f=" . $f);
                     }
                     $a_form->addItem($ti);
                 }
                 break;
         }
     }
     // append custom fields as "other"
     if (is_array($custom_fields) && !$custom_fields_done) {
         // add "other" subheader
         if ($current_group != "other") {
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt("other"));
             $a_form->addItem($sh);
         }
         foreach ($custom_fields as $custom_field) {
             $a_form->addItem($custom_field);
         }
     }
 }
Пример #5
0
 public function confirmRegistration()
 {
     global $lng, $ilias, $ilLog;
     ilUtil::setCookie('iltest', 'cookie', false);
     if (!isset($_GET['rh']) || !strlen(trim($_GET['rh']))) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
     }
     try {
         require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $oRegSettings = new ilRegistrationSettings();
         $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
         $oUser = ilObjectFactory::getInstanceByObjId($usr_id);
         $oUser->setActive(true);
         if ($oRegSettings->passwordGenerationEnabled()) {
             $passwd = ilUtil::generatePasswords(1);
             $password = $passwd[0];
             $oUser->setPasswd($password, IL_PASSWD_PLAIN);
             $oUser->setLastPasswordChangeTS(time());
         }
         $oUser->update();
         $usr_lang = $oUser->getPref('language');
         if ($lng->getLangKey() != $usr_lang) {
             $lng = new ilLanguage($usr_lang);
         }
         // send email
         // try individual account mail in user administration
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $acc_mail = new ilAccountMail();
             $acc_mail->setUser($oUser);
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $acc_mail->setUserPassword($password);
             }
             $acc_mail->send();
         } else {
             include_once 'Services/Mail/classes/class.ilMail.php';
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             // mail subject
             $subject = $lng->txt("reg_mail_subject");
             // mail body
             $body = $lng->txt("reg_mail_body_salutation") . " " . $oUser->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=" . CLIENT_ID . "\n";
             $body .= $lng->txt("login") . ": " . $oUser->getLogin() . "\n";
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $body .= $lng->txt("passwd") . ": " . $password . "\n";
             }
             $body .= "\n";
             $body .= $lng->txt('reg_mail_body_forgot_password_info') . "\n";
             $body .= "\n";
             $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
             $body .= $oUser->getProfileAsString($lng);
             $mail_obj->enableSoap(false);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail($oUser->getEmail(), '', '', $subject, $body, array(), array('normal'));
         }
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang=' . $usr_lang);
     } catch (ilRegConfirmationLinkExpiredException $exception) {
         include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
         $soap_client = new ilSoapClient();
         $soap_client->setResponseTimeout(1);
         $soap_client->enableWSDL(true);
         $soap_client->init();
         $ilLog->write(__METHOD__ . ': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
         $soap_client->call('deleteExpiredDualOptInUserObjects', array($_COOKIE['PHPSESSID'] . '::' . $_COOKIE['ilClientId'], $exception->getCode()));
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     } catch (ilRegistrationHashNotFoundException $exception) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     }
 }
Пример #6
0
    /**
     * Verifies a registration hash
     * 
     * @throws ilRegistrationHashExpiredException
     * @throws ilRegistrationHashNotFoundException
     * @param string $a_hash hashcode
     * @return integer user id of the user
     */
    public static function _verifyRegistrationHash($a_hash)
    {
        global $ilDB;
        $res = $ilDB->queryf('
			SELECT usr_id, create_date FROM usr_data 
			WHERE reg_hash = %s', array('text'), array($a_hash));
        while ($row = $ilDB->fetchAssoc($res)) {
            require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
            $oRegSettigs = new ilRegistrationSettings();
            if ((int) $oRegSettigs->getRegistrationHashLifetime() != 0 && time() - (int) $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
                require_once 'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php';
                throw new ilRegConfirmationLinkExpiredException('reg_confirmation_hash_life_time_expired', $row['usr_id']);
            }
            $ilDB->manipulateF('
				UPDATE usr_data	
				SET reg_hash = %s
				WHERE usr_id = %s', array('text', 'integer'), array('', (int) $row['usr_id']));
            return (int) $row['usr_id'];
        }
        require_once 'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php';
        throw new ilRegistrationHashNotFoundException('reg_confirmation_hash_not_found');
    }
 /**
  * 
  * Method for soap webservice: deleteExpiredDualOptInUserObjects
  * 
  * This service will run in background. The client has not to wait for response.
  * 
  * @param	string	$sid	Session id + client id, separated by ::
  * @param	integer	$usr_id	User id of the actuator
  * @return	boolean	true or false
  * @access	public
  * 
  */
 public function deleteExpiredDualOptInUserObjects($sid, $usr_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     // Session check not possible -> anonymous user is the trigger
     global $ilDB, $ilLog;
     $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
     require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
     $oRegSettigs = new ilRegistrationSettings();
     $query = '';
     /* 
      * Fetch the current actuator user object first, because this user will try to perform very probably
      * a new registration with the same login name in a few seconds ;-)
      * 
      */
     if ((int) $usr_id > 0) {
         $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data ' . 'WHERE active = 0 ' . 'AND reg_hash IS NOT NULL ' . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' ';
         $query .= 'UNION ';
     }
     $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data ' . 'WHERE active = 0 ' . 'AND reg_hash IS NOT NULL ' . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' ';
     $res = $ilDB->query($query);
     $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...');
     /* 
      * mjansen: 15.12.2010:
      * I perform the expiration check in php because of multi database support (mysql, postgresql).
      * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP()  
      */
     $num_deleted_users = 0;
     while ($row = $ilDB->fetchAssoc($res)) {
         if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) {
             continue;
         }
         if (!strlen($row['reg_hash'])) {
             continue;
         }
         if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 && $row['create_date'] != '' && time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) {
             $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false);
             if ($user instanceof ilObjUser) {
                 $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...');
                 $user->delete();
                 ++$num_deleted_users;
             }
         }
     }
     $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...');
     $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
     return true;
 }