コード例 #1
0
 public static function _getSearchableFieldsInfo($a_admin = false)
 {
     global $lng;
     $counter = 1;
     foreach (ilUserSearchOptions::_getPossibleFields($a_admin) as $field) {
         // TODO: check enabled
         // DONE
         if ($a_admin == false and !ilUserSearchOptions::_isEnabled($field)) {
             continue;
         }
         $fields[$counter]['values'] = array();
         $fields[$counter]['type'] = FIELD_TYPE_TEXT;
         $fields[$counter]['lang'] = $lng->txt($field);
         $fields[$counter]['db'] = $field;
         /**
          * @todo: implement a more general solution
          */
         $fields[$counter]['autoComplete'] = false;
         switch ($field) {
             case 'login':
             case 'firstname':
             case 'lastname':
             case 'email':
                 $fields[$counter]['autoComplete'] = true;
                 break;
             case 'title':
                 $fields[$counter]['lang'] = $lng->txt('person_title');
                 break;
                 // SELECTS
             // SELECTS
             case 'gender':
                 $fields[$counter]['type'] = FIELD_TYPE_SELECT;
                 $fields[$counter]['values'] = array(0 => $lng->txt('please_choose'), 'f' => $lng->txt('gender_f'), 'm' => $lng->txt('gender_m'));
                 break;
             case 'sel_country':
                 $fields[$counter]['type'] = FIELD_TYPE_SELECT;
                 $fields[$counter]['values'] = array(0 => $lng->txt('please_choose'));
                 // #7843 -- see ilCountrySelectInputGUI
                 $lng->loadLanguageModule('meta');
                 include_once './Services/Utilities/classes/class.ilCountry.php';
                 foreach (ilCountry::getCountryCodes() as $c) {
                     $fields[$counter]['values'][$c] = $lng->txt('meta_c_' . $c);
                 }
                 asort($fields[$counter]['values']);
                 break;
                 /*
                 case 'active':
                 	$fields[$counter]['type'] = FIELD_TYPE_SELECT;
                 	$fields[$counter]['values'] = array(-1 => $lng->txt('please_choose'),
                 									'1' => $lng->txt('active'),
                 									'0' => $lng->txt('inactive'));
                 	
                 	break;
                 */
         }
         ++$counter;
     }
     $fields = ilUserSearchOptions::__appendUserDefinedFields($fields, $counter);
     return $fields ? $fields : array();
 }
コード例 #2
0
 /**
  * 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));
 }
コード例 #3
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);
 }