ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserAutoComplete.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
13  public static function getList($a_str)
14  {
15  global $ilDB;
16 
17  /*
18  $search = explode(',', $a_str);
19  if(count($search) > 1)
20  {
21  $a_str = end($search);
22  }
23  */
24 
25  include_once './Services/JSON/classes/class.ilJsonUtil.php';
26  $result = new stdClass();
27  $result->response = new stdClass();
28  $result->response->results = array();
29  if (strlen($a_str) < 3)
30  {
31  return ilJsonUtil::encode($result);
32  }
33 
34  include_once './Services/User/classes/class.ilUserAccountSettings.php';
35  if(ilUserAccountSettings::getInstance()->isUserAccessRestricted())
36  {
37  include_once './Services/User/classes/class.ilUserFilter.php';
38  $query = "SELECT login, firstname, lastname FROM usr_data ".
39  "WHERE (".
40  $ilDB->like("login", "text", $a_str."%")." OR ".
41  $ilDB->like("firstname", "text", $a_str."%")." OR ".
42  $ilDB->like("lastname", "text", $a_str."%").
43  ") AND ".$ilDB->in('time_limit_owner',ilUserFilter::getInstance()->getFolderIds(),false,'integer')." ".
44  "ORDER BY login ";
45  $set = $ilDB->query($query);
46  }
47  else
48  {
49  $set = $ilDB->query("SELECT login, firstname, lastname FROM usr_data WHERE ".
50  $ilDB->like("login", "text", $a_str."%")." OR ".
51  $ilDB->like("firstname", "text", $a_str."%")." OR ".
52  $ilDB->like("lastname", "text", $a_str."%").
53  " ORDER BY login");
54  }
55  $max = 20;
56  $cnt = 0;
57  while (($rec = $ilDB->fetchAssoc($set)) && $cnt < $max)
58  {
59  $result->response->results[$cnt] = new stdClass();
60  $result->response->results[$cnt]->login = $rec["login"];
61  $result->response->results[$cnt]->firstname = $rec["firstname"];
62  $result->response->results[$cnt]->lastname = $rec["lastname"];
63  $cnt++;
64  }
65 
66  return ilJsonUtil::encode($result);
67  }
68 
69 }
70 ?>