ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
68  }
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 187 of file class.ilUserSearchFilter.php.

References QP_COMBINATION_OR, and ilUtil\stripSlashes().

Referenced by __searchObjects().

188  {
189  include_once 'Services/Search/classes/class.ilQueryParser.php';
190 
191  $query_parser = new ilQueryParser(ilUtil::stripSlashes($a_string));
192  $query_parser->setCombination(QP_COMBINATION_OR);
193  $query_parser->setMinWordLength(1,true);
194  $query_parser->parse();
195 
196  if(!$query_parser->validate())
197  {
198  return $query_parser->getMessage();
199  }
200  return $query_parser;
201  }
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 141 of file class.ilUserSearchFilter.php.

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

Referenced by getUsers().

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

Referenced by __searchObjects().

205  {
206  if($this->stored == false)
207  {
208  $this->result_obj->mergeEntries($new_res);
209  $this->stored = true;
210  return true;
211  }
212  else
213  {
214  $this->result_obj->intersectEntries($new_res);
215  return true;
216  }
217  }
+ Here is the caller graph for this function:

◆ __toArray()

ilUserSearchFilter::__toArray (   $entries)

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

References array.

Referenced by __searchObjects().

220  {
221  foreach($entries as $entry)
222  {
223  $users[] = $entry['obj_id'];
224  }
225  return $users ? $users : array();
226  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ disableField()

ilUserSearchFilter::disableField (   $key)

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

75  {
76  $this->search_fields[$key] = true;
77  }

◆ enableField()

ilUserSearchFilter::enableField (   $key)

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

71  {
72  $this->search_fields[$key] = true;
73  }

◆ enableMemberFilter()

ilUserSearchFilter::enableMemberFilter (   $a_status)

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

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

◆ getLimit()

ilUserSearchFilter::getLimit ( )

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

References $limit.

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

◆ getQueryString()

ilUserSearchFilter::getQueryString (   $a_field)

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

References $_SESSION.

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

◆ getUserId()

ilUserSearchFilter::getUserId ( )

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

References $usr_id.

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

◆ getUsers()

ilUserSearchFilter::getUsers ( )

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

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

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

◆ limitReached()

ilUserSearchFilter::limitReached ( )

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

References $limit_reached.

◆ memberFilter()

ilUserSearchFilter::memberFilter (   $a_usr_id,
  $entry_data 
)

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

229  {
230  return in_array($a_usr_id,$this->possible_users);
231  }

◆ setPossibleUsers()

ilUserSearchFilter::setPossibleUsers (   $a_users)

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

References array.

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

◆ storeQueryStrings()

ilUserSearchFilter::storeQueryStrings (   $a_strings)

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

References $_SESSION.

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