ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilUserSearchFilter Class Reference
+ Collaboration diagram for ilUserSearchFilter:

Public Member Functions

 __construct ($a_usr_id)
 
 enableField ($key)
 
 disableField ($key)
 
 enableMemberFilter ($a_status)
 
 setPossibleUsers ($a_users)
 
 getLimit ()
 
 limitReached ()
 
 getUserId ()
 
 storeQueryStrings ($a_strings)
 
 getQueryString ($a_field)
 
 getUsers ()
 
 __searchObjects ()
 
__parseQueryString ($a_string)
 parse query string, using query parser instance More...
 
 __storeEntries (&$new_res)
 
 __toArray ($entries)
 
 memberFilter ($a_usr_id, $entry_data)
 

Data Fields

 $limit = 0
 
 $limit_reached = false
 
 $search_fields
 
 $enabled_member_filter = false
 
 $possible_users = array()
 
 $usr_id = null
 
 $db = null
 

Detailed Description

Definition at line 39 of file class.ilUserSearchFilter.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserSearchFilter::__construct (   $a_usr_id)

Definition at line 57 of file class.ilUserSearchFilter.php.

References $ilDB.

58  {
59  global $ilDB,$ilias;
60 
61  $this->usr_id = $a_usr_id;
62  $this->db =&$ilDB;
63 
64  // Limit of filtered objects is search max hits
65  $this->limit = $ilias->getSetting('search_max_hits', 50);
66  $this->result_obj = new ilSearchResult();
67  }
global $ilDB

Member Function Documentation

◆ __parseQueryString()

& ilUserSearchFilter::__parseQueryString (   $a_string)

parse query string, using query parser instance

Returns
object of query parser or error message if an error occured public

Definition at line 174 of file class.ilUserSearchFilter.php.

References QP_COMBINATION_OR, and ilUtil\stripSlashes().

Referenced by __searchObjects().

175  {
176  include_once 'Services/Search/classes/class.ilQueryParser.php';
177 
178  $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
179  $query_parser->setCombination(QP_COMBINATION_OR);
180  $query_parser->setMinWordLength(1, true);
181  $query_parser->parse();
182 
183  if (!$query_parser->validate()) {
184  return $query_parser->getMessage();
185  }
186  return $query_parser;
187  }
const QP_COMBINATION_OR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __searchObjects()

ilUserSearchFilter::__searchObjects ( )

Definition at line 134 of file class.ilUserSearchFilter.php.

References $_SESSION, __parseQueryString(), __storeEntries(), __toArray(), ilObjectSearchFactory\_getUserSearchInstance(), array, QP_COMBINATION_OR, and ilUtil\sendInfo().

Referenced by getUsers().

135  {
136  foreach ($this->search_fields as $field => $enabled) {
137  // Disabled ?
138  if (!$enabled) {
139  continue;
140  }
141 
142  $query_string = $_SESSION['search_usr_filter'][$field];
143  if (!$query_string) {
144  continue;
145  }
146  if (!is_object($query_parser = $this->__parseQueryString($query_string))) {
147  ilUtil::sendInfo($query_parser);
148  return false;
149  }
150  $user_search =&ilObjectSearchFactory::_getUserSearchInstance($query_parser);
151  $user_search->setFields(array($field));
152 
153  // store entries
154  $this->__storeEntries($result_obj = $user_search->performSearch());
155  }
156 
157  // no filter entries
158  if (is_object($this->result_obj)) {
159  if ($this->enabled_member_filter) {
160  $this->result_obj->addObserver($this, 'memberFilter');
161  }
162  $this->result_obj->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
163 
164  return $this->__toArray($this->result_obj->getResults());
165  }
166  return array();
167  }
$_SESSION["AccountId"]
const QP_COMBINATION_OR
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static _getUserSearchInstance($query_parser)
get reference of ilLikeUserSearch
Create styles array
The data for the language used.
& __parseQueryString($a_string)
parse query string, using query parser instance
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __storeEntries()

ilUserSearchFilter::__storeEntries ( $new_res)

Definition at line 190 of file class.ilUserSearchFilter.php.

Referenced by __searchObjects().

191  {
192  if ($this->stored == false) {
193  $this->result_obj->mergeEntries($new_res);
194  $this->stored = true;
195  return true;
196  } else {
197  $this->result_obj->intersectEntries($new_res);
198  return true;
199  }
200  }
+ Here is the caller graph for this function:

◆ __toArray()

