ILIAS  release_8 Revision v8.24
ilObjOrgUnitTree 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 ilObjOrgUnitTree:

Public Member Functions

 getEmployees (int $ref_id, bool $recursive=false)
 
 getAssignements (int $ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
 
 getSuperiors (int $ref_id, bool $recursive=false)
 
 getAllChildren (int $ref_id)
 
 getOrgusWhereUserHasPermissionForOperation ($operation)
 If you want to have all orgunits where the current user has the write permission: use this with the parameter "write". More...
 
 getOrgusWhereUserHasPermissionForOperationId (string $operation_id)
 If you want to have all orgunits where the current user has the write permission: use this with the parameter 3 (3 is the "write" permission as in rbac_operations). More...
 
 getAllOrgunitsOnLevelX (int $level)
 
 getEmployeesUnderUser (int $user_id, bool $recursive=true)
 
 getSuperiorsOfUser (int $user_id, bool $recursive=true)
 
 getLevelXOfUser (int $user_id, int $level)
 for additional info see the other getLevelX method. More...
 
 getOrgUnitOfUser (int $user_id)
 
 buildTempTableWithUsrAssignements (string $temporary_table_name='orgu_usr_assignements')
 Creates a temporary table with all orgu/user assignements. More...
 
 dropTempTable (string $temporary_table_name)
 
 getTitles (array $org_refs)
 
 getEmployeeRoles ()
 
 getSuperiorRoles ()
 
 flushCache ()
 
 getLevelXOfTreenode (int $orgu_ref, int $level)
 Specify eg. More...
 
 getParent (int $orgu_ref)
 

Static Public Member Functions

static _getInstance ()
 

Static Protected Attributes

static string $temporary_table_name_getOrgUnitOfUser = null
 
static string $temporary_table_name = null
 
static ilObjOrgUnitTree $instance = null
 

Private Member Functions

 __construct ()
 
 loadArrayOfStaff (string $title, array $ref_ids)
 
 getChildren (int $ref_id)
 
 loadChildren (int $ref_id)
 
 loadRoles (string $role)
 
 loadRolesQuery (string $role)
 
 getRefIdFromRoleTitle (string $role_title)
 

Private Attributes

array $roles
 
array $role_to_orgu
 
 $staff
 
array $tree_childs = []
 
array $parent = []
 
ilDBInterface $db
 
ilObjUser $ilUser
 
ilTree $tree
 

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 Class ilObjOrgUnitTree Implements a singleton pattern for caching.

Author
: Oskar Truffer ot@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
: Martin Studer ms@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

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

Constructor & Destructor Documentation

◆ __construct()

ilObjOrgUnitTree::__construct ( )
private

Definition at line 44 of file class.ilObjOrgUnitTree.php.

45 {
46 global $DIC;
47 $this->db = $DIC->database();
48 $this->tree = $DIC->repositoryTree();
49 $this->roles = array();
50 $this->staff = array();
51 $this->ilUser = $DIC->user();
52 }
global $DIC
Definition: feed.php:28

References $DIC.

Member Function Documentation

◆ _getInstance()

static ilObjOrgUnitTree::_getInstance ( )
static

◆ buildTempTableWithUsrAssignements()

ilObjOrgUnitTree::buildTempTableWithUsrAssignements ( string  $temporary_table_name = 'orgu_usr_assignements')

Creates a temporary table with all orgu/user assignements.

there will be three columns in the table orgu_usr_assignements (or specified table-name): ref_id: Reference-IDs of OrgUnits user_id: Assigned User-IDs path: Path-representation of the OrgUnit Usage:

  1. Run ilObjOrgUnitTree::getInstance()->buildTempTableWithUsrAssignements(); in your code
  2. use the table orgu_usr_assignements for your JOINS ans SELECTS
  3. Run ilObjOrgUnitTree::getInstance()->dropTempTable(); to throw away the table
    Parameters
    string$temporary_table_name
    Returns
    bool
    Exceptions
    ilException

Definition at line 401 of file class.ilObjOrgUnitTree.php.

401 : bool
402 {
403 if (self::$temporary_table_name == $temporary_table_name) {
404 return true;
405 }
406 if (self::$temporary_table_name === null) {
408 self::$temporary_table_name = $temporary_table_name;
409 } elseif ($temporary_table_name != self::$temporary_table_name) {
410 throw new ilException('there is already a temporary table for org-unit assignement: ' . self::$temporary_table_name);
411 }
412
413 $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . " AS (
414 SELECT DISTINCT object_reference.ref_id AS ref_id, il_orgu_ua.user_id AS user_id, orgu_path_storage.path AS path
415 FROM il_orgu_ua
416 JOIN object_reference ON object_reference.ref_id = il_orgu_ua.orgu_id
417 JOIN object_data ON object_data.obj_id = object_reference.obj_id
418 JOIN orgu_path_storage ON orgu_path_storage.ref_id = object_reference.ref_id
419 WHERE object_data.type = 'orgu' AND object_reference.deleted IS NULL
420 );";
421 $this->db->manipulate($q);
422
423 return true;
424 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static string $temporary_table_name
dropTempTable(string $temporary_table_name)

References $temporary_table_name, and dropTempTable().

+ Here is the call graph for this function:

◆ dropTempTable()

ilObjOrgUnitTree::dropTempTable ( string  $temporary_table_name)

Definition at line 426 of file class.ilObjOrgUnitTree.php.

426 : bool
427 {
428 if (self::$temporary_table_name === null
429 || $temporary_table_name !== self::$temporary_table_name
430 ) {
431 return false;
432 }
433 $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
434 $this->db->manipulate($q);
435
436 self::$temporary_table_name = null;
437
438 return true;
439 }

References $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

Definition at line 477 of file class.ilObjOrgUnitTree.php.

477 : void
478 {
479 $this->roles = null;
480 }

◆ getAllChildren()

ilObjOrgUnitTree::getAllChildren ( int  $ref_id)

Definition at line 159 of file class.ilObjOrgUnitTree.php.

159 : array
160 {
161 $open = array($ref_id);
162 $closed = array();
163 while (count($open)) {
164 $ref = array_pop($open);
165 $closed[] = $ref;
166 foreach ($this->getChildren($ref) as $child) {
167 if (in_array($child, $open, true) === false && in_array($child, $closed, true) === false) {
168 $open[] = $child;
169 }
170 }
171 }
172
173 return $closed;
174 }
$ref_id
Definition: ltiauth.php:67

References $ref_id, and getChildren().

Referenced by getEmployees(), getEmployeesUnderUser(), and getSuperiors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllOrgunitsOnLevelX()

ilObjOrgUnitTree::getAllOrgunitsOnLevelX ( int  $level)

Definition at line 267 of file class.ilObjOrgUnitTree.php.

267 : array
268 {
269 $levels = array(0 => array(ilObjOrgUnit::getRootOrgRefId()));
270 $current_level = 0;
271 while ($current_level < $level) {
272 $new_level = array();
273 foreach ($levels[$current_level] as $orgu_ref) {
274 $new_level = array_merge($this->getChildren($orgu_ref), $new_level);
275 }
276 $new_level = array_unique($new_level);
277 $levels[$current_level + 1] = $new_level;
278 $current_level++;
279 }
280
281 return $levels[$level];
282 }
static getRootOrgRefId()

References getChildren(), and ilObjOrgUnit\getRootOrgRefId().

+ Here is the call graph for this function:

◆ getAssignements()

ilObjOrgUnitTree::getAssignements ( int  $ref_id,
ilOrgUnitPosition  $ilOrgUnitPosition 
)

Definition at line 90 of file class.ilObjOrgUnitTree.php.

90 : array
91 {
93 'orgu_id' => $ref_id,
94 'position_id' => $ilOrgUnitPosition->getId(),
95 ))->getArray('id', 'user_id');
96 }
static where($where, $operator=null)

