24 include_once (
"Services/Notes/classes/class.ilNote.php");
48 function ilNoteGUI($a_rep_obj_id =
"", $a_obj_id =
"", $a_obj_type =
"", $a_include_subobjects =
false)
52 $lng->loadLanguageModule(
"notes");
54 $this->rep_obj_id = $a_rep_obj_id;
55 $this->obj_id = $a_obj_id;
56 $this->obj_type = $a_obj_type;
57 $this->inc_sub = $a_include_subobjects;
62 $this->add_note_form =
false;
63 $this->edit_note_form =
false;
64 $this->private_enabled =
false;
66 $id = $this->rep_obj_id.
"_".$this->obj_id.
"_".$this->obj_type;
67 if ($notes_settings->get(
"activate_".$id))
69 $this->public_enabled =
true;
73 $this->public_enabled =
false;
75 $this->enable_hiding =
true;
76 $this->targets_enabled =
false;
77 $this->multi_selection =
false;
78 $this->export_html =
false;
80 $this->comments_settings =
false;
82 $this->note_img = array(
85 "alt" => $lng->txt(
"note")),
88 "alt" => $lng->txt(
"note").
", ".$lng->txt(
"important")),
91 "alt" => $lng->txt(
"note").
", ".$lng->txt(
"question")),
94 "alt" => $lng->txt(
"note").
", ".$lng->txt(
"pro")),
97 "alt" => $lng->txt(
"note").
", ".$lng->txt(
"contra"))
100 $this->comment_img = array(
103 "alt" => $lng->txt(
"notes_comment")),
106 "alt" => $lng->txt(
"notes_comment").
", ".$lng->txt(
"important")),
109 "alt" => $lng->txt(
"notes_comment").
", ".$lng->txt(
"question")),
112 "alt" => $lng->txt(
"notes_comment").
", ".$lng->txt(
"pro")),
115 "alt" => $lng->txt(
"notes_comment").
", ".$lng->txt(
"contra"))
124 $cmd = $this->ctrl->getCmd(
"getNotesHTML");
125 $next_class = $this->ctrl->getNextClass($this);
130 return $this->
$cmd();
140 $this->private_enabled = $a_enable;
148 $this->public_enabled = $a_enable;
156 $this->comments_settings = $a_enable;
164 $this->public_deletion_enabled = $a_enable;
172 $this->enable_hiding = $a_enable;
180 $this->targets_enabled = $a_enable;
188 $this->multi_selection = $a_enable;
198 $lng->loadLanguageModule(
"notes");
200 $ntpl =
new ilTemplate(
"tpl.notes_and_comments.html",
true,
true,
203 if ($this->private_enabled && ($ilUser->getId() != ANONYMOUS_USER_ID))
208 $comments_col =
false;
209 if ($this->public_enabled && (!$this->delete_note || $this->public_deletion_enabled))
212 $comments_col =
true;
216 if ($this->comments_settings)
218 $notes_settings =
new ilSetting(
"notes");
219 $id = $this->rep_obj_id.
"_".$this->obj_id.
"_".$this->obj_type;
220 $active = $notes_settings->get(
"activate_".$id);
222 $ntpl->setCurrentBlock(
"comments_settings");
225 $ntpl->setVariable(
"TXT_COMMENTS_SETTINGS", $lng->txt(
"notes_deactivate_comments"));
226 $ntpl->setVariable(
"HREF_COMMENTS_SETTINGS",
227 $ilCtrl->getLinkTargetByClass(
"ilnotegui",
"deactivateComments",
"notes_top"));
231 $ntpl->setVariable(
"TXT_COMMENTS_SETTINGS", $lng->txt(
"notes_activate_comments"));
232 $ntpl->setVariable(
"HREF_COMMENTS_SETTINGS",
233 $ilCtrl->getLinkTargetByClass(
"ilnotegui",
"activateComments",
"notes_top"));
235 $ntpl->parseCurrentBlock();
236 $comments_col =
true;
241 $ntpl->setCurrentBlock(
"comments_col");
242 $ntpl->parseCurrentBlock();
255 $notes_settings =
new ilSetting(
"notes");
257 if ($this->comments_settings)
259 $id = $this->rep_obj_id.
"_".$this->obj_id.
"_".$this->obj_type;
260 $notes_settings->set(
"activate_".$id, 1);
263 $ilCtrl->redirectByClass(
"ilnotegui",
"getNotesHtml");
273 $notes_settings =
new ilSetting(
"notes");
275 if ($this->comments_settings)
277 $id = $this->rep_obj_id.
"_".$this->obj_id.
"_".$this->obj_type;
278 $notes_settings->set(
"activate_".$id, 0);
281 $ilCtrl->redirectByClass(
"ilnotegui",
"getNotesHtml");
289 global
$lng,
$ilCtrl, $ilUser, $ilAccess, $tree, $objDefinition;
295 if ($this->delete_note || $this->export_html || $this->print)
297 if (
$_GET[
"note_id"] !=
"")
299 $filter =
$_GET[
"note_id"];
303 $filter = $_POST[
"note"];
308 $this->obj_type, $a_type, $this->inc_sub, $filter,
312 $this->obj_type, $a_type, $this->inc_sub, $filter,
313 "", $this->public_deletion_enabled);
315 $tpl =
new ilTemplate(
"tpl.notes_list.html",
true,
true,
"Services/Notes");
318 $cnt_str = (count($all_notes) > 0)
319 ?
" (".count($all_notes).
")"
330 if ($this->delete_note)
332 $tpl->setVariable(
"TXT_NOTES", $lng->txt(
"info_delete_sure"));
336 $tpl->setVariable(
"TXT_NOTES", $lng->txt(
"private_notes").$cnt_str);
337 $tpl->setVariable(
"A_NAME",
"notes_top");
338 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_type",
IL_NOTE_PRIVATE);
342 $tpl->setVariable(
"TXT_NOTES", $lng->txt(
"notes_public_comments").$cnt_str);
343 $tpl->setVariable(
"A_NAME",
"comments_top");
344 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_type",
IL_NOTE_PUBLIC);
346 $tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this,
"getNotesHTML",
"notes_top"));
348 if ($this->export_html || $this->print)
350 $tpl->touchBlock(
"print_style");
354 if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note &&
355 !$this->export_html && !$this->print &&
356 ($ilUser->getId() != ANONYMOUS_USER_ID))
360 $tpl->setCurrentBlock(
"add_note_btn");
363 $tpl->setVariable(
"TXT_ADD_NOTE", $lng->txt(
"notes_add_comment"));
367 $tpl->setVariable(
"TXT_ADD_NOTE", $lng->txt(
"add_note"));
369 $tpl->setVariable(
"LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass(
"ilnotegui",
"addNoteForm").
371 $tpl->parseCurrentBlock();
376 if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note
377 && !$this->export_html && !$this->print)
379 if ($ilUser->getPref(
"notes_".$suffix) ==
"n")
381 $tpl->setCurrentBlock(
"show_notes");
382 $tpl->setVariable(
"LINK_SHOW_NOTES",
383 $this->ctrl->getLinkTargetByClass(
"ilnotegui",
"showNotes",
"notes_top"));
386 $tpl->setVariable(
"TXT_SHOW_NOTES", $lng->txt(
"notes_show_comments"));
390 $tpl->setVariable(
"TXT_SHOW_NOTES", $lng->txt(
"show_".$suffix.
"_notes"));
392 $tpl->parseCurrentBlock();
397 if (($ilUser->getId() != ANONYMOUS_USER_ID))
399 $tpl->setCurrentBlock(
"hide_notes");
400 $tpl->setVariable(
"LINK_HIDE_NOTES",
401 $this->ctrl->getLinkTargetByClass(
"ilnotegui",
"hideNotes",
"notes_top"));
404 $tpl->setVariable(
"TXT_HIDE_NOTES", $lng->txt(
"notes_hide_comments"));
408 $tpl->setVariable(
"TXT_HIDE_NOTES", $lng->txt(
"hide_".$suffix.
"_notes"));
410 $tpl->parseCurrentBlock();
415 if ($ilUser->getPref(
"notes_pub_all") ==
"n")
417 $tpl->setCurrentBlock(
"all_pub_notes");
418 $tpl->setVariable(
"LINK_ALL_PUB_NOTES",
419 $this->ctrl->getLinkTargetByClass(
"ilnotegui",
"showAllPublicNotes",
"notes_top"));
420 $tpl->setVariable(
"TXT_ALL_PUB_NOTES", $lng->txt(
"notes_all_comments"));
421 $tpl->parseCurrentBlock();
425 $tpl->setCurrentBlock(
"my_pub_notes");
426 $tpl->setVariable(
"LINK_MY_PUB_NOTES",
427 $this->ctrl->getLinkTargetByClass(
"ilnotegui",
"showMyPublicNotes",
"notes_top"));
428 $tpl->setVariable(
"TXT_MY_PUB_NOTES", $lng->txt(
"notes_my_comments"));
429 $tpl->parseCurrentBlock();
437 if ($this->add_note_form && $a_type ==
$_GET[
"note_type"])
439 $tpl->setCurrentBlock(
"edit_note");
440 $tpl->setVariable(
"TXT_SUBJECT", $lng->txt(
"subject"));
443 $tpl->setVariable(
"TXT_NOTE", $lng->txt(
"notes_comment"));
447 $tpl->setVariable(
"TXT_NOTE", $lng->txt(
"note"));
449 $tpl->setVariable(
"NOTE_SUBJECT",
"");
450 $tpl->setVariable(
"SUB_NOTE",
"sub_note");
451 $tpl->setVariable(
"TA_NOTE",
"note");
452 $tpl->setVariable(
"NOTE_CONTENT",
"");
453 $tpl->setVariable(
"BTN_ADD_NOTE",
"addNote");
454 $tpl->setVariable(
"TXT_ADD_NOTE", $lng->txt(
"add"));
455 $tpl->setVariable(
"BTN_CANCEL_ADD_NOTE",
"cancelAddNote");
456 $tpl->setVariable(
"TXT_CANCEL_ADD_NOTE", $lng->txt(
"cancel"));
458 $tpl->setVariable(
"TXT_LABEL_NONE", $lng->txt(
"unlabeled"));
460 $tpl->setVariable(
"TXT_LABEL_QUESTION", $lng->txt(
"question"));
462 $tpl->setVariable(
"TXT_LABEL_IMPORTANT", $lng->txt(
"important"));
464 $tpl->setVariable(
"TXT_LABEL_PRO", $lng->txt(
"pro"));
466 $tpl->setVariable(
"TXT_LABEL_CONTRA", $lng->txt(
"contra"));
467 $tpl->parseCurrentBlock();
468 $tpl->setCurrentBlock(
"note_row");
469 $tpl->parseCurrentBlock();
473 if ($ilUser->getPref(
"notes_".$suffix) !=
"n" || !$this->enable_hiding)
475 foreach($notes as $note)
477 if ($this->edit_note_form && ($note->getId() ==
$_GET[
"note_id"])
478 && $a_type ==
$_GET[
"note_type"])
480 $tpl->setCurrentBlock(
"edit_note_form");
481 $tpl->setVariable(
"TXT_SUBJECT", $lng->txt(
"subject"));
484 $tpl->setVariable(
"TXT_NOTE", $lng->txt(
"notes_comment"));
488 $tpl->setVariable(
"TXT_NOTE", $lng->txt(
"note"));
490 $tpl->setVariable(
"NOTE_SUBJECT",
492 $tpl->setVariable(
"SUB_NOTE",
"sub_note");
493 $tpl->setVariable(
"TA_NOTE",
"note");
494 $tpl->setVariable(
"NOTE_CONTENT",
496 $tpl->setVariable(
"BTN_ADD_NOTE",
"updateNote");
497 $tpl->setVariable(
"TXT_ADD_NOTE", $lng->txt(
"save"));
498 $tpl->setVariable(
"BTN_CANCEL_ADD_NOTE",
"cancelUpdateNote");
499 $tpl->setVariable(
"TXT_CANCEL_ADD_NOTE", $lng->txt(
"cancel"));
501 $tpl->setVariable(
"TXT_LABEL_NONE", $lng->txt(
"unlabeled"));
503 $tpl->setVariable(
"TXT_LABEL_QUESTION", $lng->txt(
"question"));
505 $tpl->setVariable(
"TXT_LABEL_IMPORTANT", $lng->txt(
"important"));
507 $tpl->setVariable(
"TXT_LABEL_PRO", $lng->txt(
"pro"));
509 $tpl->setVariable(
"TXT_LABEL_CONTRA", $lng->txt(
"contra"));
510 $tpl->setVariable(
"VAL_NOTE_ID",
$_GET[
"note_id"]);
511 switch($note->getLabel())
514 $tpl->setVariable(
"SEL_NONE",
'selected="selected"');
518 $tpl->setVariable(
"SEL_IMPORTANT",
'selected="selected"');
522 $tpl->setVariable(
"SEL_QUESTION",
'selected="selected"');
526 $tpl->setVariable(
"SEL_PRO",
'selected="selected"');
530 $tpl->setVariable(
"SEL_CONTRA",
'selected="selected"');
533 $tpl->parseCurrentBlock();
540 if (($note->getAuthor() == $ilUser->getId() ||
542 && ($ilUser->getId() != ANONYMOUS_USER_ID))
547 && !$this->delete_note
548 && !$this->export_html && !$this->print)
550 $tpl->setCurrentBlock(
"delete_note");
551 $tpl->setVariable(
"TXT_DELETE_NOTE", $lng->txt(
"delete"));
552 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_id", $note->getId());
553 $tpl->setVariable(
"LINK_DELETE_NOTE",
554 $ilCtrl->getLinkTargetByClass(
"ilnotegui",
"deleteNote")
555 .
"#note_".$note->getId());
556 $tpl->parseCurrentBlock();
561 if ($note->getAuthor() == $ilUser->getId()
562 && ($ilUser->getId() != ANONYMOUS_USER_ID))
565 if ($this->multi_selection && !$this->delete_note)
567 $tpl->setCurrentBlock(
"checkbox_col");
568 $tpl->setVariable(
"CHK_NOTE",
"note[]");
569 $tpl->setVariable(
"CHK_NOTE_ID", $note->getId());
570 $tpl->parseCurrentBlock();
574 if (!$this->delete_note && !$this->export_html && !$this->print)
576 $tpl->setCurrentBlock(
"edit_note");
577 $tpl->setVariable(
"TXT_EDIT_NOTE", $lng->txt(
"edit"));
578 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_id", $note->getId());
579 $tpl->setVariable(
"LINK_EDIT_NOTE",
580 $ilCtrl->getLinkTargetByClass(
"ilnotegui",
"editNoteForm")
582 $tpl->parseCurrentBlock();
586 $tpl->setVariable(
"CNT_COL", $cnt_col);
591 $tpl->setCurrentBlock(
"author");
593 $tpl->parseCurrentBlock();
594 $tpl->setCurrentBlock(
"user_img");
595 $tpl->setVariable(
"USR_IMG",
597 $tpl->setVariable(
"USR_ALT",
599 $tpl->parseCurrentBlock();
603 if ($note->getUpdateDate() !=
"0000-00-00 00:00:00")
605 $tpl->setCurrentBlock(
"last_edit");
606 $tpl->setVariable(
"TXT_LAST_EDIT", $lng->txt(
"last_edited_on"));
607 $tpl->setVariable(
"DATE_LAST_EDIT",
609 $tpl->parseCurrentBlock();
613 if ($this->delete_note)
615 $tpl->setCurrentBlock(
"delete_ids");
616 $tpl->setVariable(
"HID_NOTE",
"note[]");
617 $tpl->setVariable(
"HID_NOTE_ID", $note->getId());
618 $tpl->parseCurrentBlock();
620 $target = $note->getObject();
624 $target[
"obj_type"], $target[
"obj_id"]);
626 $rowclass = ($rowclass !=
"tblrow1")
629 if (!$this->export_html && !$this->print)
631 $tpl->setCurrentBlock(
"note_img");
634 $tpl->setVariable(
"IMG_NOTE", $this->comment_img[$note->getLabel()][
"img"]);
635 $tpl->setVariable(
"ALT_NOTE", $this->comment_img[$note->getLabel()][
"alt"]);
639 $tpl->setVariable(
"IMG_NOTE", $this->note_img[$note->getLabel()][
"img"]);
640 $tpl->setVariable(
"ALT_NOTE", $this->note_img[$note->getLabel()][
"alt"]);
642 $tpl->parseCurrentBlock();
646 switch ($note->getLabel())
649 $tpl->setVariable(
"EXP_ICON",
"[ ]");
653 $tpl->setVariable(
"EXP_ICON",
"[!]");
657 $tpl->setVariable(
"EXP_ICON",
"[?]");
661 $tpl->setVariable(
"EXP_ICON",
"[+]");
665 $tpl->setVariable(
"EXP_ICON",
"[-]");
669 $tpl->setCurrentBlock(
"note");
670 $tpl->setVariable(
"ROWCLASS", $rowclass);
671 $tpl->setVariable(
"TXT_DATE", $lng->txt(
"date"));
672 $tpl->setVariable(
"TXT_CREATED", $lng->txt(
"create_date"));
673 $tpl->setVariable(
"VAL_DATE",
675 $tpl->setVariable(
"NOTE_TEXT", nl2br($note->getText()));
676 $tpl->setVariable(
"VAL_SUBJECT", $note->getSubject());
677 $tpl->setVariable(
"NOTE_ID", $note->getId());
678 $tpl->parseCurrentBlock();
680 $tpl->setCurrentBlock(
"note_row");
681 $tpl->parseCurrentBlock();
685 if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form)
687 $tpl->setCurrentBlock(
"multiple_commands");
688 $tpl->setVariable(
"TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
690 $tpl->setVariable(
"ALT_ARROW", $this->lng->txt(
"actions"));
691 $tpl->setVariable(
"TXT_DELETE_NOTES", $this->lng->txt(
"delete"));
692 $tpl->setVariable(
"TXT_PRINT_NOTES", $this->lng->txt(
"print"));
693 $tpl->setVariable(
"TXT_EXPORT_NOTES", $this->lng->txt(
"exp_html"));
694 $tpl->parseCurrentBlock();
698 if ($this->delete_note)
700 $tpl->setCurrentBlock(
"delete_cancel");
701 $tpl->setVariable(
"TXT_DEL_NOTES", $this->lng->txt(
"delete"));
702 $tpl->setVariable(
"TXT_CANCEL_DEL_NOTES", $this->lng->txt(
"cancel"));
703 $tpl->parseCurrentBlock();
709 $tpl->touchBlock(
"print_js");
710 $tpl->setCurrentBlock(
"print_back");
711 $tpl->setVariable(
"LINK_BACK", $this->ctrl->getLinkTarget($this,
"showNotes"));
712 $tpl->setVariable(
"TXT_BACK", $this->lng->txt(
"back"));
713 $tpl->parseCurrentBlock();
717 if ($this->delete_note && count($notes) == 0)
734 $tpl =
new ilTemplate(
"tpl.pd_note.html",
true,
true,
"Services/Notes");
735 $note =
new ilNote($note_id);
736 $target = $note->getObject();
738 if ($note->getAuthor() != $ilUser->getId())
744 $alt = $lng->txt(
"note");
746 $tpl->setCurrentBlock(
"edit_note");
747 $ilCtrl->setParameterByClass(
"ilnotegui",
"rel_obj", $target[
"rep_obj_id"]);
748 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_id", $note_id);
749 $ilCtrl->setParameterByClass(
"ilnotegui",
"note_type", $note->getType());
750 $tpl->setVariable(
"LINK_EDIT_NOTE",
751 $ilCtrl->getLinkTargetByClass(array(
"ilpersonaldesktopgui",
"ilpdnotesgui",
"ilnotegui"),
753 $tpl->setVariable(
"TXT_EDIT_NOTE", $lng->txt(
"edit"));
754 $tpl->parseCurrentBlock();
755 $ilCtrl->clearParametersByClass(
"ilnotegui");
757 $tpl->setCurrentBlock(
"note_img");
758 $tpl->setVariable(
"IMG_NOTE", $this->note_img[$note->getLabel()][
"img"]);
759 $tpl->setVariable(
"ALT_NOTE", $this->note_img[$note->getLabel()][
"alt"]);
760 $tpl->parseCurrentBlock();
763 if ($note->getUpdateDate() !=
"0000-00-00 00:00:00")
765 $tpl->setCurrentBlock(
"last_edit");
766 $tpl->setVariable(
"TXT_LAST_EDIT", $lng->txt(
"last_edited_on"));
767 $tpl->setVariable(
"DATE_LAST_EDIT",
769 $tpl->parseCurrentBlock();
772 $tpl->setVariable(
"TXT_CREATED", $lng->txt(
"create_date"));
773 $tpl->setVariable(
"VAL_DATE",
775 $tpl->setVariable(
"VAL_SUBJECT", $note->getSubject());
776 $tpl->setVariable(
"NOTE_TEXT", nl2br($note->getText()));
777 $this->
showTargets(
$tpl, $target[
"rep_obj_id"], $note_id, $target[
"obj_type"], $target[
"obj_id"]);
786 global $tree, $ilAccess, $objDefinition;
788 if ($this->targets_enabled)
790 if ($a_rep_obj_id > 0)
795 $vis_ref_ids = array();
799 if ($ilAccess->checkAccess(
"visible",
"", $ref_id))
806 if (count($vis_ref_ids) > 0)
808 foreach($vis_ref_ids as $vis_ref_id)
812 if ($a_obj_type !=
"pg")
814 if (!is_object($this->item_list_gui[$type]))
816 $class = $objDefinition->getClassName($type);
817 $location = $objDefinition->getLocation($type);
818 $full_class =
"ilObj".$class.
"ListGUI";
819 include_once(
$location.
"/class.".$full_class.
".php");
820 $this->item_list_gui[$type] =
new $full_class();
823 $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id,
$title);
824 $link = $this->item_list_gui[$type]->getCommandLink(
"infoScreen");
829 $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link).
"#note_".$a_note_id;
834 $link =
"goto.php?target=pg_".$a_obj_id.
"_".$vis_ref_id;
837 $par_id = $tree->getParentId($vis_ref_id);
838 if ($this->export_html || $this->print)
840 $tpl->setCurrentBlock(
"exp_target_object");
844 $tpl->setCurrentBlock(
"target_object");
845 $tpl->setVariable(
"LINK_TARGET", $link);
847 $tpl->setVariable(
"TXT_CONTAINER",
850 $tpl->setVariable(
"TXT_TARGET",
852 $tpl->parseCurrentBlock();
854 $tpl->touchBlock(
"target_objects");
870 $ilUser->setPref(
"notes_".$suffix,
"y");
872 $this->add_note_form =
true;
899 if($_POST[
"note"] !=
"" || $_POST[
"sub_note"] !=
"")
902 $note->setObject($this->obj_type, $this->rep_obj_id, $this->obj_id);
903 $note->setType(
$_GET[
"note_type"]);
904 $note->setAuthor($ilUser->getId());
907 $note->setLabel($_POST[
"note_label"]);
921 $note =
new ilNote($_POST[
"note_id"]);
927 $note->setLabel($_POST[
"note_label"]);
938 $this->edit_note_form =
true;
947 $this->delete_note =
true;
964 $this->delete_note =
true;
982 foreach($_POST[
"note"] as $id)
997 $this->export_html =
true;
998 $this->multi_selection =
false;
1010 $this->print =
true;
1011 $this->multi_selection =
false;
1026 $ilUser->writePref(
"notes_".$suffix,
"y");
1041 $ilUser->writePref(
"notes_".$suffix,
"n");
1053 $ilUser->writePref(
"notes_pub_all",
"y");
1065 $ilUser->writePref(
"notes_pub_all",
"n");