ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ilNoteGUI($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(
80  IL_NOTE_UNLABELED => array(
81  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
82  "alt" => $lng->txt("note")),
83  IL_NOTE_IMPORTANT => array(
84  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
85  "alt" => $lng->txt("note").", ".$lng->txt("important")),
86  IL_NOTE_QUESTION => array(
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")),
92  IL_NOTE_CONTRA => array(
93  "img" => ilUtil::getImagePath("note_unlabeled.svg"),
94  "alt" => $lng->txt("note").", ".$lng->txt("contra"))
95  );
96 
97  $this->comment_img = array(
98  IL_NOTE_UNLABELED => array(
99  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
100  "alt" => $lng->txt("notes_comment")),
101  IL_NOTE_IMPORTANT => array(
102  "img" => ilUtil::getImagePath("comment_unlabeled.svg"),
103  "alt" => $lng->txt("notes_comment").", ".$lng->txt("important")),
104  IL_NOTE_QUESTION => array(
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")),
110  IL_NOTE_CONTRA => array(
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 "catr":
455  case "crsr":
456  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
457  $title = ilContainerReference::_lookupTitle($this->rep_obj_id);
458  break;
459 
460  default:
461  $title = ilObject::_lookupTitle($this->rep_obj_id);
462  break;
463  }
464 
465  $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny"));
466 
467  // add sub-object if given
468  if($this->obj_id)
469  {
470  $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id);
471  if($sub_title)
472  {
473  $title .= " - ".$sub_title;
474  }
475  }
476 
477  $tpl->setCurrentBlock("title");
478  $tpl->setVariable("TITLE", $img." ".$title);
479  $tpl->parseCurrentBlock();
480  }
481 
482  if ($this->delete_note)
483  {
484  $cnt_str = "";
485  }
486  if ($a_type == IL_NOTE_PRIVATE)
487  {
488  $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes").$cnt_str);
489  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
490  }
491  else
492  {
493  $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments").$cnt_str);
494  $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC);
495  }
496  $anch = $this->anchor_jump
497  ? "notes_top"
498  : "";
499  $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch));
500  if ($this->ajax)
501  {
502  $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '".
503  $ilCtrl->getFormActionByClass("ilnotegui", "", "", true).
504  "'); return false;\"";
505  $tpl->setVariable("ON_SUBMIT_FORM", $os);
506  $tpl->setVariable("FORM_ID", "Ajax");
507  }
508 
509  if ($this->export_html || $this->print)
510  {
511  $tpl->touchBlock("print_style");
512  }
513 
514  // show add new note button
515  if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
516  !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID)
517  {
518  if (!$this->inc_sub) // we cannot offer add button if aggregated notes
519  { // are displayed
520  if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC)
521  {
522  $tpl->setCurrentBlock("add_note_btn");
523  if ($a_type == IL_NOTE_PUBLIC)
524  {
525  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment"));
526  }
527  else
528  {
529  $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note"));
530  }
531  $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm").
532  "#note_edit");
533  $tpl->parseCurrentBlock();
534  }
535  }
536  }
537 
538  // show show/hide button for note list
539  if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note
540  && !$this->export_html && !$this->print && !$this->edit_note_form
541  && !$this->add_note_form)
542  {
543  if ($user_setting_notes_by_type == "n")
544  {
545  if ($a_type == IL_NOTE_PUBLIC)
546  {
547  $txt = $lng->txt("notes_show_comments");
548  }
549  else
550  {
551  $txt = $lng->txt("show_".$suffix."_notes");
552  }
553  $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top");
554  }
555  else
556  {
557  // never individually hide for anonymous users
558  if (($ilUser->getId() != ANONYMOUS_USER_ID))
559  {
560  if ($a_type == IL_NOTE_PUBLIC)
561  {
562  $txt = $lng->txt("notes_hide_comments");
563  }
564  else
565  {
566  $txt = $lng->txt("hide_".$suffix."_notes");
567  }
568  $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top");
569 
570  // show all public notes / my notes only switch
571  if ($a_type == IL_NOTE_PUBLIC)
572  {
573  if ($user_setting_notes_public_all == "n")
574  {
575  $this->renderLink($tpl, "all_pub_notes", $lng->txt("notes_all_comments"),
576  "showAllPublicNotes", "notes_top");
577  }
578  else
579  {
580  $this->renderLink($tpl, "my_pub_notes", $lng->txt("notes_my_comments"),
581  "showMyPublicNotes", "notes_top");
582  }
583  }
584  }
585  }
586  }
587 
588  // show add new note text area
589  if (!$this->edit_note_form && $user_setting_notes_by_type != "n" &&
590  !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID)
591  {
592  if ($a_init_form)
593  {
594  $this->initNoteForm("create", $a_type);
595  }
596 
597  $tpl->setCurrentBlock("edit_note_form");
598 // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
599  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
600  $tpl->parseCurrentBlock();
601 
602  $tpl->parseCurrentBlock();
603  $tpl->setCurrentBlock("note_row");
604  $tpl->parseCurrentBlock();
605  }
606 
607  // list all notes
608  if ($user_setting_notes_by_type != "n" || !$this->enable_hiding)
609  {
612 
613  if(sizeof($notes))
614  {
615  if((int)$_SESSION["comments_sort_asc"] == 1)
616  {
617  $sort_txt = $lng->txt("notes_sort_desc");
618  $sort_cmd = "listSortDesc";
619  }
620  else
621  {
622  $sort_txt = $lng->txt("notes_sort_asc");
623  $sort_cmd = "listSortAsc";
624  }
625  $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch);
626  }
627 
628  $notes_given = false;
629  foreach($notes as $note)
630  {
631  if ($this->edit_note_form && ($note->getId() == $_GET["note_id"])
632  && $a_type == $_GET["note_type"])
633  {
634  if ($a_init_form)
635  {
636  $this->initNoteForm("edit", $a_type, $note);
637  }
638  $tpl->setCurrentBlock("edit_note_form");
639 // $tpl->setVariable("EDIT_FORM", $this->form->getHTML());
640  $tpl->setVariable("EDIT_FORM", $this->form_tpl->get());
641  $tpl->parseCurrentBlock();
642  }
643  else
644  {
645  $cnt_col = 2;
646 
647  // delete note stuff for all private notes
648  if ($this->checkDeletion($note)
649  && !$this->delete_note
650  && !$this->export_html && !$this->print
651  && !$this->edit_note_form && !$this->add_note_form)
652  {
653  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
654  $this->renderLink($tpl, "delete_note", $lng->txt("delete"),
655  "deleteNote", "note_".$note->getId());
656  }
657 
658  // checkboxes in multiselection mode
659  if ($this->multi_selection && !$this->delete_note)
660  {
661  $tpl->setCurrentBlock("checkbox_col");
662  $tpl->setVariable("CHK_NOTE", "note[]");
663  $tpl->setVariable("CHK_NOTE_ID", $note->getId());
664  $tpl->parseCurrentBlock();
665  $cnt_col = 1;
666  }
667 
668  // edit note stuff for all private notes
669  if ($this->checkEdit($note))
670  {
671 
672  if (!$this->delete_note && !$this->export_html && !$this->print
673  && !$this->edit_note_form && !$this->add_note_form)
674  {
675  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId());
676  $this->renderLink($tpl, "edit_note", $lng->txt("edit"),
677  "editNoteForm", "note_edit");
678  }
679  }
680 
681  $tpl->setVariable("CNT_COL", $cnt_col);
682 
683  // output author account
684  if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor()))
685  {
686  //$tpl->setCurrentBlock("author");
687  //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor()));
688  //$tpl->parseCurrentBlock();
689  $tpl->setCurrentBlock("user_img");
690  $tpl->setVariable("USR_IMG",
691  ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall"));
692  $tpl->setVariable("USR_ALT", $lng->txt("user_image").": ".
693  ilObjUser::_lookupLogin($note->getAuthor()));
694  $tpl->parseCurrentBlock();
695  $tpl->setVariable("TXT_USR",
696  ilUserUtil::getNamePresentation($note->getAuthor(), false, false)." - ");
697  }
698 
699  // last edited
700  if ($note->getUpdateDate() != null)
701  {
702  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
703  $tpl->setVariable("DATE_LAST_EDIT",
704  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME)));
705  }
706  else
707  {
708  $tpl->setVariable("VAL_DATE",
709  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME)));
710  }
711 
712  // hidden note ids for deletion
713  if ($this->delete_note)
714  {
715  $tpl->setCurrentBlock("delete_ids");
716  $tpl->setVariable("HID_NOTE", "note[]");
717  $tpl->setVariable("HID_NOTE_ID", $note->getId());
718  $tpl->parseCurrentBlock();
719  }
720  $target = $note->getObject();
721 
722  // target objects
723  $this->showTargets($tpl, $this->rep_obj_id, $note->getId(),
724  $target["obj_type"], $target["obj_id"]);
725 
726  $rowclass = ($rowclass != "tblrow1")
727  ? "tblrow1"
728  : "tblrow2";
729  if (!$this->export_html && !$this->print)
730  {
731  $tpl->setCurrentBlock("note_img");
732  if ($a_type == IL_NOTE_PUBLIC)
733  {
734  $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]);
735  $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]);
736  }
737  else
738  {
739  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
740  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
741  }
742  $tpl->parseCurrentBlock();
743  }
744  else
745  {
746  switch ($note->getLabel())
747  {
748  case IL_NOTE_UNLABELED:
749  $tpl->setVariable("EXP_ICON", "[&nbsp;]");
750  break;
751 
752  case IL_NOTE_IMPORTANT:
753  $tpl->setVariable("EXP_ICON", "[!]");
754  break;
755 
756  case IL_NOTE_QUESTION:
757  $tpl->setVariable("EXP_ICON", "[?]");
758  break;
759 
760  case IL_NOTE_PRO:
761  $tpl->setVariable("EXP_ICON", "[+]");
762  break;
763 
764  case IL_NOTE_CONTRA:
765  $tpl->setVariable("EXP_ICON", "[-]");
766  break;
767  }
768  }
769  $tpl->setCurrentBlock("note");
770  $tpl->setVariable("ROWCLASS", $rowclass);
771  $text = (trim($note->getText()) != "")
772  ? nl2br($note->getText())
773  : "<p class='subtitle'>".$lng->txt("note_content_removed")."</p>";
774  $tpl->setVariable("NOTE_TEXT", $text);
775  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
776  $tpl->setVariable("NOTE_ID", $note->getId());
777  $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC
778  ? "ilComment"
779  : "ilNote");
780  $tpl->parseCurrentBlock();
781  }
782  $tpl->setCurrentBlock("note_row");
783  $tpl->parseCurrentBlock();
784  $notes_given = true;
785  }
786 
787  if (!$notes_given)
788  {
789  $tpl->setCurrentBlock("no_notes");
790  if ($a_type == IL_NOTE_PUBLIC)
791  {
792  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments"));
793  }
794 /* else
795  {
796  $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes"));
797  }*/
798  $tpl->parseCurrentBlock();
799  }
800 
802 
803  // multiple items commands
804  if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form
805  && count($notes) > 0)
806  {
807  if ($a_type == IL_NOTE_PRIVATE)
808  {
809  $tpl->setCurrentBlock("delete_cmd");
810  $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete"));
811  $tpl->parseCurrentBlock();
812  }
813 
814  $tpl->setCurrentBlock("multiple_commands");
815  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
816  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
817  $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
818  $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print"));
819  $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html"));
820  $tpl->parseCurrentBlock();
821  }
822 
823  // delete / cancel row
824  if ($this->delete_note)
825  {
826  $tpl->setCurrentBlock("delete_cancel");
827  $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete"));
828  $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel"));
829  $tpl->parseCurrentBlock();
830  }
831 
832  // print
833  if ($this->print)
834  {
835  $tpl->touchBlock("print_js");
836  $tpl->setCurrentBlock("print_back");
837  $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes"));
838  $tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
839  $tpl->parseCurrentBlock();
840  }
841  }
842 
843  // message
844  switch($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess)
845  {
846  case "mod":
847  $mtype = "success";
848  $mtxt = $lng->txt("msg_obj_modified");
849  break;
850 
851  case "ntsdel":
852  $mtype = "success";
853  $mtxt = ($a_type == IL_NOTE_PRIVATE)
854  ? $lng->txt("notes_notes_deleted")
855  : $lng->txt("notes_comments_deleted");
856  break;
857 
858  case "ntdel":
859  $mtype = "success";
860  $mtxt = ($a_type == IL_NOTE_PRIVATE)
861  ? $lng->txt("notes_note_deleted")
862  : $lng->txt("notes_comment_deleted");
863  break;
864 
865  case "frmfld":
866  $mtype = "failure";
867  $mtxt = $lng->txt("form_input_not_valid");
868  break;
869 
870  case "qdel":
871  $mtype = "question";
872  $mtxt = $lng->txt("info_delete_sure");
873  break;
874 
875  case "noc":
876  $mtype = "failure";
877  $mtxt = $lng->txt("no_checkbox");
878  break;
879  }
880  if ($mtxt != "")
881  {
882  $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype));
883  }
884  else
885  {
886  $tpl->setVariable("MESS", "");
887  }
888 
889 
890 
891  if ($this->delete_note && count($notes) == 0)
892  {
893  return "";
894  }
895  else
896  {
897  return $tpl->get();
898  }
899  }
900 
908  protected function getSubObjectTitle($parent_obj_id, $sub_obj_id)
909  {
910  global $objDefinition, $ilCtrl;
911 
912  $parent_type = ilObject::_lookupType($parent_obj_id);
913  $parent_class = "ilObj".$objDefinition->getClassName($parent_type)."GUI";
914  $parent_path = $ilCtrl->lookupClassPath($parent_class);
915  include_once $parent_path;
916  if(method_exists($parent_class, "lookupSubObjectTitle"))
917  {
918  return call_user_func_array(array($parent_class, "lookupSubObjectTitle"), array($parent_obj_id, $sub_obj_id));
919  }
920  }
921 
925  function checkDeletion($a_note)
926  {
927  global $ilUser, $ilSetting;
928 
929  if ($ilUser->getId() == ANONYMOUS_USER_ID)
930  {
931  return false;
932  }
933 
934  $is_author = ($a_note->getAuthor() == $ilUser->getId());
935 
936  if ($a_note->getType() == IL_NOTE_PRIVATE && $is_author)
937  {
938  return true;
939  }
940 
941  if ($a_note->getType() == IL_NOTE_PUBLIC && $this->public_deletion_enabled)
942  {
943  return true;
944  }
945 
946  if ($a_note->getType() == IL_NOTE_PUBLIC && $is_author && $ilSetting->get("comments_del_user", 0))
947  {
948  return true;
949  }
950 
951  return false;
952  }
953 
957  function checkEdit($a_note)
958  {
959  global $ilUser;
960 
961  if ($a_note->getAuthor() == $ilUser->getId()
962  && ($ilUser->getId() != ANONYMOUS_USER_ID))
963  {
964  return true;
965  }
966  return false;
967  }
968 
969 
975  public function initNoteForm($a_mode = "edit", $a_type, $a_note = null)
976  {
977  global $lng, $ilCtrl;
978 
979  $this->form_tpl = new ilTemplate("tpl.notes_edit.html", true, true, "Services/Notes");
980  if ($a_note)
981  {
982  $this->form_tpl->setVariable("VAL_NOTE", ilUtil::prepareFormOutput($a_note->getText()));
983  $this->form_tpl->setVariable("NOTE_ID", $a_note->getId());
984  }
985 
986  if ($a_mode == "create")
987  {
988  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
989  ? $lng->txt("note_add_comment")
990  : $lng->txt("note_add_note"));
991  $this->form_tpl->setVariable("CMD", "addNote");
992  }
993  else
994  {
995  $this->form_tpl->setVariable("TXT_CMD", ($a_type == IL_NOTE_PUBLIC)
996  ? $lng->txt("note_update_comment")
997  : $lng->txt("note_update_note"));
998  $this->form_tpl->setVariable("CMD", "updateNote");
999  }
1000 
1001 return;
1002  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1003  $this->form = new ilPropertyFormGUI();
1004  $this->form->setOpenTag(false);
1005  $this->form->setCloseTag(false);
1006  $this->form->setDisableStandardMessage(true);
1007 
1008  // subject
1009 /* $ti = new ilTextInputGUI($this->lng->txt("subject"), "sub_note");
1010  $ti->setRequired(true);
1011  $ti->setMaxLength(200);
1012  $ti->setSize(40);
1013  if ($a_note)
1014  {
1015  $ti->setValue($a_note->getSubject());
1016  }
1017  $this->form->addItem($ti);*/
1018 
1019  // text
1020 // $ta = new ilTextAreaInputGUI(($a_type == IL_NOTE_PUBLIC)
1021 // ? $lng->txt("notes_comment")
1022 // : $lng->txt("note"), "note");
1023  $ta = new ilTextAreaInputGUI("", "note");
1024  $ta->setCols(40);
1025  $ta->setRows(4);
1026  if ($a_note)
1027  {
1028  $ta->setValue($a_note->getText());
1029  }
1030  $this->form->addItem($ta);
1031 
1032  // label
1033 /* $options = array(
1034  IL_NOTE_UNLABELED => $lng->txt("unlabeled"),
1035  IL_NOTE_QUESTION => $lng->txt("question"),
1036  IL_NOTE_IMPORTANT => $lng->txt("important"),
1037  IL_NOTE_PRO => $lng->txt("pro"),
1038  IL_NOTE_CONTRA => $lng->txt("contra"),
1039  );
1040  $si = new ilSelectInputGUI($this->lng->txt("notes_label"), "note_label");
1041  $si->setOptions($options);
1042  if ($a_note)
1043  {
1044  $si->setValue($a_note->getLabel());
1045  }
1046  $this->form->addItem($si); */
1047 
1048  // hidden note id
1049  if ($a_note)
1050  {
1051  $hi = new ilHiddenInputGUI("note_id");
1052  $hi->setValue($_GET["note_id"]);
1053  $this->form->addItem($hi);
1054  }
1055 
1056  // save and cancel commands
1057  if ($a_mode == "create")
1058  {
1059  $this->form->addCommandButton("addNote", $lng->txt("save"));
1060 /* $this->form->addCommandButton("cancelAddNote", $lng->txt("cancel"));
1061  $this->form->setTitle($a_type == IL_NOTE_PUBLIC
1062  ? $lng->txt("notes_add_comment")
1063  : $lng->txt("notes_add_note"));*/
1064  }
1065  else
1066  {
1067  $this->form->addCommandButton("updateNote", $lng->txt("save"));
1068 /* $this->form->addCommandButton("cancelUpdateNote", $lng->txt("cancel"));
1069  $this->form->setTitle($a_type == IL_NOTE_PUBLIC
1070  ? $lng->txt("notes_edit_comment")
1071  : $lng->txt("notes_edit_note"));*/
1072  }
1073 
1074  $ilCtrl->setParameter($this, "note_type", $a_type);
1075  $this->form->setFormAction($this->ctrl->getFormAction($this));
1076 
1077  }
1078 
1082  function getPDNoteHTML($note_id)
1083  {
1084  global $lng, $ilCtrl, $ilUser;
1085 
1086  $tpl = new ilTemplate("tpl.pd_note.html", true, true, "Services/Notes");
1087  $note = new ilNote($note_id);
1088  $target = $note->getObject();
1089 
1090  if ($note->getAuthor() != $ilUser->getId())
1091  {
1092  return;
1093  }
1094 
1095  $tpl->setCurrentBlock("edit_note");
1096  $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $target["rep_obj_id"]);
1097  $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note_id);
1098  $ilCtrl->setParameterByClass("ilnotegui", "note_type", $note->getType());
1099  $tpl->setVariable("LINK_EDIT_NOTE",
1100  $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"),
1101  "editNoteForm"));
1102  $tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
1103  $tpl->parseCurrentBlock();
1104  $ilCtrl->clearParametersByClass("ilnotegui");
1105 
1106  $tpl->setCurrentBlock("note_img");
1107  $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]);
1108  $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]);
1109  $tpl->parseCurrentBlock();
1110 
1111  // last edited
1112  if ($note->getUpdateDate() != null)
1113  {
1114  $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on"));
1115  $tpl->setVariable("DATE_LAST_EDIT",
1116  ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME)));
1117  }
1118  else
1119  {
1120  //$tpl->setVariable("TXT_CREATED", $lng->txt("create_date"));
1121  $tpl->setVariable("VAL_DATE",
1122  ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME)));
1123  }
1124 
1125  $tpl->setVariable("VAL_SUBJECT", $note->getSubject());
1126  $text = (trim($note->getText()) != "")
1127  ? nl2br($note->getText())
1128  : "<p class='subtitle'>".$lng->txt("note_content_removed")."</p>";
1129  $tpl->setVariable("NOTE_TEXT", $text);
1130  $this->showTargets($tpl, $target["rep_obj_id"], $note_id, $target["obj_type"], $target["obj_id"]);
1131  return $tpl->get();
1132  }
1133 
1137  function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id)
1138  {
1139  global $tree, $ilAccess, $objDefinition, $ilUser;
1140 
1141  if ($this->targets_enabled)
1142  {
1143  if ($a_rep_obj_id > 0)
1144  {
1145  // get all visible references of target object
1146 
1147  // repository
1148  $ref_ids = ilObject::_getAllReferences($a_rep_obj_id);
1149  if($ref_ids)
1150  {
1151  $vis_ref_ids = array();
1152  foreach($ref_ids as $ref_id)
1153  {
1154  if ($ilAccess->checkAccess("visible", "", $ref_id))
1155  {
1156  $vis_ref_ids[] = $ref_id;
1157  }
1158  }
1159 
1160  // output links to targets
1161  if (count($vis_ref_ids) > 0)
1162  {
1163  foreach($vis_ref_ids as $vis_ref_id)
1164  {
1165  $type = ilObject::_lookupType($vis_ref_id, true);
1166  $sub_link = $sub_title = "";
1167  if ($type == "sahs") // bad hack, needs general procedure
1168  {
1169  $link = "goto.php?target=sahs_".$vis_ref_id;
1170  $title = ilObject::_lookupTitle($a_rep_obj_id);
1171  if ($a_obj_type == "sco" || $a_obj_type == "seqc" || $a_obj_type == "chap" || $a_obj_type == "pg")
1172  {
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  }
1179  else if ($type == "poll")
1180  {
1181  include_once "Services/Link/classes/class.ilLink.php";
1182  $title = ilObject::_lookupTitle($a_rep_obj_id);
1183  $link = ilLink::_getLink($vis_ref_id, "poll");
1184  }
1185  else if ($a_obj_type != "pg")
1186  {
1187  if (!is_object($this->item_list_gui[$type]))
1188  {
1189  $class = $objDefinition->getClassName($type);
1190  $location = $objDefinition->getLocation($type);
1191  $full_class = "ilObj".$class."ListGUI";
1192  include_once($location."/class.".$full_class.".php");
1193  $this->item_list_gui[$type] = new $full_class();
1194  }
1195 
1196  // for references, get original title
1197  // (link will lead to orignal, which basically is wrong though)
1198  if($a_obj_type == "crsr" || $a_obj_type == "catr")
1199  {
1200  include_once "Services/ContainerReference/classes/class.ilContainerReference.php";
1201  $tgt_obj_id = ilContainerReference::_lookupTargetId($a_rep_obj_id);
1202  $title = ilObject::_lookupTitle($tgt_obj_id);
1203  }
1204  else
1205  {
1206  $title = ilObject::_lookupTitle($a_rep_obj_id);
1207  }
1208  $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title);
1209  $link = $this->item_list_gui[$type]->getCommandLink("infoScreen");
1210 
1211  // workaround, because # anchor can't be passed through frameset
1212  $link = ilUtil::appendUrlParameterString($link, "anchor=note_".$a_note_id);
1213 
1214  $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link)."#note_".$a_note_id;
1215  }
1216  else
1217  {
1218  $title = ilObject::_lookupTitle($a_rep_obj_id);
1219  $link = "goto.php?target=pg_".$a_obj_id."_".$vis_ref_id;
1220  }
1221 
1222  $par_id = $tree->getParentId($vis_ref_id);
1223 
1224  // sub object link
1225  if ($sub_link != "")
1226  {
1227  if ($this->export_html || $this->print)
1228  {
1229  $tpl->setCurrentBlock("exp_target_sub_object");
1230  }
1231  else
1232  {
1233  $tpl->setCurrentBlock("target_sub_object");
1234  $tpl->setVariable("LINK_SUB_TARGET", $sub_link);
1235  }
1236  $tpl->setVariable("TXT_SUB_TARGET", $sub_title);
1237  $tpl->setVariable("IMG_SUB_TARGET", $sub_icon);
1238  $tpl->parseCurrentBlock();
1239  }
1240 
1241  // container and object link
1242  if ($this->export_html || $this->print)
1243  {
1244  $tpl->setCurrentBlock("exp_target_object");
1245  }
1246  else
1247  {
1248  $tpl->setCurrentBlock("target_object");
1249  $tpl->setVariable("LINK_TARGET", $link);
1250  }
1251  $tpl->setVariable("TXT_CONTAINER",
1253  ilObject::_lookupObjId($par_id)));
1254  $tpl->setVariable("IMG_CONTAINER",
1256  ilObject::_lookupObjId($par_id), "tiny"));
1257  $tpl->setVariable("TXT_TARGET", $title);
1258  $tpl->setVariable("IMG_TARGET",
1259  ilObject::_getIcon($a_rep_obj_id, "tiny"));
1260 
1261  $tpl->parseCurrentBlock();
1262  }
1263  $tpl->touchBlock("target_objects");
1264  }
1265  }
1266  // personal workspace
1267  else
1268  {
1269  // we only need 1 instance
1270  if(!$this->wsp_tree)
1271  {
1272  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
1273  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
1274  $this->wsp_tree = new ilWorkspaceTree($ilUser->getId());
1275  $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree);
1276  }
1277  $node_id = $this->wsp_tree->lookupNodeId($a_rep_obj_id);
1278  if($this->wsp_access_handler->checkAccess("visible", "", $node_id))
1279  {
1280  $path = $this->wsp_tree->getPathFull($node_id);
1281  if($path)
1282  {
1283  $item = array_pop($path);
1284  $parent = array_pop($path);
1285 
1286  if(!$parent["title"])
1287  {
1288  $parent["title"] = $this->lng->txt("wsp_personal_workspace");
1289  }
1290 
1291  // sub-objects
1292  $additional = null;
1293  if($a_obj_id)
1294  {
1295  $sub_title = $this->getSubObjectTitle($a_rep_obj_id, $a_obj_id);
1296  if($sub_title)
1297  {
1298  $item["title"] .= " (".$sub_title.")";
1299  $additional = "_".$a_obj_id;
1300  }
1301  }
1302 
1303  $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $a_rep_obj_id, $additional);
1304  }
1305  // shared resource
1306  else
1307  {
1308  $owner = ilObject::_lookupOwner($a_rep_obj_id);
1309  $parent["title"] = $this->lng->txt("wsp_tab_shared").
1310  " (".ilObject::_lookupOwnerName($owner).")";
1311  $item["title"] = ilObject::_lookupTitle($a_rep_obj_id);
1312  $link = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=".
1313  $owner;
1314  }
1315 
1316  // container and object link
1317  if ($this->export_html || $this->print)
1318  {
1319  $tpl->setCurrentBlock("exp_target_object");
1320  }
1321  else
1322  {
1323  $tpl->setCurrentBlock("target_object");
1324  $tpl->setVariable("LINK_TARGET", $link);
1325  }
1326 
1327 
1328  // :TODO: no images in template ?
1329 
1330  $tpl->setVariable("TXT_CONTAINER", $parent["title"]);
1331  $tpl->setVariable("IMG_CONTAINER",
1332  ilObject::_getIcon($parent["obj_id"], "tiny"));
1333 
1334  $tpl->setVariable("TXT_TARGET", $item["title"]);
1335  $tpl->setVariable("IMG_TARGET",
1336  ilObject::_getIcon($a_rep_obj_id, "tiny"));
1337 
1338  $tpl->parseCurrentBlock();
1339  }
1340  }
1341  }
1342  }
1343  }
1344 
1348  function addNoteForm($a_init_form = true)
1349  {
1350  global $ilUser;
1351 
1352  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1353  ? "private"
1354  : "public";
1355  $ilUser->setPref("notes_".$suffix, "y");
1356 
1357  $this->add_note_form = true;
1358  return $this->getNotesHTML($a_init_form);
1359  }
1360 
1364  function cancelAddNote()
1365  {
1366  return $this->getNotesHTML();
1367  }
1368 
1372  function cancelUpdateNote()
1373  {
1374  return $this->getNotesHTML();
1375  }
1376 
1380  function addNote()
1381  {
1382  global $ilUser, $lng, $ilCtrl;
1383 
1384  $this->initNoteForm("create", $_GET["note_type"]);
1385 
1386  //if ($this->form->checkInput())
1387  if ($_POST["note"] != "")
1388  {
1389  $note = new ilNote();
1390  $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
1391  $note->setInRepository($this->repository_mode);
1392  $note->setType($_GET["note_type"]);
1393  $note->setAuthor($ilUser->getId());
1394  $note->setText(ilUtil::stripslashes($_POST["note"]));
1395 // $note->setSubject($_POST["sub_note"]);
1396 // $note->setLabel($_POST["note_label"]);
1397  $note->create();
1398 
1399  $this->notifyObserver("new", $note);
1400 
1401  $ilCtrl->setParameter($this, "note_mess", "mod");
1402 // $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1403  }
1404  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1405 // $this->note_mess = "frmfld";
1406 // $this->form->setValuesByPost();
1407 // return $this->addNoteForm(false);;
1408  }
1409 
1413  function updateNote()
1414  {
1415  global $ilUser, $lng, $ilCtrl;
1416 
1417  $note = new ilNote(ilUtil::stripSlashes($_POST["note_id"]));
1418  $this->initNoteForm("edit", $note->getType(),
1419  $note);
1420 
1421 // if ($this->form->checkInput())
1422 // if ($_POST["note"] != "")
1423 // {
1424  $note->setText(ilUtil::stripSlashes($_POST["note"]));
1425  $note->setSubject(ilUtil::stripSlashes($_POST["sub_note"]));
1426  $note->setLabel(ilUtil::stripSlashes($_POST["note_label"]));
1427  if ($this->checkEdit($note))
1428  {
1429  $note->update();
1430 
1431  $this->notifyObserver("update", $note);
1432 
1433  $ilCtrl->setParameter($this, "note_mess", "mod");
1434  }
1435  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1436 // }
1437 $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1438  $this->note_mess = "frmfld";
1439  $this->form->setValuesByPost();
1440  $_GET["note_id"] = $note->getId();
1441  $_GET["note_type"] = $note->getType();
1442  return $this->editNoteForm(false);
1443  }
1444 
1448  function editNoteForm($a_init_form = true)
1449  {
1450  $this->edit_note_form = true;
1451 
1452  return $this->getNotesHTML($a_init_form);
1453  }
1454 
1458  function deleteNote()
1459  {
1460  $this->delete_note = true;
1461  $this->note_mess = "qdel";
1462  return $this->getNotesHTML();
1463  }
1464 
1468  function deleteNotes()
1469  {
1470  global $lng;
1471 
1472  if (!$_POST["note"])
1473  {
1474  $this->note_mess = "noc";
1475  }
1476  else
1477  {
1478  $this->delete_note = true;
1479  $this->note_mess = "qdel";
1480  }
1481 
1482  return $this->getNotesHTML();
1483  }
1484 
1488  function cancelDelete()
1489  {
1490  return $this->getNotesHTML();
1491  }
1492 
1496  function confirmDelete()
1497  {
1498  global $ilCtrl, $lng, $ilUser;
1499 
1500  $cnt = 0;
1501  foreach($_POST["note"] as $id)
1502  {
1503  $note = new ilNote($id);
1504  if ($this->checkDeletion($note))
1505  {
1506  $note->delete();
1507  $cnt++;
1508  }
1509  }
1510  if ($cnt > 1)
1511  {
1512  $ilCtrl->setParameter($this, "note_mess", "ntsdel");
1513  }
1514  else
1515  {
1516  $ilCtrl->setParameter($this, "note_mess", "ntdel");
1517  }
1518  $ilCtrl->redirect($this, "showNotes", "notes_top", $this->ajax);
1519  }
1520 
1524  function exportNotesHTML()
1525  {
1526  $tpl = new ilTemplate("tpl.main.html", true, true);
1527 
1528  $this->export_html = true;
1529  $this->multi_selection = false;
1530  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1531  ilUtil::deliverData($tpl->get(), "notes.html");
1532  }
1533 
1537  function printNotes()
1538  {
1539  $tpl = new ilTemplate("tpl.main.html", true, true);
1540 
1541  $this->print = true;
1542  $this->multi_selection = false;
1543  $tpl->setVariable("CONTENT", $this->getNotesHTML());
1544  echo $tpl->get(); exit;
1545  }
1546 
1550  function showNotes()
1551  {
1552  global $ilUser;
1553 
1554  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1555  ? "private"
1556  : "public";
1557  $ilUser->writePref("notes_".$suffix, "y");
1558 
1559  return $this->getNotesHTML();
1560  }
1561 
1565  function hideNotes()
1566  {
1567  global $ilUser;
1568 
1569  $suffix = ($_GET["note_type"] == IL_NOTE_PRIVATE)
1570  ? "private"
1571  : "public";
1572  $ilUser->writePref("notes_".$suffix, "n");
1573 
1574  return $this->getNotesHTML();
1575  }
1576 
1581  {
1582  global $ilUser;
1583 
1584  $ilUser->writePref("notes_pub_all", "y");
1585 
1586  return $this->getNotesHTML();
1587  }
1588 
1593  {
1594  global $ilUser;
1595 
1596  $ilUser->writePref("notes_pub_all", "n");
1597 
1598  return $this->getNotesHTML();
1599  }
1600 
1604  function initJavascript($a_ajax_url, $a_type = IL_NOTE_PRIVATE)
1605  {
1606  global $tpl, $lng;
1607 
1608  $lng->loadLanguageModule("notes");
1609 
1610  include_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
1612 
1613  $lng->toJs(array("private_notes", "notes_public_comments"));
1614 
1615  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1617  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1619  $tpl->addJavascript("./Services/Notes/js/ilNotes.js");
1620 
1621  $tpl->addOnLoadCode("ilNotes.setAjaxUrl('".$a_ajax_url."');");
1622  }
1623 
1631  function getListNotesJSCall($a_hash, $a_update_code = null)
1632  {
1633  if ($a_update_code === null)
1634  {
1635  $a_update_code = "null";
1636  }
1637  else
1638  {
1639  $a_update_code = "'".$a_update_code."'";
1640  }
1641 
1642  return "ilNotes.listNotes(event, '".$a_hash."', ".$a_update_code.");";
1643  }
1644 
1652  function getListCommentsJSCall($a_hash, $a_update_code = null)
1653  {
1654  if ($a_update_code === null)
1655  {
1656  $a_update_code = "null";
1657  }
1658  else
1659  {
1660  $a_update_code = "'".$a_update_code."'";
1661  }
1662 
1663  return "ilNotes.listComments(event, '".$a_hash."', ".$a_update_code.");";
1664  }
1665 
1675  protected static function buildAjaxHash($a_node_type, $a_node_id, $a_sub_id, $a_sub_type)
1676  {
1677  return $a_node_type.";".$a_node_id.";".$a_sub_id.";".$a_sub_type;
1678  }
1679 
1683  function renderLink($a_tpl, $a_var, $a_txt, $a_cmd, $a_anchor = "")
1684  {
1685  global $ilCtrl;
1686 
1687  $low_var = strtolower($a_var);
1688  $up_var = strtoupper($a_var);
1689 
1690  if ($this->ajax)
1691  {
1692  $a_tpl->setVariable("LINK_".$up_var, "#");
1693  $oc = "onclick = \"ilNotes.cmdAjaxLink(event, '".
1694  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, "", true).
1695  "');\"";
1696  $a_tpl->setVariable("ON_CLICK_".$up_var, $oc);
1697  }
1698  else
1699  {
1700  $a_tpl->setVariable("LINK_".$up_var,
1701  $ilCtrl->getLinkTargetByClass("ilnotegui", $a_cmd, $a_anchor));
1702  }
1703 
1704  $a_tpl->setCurrentBlock($low_var);
1705  $a_tpl->setVariable("TXT_".$up_var, $a_txt);
1706  $a_tpl->parseCurrentBlock();
1707  }
1708 
1714  function addObserver($a_callback)
1715  {
1716  $this->observer[] = $a_callback;
1717  }
1718 
1725  protected function notifyObserver($a_action, $a_note)
1726  {
1727  if(sizeof($this->observer))
1728  {
1729  foreach($this->observer as $item)
1730  {
1731  $param = $a_note->getObject();
1732  $param["action"] = $a_action;
1733  $param["note_id"] = $a_note->getId();
1734 
1735  call_user_func_array($item, $param);
1736  }
1737  }
1738  }
1739 
1740  protected function listSortAsc()
1741  {
1742  $_SESSION["comments_sort_asc"] = 1;
1743  return $this->getNotesHtml();
1744  }
1745 
1746  protected function listSortDesc()
1747  {
1748  $_SESSION["comments_sort_asc"] = 0;
1749  return $this->getNotesHtml();
1750  }
1751 }
1752 
1753 ?>
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.
getNoteListHTML($a_type=IL_NOTE_PRIVATE, $a_init_form=true)
get notes/comments list as html code
getListCommentsJSCall($a_hash, $a_update_code=null)
Get list comments js call.
exit
Definition: login.php:54
initNoteForm($a_mode="edit", $a_type, $a_note=null)
Init note form.
setRepositoryMode($a_value)
Set repository mode.
_lookupOwner($a_id)
lookup object owner
enableMultiSelection($a_enable=true)
enable multi selection (checkboxes and commands)
$_POST['username']
Definition: cron.php:12
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.
$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
Tree handler for personal workspace.
_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
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.
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
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
initJavascript($a_ajax_url, $a_type=IL_NOTE_PRIVATE)
Init javascript.
showAllPublicNotes()
show all public notes to user
addObserver($a_callback)
Add observer.
cancelUpdateNote()
cancel edit note
static formatDate(ilDateTime $date)
Format a date public.
ilNoteGUI($a_rep_obj_id="", $a_obj_id="", $a_obj_type="", $a_include_subobjects=false)
constructor, specifies notes set
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:89
static _lookupType($a_id, $a_reference=false)
lookup object type
cancelDelete()
cancel deletion of note
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
global $ilUser
Definition: imgupload.php:15
$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:40
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
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.
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
static _lookupTargetId($a_obj_id)
lookup target id
getListNotesJSCall($a_hash, $a_update_code=null)
Get list notes js call.
& executeCommand()
execute command