ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 define("IL_NOTE_PRIVATE", 1);
5 define("IL_NOTE_PUBLIC", 2);
6 
7 define("IL_NOTE_UNLABELED", 0);
8 define("IL_NOTE_IMPORTANT", 1);
9 define("IL_NOTE_QUESTION", 2);
10 define("IL_NOTE_PRO", 3);
11 define("IL_NOTE_CONTRA", 4);
12 
24 class ilNote
25 {
29  protected $db;
30 
34  protected $settings;
35 
39  protected $access;
40 
41 
45  public function __construct($a_id = 0)
46  {
47  global $DIC;
48 
49  $this->db = $DIC->database();
50  $this->settings = $DIC->settings();
51  $this->access = $DIC->access();
52  if ($a_id > 0) {
53  $this->id = $a_id;
54  $this->read();
55  }
56  }
57 
63  public function setId($a_id)
64  {
65  $this->id = $a_id;
66  }
67 
73  public function getId()
74  {
75  return $this->id;
76  }
77 
88  public function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0)
89  {
90  $this->rep_obj_id = $a_rep_obj_id;
91  $this->obj_id = $a_obj_id;
92  $this->obj_type = $a_obj_type;
93  }
94 
95  public function getObject()
96  {
97  return array("rep_obj_id" => $this->rep_obj_id,
98  "obj_id" => $this->obj_id,
99  "obj_type" => $this->obj_type);
100  }
101 
102 
108  public function setType($a_type)
109  {
110  $this->type = $a_type;
111  }
112 
118  public function getType()
119  {
120  return $this->type;
121  }
122 
128  public function setAuthor($a_user_id)
129  {
130  $this->author = $a_user_id;
131  }
132 
138  public function getAuthor()
139  {
140  return $this->author;
141  }
142 
148  public function setText($a_text)
149  {
150  $this->text = $a_text;
151  }
152 
158  public function getText()
159  {
160  return $this->text;
161  }
162 
168  public function setSubject($a_subject)
169  {
170  $this->subject = $a_subject;
171  }
172 
178  public function getSubject()
179  {
180  return $this->subject;
181  }
182 
188  public function setCreationDate($a_date)
189  {
190  $this->creation_date = $a_date;
191  }
192 
198  public function getCreationDate()
199  {
200  return $this->creation_date;
201  }
202 
208  public function setUpdateDate($a_date)
209  {
210  $this->update_date = $a_date;
211  }
212 
218  public function getUpdateDate()
219  {
220  return $this->update_date;
221  }
222 
229  public function setLabel($a_label)
230  {
231  return $this->label = $a_label;
232  }
233 
240  public function getLabel()
241  {
242  return $this->label;
243  }
244 
250  public function setInRepository($a_value)
251  {
252  return $this->no_repository = !(bool) $a_value;
253  }
254 
260  public function isInRepository()
261  {
262  return !$this->no_repository;
263  }
264 
265  public function create($a_use_provided_creation_date = false)
266  {
267  $ilDB = $this->db;
268 
269  $cd = ($a_use_provided_creation_date)
270  ? $this->getCreationDate()
271  : ilUtil::now();
272 
273  $this->id = $ilDB->nextId("note");
274  /*$q = "INSERT INTO note (id, rep_obj_id, obj_id, obj_type, type,".
275  "author, note_text, subject, label, creation_date) VALUES (".
276  $ilDB->quote($this->id, "integer").",".
277  $ilDB->quote((int) $this->rep_obj_id, "integer").",".
278  $ilDB->quote((int) $this->obj_id, "integer").",".
279  $ilDB->quote((string) $this->obj_type, "text").",".
280  $ilDB->quote((int) $this->type, "integer").",".
281  $ilDB->quote((int) $this->author, "integer").",".
282  $ilDB->quote((string) $this->text, "clob").",".
283  $ilDB->quote((string) $this->subject, "text").",".
284  $ilDB->quote((int) $this->label, "integer").",".
285  $ilDB->now().")";
286  $ilDB->manipulate($q);*/
287 
288  $ilDB->insert("note", array(
289  "id" => array("integer", $this->id),
290  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
291  "obj_id" => array("integer", (int) $this->obj_id),
292  "obj_type" => array("text", (string) $this->obj_type),
293  "type" => array("integer", (int) $this->type),
294  "author" => array("integer", (int) $this->author),
295  "note_text" => array("clob", (string) $this->text),
296  "subject" => array("text", (string) $this->subject),
297  "label" => array("integer", (int) $this->label),
298  "creation_date" => array("timestamp", $cd),
299  "no_repository" => array("integer", $this->no_repository)
300  ));
301 
302  $this->sendNotifications();
303 
304  $this->creation_date = ilNote::_lookupCreationDate($this->getId());
305  }
306 
307  public function update()
308  {
309  $ilDB = $this->db;
310 
311  /*$q = "UPDATE note SET ".
312  "rep_obj_id = ".$ilDB->quote((int) $this->rep_obj_id, "integer").",".
313  "obj_id = ".$ilDB->quote((int) $this->obj_id, "integer").",".
314  "obj_type = ".$ilDB->quote((string) $this->obj_type, "text").",".
315  "type = ".$ilDB->quote((int) $this->type, "integer").",".
316  "author = ".$ilDB->quote((int) $this->author,"integer").",".
317  "note_text = ".$ilDB->quote((string) $this->text, "clob").",".
318  "subject = ".$ilDB->quote((string) $this->subject, "text").",".
319  "update_date = ".$ilDB->now().",".
320  "label = ".$ilDB->quote((int) $this->label, "integer").
321  "WHERE id =".$ilDB->quote((int) $this->getId(), "integer");
322  $ilDB->manipulate($q);*/
323  $ilDB->update("note", array(
324  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
325  "obj_id" => array("integer", (int) $this->obj_id),
326  "obj_type" => array("text", (string) $this->obj_type),
327  "type" => array("integer", (int) $this->type),
328  "author" => array("integer", (int) $this->author),
329  "note_text" => array("clob", (string) $this->text),
330  "subject" => array("text", (string) $this->subject),
331  "label" => array("integer", (int) $this->label),
332  "update_date" => array("timestamp", ilUtil::now()),
333  "no_repository" => array("integer", $this->no_repository)
334  ), array(
335  "id" => array("integer", $this->getId())
336  ));
337 
338  $this->update_date = ilNote::_lookupUpdateDate($this->getId());
339 
340  $this->sendNotifications(true);
341  }
342 
343  public function read()
344  {
345  $ilDB = $this->db;
346 
347  $q = "SELECT * FROM note WHERE id = " .
348  $ilDB->quote((int) $this->getId(), "integer");
349  $set = $ilDB->query($q);
350  $note_rec = $ilDB->fetchAssoc($set);
351  $this->setAllData($note_rec);
352  }
353 
357  public function delete()
358  {
359  $ilDB = $this->db;
360 
361  $q = "DELETE FROM note WHERE id = " .
362  $ilDB->quote((int) $this->getId(), "integer");
363  $ilDB->manipulate($q);
364  }
365 
369  public function setAllData($a_note_rec)
370  {
371  $this->setId($a_note_rec["id"]);
372  $this->setObject($a_note_rec["obj_type"], $a_note_rec["rep_obj_id"], $a_note_rec["obj_id"]);
373  $this->setType($a_note_rec["type"]);
374  $this->setAuthor($a_note_rec["author"]);
375  $this->setText($a_note_rec["note_text"]);
376  $this->setSubject($a_note_rec["subject"]);
377  $this->setLabel($a_note_rec["label"]);
378  $this->setCreationDate($a_note_rec["creation_date"]);
379  $this->setUpdateDate($a_note_rec["update_date"]);
380  $this->setInRepository(!(bool) $a_note_rec["no_repository"]);
381  }
382 
386  public static function _lookupCreationDate($a_id)
387  {
388  global $DIC;
389 
390  $ilDB = $DIC->database();
391 
392  $q = "SELECT * FROM note WHERE id = " .
393  $ilDB->quote((int) $a_id, "integer");
394  $set = $ilDB->query($q);
395  $note_rec = $ilDB->fetchAssoc($set);
396 
397  return $note_rec["creation_date"];
398  }
399 
403  public static function _lookupUpdateDate($a_id)
404  {
405  global $DIC;
406 
407  $ilDB = $DIC->database();
408 
409  $q = "SELECT * FROM note WHERE id = " .
410  $ilDB->quote((int) $a_id, "integer");
411  $set = $ilDB->query($q);
412  $note_rec = $ilDB->fetchAssoc($set);
413 
414  return $note_rec["update_date"];
415  }
416 
420  public static function _getNotesOfObject(
421  $a_rep_obj_id,
422  $a_obj_id,
423  $a_obj_type,
425  $a_incl_sub = false,
426  $a_filter = "",
427  $a_all_public = "y",
428  $a_repository_mode = true,
429  $a_sort_ascending = false
430  ) {
431  global $DIC;
432 
433  $ilDB = $DIC->database();
434  $ilUser = $DIC->user();
435 
436  $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
437  ? " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer")
438  : "";
439 
440  $sub_where = (!$a_incl_sub)
441  ? " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
442  " AND obj_type = " . $ilDB->quote((string) $a_obj_type, "text")
443  : "";
444 
445  if (!$a_repository_mode) {
446  $sub_where .= " AND no_repository = " . $ilDB->quote(1, "integer");
447  }
448 
449  $q = "SELECT * FROM note WHERE " .
450  " rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
451  $sub_where .
452  " AND type = " . $ilDB->quote((int) $a_type, "integer") .
453  $author_where .
454  " ORDER BY creation_date ";
455 
456  $q .= ((bool) $a_sort_ascending) ? "ASC" : "DESC";
457 
458  $set = $ilDB->query($q);
459  $notes = array();
460  while ($note_rec = $ilDB->fetchAssoc($set)) {
461  if ($a_filter != "") {
462  if (!is_array($a_filter)) {
463  $a_filter = array($a_filter);
464  }
465  if (!in_array($note_rec["id"], $a_filter)) {
466  continue;
467  }
468  }
469  $cnt = count($notes);
470  $notes[$cnt] = new ilNote();
471  $notes[$cnt]->setAllData($note_rec);
472  }
473 
474  return $notes;
475  }
476 
480  public static function _getLastNotesOfUser()
481  {
482  global $DIC;
483 
484  $ilDB = $DIC->database();
485  $ilUser = $DIC->user();
486 
487  $q = "SELECT * FROM note WHERE " .
488  " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
489  " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer") .
490  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
491  " ORDER BY creation_date DESC";
492 
493  $ilDB->quote($q);
494  $set = $ilDB->query($q);
495  $notes = array();
496  while ($note_rec = $ilDB->fetchAssoc($set)) {
497  $cnt = count($notes);
498  $notes[$cnt] = new ilNote();
499  $notes[$cnt]->setAllData($note_rec);
500  }
501 
502  return $notes;
503  }
504 
508  public static function _getRelatedObjectsOfUser($a_mode)
509  {
510  global $DIC;
511 
512  $ilDB = $DIC->database();
513  $ilUser = $DIC->user();
514  $tree = $DIC->repositoryTree();
515 
516  if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES) {
517  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
518  " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
519  " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
520  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
521  " ORDER BY rep_obj_id";
522 
523  $ilDB->quote($q);
524  $set = $ilDB->query($q);
525  $reps = array();
526  while ($rep_rec = $ilDB->fetchAssoc($set)) {
527  // #9343: deleted objects
528  if (ilObject::_lookupType($rep_rec["rep_obj_id"])) {
529  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
530  }
531  }
532  } else {
533  // all objects where the user wrote at least one comment
534  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
535  " type = " . $ilDB->quote((int) IL_NOTE_PUBLIC, "integer") .
536  " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
537  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
538  " ORDER BY rep_obj_id";
539 
540  $set = $ilDB->query($q);
541  $reps = array();
542  while ($rep_rec = $ilDB->fetchAssoc($set)) {
543  // #9343: deleted objects
544  if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"])) {
545  if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type)) {
546  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
547  }
548  }
549  }
550 
551  // additionally all objects on the personal desktop of the user
552  // that have at least on comment
553  $dis = ilObjUser::_lookupDesktopItems($ilUser->getId());
554  $obj_ids = array();
555  foreach ($dis as $di) {
556  $obj_ids[] = $di["obj_id"];
557  }
558  if (count($obj_ids) > 0) {
559  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
560  $ilDB->in("rep_obj_id", $obj_ids, false, "integer") .
561  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")";
562 
563  $set = $ilDB->query($q);
564  while ($rec = $ilDB->fetchAssoc($set)) {
565  $add = true;
566  reset($reps);
567  foreach ($reps as $r) {
568  if ($r["rep_obj_id"] == $rec["rep_obj_id"]) {
569  $add = false;
570  }
571  }
572  if ($add) {
573  $type = ilObject::_lookupType($rec["rep_obj_id"]);
574  if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type)) {
575  $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
576  }
577  }
578  }
579  }
580  }
581 
582  if (sizeof($reps)) {
583  // check if notes/comments belong to objects in trash
584  // see ilNoteGUI::showTargets()
585  foreach ($reps as $idx => $rep) {
586  $has_active_ref = false;
587 
588  // repository?
589  $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
590  if ($ref_ids) {
591  $reps[$idx]["ref_ids"] = array_values($ref_ids);
592 
593  foreach ($ref_ids as $ref_id) {
594  if (!$tree->isDeleted($ref_id)) {
595  $has_active_ref = true;
596  break;
597  }
598  }
599  } else {
600  // personal workspace?
601  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
602  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
603  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
604  $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
605  if ($node_id) {
606  $reps[$idx]["wsp_id"] = $node_id;
607 
608  $has_active_ref = true;
609  }
610  }
611 
612  if (!$has_active_ref) {
613  unset($reps[$idx]);
614  }
615  }
616  }
617 
618  return $reps;
619  }
620 
628  public static function getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
629  {
630  global $DIC;
631 
632  $ilDB = $DIC->database();
633 
634  $set = $ilDB->queryF(
635  "SELECT count(DISTINCT author) cnt FROM note WHERE " .
636  "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
637  array("integer", "integer", "text"),
638  array((int) $a_rep_obj_id, (int) $a_obj_id, (string) $a_type)
639  );
640  $rec = $ilDB->fetchAssoc($set);
641  return (int) $rec["cnt"];
642  }
643 
650  public static function _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs = false)
651  {
652  global $DIC;
653 
654  $ilDB = $DIC->database();
655  $ilUser = $DIC->user();
656 
657  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
658  " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
659  "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
660  " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
661  $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
662 
663  if ($a_no_sub_objs) {
664  $q .= " AND obj_id = " . $ilDB->quote(0, "integer");
665  }
666 
667  $q .= " GROUP BY rep_obj_id, type ";
668 
669  $cnt = array();
670  $set = $ilDB->query($q);
671  while ($rec = $ilDB->fetchAssoc($set)) {
672  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
673  }
674 
675  return $cnt;
676  }
677 
684  public static function _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id = null)
685  {
686  global $DIC;
687 
688  $ilDB = $DIC->database();
689  $ilUser = $DIC->user();
690 
691  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
692  " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
693  "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
694  " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
695  " rep_obj_id = " . $ilDB->quote($a_rep_obj_id, "integer");
696 
697  if ($a_sub_obj_id !== null) {
698  $q .= " AND obj_id = " . $ilDB->quote($a_sub_obj_id, "integer");
699  }
700 
701  $q .= " GROUP BY rep_obj_id, type ";
702 
703  $cnt = array();
704  $set = $ilDB->query($q);
705  while ($rec = $ilDB->fetchAssoc($set)) {
706  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
707  }
708 
709  return $cnt;
710  }
711 
718  public static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate = true)
719  {
720  global $DIC;
721 
722  $ilDB = $DIC->database();
723 
724  if ($a_obj_type == "") {
725  $a_obj_type = "-";
726  }
727  $set = $ilDB->query(
728  "SELECT * FROM note_settings " .
729  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
730  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
731  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
732  );
733  if ($rec = $ilDB->fetchAssoc($set)) {
734  if (($rec["activated"] == 0 && $a_activate) ||
735  ($rec["activated"] == 1 && !$a_activate)) {
736  $ilDB->manipulate(
737  "UPDATE note_settings SET " .
738  " activated = " . $ilDB->quote((int) $a_activate, "integer") .
739  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
740  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
741  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
742  );
743  }
744  } else {
745  if ($a_activate) {
746  $q = "INSERT INTO note_settings " .
747  "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
748  $ilDB->quote((int) $a_rep_obj_id, "integer") . "," .
749  $ilDB->quote((int) $a_obj_id, "integer") . "," .
750  $ilDB->quote($a_obj_type, "text") . "," .
751  $ilDB->quote(1, "integer") .
752  ")";
753  $ilDB->manipulate($q);
754  }
755  }
756  }
757 
764  public static function commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
765  {
766  global $DIC;
767 
768  $ilDB = $DIC->database();
769 
770  if ($a_obj_type == "") {
771  $a_obj_type = "-";
772  }
773  $set = $ilDB->query(
774  "SELECT * FROM note_settings " .
775  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
776  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
777  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
778  );
779  $rec = $ilDB->fetchAssoc($set);
780  return $rec["activated"];
781  }
782 
789  public static function getRepObjActivation($a_rep_obj_ids)
790  {
791  global $DIC;
792 
793  $ilDB = $DIC->database();
794 
795  $set = $ilDB->query("SELECT * FROM note_settings " .
796  " WHERE " . $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer") .
797  " AND obj_id = 0 ");
798  $activations = array();
799  while ($rec = $ilDB->fetchAssoc($set)) {
800  if ($rec["activated"]) {
801  $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
802  }
803  }
804 
805  return $activations;
806  }
807 
808 
812  public function sendNotifications($a_changed = false)
813  {
815  $ilAccess = $this->access;
816 
817  // no notifications for notes
818  if ($this->getType() == IL_NOTE_PRIVATE) {
819  return;
820  }
821 
822  $recipients = $ilSetting->get("comments_noti_recip");
823  $recipients = explode(",", $recipients);
824 
825  // blog: blog_id, 0, "blog"
826  // lm: lm_id, page_id, "pg" (ok)
827  // sahs: sahs_id, node_id, node_type
828  // info_screen: obj_id, 0, obj_type (ok)
829  // portfolio: port_id, page_id, "portfolio_page" (ok)
830  // wiki: wiki_id, wiki_page_id, "wpg" (ok)
831 
832  $obj = $this->getObject();
833  $rep_obj_id = $obj["rep_obj_id"];
834  $sub_obj_id = $obj["obj_id"];
835  $type = $obj["obj_type"];
836 
837  include_once("./Services/Language/classes/class.ilLanguageFactory.php");
838  include_once("./Services/User/classes/class.ilUserUtil.php");
839  include_once("./Services/Mail/classes/class.ilMail.php");
840 
841  // repository objects, no blogs
842  $ref_ids = array();
843  if (($sub_obj_id == 0 and $type != "blp") ||
844  in_array($type, array("pg", "wpg"))) {
845  $obj_title = ilObject::_lookupTitle($rep_obj_id);
846  $type_lv = "obj_" . $type;
847  $ref_ids = ilObject::_getAllReferences($rep_obj_id);
848  }
849 
850  if ($type == "wpg") {
851  $type_lv = "obj_wiki";
852  }
853  if ($type == "pg") {
854  $type_lv = "obj_lm";
855  }
856  if ($type == "blp") {
857  $obj_title = ilObject::_lookupTitle($rep_obj_id);
858  $type_lv = "obj_blog";
859  }
860  if ($type == "pfpg") {
861  $obj_title = ilObject::_lookupTitle($rep_obj_id);
862  $type_lv = "portfolio";
863  }
864  if ($type == "dcl") {
865  $obj_title = ilObject::_lookupTitle($rep_obj_id);
866  $type_lv = "obj_dcl";
867  }
868 
869  include_once("./Services/Link/classes/class.ilLink.php");
870  foreach ($recipients as $r) {
871  $login = trim($r);
872  if (($user_id = ilObjUser::_lookupId($login)) > 0) {
873  $link = "";
874  foreach ($ref_ids as $r) {
875  if ($ilAccess->checkAccessOfUser($user_id, "read", "", $r)) {
876  if ($sub_obj_id == 0 and $type != "blog") {
877  $link = ilLink::_getLink($r);
878  } elseif ($type == "wpg") {
879  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
880  include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
881  $title = ilWikiPage::lookupTitle($sub_obj_id);
882  $link = ilLink::_getStaticLink(
883  $r,
884  "wiki",
885  true,
887  );
888  } elseif ($type == "pg") {
889  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=pg_" . $sub_obj_id . "_" . $r;
890  }
891  }
892  }
893  if ($type == "blp") {
894  // todo
895  }
896  if ($type == "pfpg") {
897  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=prtf_" . $rep_obj_id;
898  }
899 
900  // use language of recipient to compose message
901  $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
902  $ulng->loadLanguageModule('note');
903 
904  if ($a_changed) {
905  $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
906  } else {
907  $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
908  }
909  $message = sprintf($ulng->txt('note_comment_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
910 
911  $message.= sprintf($ulng->txt('note_comment_notification_user_has_written'), ilUserUtil::getNamePresentation($this->getAuthor())) . "\n\n";
912 
913  $message .= $this->getText() . "\n\n";
914 
915  if ($link != "") {
916  $message .= $ulng->txt('note_comment_notification_link') . ": " . $link . "\n\n";
917  }
918 
919  $message .= $ulng->txt('note_comment_notification_reason') . "\n\n";
920 
921  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
922  $mail_obj->appendInstallationSignature(true);
923  $mail_obj->sendMail(
924  ilObjUser::_lookupLogin($user_id),
925  "",
926  "",
927  $subject,
928  $message,
929  array(),
930  array("system")
931  );
932  }
933  }
934  }
935 }
static _lookupLogin($a_user_id)
lookup login
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
create($a_use_provided_creation_date=false)
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
$type
global $DIC
Definition: saml.php:7
setSubject($a_subject)
set subject
static _lookupUpdateDate($a_id)
lookup update date of note
getText()
get text
static _lookupFullname($a_user_id)
Lookup Full Name.
static _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id=null)
Get all notes related to a specific object.
setAllData($a_note_rec)
set all note data by record array
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupId($a_user_str)
Lookup id by login.
setCreationDate($a_date)
set creation date
static _lookupTitle($a_id)
lookup object title
setText($a_text)
set text
getUpdateDate()
get update date
static now()
Return current timestamp in Y-m-d H:i:s format.
sendNotifications($a_changed=false)
Send notifications.
setAuthor($a_user_id)
set author
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
Note class.
getAuthor()
get author
getLabel()
get label
$a_type
Definition: workflow.php:92
$r
Definition: example_031.php:79
catch(Exception $e) $message
static getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
How many users have attached a note/comment to a given object?
static _lookupCreationDate($a_id)
lookup creation date of note
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
This class handles base functions for mail handling.
getId()
get id
$text
Definition: errorreport.php:18
static getRepObjActivation($a_rep_obj_ids)
Get activation for repository objects.
$ilUser
Definition: imgupload.php:18
getSubject()
get subject
setLabel($a_label)
set label
static _getRelatedObjectsOfUser($a_mode)
get all related objects for user
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:
getType()
get type
getCreationDate()
get creation date
lookupNodeId($a_obj_id)
Get node id for object id.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
__construct($a_id=0)
constructor
static _getLanguageOfUser($a_usr_id)
Get language object of user.
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
settings()
Definition: settings.php:2
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
setId($a_id)
set id
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
global $ilSetting
Definition: privfeed.php:17
setInRepository($a_value)
set repository object status
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0)
set assigned object
global $ilDB
setType($a_type)
set type
setUpdateDate($a_date)
set update date
static _getLastNotesOfUser()
get last notes of current user
static _getNotesOfObject( $a_rep_obj_id, $a_obj_id, $a_obj_type, $a_type=IL_NOTE_PRIVATE, $a_incl_sub=false, $a_filter="", $a_all_public="y", $a_repository_mode=true, $a_sort_ascending=false)
get all notes related to a specific object
isInRepository()
belongs note to repository object?
static _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs=false)
Get all notes related to multiple objcts.