ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjOrgUnitTree Class Reference

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

+ Collaboration diagram for ilObjOrgUnitTree:

Public Member Functions

 getEmployees ($ref_id, $recursive=false)
 
 getAssignements ($ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
 
 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 12 of file class.ilObjOrgUnitTree.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjOrgUnitTree::__construct ( )
private

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

50 {
51 global $DIC;
52 $ilDB = $DIC['ilDB'];
53 $tree = $DIC['tree'];
54 $this->db = $ilDB;
55 $this->tree = $tree;
56 $this->roles = array();
57 $this->staff = array();
58 }
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, and $ilDB.

Member Function Documentation

◆ _getInstance()

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

478 {
479 if (self::$temporary_table_name == $temporary_table_name) {
480 return true;
481 }
482 if (self::$temporary_table_name === null) {
484 self::$temporary_table_name = $temporary_table_name;
485 } elseif ($temporary_table_name != self::$temporary_table_name) {
486 throw new ilException('there is already a temporary table for org-unit assignement: '
487 . self::$temporary_table_name);
488 }
489
490 $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . " AS (
491 SELECT DISTINCT object_reference.ref_id AS ref_id, il_orgu_ua.user_id AS user_id, orgu_path_storage.path AS path
492 FROM il_orgu_ua
493 JOIN object_reference ON object_reference.ref_id = il_orgu_ua.orgu_id
494 JOIN object_data ON object_data.obj_id = object_reference.obj_id
495 JOIN orgu_path_storage ON orgu_path_storage.ref_id = object_reference.ref_id
496 WHERE object_data.type = 'orgu' AND object_reference.deleted IS NULL
497 );";
498 $this->db->manipulate($q);
499
500 return true;
501 }
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 509 of file class.ilObjOrgUnitTree.php.

510 {
511 if (self::$temporary_table_name === null
512 || $temporary_table_name != self::$temporary_table_name) {
513 return false;
514 }
515 $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
516 $this->db->manipulate($q);
517
518 self::$temporary_table_name = null;
519
520 return true;
521 }

References $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

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

574 {
575 $this->roles = null;
576 }

◆ getAllChildren()

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

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

178 {
179 $open = array( $ref_id );
180 $closed = array();
181 while (count($open)) {
182 $ref = array_pop($open);
183 $closed[] = $ref;
184 foreach ($this->getChildren($ref) as $child) {
185 if (!in_array($child, $open) && !in_array($child, $closed)) {
186 $open[] = $child;
187 }
188 }
189 }
190
191 return $closed;
192 }

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

313 {
314 $levels = array( 0 => array( ilObjOrgUnit::getRootOrgRefId() ) );
315 $current_level = 0;
316 while ($current_level < $level) {
317 $new_level = array();
318 foreach ($levels[$current_level] as $orgu_ref) {
319 $new_level = array_merge($this->getChildren($orgu_ref), $new_level);
320 }
321 $new_level = array_unique($new_level);
322 $levels[$current_level + 1] = $new_level;
323 $current_level++;
324 }
325
326 return $levels[$level];
327 }
static getRootOrgRefId()

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

+ Here is the call graph for this function:

◆ getAssignements()

ilObjOrgUnitTree::getAssignements (   $ref_id,
ilOrgUnitPosition  $ilOrgUnitPosition 
)
Parameters
int$ref_id
\ilOrgUnitPosition$ilOrgUnitPosition
Returns
array

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

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

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

+ Here is the call graph for this function:

◆ getChildren()

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

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

283 {
284 $this->loadChildren($ref_id);
285
286 return $this->tree_childs[$ref_id];
287 }

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

544 {
545 $this->loadRoles("employee");
546
547 return $this->roles["employee"];
548 }

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

81 {
82 // return $this->getAssignements($ref_id, new ilOrgUnitPosition(1));
83 return array_unique(($recursive ? $this->loadStaffRecursive("employee", $ref_id) : $this->loadStaff("employee", $ref_id)));
84 }
loadStaff($title, $ref_id)
loadStaffRecursive($title, $ref_id)

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

339 {
340 //querry for all orgu where user_id is superior.
341 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
342 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
343 INNER JOIN object_data roles ON roles.title LIKE CONCAT('il_orgu_superior_',refr.ref_id)
344 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
345 WHERE orgu.type = 'orgu'";
346 $set = $this->db->query($q);
347 $orgu_ref_ids = array();
348 while ($res = $this->db->fetchAssoc($set)) {
349 $orgu_ref_ids[] = $res['ref_id'];
350 }
351 $employees = array();
352 foreach ($orgu_ref_ids as $orgu_ref_id) {
353 $employees = array_merge($employees, $this->getEmployees($orgu_ref_id, $recursive));
354 }
355
356 return $employees;
357 }
getEmployees($ref_id, $recursive=false)
foreach($_POST as $key=> $value) $res

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

