ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
20  protected $ctrl;
21 
25  protected $settings;
26 
27  protected $obj_type; // [string]
28  protected $node_id; // [int]
29  protected $node_type; // [string]
30  protected $obj_id; // [int]
31  protected $sub_type; // [string]
32  protected $sub_id; // [int]
33  protected $enable_comments_settings; // [bool]
34  protected $rating_callback; // [array]
35 
36  const TYPE_REPOSITORY = 1;
37  const TYPE_WORKSPACE = 2;
38 
49  public function __construct($a_node_type, $a_access_handler, $a_obj_type, $a_node_id, $a_obj_id)
50  {
51  global $DIC;
52 
53  $this->ctrl = $DIC->ctrl();
54  $this->settings = $DIC->settings();
55  $this->node_type = (int) $a_node_type;
56  $this->access_handler = $a_access_handler;
57  $this->obj_type = (string) $a_obj_type;
58  $this->node_id = (int) $a_node_id;
59  $this->obj_id = (int) $a_obj_id;
60  }
61 
67  public function getAjaxHash()
68  {
69  return self::buildAjaxHash(
70  $this->node_type,
71  $this->node_id,
72  $this->obj_type,
73  $this->obj_id,
74  $this->sub_type,
75  $this->sub_id
76  );
77  }
78 
90  public static function buildAjaxHash($a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type = null, $a_sub_id = null)
91  {
92  return $a_node_type . ";" . $a_node_id . ";" . $a_obj_type . ";" .
93  $a_obj_id . ";" . $a_sub_type . ";" . $a_sub_id;
94  }
95 
101  public static function getInstanceFromAjaxCall()
102  {
103  global $DIC;
104 
105  $ilAccess = $DIC->access();
106  $ilUser = $DIC->user();
107 
108  if (isset($_GET["cadh"])) {
109  $parts = explode(";", (string) $_GET["cadh"]);
110 
111  $node_type = $parts[0];
112  $node_id = $parts[1];
113  $obj_type = $parts[2];
114  $obj_id = $parts[3];
115  $sub_type = $parts[4];
116  $sub_id = $parts[5];
117 
118  switch ($node_type) {
119  case self::TYPE_REPOSITORY:
120  $access_handler = $ilAccess;
121  break;
122 
123  case self::TYPE_WORKSPACE:
124  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
125  $tree = new ilWorkspaceTree($ilUser->getId());
126  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
127  $access_handler = new ilWorkspaceAccessHandler($tree);
128  break;
129 
130  default:
131  return null;
132  }
133 
134  $dispatcher = new self($node_type, $access_handler, $obj_type, $node_id, $obj_id);
135 
136  if ($sub_type && $sub_id) {
137  $dispatcher->setSubObject($sub_type, $sub_id);
138  }
139 
140  // poll comments have specific settings
141 
142  if ($node_type == self::TYPE_REPOSITORY && $obj_type != "poll") {
143  $dispatcher->enableCommentsSettings(true);
144  }
145 
146  return $dispatcher;
147  }
148  }
149 
150  public function executeCommand()
151  {
154 
155  // check access for object
156  if ($this->node_id &&
157  !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
158  !$this->access_handler->checkAccess("read", "", $this->node_id)) {
159  exit();
160  }
161 
162  $next_class = $ilCtrl->getNextClass($this);
163  $cmd = $ilCtrl->getCmd();
164 
165  $ilCtrl->saveParameter($this, "cadh");
166 
167  switch ($next_class) {
168  case "ilnotegui":
169 
171  if ($this->sub_type) {
173  }
174 
175  include_once "Services/Notes/classes/class.ilNoteGUI.php";
176  $note_gui = new ilNoteGUI($this->obj_id, $this->sub_id, $obj_type);
177  $note_gui->enablePrivateNotes(true);
178 
179  $has_write = $this->access_handler->checkAccess("write", "", $this->node_id);
180  if ($has_write && $ilSetting->get("comments_del_tutor", 1)) {
181  $note_gui->enablePublicNotesDeletion(true);
182  }
183 
184  // comments cannot be turned off globally
185  if ($this->enable_comments_settings) {
186  // should only be shown if active or permission to toggle
187  if ($has_write ||
188  $this->access_handler->checkAccess("edit_permissions", "", $this->node_id)) {
189  $note_gui->enableCommentsSettings();
190  }
191  }
192  /* this is different to the info screen but we need this
193  for sub-object action menus, e.g. wiki page */
194  elseif ($this->sub_id) {
195  $note_gui->enablePublicNotes(true);
196  }
197 
198  $ilCtrl->forwardCommand($note_gui);
199  break;
200 
201  case "iltagginggui":
202  include_once "Services/Tagging/classes/class.ilTaggingGUI.php";
203  $tags_gui = new ilTaggingGUI($this->node_id);
204  $tags_gui->setObject($this->obj_id, $this->obj_type);
205  $ilCtrl->forwardCommand($tags_gui);
206  break;
207 
208  case "ilobjectactivationgui":
209  $ilCtrl->setParameter($this, "parent_id", (int) $_REQUEST['parent_id']);
210  include_once 'Services/Object/classes/class.ilObjectActivationGUI.php';
211  $act_gui = new ilObjectActivationGUI((int) $_REQUEST['parent_id'], $this->node_id);
212  $ilCtrl->forwardCommand($act_gui);
213  break;
214 
215  case "ilratinggui":
216  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
217  $rating_gui = new ilRatingGUI();
218  if (!$_GET["rnsb"]) {
219  $rating_gui->setObject($this->obj_id, $this->obj_type, $this->sub_id, $this->sub_type);
220  } else {
221  // coming from headaction ignore sub-objects
222  $rating_gui->setObject($this->obj_id, $this->obj_type);
223  }
224  $ilCtrl->forwardCommand($rating_gui);
225  if ($this->rating_callback) {
226  // as rating in categories is form-based we need to redirect
227  // somewhere after saving
228  $ilCtrl->redirect($this->rating_callback[0], $this->rating_callback[1]);
229  }
230  break;
231 
232  default:
233  break;
234  }
235 
236  exit();
237  }
238 
245  public function setSubObject($a_sub_obj_type, $a_sub_obj_id)
246  {
247  $this->sub_type = (string) $a_sub_obj_type;
248  $this->sub_id = (int) $a_sub_obj_id;
249  }
250 
256  public function enableCommentsSettings($a_value)
257  {
258  $this->enable_comments_settings = (bool) $a_value;
259  }
260 
267  public function setRatingCallback($a_gui, $a_cmd)
268  {
269  $this->rating_callback = array($a_gui, $a_cmd);
270  }
271 
275  public function initHeaderAction()
276  {
277  // check access for object
278  if ($this->node_id &&
279  !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
280  !$this->access_handler->checkAccess("read", "", $this->node_id)) {
281  return;
282  }
283 
284  include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
285  $this->header_action = ilObjectListGUIFactory::_getListGUIByType(
286  $this->obj_type,
287  ($this->node_type == self::TYPE_REPOSITORY)
290  );
291 
292  // remove all currently unwanted actions
293  $this->header_action->enableCopy(false);
294  $this->header_action->enableCut(false);
295  $this->header_action->enableDelete(false);
296  $this->header_action->enableLink(false);
297  $this->header_action->enableInfoscreen(false);
298  $this->header_action->enableTimings(false);
299  $this->header_action->enableSubscribe($this->node_type == self::TYPE_REPOSITORY);
300 
301  $this->header_action->initItem($this->node_id, $this->obj_id);
302  $this->header_action->setHeaderSubObject($this->sub_type, $this->sub_id);
303  $this->header_action->setAjaxHash($this->getAjaxHash());
304 
305  return $this->header_action;
306  }
307 }
Add rich text string
enableCommentsSettings($a_value)
Toggle comments settings.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
Class ilTaggingGUI.
Access handler for personal workspace.
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.
settings()
Definition: settings.php:2
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