ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilOrgUnitExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13 
17  protected $stay_with_command = array( "", "render", "view", "infoScreen", "showStaff", "performPaste", "cut" );
21  protected $tree = null;
22 
23 
30  public function __construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree)
31  {
32  parent::__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree);
33  $this->setAjax(true);
34  $this->setTypeWhiteList(array( "orgu" ));
35  $this->tree->initLangCode();
36  }
37 
38 
44  public function getNodeContent($node)
45  {
46  global $DIC;
47  if ($node["title"] == "__OrgUnitAdministration") {
48  $node["title"] = $DIC->language()->txt("objs_orgu");
49  }
50  if ($node["child"] == $_GET["ref_id"]) {
51  return "<span class='ilExp2NodeContent ilHighlighted'>" . $node["title"] . "</span>";
52  } else {
53  return $node["title"];
54  }
55  }
56 
57 
61  public function getRootNode()
62  {
63  return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId());
64  }
65 
66 
75  public function getNodeIcon($a_node)
76  {
77  global $DIC;
78  $ilias = $DIC['ilias'];
79  if ($ilias->getSetting('custom_icons')) {
80  $icons_cache = ilObjOrgUnit::getIconsCache();
81  $obj_id = ilObject::_lookupObjId($a_node["child"]);
82  if (isset($icons_cache[$obj_id])) {
83  return $icons_cache[$obj_id];
84  }
85  }
86 
87  return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
88  }
89 
90 
96  public function getNodeHref($node)
97  {
98  global $DIC;
99 
100  if ($this->select_postvar) {
101  return "#";
102  }
103 
104  if ($DIC->ctrl()->getCmd() == "performPaste") {
105  $DIC->ctrl()->setParameterByClass("ilObjOrgUnitGUI", "target_node", $node["child"]);
106  }
107  $array = $DIC->ctrl()->getParameterArrayByClass("ilObjOrgUnitGUI");
108  $temp = $array['ref_id'];
109 
110  $DIC->ctrl()->setParameterByClass("ilObjOrgUnitGUI", "ref_id", $node["child"]);
111  $DIC->ctrl()->setParameterByClass("ilObjPluginDispatchGUI", "ref_id", $node["child"]);
112 
113  $link_target = ($node['type'] == "orgu") ? $this->getLinkTarget() : $this->getPluginLinkTarget();
114  $DIC->ctrl()->setParameterByClass("ilObjOrgUnitGUI", 'ref_id', $temp);
115  return $link_target;
116  }
117 
118 
122  protected function getLinkTarget()
123  {
124  global $DIC;
125  if ($DIC->ctrl()->getCmdClass() == "ilobjorgunitgui" and in_array($DIC->ctrl()->getCmd(), $this->stay_with_command)) {
126  return $DIC->ctrl()->getLinkTargetByClass(array( "ilAdministrationGUI", $DIC->ctrl()->getCmdClass() ), $DIC->ctrl()->getCmd());
127  } else {
128  return $DIC->ctrl()->getLinkTargetByClass(array( "ilAdministrationGUI", "ilobjorgunitgui" ), "view");
129  }
130  }
131 
132 
133  protected function getPluginLinkTarget()
134  {
135  global $DIC;
136  return $DIC->ctrl()->getLinkTargetByClass("ilObjPluginDispatchGUI", "forward");
137  }
138 
139 
149  public function getChildsOfNode($a_parent_node_id)
150  {
151  global $DIC;
152  $ilAccess = $DIC->access();
153 
154  $wl = $this->getTypeWhiteList();
155  if (is_array($wl) && count($wl) > 0) {
156  $childs = $this->tree->getChildsByTypeFilter($a_parent_node_id, $wl, $this->getOrderField());
157  } else {
158  $childs = $this->tree->getChilds($a_parent_node_id, $this->getOrderField());
159  }
160 
161  // apply black list filter
162  $bl = $this->getTypeBlackList();
163  if (is_array($bl) && count($bl) > 0) {
164  $bl_childs = array();
165  foreach ($childs as $k => $c) {
166  if (!in_array($c["type"], $bl)) {
167  $bl_childs[$k] = $c;
168  }
169  }
170 
171  return $bl_childs;
172  }
173 
174  //Check Access
175  foreach ($childs as $key => $child) {
176  if (!$ilAccess->checkAccess('visible', '', $child['ref_id'])) {
177  unset($childs[$key]);
178  }
179  }
180 
181  return $childs;
182  }
183 
184 
195  public function sortChilds($a_childs, $a_parent_node_id)
196  {
197  usort($a_childs, array( __CLASS__, "sortbyTitle" ));
198 
199  return $a_childs;
200  }
201 
202 
209  public function sortbyTitle($a, $b)
210  {
211  return strcmp($a["title"], $b["title"]);
212  }
213 
214 
223  public function isNodeClickable($a_node)
224  {
225  global $DIC;
226  $ilAccess = $DIC->access();
227 
228  if ($ilAccess->checkAccess('read', '', $a_node['ref_id'])) {
229  return true;
230  }
231 
232  return false;
233  }
234 
238  public function isNodeSelectable($a_node)
239  {
240  $current_node = filter_input(INPUT_GET, 'item_ref_id');
241  if ($a_node['child'] == $current_node || $this->tree->isGrandChild($current_node, $a_node['child'])) {
242  return false;
243  }
244  return true;
245  }
246 }
isNodeClickable($a_node)
Is node clickable?
global $DIC
Definition: saml.php:7
getTypeBlackList()
Get type black list.
$_GET["client_id"]
getNodeIcon($a_node)
Get node icon Return custom icon of OrgUnit type if existing.
setTypeWhiteList($a_val)
Set type white list.
__construct($a_expl_id, $a_parent_obj, $a_parent_cmd, $a_tree)
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
static _lookupObjId($a_id)
static getRootOrgRefId()
getOrderField()
Get order field.
Explorer class that works on tree objects (Services/Tree)
Class ilOrgUnitExplorerGUI.
$key
Definition: croninfo.php:18
getChildsOfNode($a_parent_node_id)
Get childs of node.
getTypeWhiteList()
Get type white list.