48         $this->result_field = 
'login';
    53         $this->
logger = $DIC->logger()->user();
    58         $this->respect_min_search_character_count = $a_status;
    81         $this->limit = $a_limit;
   124         $this->searchable_check = $a_status;
   138         $this->user_access_check = $a_status;
   154         $this->possible_fields = $a_fields;
   173         $available_fields = [];
   176                 $available_fields[] = $field;
   179         return $available_fields;
   187         $this->result_field = $a_field;
   193     public function getList(
string $a_str): string
   196         $ilDB = $DIC->database();
   201             $result_json[
'items'] = [];
   202             $result_json[
'hasMoreResults'] = 
false;
   203             $this->
logger->debug(
'Autocomplete search rejected: minimum characters count.');
   204             return json_encode($result_json);
   211         $query = implode(
" ", [
   212             'SELECT ' . $select_part,
   214             $where_part ? 
'WHERE ' . $where_part : 
'',
   215             $order_by_part ? 
'ORDER BY ' . $order_by_part : 
''   218         $this->
logger->debug(
'Query: ' . $query);
   228         $add_second_email = 
true;
   230             $add_second_email = 
false;
   235         $more_results = 
false;
   239         while (($rec = 
$ilDB->fetchAssoc(
$res)) && $cnt < ($max + 1)) {
   241                 $more_results = 
true;
   244             $recs[$rec[
'usr_id']] = $rec;
   245             $usrIds[] = $rec[
'usr_id'];
   248         $callable_name = null;
   249         if (is_callable($this->user_filter, 
true, $callable_name)) {
   250             $usrIds = call_user_func($this->user_filter, $usrIds);
   252         foreach ($usrIds as $usr_id) {
   253             $rec = $recs[$usr_id];
   255             if (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->
getPrivacyMode() || in_array($rec[
'profile_value'], [
'y',
'g'])) {
   256                 $label = $rec[
'lastname'] . 
', ' . $rec[
'firstname'] . 
' [' . $rec[
'login'] . 
']';
   258                 $label = 
'[' . $rec[
'login'] . 
']';
   261             if ($add_email && $rec[
'email'] && (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->
getPrivacyMode() || 
'y' == $rec[
'email_value'])) {
   262                 $label .= 
', ' . $rec[
'email'];
   265             if ($add_second_email && $rec[
'second_email'] && (self::PRIVACY_MODE_RESPECT_USER_SETTING != $this->
getPrivacyMode() || 
'y' == $rec[
'second_email_value'])) {
   266                 $label .= 
', ' . $rec[
'second_email'];
   269             $result[$cnt][
'value'] = (string) $rec[$this->result_field];
   270             $result[$cnt][
'label'] = $label;
   271             $result[$cnt][
'id'] = $rec[
'usr_id'];
   275         $result_json[
'items'] = $result;
   276         $result_json[
'hasMoreResults'] = $more_results;
   280         return json_encode($result_json, JSON_THROW_ON_ERROR);
   294         if (self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode()) {
   295             $fields[] = 
'profpref.value profile_value';
   296             $fields[] = 
'pubemail.value email_value';
   297             $fields[] = 
'pubsecondemail.value second_email_value';
   300         return implode(
', ', $fields);
   307         $ilDB = $DIC->database();
   311         if (self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode()) {
   312             $joins[] = 
'LEFT JOIN usr_pref profpref   313                                 ON profpref.usr_id = ud.usr_id   314                                 AND profpref.keyword = ' . 
$ilDB->quote(
'public_profile', 
'text');
   316             $joins[] = 
'LEFT JOIN usr_pref pubemail   317                                 ON pubemail.usr_id = ud.usr_id   318                                 AND pubemail.keyword = ' . 
$ilDB->quote(
'public_email', 
'text');
   320             $joins[] = 
'LEFT JOIN usr_pref pubsecondemail   321                                 ON pubsecondemail.usr_id = ud.usr_id   322                                 AND pubsecondemail.keyword = ' . 
$ilDB->quote(
'public_second_email', 
'text');
   326             return 'usr_data ud ' . implode(
' ', $joins);
   328             return 'usr_data ud';
   336         $ilDB = $DIC->database();
   339         $outer_conditions = [];
   342         if (self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode() &&
   344             $this->
getUser()->isAnonymous()
   346             if (!
$ilSetting->get(
'enable_global_profiles', 
'0')) {
   351                 $outer_conditions[] = 
'profpref.value = ' . 
$ilDB->quote(
'g', 
'text');
   357         $field_conditions = [];
   361             if (
'email' == $field && self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode()) {
   365                 $email_query[] = $field_condition;
   366                 $email_query[] = 
'pubemail.value = ' . 
$ilDB->quote(
'y', 
'text');
   367                 $field_conditions[] = 
'(' . implode(
' AND ', $email_query) . 
')';
   368             } elseif (
'second_email' == $field && self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode()) {
   372                 $email_query[] = $field_condition;
   373                 $email_query[] = 
'pubsecondemail.value = ' . 
$ilDB->quote(
'y', 
'text');
   374                 $field_conditions[] = 
'(' . implode(
' AND ', $email_query) . 
')';
   376                 $field_conditions[] = $field_condition;
   384         if (self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->
getPrivacyMode() &&
   388             $fields = 
'(' . implode(
' OR ', $field_conditions) . 
')';
   390             $field_conditions = [
   391                 '(' . implode(
' AND ', [
   393                 $ilDB->in(
'profpref.value', [
'y', 
'g'], 
false, 
'text')
   406         if ($field_conditions) {
   407             $outer_conditions[] = 
'(' . implode(
' OR ', $field_conditions) . 
')';
   413             $outer_conditions[] = 
"ud.active = " . 
$ilDB->quote(1, 
'integer');
   417             $unlimited = 
"ud.time_limit_unlimited = " . 
$ilDB->quote(1, 
'integer');
   418             $from = 
"ud.time_limit_from < " . 
$ilDB->quote(time(), 
'integer');
   419             $until = 
"ud.time_limit_until > " . 
$ilDB->quote(time(), 
'integer');
   421             $outer_conditions[] = 
'(' . $unlimited . 
' OR (' . $from . 
' AND ' . $until . 
'))';
   424         return implode(
' AND ', $outer_conditions);
   436         $ilDB = $DIC->database();
   438         $query_strings = [$query[
'query']];
   440         if (array_key_exists($field, $query)) {
   441             $query_strings = [$query[$field]];
   442         } elseif (array_key_exists(
'parts', $query)) {
   443             $query_strings = $query[
'parts'];
   446         $query_condition = 
'( ';
   448         foreach ($query_strings as $query_string) {
   450                 $query_condition .= 
' OR ';
   453                 $query_condition .= 
$ilDB->like($field, 
'text', $query_string . 
'%');
   455                 $query_condition .= 
$ilDB->like($field, 
'text', $query_string);
   458         $query_condition .= 
')';
   459         return $query_condition;
   467         $this->user_limitations = $a_limitations;
   498         if (strpos($a_query, 
'\\') === 
false) {
   499             $a_query = str_replace([
'%', 
'_'], [
'\%', 
'\_'], $a_query);
   502         $query[
'query'] = trim($a_query);
   505         if (strpos($a_query, 
',')) {
   506             $comma_separated = explode(
',', $a_query);
   508             if (count($comma_separated) == 2) {
   509                 if (trim($comma_separated[0])) {
   510                     $query[
'lastname'] = trim($comma_separated[0]);
   512                 if (trim($comma_separated[1])) {
   513                     $query[
'firstname'] = trim($comma_separated[1]);
   517             $whitespace_separated = explode(
' ', $a_query);
   518             foreach ($whitespace_separated as $part) {
   520                     $query[
'parts'][] = trim($part);
 
isFieldSearchableCheckEnabled()
 
getWherePart(array $search_query)
 
setUserLimitations(bool $a_limitations)
allow user limitations like inactive and access limitations 
 
enableUserAccessCheck(bool $a_status)
Enable user access check. 
 
setPrivacyMode(int $privacy_mode)
 
setSearchType(int $search_type)
 
const PRIVACY_MODE_RESPECT_USER_SETTING
 
enableFieldSearchableCheck(bool $a_status)
Enable the check whether the field is searchable in Administration -> Settings -> Standard Fields...
 
bool $more_link_available
 
parseQueryString(string $a_query)
Parse query string. 
 
addUserAccessFilterCallable(Closure $user_filter)
Closure for filtering users e.g $rep_search_gui->addUserAccessFilterCallable(function($user_ids) use(...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getRespectMinimumSearchCharacterCount()
 
respectMinimumSearchCharacterCount(bool $a_status)
 
static strLen(string $a_string)
 
bool $respect_min_search_character_count
 
const MIN_WORD_LENGTH
Minimum of characters required for search. 
 
getFields()
Get searchable fields. 
 
getList(string $a_str)
Get completion list. 
 
getSearchFields()
get possible search fields 
 
getUserLimitations()
allow user limitations like inactive and access limitations 
 
setResultField(string $a_field)
Set result field. 
 
setSearchFields(array $a_fields)
Set searchable fields. 
 
isUserAccessCheckEnabled()
Check if user access check is enabled. 
 
setMoreLinkAvailable(bool $more_link_available)
IMPORTANT: remember to read request parameter 'fetchall' to use this function. 
 
const PRIVACY_MODE_IGNORE_USER_SETTING
 
getQueryConditionByFieldAndValue(string $field, array $query)
 
static _isEnabled($a_key)