ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPDNotesGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
6include_once("Services/Notes/classes/class.ilNote.php");
7
18{
22 protected $ctrl;
23
27 protected $user;
28
32 protected $tabs;
33
37 protected $help;
38
42 protected $settings;
43
47 protected $access;
48
52 protected $toolbar;
53
54 public $tpl;
55 public $lng;
56
57 const PUBLIC_COMMENTS = "publiccomments";
58 const PRIVATE_NOTES = "privatenotes";
59
65 public function __construct()
66 {
67 global $DIC;
68
69 $this->user = $DIC->user();
70 $this->tabs = $DIC->tabs();
71 $this->help = $DIC["ilHelp"];
72 $this->settings = $DIC->settings();
73 $this->access = $DIC->access();
74 $this->toolbar = $DIC->toolbar();
75 $tpl = $DIC["tpl"];
76 $lng = $DIC->language();
77 $ilCtrl = $DIC->ctrl();
78 $ilUser = $DIC->user();
79 $ilTabs = $DIC->tabs();
80 $ilHelp = $DIC["ilHelp"];
81
82 $ilHelp->setScreenIdComponent("note");
83
84 $lng->loadLanguageModule("notes");
85
86 // initiate variables
87 $this->tpl = $tpl;
88 $this->lng = $lng;
89 $this->ctrl = $ilCtrl;
90
91 // link from ilPDNotesBlockGUI
92 if ($_GET["rel_obj"]) {
93 $mode = ($_GET["note_type"] == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
94 $ilUser->writePref("pd_notes_mode", $mode);
95 $ilUser->writePref("pd_notes_rel_obj" . $mode, $_GET["rel_obj"]);
96 }
97 // edit link
98 elseif ($_REQUEST["note_id"]) {
99 $note = new ilNote($_REQUEST["note_id"]);
100 $mode = ($note->getType() == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
101 $obj = $note->getObject();
102 $ilUser->writePref("pd_notes_mode", $mode);
103 $ilUser->writePref("pd_notes_rel_obj" . $mode, $obj["rep_obj_id"]);
104 }
105 }
106
110 public function executeCommand()
111 {
112 $next_class = $this->ctrl->getNextClass();
113 switch ($next_class) {
114 case "ilnotegui":
115 // scorm2004-start
116 $this->setTabs();
117 // scorm2004-end
118 $this->displayHeader();
119 $this->view(); // forwardCommand is invoked in view() method
120 break;
121
122 default:
123 // scorm2004-start
124 $this->setTabs();
125 // scorm2004-end
126 $cmd = $this->ctrl->getCmd("view");
127 $this->displayHeader();
128 $this->$cmd();
129 break;
130 }
131 $this->tpl->show(true);
132 return true;
133 }
134
138 public function displayHeader()
139 {
141
142 $t = $this->lng->txt("notes");
143 if (!$ilSetting->get("disable_notes") && !$ilSetting->get("disable_comments")) {
144 $t = $this->lng->txt("notes_and_comments");
145 }
146 if ($ilSetting->get("disable_notes")) {
147 $t = $this->lng->txt("notes_comments");
148 }
149
150 $this->tpl->setTitle($t);
151
152 // catch feedback message
153 // display infopanel if something happened
155 }
156
157 /*
158 * display notes
159 */
160 public function view()
161 {
165 $ilAccess = $this->access;
166 $ilToolbar = $this->toolbar;
167
168 //$this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html")
169 include_once("Services/Notes/classes/class.ilNoteGUI.php");
170
171 // output related item selection (if more than one)
172 include_once("Services/Notes/classes/class.ilNote.php");
173 $rel_objs = ilNote::_getRelatedObjectsOfUser($this->getMode());
174 //var_dump($rel_objs);
175 // prepend personal dektop, if first object
176 // if ($rel_objs[0]["rep_obj_id"] > 0 && $this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
177 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
178 $rel_objs = array_merge(array(0), $rel_objs);
179 }
180
181 // #9410
182 if (!$rel_objs && $this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS) {
183 $lng->loadLanguageModule("notes");
184 ilUtil::sendInfo($lng->txt("msg_no_search_result"));
185 return;
186 }
187
188 $first = true;
189 foreach ($rel_objs as $r) {
190 if ($first) { // take first one as default
191 $this->current_rel_obj = $r["rep_obj_id"];
192 $current_ref_ids = $r["ref_ids"];
193 }
194 if ($r["rep_obj_id"] == $ilUser->getPref("pd_notes_rel_obj" . $this->getMode())) {
195 $this->current_rel_obj = $r["rep_obj_id"];
196 $current_ref_ids = $r["ref_ids"];
197 }
198 $first = false;
199 }
200 if ($this->current_rel_obj > 0) {
201 $notes_gui = new ilNoteGUI(
202 $this->current_rel_obj,
203 0,
204 ilObject::_lookupType($this->current_rel_obj),
205 true
206 );
207 } else {
208 $notes_gui = new ilNoteGUI(0, $ilUser->getId(), "pd");
209 }
210
211 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
212 $notes_gui->enablePrivateNotes(true);
213 $notes_gui->enablePublicNotes(false);
214 } else {
215 $notes_gui->enablePrivateNotes(false);
216 $notes_gui->enablePublicNotes(true);
217
218 // #13707
219 if ($this->current_rel_obj > 0 &&
220 sizeof($current_ref_ids) &&
221 $ilSetting->get("comments_del_tutor", 1)) {
222 foreach ($current_ref_ids as $ref_id) {
223 if ($ilAccess->checkAccess("write", "", $ref_id)) {
224 $notes_gui->enablePublicNotesDeletion(true);
225 break;
226 }
227 }
228 }
229 }
230 $notes_gui->enableHiding(false);
231 $notes_gui->enableTargets(true);
232 $notes_gui->enableMultiSelection(true);
233 $notes_gui->enableAnchorJump(false);
234
235 $next_class = $this->ctrl->getNextClass($this);
236
237 if ($next_class == "ilnotegui") {
238 $html = $this->ctrl->forwardCommand($notes_gui);
239 } else {
240 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
241 $html = $notes_gui->getOnlyNotesHTML();
242 } else {
243 $html = $notes_gui->getOnlyCommentsHTML();
244 }
245 }
246
247 if (count($rel_objs) > 1 ||
248 ($rel_objs[0]["rep_obj_id"] > 0)) {
249 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
250
251 foreach ($rel_objs as $obj) {
252 if ($obj["rep_obj_id"] > 0) {
253 $type = ilObject::_lookupType($obj["rep_obj_id"]);
254 $type_str = (in_array($type, array("lm", "htlm", "sahs")))
255 ? $lng->txt("learning_module")
256 : $lng->txt("obj_" . $type);
257 $caption = $type_str . ": " . ilObject::_lookupTitle($obj["rep_obj_id"]);
258 } else {
259 $caption = $lng->txt("personal_desktop");
260 }
261
262 $options[$obj["rep_obj_id"]] = $caption;
263 }
264
265 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
266 $rel = new ilSelectInputGUI($lng->txt("related_to"), "rel_obj");
267 $rel->setOptions($options);
268 $rel->setValue($this->current_rel_obj);
269 $ilToolbar->addStickyItem($rel);
270
272 $btn->setCaption('change');
273 $btn->setCommand('changeRelatedObject');
274 $ilToolbar->addStickyItem($btn);
275 }
276
277 $this->tpl->setContent($html);
278 }
279
283 public function changeRelatedObject()
284 {
286
287 $ilUser->writePref("pd_notes_rel_obj" . $this->getMode(), $_POST["rel_obj"]);
288 $this->ctrl->redirect($this);
289 }
290
291 // scorm2004-start
295 public function setTabs()
296 {
297 $ilTabs = $this->tabs;
300
301 if (!$ilSetting->get("disable_notes")) {
302 $ilTabs->addTarget(
303 "private_notes",
304 $ilCtrl->getLinkTarget($this, "showPrivateNotes"),
305 "",
306 "",
307 "",
308 ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
309 );
310 }
311
312 if (!$ilSetting->get("disable_comments")) {
313 $ilTabs->addTarget(
314 "notes_public_comments",
315 $ilCtrl->getLinkTarget($this, "showPublicComments"),
316 "",
317 "",
318 "",
319 ($this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS)
320 );
321 }
322 }
323
327 public function showPrivateNotes()
328 {
331
332 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
333 $ilCtrl->redirect($this, "");
334 }
335
339 public function showPublicComments()
340 {
344
345 if ($ilSetting->get("disable_comments")) {
346 $ilCtrl->redirect($this, "showPrivateNotes");
347 }
348
349 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
350 $ilCtrl->redirect($this, "");
351 }
352
356 public function getMode()
357 {
360
361 if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS &&
362 !$ilSetting->get("disable_comments")) {
364 } else {
366 }
367 }
368}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
Notes GUI class.
Note class.
static _getRelatedObjectsOfUser($a_mode)
get all related objects for user
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Private Notes on PD.
displayHeader()
display header and locator
setTabs()
Show subtabs.
__construct()
Constructor.
showPrivateNotes()
Show private notes.
executeCommand()
execute command
changeRelatedObject()
change related object
showPublicComments()
Show public comments.
getMode()
Get current mode.
This class represents a selection list property in a property form.
static getInstance()
Factory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static infoPanel($a_keep=true)
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$type
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18