ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
6 include_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  {
163  $lng = $this->lng;
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_resource")
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->addInputItem($rel);
270 
271  $ilToolbar->addFormButton($lng->txt("change"), "changeRelatedObject");
272  }
273 
274  $this->tpl->setContent($html);
275  }
276 
280  public function changeRelatedObject()
281  {
283 
284  $ilUser->writePref("pd_notes_rel_obj" . $this->getMode(), $_POST["rel_obj"]);
285  $this->ctrl->redirect($this);
286  }
287 
288  // scorm2004-start
292  public function setTabs()
293  {
294  $ilTabs = $this->tabs;
297 
298  if (!$ilSetting->get("disable_notes")) {
299  $ilTabs->addTarget(
300  "private_notes",
301  $ilCtrl->getLinkTarget($this, "showPrivateNotes"),
302  "",
303  "",
304  "",
306  );
307  }
308 
309  if (!$ilSetting->get("disable_comments")) {
310  $ilTabs->addTarget(
311  "notes_public_comments",
312  $ilCtrl->getLinkTarget($this, "showPublicComments"),
313  "",
314  "",
315  "",
317  );
318  }
319  }
320 
324  public function showPrivateNotes()
325  {
328 
329  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PRIVATE_NOTES);
330  $ilCtrl->redirect($this, "");
331  }
332 
336  public function showPublicComments()
337  {
341 
342  if ($ilSetting->get("disable_comments")) {
343  $ilCtrl->redirect($this, "showPrivateNotes");
344  }
345 
346  $ilUser->writePref("pd_notes_mode", ilPDNotesGUI::PUBLIC_COMMENTS);
347  $ilCtrl->redirect($this, "");
348  }
349 
353  public function getMode()
354  {
357 
358  if ($ilUser->getPref("pd_notes_mode") == ilPDNotesGUI::PUBLIC_COMMENTS &&
359  !$ilSetting->get("disable_comments")) {
361  } else {
363  }
364  }
365 }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
This class represents a selection list property in a property form.
executeCommand()
execute command
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
Private Notes on PD.
showPublicComments()
Show public comments.
static _lookupTitle($a_id)
lookup object title
changeRelatedObject()
change related object
user()
Definition: user.php:4
Note class.
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
__construct()
Constructor.
$r
Definition: example_031.php:79
setTabs()
Show subtabs.
static infoPanel($a_keep=true)
$ilUser
Definition: imgupload.php:18
static _getRelatedObjectsOfUser($a_mode)
get all related objects for user
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
displayHeader()
display header and locator
settings()
Definition: settings.php:2
getMode()
Get current mode.
global $ilSetting
Definition: privfeed.php:17
enablePrivateNotes($a_enable=true)
enable private notes
$_POST["username"]
$html
Definition: example_001.php:87
showPrivateNotes()
Show private notes.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20