References $ref_id, ilOrgUnitPosition\getId(), and ActiveRecord\where().

Referenced by getEmployees(), and getSuperiors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChildren()

ilObjOrgUnitTree::getChildren ( int  $ref_id)
private

Definition at line 248 of file class.ilObjOrgUnitTree.php.

248 : array
249 {
250 $this->loadChildren($ref_id);
251 return $this->tree_childs[$ref_id];
252 }

References $ref_id, and loadChildren().

Referenced by getAllChildren(), and getAllOrgunitsOnLevelX().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmployeeRoles()

ilObjOrgUnitTree::getEmployeeRoles ( )
Returns
int[] returns an array of role_ids. orgu_ref => role_id

Definition at line 454 of file class.ilObjOrgUnitTree.php.

454 : array
455 {
456 $this->loadRoles("employee");
457 return $this->roles["employee"];
458 }

References loadRoles().

+ Here is the call graph for this function:

◆ getEmployees()

ilObjOrgUnitTree::getEmployees ( int  $ref_id,
bool  $recursive = false 
)
Parameters
int$ref_idthe reference id of the organisational unit.
bool$recursiveif true you get the ids of the subsequent orgunits employees too

Definition at line 67 of file class.ilObjOrgUnitTree.php.

67 : array
68 {
69 $arr_usr_ids = [];
70
71 switch ($recursive) {
72 case false:
73 $arr_usr_ids = $this->getAssignements(
74 $ref_id,
76 );
77 break;
78 case true:
80 $arr_usr_ids = $assignment_query->getUserIdsOfOrgUnitsInPosition(
81 $this->getAllChildren($ref_id),
83 );
84 break;
85 }
86
87 return $arr_usr_ids;
88 }
getAssignements(int $ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
static getCorePosition(int $core_identifier)

References ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, getAllChildren(), getAssignements(), ilOrgUnitPosition\getCorePosition(), and ilOrgUnitUserAssignmentQueries\getInstance().

Referenced by ilOrgUnitExtension\getEmployees().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmployeesUnderUser()

ilObjOrgUnitTree::getEmployeesUnderUser ( int  $user_id,
bool  $recursive = true 
)
Parameters
bool$recursiveif this is true subsequent orgunits of this users superior role get searched as well.
Returns
int[] returns an array of user_ids of the users which have an employee role in an orgunit of which this user's id has a superior role.

Definition at line 290 of file class.ilObjOrgUnitTree.php.

290 : array
291 {
293 $orgu_ref_ids = $assignment_query->getOrgUnitIdsOfUsersPosition(
295 $user_id
296 );
297
298 switch ($recursive) {
299 case true:
300 $orgu_ref_id_with_children = [];
301 foreach ($orgu_ref_ids as $orgu_ref_id) {
302 $orgu_ref_id_with_children = array_merge($orgu_ref_ids, $this->getAllChildren($orgu_ref_id));
303 }
304 return $assignment_query->getUserIdsOfOrgUnitsInPosition(
305 $orgu_ref_id_with_children,
307 );
308 default:
309 return $assignment_query->getUserIdsOfOrgUnitsInPosition(
310 $orgu_ref_ids,
312 );
313 }
314 }

References ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ilOrgUnitPosition\CORE_POSITION_SUPERIOR, getAllChildren(), and ilOrgUnitUserAssignmentQueries\getInstance().

+ Here is the call graph for this function:

◆ getLevelXOfTreenode()

ilObjOrgUnitTree::getLevelXOfTreenode ( int  $orgu_ref,
int  $level 
)

Specify eg.

level 1 and it will return on which orgunit on the first level after the root node the specified orgu_ref is a subunit of. eg: 0

  • - 1 2
    3 4 5
  • 6 (6, 1) = 1; (4, 1) = 2; (6, 2) = 3;
    Returns
    int|bool ref_id of the orgu or false if not found.
    Exceptions
    Exceptionin case there's a thread of an infinite loop or if you try to fetch the third level but there are only two (e.g. you want to fetch lvl 1 but give the root node as reference).

Definition at line 517 of file class.ilObjOrgUnitTree.php.

518 {
519 $line = array($orgu_ref);
520 $current_ref = $orgu_ref;
521 while ($current_ref != ilObjOrgUnit::getRootOrgRefId()) {
522 $current_ref = $this->getParent($current_ref);
523 if ($current_ref) {
524 $line[] = $current_ref;
525 } else {
526 break;
527 }
528 if (count($line) > 100) {
529 throw new Exception("There's either a non valid call of the getLevelXOfTreenode in ilObjOrgUnitTree or your nesting of orgunits is higher than 100 units, which isn't encouraged");
530 }
531 }
532 $line = array_reverse($line);
533 if (count($line) > $level) {
534 return $line[$level];
535 } else {
536 throw new Exception("you want to fetch level " . $level . " but the line to the length of the line is only " . count($line)
537 . ". The line of the given org unit is: " . print_r($line, true));
538 }
539 }

References getParent(), and ilObjOrgUnit\getRootOrgRefId().

Referenced by getLevelXOfUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLevelXOfUser()

ilObjOrgUnitTree::getLevelXOfUser ( int  $user_id,
int  $level 
)

for additional info see the other getLevelX method.

Parameters
int$user_id
Returns
int[]

Definition at line 348 of file class.ilObjOrgUnitTree.php.

348 : array
349 {
350 $q = "SELECT object_reference.ref_id FROM rbac_ua
351 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
352 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
353 JOIN object_data ON object_data.obj_id = object_reference.obj_id
354 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer') . " AND object_data.type = 'orgu';";
355
356 $set = $this->db->query($q);
357 $orgu_ref_ids = array();
358 while ($res = $this->db->fetchAssoc($set)) {
359 $orgu_ref_ids[] = $res['ref_id'];
360 }
361 $orgus_on_level_x = array();
362 foreach ($orgu_ref_ids as $orgu_ref_id) {
363 try {
364 $orgus_on_level_x[] = $this->getLevelXOfTreenode($orgu_ref_id, $level);
365 } catch (Exception $e) {
366 // this means the user is assigned to a orgu above the given level. just dont add it to the list.
367 }
368 }
369
370 return array_unique($orgus_on_level_x);
371 }
getLevelXOfTreenode(int $orgu_ref, int $level)
Specify eg.
$res
Definition: ltiservices.php:69

References Vendor\Package\$e, $res, and getLevelXOfTreenode().

+ Here is the call graph for this function:

◆ getOrgUnitOfUser()

ilObjOrgUnitTree::getOrgUnitOfUser ( int  $user_id)
Parameters
int$ref_idif given, only OrgUnits under this ID are returned (including $ref_id)
Returns
int[]

Definition at line 377 of file class.ilObjOrgUnitTree.php.

377 : array
378 {
379 $orgu_ref_ids = [];
381
382 $orgus = $orgu_query->getAssignmentsOfUserId($user_id);
383 foreach ($orgus as $orgu) {
384 $orgu_ref_ids[] = $orgu->getOrguId();
385 }
386 return $orgu_ref_ids;
387 }

References ilOrgUnitUserAssignmentQueries\getInstance().

+ Here is the call graph for this function:

◆ getOrgusWhereUserHasPermissionForOperation()

ilObjOrgUnitTree::getOrgusWhereUserHasPermissionForOperation (   $operation)

If you want to have all orgunits where the current user has the write permission: use this with the parameter "write".

Returns
int[] ids of the org units.

Definition at line 181 of file class.ilObjOrgUnitTree.php.

181 : array
182 {
183
184 /*$q = "SELECT object_data.obj_id, object_reference.ref_id, object_data.title, object_data.type, rbac_pa.ops_id, rbac_operations.ops_id as op_id FROM object_data
185 INNER JOIN rbac_operations ON rbac_operations.operation = ".$this->db->quote($operation, "text")."
186 INNER JOIN rbac_ua ON rbac_ua.usr_id = ".$this->db->quote($ilUser->getId(), "integer")."
187 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
188 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
189 INNER JOIN tree ON tree.child = rbac_fa.parent
190 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
191 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";*/
192
193 $q = "SELECT object_data.obj_id, object_reference.ref_id, object_data.title, object_data.type, rbac_pa.ops_id, rbac_operations.ops_id as op_id FROM object_data
194 INNER JOIN rbac_operations ON rbac_operations.operation = " . $this->db->quote($operation, "text") . "
195 INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($this->ilUser->getId(), "integer") . "
196 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
197 INNER JOIN object_reference ON object_reference.ref_id = rbac_pa.ref_id
198 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
199
200 $set = $this->db->query($q);
201 $orgus = [];
202 while ($res = $this->db->fetchAssoc($set)) {
203 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
204 $perm_check = unserialize($res['ops_id'], ['allowed_classes' => true]);
205 if (in_array($res["op_id"], $perm_check, true) === false) {
206 continue;
207 }
208
209 $orgus[] = $res["ref_id"];
210 }
211
212 return $orgus;
213 }

References $res.

◆ getOrgusWhereUserHasPermissionForOperationId()

ilObjOrgUnitTree::getOrgusWhereUserHasPermissionForOperationId ( string  $operation_id)

If you want to have all orgunits where the current user has the write permission: use this with the parameter 3 (3 is the "write" permission as in rbac_operations).

Returns
int[] ids of the org units.

Definition at line 220 of file class.ilObjOrgUnitTree.php.

220 : array
221 {
222 $q = "SELECT object_data.obj_id, object_data.title, object_data.type, rbac_pa.ops_id FROM object_data
223 INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($this->ilUser->getId(), "integer") . "
224 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', " . $this->db->quote(
225 $operation_id,
226 "integer"
227 ) . ", '%')
228 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
229 INNER JOIN tree ON tree.child = rbac_fa.parent
230 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
231 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
232
233 $set = $this->db->query($q);
234 $orgus = array();
235 while ($res = $this->db->fetchAssoc($set)) {
236 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
237 $perm_check = unserialize($res['ops_id'], ['allowed_classes' => true]);
238 if (in_array($res["ops_id"], $perm_check, true) === false) {
239 continue;
240 }
241
242 $orgus[] = $res["obj_id"];
243 }
244
245 return $orgus;
246 }

