ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
37 protected $news_id = 0;
38
39 protected $enable_comments_settings; // [bool]
40 protected $rating_callback; // [array]
41
42 const TYPE_REPOSITORY = 1;
43 const TYPE_WORKSPACE = 2;
44
55 public function __construct($a_node_type, $a_access_handler, $a_obj_type, $a_node_id, $a_obj_id, $a_news_id = 0)
56 {
57 global $DIC;
58
59 $this->ctrl = $DIC->ctrl();
60 $this->settings = $DIC->settings();
61 $this->node_type = (int) $a_node_type;
62 $this->access_handler = $a_access_handler;
63 $this->obj_type = (string) $a_obj_type;
64 $this->node_id = (int) $a_node_id;
65 $this->obj_id = (int) $a_obj_id;
66 $this->news_id = (int) $a_news_id;
67 }
68
74 public function getAjaxHash()
75 {
77 $this->node_type,
78 $this->node_id,
79 $this->obj_type,
80 $this->obj_id,
81 $this->sub_type,
82 $this->sub_id,
83 $this->news_id
84 );
85 }
86
98 public static function buildAjaxHash(
99 $a_node_type,
100 $a_node_id,
101 $a_obj_type,
102 $a_obj_id,
103 $a_sub_type = null,
104 $a_sub_id = null,
105 $a_news_id = 0
106 ) {
107 return $a_node_type . ";" . $a_node_id . ";" . $a_obj_type . ";" .
108 $a_obj_id . ";" . $a_sub_type . ";" . $a_sub_id . ";" . $a_news_id;
109 }
110
116 public static function getInstanceFromAjaxCall()
117 {
118 global $DIC;
119
120 $ilAccess = $DIC->access();
121 $ilUser = $DIC->user();
122 if (isset($_GET["cadh"])) {
123 $parts = explode(";", (string) $_GET["cadh"]);
124
125 $node_type = $parts[0];
126 $node_id = $parts[1];
127 $obj_type = $parts[2];
128 $obj_id = $parts[3];
129 $sub_type = $parts[4];
130 $sub_id = $parts[5];
131 $news_id = $parts[6];
132
133 switch ($node_type) {
135 $access_handler = $ilAccess;
136 break;
137
139 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
140 $tree = new ilWorkspaceTree($ilUser->getId());
141 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
142 $access_handler = new ilWorkspaceAccessHandler($tree);
143 break;
144
145 default:
146 return null;
147 }
148
149 $dispatcher = new self($node_type, $access_handler, $obj_type, $node_id, $obj_id, $news_id);
150
151 if ($sub_type && $sub_id) {
152 $dispatcher->setSubObject($sub_type, $sub_id);
153 }
154
155 // poll comments have specific settings
156
157 if ($node_type == self::TYPE_REPOSITORY && $obj_type != "poll") {
158 $dispatcher->enableCommentsSettings(true);
159 }
160
161 return $dispatcher;
162 }
163 }
164
165 public function executeCommand()
166 {
169
170 // check access for object
171 if ($this->node_id &&
172 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
173 !$this->access_handler->checkAccess("read", "", $this->node_id)) {
174 exit();
175 }
176
177 $next_class = $ilCtrl->getNextClass($this);
178 $cmd = $ilCtrl->getCmd();
179
180 $ilCtrl->saveParameter($this, "cadh");
181
182 switch ($next_class) {
183 case "ilnotegui":
184
186 if ($this->sub_type) {
188 }
189
190 include_once "Services/Notes/classes/class.ilNoteGUI.php";
191 $note_gui = new ilNoteGUI($this->obj_id, $this->sub_id, $obj_type, false, $this->news_id);
192 $note_gui->enablePrivateNotes(true);
193
194 $has_write = $this->access_handler->checkAccess("write", "", $this->node_id);
195 if ($has_write && $ilSetting->get("comments_del_tutor", 1)) {
196 $note_gui->enablePublicNotesDeletion(true);
197 }
198
199 // comments cannot be turned off globally
200 if ($this->enable_comments_settings) {
201 // should only be shown if active or permission to toggle
202 if ($has_write ||
203 $this->access_handler->checkAccess("edit_permissions", "", $this->node_id)) {
204 $note_gui->enableCommentsSettings();
205 }
206 }
207 /* this is different to the info screen but we need this
208 for sub-object action menus, e.g. wiki page */
209 elseif ($this->sub_id) {
210 $note_gui->enablePublicNotes(true);
211 }
212
213 $ilCtrl->forwardCommand($note_gui);
214 break;
215
216 case "iltagginggui":
217 include_once "Services/Tagging/classes/class.ilTaggingGUI.php";
218 $tags_gui = new ilTaggingGUI($this->node_id);
219 $tags_gui->setObject($this->obj_id, $this->obj_type);
220 $ilCtrl->forwardCommand($tags_gui);
221 break;
222
223 case "ilobjectactivationgui":
224 $ilCtrl->setParameter($this, "parent_id", (int) $_REQUEST['parent_id']);
225 include_once 'Services/Object/classes/class.ilObjectActivationGUI.php';
226 $act_gui = new ilObjectActivationGUI((int) $_REQUEST['parent_id'], $this->node_id);
227 $ilCtrl->forwardCommand($act_gui);
228 break;
229
230 case "ilratinggui":
231 include_once("./Services/Rating/classes/class.ilRatingGUI.php");
232 $rating_gui = new ilRatingGUI();
233 if (!$_GET["rnsb"]) {
234 $rating_gui->setObject($this->obj_id, $this->obj_type, $this->sub_id, $this->sub_type);
235 } else {
236 // coming from headaction ignore sub-objects
237 $rating_gui->setObject($this->obj_id, $this->obj_type);
238 }
239 $ilCtrl->forwardCommand($rating_gui);
240 if ($this->rating_callback) {
241 // as rating in categories is form-based we need to redirect
242 // somewhere after saving
243 $ilCtrl->redirect($this->rating_callback[0], $this->rating_callback[1]);
244 }
245 break;
246
247 default:
248 break;
249 }
250
251 exit();
252 }
253
260 public function setSubObject($a_sub_obj_type, $a_sub_obj_id)
261 {
262 $this->sub_type = (string) $a_sub_obj_type;
263 $this->sub_id = (int) $a_sub_obj_id;
264 }
265
271 public function enableCommentsSettings($a_value)
272 {
273 $this->enable_comments_settings = (bool) $a_value;
274 }
275
282 public function setRatingCallback($a_gui, $a_cmd)
283 {
284 $this->rating_callback = array($a_gui, $a_cmd);
285 }
286
290 public function initHeaderAction()
291 {
292 // check access for object
293 if ($this->node_id &&
294 !$this->access_handler->checkAccess("visible", "", $this->node_id) &&
295 !$this->access_handler->checkAccess("read", "", $this->node_id)) {
296 return;
297 }
298
299 include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
300 $this->header_action = ilObjectListGUIFactory::_getListGUIByType(
301 $this->obj_type,
302 ($this->node_type == self::TYPE_REPOSITORY)
305 );
306
307 // remove all currently unwanted actions
308 $this->header_action->enableCopy(false);
309 $this->header_action->enableCut(false);
310 $this->header_action->enableDelete(false);
311 $this->header_action->enableLink(false);
312 $this->header_action->enableInfoscreen(false);
313 $this->header_action->enableTimings(false);
314 $this->header_action->enableSubscribe($this->node_type == self::TYPE_REPOSITORY);
315
316 $this->header_action->initItem($this->node_id, $this->obj_id, $this->obj_type);
317 $this->header_action->setHeaderSubObject($this->sub_type, $this->sub_id);
318 $this->header_action->setAjaxHash($this->getAjaxHash());
319
320 return $this->header_action;
321 }
322}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
Class ilCommonActionDispatcherGUI.
static buildAjaxHash( $a_node_type, $a_node_id, $a_obj_type, $a_obj_id, $a_sub_type=null, $a_sub_id=null, $a_news_id=0)
Build ajax hash.
__construct($a_node_type, $a_access_handler, $a_obj_type, $a_node_id, $a_obj_id, $a_news_id=0)
Constructor.
getAjaxHash()
Build ajax hash for current (object/node) properties.
setRatingCallback($a_gui, $a_cmd)
Add callback for rating gui.
setSubObject($a_sub_obj_type, $a_sub_obj_id)
Set sub object attributes.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
enableCommentsSettings($a_value)
Toggle comments settings.
Notes GUI class.
Class ilObjectActivationGUI.
static _getListGUIByType($a_type, $a_context=ilObjectListGUI::CONTEXT_REPOSITORY)
Class ilRatingGUI.
Class ilTaggingGUI.
Access handler for personal workspace.
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:29
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46