ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilRoleAutoComplete Class Reference

Auto completion class for user lists. More...

+ Collaboration diagram for ilRoleAutoComplete:

Static Public Member Functions

static getList (string $a_str)
 Get completion list. More...
 
static getListByObject (string $a_str)
 Get list of roles assigned to an object. More...
 

Detailed Description

Auto completion class for user lists.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 25 of file class.ilRoleAutoComplete.php.

Member Function Documentation

◆ getList()

static ilRoleAutoComplete::getList ( string  $a_str)
static

Get completion list.

Definition at line 30 of file class.ilRoleAutoComplete.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilRoleAutoCompleteInputGUI\echoAutoCompleteList(), and ilRegistrationSettingsGUI\getLocalRoleAutoComplete().

30  : string
31  {
32  global $DIC;
33 
34  $ilDB = $DIC->database();
35  $ilDB->setLimit(20, 0);
36  $query = "SELECT o1.title role,o2.title container FROM object_data o1 " .
37  "JOIN rbac_fa fa ON o1.obj_id = rol_id " .
38 // "JOIN tree t1 ON fa.parent = t1.child " .
39 // "JOIN object_reference obr ON ref_id = t1.parent " .
40  "JOIN object_reference obr ON ref_id = fa.parent AND obr.deleted IS NULL " .
41  "JOIN object_data o2 ON obr.obj_id = o2.obj_id " .
42  "INNER JOIN tree t ON t.child = obr.ref_id AND t.tree = 1 " .
43  "WHERE o1.type = 'role' " .
44  "AND assign = 'y' " .
45  "AND (" . $ilDB->like('o1.title', 'text', '%' . $a_str . '%') . "OR " .
46  $ilDB->like('o2.title', 'text', '%' . $a_str . '%') . " )" .
47  "AND fa.parent != 8 " .
48  "ORDER BY role,container";
49 
50  $res = $ilDB->query($query);
51  $counter = 0;
52  $result = [];
53  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
54  $result[$counter] = new stdClass();
55  $result[$counter]->value = $row->role;
56  $result[$counter]->label = $row->role . " (" . $row->container . ")";
57  ++$counter;
58  }
59 
60  if ($counter == 0) {
61  return self::getListByObject($a_str);
62  }
63 
64  return json_encode($result, JSON_THROW_ON_ERROR);
65  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getListByObject()

static ilRoleAutoComplete::getListByObject ( string  $a_str)
static

Get list of roles assigned to an object.

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

References $DIC, $ilDB, $res, ilObject\_lookupTitle(), and ilDBConstants\FETCHMODE_OBJECT.

70  : string
71  {
72  global $DIC;
73 
74  $rbacreview = $DIC->rbac()->review();
75  $ilDB = $DIC->database();
76 
77  $result = [];
78 
79  if (strpos($a_str, '@') !== 0) {
80  return json_encode($result, JSON_THROW_ON_ERROR);
81  }
82 
83  $a_str = substr($a_str, 1);
84 
85  $ilDB->setLimit(100, 0);
86  $query = "SELECT ref_id, title FROM object_data ode " .
87  "JOIN object_reference ore ON ode.obj_id = ore.obj_id " .
88  "WHERE " . $ilDB->like('title', 'text', $a_str . '%') . ' ' .
89  'ORDER BY title';
90  $res = $ilDB->query($query);
91  $counter = 0;
92  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
93  foreach ($rbacreview->getRolesOfRoleFolder($row->ref_id, false) as $rol_id) {
94  $role = ilObject::_lookupTitle($rol_id);
95 
96  $result[$counter] = new stdClass();
97  $result[$counter]->value = $role;
98  $result[$counter]->label = $role . " (" . $row->title . ")";
99  ++$counter;
100  }
101  }
102  return json_encode($result, JSON_THROW_ON_ERROR);
103  }
$res
Definition: ltiservices.php:66
static _lookupTitle(int $obj_id)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

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