ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 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.

References $DIC, $ilDB, and $tree.

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

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

References $temporary_table_name, and dropTempTable().

483  {
484  if (self::$temporary_table_name == $temporary_table_name) {
485  return true;
486  }
487  if (self::$temporary_table_name === null) {
489  self::$temporary_table_name = $temporary_table_name;
490  } elseif ($temporary_table_name != self::$temporary_table_name) {
491  throw new ilException('there is already a temporary table for org-unit assignement: ' . self::$temporary_table_name);
492  }
493 
494  $q = "CREATE TEMPORARY TABLE IF NOT EXISTS " . $temporary_table_name . " AS (
495  SELECT DISTINCT object_reference.ref_id AS ref_id, il_orgu_ua.user_id AS user_id, orgu_path_storage.path AS path
496  FROM il_orgu_ua
497  JOIN object_reference ON object_reference.ref_id = il_orgu_ua.orgu_id
498  JOIN object_data ON object_data.obj_id = object_reference.obj_id
499  JOIN orgu_path_storage ON orgu_path_storage.ref_id = object_reference.ref_id
500  WHERE object_data.type = 'orgu' AND object_reference.deleted IS NULL
501  );";
502  $this->db->manipulate($q);
503 
504  return true;
505  }
dropTempTable($temporary_table_name)
+ Here is the call graph for this function:

◆ dropTempTable()

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

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

References $temporary_table_name.

Referenced by buildTempTableWithUsrAssignements().

514  {
515  if (self::$temporary_table_name === null
516  || $temporary_table_name != self::$temporary_table_name) {
517  return false;
518  }
519  $q = "DROP TABLE IF EXISTS " . $temporary_table_name;
520  $this->db->manipulate($q);
521 
522  self::$temporary_table_name = null;
523 
524  return true;
525  }
+ Here is the caller graph for this function:

◆ flushCache()

ilObjOrgUnitTree::flushCache ( )

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

578  {
579  $this->roles = null;
580  }

◆ getAllChildren()

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

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

References getChildren().

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

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) && !in_array($child, $closed)) {
195  $open[] = $child;
196  }
197  }
198  }
199 
200  return $closed;
201  }
+ 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 319 of file class.ilObjOrgUnitTree.php.

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

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

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

Referenced by getEmployees(), and getSuperiors().

107  {
108  return ilOrgUnitUserAssignment::where(array(
109  'orgu_id' => $ref_id,
110  'position_id' => $ilOrgUnitPosition->getId(),
111  ))->getArray('id', 'user_id');
112  }
static where($where, $operator=null)
+ 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 289 of file class.ilObjOrgUnitTree.php.

References loadChildren().

Referenced by getAllChildren(), and getAllOrgunitsOnLevelX().

290  {
291  $this->loadChildren($ref_id);
292 
293  return $this->tree_childs[$ref_id];
294  }
+ 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 547 of file class.ilObjOrgUnitTree.php.

References loadRoles().

548  {
549  $this->loadRoles("employee");
550 
551  return $this->roles["employee"];
552  }
+ 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.

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

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

81  {
82  $arr_usr_ids = [];
83 
84  switch ($recursive) {
85  case false:
87  break;
88  case true:
89  foreach ($this->getAllChildren($ref_id) as $ref_id) {
90  $arr_usr_ids = $arr_usr_ids
92  }
93  break;
94  }
95 
96  return $arr_usr_ids;
97  }
static getCorePosition($core_identifier)
getAssignements($ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
+ 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 345 of file class.ilObjOrgUnitTree.php.

References $res, and getEmployees().

346  {
347  //querry for all orgu where user_id is superior.
348  $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
349  INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
350  INNER JOIN object_data roles ON roles.title LIKE CONCAT('il_orgu_superior_',refr.ref_id)
351  INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
352  WHERE orgu.type = 'orgu'";
353  $set = $this->db->query($q);
354  $orgu_ref_ids = array();
355  while ($res = $this->db->fetchAssoc($set)) {
356  $orgu_ref_ids[] = $res['ref_id'];
357  }
358  $employees = array();
359  foreach ($orgu_ref_ids as $orgu_ref_id) {
360  $employees = array_merge($employees, $this->getEmployees($orgu_ref_id, $recursive));
361  }
362 
363  return $employees;
364  }
getEmployees($ref_id, $recursive=false)
foreach($_POST as $key=> $value) $res
+ 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 632 of file class.ilObjOrgUnitTree.php.

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

Referenced by getLevelXOfUser().

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

References $res, and getLevelXOfTreenode().

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

References $res, and getAllChildren().

440  {
441  $q = "SELECT object_reference.ref_id FROM rbac_ua
442  JOIN rbac_fa ON rbac_fa.rol_id = rbac_ua.rol_id
443  JOIN object_reference ON rbac_fa.parent = object_reference.ref_id
444  JOIN object_data ON object_data.obj_id = object_reference.obj_id
445  WHERE rbac_ua.usr_id = " . $this->db->quote($user_id, 'integer') . " AND object_data.type = 'orgu'";
446 
447  $set = $this->db->query($q);
448  $orgu_ref_ids = array();
449  while ($res = $this->db->fetchAssoc($set)) {
450  $orgu_ref_ids[] = $res['ref_id'];
451  }
452  $orgu_ref_ids = array_unique($orgu_ref_ids);
453  if ($ref_id) {
454  $childernOrgIds = $this->getAllChildren($ref_id);
455  foreach ($orgu_ref_ids as $k => $refId) {
456  if (!in_array($refId, $childernOrgIds)) {
457  unset($orgu_ref_ids[$k]);
458  }
459  }
460  }
461 
462  return $orgu_ref_ids;
463  }
foreach($_POST as $key=> $value) $res
+ 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 212 of file class.ilObjOrgUnitTree.php.

References $DIC, $ilUser, and $res.

213  {
214  global $DIC;
215  $ilUser = $DIC['ilUser'];
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 = ".$this->db->quote($operation, "text")."
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('%', rbac_operations.ops_id, '%')
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  $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
226  INNER JOIN rbac_operations ON rbac_operations.operation = " . $this->db->quote($operation, "text") . "
227  INNER JOIN rbac_ua ON rbac_ua.usr_id = " . $this->db->quote($ilUser->getId(), "integer") . "
228  INNER JOIN rbac_pa ON rbac_pa.rol_id = rbac_ua.rol_id AND rbac_pa.ops_id LIKE CONCAT('%', rbac_operations.ops_id, '%')
229  INNER JOIN object_reference ON object_reference.ref_id = rbac_pa.ref_id
230  WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'orgu'";
231 
232  $set = $this->db->query($q);
233  $orgus = array();
234  while ($res = $this->db->fetchAssoc($set)) {
235  //this is needed as the table rbac_operations is not in the first normal form, thus this needs some additional checkings.
236  $perm_check = unserialize($res['ops_id']);
237  if (!in_array($res["op_id"], $perm_check)) {
238  continue;
239  }
240 
241  $orgus[] = $res["ref_id"];
242  }
243 
244  return $orgus;
245  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$ilUser
Definition: imgupload.php:18

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

References $DIC, $ilUser, and $res.

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

◆ getParent()

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

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

Referenced by getLevelXOfTreenode().

663  {
664  if (!$this->parent[$orgu_ref]) {
665  $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
666  }
667 
668  return $this->parent[$orgu_ref];
669  }
+ Here is the caller graph for this function:

◆ getRefIdFromRoleTitle()

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

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

Referenced by loadRolesQuery().

605  {
606  $array = explode("_", $role_title);
607 
608  return $array[count($array) - 1];
609  }
+ Here is the caller graph for this function:

◆ getSuperiorRoles()

ilObjOrgUnitTree::getSuperiorRoles ( )
Returns
[]

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

References loadRoles().

559  {
560  $this->loadRoles("superior");
561 
562  return $this->roles["superior"];
563  }
+ 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 121 of file class.ilObjOrgUnitTree.php.

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

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

122  {
123  $arr_usr_ids = [];
124 
125  switch ($recursive) {
126  case false:
128  break;
129  case true:
130  foreach ($this->getAllChildren($ref_id) as $ref_id) {
131  $arr_usr_ids = $arr_usr_ids
133  }
134  break;
135  }
136 
137  return $arr_usr_ids;
138  }
static getCorePosition($core_identifier)
getAssignements($ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
+ 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 375 of file class.ilObjOrgUnitTree.php.

References $res, and getSuperiors().

376  {
377  //querry for all orgu where user_id is superior.
378  $q = "SELECT orgu.obj_id, refr.ref_id FROM object_data orgu
379  INNER JOIN object_reference refr ON refr.obj_id = orgu.obj_id
380  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)
381  INNER JOIN rbac_ua rbac ON rbac.usr_id = " . $this->db->quote($user_id, "integer") . " AND roles.obj_id = rbac.rol_id
382  WHERE orgu.type = 'orgu'";
383  $set = $this->db->query($q);
384  $orgu_ref_ids = array();
385  while ($res = $this->db->fetchAssoc($set)) {
386  $orgu_ref_ids[] = $res['ref_id'];
387  }
388  $superiors = array();
389  foreach ($orgu_ref_ids as $orgu_ref_id) {
390  $superiors = array_merge($superiors, $this->getSuperiors($orgu_ref_id, $recursive));
391  }
392 
393  return $superiors;
394  }
foreach($_POST as $key=> $value) $res
getSuperiors($ref_id, $recursive=false)
+ Here is the call graph for this function:

◆ getTitles()

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

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

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

534  {
535  $names = array();
536  foreach ($org_refs as $org_unit) {
537  $names[$org_unit] = ilObject::_lookupTitle(ilObject::_lookupObjId($org_unit));
538  }
539 
540  return $names;
541  }
static _lookupTitle($a_id)
lookup object title
static _lookupObjId($a_id)
+ 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 147 of file class.ilObjOrgUnitTree.php.

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

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

◆ loadChildren()

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

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

Referenced by getChildren().

301  {
302  if (!$this->tree_childs[$ref_id]) {
303  $children = array();
304  foreach ($this->tree->getChilds($ref_id) as $child) {
305  if ($child["type"] == "orgu") {
306  $children[] = $child["child"];
307  }
308  }
309  $this->tree_childs[$ref_id] = $children;
310  };
311  }
+ Here is the caller graph for this function:

◆ loadRoles()

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

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

References loadRolesQuery().

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

570  {
571  if ($this->roles[$role] == null) {
572  $this->loadRolesQuery($role);
573  }
574  }
+ 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 586 of file class.ilObjOrgUnitTree.php.

References $res, and getRefIdFromRoleTitle().

Referenced by loadRoles().

587  {
588  $this->roles[$role] = array();
589  $q = "SELECT obj_id, title FROM object_data WHERE type = 'role' AND title LIKE 'il_orgu_" . $role . "%'";
590  $set = $this->db->query($q);
591  while ($res = $this->db->fetchAssoc($set)) {
592  $orgu_ref = $this->getRefIdFromRoleTitle($res["title"]);
593  $this->roles[$role][$orgu_ref] = $res["obj_id"];
594  $this->role_to_orgu[$role][$res["obj_id"]] = $orgu_ref;
595  }
596  }
getRefIdFromRoleTitle($role_title)
foreach($_POST as $key=> $value) $res
+ 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.

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