ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilNote.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5define("IL_NOTE_PRIVATE", 1);
6define("IL_NOTE_PUBLIC", 2);
7
8define("IL_NOTE_UNLABELED", 0);
9define("IL_NOTE_IMPORTANT", 1);
10define("IL_NOTE_QUESTION", 2);
11define("IL_NOTE_PRO", 3);
12define("IL_NOTE_CONTRA", 4);
13
25class ilNote
26{
30 protected $db;
31
35 protected $settings;
36
40 protected $access;
41
48 protected $rep_obj_id = 0;
49
56 protected $obj_id;
57
63 protected $obj_type;
64
68 protected $news_id;
69
73 protected $no_repository = 0;
74
75
79 public function __construct($a_id = 0)
80 {
81 global $DIC;
82
83 $this->db = $DIC->database();
84 $this->settings = $DIC->settings();
85 $this->access = $DIC->access();
86 if ($a_id > 0) {
87 $this->id = $a_id;
88 $this->read();
89 }
90 }
91
97 public function setId($a_id)
98 {
99 $this->id = $a_id;
100 }
101
107 public function getId()
108 {
109 return $this->id;
110 }
111
120 public function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0, $a_news_id = 0)
121 {
122 $this->rep_obj_id = $a_rep_obj_id;
123 $this->obj_id = $a_obj_id;
124 $this->obj_type = $a_obj_type;
125 $this->news_id = $a_news_id;
126 }
127
128 public function getObject()
129 {
130 // note: any changes here will currently influence
131 // the parameters of all observers!
132 return array("rep_obj_id" => $this->rep_obj_id,
133 "obj_id" => $this->obj_id,
134 "obj_type" => $this->obj_type,
135 "news_id" => $this->news_id);
136 }
137
138
144 public function setType($a_type)
145 {
146 $this->type = $a_type;
147 }
148
154 public function getType()
155 {
156 return $this->type;
157 }
158
164 public function setAuthor($a_user_id)
165 {
166 $this->author = $a_user_id;
167 }
168
174 public function getAuthor()
175 {
176 return $this->author;
177 }
178
184 public function setText($a_text)
185 {
186 $this->text = $a_text;
187 }
188
194 public function getText()
195 {
196 return $this->text;
197 }
198
204 public function setSubject($a_subject)
205 {
206 $this->subject = $a_subject;
207 }
208
214 public function getSubject()
215 {
216 return $this->subject;
217 }
218
224 public function setCreationDate($a_date)
225 {
226 $this->creation_date = $a_date;
227 }
228
234 public function getCreationDate()
235 {
236 return $this->creation_date;
237 }
238
244 public function setUpdateDate($a_date)
245 {
246 $this->update_date = $a_date;
247 }
248
254 public function getUpdateDate()
255 {
256 return $this->update_date;
257 }
258
265 public function setLabel($a_label)
266 {
267 return $this->label = $a_label;
268 }
269
276 public function getLabel()
277 {
278 return $this->label;
279 }
280
286 public function setNewsId($a_val)
287 {
288 $this->news_id = $a_val;
289 }
290
296 public function getNewsId()
297 {
298 return $this->news_id;
299 }
300
306 public function setInRepository($a_value)
307 {
308 return $this->no_repository = !(bool) $a_value;
309 }
310
316 public function isInRepository()
317 {
318 return !$this->no_repository;
319 }
320
321 public function create($a_use_provided_creation_date = false)
322 {
324
325 $cd = ($a_use_provided_creation_date)
326 ? $this->getCreationDate()
327 : ilUtil::now();
328
329 $this->id = $ilDB->nextId("note");
330
331 $ilDB->insert("note", array(
332 "id" => array("integer", $this->id),
333 "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
334 "obj_id" => array("integer", (int) $this->obj_id),
335 "obj_type" => array("text", (string) $this->obj_type),
336 "news_id" => array("integer", (int) $this->news_id),
337 "type" => array("integer", (int) $this->type),
338 "author" => array("integer", (int) $this->author),
339 "note_text" => array("clob", (string) $this->text),
340 "subject" => array("text", (string) $this->subject),
341 "label" => array("integer", (int) $this->label),
342 "creation_date" => array("timestamp", $cd),
343 "no_repository" => array("integer", $this->no_repository)
344 ));
345
346 $this->sendNotifications();
347
348 $this->creation_date = ilNote::_lookupCreationDate($this->getId());
349 }
350
351 public function update()
352 {
354
355 $ilDB->update("note", array(
356 "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
357 "obj_id" => array("integer", (int) $this->obj_id),
358 "news_id" => array("integer", (int) $this->news_id),
359 "obj_type" => array("text", (string) $this->obj_type),
360 "type" => array("integer", (int) $this->type),
361 "author" => array("integer", (int) $this->author),
362 "note_text" => array("clob", (string) $this->text),
363 "subject" => array("text", (string) $this->subject),
364 "label" => array("integer", (int) $this->label),
365 "update_date" => array("timestamp", ilUtil::now()),
366 "no_repository" => array("integer", $this->no_repository)
367 ), array(
368 "id" => array("integer", $this->getId())
369 ));
370
371 $this->update_date = ilNote::_lookupUpdateDate($this->getId());
372
373 $this->sendNotifications(true);
374 }
375
376 public function read()
377 {
379
380 $q = "SELECT * FROM note WHERE id = " .
381 $ilDB->quote((int) $this->getId(), "integer");
382 $set = $ilDB->query($q);
383 $note_rec = $ilDB->fetchAssoc($set);
384 $this->setAllData($note_rec);
385 }
386
390 public function delete()
391 {
393
394 $q = "DELETE FROM note WHERE id = " .
395 $ilDB->quote((int) $this->getId(), "integer");
396 $ilDB->manipulate($q);
397 }
398
402 public function setAllData($a_note_rec)
403 {
404 $this->setId($a_note_rec["id"]);
405 $this->setObject(
406 $a_note_rec["obj_type"],
407 $a_note_rec["rep_obj_id"],
408 $a_note_rec["obj_id"],
409 $a_note_rec["news_id"]
410 );
411 $this->setType($a_note_rec["type"]);
412 $this->setAuthor($a_note_rec["author"]);
413 $this->setText($a_note_rec["note_text"]);
414 $this->setSubject($a_note_rec["subject"]);
415 $this->setLabel($a_note_rec["label"]);
416 $this->setCreationDate($a_note_rec["creation_date"]);
417 $this->setUpdateDate($a_note_rec["update_date"]);
418 $this->setInRepository(!(bool) $a_note_rec["no_repository"]);
419 }
420
424 public static function _lookupCreationDate($a_id)
425 {
426 global $DIC;
427
428 $ilDB = $DIC->database();
429
430 $q = "SELECT * FROM note WHERE id = " .
431 $ilDB->quote((int) $a_id, "integer");
432 $set = $ilDB->query($q);
433 $note_rec = $ilDB->fetchAssoc($set);
434
435 return $note_rec["creation_date"];
436 }
437
441 public static function _lookupUpdateDate($a_id)
442 {
443 global $DIC;
444
445 $ilDB = $DIC->database();
446
447 $q = "SELECT * FROM note WHERE id = " .
448 $ilDB->quote((int) $a_id, "integer");
449 $set = $ilDB->query($q);
450 $note_rec = $ilDB->fetchAssoc($set);
451
452 return $note_rec["update_date"];
453 }
454
458 public static function _getNotesOfObject(
459 $a_rep_obj_id,
460 $a_obj_id,
461 $a_obj_type,
462 $a_type = IL_NOTE_PRIVATE,
463 $a_incl_sub = false,
464 $a_filter = "",
465 $a_all_public = "y",
466 $a_repository_mode = true,
467 $a_sort_ascending = false,
468 $a_news_id = 0
469 ) {
470 global $DIC;
471
472 $ilDB = $DIC->database();
473 $ilUser = $DIC->user();
474
475 $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
476 ? " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer")
477 : "";
478
479 $sub_where = (!$a_incl_sub)
480 ? " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
481 " AND obj_type = " . $ilDB->quote((string) $a_obj_type, "text")
482 : "";
483
484 $news_where =
485 " AND news_id = " . $ilDB->quote((int) $a_news_id, "integer");
486
487
488 $sub_where .= " AND no_repository = " . $ilDB->quote(!$a_repository_mode, "integer");
489
490 $q = "SELECT * FROM note WHERE " .
491 " rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
492 $sub_where .
493 " AND type = " . $ilDB->quote((int) $a_type, "integer") .
494 $author_where .
495 $news_where .
496 " ORDER BY creation_date ";
497
498 $q .= ((bool) $a_sort_ascending) ? "ASC" : "DESC";
499
500 $set = $ilDB->query($q);
501 $notes = array();
502 while ($note_rec = $ilDB->fetchAssoc($set)) {
503 if ($a_filter != "") {
504 if (!is_array($a_filter)) {
505 $a_filter = array($a_filter);
506 }
507 if (!in_array($note_rec["id"], $a_filter)) {
508 continue;
509 }
510 }
511 $cnt = count($notes);
512 $notes[$cnt] = new ilNote();
513 $notes[$cnt]->setAllData($note_rec);
514 }
515
516 return $notes;
517 }
518
522 public static function _getAllNotesOfSingleRepObject(
523 $a_rep_obj_id,
524 $a_type = IL_NOTE_PRIVATE,
525 $a_incl_sub = false,
526 $a_sort_ascending = false,
527 $a_since = ""
528 ) {
529 global $DIC;
530
531 $ilDB = $DIC->database();
532
533 $sub_where = (!$a_incl_sub)
534 ? " AND obj_id = " . $ilDB->quote((int) 0, "integer") : "";
535
536 if ($a_since != "") {
537 $sub_where .= " AND creation_date > " . $ilDB->quote($a_since, "timestamp");
538 }
539
540 $sub_where .= " AND no_repository = " . $ilDB->quote(0, "integer");
541
542 $q = "SELECT * FROM note WHERE " .
543 " rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
544 $sub_where .
545 " AND type = " . $ilDB->quote((int) $a_type, "integer") .
546 " ORDER BY creation_date ";
547
548 $q .= ((bool) $a_sort_ascending) ? "ASC" : "DESC";
549 $set = $ilDB->query($q);
550 $notes = array();
551 while ($note_rec = $ilDB->fetchAssoc($set)) {
552 $cnt = count($notes);
553 $notes[$cnt] = new ilNote();
554 $notes[$cnt]->setAllData($note_rec);
555 }
556 return $notes;
557 }
558
562 public static function _getLastNotesOfUser()
563 {
564 global $DIC;
565
566 $ilDB = $DIC->database();
567 $ilUser = $DIC->user();
568
569 $q = "SELECT * FROM note WHERE " .
570 " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
571 " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer") .
572 " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
573 " ORDER BY creation_date DESC";
574
575 $ilDB->quote($q);
576 $set = $ilDB->query($q);
577 $notes = array();
578 while ($note_rec = $ilDB->fetchAssoc($set)) {
579 $cnt = count($notes);
580 $notes[$cnt] = new ilNote();
581 $notes[$cnt]->setAllData($note_rec);
582 }
583
584 return $notes;
585 }
586
590 public static function _getRelatedObjectsOfUser($a_mode)
591 {
592 global $DIC;
593
594 $fav_rep = new ilFavouritesDBRepository();
595
596 $ilDB = $DIC->database();
597 $ilUser = $DIC->user();
598 $tree = $DIC->repositoryTree();
599
600 if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES) {
601 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
602 " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
603 " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
604 " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
605 " ORDER BY rep_obj_id";
606
607 $ilDB->quote($q);
608 $set = $ilDB->query($q);
609 $reps = array();
610 while ($rep_rec = $ilDB->fetchAssoc($set)) {
611 // #9343: deleted objects
612 if (ilObject::_lookupType($rep_rec["rep_obj_id"])) {
613 $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
614 }
615 }
616 } else {
617 // all objects where the user wrote at least one comment
618 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
619 " type = " . $ilDB->quote((int) IL_NOTE_PUBLIC, "integer") .
620 " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
621 " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
622 " ORDER BY rep_obj_id";
623
624 $set = $ilDB->query($q);
625 $reps = array();
626 while ($rep_rec = $ilDB->fetchAssoc($set)) {
627 // #9343: deleted objects
628 if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"])) {
629 if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type)) {
630 $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
631 }
632 }
633 }
634
635 // additionally all objects on the personal desktop of the user
636 // that have at least on comment
637 $dis = $fav_rep->getFavouritesOfUser($ilUser->getId());
638 $obj_ids = array();
639 foreach ($dis as $di) {
640 $obj_ids[] = $di["obj_id"];
641 }
642 if (count($obj_ids) > 0) {
643 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
644 $ilDB->in("rep_obj_id", $obj_ids, false, "integer") .
645 " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")";
646
647 $set = $ilDB->query($q);
648 while ($rec = $ilDB->fetchAssoc($set)) {
649 $add = true;
650 reset($reps);
651 foreach ($reps as $r) {
652 if ($r["rep_obj_id"] == $rec["rep_obj_id"]) {
653 $add = false;
654 }
655 }
656 if ($add) {
657 $type = ilObject::_lookupType($rec["rep_obj_id"]);
658 if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type)) {
659 $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
660 }
661 }
662 }
663 }
664 }
665
666 if (sizeof($reps)) {
667 // check if notes/comments belong to objects in trash
668 // see ilNoteGUI::showTargets()
669 foreach ($reps as $idx => $rep) {
670 $has_active_ref = false;
671
672 // repository?
673 $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
674 if ($ref_ids) {
675 $reps[$idx]["ref_ids"] = array_values($ref_ids);
676
677 foreach ($ref_ids as $ref_id) {
678 if (!$tree->isDeleted($ref_id)) {
679 $has_active_ref = true;
680 break;
681 }
682 }
683 } else {
684 // personal workspace?
685 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
686 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
687 $wsp_tree = new ilWorkspaceTree($ilUser->getId());
688 $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
689 if ($node_id) {
690 $reps[$idx]["wsp_id"] = $node_id;
691
692 $has_active_ref = true;
693 }
694 }
695
696 if (!$has_active_ref) {
697 unset($reps[$idx]);
698 }
699 }
700 }
701
702 return $reps;
703 }
704
712 public static function getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
713 {
714 global $DIC;
715
716 $ilDB = $DIC->database();
717
718 $set = $ilDB->queryF(
719 "SELECT count(DISTINCT author) cnt FROM note WHERE " .
720 "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
721 array("integer", "integer", "text"),
722 array((int) $a_rep_obj_id, (int) $a_obj_id, (string) $a_type)
723 );
724 $rec = $ilDB->fetchAssoc($set);
725 return (int) $rec["cnt"];
726 }
727
734 public static function _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs = false)
735 {
736 global $DIC;
737
738 $ilDB = $DIC->database();
739 $ilUser = $DIC->user();
740
741 $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
742 " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
743 "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
744 " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
745 $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
746
747 if ($a_no_sub_objs) {
748 $q .= " AND obj_id = " . $ilDB->quote(0, "integer");
749 }
750
751 $q .= " GROUP BY rep_obj_id, type ";
752
753 $cnt = array();
754 $set = $ilDB->query($q);
755 while ($rec = $ilDB->fetchAssoc($set)) {
756 $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
757 }
758
759 return $cnt;
760 }
761
768 public static function _countNotesAndComments(
769 $a_rep_obj_id,
770 $a_sub_obj_id = null,
771 $a_obj_type = "",
772 $a_news_id = 0
773 ) {
774 global $DIC;
775
776 $ilDB = $DIC->database();
777 $ilUser = $DIC->user();
778
779 $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
780 " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
781 "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
782 " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
783 " rep_obj_id = " . $ilDB->quote($a_rep_obj_id, "integer");
784
785 if ($a_sub_obj_id !== null) {
786 $q .= " AND obj_id = " . $ilDB->quote($a_sub_obj_id, "integer");
787 $q .= " AND obj_type = " . $ilDB->quote($a_obj_type, "text");
788 }
789
790 $q .= " AND news_id = " . $ilDB->quote($a_news_id, "integer");
791
792 $q .= " GROUP BY rep_obj_id, type ";
793
794 $cnt = array();
795 $set = $ilDB->query($q);
796 while ($rec = $ilDB->fetchAssoc($set)) {
797 $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
798 }
799
800 return $cnt;
801 }
802
809 public static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate = true)
810 {
811 global $DIC;
812
813 $ilDB = $DIC->database();
814
815 if ($a_obj_type == "") {
816 $a_obj_type = "-";
817 }
818 $set = $ilDB->query(
819 "SELECT * FROM note_settings " .
820 " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
821 " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
822 " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
823 );
824 if ($rec = $ilDB->fetchAssoc($set)) {
825 if (($rec["activated"] == 0 && $a_activate) ||
826 ($rec["activated"] == 1 && !$a_activate)) {
827 $ilDB->manipulate(
828 "UPDATE note_settings SET " .
829 " activated = " . $ilDB->quote((int) $a_activate, "integer") .
830 " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
831 " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
832 " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
833 );
834 }
835 } else {
836 if ($a_activate) {
837 $q = "INSERT INTO note_settings " .
838 "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
839 $ilDB->quote((int) $a_rep_obj_id, "integer") . "," .
840 $ilDB->quote((int) $a_obj_id, "integer") . "," .
841 $ilDB->quote($a_obj_type, "text") . "," .
842 $ilDB->quote(1, "integer") .
843 ")";
844 $ilDB->manipulate($q);
845 }
846 }
847 }
848
855 public static function commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id = 0)
856 {
857 global $DIC;
858
859 $ilDB = $DIC->database();
860
861 if ($a_news_id > 0) {
862 return true;
863 }
864
865 if ($a_obj_type == "") {
866 $a_obj_type = "-";
867 }
868 $set = $ilDB->query(
869 "SELECT * FROM note_settings " .
870 " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
871 " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
872 " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
873 );
874 $rec = $ilDB->fetchAssoc($set);
875 return $rec["activated"];
876 }
877
884 public static function getRepObjActivation($a_rep_obj_ids)
885 {
886 global $DIC;
887
888 $ilDB = $DIC->database();
889
890 $set = $ilDB->query("SELECT * FROM note_settings " .
891 " WHERE " . $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer") .
892 " AND obj_id = 0 ");
893 $activations = array();
894 while ($rec = $ilDB->fetchAssoc($set)) {
895 if ($rec["activated"]) {
896 $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
897 }
898 }
899
900 return $activations;
901 }
902
903
907 public function sendNotifications($a_changed = false)
908 {
910 $ilAccess = $this->access;
911
912 // no notifications for notes
913 if ($this->getType() == IL_NOTE_PRIVATE) {
914 return;
915 }
916
917 $recipients = $ilSetting->get("comments_noti_recip");
918 $recipients = explode(",", $recipients);
919
920 // blog: blog_id, 0, "blog"
921 // lm: lm_id, page_id, "pg" (ok)
922 // sahs: sahs_id, node_id, node_type
923 // info_screen: obj_id, 0, obj_type (ok)
924 // portfolio: port_id, page_id, "portfolio_page" (ok)
925 // wiki: wiki_id, wiki_page_id, "wpg" (ok)
926
927 $obj = $this->getObject();
928 $rep_obj_id = $obj["rep_obj_id"];
929 $sub_obj_id = $obj["obj_id"];
930 $type = $obj["obj_type"];
931
932 include_once("./Services/Language/classes/class.ilLanguageFactory.php");
933 include_once("./Services/User/classes/class.ilUserUtil.php");
934 include_once("./Services/Mail/classes/class.ilMail.php");
935
936 // repository objects, no blogs
937 $ref_ids = array();
938 if (($sub_obj_id == 0 and $type != "blp") ||
939 in_array($type, array("pg", "wpg"))) {
941 $type_lv = "obj_" . $type;
943 }
944
945 if ($type == "wpg") {
946 $type_lv = "obj_wiki";
947 }
948 if ($type == "pg") {
949 $type_lv = "obj_lm";
950 }
951 if ($type == "blp") {
953 $type_lv = "obj_blog";
954 }
955 if ($type == "pfpg") {
957 $type_lv = "portfolio";
958 }
959 if ($type == "dcl") {
961 $type_lv = "obj_dcl";
962 }
963
964 include_once("./Services/Link/classes/class.ilLink.php");
965 foreach ($recipients as $r) {
966 $login = trim($r);
967 if (($user_id = ilObjUser::_lookupId($login)) > 0) {
968 $link = "";
969 foreach ($ref_ids as $r) {
970 if ($ilAccess->checkAccessOfUser($user_id, "read", "", $r)) {
971 if ($sub_obj_id == 0 and $type != "blog") {
972 $link = ilLink::_getLink($r);
973 } elseif ($type == "wpg") {
974 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
975 include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
976 $title = ilWikiPage::lookupTitle($sub_obj_id);
978 $r,
979 "wiki",
980 true,
981 "_" . ilWikiUtil::makeUrlTitle($title)
982 );
983 } elseif ($type == "pg") {
984 $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=pg_" . $sub_obj_id . "_" . $r;
985 }
986 }
987 }
988 if ($type == "blp") {
989 // todo
990 }
991 if ($type == "pfpg") {
992 $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=prtf_" . $rep_obj_id;
993 }
994
995 // use language of recipient to compose message
997 $ulng->loadLanguageModule('note');
998
999 if ($a_changed) {
1000 $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
1001 } else {
1002 $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
1003 }
1004 $message = sprintf($ulng->txt('note_comment_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
1005
1006 $message .= sprintf($ulng->txt('note_comment_notification_user_has_written'), ilUserUtil::getNamePresentation($this->getAuthor())) . "\n\n";
1007
1008 $message .= $this->getText() . "\n\n";
1009
1010 if ($link != "") {
1011 $message .= $ulng->txt('note_comment_notification_link') . ": " . $link . "\n\n";
1012 }
1013
1014 $message .= $ulng->txt('note_comment_notification_reason') . "\n\n";
1015
1016 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
1017 $mail_obj->appendInstallationSignature(true);
1018 $mail_obj->enqueue(
1019 ilObjUser::_lookupLogin($user_id),
1020 "",
1021 "",
1022 $subject,
1023 $message,
1024 array()
1025 );
1026 }
1027 }
1028 }
1029}
An exception for terminatinating execution or to throw for unit testing.
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
static _getLanguageOfUser($a_usr_id)
Get language object of user.
Note class.
create($a_use_provided_creation_date=false)
static _lookupUpdateDate($a_id)
lookup update date of note
static _getLastNotesOfUser()
get last notes of current user
__construct($a_id=0)
constructor
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
getUpdateDate()
get update date
setType($a_type)
set type
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
getSubject()
get subject
getLabel()
get label
setLabel($a_label)
set label
setUpdateDate($a_date)
set update date
setId($a_id)
set id
setAllData($a_note_rec)
set all note data by record array
setAuthor($a_user_id)
set author
static _countNotesAndComments( $a_rep_obj_id, $a_sub_obj_id=null, $a_obj_type="", $a_news_id=0)
Get all notes related to a specific object.
getAuthor()
get author
static _getAllNotesOfSingleRepObject( $a_rep_obj_id, $a_type=IL_NOTE_PRIVATE, $a_incl_sub=false, $a_sort_ascending=false, $a_since="")
get all notes related to a single repository object
setText($a_text)
set text
getText()
get text
sendNotifications($a_changed=false)
Send notifications.
getCreationDate()
get creation date
static _lookupCreationDate($a_id)
lookup creation date of note
setInRepository($a_value)
set repository object status
setNewsId($a_val)
Set news id.
static _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs=false)
Get all notes related to multiple objcts.
getId()
get id
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, $a_news_id=0)
get all notes related to a specific object
getNewsId()
Get news id.
static getRepObjActivation($a_rep_obj_ids)
Get activation for repository objects.
setCreationDate($a_date)
set creation date
isInRepository()
belongs note to repository object?
static _getRelatedObjectsOfUser($a_mode)
get all related objects for user
getType()
get type
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0, $a_news_id=0)
set assigned object
static getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
How many users have attached a note/comment to a given object?
setSubject($a_subject)
set subject
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
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:
static now()
Return current timestamp in Y-m-d H:i:s format.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
Tree handler for personal workspace.
const CLIENT_ID
Definition: constants.php:39
const ANONYMOUS_USER_ID
Definition: constants.php:25
$login
Definition: cron.php:13
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
global $ilSetting
Definition: privfeed.php:17
$type
settings()
Definition: settings.php:2
global $ilDB
$message
Definition: xapiexit.php:14