ILIAS  release_7 Revision v7.30-3-g800a261c036
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->printToStdout(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 if ($this->getMode() == self::PRIVATE_NOTES) {
151 $t = $this->lng->txt("private_notes");
152 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_nots.svg"));
153 } else {
154 $t = $this->lng->txt("notes_public_comments");
155 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_coms.svg"));
156 }
157
158 $this->tpl->setTitle($t);
159
160 // catch feedback message
161 // display infopanel if something happened
163 }
164
165 /*
166 * display notes
167 */
168 public function view()
169 {
173 $ilAccess = $this->access;
174 $ilToolbar = $this->toolbar;
175
176 //$this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html")
177 include_once("Services/Notes/classes/class.ilNoteGUI.php");
178
179 // output related item selection (if more than one)
180 include_once("Services/Notes/classes/class.ilNote.php");
181 $rel_objs = ilNote::_getRelatedObjectsOfUser($this->getMode());
182 //var_dump($rel_objs);
183 // prepend personal dektop, if first object
184 // if ($rel_objs[0]["rep_obj_id"] > 0 && $this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
185 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
186 $rel_objs = array_merge(array(0), $rel_objs);
187 }
188
189 // #9410
190 if (!$rel_objs && $this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS) {
191 $lng->loadLanguageModule("notes");
192 ilUtil::sendInfo($lng->txt("msg_no_search_result"));
193 return;
194 }
195
196 $first = true;
197 $current_ref_ids = [];
198 foreach ($rel_objs as $r) {
199 if ($first) { // take first one as default
200 $this->current_rel_obj = $r["rep_obj_id"];
201 $current_ref_ids = $r["ref_ids"];
202 }
203 if ($r["rep_obj_id"] == $ilUser->getPref("pd_notes_rel_obj" . $this->getMode())) {
204 $this->current_rel_obj = $r["rep_obj_id"];
205 $current_ref_ids = $r["ref_ids"];
206 }
207 $first = false;
208 }
209 if ($this->current_rel_obj > 0) {
210 $notes_gui = new ilNoteGUI(
211 $this->current_rel_obj,
212 0,
213 ilObject::_lookupType($this->current_rel_obj),
214 true,
215 0,
216 false
217 );
218 } else {
219 $notes_gui = new ilNoteGUI(0, $ilUser->getId(), "pd", false, 0, false);
220 }
221
222 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
223 $notes_gui->enablePrivateNotes(true);
224 $notes_gui->enablePublicNotes(false);
225 } else {
226 $notes_gui->enablePrivateNotes(false);
227 $notes_gui->enablePublicNotes(true);
228 // #13707
229 if ($this->current_rel_obj > 0 &&
230 count($current_ref_ids) > 0 &&
231 $ilSetting->get("comments_del_tutor", 1)) {
232 foreach ($current_ref_ids as $ref_id) {
233 if ($ilAccess->checkAccess("write", "", $ref_id)) {
234 $notes_gui->enablePublicNotesDeletion(true);
235 break;
236 }
237 }
238 }
239 }
240 $notes_gui->enableHiding(false);
241 $notes_gui->enableTargets(true);
242 $notes_gui->enableMultiSelection(true);
243 $notes_gui->enableAnchorJump(false);
244
245 $next_class = $this->ctrl->getNextClass($this);
246
247 if ($next_class == "ilnotegui") {
248 $html = $this->ctrl->forwardCommand($notes_gui);
249 } else {
250 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES) {
251 $html = $notes_gui->getOnlyNotesHTML();
252 } else {
253 $html = $notes_gui->getOnlyCommentsHTML();
254 }
255 }
256
257 if (count($rel_objs) > 1 ||
258 ($rel_objs[0]["rep_obj_id"] > 0)) {
259 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
260
261 foreach ($rel_objs as $obj) {
262 if ($obj["rep_obj_id"] > 0) {
263 $type = ilObject::_lookupType($obj["rep_obj_id"]);
264 $type_str = (in_array($type, array("lm", "htlm", "sahs")))
265 ? $lng->txt("obj_lm")
266 : $lng->txt("obj_" . $type);
267 $caption = $type_str . ": " . ilObject::_lookupTitle($obj["rep_obj_id"]);
268 } else {
269 $caption = $lng->txt("note_without_object");
270 }
271
272 $options[$obj["rep_obj_id"]] = $caption;
273 }
274
275 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
276 $rel = new ilSelectInputGUI($lng->txt("related_to"), "rel_obj");
277 $rel->setOptions($options);
278 $rel->setValue($this->current_rel_obj);
279 $ilToolbar->addStickyItem($rel);
280
282 $btn->setCaption('change');
283 $btn->setCommand('changeRelatedObject');
284 $ilToolbar->addStickyItem($btn);
285 }
286
287 $this->tpl->setContent($html);
288 }
289
293 public function changeRelatedObject()
294 {
296
297 $ilUser->writePref("pd_notes_rel_obj" . $this->getMode(), $_POST["rel_obj"]);
298 $this->ctrl->redirect($this);
299 }
300
301 // scorm2004-start
305 public function setTabs()
306 {
307 $ilTabs = $this->tabs;
309 $ilCtrl = $this->ctrl;
310
311 /*
312 if(!$ilSetting->get("disable_notes"))
313 {
314 $ilTabs->addTarget("private_notes",
315 $ilCtrl->getLinkTarget($this, "showPrivateNotes"), "", "", "",
316 ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES));
317 }
318
319 if(!$ilSetting->get("disable_comments"))
320 {
321 $ilTabs->addTarget("notes_public_comments",
322 $ilCtrl->getLinkTarget($this, "showPublicComments"), "", "", "",
323 ($this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS));
324 }*/
325 }
326
330 public function showPrivateNotes()
331 {
333 $ilCtrl = $this->ctrl;
334
335 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
336 $ilCtrl->redirect($this, "");
337 }
338
342 public function showPublicComments()
343 {
345 $ilCtrl = $this->ctrl;
347
348 if ($ilSetting->get("disable_comments")) {
349 $ilCtrl->redirect($this, "showPrivateNotes");
350 }
351
352 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
353 $ilCtrl->redirect($this, "");
354 }
355
359 public function getMode()
360 {
363
364 if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS &&
365 !$ilSetting->get("disable_comments")) {
367 } else {
369 }
370 }
371}
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 getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
global $ilSetting
Definition: privfeed.php:17
$type
settings()
Definition: settings.php:2