ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, and $ilDB.

58  {
59  global $DIC;
60 
61  $ilDB = $DIC['ilDB'];
62  $ilias = $DIC['ilias'];
63 
64  $this->usr_id = $a_usr_id;
65  $this->db = &$ilDB;
66 
67  // Limit of filtered objects is search max hits
68  $this->limit = $ilias->getSetting('search_max_hits', 50);
69  $this->result_obj = new ilSearchResult();
70  }
global $DIC
Definition: saml.php:7
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 177 of file class.ilUserSearchFilter.php.

References QP_COMBINATION_OR, and ilUtil\stripSlashes().

Referenced by __searchObjects().

178  {
179  include_once 'Services/Search/classes/class.ilQueryParser.php';
180 
181  $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
182  $query_parser->setCombination(QP_COMBINATION_OR);
183  $query_parser->setMinWordLength(1, true);
184  $query_parser->parse();
185 
186  if (!$query_parser->validate()) {
187  return $query_parser->getMessage();
188  }
189  return $query_parser;
190  }
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 137 of file class.ilUserSearchFilter.php.

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

Referenced by getUsers().

138  {
139  foreach ($this->search_fields as $field => $enabled) {
140  // Disabled ?
141  if (!$enabled) {
142  continue;
143  }
144 
145  $query_string = $_SESSION['search_usr_filter'][$field];
146  if (!$query_string) {
147  continue;
148  }
149  if (!is_object($query_parser = $this->__parseQueryString($query_string))) {
150  ilUtil::sendInfo($query_parser);
151  return false;
152  }
153  $user_search = &ilObjectSearchFactory::_getUserSearchInstance($query_parser);
154  $user_search->setFields(array($field));
155 
156  // store entries
157  $this->__storeEntries($result_obj = $user_search->performSearch());
158  }
159 
160  // no filter entries
161  if (is_object($this->result_obj)) {
162  if ($this->enabled_member_filter) {
163  $this->result_obj->addObserver($this, 'memberFilter');
164  }
165  $this->result_obj->filter(ROOT_FOLDER_ID, QP_COMBINATION_OR);
166 
167  return $this->__toArray($this->result_obj->getResults());
168  }
169  return array();
170  }
$_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
& __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 193 of file class.ilUserSearchFilter.php.

Referenced by __searchObjects().

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

◆ __toArray()

ilUserSearchFilter::__toArray (   $entries)

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

References $users.

Referenced by __searchObjects().

206  {
207  foreach ($entries as $entry) {
208  $users[] = $entry['obj_id'];
209  }
210  return $users ? $users : array();
211  }
$users
Definition: authpage.php:44
+ Here is the caller graph for this function:

◆ disableField()

ilUserSearchFilter::disableField (   $key)

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

References $key.

77  {
78  $this->search_fields[$key] = true;
79  }
$key
Definition: croninfo.php:18

◆ enableField()

ilUserSearchFilter::enableField (   $key)

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

References $key.

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

◆ enableMemberFilter()

ilUserSearchFilter::enableMemberFilter (   $a_status)

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

81  {
82  $this->enabled_member_filter = $a_status;
83  }

◆ getLimit()

ilUserSearchFilter::getLimit ( )

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

References $limit.

92  {
93  return $this->limit;
94  }

◆ getQueryString()

ilUserSearchFilter::getQueryString (   $a_field)

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

References $_SESSION.

112  {
113  return isset($_SESSION['search_usr_filter'][$a_field]) ? $_SESSION['search_usr_filter'][$a_field] : '';
114  }
$_SESSION["AccountId"]

◆ getUserId()

ilUserSearchFilter::getUserId ( )

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

References $usr_id.

102  {
103  return $this->usr_id;
104  }

◆ getUsers()

ilUserSearchFilter::getUsers ( )

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

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

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

◆ limitReached()

ilUserSearchFilter::limitReached ( )

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

References $limit_reached.

◆ memberFilter()

ilUserSearchFilter::memberFilter (   $a_usr_id,
  $entry_data 
)

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

214  {
215  return in_array($a_usr_id, $this->possible_users);
216  }

◆ setPossibleUsers()

ilUserSearchFilter::setPossibleUsers (   $a_users)

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

86  {
87  $this->possible_users = $a_users ? $a_users : array();
88  }

◆ storeQueryStrings()

ilUserSearchFilter::storeQueryStrings (   $a_strings)

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

References $_SESSION.

107  {
108  $_SESSION['search_usr_filter'] = $a_strings;
109  }
$_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: