ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $lng = $DIC['lng'];
48  if ($node["title"] == "__OrgUnitAdministration") {
49  $node["title"] = $lng->txt("objs_orgu");
50  }
51  if ($node["child"] == $_GET["ref_id"]) {
52  return "<span class='ilExp2NodeContent ilHighlighted'>" . $node["title"] . "</span>";
53  } else {
54  return $node["title"];
55  }
56  }
57 
58 
62  public function getRootNode()
63  {
64  return $this->getTree()->getNodeData(ilObjOrgUnit::getRootOrgRefId());
65  }
66 
67 
76  public function getNodeIcon($a_node)
77  {
78  global $DIC;
79  $ilias = $DIC['ilias'];
80  if ($ilias->getSetting('custom_icons')) {
81  $icons_cache = ilObjOrgUnit::getIconsCache();
82  $obj_id = ilObject::_lookupObjId($a_node["child"]);
83  if (isset($icons_cache[$obj_id])) {
84  return $icons_cache[$obj_id];
85  }
86  }
87 
88  return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
89  }
90 
91 
97  public function getNodeHref($node)
98  {
99  global $DIC;
100  $ilCtrl = $DIC['ilCtrl'];
101  if ($ilCtrl->getCmd() == "performPaste") {
102  $ilCtrl->setParameterByClass("ilObjOrgUnitGUI", "target_node", $node["child"]);
103  }
104  $array = $ilCtrl->getParameterArrayByClass("ilObjOrgUnitGUI");
105  $temp = $array['ref_id'];
106 
107  $ilCtrl->setParameterByClass("ilObjOrgUnitGUI", "ref_id", $node["child"]);
108  $ilCtrl->setParameterByClass("ilObjPluginDispatchGUI", "ref_id", $node["child"]);
109 
110  $link_target = ($node['type'] == "orgu") ? $this->getLinkTarget() : $this->getPluginLinkTarget();
111  $ilCtrl->setParameterByClass("ilObjOrgUnitGUI", 'ref_id', $temp);
112  return $link_target;
113  }
114 
115 
119  protected function getLinkTarget()
120  {
121  global $DIC;
122  $ilCtrl = $DIC['ilCtrl'];
123 
124  if ($ilCtrl->getCmdClass() == "ilobjorgunitgui" and in_array($ilCtrl->getCmd(), $this->stay_with_command)) {
125  return $ilCtrl->getLinkTargetByClass(array( "ilAdministrationGUI", $ilCtrl->getCmdClass() ), $ilCtrl->getCmd());
126  } else {
127  return $ilCtrl->getLinkTargetByClass(array( "ilAdministrationGUI", "ilobjorgunitgui" ), "view");
128  }
129  }
130 
131 
132  protected function getPluginLinkTarget()
133  {
134  global $DIC;
135  $ilCtrl = $DIC['ilCtrl'];
136 
137  return $ilCtrl->getLinkTargetByClass("ilObjPluginDispatchGUI", "forward");
138  }
139 
140 
150  public function getChildsOfNode($a_parent_node_id)
151  {
152  global $DIC;
153  $ilAccess = $DIC['ilAccess'];
154 
155  $wl = $this->getTypeWhiteList();
156  if (is_array($wl) && count($wl) > 0) {
157  $childs = $this->tree->getChildsByTypeFilter($a_parent_node_id, $wl, $this->getOrderField());
158  } else {
159  $childs = $this->tree->getChilds($a_parent_node_id, $this->getOrderField());
160  }
161 
162  // apply black list filter
163  $bl = $this->getTypeBlackList();
164  if (is_array($bl) && count($bl) > 0) {
165  $bl_childs = array();
166  foreach ($childs as $k => $c) {
167  if (!in_array($c["type"], $bl)) {
168  $bl_childs[$k] = $c;
169  }
170  }
171 
172  return $bl_childs;
173  }
174 
175  //Check Access
176  foreach ($childs as $key => $child) {
177  if (!$ilAccess->checkAccess('visible', '', $child['ref_id'])) {
178  unset($childs[$key]);
179  }
180  }
181 
182  return $childs;
183  }
184 
185 
196  public function sortChilds($a_childs, $a_parent_node_id)
197  {
198  usort($a_childs, array( __CLASS__, "sortbyTitle" ));
199 
200  return $a_childs;
201  }
202 
203 
210  public function sortbyTitle($a, $b)
211  {
212  return strcmp($a["title"], $b["title"]);
213  }
214 
215 
224  public function isNodeClickable($a_node)
225  {
226  global $DIC;
227  $ilAccess = $DIC['ilAccess'];
228 
229  if ($ilAccess->checkAccess('read', '', $a_node['ref_id'])) {
230  return true;
231  }
232 
233  return false;
234  }
235 }
isNodeClickable($a_node)
Is node clickable?
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
global $ilCtrl
Definition: ilias.php:18
__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)
Create styles array
The data for the language used.
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.