/**
  * Get all selectable columns
  *
  * @return array
  *
  * @global ilRbacReview $rbacreview
  */
 public function getSelectableColumns()
 {
     global $rbacreview, $ilUser;
     if (!self::$all_selectable_cols) {
         include_once './Services/Search/classes/class.ilUserSearchOptions.php';
         $columns = ilUserSearchOptions::getSelectableColumnInfo($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID));
         if ($this->admin_mode) {
             // #11293
             $columns['access_until'] = array('txt' => $this->lng->txt('access_until'));
             $columns['last_login'] = array('txt' => $this->lng->txt('last_login'));
         }
         self::$all_selectable_cols = $columns;
     }
     return self::$all_selectable_cols;
 }
 function __performUserSearch()
 {
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     include_once 'Services/Search/classes/class.ilObjectSearchFactory.php';
     foreach (ilUserSearchOptions::_getSearchableFieldsInfo(!$this->isSearchableCheckEnabled()) as $info) {
         $name = $info['db'];
         $query_string = $_SESSION['rep_query']['usr'][$name];
         // continue if no query string is given
         if (!$query_string) {
             continue;
         }
         if (!is_object($query_parser = $this->__parseQueryString($query_string))) {
             ilUtil::sendInfo($query_parser);
             return false;
         }
         switch ($info['type']) {
             case FIELD_TYPE_UDF_SELECT:
                 // Do a phrase query for select fields
                 $query_parser = $this->__parseQueryString('"' . $query_string . '"');
             case FIELD_TYPE_UDF_TEXT:
                 $udf_search = ilObjectSearchFactory::_getUserDefinedFieldSearchInstance($query_parser);
                 $udf_search->setFields(array($name));
                 $result_obj = $udf_search->performSearch();
                 // Store entries
                 $this->__storeEntries($result_obj);
                 break;
             case FIELD_TYPE_SELECT:
                 // Do a phrase query for select fields
                 $query_parser = $this->__parseQueryString('"' . $query_string . '"');
             case FIELD_TYPE_TEXT:
                 $user_search =& ilObjectSearchFactory::_getUserSearchInstance($query_parser);
                 $user_search->setFields(array($name));
                 $result_obj = $user_search->performSearch();
                 // store entries
                 $this->__storeEntries($result_obj);
                 break;
         }
     }
 }
 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();
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilSetting;
     $field = $a_set["key"];
     $props = array("visible" => "user_visible_in_profile", "changeable" => "changeable", "searchable" => "header_searchable", "required" => "required_field", "export" => "export", "course_export" => "course_export", 'group_export' => 'group_export', "visib_reg" => "header_visible_registration", 'visib_lua' => 'usr_settings_visib_lua', 'changeable_lua' => 'usr_settings_changeable_lua');
     foreach ($props as $prop => $lv) {
         $up_prop = strtoupper($prop);
         if ($prop != "searchable" && $a_set[$prop . "_hide"] != true || $prop == "searchable" && ilUserSearchOptions::_isSearchable($field)) {
             $this->tpl->setCurrentBlock($prop);
             $this->tpl->setVariable("HEADER_" . $up_prop, $lng->txt($lv));
             $this->tpl->setVariable("PROFILE_OPTION_" . $up_prop, $prop . "_" . $field);
             // determine checked status
             $checked = false;
             if ($prop == "visible" && $ilSetting->get("usr_settings_hide_" . $field) != "1") {
                 $checked = true;
             }
             if ($prop == "changeable" && $ilSetting->get("usr_settings_disable_" . $field) != "1") {
                 $checked = true;
             }
             if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field)) {
                 $checked = true;
             }
             if ($prop == "required" && $ilSetting->get("require_" . $field) == "1") {
                 $checked = true;
             }
             if ($prop == "export" && $ilSetting->get("usr_settings_export_" . $field) == "1") {
                 $checked = true;
             }
             if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_" . $field) == "1") {
                 $checked = true;
             }
             if ($prop == "group_export" && $ilSetting->get("usr_settings_group_export_" . $field) == "1") {
                 $checked = true;
             }
             if ($prop == "visib_reg" && (int) $ilSetting->get('usr_settings_visib_reg_' . $field, '1')) {
                 $checked = true;
             }
             if ($prop == "visib_lua" && (int) $ilSetting->get('usr_settings_visib_lua_' . $field, '1')) {
                 $checked = true;
             }
             if ($prop == "changeable_lua" && (int) $ilSetting->get('usr_settings_changeable_lua_' . $field, '1')) {
                 $checked = true;
             }
             if ($this->confirm_change == 1) {
                 $checked = $_POST["chb"][$prop . "_" . $field];
             }
             if (isset($a_set[$prop . "_fix_value"])) {
                 $checked = $a_set[$prop . "_fix_value"];
             }
             if ($checked) {
                 $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
             }
             if (isset($a_set[$prop . "_fix_value"])) {
                 $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
             }
             $this->tpl->parseCurrentBlock();
         }
     }
     // default
     if ($a_set["default"] != "") {
         switch ($a_set["input"]) {
             case "selection":
             case "hitsperpage":
                 $selected_option = $ilSetting->get($field);
                 if ($selected_option == "") {
                     $selected_option = $a_set["default"];
                 }
                 foreach ($a_set["options"] as $k => $v) {
                     $this->tpl->setCurrentBlock("def_sel_option");
                     $this->tpl->setVariable("OPTION_VALUE", $k);
                     $text = $a_set["input"] == "selection" ? $lng->txt($v) : $v;
                     if ($a_set["input"] == "hitsperpage" && $k == 9999) {
                         $text = $lng->txt("no_limit");
                     }
                     if ($selected_option == $k) {
                         $this->tpl->setVariable("OPTION_SELECTED", ' selected="selected" ');
                     }
                     $this->tpl->setVariable("OPTION_TEXT", $text);
                     $this->tpl->parseCurrentBlock();
                 }
                 $this->tpl->setCurrentBlock("def_selection");
                 $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
                 $this->tpl->parseCurrentBlock();
                 break;
         }
         $this->tpl->setCurrentBlock("default");
         $this->tpl->parseCurrentBlock();
     }
     // group name
     $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
     // field name
     $lv = $a_set["lang_var"] == "" ? $a_set["key"] : $a_set["lang_var"];
     if ($a_set["key"] == "country") {
         $lv = "country_free_text";
     }
     if ($a_set["key"] == "sel_country") {
         $lv = "country_selection";
     }
     $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
 }
 public static function __appendUserDefinedFields($fields, $counter)
 {
     include_once './Services/User/classes/class.ilUserDefinedFields.php';
     $user_defined_fields = ilUserDefinedFields::_getInstance();
     foreach ($user_defined_fields->getSearchableDefinitions() as $definition) {
         $fields[$counter]['values'] = ilUserSearchOptions::__prepareValues($definition['field_values']);
         $fields[$counter]['lang'] = $definition['field_name'];
         $fields[$counter]['db'] = $definition['field_id'];
         switch ($definition['field_type']) {
             case UDF_TYPE_TEXT:
                 $fields[$counter]['type'] = FIELD_TYPE_UDF_TEXT;
                 break;
             case UDF_TYPE_SELECT:
                 $fields[$counter]['type'] = FIELD_TYPE_UDF_SELECT;
                 break;
         }
         ++$counter;
     }
     return $fields ? $fields : array();
 }
