ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRoleAutoComplete Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Auto completion class for user lists

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

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

Member Function Documentation

◆ getList()

static ilRoleAutoComplete::getList ( string  $a_str)
static

Get completion list.

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

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

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

29  : string
30  {
31  global $DIC;
32 
33  $ilDB = $DIC->database();
34  $ilDB->setLimit(20, 0);
35  $query = "SELECT o1.title role,o2.title container FROM object_data o1 " .
36  "JOIN rbac_fa fa ON o1.obj_id = rol_id " .
37 // "JOIN tree t1 ON fa.parent = t1.child " .
38 // "JOIN object_reference obr ON ref_id = t1.parent " .
39  "JOIN object_reference obr ON ref_id = fa.parent " .
40  "JOIN object_data o2 ON obr.obj_id = o2.obj_id " .
41  "WHERE o1.type = 'role' " .
42  "AND assign = 'y' " .
43  "AND (" . $ilDB->like('o1.title', 'text', '%' . $a_str . '%') . "OR " .
44  $ilDB->like('o2.title', 'text', '%' . $a_str . '%') . " )" .
45  "AND fa.parent != 8 " .
46  "ORDER BY role,container";
47 
48  $res = $ilDB->query($query);
49  $counter = 0;
50  $result = array();
51  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
52  $result[$counter] = new stdClass();
53  $result[$counter]->value = $row->role;
54  $result[$counter]->label = $row->role . " (" . $row->container . ")";
55  ++$counter;
56  }
57 
58  if ($counter == 0) {
59  return self::getListByObject($a_str);
60  }
61 
62  return json_encode($result, JSON_THROW_ON_ERROR);
63  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
+ 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 68 of file class.ilRoleAutoComplete.php.

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

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

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