ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
OrgUnitToolProvider.php
Go to the documentation of this file.
1 <?php
2 
20 namespace ILIAS\OrgUnit\Provider;
21 
27 use ilObjOrgUnit;
28 use ilObjOrgUnitGUI;
31 use ilTree;
32 
38 {
39  public const SHOW_ORGU_TREE = 'show_orgu_tree';
40 
42  {
43  return $this->context_collection->main()->administration();
44  }
45 
50  public function getToolsForContextStack(CalledContexts $called_contexts): array
51  {
52  $tools = [];
53 
54  if ($called_contexts->current()->getAdditionalData()->is(self::SHOW_ORGU_TREE, true)) {
55  $iff = function (string $id) {
56  return $this->identification_provider->contextAwareIdentifier($id);
57  };
58 
59  $t = function (string $key): string {
60  return $this->dic->language()->txt($key);
61  };
62 
63  $tools[] = $this->factory->treeTool($iff('tree_new'))
64  ->withTitle($t('tree'))
65  ->withSymbol($this->dic->ui()->factory()->symbol()->icon()->standard(
66  'orgu',
67  'Orgu'
68  ))
69  ->withTree($this->getTree());
70  }
71 
72  return $tools;
73  }
74 
75  private function getTree(): Tree
76  {
77  global $DIC;
78  $lng = $DIC->language();
79  $tree = $this->getTreeRecursion();
80 
81  $parent_node_id = $DIC->repositoryTree()->getParentId(ilObjOrgUnit::getRootOrgRefId());
82 
83  return $this->dic->ui()->factory()->tree()->expandable($lng->txt("org_units"), $tree)
84  ->withData($tree->getChildsOfNode($parent_node_id));
85  }
86 
87  private function getTreeRecursion(): TreeRecursion
88  {
89  $tree = new ilOrgUnitExplorerGUI(
90  "orgu_explorer",
91  ilObjOrgUnitGUI::class,
92  "showTree",
93  new ilTree(1),
94  $this->dic["ilAccess"]
95  );
96  $tree->setTypeWhiteList($this->getTreeWhiteList());
97  $tree->setRootId(ilObjOrgUnit::getRootOrgRefId());
98  $ref_id = (int) ($_GET['item_ref_id'] ?? $_GET['ref_id'] ?? 0);
99  if ($ref_id !== 0) {
100  $tree->setPathOpen((int) $ref_id);
101  }
102  $tree->setOrderField('title');
103 
104  return $tree;
105  }
106 
110  private function getTreeWhiteList(): array
111  {
112  $whiteList = array('orgu');
113  $pls = ilOrgUnitExtension::getActivePluginIdsForTree();
114 
115  return array_merge($whiteList, $pls);
116  }
117 }
$ref_id
Definition: ltiauth.php:66
getToolsForContextStack(CalledContexts $called_contexts)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:25
$_GET['cmd']
Definition: lti.php:26
static getRootOrgRefId()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes a Tree Control.
Definition: Tree.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
Interface for mapping data-structures to the Tree.
global $lng
Definition: privfeed.php:32