ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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)
 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_namgetOrgUnitOfUsere = null
 
static $temporary_table_name
 

Private Member Functions

 __construct ()
 
 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 53 of file class.ilObjOrgUnitTree.php.

54 {
55 global $DIC;
56 $ilDB = $DIC['ilDB'];
57 $tree = $DIC['tree'];
58 $this->db = $ilDB;
59 $this->tree = $tree;
60 $this->roles = array();
61 $this->staff = array();
62 }
global $ilDB
$DIC
Definition: xapitoken.php:46

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

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

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

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

References $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

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

572 {
573 $this->roles = null;
574 }

◆ getAllChildren()

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

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

189 {
190 $open = array($ref_id);
191 $closed = array();
192 while (count($open)) {
193 $ref = array_pop($open);
194 $closed[] = $ref;
195 foreach ($this->getChildren($ref) as $child) {
196 if (!in_array($child, $open) && !in_array($child, $closed)) {
197 $open[] = $child;
198 }
199 }
200 }
201
202 return $closed;
203 }

References 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 (   $level)
Parameters
$level
Returns
array

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

322 {
323 $levels = array(0 => array(ilObjOrgUnit::getRootOrgRefId()));
324 $current_level = 0;
325 while ($current_level < $level) {
326 $new_level = array();
327 foreach ($levels[$current_level] as $orgu_ref) {
328 $new_level = array_merge($this->getChildren($orgu_ref), $new_level);
329 }
330 $new_level = array_unique($new_level);
331 $levels[$current_level + 1] = $new_level;
332 $current_level++;
333 }
334
335 return $levels[$level];
336 }
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 108 of file class.ilObjOrgUnitTree.php.

109 {
111 'orgu_id' => $ref_id,
112 'position_id' => $ilOrgUnitPosition->getId(),
113 ))->getArray('id', 'user_id');
114 }
static where($where, $operator=null)

References 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 (   $ref_id)
private
Parameters
$ref_id
Returns
int[]

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

292 {
293 $this->loadChildren($ref_id);
294
295 return $this->tree_childs[$ref_id];
296 }

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

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

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

85 {
86 $arr_usr_ids = [];
87
88 switch ($recursive) {
89 case false:
91 break;
92 case true:
94 $arr_usr_ids = $assignment_query->getUserIdsOfOrgUnitsInPosition($this->getAllChildren($ref_id),ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
95 break;
96 }
97
98 return $arr_usr_ids;
99 }
getAssignements($ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
static getCorePosition($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 (   $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 347 of file class.ilObjOrgUnitTree.php.

348 {
349 $employees = [];
351
352 $orgu_ref_ids = $assignment_query->getOrgUnitIdsOfUsersPosition(
354 $user_id);
355
356 switch($recursive) {
357 case true:
358 $orgu_ref_id_with_children = [];
359 foreach($orgu_ref_ids as $orgu_ref_id ) {
360 $orgu_ref_id_with_children = array_merge($orgu_ref_ids, $this->getAllChildren($orgu_ref_id));
361 }
362
363 return $assignment_query->getUserIdsOfOrgUnitsInPosition($orgu_ref_id_with_children,ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
364 break;
365 default:
366 return $assignment_query->getUserIdsOfOrgUnitsInPosition($orgu_ref_ids,ilOrgUnitPosition::CORE_POSITION_EMPLOYEE);
367 break;
368 }
369
370 return [];
371 }

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

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

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

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

413 {
414 $q = "SELECT object_reference.ref_id FROM rbac_ua
415 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
416 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
417 JOIN object_data ON object_data.obj_id = object_reference.obj_id
418 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer') . " AND object_data.type = 'orgu';";
419
420 $set = $this->db->query($q);
421 $orgu_ref_ids = array();
422 while ($res = $this->db->fetchAssoc($set)) {
423 $orgu_ref_ids[] = $res['ref_id'];
424 }
425 $orgus_on_level_x = array();
426 foreach ($orgu_ref_ids as $orgu_ref_id) {
427 try {
428 $orgus_on_level_x[] = $this->getLevelXOfTreenode($orgu_ref_id, $level);
429 } catch (Exception $e) {
430 // this means the user is assigned to a orgu above the given level. just dont add it to the list.
431 }
432 }
433
434 return array_unique($orgus_on_level_x);
435 }
getLevelXOfTreenode($orgu_ref, $level)
Specify eg.
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ getOrgUnitOfUser()

ilObjOrgUnitTree::getOrgUnitOfUser (   $user_id)

getOrgUnitOfUser

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

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

447 {
448 $orgu_ref_ids = [];
450
451 $orgus = $orgu_query->getAssignmentsOfUserId($user_id);
452 foreach($orgus as $orgu) {
453 $orgu_ref_ids[] = $orgu->getOrguId();
454 }
455 return $orgu_ref_ids;
456 }

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

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

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

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

259 {
260 global $DIC;
261 $ilUser = $DIC['ilUser'];
262 $q = "SELECT object_data.obj_id, object_data.title, object_data.type, rbac_pa.ops_id FROM object_data
263 INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($ilUser->getId(), "integer") . "
264 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") . ", '%')
265 INNER JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
266 INNER JOIN tree ON tree.child = rbac_fa.parent
267 INNER JOIN object_reference ON object_reference.ref_id = tree.parent
268 WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
269
270 $set = $this->db->query($q);
271 $orgus = array();
272 while ($res = $this->db->fetchAssoc($set)) {
273 //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
274 $perm_check = unserialize($res['ops_id']);
275 if (!in_array($res["ops_id"], $perm_check)) {
276 continue;
277 }
278
279 $orgus[] = $res["obj_id"];
280 }
281
282 return $orgus;
283 }

References $DIC, $ilUser, and $res.

◆ getParent()

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

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

657 {
658 if (!$this->parent[$orgu_ref]) {
659 $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
660 }
661
662 return $this->parent[$orgu_ref];
663 }

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

+ Here is the caller graph for this function:

◆ getRefIdFromRoleTitle()

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

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

599 {
600 $array = explode("_", $role_title);
601
602 return $array[count($array) - 1];
603 }

Referenced by loadRolesQuery().

+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
\int[]

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

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

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

124 {
125 $arr_usr_ids = [];
126
127 switch ($recursive) {
128 case false:
130 break;
131 case true:
132 foreach ($this->getAllChildren($ref_id) as $ref_id) {
133 $arr_usr_ids = $arr_usr_ids
135 }
136 break;
137 }
138
139 return $arr_usr_ids;
140 }

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 (   $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 382 of file class.ilObjOrgUnitTree.php.

383 {
384 //querry for all orgu where user_id is superior.
385 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
386 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
387 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)
388 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
389 WHERE orgu.type = 'orgu'";
390 $set = $this->db->query($q);
391 $orgu_ref_ids = array();
392 while ($res = $this->db->fetchAssoc($set)) {
393 $orgu_ref_ids[] = $res['ref_id'];
394 }
395 $superiors = array();
396 foreach ($orgu_ref_ids as $orgu_ref_id) {
397 $superiors = array_merge($superiors, $this->getSuperiors($orgu_ref_id, $recursive));
398 }
399
400 return $superiors;
401 }
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 527 of file class.ilObjOrgUnitTree.php.

528 {
529 $names = array();
530 foreach ($org_refs as $org_unit) {
531 $names[$org_unit] = ilObject::_lookupTitle(ilObject::_lookupObjId($org_unit));
532 }
533
534 return $names;
535 }
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title

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

150 {
151 $this->loadRoles($title);
152 $all_refs = $ref_ids;
153 //take away ref_ids that are already loaded.
154 foreach ($ref_ids as $id => $ref_id) {
155 if (isset($this->staff[$title][$ref_id])) {
156 unset($ref_ids[$id]);
157 } else {
158 $this->staff[$title][$ref_id] = array();
159 $ref_ids[$id] = $this->roles[$title][$ref_id];
160 }
161 }
162
163 //if there are still refs that need to be loaded, then do so.
164 if (count($ref_ids)) {
165 $q = "SELECT usr_id, rol_id FROM rbac_ua WHERE " . $this->db->in("rol_id", $ref_ids, false, "integer");
166 $set = $this->db->query($q);
167 while ($res = $this->db->fetchAssoc($set)) {
168 $orgu_ref = $this->role_to_orgu[$title][$res["rol_id"]];
169 $this->staff[$title][$orgu_ref][] = $res["usr_id"];
170 }
171 }
172
173 //collect * users.
174 $all_users = array();
175 foreach ($all_refs as $ref) {
176 $all_users = array_merge($all_users, $this->staff[$title][$ref]);
177 }
178
179 return $all_users;
180 }

References $res, and loadRoles().

+ Here is the call graph for this function:

◆ loadChildren()

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

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

303 {
304 if (!$this->tree_childs[$ref_id]) {
305 $children = array();
306 foreach ($this->tree->getChilds($ref_id) as $child) {
307 if ($child["type"] == "orgu") {
308 $children[] = $child["child"];
309 }
310 }
311 $this->tree_childs[$ref_id] = $children;
312 };
313 }

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ loadRoles()

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

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

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

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

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

Field Documentation

◆ $db

ilObjOrgUnitTree::$db
private

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

◆ $instance

ilObjOrgUnitTree::$instance
staticprivate

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

Referenced by _getInstance().

◆ $parent

ilObjOrgUnitTree::$parent
private

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

◆ $role_to_orgu

ilObjOrgUnitTree::$role_to_orgu
private

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

◆ $roles

ilObjOrgUnitTree::$roles
private

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

◆ $staff

ilObjOrgUnitTree::$staff
private

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

◆ $temporary_table_name

ilObjOrgUnitTree::$temporary_table_name
staticprotected

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

Referenced by buildTempTableWithUsrAssignements(), and dropTempTable().

◆ $temporary_table_namgetOrgUnitOfUsere

ilObjOrgUnitTree::$temporary_table_namgetOrgUnitOfUsere = null
staticprotected

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

◆ $tree_childs

ilObjOrgUnitTree::$tree_childs
private

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


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