ilUserSearchFilter::__toArray (   $entries)

Definition at line 202 of file class.ilUserSearchFilter.php.

References $users, and array.

Referenced by __searchObjects().

203  {
204  foreach ($entries as $entry) {
205  $users[] = $entry['obj_id'];
206  }
207  return $users ? $users : array();
208  }
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
+ Here is the caller graph for this function:

◆ disableField()

ilUserSearchFilter::disableField (   $key)

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

References $key.

74  {
75  $this->search_fields[$key] = true;
76  }
$key
Definition: croninfo.php:18

◆ enableField()

ilUserSearchFilter::enableField (   $key)

Definition at line 69 of file class.ilUserSearchFilter.php.

References $key.

70  {
71  $this->search_fields[$key] = true;
72  }
$key
Definition: croninfo.php:18

◆ enableMemberFilter()

ilUserSearchFilter::enableMemberFilter (   $a_status)

Definition at line 77 of file class.ilUserSearchFilter.php.

78  {
79  $this->enabled_member_filter = $a_status;
80  }

◆ getLimit()

ilUserSearchFilter::getLimit ( )

Definition at line 88 of file class.ilUserSearchFilter.php.

References $limit.

89  {
90  return $this->limit;
91  }

◆ getQueryString()

ilUserSearchFilter::getQueryString (   $a_field)

Definition at line 108 of file class.ilUserSearchFilter.php.

References $_SESSION.

109  {
110  return isset($_SESSION['search_usr_filter'][$a_field]) ? $_SESSION['search_usr_filter'][$a_field] : '';
111  }
$_SESSION["AccountId"]

◆ getUserId()

ilUserSearchFilter::getUserId ( )

Definition at line 98 of file class.ilUserSearchFilter.php.

References $usr_id.

99  {
100  return $this->usr_id;
101  }

◆ getUsers()

ilUserSearchFilter::getUsers ( )

Definition at line 114 of file class.ilUserSearchFilter.php.

References $_SESSION, $possible_users, and __searchObjects().

115  {
116  // Check if a query string is given
117  foreach ($this->search_fields as $field => $enabled) {
118  if (!$enabled) {
119  continue;
120  }
121  if (strlen($_SESSION['search_usr_filter'][$field])) {
122  $search = true;
123  break;
124  }
125  }
126  if ($search) {
127  return $this->__searchObjects();
128  } else {
129  return $this->possible_users;
130  }
131  }
$_SESSION["AccountId"]
+ Here is the call graph for this function:

◆ limitReached()

ilUserSearchFilter::limitReached ( )

Definition at line 93 of file class.ilUserSearchFilter.php.

References $limit_reached.

◆ memberFilter()

ilUserSearchFilter::memberFilter (   $a_usr_id,
  $entry_data 
)

Definition at line 210 of file class.ilUserSearchFilter.php.

211  {
212  return in_array($a_usr_id, $this->possible_users);
213  }

◆ setPossibleUsers()

ilUserSearchFilter::setPossibleUsers (   $a_users)

Definition at line 82 of file class.ilUserSearchFilter.php.

References array.

83  {
84  $this->possible_users = $a_users ? $a_users : array();
85  }
Create styles array
The data for the language used.

◆ storeQueryStrings()

ilUserSearchFilter::storeQueryStrings (   $a_strings)

Definition at line 103 of file class.ilUserSearchFilter.php.

References $_SESSION.

104  {
105  $_SESSION['search_usr_filter'] = $a_strings;
106  }
$_SESSION["AccountId"]

Field Documentation

◆ $db

ilUserSearchFilter::$db = null

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

◆ $enabled_member_filter

ilUserSearchFilter::$enabled_member_filter = false

Definition at line 49 of file class.ilUserSearchFilter.php.

◆ $limit

ilUserSearchFilter::$limit = 0

Definition at line 41 of file class.ilUserSearchFilter.php.

Referenced by getLimit().

◆ $limit_reached

ilUserSearchFilter::$limit_reached = false

Definition at line 42 of file class.ilUserSearchFilter.php.

Referenced by limitReached().

◆ $possible_users

ilUserSearchFilter::$possible_users = array()

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

Referenced by getUsers().

◆ $search_fields

ilUserSearchFilter::$search_fields
Initial value:
= array('login' => true,
'firstname' => true,
'lastname' => true)

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

◆ $usr_id

ilUserSearchFilter::$usr_id = null

Definition at line 54 of file class.ilUserSearchFilter.php.

Referenced by getUserId().


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