References $res.

◆ getParent()

ilObjOrgUnitTree::getParent ( int  $orgu_ref)

Definition at line 541 of file class.ilObjOrgUnitTree.php.

541 : int
542 {
543 if (array_key_exists($orgu_ref, $this->parent) === false) {
544 $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
545 }
546
547 return $this->parent[$orgu_ref];
548 }

Referenced by getLevelXOfTreenode(), and ilOrgUnitRecursiveUserAssignmentTableGUI\mayViewLPIn().

+ Here is the caller graph for this function:

◆ getRefIdFromRoleTitle()

ilObjOrgUnitTree::getRefIdFromRoleTitle ( string  $role_title)
private

Definition at line 494 of file class.ilObjOrgUnitTree.php.

494 : int
495 {
496 $array = explode("_", $role_title);
497
498 return $array[count($array) - 1];
499 }

Referenced by loadRolesQuery().

+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
int[]

Definition at line 463 of file class.ilObjOrgUnitTree.php.

463 : array
464 {
465 $this->loadRoles("superior");
466
467 return $this->roles["superior"];
468 }

References loadRoles().

+ Here is the call graph for this function:

◆ getSuperiors()

ilObjOrgUnitTree::getSuperiors ( int  $ref_id,
bool  $recursive = false 
)
Parameters
int$ref_idthe reference id of the organisational unit.
bool$recursiveif true you get the ids of the subsequent orgunits superiors too
Returns
int[] array of user ids.

