ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
23  protected $ctrl;
24 
28  protected $lng;
29 
33  protected $user;
34 
38  protected $settings;
39 
43  protected $obj_definition;
44 
48  protected $tree;
49 
53  protected $access;
54 
55  public $public_deletion_enabled = false;
56  public $repository_mode = false;
57  public $old = false;
66  public function __construct($a_rep_obj_id = "", $a_obj_id = "", $a_obj_type = "", $a_include_subobjects = false)
67  {
68  global $DIC;
69 
70  $this->user = $DIC->user();
71  $this->settings = $DIC->settings();
72  $this->obj_definition = $DIC["objDefinition"];
73  $this->tree = $DIC->repositoryTree();
74  $this->access = $DIC->access();
75  $ilCtrl = $DIC->ctrl();
76  $lng = $DIC->language();
77 
78  $lng->loadLanguageModule("notes");
79 
80  $ilCtrl->saveParameter($this, "notes_only");
81  $this->only = $_GET["notes_only"];
82 
83  $this->rep_obj_id = $a_rep_obj_id;
84  $this->obj_id = $a_obj_id;
85  $this->obj_type = $a_obj_type;
86  $this->inc_sub = $a_include_subobjects;
87 
88  // auto-detect object type
89  if (!$this->obj_type && $a_rep_obj_id) {
90  $this->obj_type = ilObject::_lookupType($a_rep_obj_id);
91  }
92 
93  $this->ajax = $ilCtrl->isAsynch();
94 
95  $this->ctrl = $ilCtrl;
96  $this->lng = $lng;
97 
98  $this->anchor_jump = true;
99  $this->add_note_form = false;
100  $this->edit_note_form = false;
101  $this->private_enabled = false;
102  $notes_settings = new ilSetting("notes");
103  $id = $this->rep_obj_id . "_" . $this->obj_id . "_" . $this->obj_type;
104  //if ($notes_settings->get("activate_".$id))
105  if (ilNote::commentsActivated($this->rep_obj_id, $this->obj_id, $this->obj_type)) {
106  $this->public_enabled = true;
107  } else {
108  $this->public_enabled = false;
109  }
110  $this->enable_hiding = false;
111  $this->targets_enabled = false;
112  $this->multi_selection = false;
113  $this->export_html = false;
114  $this->print = false;
115  $this->comments_settings = false;
116 
117  $this->note_img = array(
119  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
120  "alt" => $lng->txt("note")),
122  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
123  "alt" => $lng->txt("note") . ", " . $lng->txt("important")),
125  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
126  "alt" => $lng->txt("note") . ", " . $lng->txt("question")),
127  IL_NOTE_PRO => array(
128  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
129  "alt" => $lng->txt("note") . ", " . $lng->txt("pro")),
131  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
132  "alt" => $lng->txt("note") . ", " . $lng->txt("contra"))
133  );
134 
135  $this->comment_img = array(
137  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
138  "alt" => $lng->txt("notes_comment")),
140  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
141  "alt" => $lng->txt("notes_comment") . ", " . $lng->txt("important")),
143  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
144  "alt" => $lng->txt("notes_comment") . ", " . $lng->txt("question")),
145  IL_NOTE_PRO => array(
146  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
147  "alt" => $lng->txt("notes_comment") . ", " . $lng->txt("pro")),
149  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
150  "alt" => $lng->txt("notes_comment") . ", " . $lng->txt("contra"))
151  );
152 
153  // default: notes for repository objects
154  $this->setRepositoryMode(true);
155  }
156 
160  public function executeCommand()
161  {
162  $cmd = $this->ctrl->getCmd("getNotesHTML");
163  $next_class = $this->ctrl->getNextClass($this);
164 
165  switch ($next_class) {
166  default:
167  return $this->$cmd();
168  break;
169  }
170  }
171 
175  public function enablePrivateNotes($a_enable = true)
176  {
177  $this->private_enabled = $a_enable;
178  }
179 
183  public function enablePublicNotes($a_enable = true)
184  {
185  $this->public_enabled = $a_enable;
186  }
187 
191  public function enableCommentsSettings($a_enable = true)
192  {
193  $this->comments_settings = $a_enable;
194  }
195 
199  public function enablePublicNotesDeletion($a_enable = true)
200  {
201  $this->public_deletion_enabled = $a_enable;
202  }
203 
207  public function enableHiding($a_enable = true)
208  {
209  $this->enable_hiding = $a_enable;
210  }
211 
215  public function enableTargets($a_enable = true)
216  {
217  $this->targets_enabled = $a_enable;
218  }
219 
223  public function enableMultiSelection($a_enable = true)
224  {
225  $this->multi_selection = $a_enable;
226  }
227 
231  public function enableAnchorJump($a_enable = true)
232  {
233  $this->anchor_jump = $a_enable;
234  }
235 
241  public function setRepositoryMode($a_value)
242  {
243  $this->repository_mode = (bool) $a_value;
244  }
245 
246 
253  public function getOnlyNotesHTML()
254  {
256  $ilCtrl->setParameter($this, "notes_only", "notes");
257  $this->only = "notes";
258  return $this->getNotesHTML($a_init_form = true);
259  }
260 
267  public function getOnlyCommentsHTML()
268  {
270  $ilCtrl->setParameter($this, "notes_only", "comments");
271  $this->only = "comments";
272  return $this->getNotesHTML($a_init_form = true);
273  }
274 
275 
276  /***
277  * get note lists html code
278  */
279  public function getNotesHTML($a_init_form = true)
280  {
282  $lng = $this->lng;
285 
286  $lng->loadLanguageModule("notes");
287 
288  $ntpl = new ilTemplate(
289  "tpl.notes_and_comments.html",
290  true,
291  true,
292  "Services/Notes"
293  );
294 
295  // check, whether column is hidden due to processing in other column
296  $hide_comments = ($this->only == "notes");
297  $hide_notes = ($this->only == "comments");
298  switch ($ilCtrl->getCmd()) {
299  case "addNoteForm":
300  case "editNoteForm":
301  case "addNote":
302  case "updateNote":
303  if ($_GET["note_type"] == IL_NOTE_PRIVATE) {
304  $hide_comments = true;
305  }
306  if ($_GET["note_type"] == IL_NOTE_PUBLIC) {
307  $hide_notes = true;
308  }
309  break;
310  }
311 
312 
313  // temp workaround: only show comments (if both have been activated)
314  if ($this->private_enabled && $this->public_enabled
315  && $this->only != "notes") {
316  $this->private_enabled = false;
317  }
318 
319  $nodes_col = false;
320  if ($this->private_enabled && ($ilUser->getId() != ANONYMOUS_USER_ID)
321  && !$hide_notes) {
322  $ntpl->setCurrentBlock("notes_col");
323  $ntpl->setVariable("NOTES", $this->getNoteListHTML(IL_NOTE_PRIVATE, $a_init_form));
324  $ntpl->parseCurrentBlock();
325  $nodes_col = true;
326  }
327 
328  // #15948 - public enabled vs. comments_settings
329  $comments_col = false;
330  if ($this->public_enabled && (!$this->delete_note || $this->public_deletion_enabled || $ilSetting->get("comments_del_user", 0))
331  && !$hide_comments /* && $ilUser->getId() != ANONYMOUS_USER_ID */) {
332  $ntpl->setVariable("COMMENTS", $this->getNoteListHTML(IL_NOTE_PUBLIC, $a_init_form));
333  $comments_col = true;
334  }
335 
336  // Comments Settings
337  if ($this->comments_settings && !$hide_comments && !$this->delete_note
338  && !$this->edit_note_form && !$this->add_note_form && $ilUser->getId() != ANONYMOUS_USER_ID) {
339  $notes_settings = new ilSetting("notes");
340  $id = $this->rep_obj_id . "_" . $this->obj_id . "_" . $this->obj_type;
341  //$active = $notes_settings->get("activate_".$id);
342  $active = ilNote::commentsActivated($this->rep_obj_id, $this->obj_id, $this->obj_type);
343 
344  if ($active) {
345  $this->renderLink(
346  $ntpl,
347  "comments_settings",
348  $lng->txt("notes_deactivate_comments"),
349  "deactivateComments",
350  "notes_top"
351  );
352  $ntpl->setCurrentBlock("comments_settings2");
353  } else {
354  $this->renderLink(
355  $ntpl,
356  "comments_settings",
357  $lng->txt("notes_activate_comments"),
358  "activateComments",
359  "notes_top"
360  );
361  $ntpl->setCurrentBlock("comments_settings2");
362 
363  if ($this->ajax && !$comments_col) {
364  $ntpl->setVariable(
365  "COMMENTS_MESS",
366  $ntpl->getMessageHTML($lng->txt("comments_feature_currently_not_activated_for_object"), "info")
367  );
368  }
369  }
370  $ntpl->parseCurrentBlock();
371 
372  if (!$comments_col) {
373  $ntpl->setVariable("COMMENTS", "");
374  }
375 
376  $comments_col = true;
377  }
378 
379  if ($comments_col) {
380  $ntpl->setCurrentBlock("comments_col");
381  if ($nodes_col) {
382  // $ntpl->touchBlock("comments_style");
383  }
384  $ntpl->parseCurrentBlock();
385  }
386 
387  if ($this->ajax) {
388  echo $ntpl->get();
389  exit;
390  }
391 
392  return $ntpl->get();
393  }
394 
398  public function activateComments()
399  {
401 
402  $notes_settings = new ilSetting("notes");
403 
404  if ($this->comments_settings) {
405  $id = $this->rep_obj_id . "_" . $this->obj_id . "_" . $this->obj_type;
406  //$notes_settings->set("activate_".$id, 1);
407  ilNote::activateComments($this->rep_obj_id, $this->obj_id, $this->obj_type, true);
408  }
409 
410  $ilCtrl->redirectByClass("ilnotegui", "showNotes", "", $this->ajax);
411  // $ilCtrl->redirectByClass("ilnotegui", "getNotesHtml", "", $this->ajax);
412  }
413 
417  public function deactivateComments()
418  {
420 
421  $notes_settings = new ilSetting("notes");
422 
423  if ($this->comments_settings) {
424  $id = $this->rep_obj_id . "_" . $this->obj_id . "_" . $this->obj_type;
425  //$notes_settings->set("activate_".$id, 0);
426  ilNote::activateComments($this->rep_obj_id, $this->obj_id, $this->obj_type, false);
427  }
428 
429  $ilCtrl->redirectByClass("ilnotegui", "showNotes", "", $this->ajax);
430  //$ilCtrl->redirectByClass("ilnotegui", "getNotesHtml", "", $this->ajax);
431  }
432 
436  public function getNoteListHTML($a_type = IL_NOTE_PRIVATE, $a_init_form = true)
437  {
438  $lng = $this->lng;
441 
442  include_once("./Services/User/classes/class.ilUserUtil.php");
443 
444  $suffix = ($a_type == IL_NOTE_PRIVATE)
445  ? "private"
446  : "public";
447 
448  /* user settings are deprecated
449  $user_setting_notes_public_all = $ilUser->getPref("notes_pub_all");
450  $user_setting_notes_by_type = $ilUser->getPref("notes_".$suffix);
451  */
452  $user_setting_notes_public_all = "y";
453  $user_setting_notes_by_type = "y";
454 
455  if ($this->delete_note || $this->export_html || $this->print) {
456  if ($_GET["note_id"] != "") {
457  $filter = $_GET["note_id"];
458  } else {
459  $filter = $_POST["note"];
460  }
461  }
462 
463  $notes = ilNote::_getNotesOfObject(
464  $this->rep_obj_id,
465  $this->obj_id,
466  $this->obj_type,
467  $a_type,
468  $this->inc_sub,
469  $filter,
470  $user_setting_notes_public_all,
471  $this->repository_mode,
472  (bool) $_SESSION["comments_sort_asc"]
473  );
474 
475  $all_notes = ilNote::_getNotesOfObject(
476  $this->rep_obj_id,
477  $this->obj_id,
478  $this->obj_type,
479  $a_type,
480  $this->inc_sub,
481  $filter,
482  "",
483  $this->repository_mode
484  );
485 
486  $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes");
487 
488  if ($this->ajax) {
489  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
490  $tpl->setCurrentBlock("close_img");
491  $tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
492  $tpl->parseCurrentBlock();
493  }
494 
495  // show counter if notes are hidden
496  $cnt_str = (count($all_notes) > 0)
497  ? " (" . count($all_notes) . ")"
498  : "";
499 
500  // title
501  if ($this->ajax) {
502  switch ($this->obj_type) {
503  case "grpr":
504  case "catr":
505  case "crsr":
506  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
507  $title = ilContainerReference::_lookupTitle($this->rep_obj_id);
508  break;
509 
510  default:
511  $title = ilObject::_lookupTitle($this->rep_obj_id);
512  break;
513  }
514 
515  $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny"));
516 
517  // add sub-object if given
518  if ($this->obj_id) {
519  $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id);
520  if ($sub_title) {
521  $title .= " - " . $sub_title;
522  }
523  }
524 
525  $tpl->setCurrentBlock("title");
526  $tpl->setVariable("TITLE", $img . " " . $title);
527  $tpl->parseCurrentBlock();
528  }
529 
530  if ($this->delete_note) {
531  $cnt_str = "";
532  }
533  if ($a_type == IL_NOTE_PRIVATE) {
534  $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes") . $cnt_str);
535  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
536  } else {
537  $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments") . $cnt_str);
538  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
539  }
540  $anch = $this->anchor_jump
541  ? "notes_top"
542  : "";
543  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch));
544  if ($this->ajax) {
545  $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '" .
546  $ilCtrl->getFormActionByClass("ilnotegui", "", "", true) .
547  "'); return false;\"";
548  $tpl->setVariable("ON_SUBMIT_FORM", $os);
549  $tpl->setVariable("FORM_ID", "Ajax");
550  }
551 
552  if ($this->export_html || $this->print) {
553  $tpl->touchBlock("print_style");
554  }
555 
556  // show add new note button
557  if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
558  !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID) {
559  if (!$this->inc_sub) { // we cannot offer add button if aggregated notes
560  // are displayed
561  if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC) {
562  $tpl->setCurrentBlock("add_note_btn");
563  if ($a_type == IL_NOTE_PUBLIC) {
564  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment"));
565  } else {
566  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
567  }
568  $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm") .
569  "#note_edit");
570  $tpl->parseCurrentBlock();
571  }
572  }
573  }
574 
575  // show show/hide button for note list
576  if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note
577  && !$this->export_html && !$this->print && !$this->edit_note_form
578  && !$this->add_note_form) {
579  if ($user_setting_notes_by_type == "n") {
580  if ($a_type == IL_NOTE_PUBLIC) {
581  $txt = $lng->txt("notes_show_comments");
582  } else {
583  $txt = $lng->txt("show_" . $suffix . "_notes");
584  }
585  $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top");
586  } else {
587  // never individually hide for anonymous users
588  if (($ilUser->getId() != ANONYMOUS_USER_ID)) {
589  if ($a_type == IL_NOTE_PUBLIC) {
590  $txt = $lng->txt("notes_hide_comments");
591  } else {
592  $txt = $lng->txt("hide_" . $suffix . "_notes");
593  }
594  $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top");
595 
596  // show all public notes / my notes only switch
597  if ($a_type == IL_NOTE_PUBLIC) {
598  if ($user_setting_notes_public_all == "n") {
599  $this->renderLink(
600  $tpl,
601  "all_pub_notes",
602  $lng->txt("notes_all_comments"),
603  "showAllPublicNotes",
604  "notes_top"
605  );
606  } else {
607  $this->renderLink(
608  $tpl,
609  "my_pub_notes",
610  $lng->txt("notes_my_comments"),
611  "showMyPublicNotes",
612  "notes_top"
613  );
614  }
615  }
616  }
617  }
618  }
619 
620  // show add new note text area
621  if (!$this->edit_note_form && $user_setting_notes_by_type != "n" &&
622  !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID) {
623  if ($a_init_form) {
624  $this->initNoteForm("create", $a_type);
625  }
626 
627  $tpl->setCurrentBlock("edit_note_form");
628  // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
629  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
630  $tpl->parseCurrentBlock();
631 
632  $tpl->parseCurrentBlock();
633  $tpl->setCurrentBlock("note_row");
634  $tpl->parseCurrentBlock();
635  }
636 
637  // list all notes
638  if ($user_setting_notes_by_type != "n" || !$this->enable_hiding) {
641 
642  if (sizeof($notes)) {
643  if ((int) $_SESSION["comments_sort_asc"] == 1) {
644  $sort_txt = $lng->txt("notes_sort_desc");
645  $sort_cmd = "listSortDesc";
646  } else {
647  $sort_txt = $lng->txt("notes_sort_asc");
648  $sort_cmd = "listSortAsc";
649  }
650  $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch);
651  }
652 
653  $notes_given = false;
654  foreach ($notes as $note) {
655  if ($this->edit_note_form && ($note->getId() == $_GET["note_id"])
656  && $a_type == $_GET["note_type"]) {
657  if ($a_init_form) {
658  $this->initNoteForm("edit", $a_type, $note);
659  }
660  $tpl->setCurrentBlock("edit_note_form");
661  // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
662  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
663  $tpl->parseCurrentBlock();
664  } else {
665  $cnt_col = 2;
666 
667  // delete note stuff for all private notes
668  if ($this->checkDeletion($note)
669  && !$this->delete_note
670  && !$this->export_html && !$this->print
671  && !$this->edit_note_form && !$this->add_note_form) {
672  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
673  $this->renderLink(
674  $tpl,
675  "delete_note",
676  $lng->txt("delete"),
677  "deleteNote",
678  "note_" . $note->getId()
679  );
680  }
681 
682  // checkboxes in multiselection mode
683  if ($this->multi_selection && !$this->delete_note) {
684  $tpl->setCurrentBlock("checkbox_col");
685  $tpl->setVariable("CHK_NOTE", "note[]");
686  $tpl->setVariable("CHK_NOTE_ID", $note->getId());
687  $tpl->parseCurrentBlock();
688  $cnt_col = 1;
689  }
690 
691  // edit note stuff for all private notes
692  if ($this->checkEdit($note)) {
693  if (!$this->delete_note && !$this->export_html && !$this->print
694  && !$this->edit_note_form && !$this->add_note_form) {
695  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
696  $this->renderLink(
697  $tpl,
698  "edit_note",
699  $lng->txt("edit"),
700  "editNoteForm",
701  "note_edit"
702  );
703  }
704  }
705 
706  $tpl->setVariable("CNT_COL", $cnt_col);
707 
708  // output author account
709  if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor())) {
710  //$tpl->setCurrentBlock("author");
711  //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
712  //$tpl->parseCurrentBlock();
713  $tpl->setCurrentBlock("user_img");
714  $tpl->setVariable(
715  "USR_IMG",
716  ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall")
717  );
718  $tpl->setVariable("USR_ALT", $lng->txt("user_image") . ": " .
719  ilObjUser::_lookupLogin($note->getAuthor()));
720  $tpl->parseCurrentBlock();
721  $tpl->setVariable(
722  "TXT_USR",
723  ilUserUtil::getNamePresentation($note->getAuthor(), false, false) . " - "
724  );
725  }
726 
727  // last edited
728  if ($note->getUpdateDate() != null) {
729  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
730  $tpl->setVariable(
731  "DATE_LAST_EDIT",
732  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME))
733  );
734  } else {
735  $tpl->setVariable(
736  "VAL_DATE",
737  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME))
738  );
739  }
740 
741  // hidden note ids for deletion
742  if ($this->delete_note) {
743  $tpl->setCurrentBlock("delete_ids");
744  $tpl->setVariable("HID_NOTE", "note[]");
745  $tpl->setVariable("HID_NOTE_ID", $note->getId());
746  $tpl->parseCurrentBlock();
747  }
748  $target = $note->getObject();
749 
750  // target objects
751  $this->showTargets(
752  $tpl,
753  $this->rep_obj_id,
754  $note->getId(),
755  $target["obj_type"],
756  $target["obj_id"]
757  );
758 
759  $rowclass = ($rowclass != "tblrow1")
760  ? "tblrow1"
761  : "tblrow2";
762  if (!$this->export_html && !$this->print) {
763  $tpl->setCurrentBlock("note_img");
764  if ($a_type == IL_NOTE_PUBLIC) {
765  $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]);
766  $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]);
767  } else {
768  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
769  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
770  }
771  $tpl->parseCurrentBlock();
772  } else {
773  switch ($note->getLabel()) {
774  case IL_NOTE_UNLABELED:
775  $tpl->setVariable("EXP_ICON", "[&nbsp;]");
776  break;
777 
778  case IL_NOTE_IMPORTANT:
779  $tpl->setVariable("EXP_ICON", "[!]");
780  break;
781 
782  case IL_NOTE_QUESTION:
783  $tpl->setVariable("EXP_ICON", "[?]");
784  break;
785 
786  case IL_NOTE_PRO:
787  $tpl->setVariable("EXP_ICON", "[+]");
788  break;
789 
790  case IL_NOTE_CONTRA:
791  $tpl->setVariable("EXP_ICON", "[-]");
792  break;
793  }
794  }
795  $tpl->setCurrentBlock("note");
796  $tpl->setVariable("ROWCLASS", $rowclass);
797  $text = (trim($note->getText()) != "")
798  ? nl2br($note->getText())
799  : "<p class='subtitle'>" . $lng->txt("note_content_removed") . "</p>";
800  $tpl->setVariable("NOTE_TEXT", $text);
801  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
802  $tpl->setVariable("NOTE_ID", $note->getId());
803  $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC
804  ? "ilComment"
805  : "ilNote");
806  $tpl->parseCurrentBlock();
807  }
808  $tpl->setCurrentBlock("note_row");
809  $tpl->parseCurrentBlock();
810  $notes_given = true;
811  }
812 
813  if (!$notes_given) {
814  $tpl->setCurrentBlock("no_notes");
815  if ($a_type == IL_NOTE_PUBLIC) {
816  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments"));
817  }
818  /* else
819  {
820  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes"));
821  }*/
822  $tpl->parseCurrentBlock();
823  }
824 
826 
827  // multiple items commands
828  if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form
829  && count($notes) > 0) {
830  if ($a_type == IL_NOTE_PRIVATE) {
831  $tpl->setCurrentBlock("delete_cmd");
832  $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
833  $tpl->parseCurrentBlock();
834  }
835 
836  $tpl->setCurrentBlock("multiple_commands");
837  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
838  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
839  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
840  $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
841  $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
842  $tpl->parseCurrentBlock();
843  }
844 
845  // delete / cancel row
846  if ($this->delete_note) {
847  $tpl->setCurrentBlock("delete_cancel");
848  $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
849  $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
850  $tpl->parseCurrentBlock();
851  }
852 
853  // print
854  if ($this->print) {
855  $tpl->touchBlock("print_js");
856  $tpl->setCurrentBlock("print_back");
857  $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
858  $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
859  $tpl->parseCurrentBlock();
860  }
861  }
862 
863  // message
864  switch ($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess) {
865  case "mod":
866  $mtype = "success";
867  $mtxt = $lng->txt("msg_obj_modified");
868  break;
869 
870  case "ntsdel":
871  $mtype = "success";
872  $mtxt = ($a_type == IL_NOTE_PRIVATE)
873  ? $lng->txt("notes_notes_deleted")
874  : $lng->txt("notes_comments_deleted");
875  break;
876 
877  case "ntdel":
878  $mtype = "success";
879  $mtxt = ($a_type == IL_NOTE_PRIVATE)
880  ? $lng->txt("notes_note_deleted")
881  : $lng->txt("notes_comment_deleted");
882  break;
883 
884  case "frmfld":
885  $mtype = "failure";
886  $mtxt = $lng->txt("form_input_not_valid");
887  break;
888 
889  case "qdel":
890  $mtype = "question";
891  $mtxt = $lng->txt("info_delete_sure");
892  break;
893 
894  case "noc":
895  $mtype = "failure";
896  $mtxt = $lng->txt("no_checkbox");
897  break;
898  }
899  if ($mtxt != "") {
900  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
901  } else {
902  $tpl->setVariable("MESS", "");
903  }
904 
905 
906 
907  if ($this->delete_note && count($notes) == 0) {
908  return "";
909  } else {
910  return $tpl->get();
911  }
912  }
913 
921  protected function getSubObjectTitle($parent_obj_id, $sub_obj_id)
922  {
923  $objDefinition = $this->obj_definition;
925 
926  $parent_type = ilObject::_lookupType($parent_obj_id);
927  $parent_class = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
928  $parent_path = $ilCtrl->lookupClassPath($parent_class);
929  include_once $parent_path;
930  if (method_exists($parent_class, "lookupSubObjectTitle")) {
931  return call_user_func_array(array($parent_class, "lookupSubObjectTitle"), array($parent_obj_id, $sub_obj_id));
932  }
933  }
934 
938  public function checkDeletion($a_note)
939  {
942 
943  if ($ilUser->getId() == ANONYMOUS_USER_ID) {
944  return false;
945  }
946 
947  $is_author = ($a_note->getAuthor() == $ilUser->getId());
948 
949  if ($a_note->getType() == IL_NOTE_PRIVATE && $is_author) {
950  return true;
951  }
952 
953  if ($a_note->getType() == IL_NOTE_PUBLIC && $this->public_deletion_enabled) {
954  return true;
955  }
956 
957  if ($a_note->getType() == IL_NOTE_PUBLIC && $is_author && $ilSetting->get("comments_del_user", 0)) {
958  return true;
959  }
960 
961  return false;
962  }
963 
967  public function checkEdit($a_note)
968  {
970 
971  if ($a_note->getAuthor() == $ilUser->getId()
972  && ($ilUser->getId() != ANONYMOUS_USER_ID)) {
973  return true;
974  }
975  return false;
976  }
977 
978 
984  public function initNoteForm($a_mode = "edit", $a_type, $a_note = null)
985  {
986  $lng = $this->lng;
988 
989  $this->form_tpl = new ilTemplate("tpl.notes_edit.html", true, true, "Services/Notes");
990  if ($a_note) {
991  $this->form_tpl->setVariable("VAL_NOTE", ilUtil::prepareFormOutput($a_note->getText()));
992  $this->form_tpl->setVariable("NOTE_ID", $a_note->getId());
993  }
994 
995  if ($a_mode == "create") {
996  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
997  ? $lng->txt("note_add_comment")
998  : $lng->txt("note_add_note"));
999  $this->form_tpl->setVariable("CMD", "addNote");
1000  } else {
1001  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
1002  ? $lng->txt("note_update_comment")
1003  : $lng->txt("note_update_note"));
1004  $this->form_tpl->setVariable("CMD", "updateNote");
1005  }
1006 
1007  return;
1008  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1009  $this->form = new ilPropertyFormGUI();
1010  $this->form->setOpenTag(false);
1011  $this->form->setCloseTag(false);
1012  $this->form->setDisableStandardMessage(true);
1013 
1014  // subject
1015  /* $ti = new ilTextInputGUI($this->lng->txt("subject"), "sub_note");
1016  $ti->setRequired(true);
1017  $ti->setMaxLength(200);
1018  $ti->setSize(40);
1019  if ($a_note)
1020  {
1021  $ti->setValue($a_note->getSubject());
1022  }
1023  $this->form->addItem($ti);*/
1024 
1025  // text
1026  // $ta = new ilTextAreaInputGUI(($a_type == IL_NOTE_PUBLIC)
1027  // ? $lng->txt("notes_comment")
1028  // : $lng->txt("note"), "note");
1029  $ta = new ilTextAreaInputGUI("", "note");
1030  $ta->setCols(40);
1031  $ta->setRows(4);
1032  if ($a_note) {
1033  $ta->setValue($a_note->getText());
1034  }
1035  $this->form->addItem($ta);
1036 
1037  // label
1038  /* $options = array(
1039  IL_NOTE_UNLABELED => $lng->txt("unlabeled"),
1040  IL_NOTE_QUESTION => $lng->txt("question"),
1041  IL_NOTE_IMPORTANT => $lng->txt("important"),
1042  IL_NOTE_PRO => $lng->txt("pro"),
1043  IL_NOTE_CONTRA => $lng->txt("contra"),
1044  );
1045  $si = new ilSelectInputGUI($this->lng->txt("notes_label"), "note_label");
1046  $si->setOptions($options);
1047  if ($a_note)
1048  {
1049  $si->setValue($a_note->getLabel());
1050  }
1051  $this->form->addItem($si); */
1052 
1053  // hidden note id
1054  if ($a_note) {
1055  $hi = new ilHiddenInputGUI("note_id");
1056  $hi->setValue($_GET["note_id"]);
1057  $this->form->addItem($hi);
1058  }
1059 
1060  // save and cancel commands
1061  if ($a_mode == "create") {
1062  $this->form->addCommandButton("addNote", $lng->txt("save"));
1063  /* $this->form->addCommandButton("cancelAddNote", $lng->txt("cancel"));
1064  $this->form->setTitle($a_type == IL_NOTE_PUBLIC
1065  ? $lng->txt("notes_add_comment")
1066  : $lng->txt("notes_add_note"));*/
1067  } else {
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 
1082  public function getPDNoteHTML($note_id)
1083  {
1084  $lng = $this->lng;
1085  $ilCtrl = $this->ctrl;
1086  $ilUser = $this->user;
1087 
1088  $tpl = new ilTemplate("tpl.pd_note.html", true, true, "Services/Notes");
1089  $note = new ilNote($note_id);
1090  $target = $note->getObject();
1091 
1092  if ($note->getAuthor() != $ilUser->getId()) {
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(
1101  "LINK_EDIT_NOTE",
1102  $ilCtrl->getLinkTargetByClass(
1103  array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"),
1104  "editNoteForm"
1105  )
1106  );
1107  $tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
1108  $tpl->parseCurrentBlock();
1109  $ilCtrl->clearParametersByClass("ilnotegui");
1110 
1111  $tpl->setCurrentBlock("note_img");
1112  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
1113  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
1114  $tpl->parseCurrentBlock();
1115 
1116  // last edited
1117  if ($note->getUpdateDate() != null) {
1118  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
1119  $tpl->setVariable(
1120  "DATE_LAST_EDIT",
1121  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME))
1122  );
1123  } else {
1124  //$tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
1125  $tpl->setVariable(
1126  "VAL_DATE",
1127  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME))
1128  );
1129  }
1130 
1131  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
1132  $text = (trim($note->getText()) != "")
1133  ? nl2br($note->getText())
1134  : "<p class='subtitle'>" . $lng->txt("note_content_removed") . "</p>";
1135  $tpl->setVariable("NOTE_TEXT", $text);
1136  $this->showTargets($tpl, $target["rep_obj_id"], $note_id, $target["obj_type"], $target["obj_id"]);
1137  return $tpl->get();
1138  }
1139 
1143  public function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
1144  {
1145  $tree = $this->tree;
1146  $ilAccess = $this->access;
1147  $objDefinition = $this->obj_definition;
1148  $ilUser = $this->user;
1149 
1150  if ($this->targets_enabled) {
1151  if ($a_rep_obj_id > 0) {
1152  // get all visible references of target object
1153 
1154  // repository
1155  $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
1156  if ($ref_ids) {
1157  $vis_ref_ids = array();
1158  foreach ($ref_ids as $ref_id) {
1159  if ($ilAccess->checkAccess("visible", "", $ref_id)) {
1160  $vis_ref_ids[] = $ref_id;
1161  }
1162  }
1163 
1164  // output links to targets
1165  if (count($vis_ref_ids) > 0) {
1166  foreach ($vis_ref_ids as $vis_ref_id) {
1167  $type = ilObject::_lookupType($vis_ref_id, true);
1168  $sub_link = $sub_title = "";
1169  if ($type == "sahs") { // bad hack, needs general procedure
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  $sub_link = "goto.php?target=sahs_" . $vis_ref_id . "_" . $a_obj_id;
1174  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1175  $sub_title = ilSCORM2004Node::_lookupTitle($a_obj_id);
1176  $sub_icon = ilUtil::getImagePath("icon_" . $a_obj_type . ".svg");
1177  }
1178  } elseif ($type == "poll") {
1179  include_once "Services/Link/classes/class.ilLink.php";
1180  $title = ilObject::_lookupTitle($a_rep_obj_id);
1181  $link = ilLink::_getLink($vis_ref_id, "poll");
1182  } elseif ($a_obj_type != "pg") {
1183  if (!is_object($this->item_list_gui[$type])) {
1184  $class = $objDefinition->getClassName($type);
1185  $location = $objDefinition->getLocation($type);
1186  $full_class = "ilObj" . $class . "ListGUI";
1187  include_once($location . "/class." . $full_class . ".php");
1188  $this->item_list_gui[$type] = new $full_class();
1189  }
1190 
1191  // for references, get original title
1192  // (link will lead to orignal, which basically is wrong though)
1193  if ($a_obj_type == "crsr" || $a_obj_type == "catr" || $a_obj_type == "grpr") {
1194  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
1195  $tgt_obj_id = ilContainerReference::_lookupTargetId($a_rep_obj_id);
1196  $title = ilObject::_lookupTitle($tgt_obj_id);
1197  } else {
1198  $title = ilObject::_lookupTitle($a_rep_obj_id);
1199  }
1200  $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
1201  $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
1202 
1203  // workaround, because # anchor can't be passed through frameset
1204  $link = ilUtil::appendUrlParameterString($link, "anchor=note_" . $a_note_id);
1205 
1206  $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link) . "#note_" . $a_note_id;
1207  } else {
1208  $title = ilObject::_lookupTitle($a_rep_obj_id);
1209  $link = "goto.php?target=pg_" . $a_obj_id . "_" . $vis_ref_id;
1210  }
1211 
1212  $par_id = $tree->getParentId($vis_ref_id);
1213 
1214  // sub object link
1215  if ($sub_link != "") {
1216  if ($this->export_html || $this->print) {
1217  $tpl->setCurrentBlock("exp_target_sub_object");
1218  } else {
1219  $tpl->setCurrentBlock("target_sub_object");
1220  $tpl->setVariable("LINK_SUB_TARGET", $sub_link);
1221  }
1222  $tpl->setVariable("TXT_SUB_TARGET", $sub_title);
1223  $tpl->setVariable("IMG_SUB_TARGET", $sub_icon);
1224  $tpl->parseCurrentBlock();
1225  }
1226 
1227  // container and object link
1228  if ($this->export_html || $this->print) {
1229  $tpl->setCurrentBlock("exp_target_object");
1230  } else {
1231  $tpl->setCurrentBlock("target_object");
1232  $tpl->setVariable("LINK_TARGET", $link);
1233  }
1234  $tpl->setVariable(
1235  "TXT_CONTAINER",
1237  ilObject::_lookupObjId($par_id)
1238  )
1239  );
1240  $tpl->setVariable(
1241  "IMG_CONTAINER",
1243  ilObject::_lookupObjId($par_id),
1244  "tiny"
1245  )
1246  );
1247  $tpl->setVariable("TXT_TARGET", $title);
1248  $tpl->setVariable(
1249  "IMG_TARGET",
1250  ilObject::_getIcon($a_rep_obj_id, "tiny")
1251  );
1252 
1253  $tpl->parseCurrentBlock();
1254  }
1255  $tpl->touchBlock("target_objects");
1256  }
1257  }
1258  // personal workspace
1259  else {
1260  // we only need 1 instance
1261  if (!$this->wsp_tree) {
1262  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1263  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
1264  $this->wsp_tree = new ilWorkspaceTree($ilUser->getId());
1265  $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
1266  }
1267  $node_id = $this->wsp_tree->lookupNodeId($a_rep_obj_id);
1268  if ($this->wsp_access_handler->checkAccess("visible", "", $node_id)) {
1269  $path = $this->wsp_tree->getPathFull($node_id);
1270  if ($path) {
1271  $item = array_pop($path);
1272  $parent = array_pop($path);
1273 
1274  if (!$parent["title"]) {
1275  $parent["title"] = $this->lng->txt("wsp_personal_workspace");
1276  }
1277 
1278  // sub-objects
1279  $additional = null;
1280  if ($a_obj_id) {
1281  $sub_title = $this->getSubObjectTitle($a_rep_obj_id, $a_obj_id);
1282  if ($sub_title) {
1283  $item["title"] .= " (" . $sub_title . ")";
1284  $additional = "_" . $a_obj_id;
1285  }
1286  }
1287 
1288  $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $a_rep_obj_id, $additional);
1289  }
1290  // shared resource
1291  else {
1292  $owner = ilObject::_lookupOwner($a_rep_obj_id);
1293  $parent["title"] = $this->lng->txt("wsp_tab_shared") .
1294  " (" . ilObject::_lookupOwnerName($owner) . ")";
1295  $item["title"] = ilObject::_lookupTitle($a_rep_obj_id);
1296  $link = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=" .
1297  $owner;
1298  }
1299 
1300  // container and object link
1301  if ($this->export_html || $this->print) {
1302  $tpl->setCurrentBlock("exp_target_object");
1303  } else {
1304  $tpl->setCurrentBlock("target_object");
1305  $tpl->setVariable("LINK_TARGET", $link);
1306  }
1307 
1308 
1309  // :TODO: no images in template ?
1310 
1311  $tpl->setVariable("TXT_CONTAINER", $parent["title"]);
1312  $tpl->setVariable(
1313  "IMG_CONTAINER",
1314  ilObject::_getIcon($parent["obj_id"], "tiny")
1315  );
1316 
1317  $tpl->setVariable("TXT_TARGET", $item["title"]);
1318  $tpl->setVariable(
1319  "IMG_TARGET",
1320  ilObject::_getIcon($a_rep_obj_id, "tiny")
1321  );
1322 
1323  $tpl->parseCurrentBlock();
1324  }
1325  }
1326  }
1327  }
1328  }
1329 
1333  public function addNoteForm($a_init_form = true)
1334  {
1335  $ilUser = $this->user;
1336 
1337  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1338  ? "private"
1339  : "public";
1340  $ilUser->setPref("notes_" . $suffix, "y");
1341 
1342  $this->add_note_form = true;
1343  return $this->getNotesHTML($a_init_form);
1344  }
1345 
1349  public function cancelAddNote()
1350  {
1351  return $this->getNotesHTML();
1352  }
1353 
1357  public function cancelUpdateNote()
1358  {
1359  return $this->getNotesHTML();
1360  }
1361 
1365  public function addNote()
1366  {
1367  $ilUser = $this->user;
1368  $lng = $this->lng;
1369  $ilCtrl = $this->ctrl;
1370 
1371  $this->initNoteForm("create", $_GET["note_type"]);
1372 
1373  //if ($this->form->checkInput())
1374  if ($_POST["note"] != "") {
1375  $note = new ilNote();
1376  $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
1377  $note->setInRepository($this->repository_mode);
1378  $note->setType($_GET["note_type"]);
1379  $note->setAuthor($ilUser->getId());
1380  $note->setText(ilUtil::stripslashes($_POST["note"]));
1381  // $note->setSubject($_POST["sub_note"]);
1382  // $note->setLabel($_POST["note_label"]);
1383  $note->create();
1384 
1385  $this->notifyObserver("new", $note);
1386 
1387  $ilCtrl->setParameter($this, "note_mess", "mod");
1388  // $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1389  }
1390  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1391  // $this->note_mess = "frmfld";
1392 // $this->form->setValuesByPost();
1393 // return $this->addNoteForm(false);;
1394  }
1395 
1399  public function updateNote()
1400  {
1401  $ilUser = $this->user;
1402  $lng = $this->lng;
1403  $ilCtrl = $this->ctrl;
1404 
1405  $note = new ilNote(ilUtil::stripSlashes($_POST["note_id"]));
1406  $this->initNoteForm(
1407  "edit",
1408  $note->getType(),
1409  $note
1410  );
1411 
1412  // if ($this->form->checkInput())
1413  // if ($_POST["note"] != "")
1414  // {
1415  $note->setText(ilUtil::stripSlashes($_POST["note"]));
1416  $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
1417  $note->setLabel(ilUtil::stripSlashes($_POST["note_label"]));
1418  if ($this->checkEdit($note)) {
1419  $note->update();
1420 
1421  $this->notifyObserver("update", $note);
1422 
1423  $ilCtrl->setParameter($this, "note_mess", "mod");
1424  }
1425  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1426  // }
1427  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1428  $this->note_mess = "frmfld";
1429  $this->form->setValuesByPost();
1430  $_GET["note_id"] = $note->getId();
1431  $_GET["note_type"] = $note->getType();
1432  return $this->editNoteForm(false);
1433  }
1434 
1438  public function editNoteForm($a_init_form = true)
1439  {
1440  $this->edit_note_form = true;
1441 
1442  return $this->getNotesHTML($a_init_form);
1443  }
1444 
1448  public function deleteNote()
1449  {
1450  $this->delete_note = true;
1451  $this->note_mess = "qdel";
1452  return $this->getNotesHTML();
1453  }
1454 
1458  public function deleteNotes()
1459  {
1460  $lng = $this->lng;
1461 
1462  if (!$_POST["note"]) {
1463  $this->note_mess = "noc";
1464  } else {
1465  $this->delete_note = true;
1466  $this->note_mess = "qdel";
1467  }
1468 
1469  return $this->getNotesHTML();
1470  }
1471 
1475  public function cancelDelete()
1476  {
1477  return $this->getNotesHTML();
1478  }
1479 
1483  public function confirmDelete()
1484  {
1485  $ilCtrl = $this->ctrl;
1486  $lng = $this->lng;
1487  $ilUser = $this->user;
1488 
1489  $cnt = 0;
1490  foreach ($_POST["note"] as $id) {
1491  $note = new ilNote($id);
1492  if ($this->checkDeletion($note)) {
1493  $note->delete();
1494  $cnt++;
1495  }
1496  }
1497  if ($cnt > 1) {
1498  $ilCtrl->setParameter($this, "note_mess", "ntsdel");
1499  } else {
1500  $ilCtrl->setParameter($this, "note_mess", "ntdel");
1501  }
1502  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1503  }
1504 
1508  public function exportNotesHTML()
1509  {
1510  $tpl = new ilTemplate("tpl.main.html", true, true);
1511 
1512  $this->export_html = true;
1513  $this->multi_selection = false;
1514  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1515  ilUtil::deliverData($tpl->get(), "notes.html");
1516  }
1517 
1521  public function printNotes()
1522  {
1523  $tpl = new ilTemplate("tpl.main.html", true, true);
1524 
1525  $this->print = true;
1526  $this->multi_selection = false;
1527  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1528  echo $tpl->get();
1529  exit;
1530  }
1531 
1535  public function showNotes()
1536  {
1537  $ilUser = $this->user;
1538 
1539  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1540  ? "private"
1541  : "public";
1542  $ilUser->writePref("notes_" . $suffix, "y");
1543 
1544  return $this->getNotesHTML();
1545  }
1546 
1550  public function hideNotes()
1551  {
1552  $ilUser = $this->user;
1553 
1554  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1555  ? "private"
1556  : "public";
1557  $ilUser->writePref("notes_" . $suffix, "n");
1558 
1559  return $this->getNotesHTML();
1560  }
1561 
1565  public function showAllPublicNotes()
1566  {
1567  $ilUser = $this->user;
1568 
1569  $ilUser->writePref("notes_pub_all", "y");
1570 
1571  return $this->getNotesHTML();
1572  }
1573 
1577  public function showMyPublicNotes()
1578  {
1579  $ilUser = $this->user;
1580 
1581  $ilUser->writePref("notes_pub_all", "n");
1582 
1583  return $this->getNotesHTML();
1584  }
1585 
1589  public static function initJavascript($a_ajax_url, $a_type = IL_NOTE_PRIVATE, ilTemplate $a_main_tpl = null)
1590  {
1591  global $DIC;
1592 
1593  if ($a_main_tpl != null) {
1594  $tpl = $a_main_tpl;
1595  } else {
1596  $tpl = $DIC["tpl"];
1597  }
1598  $lng = $DIC->language();
1599 
1600  $lng->loadLanguageModule("notes");
1601 
1602  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1604 
1605  $lng->toJs(array("private_notes", "notes_public_comments"), $tpl);
1606 
1607  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1608  ilYuiUtil::initPanel(false, $tpl);
1609  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1611  $tpl->addJavascript("./Services/Notes/js/ilNotes.js");
1612 
1613  $tpl->addOnLoadCode("ilNotes.setAjaxUrl('" . $a_ajax_url . "');");
1614  }
1615 
1623  public static function getListNotesJSCall($a_hash, $a_update_code = null)
1624  {
1625  if ($a_update_code === null) {
1626  $a_update_code = "null";
1627  } else {
1628  $a_update_code = "'" . $a_update_code . "'";
1629  }
1630 
1631  return "ilNotes.listNotes(event, '" . $a_hash . "', " . $a_update_code . ");";
1632  }
1633 
1641  public static function getListCommentsJSCall($a_hash, $a_update_code = null)
1642  {
1643  if ($a_update_code === null) {
1644  $a_update_code = "null";
1645  } else {
1646  $a_update_code = "'" . $a_update_code . "'";
1647  }
1648 
1649  return "ilNotes.listComments(event, '" . $a_hash . "', " . $a_update_code . ");";
1650  }
1651 
1661  protected static function buildAjaxHash($a_node_type, $a_node_id, $a_sub_id, $a_sub_type)
1662  {
1663  return $a_node_type . ";" . $a_node_id . ";" . $a_sub_id . ";" . $a_sub_type;
1664  }
1665 
1669  public function renderLink($a_tpl, $a_var, $a_txt, $a_cmd, $a_anchor = "")
1670  {
1671  $ilCtrl = $this->ctrl;
1672 
1673  $low_var = strtolower($a_var);
1674  $up_var = strtoupper($a_var);
1675 
1676  if ($this->ajax) {
1677  $a_tpl->setVariable("LINK_" . $up_var, "#");
1678  $oc = "onclick = \"ilNotes.cmdAjaxLink(event, '" .
1679  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, "", true) .
1680  "');\"";
1681  $a_tpl->setVariable("ON_CLICK_" . $up_var, $oc);
1682  } else {
1683  $a_tpl->setVariable(
1684  "LINK_" . $up_var,
1685  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, $a_anchor)
1686  );
1687  }
1688 
1689  $a_tpl->setCurrentBlock($low_var);
1690  $a_tpl->setVariable("TXT_" . $up_var, $a_txt);
1691  $a_tpl->parseCurrentBlock();
1692  }
1693 
1699  public function addObserver($a_callback)
1700  {
1701  $this->observer[] = $a_callback;
1702  }
1703 
1710  protected function notifyObserver($a_action, $a_note)
1711  {
1712  if (is_array($this->observer) && count($this->observer) > 0) {
1713  foreach ($this->observer as $item) {
1714  $param = $a_note->getObject();
1715  $param["action"] = $a_action;
1716  $param["note_id"] = $a_note->getId();
1717 
1718  call_user_func_array($item, $param);
1719  }
1720  }
1721  }
1722 
1723  protected function listSortAsc()
1724  {
1725  $_SESSION["comments_sort_asc"] = 1;
1726  return $this->getNotesHtml();
1727  }
1728 
1729  protected function listSortDesc()
1730  {
1731  $_SESSION["comments_sort_asc"] = 0;
1732  return $this->getNotesHtml();
1733  }
1734 }
static _lookupLogin($a_user_id)
lookup login
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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
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
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.
$type
global $DIC
Definition: saml.php:7
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
$tpl
Definition: ilias.php:10
$location
Definition: buildRTE.php:44
static initJavascript($a_ajax_url, $a_type=IL_NOTE_PRIVATE, ilTemplate $a_main_tpl=null)
Init javascript.
updateNote()
update note
getPDNoteHTML($note_id)
Note display for personal desktop.
getOnlyNotesHTML()
Get only notes html.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
executeCommand()
execute command
if(!array_key_exists('StateId', $_REQUEST)) $id
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
static initJS(ilTemplate $a_main_tpl=null)
Init javascript.
editNoteForm($a_init_form=true)
get notes list including add note area
activateComments()
Activate Comments.
enableTargets($a_enable=true)
enable target objects
user()
Definition: user.php:4
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
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:92
exportNotesHTML()
export selected notes to html
This class represents a hidden form property in a property form.
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
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
$text
Definition: errorreport.php:18
addObserver($a_callback)
Add observer.
cancelUpdateNote()
cancel edit note
$ilUser
Definition: imgupload.php:18
static _lookupOwner($a_id)
lookup object owner
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
$txt
Definition: error.php:11
$additional
Definition: goto.php:50
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.
showMyPublicNotes()
show only public notes of user
printNotes()
notes print view screen
settings()
Definition: settings.php:2
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
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
global $ilSetting
Definition: privfeed.php:17
This class represents a text area property in a property form.
__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
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
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
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 _lookupOwnerName($a_owner_id)
lookup owner name for owner id
cancelAddNote()
cancel add note
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
$_POST["username"]
static _lookupTargetId($a_obj_id)
lookup target id