60        $this->roles = array();
 
   61        $this->staff = array();
 
   70        if (self::$instance === 
null) {
 
   71            self::$instance = 
new self();
 
  111            'orgu_id' => $ref_id,
 
  112            'position_id' => $ilOrgUnitPosition->
getId(),
 
  113        ))->getArray(
'id', 
'user_id');
 
  127        switch ($recursive) {
 
  133                    $arr_usr_ids = $arr_usr_ids
 
  152        $all_refs = $ref_ids;
 
  154        foreach ($ref_ids as $id => $ref_id) {
 
  155            if (isset($this->staff[$title][$ref_id])) {
 
  156                unset($ref_ids[$id]);
 
  158                $this->staff[$title][$ref_id] = array();
 
  159                $ref_ids[$id] = $this->roles[$title][$ref_id];
 
  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"];
 
  174        $all_users = array();
 
  175        foreach ($all_refs as $ref) {
 
  176            $all_users = array_merge($all_users, $this->staff[$title][$ref]);
 
  190        $open = array($ref_id);
 
  192        while (count($open)) {
 
  193            $ref = array_pop($open);
 
  196                if (!in_array($child, $open) && !in_array($child, $closed)) {
 
  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'";
 
  234        $set = $this->db->query($q);
 
  236        while (
$res = $this->db->fetchAssoc($set)) {
 
  238            $perm_check = unserialize(
$res[
'ops_id']);
 
  239            if (!in_array(
$res[
"op_id"], $perm_check)) {
 
  243            $orgus[] = 
$res[
"ref_id"];
 
  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'";
 
  270        $set = $this->db->query($q);
 
  272        while (
$res = $this->db->fetchAssoc($set)) {
 
  274            $perm_check = unserialize(
$res[
'ops_id']);
 
  275            if (!in_array(
$res[
"ops_id"], $perm_check)) {
 
  279            $orgus[] = 
$res[
"obj_id"];
 
  295        return $this->tree_childs[$ref_id];
 
  304        if (!$this->tree_childs[$ref_id]) {
 
  306            foreach ($this->tree->getChilds($ref_id) as $child) {
 
  307                if ($child[
"type"] == 
"orgu") {
 
  308                    $children[] = $child[
"child"];
 
  311            $this->tree_childs[$ref_id] = $children;
 
  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);
 
  330            $new_level = array_unique($new_level);
 
  331            $levels[$current_level + 1] = $new_level;
 
  335        return $levels[$level];
 
  352        $orgu_ref_ids = $assignment_query->getOrgUnitIdsOfUsersPosition(
 
  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));
 
  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'];
 
  395        $superiors = array();
 
  396        foreach ($orgu_ref_ids as $orgu_ref_id) {
 
  397            $superiors = array_merge($superiors, $this->
getSuperiors($orgu_ref_id, $recursive));
 
  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';";
 
  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'];
 
  425        $orgus_on_level_x = array();
 
  426        foreach ($orgu_ref_ids as $orgu_ref_id) {
 
  429            } 
catch (Exception 
$e) {
 
  434        return array_unique($orgus_on_level_x);
 
  451        $orgus =  $orgu_query->getAssignmentsOfUserId($user_id);
 
  452        foreach($orgus as $orgu) {
 
  453            $orgu_ref_ids[] = $orgu->getOrguId();
 
  455        return $orgu_ref_ids;
 
  480        if (self::$temporary_table_name === 
null) {
 
  484            throw new ilException(
'there is already a temporary table for org-unit assignement: ' . self::$temporary_table_name);
 
  488                                SELECT DISTINCT object_reference.ref_id AS ref_id, il_orgu_ua.user_id AS user_id, orgu_path_storage.path AS path 
  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 
  495        $this->db->manipulate($q);
 
  508        if (self::$temporary_table_name === 
null 
  514        $this->db->manipulate($q);
 
  516        self::$temporary_table_name = 
null;
 
  530        foreach ($org_refs as $org_unit) {
 
  545        return $this->roles[
"employee"];
 
  556        return $this->roles[
"superior"];
 
  565        if ($this->roles[$role] == 
null) {
 
  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)) {
 
  587            $this->roles[$role][$orgu_ref] = 
$res[
"obj_id"];
 
  588            $this->role_to_orgu[$role][
$res[
"obj_id"]] = $orgu_ref;
 
  600        $array = explode(
"_", $role_title);
 
  602        return $array[count($array) - 1];
 
  628        $line = array($orgu_ref);
 
  629        $current_ref = $orgu_ref;
 
  631            $current_ref = $this->
getParent($current_ref);
 
  633                $line[] = $current_ref;
 
  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");
 
  641        $line = array_reverse($line);
 
  642        if (count($line) > $level) {
 
  643            return $line[$level];
 
  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));
 
  658        if (!$this->parent[$orgu_ref]) {
 
  659            $this->parent[$orgu_ref] = $this->tree->getParentId($orgu_ref);
 
  662        return $this->parent[$orgu_ref];
 
static where($where, $operator=null)
An exception for terminatinating execution or to throw for unit testing.
Base class for ILIAS Exception handling.
Class ilObjOrgUnitTree Implements a singleton pattern for caching.
buildTempTableWithUsrAssignements($temporary_table_name='orgu_usr_assignements')
Creates a temporary table with all orgu/user assignements.
getOrgusWhereUserHasPermissionForOperation($operation)
If you want to have all orgunits where the current user has the write permission: use this with the p...
getOrgusWhereUserHasPermissionForOperationId($operation_id)
If you want to have all orgunits where the current user has the write permission: use this with the p...
getAllOrgunitsOnLevelX($level)
getOrgUnitOfUser($user_id)
getOrgUnitOfUser
getEmployeesUnderUser($user_id, $recursive=true)
getAssignements($ref_id, ilOrgUnitPosition $ilOrgUnitPosition)
getEmployees($ref_id, $recursive=false)
static $temporary_table_namgetOrgUnitOfUsere
loadArrayOfStaff($title, $ref_ids)
getRefIdFromRoleTitle($role_title)
getSuperiors($ref_id, $recursive=false)
getLevelXOfTreenode($orgu_ref, $level)
Specify eg.
getLevelXOfUser($user_id, $level)
for additional info see the other getLevelX method.
dropTempTable($temporary_table_name)
static $temporary_table_name
getSuperiorsOfUser($user_id, $recursive=true)
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static getCorePosition($core_identifier)
const CORE_POSITION_EMPLOYEE
const CORE_POSITION_SUPERIOR
foreach($_POST as $key=> $value) $res