ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilOrgUnitExtension.php
Go to the documentation of this file.
1 <?php
2 
24 abstract class ilOrgUnitExtension extends ilObjectPlugin
25 {
27  protected int $parent_ref_id;
28  protected ilTree $tree;
29 
33  public function __construct(int $a_ref_id = 0)
34  {
35  global $DIC;
36  $tree = $DIC->repositoryTree();
37 
38  $http = $DIC->http();
39  $refinery = $DIC->refinery();
40  $ref_id = $http->wrapper()->query()->retrieve('ref_id', $refinery->to()->int());
41 
42  parent::__construct($a_ref_id);
44  $this->parent_ref_id = $tree->getParentId($a_ref_id ? $a_ref_id : $ref_id);
45  $this->tree = $tree;
46  }
47 
52  public static function getActivePluginIdsForTree(): array
53  {
54  global $DIC;
55  $component_factory = $DIC["component.factory"];
56 
60  $list = array();
61 
62  foreach ($component_factory->getActivePluginsInSlot("orguext") as $plugin) {
63  if ($plugin->showInTree()) {
64  $list[] = $plugin->getId();
65  }
66  }
67 
68  return $list;
69  }
70 
76  public function getEmployees(bool $recursively = false): array
77  {
78  return $this->ilObjOrgUnitTree->getEmployees($this->parent_ref_id, $recursively);
79  }
80 
86  public function getSuperiors(bool $recursively = false): array
87  {
88  return $this->ilObjOrgUnitTree->getSuperiors($this->parent_ref_id, $recursively);
89  }
90 
91  public function getOrgUnit(): ?ilObject
92  {
93  return ilObjectFactory::getInstanceByRefId($this->parent_ref_id);
94  }
95 
99  public function getOrgUnitPathRefIds(): array
100  {
101  $path = array();
102  foreach ($this->getOrgUnitPath() as $node) {
103  $path[] = $node['child'];
104  }
105 
106  return $path;
107  }
108 
112  public function getOrgUnitPath(): array
113  {
114  return $this->tree->getPathFull($this->parent_ref_id, ilObjOrgUnit::getRootOrgRefId());
115  }
116 
120  public function getOrgUnitPathTitles(): array
121  {
122  $titles = array();
123  foreach ($this->getOrgUnitPath() as $node) {
124  if ($node["title"] == "__OrgUnitAdministration") {
125  $node["title"] = $this->lng->txt("objs_orgu");
126  }
127  $titles[] = $node['title'];
128  }
129 
130  return $titles;
131  }
132 
138  public function getOrgUnitSubtree(bool $with_data = true, string $type = ""): array
139  {
140  $node = $this->tree->getNodeData($this->parent_ref_id);
141 
142  return $this->tree->getSubTree($node, $with_data, [$type]);
143  }
144 }
string $type
$http
Definition: deliver.php:14
ilComponentFactory $component_factory
$path
Definition: ltiservices.php:30
getActivePluginsInSlot(string $slot_id)
Get the active plugins for the given slot.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
global $DIC
Definition: shib_login.php:25
__construct(int $a_ref_id=0)
ilOrgUnitExtension constructor.
getParentId(int $a_node_id)
get parent id of given node
getSuperiors(bool $recursively=false)
Get all user ids of superiors of the underlying OrgUnit.
static getRootOrgRefId()
getEmployees(bool $recursively=false)
Get all user ids of employees of the underlying OrgUnit.
__construct(Container $dic, ilPlugin $plugin)
getOrgUnitSubtree(bool $with_data=true, string $type="")
ilObjOrgUnitTree $ilObjOrgUnitTree
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...