ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilRoleAutoComplete.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  include_once './Services/JSON/classes/class.ilJsonUtil.php';
18  $result = new stdClass();
19  $result->response = new stdClass();
20  $result->response->results = array();
21  if (strlen($a_str) < 3)
22  {
24  }
25 
26  $ilDB->setLimit(20);
27  $query = "SELECT o1.title role,o2.title container FROM object_data o1 ".
28  "JOIN rbac_fa fa ON o1.obj_id = rol_id ".
29  "JOIN tree t1 ON fa.parent = t1.child ".
30  "JOIN object_reference obr ON ref_id = t1.parent ".
31  "JOIN object_data o2 ON obr.obj_id = o2.obj_id ".
32  "WHERE o1.type = 'role' ".
33  "AND assign = 'y' ".
34  "AND ".$ilDB->like('o1.title','text','%'.$a_str.'%')." ".
35  "AND fa.parent != 8 ".
36  "ORDER BY role,container";
37 
38  $res = $ilDB->query($query);
39  $counter = 0;
40  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
41  {
42  $result->response->results[$counter] = new stdClass();
43  $result->response->results[$counter]->role = $row->role;
44  $result->response->results[$counter]->container = $row->container;
45  ++$counter;
46  }
47 
48  if($counter == 0)
49  {
50  return self::getListByObject($a_str);
51  }
53  }
54 
60  public static function getListByObject($a_str)
61  {
62  global $rbacreview,$ilDB;
63 
64  include_once './Services/JSON/classes/class.ilJsonUtil.php';
65  $result = new stdClass();
66  $result->response = new stdClass();
67  $result->response->results = array();
68 
69  if(strpos($a_str,'@') !== 0)
70  {
72  }
73 
74  $a_str = substr($a_str,1);
75 
76  $ilDB->setLimit(100);
77  $query = "SELECT ref_id, title FROM object_data ode ".
78  "JOIN object_reference ore ON ode.obj_id = ore.obj_id ".
79  "WHERE ".$ilDB->like('title', 'text',$a_str.'%').' '.
80  'ORDER BY title';
81  $res = $ilDB->query($query);
82  $counter = 0;
83  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
84  {
85  $rolf = $rbacreview->getRoleFolderIdOfObject($row->ref_id);
86  if($rolf)
87  {
88  foreach($rbacreview->getRolesOfRoleFolder($rolf,false) as $rol_id)
89  {
90  $result->response->results[$counter] = new stdClass();
91  $result->response->results[$counter]->role = ilObject::_lookupTitle($rol_id);
92  $result->response->results[$counter]->container = $row->title;
93  ++$counter;
94  }
95  }
96  }
98  }
99 }
100 ?>