Definition at line 103 of file class.ilObjOrgUnitTree.php.

103 : array
104 {
105 if ($recursive === false) {
106 return $this->getAssignements(
107 $ref_id,
109 );
110 }
111
112 $arr_usr_ids = [];
113 foreach ($this->getAllChildren($ref_id) as $ref_id_child) {
114 $arr_usr_ids += $this->getAssignements(
115 $ref_id_child,
117 );
118 }
119 return $arr_usr_ids;
120 }

References ilOrgUnitPosition\CORE_POSITION_SUPERIOR, getAllChildren(), getAssignements(), and ilOrgUnitPosition\getCorePosition().

Referenced by ilOrgUnitExtension\getSuperiors(), and getSuperiorsOfUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuperiorsOfUser()

ilObjOrgUnitTree::getSuperiorsOfUser ( int  $user_id,
bool  $recursive = true 
)
Parameters
bool$recursiveif this is true subsequent orgunits of this users superior role get searched as well.
Returns
int[] returns an array of user_ids of the users which have an employee role in an orgunit of which this user's id has a superior role.

Definition at line 322 of file class.ilObjOrgUnitTree.php.

322 : array
323 {
324 //querry for all orgu where user_id is superior.
325 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
326 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
327 INNER JOIN object_data roles ON roles.title LIKE CONCAT('il_orgu_employee_',refr.ref_id) OR roles.title LIKE CONCAT('il_orgu_superior_',refr.ref_id)
328 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
329 WHERE orgu.type = 'orgu'";
330 $set = $this->db->query($q);
331 $orgu_ref_ids = array();
332 while ($res = $this->db->fetchAssoc($set)) {
333 $orgu_ref_ids[] = $res['ref_id'];
334 }
335 $superiors = array();
336 foreach ($orgu_ref_ids as $orgu_ref_id) {
337 $superiors = array_merge($superiors, $this->getSuperiors($orgu_ref_id, $recursive));
338 }
339
340 return $superiors;
341 }
getSuperiors(int $ref_id, bool $recursive=false)