630 {
631 $line = array( $orgu_ref );
632 $current_ref = $orgu_ref;
633 while ($current_ref != ilObjOrgUnit::getRootOrgRefId()) {
634 $current_ref = $this->getParent($current_ref);
635 if ($current_ref) {
636 $line[] = $current_ref;
637 } else {
638 break;
639 }
640 if (count($line) > 100) {
641 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");
642 }
643 }
644 $line = array_reverse($line);
645 if (count($line) > $level) {
646 return $line[$level];
647 } else {
648 throw new Exception("you want to fetch level " . $level
649 . " but the line to the length of the line is only " . count($line)
650 . ". The line of the given org unit is: " . print_r($line, true));
651 }
652 }

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

399 {
400 $q = "SELECT object_reference.ref_id FROM rbac_ua
401 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
402 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
403 JOIN object_data ON object_data.obj_id = object_reference.obj_id
404 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer')
405 . " AND object_data.type = 'orgu';";
406
407 $set = $this->db->query($q);
408 $orgu_ref_ids = array();
409 while ($res = $this->db->fetchAssoc($set)) {
410 $orgu_ref_ids[] = $res['ref_id'];
411 }
412 $orgus_on_level_x = array();
413 foreach ($orgu_ref_ids as $orgu_ref_id) {
414 try {
415 $orgus_on_level_x[] = $this->getLevelXOfTreenode($orgu_ref_id, $level);
416 } catch (Exception $e) {
417 // this means the user is assigned to a orgu above the given level. just dont add it to the list.
418 }
419 }
420
421 return array_unique($orgus_on_level_x);
422 }
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 433 of file class.ilObjOrgUnitTree.php.

434 {
435 $q = "SELECT object_reference.ref_id 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 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer')
440 . " AND object_data.type = 'orgu'";
441
442 $set = $this->db->query($q);
443 $orgu_ref_ids = array();
444 while ($res = $this->db->fetchAssoc($set)) {
445 $orgu_ref_ids[] = $res['ref_id'];
446 }
447 $orgu_ref_ids = array_unique($orgu_ref_ids);
448 if ($ref_id) {
449 $childernOrgIds = $this->getAllChildren($ref_id);
450 foreach ($orgu_ref_ids as $k => $refId) {
451 if (!in_array($refId, $childernOrgIds)) {
452 unset($orgu_ref_ids[$k]);
453 }
454 }
455 }
456
457 return $orgu_ref_ids;
458 }

References $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 203 of file class.ilObjOrgUnitTree.php.

204 {
205 global $DIC;
206 $ilUser = $DIC['ilUser'];
207 /*$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
208 INNER JOIN rbac_operations ON rbac_operations.operation = ".$this->db->quote($operation, "text")."
209 INNER JOIN rbac_ua ON rbac_ua.usr_id = ".$this->db->quote($ilUser->getId(), "integer")."
210 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
211 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
212 INNER JOIN tree ON tree.child = rbac_fa.parent
213 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
214 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";*/
215
216 $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
217 INNER JOIN rbac_operations ON rbac_operations.operation = "
218 . $this->db->quote($operation, "text") . "
219 INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($ilUser->getId(), "integer") . "
220 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
221 INNER JOIN object_reference ON object_reference.ref_id = rbac_pa.ref_id
222 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
223
224 $set = $this->db->query($q);
225 $orgus = array();
226 while ($res = $this->db->fetchAssoc($set)) {
227 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
228 $perm_check = unserialize($res['ops_id']);
229 if (!in_array($res["op_id"], $perm_check)) {
230 continue;
231 }
232
233 $orgus[] = $res["ref_id"];
234 }
235
236 return $orgus;
237 }
$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 248 of file class.ilObjOrgUnitTree.php.

249 {
250 global $DIC;
251 $ilUser = $DIC['ilUser'];
252 $q = "SELECT object_data.obj_id, object_data.title, object_data.type, rbac_pa.ops_id FROM object_data
253 INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($ilUser->getId(), "integer") . "
254 INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', "
255 . $this->db->quote($operation_id, "integer") . ", '%')
256 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
257 INNER JOIN tree ON tree.child = rbac_fa.parent
258 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
259 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
260
261 $set = $this->db->query($q);
262 $orgus = array();
263 while ($res = $this->db->fetchAssoc($set)) {
264 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
265 $perm_check = unserialize($res['ops_id']);
266 if (!in_array($res["ops_id"], $perm_check)) {
267 continue;
268 }
269
270 $orgus[] = $res["obj_id"];
271 }
272
273 return $orgus;
274 }

