ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilNoteGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once ("Services/Notes/classes/class.ilNote.php");
7 
8 
18 class ilNoteGUI
19 {
21  var $repository_mode = false;
22  var $old = false;
23 
32  function __construct($a_rep_obj_id = "", $a_obj_id = "", $a_obj_type = "", $a_include_subobjects = false)
33  {
34  global $ilCtrl, $lng;
35 
36  $lng->loadLanguageModule("notes");
37 
38  $ilCtrl->saveParameter($this, "notes_only");
39  $this->only = $_GET["notes_only"];
40 
41  $this->rep_obj_id = $a_rep_obj_id;
42  $this->obj_id = $a_obj_id;
43  $this->obj_type = $a_obj_type;
44  $this->inc_sub = $a_include_subobjects;
45 
46  // auto-detect object type
47  if(!$this->obj_type && $a_rep_obj_id)
48  {
49  $this->obj_type = ilObject::_lookupType($a_rep_obj_id);
50  }
51 
52  $this->ajax = $ilCtrl->isAsynch();
53 
54  $this->ctrl = $ilCtrl;
55  $this->lng = $lng;
56 
57  $this->anchor_jump = true;
58  $this->add_note_form = false;
59  $this->edit_note_form = false;
60  $this->private_enabled = false;
61  $notes_settings = new ilSetting("notes");
62  $id = $this->rep_obj_id."_".$this->obj_id."_".$this->obj_type;
63  //if ($notes_settings->get("activate_".$id))
64  if (ilNote::commentsActivated($this->rep_obj_id, $this->obj_id, $this->obj_type))
65  {
66  $this->public_enabled = true;
67  }
68  else
69  {
70  $this->public_enabled = false;
71  }
72  $this->enable_hiding = false;
73  $this->targets_enabled = false;
74  $this->multi_selection = false;
75  $this->export_html = false;
76  $this->print = false;
77  $this->comments_settings = false;
78 
79  $this->note_img = array(
81  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
82  "alt" => $lng->txt("note")),
84  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
85  "alt" => $lng->txt("note").", ".$lng->txt("important")),
87  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
88  "alt" => $lng->txt("note").", ".$lng->txt("question")),
89  IL_NOTE_PRO => array(
90  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
91  "alt" => $lng->txt("note").", ".$lng->txt("pro")),
93  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
94  "alt" => $lng->txt("note").", ".$lng->txt("contra"))
95  );
96 
97  $this->comment_img = array(
99  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
100  "alt" => $lng->txt("notes_comment")),
102  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
103  "alt" => $lng->txt("notes_comment").", ".$lng->txt("important")),
105  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
106  "alt" => $lng->txt("notes_comment").", ".$lng->txt("question")),
107  IL_NOTE_PRO => array(
108  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
109  "alt" => $lng->txt("notes_comment").", ".$lng->txt("pro")),
111  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
112  "alt" => $lng->txt("notes_comment").", ".$lng->txt("contra"))
113  );
114 
115  // default: notes for repository objects
116  $this->setRepositoryMode(true);
117  }
118 
122  function executeCommand()
123  {
124  $cmd = $this->ctrl->getCmd("getNotesHTML");
125  $next_class = $this->ctrl->getNextClass($this);
126 
127  switch($next_class)
128  {
129  default:
130  return $this->$cmd();
131  break;
132  }
133  }
134 
138  function enablePrivateNotes($a_enable = true)
139  {
140  $this->private_enabled = $a_enable;
141  }
142 
146  function enablePublicNotes($a_enable = true)
147  {
148  $this->public_enabled = $a_enable;
149  }
150 
154  function enableCommentsSettings($a_enable = true)
155  {
156  $this->comments_settings = $a_enable;
157  }
158 
162  function enablePublicNotesDeletion($a_enable = true)
163  {
164  $this->public_deletion_enabled = $a_enable;
165  }
166 
170  function enableHiding($a_enable = true)
171  {
172  $this->enable_hiding = $a_enable;
173  }
174 
178  function enableTargets($a_enable = true)
179  {
180  $this->targets_enabled = $a_enable;
181  }
182 
186  function enableMultiSelection($a_enable = true)
187  {
188  $this->multi_selection = $a_enable;
189  }
190 
194  function enableAnchorJump($a_enable = true)
195  {
196  $this->anchor_jump = $a_enable;
197  }
198 
204  function setRepositoryMode($a_value)
205  {
206  $this->repository_mode = (bool)$a_value;
207  }
208 
209 
216  function getOnlyNotesHTML()
217  {
218  global $ilCtrl;
219  $ilCtrl->setParameter($this, "notes_only", "notes");
220  $this->only = "notes";
221  return $this->getNotesHTML($a_init_form = true);
222  }
223 
231  {
232  global $ilCtrl;
233  $ilCtrl->setParameter($this, "notes_only", "comments");
234  $this->only = "comments";
235  return $this->getNotesHTML($a_init_form = true);
236  }
237 
238 
239  /***
240  * get note lists html code
241  */
242  function getNotesHTML($a_init_form = true)
243  {
244  global $ilUser, $lng, $ilCtrl, $ilSetting;
245 
246  $lng->loadLanguageModule("notes");
247 
248  $ntpl = new ilTemplate("tpl.notes_and_comments.html", true, true,
249  "Services/Notes");
250 
251  // check, whether column is hidden due to processing in other column
252  $hide_comments = ($this->only == "notes");
253  $hide_notes = ($this->only == "comments");
254  switch($ilCtrl->getCmd())
255  {
256  case "addNoteForm":
257  case "editNoteForm":
258  case "addNote":
259  case "updateNote":
260  if ($_GET["note_type"] == IL_NOTE_PRIVATE)
261  {
262  $hide_comments = true;
263  }
264  if ($_GET["note_type"] == IL_NOTE_PUBLIC)
265  {
266  $hide_notes = true;
267  }
268  break;
269  }
270 
271 
272 // temp workaround: only show comments (if both have been activated)
273 if ($this->private_enabled && $this->public_enabled
274  && $this->only != "notes")
275 {
276  $this->private_enabled = false;
277 }
278 
279  $nodes_col = false;
280  if ($this->private_enabled && ($ilUser->getId() != ANONYMOUS_USER_ID)
281  && !$hide_notes)
282  {
283  $ntpl->setCurrentBlock("notes_col");
284  $ntpl->setVariable("NOTES", $this->getNoteListHTML(IL_NOTE_PRIVATE, $a_init_form));
285  $ntpl->parseCurrentBlock();
286  $nodes_col = true;
287  }
288 
289  // #15948 - public enabled vs. comments_settings
290  $comments_col = false;
291  if ($this->public_enabled && (!$this->delete_note || $this->public_deletion_enabled || $ilSetting->get("comments_del_user", 0))
292  && !$hide_comments /* && $ilUser->getId() != ANONYMOUS_USER_ID */)
293  {
294  $ntpl->setVariable("COMMENTS", $this->getNoteListHTML(IL_NOTE_PUBLIC, $a_init_form));
295  $comments_col = true;
296  }
297 
298  // Comments Settings
299  if ($this->comments_settings && !$hide_comments && !$this->delete_note
300  && !$this->edit_note_form && !$this->add_note_form && $ilUser->getId() != ANONYMOUS_USER_ID)
301  {
302  $notes_settings = new ilSetting("notes");
303  $id = $this->rep_obj_id."_".$this->obj_id."_".$this->obj_type;
304  //$active = $notes_settings->get("activate_".$id);
305  $active = ilNote::commentsActivated($this->rep_obj_id, $this->obj_id, $this->obj_type);
306 
307  if ($active)
308  {
309  $this->renderLink($ntpl, "comments_settings", $lng->txt("notes_deactivate_comments"),
310  "deactivateComments", "notes_top");
311  $ntpl->setCurrentBlock("comments_settings2");
312  }
313  else
314  {
315  $this->renderLink($ntpl, "comments_settings", $lng->txt("notes_activate_comments"),
316  "activateComments", "notes_top");
317  $ntpl->setCurrentBlock("comments_settings2");
318 
319  if ($this->ajax && !$comments_col)
320  {
321  $ntpl->setVariable("COMMENTS_MESS",
322  $ntpl->getMessageHTML($lng->txt("comments_feature_currently_not_activated_for_object"), "info"));
323  }
324  }
325  $ntpl->parseCurrentBlock();
326 
327  if (!$comments_col)
328  {
329  $ntpl->setVariable("COMMENTS", "");
330  }
331 
332  $comments_col = true;
333  }
334 
335  if ($comments_col)
336  {
337  $ntpl->setCurrentBlock("comments_col");
338  if ($nodes_col)
339  {
340 // $ntpl->touchBlock("comments_style");
341  }
342  $ntpl->parseCurrentBlock();
343  }
344 
345  if ($this->ajax)
346  {
347  echo $ntpl->get();
348  exit;
349  }
350 
351  return $ntpl->get();
352  }
353 
357  function activateComments()
358  {
359  global $ilCtrl;
360 
361  $notes_settings = new ilSetting("notes");
362 
363  if ($this->comments_settings)
364  {
365  $id = $this->rep_obj_id."_".$this->obj_id."_".$this->obj_type;
366  //$notes_settings->set("activate_".$id, 1);
367  ilNote::activateComments($this->rep_obj_id, $this->obj_id, $this->obj_type, true);
368  }
369 
370  $ilCtrl->redirectByClass("ilnotegui", "showNotes", "", $this->ajax);
371 // $ilCtrl->redirectByClass("ilnotegui", "getNotesHtml", "", $this->ajax);
372  }
373 
378  {
379  global $ilCtrl;
380 
381  $notes_settings = new ilSetting("notes");
382 
383  if ($this->comments_settings)
384  {
385  $id = $this->rep_obj_id."_".$this->obj_id."_".$this->obj_type;
386  //$notes_settings->set("activate_".$id, 0);
387  ilNote::activateComments($this->rep_obj_id, $this->obj_id, $this->obj_type, false);
388  }
389 
390  $ilCtrl->redirectByClass("ilnotegui", "showNotes", "", $this->ajax);
391  //$ilCtrl->redirectByClass("ilnotegui", "getNotesHtml", "", $this->ajax);
392  }
393 
397  function getNoteListHTML($a_type = IL_NOTE_PRIVATE, $a_init_form = true)
398  {
399  global $lng, $ilCtrl, $ilUser;
400 
401  include_once("./Services/User/classes/class.ilUserUtil.php");
402 
403  $suffix = ($a_type == IL_NOTE_PRIVATE)
404  ? "private"
405  : "public";
406 
407  /* user settings are deprecated
408  $user_setting_notes_public_all = $ilUser->getPref("notes_pub_all");
409  $user_setting_notes_by_type = $ilUser->getPref("notes_".$suffix);
410  */
411  $user_setting_notes_public_all = "y";
412  $user_setting_notes_by_type = "y";
413 
414  if ($this->delete_note || $this->export_html || $this->print)
415  {
416  if ($_GET["note_id"] != "")
417  {
418  $filter = $_GET["note_id"];
419  }
420  else
421  {
422  $filter = $_POST["note"];
423  }
424  }
425 
426  $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id,
427  $this->obj_type, $a_type, $this->inc_sub, $filter,
428  $user_setting_notes_public_all, $this->repository_mode, (bool)$_SESSION["comments_sort_asc"]);
429 
430  $all_notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id,
431  $this->obj_type, $a_type, $this->inc_sub, $filter,
432  "", $this->repository_mode);
433 
434  $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes");
435 
436  if ($this->ajax)
437  {
438  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
439  $tpl->setCurrentBlock("close_img");
440  $tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
441  $tpl->parseCurrentBlock();
442  }
443 
444  // show counter if notes are hidden
445  $cnt_str = (count($all_notes) > 0)
446  ? " (".count($all_notes).")"
447  : "";
448 
449  // title
450  if ($this->ajax)
451  {
452  switch($this->obj_type)
453  {
454  case "grpr":
455  case "catr":
456  case "crsr":
457  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
458  $title = ilContainerReference::_lookupTitle($this->rep_obj_id);
459  break;
460 
461  default:
462  $title = ilObject::_lookupTitle($this->rep_obj_id);
463  break;
464  }
465 
466  $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny"));
467 
468  // add sub-object if given
469  if($this->obj_id)
470  {
471  $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id);
472  if($sub_title)
473  {
474  $title .= " - ".$sub_title;
475  }
476  }
477 
478  $tpl->setCurrentBlock("title");
479  $tpl->setVariable("TITLE", $img." ".$title);
480  $tpl->parseCurrentBlock();
481  }
482 
483  if ($this->delete_note)
484  {
485  $cnt_str = "";
486  }
487  if ($a_type == IL_NOTE_PRIVATE)
488  {
489  $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes").$cnt_str);
490  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
491  }
492  else
493  {
494  $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments").$cnt_str);
495  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
496  }
497  $anch = $this->anchor_jump
498  ? "notes_top"
499  : "";
500  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch));
501  if ($this->ajax)
502  {
503  $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '".
504  $ilCtrl->getFormActionByClass("ilnotegui", "", "", true).
505  "'); return false;\"";
506  $tpl->setVariable("ON_SUBMIT_FORM", $os);
507  $tpl->setVariable("FORM_ID", "Ajax");
508  }
509 
510  if ($this->export_html || $this->print)
511  {
512  $tpl->touchBlock("print_style");
513  }
514 
515  // show add new note button
516  if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
517  !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID)
518  {
519  if (!$this->inc_sub) // we cannot offer add button if aggregated notes
520  { // are displayed
521  if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC)
522  {
523  $tpl->setCurrentBlock("add_note_btn");
524  if ($a_type == IL_NOTE_PUBLIC)
525  {
526  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment"));
527  }
528  else
529  {
530  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
531  }
532  $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm").
533  "#note_edit");
534  $tpl->parseCurrentBlock();
535  }
536  }
537  }
538 
539  // show show/hide button for note list
540  if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note
541  && !$this->export_html && !$this->print && !$this->edit_note_form
542  && !$this->add_note_form)
543  {
544  if ($user_setting_notes_by_type == "n")
545  {
546  if ($a_type == IL_NOTE_PUBLIC)
547  {
548  $txt = $lng->txt("notes_show_comments");
549  }
550  else
551  {
552  $txt = $lng->txt("show_".$suffix."_notes");
553  }
554  $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top");
555  }
556  else
557  {
558  // never individually hide for anonymous users
559  if (($ilUser->getId() != ANONYMOUS_USER_ID))
560  {
561  if ($a_type == IL_NOTE_PUBLIC)
562  {
563  $txt = $lng->txt("notes_hide_comments");
564  }
565  else
566  {
567  $txt = $lng->txt("hide_".$suffix."_notes");
568  }
569  $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top");
570 
571  // show all public notes / my notes only switch
572  if ($a_type == IL_NOTE_PUBLIC)
573  {
574  if ($user_setting_notes_public_all == "n")
575  {
576  $this->renderLink($tpl, "all_pub_notes", $lng->txt("notes_all_comments"),
577  "showAllPublicNotes", "notes_top");
578  }
579  else
580  {
581  $this->renderLink($tpl, "my_pub_notes", $lng->txt("notes_my_comments"),
582  "showMyPublicNotes", "notes_top");
583  }
584  }
585  }
586  }
587  }
588 
589  // show add new note text area
590  if (!$this->edit_note_form && $user_setting_notes_by_type != "n" &&
591  !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID)
592  {
593  if ($a_init_form)
594  {
595  $this->initNoteForm("create", $a_type);
596  }
597 
598  $tpl->setCurrentBlock("edit_note_form");
599 // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
600  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
601  $tpl->parseCurrentBlock();
602 
603  $tpl->parseCurrentBlock();
604  $tpl->setCurrentBlock("note_row");
605  $tpl->parseCurrentBlock();
606  }
607 
608  // list all notes
609  if ($user_setting_notes_by_type != "n" || !$this->enable_hiding)
610  {
613 
614  if(sizeof($notes))
615  {
616  if((int)$_SESSION["comments_sort_asc"] == 1)
617  {
618  $sort_txt = $lng->txt("notes_sort_desc");
619  $sort_cmd = "listSortDesc";
620  }
621  else
622  {
623  $sort_txt = $lng->txt("notes_sort_asc");
624  $sort_cmd = "listSortAsc";
625  }
626  $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch);
627  }
628 
629  $notes_given = false;
630  foreach($notes as $note)
631  {
632  if ($this->edit_note_form && ($note->getId() == $_GET["note_id"])
633  && $a_type == $_GET["note_type"])
634  {
635  if ($a_init_form)
636  {
637  $this->initNoteForm("edit", $a_type, $note);
638  }
639  $tpl->setCurrentBlock("edit_note_form");
640 // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
641  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
642  $tpl->parseCurrentBlock();
643  }
644  else
645  {
646  $cnt_col = 2;
647 
648  // delete note stuff for all private notes
649  if ($this->checkDeletion($note)
650  && !$this->delete_note
651  && !$this->export_html && !$this->print
652  && !$this->edit_note_form && !$this->add_note_form)
653  {
654  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
655  $this->renderLink($tpl, "delete_note", $lng->txt("delete"),
656  "deleteNote", "note_".$note->getId());
657  }
658 
659  // checkboxes in multiselection mode
660  if ($this->multi_selection && !$this->delete_note)
661  {
662  $tpl->setCurrentBlock("checkbox_col");
663  $tpl->setVariable("CHK_NOTE", "note[]");
664  $tpl->setVariable("CHK_NOTE_ID", $note->getId());
665  $tpl->parseCurrentBlock();
666  $cnt_col = 1;
667  }
668 
669  // edit note stuff for all private notes
670  if ($this->checkEdit($note))
671  {
672 
673  if (!$this->delete_note && !$this->export_html && !$this->print
674  && !$this->edit_note_form && !$this->add_note_form)
675  {
676  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
677  $this->renderLink($tpl, "edit_note", $lng->txt("edit"),
678  "editNoteForm", "note_edit");
679  }
680  }
681 
682  $tpl->setVariable("CNT_COL", $cnt_col);
683 
684  // output author account
685  if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor()))
686  {
687  //$tpl->setCurrentBlock("author");
688  //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
689  //$tpl->parseCurrentBlock();
690  $tpl->setCurrentBlock("user_img");
691  $tpl->setVariable("USR_IMG",
692  ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall"));
693  $tpl->setVariable("USR_ALT", $lng->txt("user_image").": ".
694  ilObjUser::_lookupLogin($note->getAuthor()));
695  $tpl->parseCurrentBlock();
696  $tpl->setVariable("TXT_USR",
697  ilUserUtil::getNamePresentation($note->getAuthor(), false, false)." - ");
698  }
699 
700  // last edited
701  if ($note->getUpdateDate() != null)
702  {
703  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
704  $tpl->setVariable("DATE_LAST_EDIT",
705  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME)));
706  }
707  else
708  {
709  $tpl->setVariable("VAL_DATE",
710  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME)));
711  }
712 
713  // hidden note ids for deletion
714  if ($this->delete_note)
715  {
716  $tpl->setCurrentBlock("delete_ids");
717  $tpl->setVariable("HID_NOTE", "note[]");
718  $tpl->setVariable("HID_NOTE_ID", $note->getId());
719  $tpl->parseCurrentBlock();
720  }
721  $target = $note->getObject();
722 
723  // target objects
724  $this->showTargets($tpl, $this->rep_obj_id, $note->getId(),
725  $target["obj_type"], $target["obj_id"]);
726 
727  $rowclass = ($rowclass != "tblrow1")
728  ? "tblrow1"
729  : "tblrow2";
730  if (!$this->export_html && !$this->print)
731  {
732  $tpl->setCurrentBlock("note_img");
733  if ($a_type == IL_NOTE_PUBLIC)
734  {
735  $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]);
736  $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]);
737  }
738  else
739  {
740  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
741  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
742  }
743  $tpl->parseCurrentBlock();
744  }
745  else
746  {
747  switch ($note->getLabel())
748  {
749  case IL_NOTE_UNLABELED:
750  $tpl->setVariable("EXP_ICON", "[&nbsp;]");
751  break;
752 
753  case IL_NOTE_IMPORTANT:
754  $tpl->setVariable("EXP_ICON", "[!]");
755  break;
756 
757  case IL_NOTE_QUESTION:
758  $tpl->setVariable("EXP_ICON", "[?]");
759  break;
760 
761  case IL_NOTE_PRO:
762  $tpl->setVariable("EXP_ICON", "[+]");
763  break;
764 
765  case IL_NOTE_CONTRA:
766  $tpl->setVariable("EXP_ICON", "[-]");
767  break;
768  }
769  }
770  $tpl->setCurrentBlock("note");
771  $tpl->setVariable("ROWCLASS", $rowclass);
772  $text = (trim($note->getText()) != "")
773  ? nl2br($note->getText())
774  : "<p class='subtitle'>".$lng->txt("note_content_removed")."</p>";
775  $tpl->setVariable("NOTE_TEXT", $text);
776  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
777  $tpl->setVariable("NOTE_ID", $note->getId());
778  $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC
779  ? "ilComment"
780  : "ilNote");
781  $tpl->parseCurrentBlock();
782  }
783  $tpl->setCurrentBlock("note_row");
784  $tpl->parseCurrentBlock();
785  $notes_given = true;
786  }
787 
788  if (!$notes_given)
789  {
790  $tpl->setCurrentBlock("no_notes");
791  if ($a_type == IL_NOTE_PUBLIC)
792  {
793  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments"));
794  }
795 /* else
796  {
797  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes"));
798  }*/
799  $tpl->parseCurrentBlock();
800  }
801 
803 
804  // multiple items commands
805  if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form
806  && count($notes) > 0)
807  {
808  if ($a_type == IL_NOTE_PRIVATE)
809  {
810  $tpl->setCurrentBlock("delete_cmd");
811  $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
812  $tpl->parseCurrentBlock();
813  }
814 
815  $tpl->setCurrentBlock("multiple_commands");
816  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
817  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
818  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
819  $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
820  $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
821  $tpl->parseCurrentBlock();
822  }
823 
824  // delete / cancel row
825  if ($this->delete_note)
826  {
827  $tpl->setCurrentBlock("delete_cancel");
828  $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
829  $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
830  $tpl->parseCurrentBlock();
831  }
832 
833  // print
834  if ($this->print)
835  {
836  $tpl->touchBlock("print_js");
837  $tpl->setCurrentBlock("print_back");
838  $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
839  $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
840  $tpl->parseCurrentBlock();
841  }
842  }
843 
844  // message
845  switch($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess)
846  {
847  case "mod":
848  $mtype = "success";
849  $mtxt = $lng->txt("msg_obj_modified");
850  break;
851 
852  case "ntsdel":
853  $mtype = "success";
854  $mtxt = ($a_type == IL_NOTE_PRIVATE)
855  ? $lng->txt("notes_notes_deleted")
856  : $lng->txt("notes_comments_deleted");
857  break;
858 
859  case "ntdel":
860  $mtype = "success";
861  $mtxt = ($a_type == IL_NOTE_PRIVATE)
862  ? $lng->txt("notes_note_deleted")
863  : $lng->txt("notes_comment_deleted");
864  break;
865 
866  case "frmfld":
867  $mtype = "failure";
868  $mtxt = $lng->txt("form_input_not_valid");
869  break;
870 
871  case "qdel":
872  $mtype = "question";
873  $mtxt = $lng->txt("info_delete_sure");
874  break;
875 
876  case "noc":
877  $mtype = "failure";
878  $mtxt = $lng->txt("no_checkbox");
879  break;
880  }
881  if ($mtxt != "")
882  {
883  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
884  }
885  else
886  {
887  $tpl->setVariable("MESS", "");
888  }
889 
890 
891 
892  if ($this->delete_note && count($notes) == 0)
893  {
894  return "";
895  }
896  else
897  {
898  return $tpl->get();
899  }
900  }
901 
909  protected function getSubObjectTitle($parent_obj_id, $sub_obj_id)
910  {
911  global $objDefinition, $ilCtrl;
912 
913  $parent_type = ilObject::_lookupType($parent_obj_id);
914  $parent_class = "ilObj".$objDefinition->getClassName($parent_type)."GUI";
915  $parent_path = $ilCtrl->lookupClassPath($parent_class);
916  include_once $parent_path;
917  if(method_exists($parent_class, "lookupSubObjectTitle"))
918  {
919  return call_user_func_array(array($parent_class, "lookupSubObjectTitle"), array($parent_obj_id, $sub_obj_id));
920  }
921  }
922 
926  function checkDeletion($a_note)
927  {
928  global $ilUser, $ilSetting;
929 
930  if ($ilUser->getId() == ANONYMOUS_USER_ID)
931  {
932  return false;
933  }
934 
935  $is_author = ($a_note->getAuthor() == $ilUser->getId());
936 
937  if ($a_note->getType() == IL_NOTE_PRIVATE && $is_author)
938  {
939  return true;
940  }
941 
942  if ($a_note->getType() == IL_NOTE_PUBLIC && $this->public_deletion_enabled)
943  {
944  return true;
945  }
946 
947  if ($a_note->getType() == IL_NOTE_PUBLIC && $is_author && $ilSetting->get("comments_del_user", 0))
948  {
949  return true;
950  }
951 
952  return false;
953  }
954 
958  function checkEdit($a_note)
959  {
960  global $ilUser;
961 
962  if ($a_note->getAuthor() == $ilUser->getId()
963  && ($ilUser->getId() != ANONYMOUS_USER_ID))
964  {
965  return true;
966  }
967  return false;
968  }
969 
970 
976  public function initNoteForm($a_mode = "edit", $a_type, $a_note = null)
977  {
978  global $lng, $ilCtrl;
979 
980  $this->form_tpl = new ilTemplate("tpl.notes_edit.html", true, true, "Services/Notes");
981  if ($a_note)
982  {
983  $this->form_tpl->setVariable("VAL_NOTE", ilUtil::prepareFormOutput($a_note->getText()));
984  $this->form_tpl->setVariable("NOTE_ID", $a_note->getId());
985  }
986 
987  if ($a_mode == "create")
988  {
989  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
990  ? $lng->txt("note_add_comment")
991  : $lng->txt("note_add_note"));
992  $this->form_tpl->setVariable("CMD", "addNote");
993  }
994  else
995  {
996  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
997  ? $lng->txt("note_update_comment")
998  : $lng->txt("note_update_note"));
999  $this->form_tpl->setVariable("CMD", "updateNote");
1000  }
1001 
1002 return;
1003  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1004  $this->form = new ilPropertyFormGUI();
1005  $this->form->setOpenTag(false);
1006  $this->form->setCloseTag(false);
1007  $this->form->setDisableStandardMessage(true);
1008 
1009  // subject
1010 /* $ti = new ilTextInputGUI($this->lng->txt("subject"), "sub_note");
1011  $ti->setRequired(true);
1012  $ti->setMaxLength(200);
1013  $ti->setSize(40);
1014  if ($a_note)
1015  {
1016  $ti->setValue($a_note->getSubject());
1017  }
1018  $this->form->addItem($ti);*/
1019 
1020  // text
1021 // $ta = new ilTextAreaInputGUI(($a_type == IL_NOTE_PUBLIC)
1022 // ? $lng->txt("notes_comment")
1023 // : $lng->txt("note"), "note");
1024  $ta = new ilTextAreaInputGUI("", "note");
1025  $ta->setCols(40);
1026  $ta->setRows(4);
1027  if ($a_note)
1028  {
1029  $ta->setValue($a_note->getText());
1030  }
1031  $this->form->addItem($ta);
1032 
1033  // label
1034 /* $options = array(
1035  IL_NOTE_UNLABELED => $lng->txt("unlabeled"),
1036  IL_NOTE_QUESTION => $lng->txt("question"),
1037  IL_NOTE_IMPORTANT => $lng->txt("important"),
1038  IL_NOTE_PRO => $lng->txt("pro"),
1039  IL_NOTE_CONTRA => $lng->txt("contra"),
1040  );
1041  $si = new ilSelectInputGUI($this->lng->txt("notes_label"), "note_label");
1042  $si->setOptions($options);
1043  if ($a_note)
1044  {
1045  $si->setValue($a_note->getLabel());
1046  }
1047  $this->form->addItem($si); */
1048 
1049  // hidden note id
1050  if ($a_note)
1051  {
1052  $hi = new ilHiddenInputGUI("note_id");
1053  $hi->setValue($_GET["note_id"]);
1054  $this->form->addItem($hi);
1055  }
1056 
1057  // save and cancel commands
1058  if ($a_mode == "create")
1059  {
1060  $this->form->addCommandButton("addNote", $lng->txt("save"));
1061 /* $this->form->addCommandButton("cancelAddNote", $lng->txt("cancel"));
1062  $this->form->setTitle($a_type == IL_NOTE_PUBLIC
1063  ? $lng->txt("notes_add_comment")
1064  : $lng->txt("notes_add_note"));*/
1065  }
1066  else
1067  {
1068  $this->form->addCommandButton("updateNote", $lng->txt("save"));
1069 /* $this->form->addCommandButton("cancelUpdateNote", $lng->txt("cancel"));
1070  $this->form->setTitle($a_type == IL_NOTE_PUBLIC
1071  ? $lng->txt("notes_edit_comment")
1072  : $lng->txt("notes_edit_note"));*/
1073  }
1074 
1075  $ilCtrl->setParameter($this, "note_type", $a_type);
1076  $this->form->setFormAction($this->ctrl->getFormAction($this));
1077 
1078  }
1079 
1083  function getPDNoteHTML($note_id)
1084  {
1085  global $lng, $ilCtrl, $ilUser;
1086 
1087  $tpl = new ilTemplate("tpl.pd_note.html", true, true, "Services/Notes");
1088  $note = new ilNote($note_id);
1089  $target = $note->getObject();
1090 
1091  if ($note->getAuthor() != $ilUser->getId())
1092  {
1093  return;
1094  }
1095 
1096  $tpl->setCurrentBlock("edit_note");
1097  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $target["rep_obj_id"]);
1098  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note_id);
1099  $ilCtrl->setParameterByClass("ilnotegui", "note_type", $note->getType());
1100  $tpl->setVariable("LINK_EDIT_NOTE",
1101  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"),
1102  "editNoteForm"));
1103  $tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
1104  $tpl->parseCurrentBlock();
1105  $ilCtrl->clearParametersByClass("ilnotegui");
1106 
1107  $tpl->setCurrentBlock("note_img");
1108  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
1109  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
1110  $tpl->parseCurrentBlock();
1111 
1112  // last edited
1113  if ($note->getUpdateDate() != null)
1114  {
1115  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
1116  $tpl->setVariable("DATE_LAST_EDIT",
1117  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME)));
1118  }
1119  else
1120  {
1121  //$tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
1122  $tpl->setVariable("VAL_DATE",
1123  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME)));
1124  }
1125 
1126  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
1127  $text = (trim($note->getText()) != "")
1128  ? nl2br($note->getText())
1129  : "<p class='subtitle'>".$lng->txt("note_content_removed")."</p>";
1130  $tpl->setVariable("NOTE_TEXT", $text);
1131  $this->showTargets($tpl, $target["rep_obj_id"], $note_id, $target["obj_type"], $target["obj_id"]);
1132  return $tpl->get();
1133  }
1134 
1138  function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
1139  {
1140  global $tree, $ilAccess, $objDefinition, $ilUser;
1141 
1142  if ($this->targets_enabled)
1143  {
1144  if ($a_rep_obj_id > 0)
1145  {
1146  // get all visible references of target object
1147 
1148  // repository
1149  $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
1150  if($ref_ids)
1151  {
1152  $vis_ref_ids = array();
1153  foreach($ref_ids as $ref_id)
1154  {
1155  if ($ilAccess->checkAccess("visible", "", $ref_id))
1156  {
1157  $vis_ref_ids[] = $ref_id;
1158  }
1159  }
1160 
1161  // output links to targets
1162  if (count($vis_ref_ids) > 0)
1163  {
1164  foreach($vis_ref_ids as $vis_ref_id)
1165  {
1166  $type = ilObject::_lookupType($vis_ref_id, true);
1167  $sub_link = $sub_title = "";
1168  if ($type == "sahs") // bad hack, needs general procedure
1169  {
1170  $link = "goto.php?target=sahs_".$vis_ref_id;
1171  $title = ilObject::_lookupTitle($a_rep_obj_id);
1172  if ($a_obj_type == "sco" || $a_obj_type == "seqc" || $a_obj_type == "chap" || $a_obj_type == "pg")
1173  {
1174  $sub_link = "goto.php?target=sahs_".$vis_ref_id."_".$a_obj_id;
1175  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1176  $sub_title = ilSCORM2004Node::_lookupTitle($a_obj_id);
1177  $sub_icon = ilUtil::getImagePath("icon_".$a_obj_type.".svg");
1178  }
1179  }
1180  else if ($type == "poll")
1181  {
1182  include_once "Services/Link/classes/class.ilLink.php";
1183  $title = ilObject::_lookupTitle($a_rep_obj_id);
1184  $link = ilLink::_getLink($vis_ref_id, "poll");
1185  }
1186  else if ($a_obj_type != "pg")
1187  {
1188  if (!is_object($this->item_list_gui[$type]))
1189  {
1190  $class = $objDefinition->getClassName($type);
1191  $location = $objDefinition->getLocation($type);
1192  $full_class = "ilObj".$class."ListGUI";
1193  include_once($location."/class.".$full_class.".php");
1194  $this->item_list_gui[$type] = new $full_class();
1195  }
1196 
1197  // for references, get original title
1198  // (link will lead to orignal, which basically is wrong though)
1199  if($a_obj_type == "crsr" || $a_obj_type == "catr" || $a_obj_type == "grpr")
1200  {
1201  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
1202  $tgt_obj_id = ilContainerReference::_lookupTargetId($a_rep_obj_id);
1203  $title = ilObject::_lookupTitle($tgt_obj_id);
1204  }
1205  else
1206  {
1207  $title = ilObject::_lookupTitle($a_rep_obj_id);
1208  }
1209  $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
1210  $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
1211 
1212  // workaround, because # anchor can't be passed through frameset
1213  $link = ilUtil::appendUrlParameterString($link, "anchor=note_".$a_note_id);
1214 
1215  $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link)."#note_".$a_note_id;
1216  }
1217  else
1218  {
1219  $title = ilObject::_lookupTitle($a_rep_obj_id);
1220  $link = "goto.php?target=pg_".$a_obj_id."_".$vis_ref_id;
1221  }
1222 
1223  $par_id = $tree->getParentId($vis_ref_id);
1224 
1225  // sub object link
1226  if ($sub_link != "")
1227  {
1228  if ($this->export_html || $this->print)
1229  {
1230  $tpl->setCurrentBlock("exp_target_sub_object");
1231  }
1232  else
1233  {
1234  $tpl->setCurrentBlock("target_sub_object");
1235  $tpl->setVariable("LINK_SUB_TARGET", $sub_link);
1236  }
1237  $tpl->setVariable("TXT_SUB_TARGET", $sub_title);
1238  $tpl->setVariable("IMG_SUB_TARGET", $sub_icon);
1239  $tpl->parseCurrentBlock();
1240  }
1241 
1242  // container and object link
1243  if ($this->export_html || $this->print)
1244  {
1245  $tpl->setCurrentBlock("exp_target_object");
1246  }
1247  else
1248  {
1249  $tpl->setCurrentBlock("target_object");
1250  $tpl->setVariable("LINK_TARGET", $link);
1251  }
1252  $tpl->setVariable("TXT_CONTAINER",
1254  ilObject::_lookupObjId($par_id)));
1255  $tpl->setVariable("IMG_CONTAINER",
1257  ilObject::_lookupObjId($par_id), "tiny"));
1258  $tpl->setVariable("TXT_TARGET", $title);
1259  $tpl->setVariable("IMG_TARGET",
1260  ilObject::_getIcon($a_rep_obj_id, "tiny"));
1261 
1262  $tpl->parseCurrentBlock();
1263  }
1264  $tpl->touchBlock("target_objects");
1265  }
1266  }
1267  // personal workspace
1268  else
1269  {
1270  // we only need 1 instance
1271  if(!$this->wsp_tree)
1272  {
1273  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1274  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
1275  $this->wsp_tree = new ilWorkspaceTree($ilUser->getId());
1276  $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
1277  }
1278  $node_id = $this->wsp_tree->lookupNodeId($a_rep_obj_id);
1279  if($this->wsp_access_handler->checkAccess("visible", "", $node_id))
1280  {
1281  $path = $this->wsp_tree->getPathFull($node_id);
1282  if($path)
1283  {
1284  $item = array_pop($path);
1285  $parent = array_pop($path);
1286 
1287  if(!$parent["title"])
1288  {
1289  $parent["title"] = $this->lng->txt("wsp_personal_workspace");
1290  }
1291 
1292  // sub-objects
1293  $additional = null;
1294  if($a_obj_id)
1295  {
1296  $sub_title = $this->getSubObjectTitle($a_rep_obj_id, $a_obj_id);
1297  if($sub_title)
1298  {
1299  $item["title"] .= " (".$sub_title.")";
1300  $additional = "_".$a_obj_id;
1301  }
1302  }
1303 
1304  $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $a_rep_obj_id, $additional);
1305  }
1306  // shared resource
1307  else
1308  {
1309  $owner = ilObject::_lookupOwner($a_rep_obj_id);
1310  $parent["title"] = $this->lng->txt("wsp_tab_shared").
1311  " (".ilObject::_lookupOwnerName($owner).")";
1312  $item["title"] = ilObject::_lookupTitle($a_rep_obj_id);
1313  $link = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=".
1314  $owner;
1315  }
1316 
1317  // container and object link
1318  if ($this->export_html || $this->print)
1319  {
1320  $tpl->setCurrentBlock("exp_target_object");
1321  }
1322  else
1323  {
1324  $tpl->setCurrentBlock("target_object");
1325  $tpl->setVariable("LINK_TARGET", $link);
1326  }
1327 
1328 
1329  // :TODO: no images in template ?
1330 
1331  $tpl->setVariable("TXT_CONTAINER", $parent["title"]);
1332  $tpl->setVariable("IMG_CONTAINER",
1333  ilObject::_getIcon($parent["obj_id"], "tiny"));
1334 
1335  $tpl->setVariable("TXT_TARGET", $item["title"]);
1336  $tpl->setVariable("IMG_TARGET",
1337  ilObject::_getIcon($a_rep_obj_id, "tiny"));
1338 
1339  $tpl->parseCurrentBlock();
1340  }
1341  }
1342  }
1343  }
1344  }
1345 
1349  function addNoteForm($a_init_form = true)
1350  {
1351  global $ilUser;
1352 
1353  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1354  ? "private"
1355  : "public";
1356  $ilUser->setPref("notes_".$suffix, "y");
1357 
1358  $this->add_note_form = true;
1359  return $this->getNotesHTML($a_init_form);
1360  }
1361 
1365  function cancelAddNote()
1366  {
1367  return $this->getNotesHTML();
1368  }
1369 
1373  function cancelUpdateNote()
1374  {
1375  return $this->getNotesHTML();
1376  }
1377 
1381  function addNote()
1382  {
1383  global $ilUser, $lng, $ilCtrl;
1384 
1385  $this->initNoteForm("create", $_GET["note_type"]);
1386 
1387  //if ($this->form->checkInput())
1388  if ($_POST["note"] != "")
1389  {
1390  $note = new ilNote();
1391  $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
1392  $note->setInRepository($this->repository_mode);
1393  $note->setType($_GET["note_type"]);
1394  $note->setAuthor($ilUser->getId());
1395  $note->setText(ilUtil::stripslashes($_POST["note"]));
1396 // $note->setSubject($_POST["sub_note"]);
1397 // $note->setLabel($_POST["note_label"]);
1398  $note->create();
1399 
1400  $this->notifyObserver("new", $note);
1401 
1402  $ilCtrl->setParameter($this, "note_mess", "mod");
1403 // $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1404  }
1405  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1406 // $this->note_mess = "frmfld";
1407 // $this->form->setValuesByPost();
1408 // return $this->addNoteForm(false);;
1409  }
1410 
1414  function updateNote()
1415  {
1416  global $ilUser, $lng, $ilCtrl;
1417 
1418  $note = new ilNote(ilUtil::stripSlashes($_POST["note_id"]));
1419  $this->initNoteForm("edit", $note->getType(),
1420  $note);
1421 
1422 // if ($this->form->checkInput())
1423 // if ($_POST["note"] != "")
1424 // {
1425  $note->setText(ilUtil::stripSlashes($_POST["note"]));
1426  $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
1427  $note->setLabel(ilUtil::stripSlashes($_POST["note_label"]));
1428  if ($this->checkEdit($note))
1429  {
1430  $note->update();
1431 
1432  $this->notifyObserver("update", $note);
1433 
1434  $ilCtrl->setParameter($this, "note_mess", "mod");
1435  }
1436  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1437 // }
1438 $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1439  $this->note_mess = "frmfld";
1440  $this->form->setValuesByPost();
1441  $_GET["note_id"] = $note->getId();
1442  $_GET["note_type"] = $note->getType();
1443  return $this->editNoteForm(false);
1444  }
1445 
1449  function editNoteForm($a_init_form = true)
1450  {
1451  $this->edit_note_form = true;
1452 
1453  return $this->getNotesHTML($a_init_form);
1454  }
1455 
1459  function deleteNote()
1460  {
1461  $this->delete_note = true;
1462  $this->note_mess = "qdel";
1463  return $this->getNotesHTML();
1464  }
1465 
1469  function deleteNotes()
1470  {
1471  global $lng;
1472 
1473  if (!$_POST["note"])
1474  {
1475  $this->note_mess = "noc";
1476  }
1477  else
1478  {
1479  $this->delete_note = true;
1480  $this->note_mess = "qdel";
1481  }
1482 
1483  return $this->getNotesHTML();
1484  }
1485 
1489  function cancelDelete()
1490  {
1491  return $this->getNotesHTML();
1492  }
1493 
1497  function confirmDelete()
1498  {
1499  global $ilCtrl, $lng, $ilUser;
1500 
1501  $cnt = 0;
1502  foreach($_POST["note"] as $id)
1503  {
1504  $note = new ilNote($id);
1505  if ($this->checkDeletion($note))
1506  {
1507  $note->delete();
1508  $cnt++;
1509  }
1510  }
1511  if ($cnt > 1)
1512  {
1513  $ilCtrl->setParameter($this, "note_mess", "ntsdel");
1514  }
1515  else
1516  {
1517  $ilCtrl->setParameter($this, "note_mess", "ntdel");
1518  }
1519  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1520  }
1521 
1525  function exportNotesHTML()
1526  {
1527  $tpl = new ilTemplate("tpl.main.html", true, true);
1528 
1529  $this->export_html = true;
1530  $this->multi_selection = false;
1531  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1532  ilUtil::deliverData($tpl->get(), "notes.html");
1533  }
1534 
1538  function printNotes()
1539  {
1540  $tpl = new ilTemplate("tpl.main.html", true, true);
1541 
1542  $this->print = true;
1543  $this->multi_selection = false;
1544  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1545  echo $tpl->get(); exit;
1546  }
1547 
1551  function showNotes()
1552  {
1553  global $ilUser;
1554 
1555  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1556  ? "private"
1557  : "public";
1558  $ilUser->writePref("notes_".$suffix, "y");
1559 
1560  return $this->getNotesHTML();
1561  }
1562 
1566  function hideNotes()
1567  {
1568  global $ilUser;
1569 
1570  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1571  ? "private"
1572  : "public";
1573  $ilUser->writePref("notes_".$suffix, "n");
1574 
1575  return $this->getNotesHTML();
1576  }
1577 
1582  {
1583  global $ilUser;
1584 
1585  $ilUser->writePref("notes_pub_all", "y");
1586 
1587  return $this->getNotesHTML();
1588  }
1589 
1594  {
1595  global $ilUser;
1596 
1597  $ilUser->writePref("notes_pub_all", "n");
1598 
1599  return $this->getNotesHTML();
1600  }
1601 
1605  static function initJavascript($a_ajax_url, $a_type = IL_NOTE_PRIVATE)
1606  {
1607  global $tpl, $lng;
1608 
1609  $lng->loadLanguageModule("notes");
1610 
1611  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1613 
1614  $lng->toJs(array("private_notes", "notes_public_comments"));
1615 
1616  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1618  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1620  $tpl->addJavascript("./Services/Notes/js/ilNotes.js");
1621 
1622  $tpl->addOnLoadCode("ilNotes.setAjaxUrl('".$a_ajax_url."');");
1623  }
1624 
1632  static function getListNotesJSCall($a_hash, $a_update_code = null)
1633  {
1634  if ($a_update_code === null)
1635  {
1636  $a_update_code = "null";
1637  }
1638  else
1639  {
1640  $a_update_code = "'".$a_update_code."'";
1641  }
1642 
1643  return "ilNotes.listNotes(event, '".$a_hash."', ".$a_update_code.");";
1644  }
1645 
1653  static function getListCommentsJSCall($a_hash, $a_update_code = null)
1654  {
1655  if ($a_update_code === null)
1656  {
1657  $a_update_code = "null";
1658  }
1659  else
1660  {
1661  $a_update_code = "'".$a_update_code."'";
1662  }
1663 
1664  return "ilNotes.listComments(event, '".$a_hash."', ".$a_update_code.");";
1665  }
1666 
1676  protected static function buildAjaxHash($a_node_type, $a_node_id, $a_sub_id, $a_sub_type)
1677  {
1678  return $a_node_type.";".$a_node_id.";".$a_sub_id.";".$a_sub_type;
1679  }
1680 
1684  function renderLink($a_tpl, $a_var, $a_txt, $a_cmd, $a_anchor = "")
1685  {
1686  global $ilCtrl;
1687 
1688  $low_var = strtolower($a_var);
1689  $up_var = strtoupper($a_var);
1690 
1691  if ($this->ajax)
1692  {
1693  $a_tpl->setVariable("LINK_".$up_var, "#");
1694  $oc = "onclick = \"ilNotes.cmdAjaxLink(event, '".
1695  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, "", true).
1696  "');\"";
1697  $a_tpl->setVariable("ON_CLICK_".$up_var, $oc);
1698  }
1699  else
1700  {
1701  $a_tpl->setVariable("LINK_".$up_var,
1702  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, $a_anchor));
1703  }
1704 
1705  $a_tpl->setCurrentBlock($low_var);
1706  $a_tpl->setVariable("TXT_".$up_var, $a_txt);
1707  $a_tpl->parseCurrentBlock();
1708  }
1709 
1715  function addObserver($a_callback)
1716  {
1717  $this->observer[] = $a_callback;
1718  }
1719 
1726  protected function notifyObserver($a_action, $a_note)
1727  {
1728  if(sizeof($this->observer))
1729  {
1730  foreach($this->observer as $item)
1731  {
1732  $param = $a_note->getObject();
1733  $param["action"] = $a_action;
1734  $param["note_id"] = $a_note->getId();
1735 
1736  call_user_func_array($item, $param);
1737  }
1738  }
1739  }
1740 
1741  protected function listSortAsc()
1742  {
1743  $_SESSION["comments_sort_asc"] = 1;
1744  return $this->getNotesHtml();
1745  }
1746 
1747  protected function listSortDesc()
1748  {
1749  $_SESSION["comments_sort_asc"] = 0;
1750  return $this->getNotesHtml();
1751  }
1752 }
1753 
1754 ?>
static _lookupLogin($a_user_id)
lookup login
checkDeletion($a_note)
Check whether deletion is allowed.
getOnlyCommentsHTML()
Get only comments html.
static _lookupTitle($a_obj_id)
Lookup Title.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
const IL_NOTE_CONTRA
ILIAS Setting Class.
getNotesHTML($a_init_form=true)
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
enableCommentsSettings($a_enable=true)
enable private notes
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$path
Definition: aliased.php:25
getNoteListHTML($a_type=IL_NOTE_PRIVATE, $a_init_form=true)
get notes/comments list as html code
initNoteForm($a_mode="edit", $a_type, $a_note=null)
Init note form.
setRepositoryMode($a_value)
Set repository mode.
enableMultiSelection($a_enable=true)
enable multi selection (checkboxes and commands)
const IL_NOTE_PRO
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
const IL_CAL_DATETIME
enableAnchorJump($a_enable=true)
enable anchor for form jump
$_SESSION["AccountId"]
This class represents a property form user interface.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
$location
Definition: buildRTE.php:44
updateNote()
update note
getPDNoteHTML($note_id)
Note display for personal desktop.
getOnlyNotesHTML()
Get only notes html.
executeCommand()
execute command
$cmd
Definition: sahs_server.php:35
static get($a_glyph, $a_text="")
Get glyph html.
Access handler for personal workspace.
renderLink($a_tpl, $a_var, $a_txt, $a_cmd, $a_anchor="")
Render a link.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
deactivateComments()
Deactivate Comments.
checkEdit($a_note)
Check edit.
enablePublicNotes($a_enable=true)
enable public notes
showNotes()
show notes
editNoteForm($a_init_form=true)
get notes list including add note area
activateComments()
Activate Comments.
enableTargets($a_enable=true)
enable target objects
static _getAllReferences($a_id)
get all reference ids of object
static getListNotesJSCall($a_hash, $a_update_code=null)
Get list notes js call.
Tree handler for personal workspace.
Note class.
static useRelativeDates()
check if relative dates are used
global $tpl
Definition: ilias.php:8
static initJS()
Init javascript.
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
getSubObjectTitle($parent_obj_id, $sub_obj_id)
Get sub object title if available with callback.
$a_type
Definition: workflow.php:93
exportNotesHTML()
export selected notes to html
This class represents a hidden form property in a property form.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
deleteNote()
delete note confirmation
Class for single dates.
static _lookupTitle($a_obj_id)
Overwitten from base class.
static getGotoLink($a_node_id, $a_obj_id, $a_additional=null)
enableHiding($a_enable=true)
enable hiding
static initJavascript($a_ajax_url, $a_type=IL_NOTE_PRIVATE)
Init javascript.
addNote()
add note
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
showAllPublicNotes()
show all public notes to user
addObserver($a_callback)
Add observer.
cancelUpdateNote()
cancel edit note
static formatDate(ilDateTime $date)
Format a date public.
$ilUser
Definition: imgupload.php:18
static _lookupOwner($a_id)
lookup object owner
static _getNotesOfObject($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_type=IL_NOTE_PRIVATE, $a_incl_sub=false, $a_filter="", $a_all_public="y", $a_repository_mode=true, $a_sort_ascending=false)
get all notes related to a specific object
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$txt
Definition: error.php:12
$additional
Definition: goto.php:52
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
cancelDelete()
cancel deletion of note
static getListCommentsJSCall($a_hash, $a_update_code=null)
Get list comments js call.
notifyObserver($a_action, $a_note)
Notify observers on update/create.
static initPanel($a_resize=false)
Init yui panel.
showMyPublicNotes()
show only public notes of user
printNotes()
notes print view screen
showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
show related objects as links
const IL_NOTE_UNLABELED
Definition: class.ilNote.php:7
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
hideNotes()
hide notes
enablePublicNotesDeletion($a_enable=true)
enable public notes
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
confirmDelete()
cancel deletion of note
$ref_id
Definition: sahs_server.php:39
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
static _getPersonalPicturePath($a_usr_id, $a_size="small", $a_force_pic=false, $a_prevent_no_photo_image=false)
Get path to personal picture.
__construct($a_rep_obj_id="", $a_obj_id="", $a_obj_type="", $a_include_subobjects=false)
constructor, specifies notes set
const IL_NOTE_QUESTION
Definition: class.ilNote.php:9
$text
static initjQuery($a_tpl=null)
Init jQuery.
addNoteForm($a_init_form=true)
get notes list including add note area
enablePrivateNotes($a_enable=true)
enable private notes
const IL_NOTE_IMPORTANT
Definition: class.ilNote.php:8
static buildAjaxHash($a_node_type, $a_node_id, $a_sub_id, $a_sub_type)
Combine properties to hash.
deleteNotes()
delete notes confirmation
cancelAddNote()
cancel add note
$_POST["username"]
static _lookupTargetId($a_obj_id)
lookup target id