References $res, and getSuperiors().

+ Here is the call graph for this function:

◆ getTitles()

ilObjOrgUnitTree::getTitles ( array  $org_refs)

Definition at line 441 of file class.ilObjOrgUnitTree.php.

441 : array
442 {
443 $names = array();
444 foreach ($org_refs as $org_unit) {
445 $names[$org_unit] = ilObject::_lookupTitle(ilObject::_lookupObjId($org_unit));
446 }
447
448 return $names;
449 }
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)

References ilObject\_lookupObjId(), and ilObject\_lookupTitle().

+ Here is the call graph for this function:

◆ loadArrayOfStaff()

ilObjOrgUnitTree::loadArrayOfStaff ( string  $title,
array  $ref_ids 
)
private
Parameters
string$title"employee" or "superior"
int[]$ref_idsarray of orgu object ref ids.
Returns
int[] user_ids

Definition at line 127 of file class.ilObjOrgUnitTree.php.

127 : array
128 {
129 $this->loadRoles($title);
130 $all_refs = $ref_ids;
131 //take away ref_ids that are already loaded.
132 foreach ($ref_ids as $id => $ref_id) {
133 if (isset($this->staff[$title][$ref_id])) {
134 unset($ref_ids[$id]);
135 } else {
136 $this->staff[$title][$ref_id] = array();
137 $ref_ids[$id] = $this->roles[$title][$ref_id];
138 }
139 }
140
141 //if there are still refs that need to be loaded, then do so.
142 if (count($ref_ids)) {
143 $q = "SELECT usr_id, rol_id FROM rbac_ua WHERE " . $this->db->in("rol_id", $ref_ids, false, "integer");
144 $set = $this->db->query($q);
145 while ($res = $this->db->fetchAssoc($set)) {
146 $orgu_ref = $this->role_to_orgu[$title][$res["rol_id"]];
147 $this->staff[$title][$orgu_ref][] = $res["usr_id"];
148 }
149 }
150
151 //collect * users.
152 $all_users = [];
153 foreach ($all_refs as $ref) {
154 $all_users = array_merge($all_users, $this->staff[$title][$ref]);
155 }
156 return $all_users;
157 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id, $ref_id, $res, and loadRoles().

+ Here is the call graph for this function:

◆ loadChildren()

ilObjOrgUnitTree::loadChildren ( int  $ref_id)
private

Definition at line 254 of file class.ilObjOrgUnitTree.php.

254 : void
255 {
256 if (!array_key_exists($ref_id, $this->tree_childs)) {
257 $children = [];
258 foreach ($this->tree->getChilds($ref_id) as $child) {
259 if ($child["type"] == "orgu") {
260 $children[] = $child["child"];
261 }
262 }
263 $this->tree_childs[$ref_id] = $children;
264 }
265 }

References $ref_id.

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ loadRoles()

ilObjOrgUnitTree::loadRoles ( string  $role)
private

Definition at line 470 of file class.ilObjOrgUnitTree.php.

471 {
472 if ($this->roles[$role] == null) {
473 $this->loadRolesQuery($role);
474 }
475 }

References loadRolesQuery().

Referenced by getEmployeeRoles(), getSuperiorRoles(), and loadArrayOfStaff().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadRolesQuery()

ilObjOrgUnitTree::loadRolesQuery ( string  $role)
private

Definition at line 482 of file class.ilObjOrgUnitTree.php.

482 : void
483 {
484 $this->roles[$role] = array();
485 $q = "SELECT obj_id, title FROM object_data WHERE type = 'role' AND title LIKE 'il_orgu_" . $role . "%'";
486 $set = $this->db->query($q);
487 while ($res = $this->db->fetchAssoc($set)) {
488 $orgu_ref = $this->getRefIdFromRoleTitle($res["title"]);
489 $this->roles[$role][$orgu_ref] = $res["obj_id"];
490 $this->role_to_orgu[$role][$res["obj_id"]] = $orgu_ref;
491 }
492 }
getRefIdFromRoleTitle(string $role_title)

References $res, and getRefIdFromRoleTitle().

Referenced by loadRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilObjOrgUnitTree::$db
private

Definition at line 40 of file class.ilObjOrgUnitTree.php.

◆ $ilUser

ilObjUser ilObjOrgUnitTree::$ilUser
private

Definition at line 41 of file class.ilObjOrgUnitTree.php.

◆ $instance

ilObjOrgUnitTree ilObjOrgUnitTree::$instance = null
staticprotected

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

◆ $parent

array ilObjOrgUnitTree::$parent = []
private

Definition at line 39 of file class.ilObjOrgUnitTree.php.

◆ $role_to_orgu

array ilObjOrgUnitTree::$role_to_orgu
private

Definition at line 33 of file class.ilObjOrgUnitTree.php.

◆ $roles

array ilObjOrgUnitTree::$roles
private

Definition at line 31 of file class.ilObjOrgUnitTree.php.

◆ $staff

ilObjOrgUnitTree::$staff
private

Definition at line 35 of file class.ilObjOrgUnitTree.php.

◆ $temporary_table_name

string ilObjOrgUnitTree::$temporary_table_name = null
staticprotected

Definition at line 28 of file class.ilObjOrgUnitTree.php.

Referenced by buildTempTableWithUsrAssignements(), and dropTempTable().

◆ $temporary_table_name_getOrgUnitOfUser

string ilObjOrgUnitTree::$temporary_table_name_getOrgUnitOfUser = null
staticprotected

Definition at line 27 of file class.ilObjOrgUnitTree.php.

◆ $tree

ilTree ilObjOrgUnitTree::$tree
private

Definition at line 42 of file class.ilObjOrgUnitTree.php.

◆ $tree_childs

array ilObjOrgUnitTree::$tree_childs = []
private

Definition at line 37 of file class.ilObjOrgUnitTree.php.


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