References $DIC, $ilUser, and $res.

◆ getParent()

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

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

661 {
662 if (!$this->parent[$orgu_ref]) {
663 $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
664 }
665
666 return $this->parent[$orgu_ref];
667 }

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

602 {
603 $array = explode("_", $role_title);
604
605 return $array[count($array) - 1];
606 }

Referenced by loadRolesQuery().

+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
\int[]

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

555 {
556 $this->loadRoles("superior");
557
558 return $this->roles["superior"];
559 }

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

108 {
109 return array_unique(($recursive ? $this->loadStaffRecursive("superior", $ref_id) : $this->loadStaff("superior", $ref_id)));
110 }

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

369 {
370 //querry for all orgu where user_id is superior.
371 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
372 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
373 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)
374 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
375 WHERE orgu.type = 'orgu'";
376 $set = $this->db->query($q);
377 $orgu_ref_ids = array();
378 while ($res = $this->db->fetchAssoc($set)) {
379 $orgu_ref_ids[] = $res['ref_id'];
380 }
381 $superiors = array();
382 foreach ($orgu_ref_ids as $orgu_ref_id) {
383 $superiors = array_merge($superiors, $this->getSuperiors($orgu_ref_id, $recursive));
384 }
385
386 return $superiors;
387 }
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 529 of file class.ilObjOrgUnitTree.php.

530 {
531 $names = array();
532 foreach ($org_refs as $org_unit) {
534 }
535
536 return $names;
537 }
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 137 of file class.ilObjOrgUnitTree.php.

138 {
139 $this->loadRoles($title);
140 $all_refs = $ref_ids;
141 //take away ref_ids that are already loaded.
142 foreach ($ref_ids as $id => $ref_id) {
143 if (isset($this->staff[$title][$ref_id])) {
144 unset($ref_ids[$id]);
145 } else {
146 $this->staff[$title][$ref_id] = array();
147 $ref_ids[$id] = $this->roles[$title][$ref_id];
148 }
149 }
150
151 //if there are still refs that need to be loaded, then do so.
152 if (count($ref_ids)) {
153 $q = "SELECT usr_id, rol_id FROM rbac_ua WHERE "
154 . $this->db->in("rol_id", $ref_ids, false, "integer");
155 $set = $this->db->query($q);
156 while ($res = $this->db->fetchAssoc($set)) {
157 $orgu_ref = $this->role_to_orgu[$title][$res["rol_id"]];
158 $this->staff[$title][$orgu_ref][] = $res["usr_id"];
159 }
160 }
161
162 //collect * users.
163 $all_users = array();
164 foreach ($all_refs as $ref) {
165 $all_users = array_merge($all_users, $this->staff[$title][$ref]);
166 }
167
168 return $all_users;
169 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $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 293 of file class.ilObjOrgUnitTree.php.

294 {
295 if (!$this->tree_childs[$ref_id]) {
296 $children = array();
297 foreach ($this->tree->getChilds($ref_id) as $child) {
298 if ($child["type"] == "orgu") {
299 $children[] = $child["child"];
300 }
301 }
302 $this->tree_childs[$ref_id] = $children;
303 };
304 }

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ loadRoles()

ilObjOrgUnitTree::loadRoles (   $role)
private
Parameters
$role

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

566 {
567 if ($this->roles[$role] == null) {
568 $this->loadRolesQuery($role);
569 }
570 }

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

583 {
584 $this->roles[$role] = array();
585 $q = "SELECT obj_id, title FROM object_data WHERE type = 'role' AND title LIKE 'il_orgu_"
586 . $role . "%'";
587 $set = $this->db->query($q);
588 while ($res = $this->db->fetchAssoc($set)) {
589 $orgu_ref = $this->getRefIdFromRoleTitle($res["title"]);
590 $this->roles[$role][$orgu_ref] = $res["obj_id"];
591 $this->role_to_orgu[$role][$res["obj_id"]] = $orgu_ref;
592 }
593 }
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 119 of file class.ilObjOrgUnitTree.php.

120 {
121 return $this->loadArrayOfStaff($title, array( $ref_id ));
122 }
loadArrayOfStaff($title, $ref_ids)

References $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 125 of file class.ilObjOrgUnitTree.php.

126 {
127 return $this->loadArrayOfStaff($title, $this->getAllChildren($ref_id));
128 }

References $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: