ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

 getAssignements (int $ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
 
 getAssignedUsers (array $orgu_ids, int $position_id)
 
 getEmployees (int $ref_id, bool $recursive=false)
 
 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 ()
 

Protected Member Functions

 getPositionRepo ()
 
 getAssignmentRepo ()
 

Protected Attributes

ilOrgUnitPositionDBRepository $positionRepo
 
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
 

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

47 {
48 global $DIC;
49 $this->db = $DIC->database();
50 $this->tree = $DIC->repositoryTree();
51 $this->roles = array();
52 $this->staff = array();
53 $this->ilUser = $DIC->user();
54 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ _getInstance()

static ilObjOrgUnitTree::_getInstance ( )
static

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

57 {
58 if (static::$instance === null) {
59 static::$instance = new self();
60 }
61
62 return static::$instance;
63 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by ilLikeUserOrgUnitSearch\__construct(), ilOrgUnitExtension\__construct(), ilObjOrgUnitAccess\_checkAccessToUserLearningProgress(), ilOrgUnitUserAssignmentGUI\assignmentsRecursive(), ilMStListCoursesTableGUI\fillRow(), ilMStShowUserCoursesTableGUI\fillRow(), ilOrgUnitUserAssignmentDBRepository\getOrgUnitsByUserAndPosition(), ilStudyProgrammeMembershipSourceReaderFactory\getReaderFor(), ilCourseParticipantsTableGUI\parse(), and ilGroupParticipantsTableGUI\parse().

+ Here is the caller graph for this function:

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

411 : bool
412 {
413 if (self::$temporary_table_name == $temporary_table_name) {
414 return true;
415 }
416 if (self::$temporary_table_name === null) {
418 self::$temporary_table_name = $temporary_table_name;
419 } elseif ($temporary_table_name != self::$temporary_table_name) {
420 throw new ilException('there is already a temporary table for org-unit assignement: ' . self::$temporary_table_name);
421 }
422
423 $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . " AS (
424 SELECT DISTINCT object_reference.ref_id AS ref_id, il_orgu_ua.user_id AS user_id, orgu_path_storage.path AS path
425 FROM il_orgu_ua
426 JOIN object_reference ON object_reference.ref_id = il_orgu_ua.orgu_id
427 JOIN object_data ON object_data.obj_id = object_reference.obj_id
428 JOIN orgu_path_storage ON orgu_path_storage.ref_id = object_reference.ref_id
429 WHERE object_data.type = 'orgu' AND object_reference.deleted IS NULL
430 );";
431 $this->db->manipulate($q);
432
433 return true;
434 }
Base class for ILIAS Exception handling.
static string $temporary_table_name
dropTempTable(string $temporary_table_name)
$q
Definition: shib_logout.php:23

References $q, $temporary_table_name, and dropTempTable().

+ Here is the call graph for this function:

◆ dropTempTable()

ilObjOrgUnitTree::dropTempTable ( string  $temporary_table_name)

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

436 : bool
437 {
438 if (self::$temporary_table_name === null
439 || $temporary_table_name !== self::$temporary_table_name
440 ) {
441 return false;
442 }
443 $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
444 $this->db->manipulate($q);
445
446 self::$temporary_table_name = null;
447
448 return true;
449 }

References $q, and $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

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

487 : void
488 {
489 $this->roles = null;
490 }

◆ getAllChildren()

ilObjOrgUnitTree::getAllChildren ( int  $ref_id)

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

186 : array
187 {
188 $open = array($ref_id);
189 $closed = array();
190 while (count($open)) {
191 $ref = array_pop($open);
192 $closed[] = $ref;
193 foreach ($this->getChildren($ref) as $child) {
194 if (in_array($child, $open, true) === false && in_array($child, $closed, true) === false) {
195 $open[] = $child;
196 }
197 }
198 }
199
200 return $closed;
201 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, and getChildren().

Referenced by getEmployees(), 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 293 of file class.ilObjOrgUnitTree.php.

293 : array
294 {
295 $levels = array(0 => array(ilObjOrgUnit::getRootOrgRefId()));
296 $current_level = 0;
297 while ($current_level < $level) {
298 $new_level = array();
299 foreach ($levels[$current_level] as $orgu_ref) {
300 $new_level = array_merge($this->getChildren($orgu_ref), $new_level);
301 }
302 $new_level = array_unique($new_level);
303 $levels[$current_level + 1] = $new_level;
304 $current_level++;
305 }
306
307 return $levels[$level];
308 }
static getRootOrgRefId()

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

+ Here is the call graph for this function:

◆ getAssignedUsers()

ilObjOrgUnitTree::getAssignedUsers ( array  $orgu_ids,
int  $position_id 
)
Parameters
int[]$orgu_ids
Returns
int[]

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

97 : array
98 {
99 return $this->getAssignmentRepo()->getUsersByOrgUnitsAndPosition($orgu_ids, $position_id);
100 }

References getAssignmentRepo().

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

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

◆ getAssignements()

ilObjOrgUnitTree::getAssignements ( int  $ref_id,
ilOrgUnitPosition  $ilOrgUnitPosition 
)
Deprecated:
Please use getAssignedUsers()

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

88 : array
89 {
90 return $this->getAssignedUsers([$ref_id], $ilOrgUnitPosition->getId());
91 }
getAssignedUsers(array $orgu_ids, int $position_id)

References getAssignedUsers(), and ilOrgUnitPosition\getId().

+ Here is the call graph for this function:

◆ getAssignmentRepo()

ilObjOrgUnitTree::getAssignmentRepo ( )
protected

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

76 {
77 if (!isset($this->assignmentRepo)) {
79 $this->assignmentRepo = $dic["repo.UserAssignments"];
80 }
81
83 }
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
$dic
Definition: ltiresult.php:33

References $assignmentRepo, $dic, and ilOrgUnitLocalDIC\dic().

Referenced by getAssignedUsers(), getEmployeesUnderUser(), and getOrgUnitOfUser().

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

274 : array
275 {
276 $this->loadChildren($ref_id);
277 return $this->tree_childs[$ref_id];
278 }

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

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

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

106 : array
107 {
108 $employee_position = $this->getPositionRepo()
109 ->getSingle(ilOrgUnitPosition::CORE_POSITION_EMPLOYEE, 'core_identifier')
110 ->getId();
111
112 if ($recursive === false) {
113 return $this->getAssignedUsers(
114 [$ref_id],
115 $employee_position
116 );
117 }
118
119 return $this->getAssignedUsers(
120 $this->getAllChildren($ref_id),
121 $employee_position
122 );
123 }

References ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, getAllChildren(), getAssignedUsers(), and getPositionRepo().

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

316 : array
317 {
318 $superior_position = $this->getPositionRepo()
319 ->getSingle(ilOrgUnitPosition::CORE_POSITION_SUPERIOR, 'core_identifier')
320 ->getId();
321 $employee_position = $this->getPositionRepo()
322 ->getSingle(ilOrgUnitPosition::CORE_POSITION_EMPLOYEE, 'core_identifier')
323 ->getId();
324
325 $orgu_ids = $this->getAssignmentRepo()
326 ->getOrgUnitsByUserAndPosition($user_id, $superior_position, $recursive);
327
328 return $this->getAssignedUsers(
329 $orgu_ids,
330 $employee_position
331 );
332 }

References ilOrgUnitPosition\CORE_POSITION_EMPLOYEE, ilOrgUnitPosition\CORE_POSITION_SUPERIOR, getAssignedUsers(), getAssignmentRepo(), and getPositionRepo().

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

528 {
529 $line = array($orgu_ref);
530 $current_ref = $orgu_ref;
531 while ($current_ref != ilObjOrgUnit::getRootOrgRefId()) {
532 $current_ref = $this->getParent($current_ref);
533 if ($current_ref) {
534 $line[] = $current_ref;
535 } else {
536 break;
537 }
538 if (count($line) > 100) {
539 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");
540 }
541 }
542 $line = array_reverse($line);
543 if (count($line) > $level) {
544 return $line[$level];
545 } else {
546 throw new Exception("you want to fetch level " . $level . " but the line to the length of the line is only " . count($line)
547 . ". The line of the given org unit is: " . print_r($line, true));
548 }
549 }

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

366 : array
367 {
368 $q = "SELECT object_reference.ref_id FROM rbac_ua
369 JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
370 JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
371 JOIN object_data ON object_data.obj_id = object_reference.obj_id
372 WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer') . " AND object_data.type = 'orgu';";
373
374 $set = $this->db->query($q);
375 $orgu_ref_ids = array();
376 while ($res = $this->db->fetchAssoc($set)) {
377 $orgu_ref_ids[] = $res['ref_id'];
378 }
379 $orgus_on_level_x = array();
380 foreach ($orgu_ref_ids as $orgu_ref_id) {
381 try {
382 $orgus_on_level_x[] = $this->getLevelXOfTreenode($orgu_ref_id, $level);
383 } catch (Exception $e) {
384 // this means the user is assigned to a orgu above the given level. just dont add it to the list.
385 }
386 }
387
388 return array_unique($orgus_on_level_x);
389 }
getLevelXOfTreenode(int $orgu_ref, int $level)
Specify eg.
$res
Definition: ltiservices.php:69

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

+ Here is the call graph for this function:

◆ getOrgUnitOfUser()

ilObjOrgUnitTree::getOrgUnitOfUser ( int  $user_id)
Returns
int[]

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

394 : array
395 {
396 return $this->getAssignmentRepo()->getOrgUnitsByUser($user_id);
397 }

References getAssignmentRepo().

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

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

References $q, and $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 246 of file class.ilObjOrgUnitTree.php.

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

References $q, and $res.

◆ getParent()

ilObjOrgUnitTree::getParent ( int  $orgu_ref)

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

551 : int
552 {
553 if (array_key_exists($orgu_ref, $this->parent) === false) {
554 $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
555 }
556
557 return $this->parent[$orgu_ref];
558 }

Referenced by getLevelXOfTreenode().

+ Here is the caller graph for this function:

◆ getPositionRepo()

ilObjOrgUnitTree::getPositionRepo ( )
protected

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

66 {
67 if (!isset($this->positionRepo)) {
69 $this->positionRepo = $dic["repo.Positions"];
70 }
71
73 }
ilOrgUnitPositionDBRepository $positionRepo

References $dic, $positionRepo, and ilOrgUnitLocalDIC\dic().

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

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

◆ getRefIdFromRoleTitle()

ilObjOrgUnitTree::getRefIdFromRoleTitle ( string  $role_title)
private

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

504 : int
505 {
506 $array = explode("_", $role_title);
507
508 return $array[count($array) - 1];
509 }

Referenced by loadRolesQuery().

+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
int[]

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

473 : array
474 {
475 $this->loadRoles("superior");
476
477 return $this->roles["superior"];
478 }

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

130 : array
131 {
132 $superior_position = $this->getPositionRepo()
133 ->getSingle(ilOrgUnitPosition::CORE_POSITION_SUPERIOR, 'core_identifier')
134 ->getId();
135
136 if ($recursive === false) {
137 return $this->getAssignedUsers(
138 [$ref_id],
139 $superior_position
140 );
141 }
142
143 return $this->getAssignedUsers(
144 $this->getAllChildren($ref_id),
145 $superior_position
146 );
147 }

References ilOrgUnitPosition\CORE_POSITION_SUPERIOR, getAllChildren(), getAssignedUsers(), and getPositionRepo().

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

340 : array
341 {
342 //querry for all orgu where user_id is superior.
343 $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
344 INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
345 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)
346 INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
347 WHERE orgu.type = 'orgu'";
348 $set = $this->db->query($q);
349 $orgu_ref_ids = array();
350 while ($res = $this->db->fetchAssoc($set)) {
351 $orgu_ref_ids[] = $res['ref_id'];
352 }
353 $superiors = array();
354 foreach ($orgu_ref_ids as $orgu_ref_id) {
355 $superiors = array_merge($superiors, $this->getSuperiors($orgu_ref_id, $recursive));
356 }
357
358 return $superiors;
359 }
getSuperiors(int $ref_id, bool $recursive=false)

References $q, $res, $user_id, and getSuperiors().

+ Here is the call graph for this function:

◆ getTitles()

ilObjOrgUnitTree::getTitles ( array  $org_refs)

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

451 : array
452 {
453 $names = array();
454 foreach ($org_refs as $org_unit) {
455 $names[$org_unit] = ilObject::_lookupTitle(ilObject::_lookupObjId($org_unit));
456 }
457
458 return $names;
459 }
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 154 of file class.ilObjOrgUnitTree.php.

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

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

+ Here is the call graph for this function:

◆ loadChildren()

ilObjOrgUnitTree::loadChildren ( int  $ref_id)
private

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

280 : void
281 {
282 if (!array_key_exists($ref_id, $this->tree_childs)) {
283 $children = [];
284 foreach ($this->tree->getChilds($ref_id) as $child) {
285 if ($child["type"] == "orgu") {
286 $children[] = $child["child"];
287 }
288 }
289 $this->tree_childs[$ref_id] = $children;
290 }
291 }

References $ref_id.

Referenced by getChildren().

+ Here is the caller graph for this function:

◆ loadRoles()

ilObjOrgUnitTree::loadRoles ( string  $role)
private

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

481 {
482 if ($this->roles[$role] == null) {
483 $this->loadRolesQuery($role);
484 }
485 }

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

492 : void
493 {
494 $this->roles[$role] = array();
495 $q = "SELECT obj_id, title FROM object_data WHERE type = 'role' AND title LIKE 'il_orgu_" . $role . "%'";
496 $set = $this->db->query($q);
497 while ($res = $this->db->fetchAssoc($set)) {
498 $orgu_ref = $this->getRefIdFromRoleTitle($res["title"]);
499 $this->roles[$role][$orgu_ref] = $res["obj_id"];
500 $this->role_to_orgu[$role][$res["obj_id"]] = $orgu_ref;
501 }
502 }
getRefIdFromRoleTitle(string $role_title)

References $q, $res, and getRefIdFromRoleTitle().

Referenced by loadRoles().

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

Field Documentation

◆ $assignmentRepo

ilOrgUnitUserAssignmentDBRepository ilObjOrgUnitTree::$assignmentRepo
protected

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

Referenced by getAssignmentRepo().

◆ $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.

◆ $positionRepo

ilOrgUnitPositionDBRepository ilObjOrgUnitTree::$positionRepo
protected

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

Referenced by getPositionRepo().

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