ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjOrgUnitTree Class Reference

Class ilObjOrgUnitTree Implements a singleton pattern for caching. More...

+ Collaboration diagram for ilObjOrgUnitTree:

Public Member Functions

 getEmployees ($ref_id, $recursive=false)
 
 getSuperiors ($ref_id, $recursive=false)
 
 getAllChildren ($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 ($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 ($level)
 
 getEmployeesUnderUser ($user_id, $recursive=true)
 
 getSuperiorsOfUser ($user_id, $recursive=true)
 
 getLevelXOfUser ($user_id, $level)
 for additional info see the other getLevelX method. More...
 
 getOrgUnitOfUser ($user_id, $ref_id=0)
 getOrgUnitOfUser More...
 
 buildTempTableWithUsrAssignements ($temporary_table_name='orgu_usr_assignements')
 Creates a temporary table with all orgu/user assignements. More...
 
 dropTempTable ($temporary_table_name)
 
 getTitles ($org_refs)
 
 getEmployeeRoles ()
 
 getSuperiorRoles ()
 
 flushCache ()
 
 getLevelXOfTreenode ($orgu_ref, $level)
 Specify eg. More...
 
 getParent ($orgu_ref)
 

Static Public Member Functions

static _getInstance ()
 

Static Protected Attributes

static $temporary_table_name = null
 

Private Member Functions

 __construct ()
 
 loadStaff ($title, $ref_id)
 
 loadStaffRecursive ($title, $ref_id)
 
 loadArrayOfStaff ($title, $ref_ids)
 
 getChildren ($ref_id)
 
 loadChildren ($ref_id)
 
 loadRoles ($role)
 
 loadRolesQuery ($role)
 
 getRefIdFromRoleTitle ($role_title)
 

Private Attributes

 $roles
 
 $role_to_orgu
 
 $staff
 
 $tree_childs
 
 $parent
 
 $db
 

Static Private Attributes

static $instance
 

Detailed Description

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 13 of file class.ilObjOrgUnitTree.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjOrgUnitTree::__construct ( )
private

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

49 {
50 global $DIC;
51 $ilDB = $DIC['ilDB'];
52 $tree = $DIC['tree'];
53 $this->db = $ilDB;
54 $this->tree = $tree;
55 $this->roles = array();
56 $this->staff = array();
57 }
global $ilDB
global $DIC

References $DIC, and $ilDB.

Member Function Documentation

◆ _getInstance()

static ilObjOrgUnitTree::_getInstance ( )
static

◆ buildTempTableWithUsrAssignements()

ilObjOrgUnitTree::buildTempTableWithUsrAssignements (   $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
Exceptions
ilException
Parameters
string$temporary_table_name
Returns
bool

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

422 {
423 if (self::$temporary_table_name == $temporary_table_name) {
424 return true;
425 }
426 if (self::$temporary_table_name === null) {
428 self::$temporary_table_name = $temporary_table_name;
429 } elseif ($temporary_table_name != self::$temporary_table_name) {
430 throw new ilException('there is already a temporary table for org-unit assignement: ' . self::$temporary_table_name);
431 }
432
433 $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . " AS (
434 SELECT DISTINCT object_reference.ref_id AS ref_id, rbac_ua.usr_id AS user_id, orgu_path_storage.path AS path
435 FROM rbac_ua
436 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
437 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
438 JOIN object_data ON object_data.obj_id = object_reference.obj_id
439 JOIN orgu_path_storage ON orgu_path_storage.ref_id = object_reference.ref_id
440 WHERE object_data.type = 'orgu' AND object_reference.deleted IS NULL
441 );";
442 $this->db->manipulate($q);
443 return true;
444 }
Base class for ILIAS Exception handling.
dropTempTable($temporary_table_name)

References $temporary_table_name, and dropTempTable().

+ Here is the call graph for this function:

◆ dropTempTable()

ilObjOrgUnitTree::dropTempTable (   $temporary_table_name)
Parameters
$temporary_table_name
Returns
bool

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

451 {
452 if (self::$temporary_table_name === null || $temporary_table_name != self::$temporary_table_name) {
453 return false;
454 }
455 $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
456 $this->db->manipulate($q);
457
458 self::$temporary_table_name = null;
459
460 return true;
461 }

References $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

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

508 {
509 $this->roles = null;
510 }

◆ getAllChildren()

ilObjOrgUnitTree::getAllChildren (   $ref_id)
Parameters
$ref_id
Returns
array

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

149 {
150 $open = array( $ref_id );
151 $closed = array();
152 while (count($open)) {
153 $ref = array_pop($open);
154 $closed[] = $ref;
155 foreach ($this->getChildren($ref) as $child) {
156 if (!in_array($child, $open) && !in_array($child, $closed)) {
157 $open[] = $child;
158 }
159 }
160 }
161
162 return $closed;
163 }
$ref_id
Definition: sahs_server.php:39

References $ref_id, and getChildren().

Referenced by getOrgUnitOfUser(), and loadStaffRecursive().

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

◆ getAllOrgunitsOnLevelX()

ilObjOrgUnitTree::getAllOrgunitsOnLevelX (   $level)
Parameters
$level
Returns
array

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

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

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

+ Here is the call graph for this function:

◆ getChildren()

ilObjOrgUnitTree::getChildren (   $ref_id)
private
Parameters
$ref_id
Returns
int[]

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

245 {
246 $this->loadChildren($ref_id);
247
248 return $this->tree_childs[$ref_id];
249 }

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 481 of file class.ilObjOrgUnitTree.php.

481 {
482 $this->loadRoles("employee");
483
484 return $this->roles["employee"];
485 }

References loadRoles().

+ Here is the call graph for this function:

◆ getEmployees()

ilObjOrgUnitTree::getEmployees (   $ref_id,
  $recursive = false 
)
Parameters
$ref_idint the reference id of the organisational unit.
$recursivebool if true you get the ids of the subsequent orgunits employees too
Returns
int[] array of user ids.

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

77 {
78 return array_unique(($recursive ? $this->loadStaffRecursive("employee", $ref_id) : $this->loadStaff("employee", $ref_id)));
79 }
loadStaff($title, $ref_id)
loadStaffRecursive($title, $ref_id)

References $ref_id, loadStaff(), and loadStaffRecursive().

Referenced by ilOrgUnitExtension\getEmployees(), and getEmployeesUnderUser().

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

◆ getEmployeesUnderUser()

ilObjOrgUnitTree::getEmployeesUnderUser (   $user_id,
  $recursive = true 
)
Parameters
$user_idint
$recursivebool if 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 294 of file class.ilObjOrgUnitTree.php.

294 {
295 //querry for all orgu where user_id is superior.
296 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
297 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
298 INNER JOIN object_data roles ON roles.title LIKE CONCAT('il_orgu_superior_',refr.ref_id)
299 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
300 WHERE orgu.type = 'orgu'";
301 $set = $this->db->query($q);
302 $orgu_ref_ids = array();
303 while ($res = $this->db->fetchAssoc($set)) {
304 $orgu_ref_ids[] = $res['ref_id'];
305 }
306 $employees = array();
307 foreach ($orgu_ref_ids as $orgu_ref_id) {
308 $employees = array_merge($employees, $this->getEmployees($orgu_ref_id, $recursive));
309 }
310
311 return $employees;
312 }
getEmployees($ref_id, $recursive=false)

References $res, and getEmployees().

+ Here is the call graph for this function:

◆ getLevelXOfTreenode()

ilObjOrgUnitTree::getLevelXOfTreenode (   $orgu_ref,
  $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;

Parameters
$orgu_ref
$level
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).
Returns
int|bool ref_id of the orgu or false if not found.

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

557 {
558 $line = array( $orgu_ref );
559 $current_ref = $orgu_ref;
560 while ($current_ref != ilObjOrgUnit::getRootOrgRefId()) {
561 $current_ref = $this->getParent($current_ref);
562 if ($current_ref) {
563 $line[] = $current_ref;
564 } else {
565 break;
566 }
567 if (count($line) > 100) {
568 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");
569 }
570 }
571 $line = array_reverse($line);
572 if (count($line) > $level) {
573 return $line[$level];
574 } else {
575 throw new Exception("you want to fetch level " . $level . " but the line to the length of the line is only " . count($line)
576 . ". The line of the given org unit is: " . print_r($line, true));
577 }
578 }

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 (   $user_id,
  $level 
)

for additional info see the other getLevelX method.

Parameters
$user_id
$level
Returns
int[]

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

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($orgu_ref, $level)
Specify eg.

References $res, and getLevelXOfTreenode().

+ Here is the call graph for this function:

◆ getOrgUnitOfUser()

ilObjOrgUnitTree::getOrgUnitOfUser (   $user_id,
  $ref_id = 0 
)

getOrgUnitOfUser

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

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

381 {
382 $q = "SELECT object_reference.ref_id FROM rbac_ua
383 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
384 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
385 JOIN object_data ON object_data.obj_id = object_reference.obj_id
386 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer') . " AND object_data.type = 'orgu'";
387
388 $set = $this->db->query($q);
389 $orgu_ref_ids = array();
390 while ($res = $this->db->fetchAssoc($set)) {
391 $orgu_ref_ids[] = $res['ref_id'];
392 }
393 $orgu_ref_ids = array_unique($orgu_ref_ids);
394 if ($ref_id) {
395 $childernOrgIds = $this->getAllChildren($ref_id);
396 foreach ($orgu_ref_ids as $k => $refId) {
397 if (!in_array($refId, $childernOrgIds)) {
398 unset($orgu_ref_ids[$k]);
399 }
400 }
401 }
402
403 return $orgu_ref_ids;
404 }

References $ref_id, $res, and getAllChildren().

+ 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".

Parameters
$operationstring
Returns
int[] ids of the org units.

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

172 {
173 global $DIC;
174 $ilUser = $DIC['ilUser'];
175 /*$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
176 INNER JOIN rbac_operations ON rbac_operations.operation = ".$this->db->quote($operation, "text")."
177 INNER JOIN rbac_ua ON rbac_ua.usr_id = ".$this->db->quote($ilUser->getId(), "integer")."
178 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
179 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
180 INNER JOIN tree ON tree.child = rbac_fa.parent
181 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
182 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";*/
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 object_reference ON object_reference.ref_id = rbac_pa.ref_id
189 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
190
191 $set = $this->db->query($q);
192 $orgus = array();
193 while ($res = $this->db->fetchAssoc($set)) {
194 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
195 $perm_check = unserialize($res['ops_id']);
196 if (!in_array($res["op_id"], $perm_check)) {
197 continue;
198 }
199
200 $orgus[] = $res["ref_id"];
201 }
202
203 return $orgus;
204 }
$ilUser
Definition: imgupload.php:18

References $DIC, $ilUser, and $res.

◆ getOrgusWhereUserHasPermissionForOperationId()

ilObjOrgUnitTree::getOrgusWhereUserHasPermissionForOperationId (   $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).

Parameters
$operation_id
Returns
int[] ids of the org units.

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

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

References $DIC, $ilUser, and $res.

◆ getParent()

ilObjOrgUnitTree::getParent (   $orgu_ref)
Parameters
$orgu_refint
Returns
int

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

585 {
586 if (!$this->parent[$orgu_ref]) {
587 $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
588 }
589
590 return $this->parent[$orgu_ref];
591 }

Referenced by getLevelXOfTreenode().

+ Here is the caller graph for this function:

◆ getRefIdFromRoleTitle()

ilObjOrgUnitTree::getRefIdFromRoleTitle (   $role_title)
private
Parameters
$role_title
Returns
int

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

532 {
533 $array = explode("_", $role_title);
534
535 return $array[count($array) - 1];
536 }

Referenced by loadRolesQuery().

+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
\int[]

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

491 {
492 $this->loadRoles("superior");
493
494 return $this->roles["superior"];
495 }

References loadRoles().

+ Here is the call graph for this function:

◆ getSuperiors()

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

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

87 {
88 return array_unique(($recursive ? $this->loadStaffRecursive("superior", $ref_id) : $this->loadStaff("superior", $ref_id)));
89 }

References $ref_id, loadStaff(), and loadStaffRecursive().

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 (   $user_id,
  $recursive = true 
)
Parameters
$user_idint
$recursivebool if 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 320 of file class.ilObjOrgUnitTree.php.

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

References $res, and getSuperiors().

+ Here is the call graph for this function:

◆ getTitles()

ilObjOrgUnitTree::getTitles (   $org_refs)
Parameters
$org_refs
Returns
array

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

468 {
469 $names = array();
470 foreach ($org_refs as $org_unit) {
472 }
473
474 return $names;
475 }
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title

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

+ Here is the call graph for this function:

◆ loadArrayOfStaff()

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

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

112 {
113 $this->loadRoles($title);
114 $all_refs = $ref_ids;
115 //take away ref_ids that are already loaded.
116 foreach ($ref_ids as $id => $ref_id) {
117 if (isset($this->staff[$title][$ref_id])) {
118 unset($ref_ids[$id]);
119 } else {
120 $this->staff[$title][$ref_id] = array();
121 $ref_ids[$id] = $this->roles[$title][$ref_id];
122 }
123 }
124
125 //if there are still refs that need to be loaded, then do so.
126 if (count($ref_ids)) {
127 $q = "SELECT usr_id, rol_id FROM rbac_ua WHERE " . $this->db->in("rol_id", $ref_ids, false, "integer");
128 $set = $this->db->query($q);
129 while ($res = $this->db->fetchAssoc($set)) {
130 $orgu_ref = $this->role_to_orgu[$title][$res["rol_id"]];
131 $this->staff[$title][$orgu_ref][] = $res["usr_id"];
132 }
133 }
134
135 //collect * users.
136 $all_users = array();
137 foreach ($all_refs as $ref) {
138 $all_users = array_merge($all_users, $this->staff[$title][$ref]);
139 }
140
141 return $all_users;
142 }

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

Referenced by loadStaff(), and loadStaffRecursive().

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

◆ loadChildren()

ilObjOrgUnitTree::loadChildren (   $ref_id)
private
Parameters
$ref_id

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

255 {
256 if (!$this->tree_childs[$ref_id]) {
257 $children = array();
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 (   $role)
private
Parameters
$role

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

501 {
502 if ($this->roles[$role] == null) {
503 $this->loadRolesQuery($role);
504 }
505 }

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 (   $role)
private
Parameters
$role

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

516 {
517 $this->roles[$role] = array();
518 $q = "SELECT obj_id, title FROM object_data WHERE type = 'role' AND title LIKE 'il_orgu_" . $role . "%'";
519 $set = $this->db->query($q);
520 while ($res = $this->db->fetchAssoc($set)) {
521 $orgu_ref = $this->getRefIdFromRoleTitle($res["title"]);
522 $this->roles[$role][$orgu_ref] = $res["obj_id"];
523 $this->role_to_orgu[$role][$res["obj_id"]] = $orgu_ref;
524 }
525 }
getRefIdFromRoleTitle($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:

◆ loadStaff()

ilObjOrgUnitTree::loadStaff (   $title,
  $ref_id 
)
private
Parameters
$titlestring "employee" or "superior"
$ref_idint ref id of org unit.
Returns
int[] array of user_obj ids

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

97 {
98 return $this->loadArrayOfStaff($title, array( $ref_id ));
99 }
loadArrayOfStaff($title, $ref_ids)

References $ref_id, $title, and loadArrayOfStaff().

Referenced by getEmployees(), and getSuperiors().

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

◆ loadStaffRecursive()

ilObjOrgUnitTree::loadStaffRecursive (   $title,
  $ref_id 
)
private

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

102 {
103 return $this->loadArrayOfStaff($title, $this->getAllChildren($ref_id));
104 }

References $ref_id, $title, getAllChildren(), and loadArrayOfStaff().

Referenced by getEmployees(), and getSuperiors().

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

Field Documentation

◆ $db

ilObjOrgUnitTree::$db
private

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

◆ $instance

ilObjOrgUnitTree::$instance
staticprivate

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

Referenced by _getInstance().

◆ $parent

ilObjOrgUnitTree::$parent
private

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

◆ $role_to_orgu

ilObjOrgUnitTree::$role_to_orgu
private

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

◆ $roles

ilObjOrgUnitTree::$roles
private

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

◆ $staff

ilObjOrgUnitTree::$staff
private

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

◆ $temporary_table_name

ilObjOrgUnitTree::$temporary_table_name = null
staticprotected

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

Referenced by buildTempTableWithUsrAssignements(), and dropTempTable().

◆ $tree_childs

ilObjOrgUnitTree::$tree_childs
private

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


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