ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilNote.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4define("IL_NOTE_PRIVATE", 1);
5define("IL_NOTE_PUBLIC", 2);
6
7define("IL_NOTE_UNLABELED", 0);
8define("IL_NOTE_IMPORTANT", 1);
9define("IL_NOTE_QUESTION", 2);
10define("IL_NOTE_PRO", 3);
11define("IL_NOTE_CONTRA", 4);
12
24class ilNote
25{
26
30 function ilNote($a_id = 0)
31 {
32 if ($a_id > 0)
33 {
34 $this->id = $a_id;
35 $this->read();
36 }
37 }
38
44 function setId($a_id)
45 {
46 $this->id = $a_id;
47 }
48
54 function getId()
55 {
56 return $this->id;
57 }
58
69 function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0)
70 {
71 $this->rep_obj_id = $a_rep_obj_id;
72 $this->obj_id = $a_obj_id;
73 $this->obj_type = $a_obj_type;
74 }
75
76 function getObject()
77 {
78 return array("rep_obj_id" => $this->rep_obj_id,
79 "obj_id" => $this->obj_id,
80 "obj_type" => $this->obj_type);
81 }
82
83
89 function setType($a_type)
90 {
91 $this->type = $a_type;
92 }
93
99 function getType()
100 {
101 return $this->type;
102 }
103
109 function setAuthor($a_user_id)
110 {
111 $this->author = $a_user_id;
112 }
113
119 function getAuthor()
120 {
121 return $this->author;
122 }
123
129 function setText($a_text)
130 {
131 $this->text = $a_text;
132 }
133
139 function getText()
140 {
141 return $this->text;
142 }
143
149 function setSubject($a_subject)
150 {
151 $this->subject = $a_subject;
152 }
153
159 function getSubject()
160 {
161 return $this->subject;
162 }
163
169 function setCreationDate($a_date)
170 {
171 $this->creation_date = $a_date;
172 }
173
180 {
181 return $this->creation_date;
182 }
183
189 function setUpdateDate($a_date)
190 {
191 $this->update_date = $a_date;
192 }
193
199 function getUpdateDate()
200 {
201 return $this->update_date;
202 }
203
210 function setLabel($a_label)
211 {
212 return $this->label = $a_label;
213 }
214
221 function getLabel()
222 {
223 return $this->label;
224 }
225
231 function setInRepository($a_value)
232 {
233 return $this->no_repository = !(bool)$a_value;
234 }
235
241 function isInRepository()
242 {
243 return !$this->no_repository;
244 }
245
246 function create($a_use_provided_creation_date = false)
247 {
248 global $ilDB;
249
250 $cd = ($a_use_provided_creation_date)
251 ? $this->getCreationDate()
252 : ilUtil::now();
253
254 $this->id = $ilDB->nextId("note");
255 /*$q = "INSERT INTO note (id, rep_obj_id, obj_id, obj_type, type,".
256 "author, note_text, subject, label, creation_date) VALUES (".
257 $ilDB->quote($this->id, "integer").",".
258 $ilDB->quote((int) $this->rep_obj_id, "integer").",".
259 $ilDB->quote((int) $this->obj_id, "integer").",".
260 $ilDB->quote((string) $this->obj_type, "text").",".
261 $ilDB->quote((int) $this->type, "integer").",".
262 $ilDB->quote((int) $this->author, "integer").",".
263 $ilDB->quote((string) $this->text, "clob").",".
264 $ilDB->quote((string) $this->subject, "text").",".
265 $ilDB->quote((int) $this->label, "integer").",".
266 $ilDB->now().")";
267 $ilDB->manipulate($q);*/
268
269 $ilDB->insert("note", array(
270 "id" => array("integer", $this->id),
271 "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
272 "obj_id" => array("integer", (int) $this->obj_id),
273 "obj_type" => array("text", (string) $this->obj_type),
274 "type" => array("integer", (int) $this->type),
275 "author" => array("integer", (int) $this->author),
276 "note_text" => array("clob", (string) $this->text),
277 "subject" => array("text", (string) $this->subject),
278 "label" => array("integer", (int) $this->label),
279 "creation_date" => array("timestamp", $cd),
280 "no_repository" => array("integer", $this->no_repository)
281 ));
282
283 $this->sendNotifications();
284
285 $this->creation_date = ilNote::_lookupCreationDate($this->getId());
286 }
287
288 function update()
289 {
290 global $ilDB;
291
292 /*$q = "UPDATE note SET ".
293 "rep_obj_id = ".$ilDB->quote((int) $this->rep_obj_id, "integer").",".
294 "obj_id = ".$ilDB->quote((int) $this->obj_id, "integer").",".
295 "obj_type = ".$ilDB->quote((string) $this->obj_type, "text").",".
296 "type = ".$ilDB->quote((int) $this->type, "integer").",".
297 "author = ".$ilDB->quote((int) $this->author,"integer").",".
298 "note_text = ".$ilDB->quote((string) $this->text, "clob").",".
299 "subject = ".$ilDB->quote((string) $this->subject, "text").",".
300 "update_date = ".$ilDB->now().",".
301 "label = ".$ilDB->quote((int) $this->label, "integer").
302 "WHERE id =".$ilDB->quote((int) $this->getId(), "integer");
303 $ilDB->manipulate($q);*/
304 $ilDB->update("note", array(
305 "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
306 "obj_id" => array("integer", (int) $this->obj_id),
307 "obj_type" => array("text", (string) $this->obj_type),
308 "type" => array("integer", (int) $this->type),
309 "author" => array("integer", (int) $this->author),
310 "note_text" => array("clob", (string) $this->text),
311 "subject" => array("text", (string) $this->subject),
312 "label" => array("integer", (int) $this->label),
313 "update_date" => array("timestamp", ilUtil::now()),
314 "no_repository" => array("integer", $this->no_repository)
315 ), array(
316 "id" => array("integer", $this->getId())
317 ));
318
319 $this->update_date = ilNote::_lookupUpdateDate($this->getId());
320
321 $this->sendNotifications(true);
322 }
323
324 function read()
325 {
326 global $ilDB;
327
328 $q = "SELECT * FROM note WHERE id = ".
329 $ilDB->quote((int) $this->getId(), "integer");
330 $set = $ilDB->query($q);
331 $note_rec = $ilDB->fetchAssoc($set);
332 $this->setAllData($note_rec);
333 }
334
338 function delete()
339 {
340 global $ilDB;
341
342 $q = "DELETE FROM note WHERE id = ".
343 $ilDB->quote((int) $this->getId(), "integer");
344 $ilDB->manipulate($q);
345 }
346
350 function setAllData($a_note_rec)
351 {
352 $this->setId($a_note_rec["id"]);
353 $this->setObject($a_note_rec["obj_type"], $a_note_rec["rep_obj_id"], $a_note_rec["obj_id"]);
354 $this->setType($a_note_rec["type"]);
355 $this->setAuthor($a_note_rec["author"]);
356 $this->setText($a_note_rec["note_text"]);
357 $this->setSubject($a_note_rec["subject"]);
358 $this->setLabel($a_note_rec["label"]);
359 $this->setCreationDate($a_note_rec["creation_date"]);
360 $this->setUpdateDate($a_note_rec["update_date"]);
361 $this->setInRepository(!(bool)$a_note_rec["no_repository"]);
362 }
363
367 function _lookupCreationDate($a_id)
368 {
369 global $ilDB;
370
371 $q = "SELECT * FROM note WHERE id = ".
372 $ilDB->quote((int) $this->getId(), "integer");
373 $set = $ilDB->query($q);
374 $note_rec = $ilDB->fetchAssoc($set);
375
376 return $note_rec["creation_date"];
377 }
378
382 function _lookupUpdateDate($a_id)
383 {
384 global $ilDB;
385
386 $q = "SELECT * FROM note WHERE id = ".
387 $ilDB->quote((int) $this->getId(), "integer");
388 $set = $ilDB->query($q);
389 $note_rec = $ilDB->fetchAssoc($set);
390
391 return $note_rec["update_date"];
392 }
393
397 function _getNotesOfObject($a_rep_obj_id, $a_obj_id, $a_obj_type,
398 $a_type = IL_NOTE_PRIVATE, $a_incl_sub = false, $a_filter = "",
399 $a_all_public = "y", $a_repository_mode = true, $a_sort_ascending = false)
400 {
401 global $ilDB, $ilUser;
402
403 $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
404 ? " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer")
405 : "";
406
407 $sub_where = (!$a_incl_sub)
408 ? " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
409 " AND obj_type = ".$ilDB->quote((string) $a_obj_type, "text")
410 : "";
411
412 if(!$a_repository_mode)
413 {
414 $sub_where .= " AND no_repository = ".$ilDB->quote(1, "integer");
415 }
416
417 $q = "SELECT * FROM note WHERE ".
418 " rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
419 $sub_where.
420 " AND type = ".$ilDB->quote((int) $a_type, "integer").
421 $author_where.
422 " ORDER BY creation_date ";
423
424 $q .= ((bool)$a_sort_ascending) ? "ASC" : "DESC";
425
426 $set = $ilDB->query($q);
427 $notes = array();
428 while($note_rec = $ilDB->fetchAssoc($set))
429 {
430 if ($a_filter != "")
431 {
432 if (!is_array($a_filter))
433 {
434 $a_filter = array($a_filter);
435 }
436 if (!in_array($note_rec["id"], $a_filter))
437 {
438 continue;
439 }
440 }
441 $cnt = count($notes);
442 $notes[$cnt] = new ilNote();
443 $notes[$cnt]->setAllData($note_rec);
444 }
445
446 return $notes;
447 }
448
453 {
454 global $ilDB, $ilUser;
455
456 $q = "SELECT * FROM note WHERE ".
457 " type = ".$ilDB->quote((int) IL_NOTE_PRIVATE, "integer").
458 " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer").
459 " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
460 " ORDER BY creation_date DESC";
461
462 $ilDB->quote($q);
463 $set = $ilDB->query($q);
464 $notes = array();
465 while($note_rec = $ilDB->fetchAssoc($set))
466 {
467 $cnt = count($notes);
468 $notes[$cnt] = new ilNote();
469 $notes[$cnt]->setAllData($note_rec);
470 }
471
472 return $notes;
473 }
474
478 function _getRelatedObjectsOfUser($a_mode)
479 {
480 global $ilDB, $ilUser, $tree;
481
482 if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES)
483 {
484 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
485 " type = ".$ilDB->quote((int) IL_NOTE_PRIVATE, "integer").
486 " AND author = ".$ilDB->quote($ilUser->getId(), "integer").
487 " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
488 " ORDER BY rep_obj_id";
489
490 $ilDB->quote($q);
491 $set = $ilDB->query($q);
492 $reps = array();
493 while($rep_rec = $ilDB->fetchAssoc($set))
494 {
495 // #9343: deleted objects
496 if(ilObject::_lookupType($rep_rec["rep_obj_id"]))
497 {
498 $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
499 }
500 }
501 }
502 else
503 {
504 // all objects where the user wrote at least one comment
505 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
506 " type = ".$ilDB->quote((int) IL_NOTE_PUBLIC, "integer").
507 " AND author = ".$ilDB->quote($ilUser->getId(), "integer").
508 " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
509 " ORDER BY rep_obj_id";
510
511 $set = $ilDB->query($q);
512 $reps = array();
513 while($rep_rec = $ilDB->fetchAssoc($set))
514 {
515 // #9343: deleted objects
516 if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"]))
517 {
518 if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type))
519 {
520 $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
521 }
522 }
523 }
524
525 // additionally all objects on the personal desktop of the user
526 // that have at least on comment
528 $obj_ids = array();
529 foreach($dis as $di)
530 {
531 $obj_ids[] = $di["obj_id"];
532 }
533 if (count($obj_ids) > 0)
534 {
535 $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
536 $ilDB->in("rep_obj_id", $obj_ids, false, "integer").
537 " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")";
538
539 $set = $ilDB->query($q);
540 while($rec = $ilDB->fetchAssoc($set))
541 {
542 $add = true;
543 reset($reps);
544 foreach ($reps as $r)
545 {
546 if ($r["rep_obj_id"] == $rec["rep_obj_id"])
547 {
548 $add = false;
549 }
550 }
551 if ($add)
552 {
553 $type = ilObject::_lookupType($rec["rep_obj_id"]);
554 if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type))
555 {
556 $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
557 }
558 }
559 }
560 }
561 }
562
563 if(sizeof($reps))
564 {
565 // check if notes/comments belong to objects in trash
566 // see ilNoteGUI::showTargets()
567 foreach($reps as $idx => $rep)
568 {
569 $has_active_ref = false;
570
571 // repository?
572 $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
573 if($ref_ids)
574 {
575 $reps[$idx]["ref_ids"] = array_values($ref_ids);
576
577 foreach($ref_ids as $ref_id)
578 {
579 if(!$tree->isDeleted($ref_id))
580 {
581 $has_active_ref = true;
582 break;
583 }
584 }
585 }
586 else
587 {
588 // personal workspace?
589 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
590 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
591 $wsp_tree = new ilWorkspaceTree($ilUser->getId());
592 $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
593 if($node_id)
594 {
595 $reps[$idx]["wsp_id"] = $node_id;
596
597 $has_active_ref = true;
598 }
599 }
600
601 if(!$has_active_ref)
602 {
603 unset($reps[$idx]);
604 }
605 }
606 }
607
608 return $reps;
609 }
610
618 static function getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
619 {
620 global $ilDB;
621
622 $set = $ilDB->queryF("SELECT count(DISTINCT author) cnt FROM note WHERE ".
623 "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
624 array("integer", "integer", "text"),
625 array((int) $a_rep_obj_id, (int) $a_obj_id, (string)$a_type));
626 $rec = $ilDB->fetchAssoc($set);
627 return (int) $rec["cnt"];
628 }
629
636 static function _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs = false)
637 {
638 global $ilDB, $ilUser;
639
640 $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
641 " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
642 "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
643 " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
644 $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
645
646 if ($a_no_sub_objs)
647 {
648 $q .= " AND obj_id = ".$ilDB->quote(0, "integer");
649 }
650
651 $q .= " GROUP BY rep_obj_id, type ";
652
653 $cnt = array();
654 $set = $ilDB->query($q);
655 while ($rec = $ilDB->fetchAssoc($set))
656 {
657 $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
658 }
659
660 return $cnt;
661 }
662
669 static function _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id = null)
670 {
671 global $ilDB, $ilUser;
672
673 $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
674 " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
675 "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
676 " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
677 " rep_obj_id = ".$ilDB->quote($a_rep_obj_id, "integer");
678
679 if ($a_sub_obj_id !== null)
680 {
681 $q .= " AND obj_id = ".$ilDB->quote($a_sub_obj_id, "integer");
682 }
683
684 $q .= " GROUP BY rep_obj_id, type ";
685
686 $cnt = array();
687 $set = $ilDB->query($q);
688 while ($rec = $ilDB->fetchAssoc($set))
689 {
690 $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
691 }
692
693 return $cnt;
694 }
695
702 static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate = true)
703 {
704 global $ilDB;
705
706 if ($a_obj_type == "")
707 {
708 $a_obj_type = "-";
709 }
710 $set = $ilDB->query("SELECT * FROM note_settings ".
711 " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
712 " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
713 " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
714 );
715 if ($rec = $ilDB->fetchAssoc($set))
716 {
717 if (($rec["activated"] == 0 && $a_activate) ||
718 ($rec["activated"] == 1 && !$a_activate))
719 {
720 $ilDB->manipulate("UPDATE note_settings SET ".
721 " activated = ".$ilDB->quote((int) $a_activate, "integer").
722 " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
723 " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
724 " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
725 );
726 }
727 }
728 else
729 {
730 if ($a_activate)
731 {
732 $q = "INSERT INTO note_settings ".
733 "(rep_obj_id, obj_id, obj_type, activated) VALUES (".
734 $ilDB->quote((int) $a_rep_obj_id, "integer").",".
735 $ilDB->quote((int) $a_obj_id, "integer").",".
736 $ilDB->quote($a_obj_type, "text").",".
737 $ilDB->quote(1, "integer").
738 ")";
739 $ilDB->manipulate($q);
740 }
741 }
742 }
743
750 static function commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
751 {
752 global $ilDB;
753
754 if ($a_obj_type == "")
755 {
756 $a_obj_type = "-";
757 }
758 $set = $ilDB->query("SELECT * FROM note_settings ".
759 " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
760 " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
761 " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
762 );
763 $rec = $ilDB->fetchAssoc($set);
764 return $rec["activated"];
765 }
766
773 static function getRepObjActivation($a_rep_obj_ids)
774 {
775 global $ilDB;
776
777 $set = $ilDB->query("SELECT * FROM note_settings ".
778 " WHERE ".$ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer").
779 " AND obj_id = 0 ");
780 $activations = array();
781 while ($rec = $ilDB->fetchAssoc($set))
782 {
783 if ($rec["activated"])
784 {
785 $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
786 }
787 }
788
789 return $activations;
790 }
791
792
796 function sendNotifications($a_changed = false)
797 {
798 global $ilSetting, $ilAccess;
799
800 // no notifications for notes
801 if ($this->getType() == IL_NOTE_PRIVATE)
802 {
803 return;
804 }
805
806 $recipients = $ilSetting->get("comments_noti_recip");
807 $recipients = explode(",", $recipients);
808
809 // blog: blog_id, 0, "blog"
810 // lm: lm_id, page_id, "pg" (ok)
811 // sahs: sahs_id, node_id, node_type
812 // info_screen: obj_id, 0, obj_type (ok)
813 // portfolio: port_id, page_id, "portfolio_page" (ok)
814 // wiki: wiki_id, wiki_page_id, "wpg" (ok)
815
816 $obj = $this->getObject();
817 $rep_obj_id = $obj["rep_obj_id"];
818 $sub_obj_id = $obj["obj_id"];
819 $type = $obj["obj_type"];
820
821 include_once("./Services/Language/classes/class.ilLanguageFactory.php");
822 include_once("./Services/User/classes/class.ilUserUtil.php");
823 include_once("./Services/Mail/classes/class.ilMail.php");
824
825 // repository objects, no blogs
826 $ref_ids = array();
827 if (($sub_obj_id == 0 and $type != "blp") ||
828 in_array($type, array("pg", "wpg")))
829 {
830 $obj_title = ilObject::_lookupTitle($rep_obj_id);
831 $type_lv = "obj_".$type;
832 $ref_ids = ilObject::_getAllReferences($rep_obj_id);
833 }
834
835 if ($type == "wpg")
836 {
837 $type_lv = "obj_wiki";
838 }
839 if ($type == "pg")
840 {
841 $type_lv = "obj_lm";
842 }
843 if ($type == "blp")
844 {
845 $obj_title = ilObject::_lookupTitle($rep_obj_id);
846 $type_lv = "obj_blog";
847 }
848 if ($type == "pfpg")
849 {
850 $obj_title = ilObject::_lookupTitle($rep_obj_id);
851 $type_lv = "portfolio";
852 }
853
854 include_once("./Services/Link/classes/class.ilLink.php");
855 foreach($recipients as $r)
856 {
857 $login = trim($r);
858 if (($user_id = ilObjUser::_lookupId($login)) > 0)
859 {
860 $link = "";
861 foreach ($ref_ids as $r)
862 {
863 if ($ilAccess->checkAccessOfUser($user_id, "read", "", $r))
864 {
865 if ($sub_obj_id == 0 and $type != "blog")
866 {
867 $link = ilLink::_getLink($r);
868 }
869 else if ($type == "wpg")
870 {
871 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
872 include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
873 $title = ilWikiPage::lookupTitle($sub_obj_id);
874 $link = ilLink::_getStaticLink($r, "wiki",
875 true, "_".ilWikiUtil::makeUrlTitle($title));
876 }
877 else if ($type == "pg")
878 {
879 $link = ILIAS_HTTP_PATH.'/goto.php?client_id='.CLIENT_ID."&target=pg_".$sub_obj_id."_".$r;
880 }
881 }
882 }
883 if ($type == "blp")
884 {
885 // todo
886 }
887 if ($type == "pfpg")
888 {
889 $link = ILIAS_HTTP_PATH.'/goto.php?client_id='.CLIENT_ID."&target=prtf_".$rep_obj_id;
890 }
891
892 // use language of recipient to compose message
894 $ulng->loadLanguageModule('note');
895
896 if ($a_changed)
897 {
898 $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title." (".$ulng->txt($type_lv).")");
899 }
900 else
901 {
902 $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title." (".$ulng->txt($type_lv).")");
903 }
904 $message = sprintf($ulng->txt('note_comment_notification_salutation'), ilObjUser::_lookupFullname($user_id))."\n\n";
905
906 $message.= sprintf($ulng->txt('note_comment_notification_user_has_written'), ilUserUtil::getNamePresentation($this->getAuthor()))."\n\n";
907
908 $message .= $this->getText()."\n\n";
909
910 if ($link != "")
911 {
912 $message .= $ulng->txt('note_comment_notification_link').": ".$link."\n\n";
913 }
914
915 $message .= $ulng->txt('note_comment_notification_reason')."\n\n";
916
917 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
918 $mail_obj->appendInstallationSignature(true);
919 $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id),
920 "", "", $subject, $message, array(), array("system"));
921 }
922 }
923
924 }
925
926}
927?>
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
static _getLanguageOfUser($a_usr_id)
Get language object of user.
Class Mail this class handles base functions for mail handling.
Note class.
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
create($a_use_provided_creation_date=false)
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0)
set assigned 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
_lookupCreationDate($a_id)
lookup creation date of note
_getLastNotesOfUser()
get last notes of current user
static _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id=null)
Get all notes related to a specific object.
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
_lookupUpdateDate($a_id)
lookup update date of note
getAuthor()
get author
_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
setText($a_text)
set text
getText()
get text
ilNote($a_id=0)
constructor
sendNotifications($a_changed=false)
Send notifications.
getCreationDate()
get creation date
setInRepository($a_value)
set repository object status
static _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs=false)
Get all notes related to multiple objcts.
getId()
get id
static getRepObjActivation($a_rep_obj_ids)
Get activation for repository objects.
setCreationDate($a_date)
set creation date
isInRepository()
belongs note to repository object?
getType()
get type
_getRelatedObjectsOfUser($a_mode)
get all related objects for user
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.
_lookupFullname($a_user_id)
Lookup Full Name.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
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)
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.
$text
$r
Definition: example_031.php:79
global $ilSetting
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
global $ilDB
global $ilUser
Definition: imgupload.php:15