ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCommonActionDispatcherGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
17  protected $obj_type; // [string]
18  protected $node_id; // [int]
19  protected $node_type; // [string]
20  protected $obj_id; // [int]
21  protected $sub_type; // [string]
22  protected $sub_id; // [int]
23  protected $enable_comments_settings; // [bool]
24  protected $rating_callback; // [array]
25 
26  const TYPE_REPOSITORY = 1;
27  const TYPE_WORKSPACE = 2;
28 
39  function __construct($a_node_type, $a_access_handler, $a_obj_type, $a_node_id, $a_obj_id)
40  {
41  $this->node_type = (int)$a_node_type;
42  $this->access_handler = $a_access_handler;
43  $this->obj_type = (string)$a_obj_type;
44  $this->node_id = (int)$a_node_id;
45  $this->obj_id = (int)$a_obj_id;
46  }
47 
53  function getAjaxHash()
54  {
55  return self::buildAjaxHash($this->node_type, $this->node_id, $this->obj_type,
56  $this->obj_id, $this->sub_type, $this->sub_id);
57  }
58 
70  static function buildAjaxHash($a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type = null, $a_sub_id = null)
71  {
72  return $a_node_type.";".$a_node_id.";".$a_obj_type.";".
73  $a_obj_id.";".$a_sub_type.";".$a_sub_id;
74  }
75 
81  static function getInstanceFromAjaxCall()
82  {
83  global $ilAccess, $ilUser;
84 
85  if(isset($_GET["cadh"]))
86  {
87  $parts = explode(";", (string)$_GET["cadh"]);
88 
89  $node_type = $parts[0];
90  $node_id = $parts[1];
91  $obj_type = $parts[2];
92  $obj_id = $parts[3];
93  $sub_type = $parts[4];
94  $sub_id = $parts[5];
95 
96  switch($node_type)
97  {
98  case self::TYPE_REPOSITORY:
99  $access_handler = $ilAccess;
100  break;
101 
102  case self::TYPE_WORKSPACE:
103  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
104  $tree = new ilWorkspaceTree($ilUser->getId());
105  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
106  $access_handler = new ilWorkspaceAccessHandler($tree);
107  break;
108 
109  default:
110  return null;
111  }
112 
113  $dispatcher = new self($node_type, $access_handler, $obj_type, $node_id, $obj_id);
114 
115  if($sub_type && $sub_id)
116  {
117  $dispatcher->setSubObject($sub_type, $sub_id);
118  }
119 
120  // poll comments have specific settings
121 
122  if($node_type == self::TYPE_REPOSITORY && $obj_type != "poll")
123  {
124  $dispatcher->enableCommentsSettings(true);
125  }
126 
127  return $dispatcher;
128  }
129  }
130 
131  function executeCommand()
132  {
133  global $ilCtrl, $ilSetting;
134 
135  // check access for object
136  if ($this->node_id &&
137  !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
138  !$this->access_handler->checkAccess("read", "", $this->node_id))
139  {
140  exit();
141  }
142 
143  $next_class = $ilCtrl->getNextClass($this);
144  $cmd = $ilCtrl->getCmd();
145 
146  $ilCtrl->saveParameter($this, "cadh");
147 
148  switch($next_class)
149  {
150  case "ilnotegui":
151 
153  if($this->sub_type)
154  {
156  }
157 
158  include_once "Services/Notes/classes/class.ilNoteGUI.php";
159  $note_gui = new ilNoteGUI($this->obj_id, $this->sub_id, $obj_type);
160  $note_gui->enablePrivateNotes(true);
161 
162  $has_write = $this->access_handler->checkAccess("write", "", $this->node_id);
163  if($has_write && $ilSetting->get("comments_del_tutor", 1))
164  {
165  $note_gui->enablePublicNotesDeletion(true);
166  }
167 
168  // comments cannot be turned off globally
169  if($this->enable_comments_settings)
170  {
171  // should only be shown if active or permission to toggle
172  if($has_write ||
173  $this->access_handler->checkAccess("edit_permissions", "", $this->node_id))
174  {
175  $note_gui->enableCommentsSettings();
176  }
177  }
178  /* this is different to the info screen but we need this
179  for sub-object action menus, e.g. wiki page */
180  else if($this->sub_id)
181  {
182  $note_gui->enablePublicNotes(true);
183  }
184 
185  $ilCtrl->forwardCommand($note_gui);
186  break;
187 
188  case "iltagginggui":
189  include_once "Services/Tagging/classes/class.ilTaggingGUI.php";
190  $tags_gui = new ilTaggingGUI($this->node_id);
191  $tags_gui->setObject($this->obj_id, $this->obj_type);
192  $ilCtrl->forwardCommand($tags_gui);
193  break;
194 
195  case "ilobjectactivationgui":
196  $ilCtrl->setParameter($this, "parent_id", (int)$_REQUEST['parent_id']);
197  include_once 'Services/Object/classes/class.ilObjectActivationGUI.php';
198  $act_gui = new ilObjectActivationGUI((int)$_REQUEST['parent_id'],$this->node_id);
199  $ilCtrl->forwardCommand($act_gui);
200  break;
201 
202  case "ilratinggui":
203  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
204  $rating_gui = new ilRatingGUI();
205  if(!$_GET["rnsb"])
206  {
207  $rating_gui->setObject($this->obj_id, $this->obj_type, $this->sub_id, $this->sub_type);
208  }
209  else
210  {
211  // coming from headaction ignore sub-objects
212  $rating_gui->setObject($this->obj_id, $this->obj_type);
213  }
214  $ilCtrl->forwardCommand($rating_gui);
215  if($this->rating_callback)
216  {
217  // as rating in categories is form-based we need to redirect
218  // somewhere after saving
219  $ilCtrl->redirect($this->rating_callback[0], $this->rating_callback[1]);
220  }
221  break;
222 
223  default:
224  break;
225  }
226 
227  exit();
228  }
229 
236  function setSubObject($a_sub_obj_type, $a_sub_obj_id)
237  {
238  $this->sub_type = (string)$a_sub_obj_type;
239  $this->sub_id = (int)$a_sub_obj_id;
240  }
241 
247  function enableCommentsSettings($a_value)
248  {
249  $this->enable_comments_settings = (bool)$a_value;
250  }
251 
258  function setRatingCallback($a_gui, $a_cmd)
259  {
260  $this->rating_callback = array($a_gui, $a_cmd);
261  }
262 
266  function initHeaderAction()
267  {
268  // check access for object
269  if ($this->node_id &&
270  !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
271  !$this->access_handler->checkAccess("read", "", $this->node_id))
272  {
273  return;
274  }
275 
276  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
277  $this->header_action = ilObjectListGUIFactory::_getListGUIByType(
278  $this->obj_type,
279  ($this->node_type == self::TYPE_REPOSITORY)
282  );
283 
284  // remove all currently unwanted actions
285  $this->header_action->enableCopy(false);
286  $this->header_action->enableCut(false);
287  $this->header_action->enableDelete(false);
288  $this->header_action->enableLink(false);
289  $this->header_action->enableInfoscreen(false);
290  $this->header_action->enableTimings(false);
291  $this->header_action->enableSubscribe($this->node_type == self::TYPE_REPOSITORY);
292 
293  $this->header_action->initItem($this->node_id, $this->obj_id);
294  $this->header_action->setHeaderSubObject($this->sub_type, $this->sub_id);
295  $this->header_action->setAjaxHash($this->getAjaxHash());
296 
297  return $this->header_action;
298  }
299 }
300 
301 ?>
enableCommentsSettings($a_value)
Toggle comments settings.
$_GET["client_id"]
Class ilTaggingGUI.
$cmd
Definition: sahs_server.php:35
Access handler for personal workspace.
Add rich text string
The name of the decorator.
Tree handler for personal workspace.
Class ilObjectActivationGUI.
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
setRatingCallback($a_gui, $a_cmd)
Add callback for rating gui.
Class ilRatingGUI.
__construct($a_node_type, $a_access_handler, $a_obj_type, $a_node_id, $a_obj_id)
Constructor.
static buildAjaxHash($a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type=null, $a_sub_id=null)
Build ajax hash.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
global $ilSetting
Definition: privfeed.php:17
getAjaxHash()
Build ajax hash for current (object/node) properties.
Class ilCommonActionDispatcherGUI.
setSubObject($a_sub_obj_type, $a_sub_obj_id)
Set sub object attributes.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call