ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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{
19
25 var $ilias;
26 var $tpl;
27 var $lng;
28
29 const PUBLIC_COMMENTS = "publiccomments";
30 const PRIVATE_NOTES = "privatenotes";
31
37 function __construct()
38 {
39 global $ilias, $tpl, $lng, $ilCtrl, $ilUser, $ilTabs, $ilHelp;
40
41 $ilHelp->setScreenIdComponent("note");
42
43 $lng->loadLanguageModule("notes");
44
45 // initiate variables
46 $this->ilias = $ilias;
47 $this->tpl = $tpl;
48 $this->lng = $lng;
49 $this->ctrl = $ilCtrl;
50
51 // link from ilPDNotesBlockGUI
52 if($_GET["rel_obj"])
53 {
54 $mode = ($_GET["note_type"] == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
55 $ilUser->writePref("pd_notes_mode", $mode);
56 $ilUser->writePref("pd_notes_rel_obj".$mode, $_GET["rel_obj"]);
57 }
58 // edit link
59 else if($_REQUEST["note_id"])
60 {
61 $note = new ilNote($_REQUEST["note_id"]);
62 $mode = ($note->getType() == IL_NOTE_PRIVATE) ? self::PRIVATE_NOTES : self::PUBLIC_COMMENTS;
63 $obj = $note->getObject();
64 $ilUser->writePref("pd_notes_mode", $mode);
65 $ilUser->writePref("pd_notes_rel_obj".$mode, $obj["rep_obj_id"]);
66 }
67 }
68
72 function executeCommand()
73 {
74 $next_class = $this->ctrl->getNextClass();
75 switch($next_class)
76 {
77 case "ilnotegui":
78 // scorm2004-start
79 $this->setTabs();
80 // scorm2004-end
81 $this->displayHeader();
82 $this->view(); // forwardCommand is invoked in view() method
83 break;
84
85 default:
86 // scorm2004-start
87 $this->setTabs();
88 // scorm2004-end
89 $cmd = $this->ctrl->getCmd("view");
90 $this->displayHeader();
91 $this->$cmd();
92 break;
93 }
94 $this->tpl->show(true);
95 return true;
96 }
97
101 function displayHeader()
102 {
103 global $ilSetting;
104
105 $t = $this->lng->txt("notes");
106 if (!$this->ilias->getSetting("disable_notes") && !$ilSetting->get("disable_comments"))
107 {
108 $t = $this->lng->txt("notes_and_comments");
109 }
110 if ($this->ilias->getSetting("disable_notes"))
111 {
112 $t = $this->lng->txt("notes_comments");
113 }
114
115 $this->tpl->setTitle($t);
116
117 // catch feedback message
118 // display infopanel if something happened
120
121 }
122
123 /*
124 * display notes
125 */
126 function view()
127 {
128 global $ilUser, $lng, $ilSetting, $ilAccess, $ilToolbar;
129
130 //$this->tpl->addBlockFile("ADM_CONTENT", "objects", "tpl.table.html")
131 include_once("Services/Notes/classes/class.ilNoteGUI.php");
132
133 // output related item selection (if more than one)
134 include_once("Services/Notes/classes/class.ilNote.php");
135 $rel_objs = ilNote::_getRelatedObjectsOfUser($this->getMode());
136//var_dump($rel_objs);
137 // prepend personal dektop, if first object
138// if ($rel_objs[0]["rep_obj_id"] > 0 && $this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
139 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
140 {
141
142 $rel_objs = array_merge(array(0), $rel_objs);
143 }
144
145 // #9410
146 if(!$rel_objs && $this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS)
147 {
148 $lng->loadLanguageModule("notes");
149 ilUtil::sendInfo($lng->txt("msg_no_search_result"));
150 return;
151 }
152
153 $first = true;
154 foreach ($rel_objs as $r)
155 {
156 if ($first) // take first one as default
157 {
158 $this->current_rel_obj = $r["rep_obj_id"];
159 $current_ref_ids = $r["ref_ids"];
160 }
161 if ($r["rep_obj_id"] == $ilUser->getPref("pd_notes_rel_obj".$this->getMode()))
162 {
163 $this->current_rel_obj = $r["rep_obj_id"];
164 $current_ref_ids = $r["ref_ids"];
165 }
166 $first = false;
167 }
168 if ($this->current_rel_obj > 0)
169 {
170 $notes_gui = new ilNoteGUI($this->current_rel_obj, 0,
171 ilObject::_lookupType($this->current_rel_obj),true);
172 }
173 else
174 {
175 $notes_gui = new ilNoteGUI(0, $ilUser->getId(), "pd");
176 }
177
178 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
179 {
180 $notes_gui->enablePrivateNotes(true);
181 $notes_gui->enablePublicNotes(false);
182 }
183 else
184 {
185 $notes_gui->enablePrivateNotes(false);
186 $notes_gui->enablePublicNotes(true);
187
188 // #13707
189 if ($this->current_rel_obj > 0 &&
190 sizeof($current_ref_ids) &&
191 $ilSetting->get("comments_del_tutor", 1))
192 {
193 foreach($current_ref_ids as $ref_id)
194 {
195 if($ilAccess->checkAccess("write", "", $ref_id))
196 {
197 $notes_gui->enablePublicNotesDeletion(true);
198 break;
199 }
200 }
201 }
202 }
203 $notes_gui->enableHiding(false);
204 $notes_gui->enableTargets(true);
205 $notes_gui->enableMultiSelection(true);
206 $notes_gui->enableAnchorJump(false);
207
208 $next_class = $this->ctrl->getNextClass($this);
209
210 if ($next_class == "ilnotegui")
211 {
212 $html = $this->ctrl->forwardCommand($notes_gui);
213 }
214 else
215 {
216 if ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES)
217 {
218 $html = $notes_gui->getOnlyNotesHTML();
219 }
220 else
221 {
222 $html = $notes_gui->getOnlyCommentsHTML();
223 }
224 }
225
226 if (count($rel_objs) > 1 ||
227 ($rel_objs[0]["rep_obj_id"] > 0))
228 {
229 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
230
231 foreach($rel_objs as $obj)
232 {
233 if ($obj["rep_obj_id"] > 0)
234 {
235 $type = ilObject::_lookupType($obj["rep_obj_id"]);
236 $type_str = (in_array($type, array("lm", "htlm", "sahs")))
237 ? $lng->txt("learning_resource")
238 : $lng->txt("obj_".$type);
239 $caption = $type_str.": ".ilObject::_lookupTitle($obj["rep_obj_id"]);
240 }
241 else
242 {
243 $caption = $lng->txt("personal_desktop");
244 }
245
246 $options[$obj["rep_obj_id"]] = $caption;
247 }
248
249 include_once "Services/Form/classes/class.ilSelectInputGUI.php";
250 $rel = new ilSelectInputGUI($lng->txt("related_to"), "rel_obj");
251 $rel->setOptions($options);
252 $rel->setValue($this->current_rel_obj);
253 $ilToolbar->addInputItem($rel);
254
255 $ilToolbar->addFormButton($lng->txt("change"), "changeRelatedObject");
256 }
257
258 $this->tpl->setContent($html);
259 }
260
265 {
266 global $ilUser;
267
268 $ilUser->writePref("pd_notes_rel_obj".$this->getMode(), $_POST["rel_obj"]);
269 $this->ctrl->redirect($this);
270 }
271
272 // scorm2004-start
276 function setTabs()
277 {
278 global $ilTabs, $ilSetting, $ilCtrl;
279
280 if(!$ilSetting->get("disable_notes"))
281 {
282 $ilTabs->addTarget("private_notes",
283 $ilCtrl->getLinkTarget($this, "showPrivateNotes"), "", "", "",
284 ($this->getMode() == ilPDNotesGUI::PRIVATE_NOTES));
285 }
286
287 if(!$ilSetting->get("disable_comments"))
288 {
289 $ilTabs->addTarget("notes_public_comments",
290 $ilCtrl->getLinkTarget($this, "showPublicComments"), "", "", "",
291 ($this->getMode() == ilPDNotesGUI::PUBLIC_COMMENTS));
292 }
293 }
294
299 {
300 global $ilUser, $ilCtrl;
301
302 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
303 $ilCtrl->redirect($this, "");
304 }
305
310 {
311 global $ilUser, $ilCtrl, $ilSetting;
312
313 if($ilSetting->get("disable_comments"))
314 {
315 $ilCtrl->redirect($this, "showPrivateNotes");
316 }
317
318 $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
319 $ilCtrl->redirect($this, "");
320 }
321
325 function getMode()
326 {
327 global $ilUser, $ilSetting;
328
329 if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS &&
330 !$ilSetting->get("disable_comments"))
331 {
333 }
334 else
335 {
337 }
338 }
339}
340?>
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
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 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
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18