Exemplo n.º 6
0
 /**
  * Get completion list
  * @param string $a_str
  * @return string
  */
 public function getList($a_str)
 {
     /**
      * @var $ilDB  ilDB
      * @var $ilLog ilLog
      */
     global $ilDB, $ilLog;
     $select_part = $this->getSelectPart();
     $where_part = $this->getWherePart($a_str);
     $order_by_part = $this->getOrderByPart();
     $query = implode(" ", array('SELECT ' . $select_part, 'FROM ' . $this->getFromPart(), $where_part ? 'WHERE ' . $where_part : '', $order_by_part ? 'ORDER BY ' . $order_by_part : ''));
     $ilLog->write(__METHOD__ . ': Query: ' . $query);
     $res = $ilDB->query($query);
     // add email only if it is "searchable"
     $add_email = true;
     include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
     if ($this->isFieldSearchableCheckEnabled() && !ilUserSearchOptions::_isEnabled("email")) {
         $add_email = false;
     }
     include_once './Services/Search/classes/class.ilSearchSettings.php';
     $max = $this->getLimit() ? $this->getLimit() : ilSearchSettings::getInstance()->getAutoCompleteLength();
     $cnt = 0;
     $more_results = FALSE;
     $result = array();
     while (($rec = $ilDB->fetchAssoc($res)) && $cnt < $max + 1) {
         if ($cnt >= $max) {
             $more_results = TRUE;
             break;
         }
         // @todo: Open discussion: We should remove all non public fields from result
         $label = $rec['lastname'] . ', ' . $rec['firstname'] . ' [' . $rec['login'] . ']';
         if ($add_email && $rec['email'] && (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->getPrivacyMode() || 'y' == $rec['email_value'])) {
             $label .= ', ' . $rec['email'];
         }
         $result[$cnt]['value'] = (string) $rec[$this->result_field];
         $result[$cnt]['label'] = $label;
         $result[$cnt]['id'] = $rec['usr_id'];
         $cnt++;
     }
     include_once 'Services/JSON/classes/class.ilJsonUtil.php';
     $result_json['items'] = $result;
     $result_json['hasMoreResults'] = $more_results;
     $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($result_json, TRUE));
     return ilJsonUtil::encode($result_json);
 }