ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUserAutoComplete Class Reference

Auto completion class for user lists. More...

+ Inheritance diagram for ilUserAutoComplete:
+ Collaboration diagram for ilUserAutoComplete:

Public Member Functions

 __construct ()
 Default constructor. More...
 
 respectMinimumSearchCharacterCount ($a_status)
 
 getRespectMinimumSearchCharacterCount ()
 
 addUserAccessFilterCallable (callable $user_filter)
 Closure for filtering users e.g $rep_search_gui->addUserAccessFilterCallable(function($user_ids) use($ref_id,$rbac_perm,$pos_perm)) { // filter users return $filtered_users }. More...
 
 setLimit ($a_limit)
 
 getLimit ()
 
 setSearchType ($search_type)
 
 getSearchType ()
 
 setPrivacyMode ($privacy_mode)
 
 getPrivacyMode ()
 
 setUser ($user)
 
 getUser ()
 
 enableFieldSearchableCheck ($a_status)
 Enable the check whether the field is searchable in Administration -> Settings -> Standard Fields. More...
 
 isFieldSearchableCheckEnabled ()
 Searchable check enabled. More...
 
 enableUserAccessCheck ($a_status)
 Enable user access check. More...
 
 isUserAccessCheckEnabled ()
 Check if user access check is enabled. More...
 
 setSearchFields ($a_fields)
 Set searchable fields. More...
 
 getSearchFields ()
 get possible search fields More...
 
 setResultField ($a_field)
 Set result field. More...
 
 setUserLimitations ($a_limitations)
 allow user limitations like inactive and access limitations More...
 
 getUserLimitations ()
 allow user limitations like inactive and access limitations More...
 
 isMoreLinkAvailable ()
 
 setMoreLinkAvailable ($more_link_available)
 IMPORTANT: remember to read request parameter 'fetchall' to use this function. More...
 
 parseQueryString ($a_query)
 Parse query string. More...
 

Data Fields

const MAX_ENTRIES = 1000
 
const SEARCH_TYPE_LIKE = 1
 
const SEARCH_TYPE_EQUALS = 2
 
const PRIVACY_MODE_RESPECT_USER_SETTING = 1
 
const PRIVACY_MODE_IGNORE_USER_SETTING = 2
 

Protected Member Functions

 getFields ()
 Get searchable fields. More...
 
 getSelectPart ()
 
 getOrderByPart ()
 

Protected Attributes

 $user_filter = null
 

Private Attributes

 $logger = null
 
 $searchable_check = false
 
 $user_access_check = true
 
 $possible_fields = array()
 
 $result_field
 
 $search_type
 
 $privacy_mode
 
 $user
 
 $limit = 0
 
 $user_limitations = true
 
 $respect_min_search_character_count = true
 
 $more_link_available = false
 

Detailed Description

Auto completion class for user lists.

Definition at line 7 of file class.ilUserAutoComplete.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserAutoComplete::__construct ( )

Default constructor.

Definition at line 95 of file class.ilUserAutoComplete.php.

References $DIC, setPrivacyMode(), and setSearchType().

96  {
97  global $DIC;
98 
99  $this->result_field = 'login';
100 
101  $this->setSearchType(self::SEARCH_TYPE_LIKE);
102  $this->setPrivacyMode(self::PRIVACY_MODE_IGNORE_USER_SETTING);
103 
104  $this->logger = $DIC->logger()->user();
105  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ addUserAccessFilterCallable()

ilUserAutoComplete::addUserAccessFilterCallable ( callable  $user_filter)

Closure for filtering users e.g $rep_search_gui->addUserAccessFilterCallable(function($user_ids) use($ref_id,$rbac_perm,$pos_perm)) { // filter users return $filtered_users }.

Parameters
callable$user_filter

Definition at line 133 of file class.ilUserAutoComplete.php.

References $user_filter.

134  {
135  $this->user_filter = $user_filter;
136  }

◆ enableFieldSearchableCheck()

ilUserAutoComplete::enableFieldSearchableCheck (   $a_status)

Enable the check whether the field is searchable in Administration -> Settings -> Standard Fields.

Parameters
bool$a_status

Definition at line 200 of file class.ilUserAutoComplete.php.

201  {
202  $this->searchable_check = $a_status;
203  }

◆ enableUserAccessCheck()

ilUserAutoComplete::enableUserAccessCheck (   $a_status)

Enable user access check.

See also
Administration -> User Accounts -> Settings -> General Settings
Parameters
bool$a_status

Definition at line 219 of file class.ilUserAutoComplete.php.

220  {
221  $this->user_access_check = $a_status;
222  }

◆ getFields()

ilUserAutoComplete::getFields ( )
protected

Get searchable fields.

Returns
array

Definition at line 255 of file class.ilUserAutoComplete.php.

References ilUserSearchOptions\_isEnabled(), getSearchFields(), and isFieldSearchableCheckEnabled().

Referenced by getSelectPart().

256  {
257  if (!$this->isFieldSearchableCheckEnabled()) {
258  return $this->getSearchFields();
259  }
260  $available_fields = array();
261  foreach ($this->getSearchFields() as $field) {
262  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
263  if (ilUserSearchOptions::_isEnabled($field)) {
264  $available_fields[] = $field;
265  }
266  }
267  return $available_fields;
268  }
isFieldSearchableCheckEnabled()
Searchable check enabled.
getSearchFields()
get possible search fields
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLimit()

ilUserAutoComplete::getLimit ( )

Definition at line 143 of file class.ilUserAutoComplete.php.

References $limit.

Referenced by setResultField().

144  {
145  return $this->limit;
146  }
+ Here is the caller graph for this function:

◆ getOrderByPart()

ilUserAutoComplete::getOrderByPart ( )
protected
Returns
string

Definition at line 547 of file class.ilUserAutoComplete.php.

References $DIC, $ilDB, $query, and getSearchType().

Referenced by setResultField().

548  {
549  return 'login ASC';
550  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrivacyMode()

ilUserAutoComplete::getPrivacyMode ( )
Returns
int

Definition at line 175 of file class.ilUserAutoComplete.php.

References $privacy_mode.

Referenced by getSelectPart(), and setResultField().

176  {
177  return $this->privacy_mode;
178  }
+ Here is the caller graph for this function:

◆ getRespectMinimumSearchCharacterCount()

ilUserAutoComplete::getRespectMinimumSearchCharacterCount ( )
Returns
bool

Definition at line 118 of file class.ilUserAutoComplete.php.

References $respect_min_search_character_count.

◆ getSearchFields()

ilUserAutoComplete::getSearchFields ( )

get possible search fields

Returns
array

Definition at line 246 of file class.ilUserAutoComplete.php.

References $possible_fields.

Referenced by getFields().

247  {
248  return $this->possible_fields;
249  }
+ Here is the caller graph for this function:

◆ getSearchType()

ilUserAutoComplete::getSearchType ( )
Returns
mixed

Definition at line 159 of file class.ilUserAutoComplete.php.

References $search_type.

Referenced by getOrderByPart().

160  {
161  return $this->search_type;
162  }
+ Here is the caller graph for this function:

◆ getSelectPart()

ilUserAutoComplete::getSelectPart ( )
protected
Returns
string

Definition at line 383 of file class.ilUserAutoComplete.php.

References $DIC, $from, $ilDB, $ilSetting, getFields(), ilUserAccountSettings\getInstance(), ilUserFilter\getInstance(), ilSearchSettings\getInstance(), getPrivacyMode(), getUser(), and getUserLimitations().

Referenced by setResultField().

384  {
385  $fields = array(
386  'ud.usr_id',
387  'ud.login',
388  'ud.firstname',
389  'ud.lastname',
390  'ud.email',
391  'ud.second_email'
392  );
393 
394  if (self::PRIVACY_MODE_RESPECT_USER_SETTING == $this->getPrivacyMode()) {
395  $fields[] = 'profpref.value profile_value';
396  $fields[] = 'pubemail.value email_value';
397  $fields[] = 'pubsecondemail.value second_email_value';
398  }
399 
400  return implode(', ', $fields);
401  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUser()

ilUserAutoComplete::getUser ( )
Returns
ilObjUser

Definition at line 191 of file class.ilUserAutoComplete.php.

References $user.

Referenced by getSelectPart(), and ilOnScreenChatUserUserAutoComplete\getWherePart().

192  {
193  return $this->user;
194  }
+ Here is the caller graph for this function:

◆ getUserLimitations()

ilUserAutoComplete::getUserLimitations ( )

allow user limitations like inactive and access limitations

Returns
bool

Definition at line 604 of file class.ilUserAutoComplete.php.

References $user_limitations.

Referenced by getSelectPart().

605  {
607  }
+ Here is the caller graph for this function:

◆ isFieldSearchableCheckEnabled()

ilUserAutoComplete::isFieldSearchableCheckEnabled ( )

Searchable check enabled.

Returns
bool

Definition at line 209 of file class.ilUserAutoComplete.php.

References $searchable_check.

Referenced by getFields(), and setResultField().

210  {
212  }
+ Here is the caller graph for this function:

◆ isMoreLinkAvailable()

ilUserAutoComplete::isMoreLinkAvailable ( )
Returns
boolean

Definition at line 612 of file class.ilUserAutoComplete.php.

References $more_link_available.

Referenced by setResultField().

613  {
615  }
+ Here is the caller graph for this function:

◆ isUserAccessCheckEnabled()

ilUserAutoComplete::isUserAccessCheckEnabled ( )

Check if user access check is enabled.

Returns
bool

Definition at line 228 of file class.ilUserAutoComplete.php.

References $user_access_check.

229  {
231  }

◆ parseQueryString()

ilUserAutoComplete::parseQueryString (   $a_query)

Parse query string.

Parameters
string$a_query
Returns
$query

Definition at line 632 of file class.ilUserAutoComplete.php.

References $query, and ilLogLevel\DEBUG.

Referenced by setResultField().

633  {
634  $query = array();
635 
636  if (!stristr($a_query, '\\')) {
637  $a_query = str_replace('%', '\%', $a_query);
638  $a_query = str_replace('_', '\_', $a_query);
639  }
640 
641  $query['query'] = trim($a_query);
642 
643  // "," means fixed search for lastname, firstname
644  if (strpos($a_query, ',')) {
645  $comma_separated = (array) explode(',', $a_query);
646 
647  if (count($comma_separated) == 2) {
648  if (trim($comma_separated[0])) {
649  $query['lastname'] = trim($comma_separated[0]);
650  }
651  if (trim($comma_separated[1])) {
652  $query['firstname'] = trim($comma_separated[1]);
653  }
654  }
655  } else {
656  $whitespace_separated = (array) explode(' ', $a_query);
657  foreach ($whitespace_separated as $part) {
658  if (trim($part)) {
659  $query['parts'][] = trim($part);
660  }
661  }
662  }
663 
664  $this->logger->dump($query, ilLogLevel::DEBUG);
665 
666  return $query;
667  }
$query
+ Here is the caller graph for this function:

◆ respectMinimumSearchCharacterCount()

ilUserAutoComplete::respectMinimumSearchCharacterCount (   $a_status)
Parameters
bool$a_status

Definition at line 110 of file class.ilUserAutoComplete.php.

111  {
112  $this->respect_min_search_character_count = $a_status;
113  }

◆ setLimit()

ilUserAutoComplete::setLimit (   $a_limit)

Definition at line 138 of file class.ilUserAutoComplete.php.

139  {
140  $this->limit = $a_limit;
141  }

◆ setMoreLinkAvailable()

ilUserAutoComplete::setMoreLinkAvailable (   $more_link_available)

IMPORTANT: remember to read request parameter 'fetchall' to use this function.

Parameters
boolean$more_link_available

Definition at line 622 of file class.ilUserAutoComplete.php.

References $more_link_available.

623  {
624  $this->more_link_available = $more_link_available;
625  }

◆ setPrivacyMode()

ilUserAutoComplete::setPrivacyMode (   $privacy_mode)
Parameters
int$privacy_mode

Definition at line 167 of file class.ilUserAutoComplete.php.

References $privacy_mode.

Referenced by __construct().

168  {
169  $this->privacy_mode = $privacy_mode;
170  }
+ Here is the caller graph for this function:

◆ setResultField()

ilUserAutoComplete::setResultField (   $a_field)

Set result field.

Parameters
string$a_field

Definition at line 274 of file class.ilUserAutoComplete.php.

References $DIC, $ilDB, $query, $res, $result, ilUserSearchOptions\_isEnabled(), ilLogLevel\DEBUG, ilJsonUtil\encode(), ilSearchSettings\getInstance(), getLimit(), getOrderByPart(), getPrivacyMode(), getSelectPart(), isFieldSearchableCheckEnabled(), isMoreLinkAvailable(), ilQueryParser\MIN_WORD_LENGTH, parseQueryString(), and ilStr\strLen().

275  {
276  $this->result_field = $a_field;
277  }
+ Here is the call graph for this function:

◆ setSearchFields()

ilUserAutoComplete::setSearchFields (   $a_fields)

Set searchable fields.

Parameters
array$a_fields

Definition at line 237 of file class.ilUserAutoComplete.php.

238  {
239  $this->possible_fields = $a_fields;
240  }

◆ setSearchType()

ilUserAutoComplete::setSearchType (   $search_type)
Parameters
int$search_type

Definition at line 151 of file class.ilUserAutoComplete.php.

References $search_type.

Referenced by __construct().

152  {
153  $this->search_type = $search_type;
154  }
+ Here is the caller graph for this function:

◆ setUser()

ilUserAutoComplete::setUser (   $user)
Parameters
ilObjUser$user

Definition at line 183 of file class.ilUserAutoComplete.php.

References $user, and user().

184  {
185  $this->user = $user;
186  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ setUserLimitations()

ilUserAutoComplete::setUserLimitations (   $a_limitations)

allow user limitations like inactive and access limitations

Parameters
bool$a_limitations

Definition at line 595 of file class.ilUserAutoComplete.php.

596  {
597  $this->user_limitations = (bool) $a_limitations;
598  }

Field Documentation

◆ $limit

ilUserAutoComplete::$limit = 0
private

Definition at line 73 of file class.ilUserAutoComplete.php.

Referenced by getLimit().

◆ $logger

ilUserAutoComplete::$logger = null
private

Definition at line 35 of file class.ilUserAutoComplete.php.

◆ $more_link_available

ilUserAutoComplete::$more_link_available = false
private

Definition at line 85 of file class.ilUserAutoComplete.php.

Referenced by isMoreLinkAvailable(), and setMoreLinkAvailable().

◆ $possible_fields

ilUserAutoComplete::$possible_fields = array()
private

Definition at line 50 of file class.ilUserAutoComplete.php.

Referenced by getSearchFields().

◆ $privacy_mode

ilUserAutoComplete::$privacy_mode
private

Definition at line 65 of file class.ilUserAutoComplete.php.

Referenced by getPrivacyMode(), and setPrivacyMode().

◆ $respect_min_search_character_count

ilUserAutoComplete::$respect_min_search_character_count = true
private

Definition at line 80 of file class.ilUserAutoComplete.php.

Referenced by getRespectMinimumSearchCharacterCount().

◆ $result_field

ilUserAutoComplete::$result_field
private

Definition at line 55 of file class.ilUserAutoComplete.php.

◆ $search_type

ilUserAutoComplete::$search_type
private

Definition at line 60 of file class.ilUserAutoComplete.php.

Referenced by getSearchType(), and setSearchType().

◆ $searchable_check

ilUserAutoComplete::$searchable_check = false
private

Definition at line 40 of file class.ilUserAutoComplete.php.

Referenced by isFieldSearchableCheckEnabled().

◆ $user

ilUserAutoComplete::$user
private

Definition at line 70 of file class.ilUserAutoComplete.php.

Referenced by getUser(), and setUser().

◆ $user_access_check

ilUserAutoComplete::$user_access_check = true
private

Definition at line 45 of file class.ilUserAutoComplete.php.

Referenced by isUserAccessCheckEnabled().

◆ $user_filter

ilUserAutoComplete::$user_filter = null
protected

Definition at line 90 of file class.ilUserAutoComplete.php.

Referenced by addUserAccessFilterCallable().

◆ $user_limitations

ilUserAutoComplete::$user_limitations = true
private

Definition at line 75 of file class.ilUserAutoComplete.php.

Referenced by getUserLimitations().

◆ MAX_ENTRIES

◆ PRIVACY_MODE_IGNORE_USER_SETTING

const ilUserAutoComplete::PRIVACY_MODE_IGNORE_USER_SETTING = 2

Definition at line 30 of file class.ilUserAutoComplete.php.

◆ PRIVACY_MODE_RESPECT_USER_SETTING

◆ SEARCH_TYPE_EQUALS

const ilUserAutoComplete::SEARCH_TYPE_EQUALS = 2

◆ SEARCH_TYPE_LIKE

const ilUserAutoComplete::SEARCH_TYPE_LIKE = 1

Definition at line 15 of file class.ilUserAutoComplete.php.


The documentation for this class was generated from the following file: