ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilNote Class Reference

Note class. More...

+ Collaboration diagram for ilNote:

Public Member Functions

 __construct ($a_id=0)
 constructor More...
 
 setId ($a_id)
 set id More...
 
 getId ()
 get id More...
 
 setObject ($a_obj_type, $a_rep_obj_id, $a_obj_id=0, $a_news_id=0)
 set assigned object More...
 
 getObject ()
 
 setType ($a_type)
 set type More...
 
 getType ()
 get type More...
 
 setAuthor ($a_user_id)
 set author More...
 
 getAuthor ()
 get author More...
 
 setText ($a_text)
 set text More...
 
 getText ()
 get text More...
 
 setSubject ($a_subject)
 set subject More...
 
 getSubject ()
 get subject More...
 
 setCreationDate ($a_date)
 set creation date More...
 
 getCreationDate ()
 get creation date More...
 
 setUpdateDate ($a_date)
 set update date More...
 
 getUpdateDate ()
 get update date More...
 
 setLabel ($a_label)
 set label More...
 
 getLabel ()
 get label More...
 
 setNewsId ($a_val)
 Set news id. More...
 
 getNewsId ()
 Get news id. More...
 
 setInRepository ($a_value)
 set repository object status More...
 
 isInRepository ()
 belongs note to repository object? More...
 
 create ($a_use_provided_creation_date=false)
 
 update ()
 
 read ()
 
 delete ()
 delete note More...
 
 setAllData ($a_note_rec)
 set all note data by record array More...
 
 sendNotifications ($a_changed=false)
 Send notifications. More...
 

Static Public Member Functions

static _lookupCreationDate ($a_id)
 lookup creation date of note More...
 
static _lookupUpdateDate ($a_id)
 lookup update date of note More...
 
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 More...
 
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 More...
 
static _getLastNotesOfUser ()
 get last notes of current user More...
 
static _getRelatedObjectsOfUser ($a_mode)
 get all related objects for user More...
 
static getUserCount ($a_rep_obj_id, $a_obj_id, $a_type)
 How many users have attached a note/comment to a given object? More...
 
static _countNotesAndCommentsMultiple ($a_rep_obj_ids, $a_no_sub_objs=false)
 Get all notes related to multiple objcts. More...
 
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. More...
 
static activateComments ($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
 Activate notes feature. More...
 
static commentsActivated ($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
 Are comments activated for object? More...
 
static getRepObjActivation ($a_rep_obj_ids)
 Get activation for repository objects. More...
 

Protected Attributes

 $db
 
 $settings
 
 $access
 
 $rep_obj_id = 0
 
 $obj_id
 
 $obj_type
 
 $news_id
 

Detailed Description

Note class.

Represents a single note.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 25 of file class.ilNote.php.

Constructor & Destructor Documentation

◆ __construct()

ilNote::__construct (   $a_id = 0)

constructor

Definition at line 74 of file class.ilNote.php.

References $DIC, read(), and settings().

75  {
76  global $DIC;
77 
78  $this->db = $DIC->database();
79  $this->settings = $DIC->settings();
80  $this->access = $DIC->access();
81  if ($a_id > 0) {
82  $this->id = $a_id;
83  $this->read();
84  }
85  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

Member Function Documentation

◆ _countNotesAndComments()

static ilNote::_countNotesAndComments (   $a_rep_obj_id,
  $a_sub_obj_id = null,
  $a_obj_type = "",
  $a_news_id = 0 
)
static

Get all notes related to a specific object.

Parameters
array$a_rep_obj_idsrepository object IDs array
int$a_sub_obj_idsub objects (if null, all comments are counted)

Definition at line 761 of file class.ilNote.php.

References $DIC, $ilDB, $ilUser, IL_NOTE_PRIVATE, and IL_NOTE_PUBLIC.

Referenced by ilNoteGUI\getCommentsWidget(), ilObjectListGUI\getHeaderAction(), and ilPollBlockGUI\getNumberOfComments().

766  {
767  global $DIC;
768 
769  $ilDB = $DIC->database();
770  $ilUser = $DIC->user();
771 
772  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
773  " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
774  "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
775  " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
776  " rep_obj_id = " . $ilDB->quote($a_rep_obj_id, "integer");
777 
778  if ($a_sub_obj_id !== null) {
779  $q .= " AND obj_id = " . $ilDB->quote($a_sub_obj_id, "integer");
780  $q .= " AND obj_type = " . $ilDB->quote($a_obj_type, "text");
781  }
782 
783  $q .= " AND news_id = " . $ilDB->quote($a_news_id, "integer");
784 
785  $q .= " GROUP BY rep_obj_id, type ";
786 
787  $cnt = array();
788  $set = $ilDB->query($q);
789  while ($rec = $ilDB->fetchAssoc($set)) {
790  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
791  }
792 
793  return $cnt;
794  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
global $DIC
Definition: saml.php:7
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ _countNotesAndCommentsMultiple()

static ilNote::_countNotesAndCommentsMultiple (   $a_rep_obj_ids,
  $a_no_sub_objs = false 
)
static

Get all notes related to multiple objcts.

Parameters
array$a_rep_obj_idsrepository object IDs array
boolean$a_no_sub_objsinclude subobjects true/false

Definition at line 727 of file class.ilNote.php.

References $DIC, $ilDB, $ilUser, IL_NOTE_PRIVATE, and IL_NOTE_PUBLIC.

Referenced by ilObjectListGUI\preloadCommonProperties().

728  {
729  global $DIC;
730 
731  $ilDB = $DIC->database();
732  $ilUser = $DIC->user();
733 
734  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
735  " ((type = " . $ilDB->quote(IL_NOTE_PRIVATE, "integer") . " AND " .
736  "author = " . $ilDB->quote((int) $ilUser->getId(), "integer") . ") OR " .
737  " type = " . $ilDB->quote(IL_NOTE_PUBLIC, "integer") . ") AND " .
738  $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
739 
740  if ($a_no_sub_objs) {
741  $q .= " AND obj_id = " . $ilDB->quote(0, "integer");
742  }
743 
744  $q .= " GROUP BY rep_obj_id, type ";
745 
746  $cnt = array();
747  $set = $ilDB->query($q);
748  while ($rec = $ilDB->fetchAssoc($set)) {
749  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
750  }
751 
752  return $cnt;
753  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
global $DIC
Definition: saml.php:7
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ _getAllNotesOfSingleRepObject()

static ilNote::_getAllNotesOfSingleRepObject (   $a_rep_obj_id,
  $a_type = IL_NOTE_PRIVATE,
  $a_incl_sub = false,
  $a_sort_ascending = false,
  $a_since = "" 
)
static

get all notes related to a single repository object

Definition at line 517 of file class.ilNote.php.

References $a_type, $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\load().

523  {
524  global $DIC;
525 
526  $ilDB = $DIC->database();
527 
528  $sub_where = (!$a_incl_sub)
529  ? " AND obj_id = " . $ilDB->quote((int) 0, "integer") : "";
530 
531  if ($a_since != "") {
532  $sub_where .= " AND creation_date > " . $ilDB->quote($a_since, "timestamp");
533  }
534 
535  $sub_where .= " AND no_repository = " . $ilDB->quote(0, "integer");
536 
537  $q = "SELECT * FROM note WHERE " .
538  " rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
539  $sub_where .
540  " AND type = " . $ilDB->quote((int) $a_type, "integer") .
541  " ORDER BY creation_date ";
542 
543  $q .= ((bool) $a_sort_ascending) ? "ASC" : "DESC";
544  $set = $ilDB->query($q);
545  $notes = array();
546  while ($note_rec = $ilDB->fetchAssoc($set)) {
547  $cnt = count($notes);
548  $notes[$cnt] = new ilNote();
549  $notes[$cnt]->setAllData($note_rec);
550  }
551  return $notes;
552  }
global $DIC
Definition: saml.php:7
Note class.
$a_type
Definition: workflow.php:92
global $ilDB
+ Here is the caller graph for this function:

◆ _getLastNotesOfUser()

static ilNote::_getLastNotesOfUser ( )
static

get last notes of current user

Definition at line 557 of file class.ilNote.php.

References $DIC, $ilDB, $ilUser, and IL_NOTE_PRIVATE.

Referenced by ilPDNotesBlockGUI\fillDataSection().

558  {
559  global $DIC;
560 
561  $ilDB = $DIC->database();
562  $ilUser = $DIC->user();
563 
564  $q = "SELECT * FROM note WHERE " .
565  " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
566  " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer") .
567  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
568  " ORDER BY creation_date DESC";
569 
570  $ilDB->quote($q);
571  $set = $ilDB->query($q);
572  $notes = array();
573  while ($note_rec = $ilDB->fetchAssoc($set)) {
574  $cnt = count($notes);
575  $notes[$cnt] = new ilNote();
576  $notes[$cnt]->setAllData($note_rec);
577  }
578 
579  return $notes;
580  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
global $DIC
Definition: saml.php:7
Note class.
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ _getNotesOfObject()

static ilNote::_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 
)
static

get all notes related to a specific object

Definition at line 453 of file class.ilNote.php.

References $a_type, $DIC, $ilDB, $ilUser, and IL_NOTE_PRIVATE.

Referenced by ilDclBaseRecordModel\getComments(), ilNoteGUI\getNoteListHTML(), ilDclBaseRecordModel\getStandardFieldPlainText(), ilObjBlogGUI\renderList(), and ilQuestionBrowserTableGUI\setQuestionData().

464  {
465  global $DIC;
466 
467  $ilDB = $DIC->database();
468  $ilUser = $DIC->user();
469 
470  $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
471  ? " AND author = " . $ilDB->quote((int) $ilUser->getId(), "integer")
472  : "";
473 
474  $sub_where = (!$a_incl_sub)
475  ? " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
476  " AND obj_type = " . $ilDB->quote((string) $a_obj_type, "text")
477  : "";
478 
479  $news_where =
480  " AND news_id = " . $ilDB->quote((int) $a_news_id, "integer");
481 
482 
483  $sub_where .= " AND no_repository = " . $ilDB->quote(!$a_repository_mode, "integer");
484 
485  $q = "SELECT * FROM note WHERE " .
486  " rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
487  $sub_where .
488  " AND type = " . $ilDB->quote((int) $a_type, "integer") .
489  $author_where .
490  $news_where .
491  " ORDER BY creation_date ";
492 
493  $q .= ((bool) $a_sort_ascending) ? "ASC" : "DESC";
494 
495  $set = $ilDB->query($q);
496  $notes = array();
497  while ($note_rec = $ilDB->fetchAssoc($set)) {
498  if ($a_filter != "") {
499  if (!is_array($a_filter)) {
500  $a_filter = array($a_filter);
501  }
502  if (!in_array($note_rec["id"], $a_filter)) {
503  continue;
504  }
505  }
506  $cnt = count($notes);
507  $notes[$cnt] = new ilNote();
508  $notes[$cnt]->setAllData($note_rec);
509  }
510 
511  return $notes;
512  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
global $DIC
Definition: saml.php:7
Note class.
$a_type
Definition: workflow.php:92
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ _getRelatedObjectsOfUser()

static ilNote::_getRelatedObjectsOfUser (   $a_mode)
static

get all related objects for user

Definition at line 585 of file class.ilNote.php.

References $DIC, $ilDB, $ilUser, $r, $tree, $type, ilObject\_getAllReferences(), ilObjUser\_lookupDesktopItems(), ilObject\_lookupType(), commentsActivated(), IL_NOTE_PRIVATE, IL_NOTE_PUBLIC, ilWorkspaceTree\lookupNodeId(), and ilPDNotesGUI\PRIVATE_NOTES.

Referenced by ilPDNotesGUI\view().

586  {
587  global $DIC;
588 
589  $ilDB = $DIC->database();
590  $ilUser = $DIC->user();
591  $tree = $DIC->repositoryTree();
592 
593  if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES) {
594  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
595  " type = " . $ilDB->quote((int) IL_NOTE_PRIVATE, "integer") .
596  " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
597  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
598  " ORDER BY rep_obj_id";
599 
600  $ilDB->quote($q);
601  $set = $ilDB->query($q);
602  $reps = array();
603  while ($rep_rec = $ilDB->fetchAssoc($set)) {
604  // #9343: deleted objects
605  if (ilObject::_lookupType($rep_rec["rep_obj_id"])) {
606  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
607  }
608  }
609  } else {
610  // all objects where the user wrote at least one comment
611  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
612  " type = " . $ilDB->quote((int) IL_NOTE_PUBLIC, "integer") .
613  " AND author = " . $ilDB->quote($ilUser->getId(), "integer") .
614  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")" .
615  " ORDER BY rep_obj_id";
616 
617  $set = $ilDB->query($q);
618  $reps = array();
619  while ($rep_rec = $ilDB->fetchAssoc($set)) {
620  // #9343: deleted objects
621  if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"])) {
622  if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type)) {
623  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
624  }
625  }
626  }
627 
628  // additionally all objects on the personal desktop of the user
629  // that have at least on comment
630  $dis = ilObjUser::_lookupDesktopItems($ilUser->getId());
631  $obj_ids = array();
632  foreach ($dis as $di) {
633  $obj_ids[] = $di["obj_id"];
634  }
635  if (count($obj_ids) > 0) {
636  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE " .
637  $ilDB->in("rep_obj_id", $obj_ids, false, "integer") .
638  " AND (no_repository IS NULL OR no_repository < " . $ilDB->quote(1, "integer") . ")";
639 
640  $set = $ilDB->query($q);
641  while ($rec = $ilDB->fetchAssoc($set)) {
642  $add = true;
643  reset($reps);
644  foreach ($reps as $r) {
645  if ($r["rep_obj_id"] == $rec["rep_obj_id"]) {
646  $add = false;
647  }
648  }
649  if ($add) {
650  $type = ilObject::_lookupType($rec["rep_obj_id"]);
651  if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type)) {
652  $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
653  }
654  }
655  }
656  }
657  }
658 
659  if (sizeof($reps)) {
660  // check if notes/comments belong to objects in trash
661  // see ilNoteGUI::showTargets()
662  foreach ($reps as $idx => $rep) {
663  $has_active_ref = false;
664 
665  // repository?
666  $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
667  if ($ref_ids) {
668  $reps[$idx]["ref_ids"] = array_values($ref_ids);
669 
670  foreach ($ref_ids as $ref_id) {
671  if (!$tree->isDeleted($ref_id)) {
672  $has_active_ref = true;
673  break;
674  }
675  }
676  } else {
677  // personal workspace?
678  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
679  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
680  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
681  $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
682  if ($node_id) {
683  $reps[$idx]["wsp_id"] = $node_id;
684 
685  $has_active_ref = true;
686  }
687  }
688 
689  if (!$has_active_ref) {
690  unset($reps[$idx]);
691  }
692  }
693  }
694 
695  return $reps;
696  }
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
$type
global $DIC
Definition: saml.php:7
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
$r
Definition: example_031.php:79
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
$ilUser
Definition: imgupload.php:18
lookupNodeId($a_obj_id)
Get node id for object id.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupCreationDate()

static ilNote::_lookupCreationDate (   $a_id)
static

lookup creation date of note

Definition at line 419 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by create().

420  {
421  global $DIC;
422 
423  $ilDB = $DIC->database();
424 
425  $q = "SELECT * FROM note WHERE id = " .
426  $ilDB->quote((int) $a_id, "integer");
427  $set = $ilDB->query($q);
428  $note_rec = $ilDB->fetchAssoc($set);
429 
430  return $note_rec["creation_date"];
431  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ _lookupUpdateDate()

static ilNote::_lookupUpdateDate (   $a_id)
static

lookup update date of note

Definition at line 436 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by update().

437  {
438  global $DIC;
439 
440  $ilDB = $DIC->database();
441 
442  $q = "SELECT * FROM note WHERE id = " .
443  $ilDB->quote((int) $a_id, "integer");
444  $set = $ilDB->query($q);
445  $note_rec = $ilDB->fetchAssoc($set);
446 
447  return $note_rec["update_date"];
448  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ activateComments()

static ilNote::activateComments (   $a_rep_obj_id,
  $a_obj_id,
  $a_obj_type,
  $a_activate = true 
)
static

Activate notes feature.

Parameters

Definition at line 802 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by ilNoteGUI\activateComments(), ilObjContentObject\createProperties(), ilNoteGUI\deactivateComments(), ilObjBlog\doCreate(), ilObjBlog\doUpdate(), ilObjPortfolioBase\doUpdate(), ilObjPoll\doUpdate(), ilLearningModuleDataSet\importRecord(), and ilObjContentObject\updateProperties().

803  {
804  global $DIC;
805 
806  $ilDB = $DIC->database();
807 
808  if ($a_obj_type == "") {
809  $a_obj_type = "-";
810  }
811  $set = $ilDB->query(
812  "SELECT * FROM note_settings " .
813  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
814  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
815  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
816  );
817  if ($rec = $ilDB->fetchAssoc($set)) {
818  if (($rec["activated"] == 0 && $a_activate) ||
819  ($rec["activated"] == 1 && !$a_activate)) {
820  $ilDB->manipulate(
821  "UPDATE note_settings SET " .
822  " activated = " . $ilDB->quote((int) $a_activate, "integer") .
823  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
824  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
825  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
826  );
827  }
828  } else {
829  if ($a_activate) {
830  $q = "INSERT INTO note_settings " .
831  "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
832  $ilDB->quote((int) $a_rep_obj_id, "integer") . "," .
833  $ilDB->quote((int) $a_obj_id, "integer") . "," .
834  $ilDB->quote($a_obj_type, "text") . "," .
835  $ilDB->quote(1, "integer") .
836  ")";
837  $ilDB->manipulate($q);
838  }
839  }
840  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ commentsActivated()

static ilNote::commentsActivated (   $a_rep_obj_id,
  $a_obj_id,
  $a_obj_type,
  $a_news_id = 0 
)
static

Are comments activated for object?

Parameters

Definition at line 848 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by ilNoteGUI\__construct(), _getRelatedObjectsOfUser(), ilObjBlog\doRead(), ilObjPortfolioBase\doRead(), ilObjPoll\doRead(), ilNoteGUI\getNotesHTML(), ilPortfolioDataSet\getXmlRecord(), ilPollDataSet\getXmlRecord(), ilBlogDataSet\getXmlRecord(), ilObjectGUI\initHeaderAction(), ilObjectListGUI\isCommentsActivated(), ilLearningModuleDataSet\readData(), and ilObjContentObject\readProperties().

849  {
850  global $DIC;
851 
852  $ilDB = $DIC->database();
853 
854  if ($a_news_id > 0) {
855  return true;
856  }
857 
858  if ($a_obj_type == "") {
859  $a_obj_type = "-";
860  }
861  $set = $ilDB->query(
862  "SELECT * FROM note_settings " .
863  " WHERE rep_obj_id = " . $ilDB->quote((int) $a_rep_obj_id, "integer") .
864  " AND obj_id = " . $ilDB->quote((int) $a_obj_id, "integer") .
865  " AND obj_type = " . $ilDB->quote($a_obj_type, "text")
866  );
867  $rec = $ilDB->fetchAssoc($set);
868  return $rec["activated"];
869  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ create()

ilNote::create (   $a_use_provided_creation_date = false)

Definition at line 316 of file class.ilNote.php.

References $db, $ilDB, _lookupCreationDate(), getCreationDate(), getId(), ilUtil\now(), and sendNotifications().

317  {
318  $ilDB = $this->db;
319 
320  $cd = ($a_use_provided_creation_date)
321  ? $this->getCreationDate()
322  : ilUtil::now();
323 
324  $this->id = $ilDB->nextId("note");
325 
326  $ilDB->insert("note", array(
327  "id" => array("integer", $this->id),
328  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
329  "obj_id" => array("integer", (int) $this->obj_id),
330  "obj_type" => array("text", (string) $this->obj_type),
331  "news_id" => array("integer", (int) $this->news_id),
332  "type" => array("integer", (int) $this->type),
333  "author" => array("integer", (int) $this->author),
334  "note_text" => array("clob", (string) $this->text),
335  "subject" => array("text", (string) $this->subject),
336  "label" => array("integer", (int) $this->label),
337  "creation_date" => array("timestamp", $cd),
338  "no_repository" => array("integer", $this->no_repository)
339  ));
340 
341  $this->sendNotifications();
342 
343  $this->creation_date = ilNote::_lookupCreationDate($this->getId());
344  }
static now()
Return current timestamp in Y-m-d H:i:s format.
sendNotifications($a_changed=false)
Send notifications.
static _lookupCreationDate($a_id)
lookup creation date of note
getId()
get id
getCreationDate()
get creation date
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilNote::delete ( )

delete note

Definition at line 385 of file class.ilNote.php.

References $db, $ilDB, and getId().

386  {
387  $ilDB = $this->db;
388 
389  $q = "DELETE FROM note WHERE id = " .
390  $ilDB->quote((int) $this->getId(), "integer");
391  $ilDB->manipulate($q);
392  }
getId()
get id
global $ilDB
+ Here is the call graph for this function:

◆ getAuthor()

ilNote::getAuthor ( )

get author

Returns
int user id

Definition at line 169 of file class.ilNote.php.

Referenced by sendNotifications().

170  {
171  return $this->author;
172  }
+ Here is the caller graph for this function:

◆ getCreationDate()

ilNote::getCreationDate ( )

get creation date

Returns
string creation date

Definition at line 229 of file class.ilNote.php.

Referenced by create().

230  {
231  return $this->creation_date;
232  }
+ Here is the caller graph for this function:

◆ getId()

ilNote::getId ( )

get id

Returns
int note id

Definition at line 102 of file class.ilNote.php.

References $id.

Referenced by create(), delete(), read(), and update().

103  {
104  return $this->id;
105  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the caller graph for this function:

◆ getLabel()

ilNote::getLabel ( )

get label

Returns
int IL_NOTE_UNLABELED | IL_NOTE_IMPORTANT | IL_NOTE_QUESTION | IL_NOTE_PRO | IL_NOTE_CONTRA

Definition at line 271 of file class.ilNote.php.

272  {
273  return $this->label;
274  }

◆ getNewsId()

ilNote::getNewsId ( )

Get news id.

Returns
int news id

Definition at line 291 of file class.ilNote.php.

References $news_id.

292  {
293  return $this->news_id;
294  }

◆ getObject()

ilNote::getObject ( )

Definition at line 123 of file class.ilNote.php.

Referenced by sendNotifications().

124  {
125  // note: any changes here will currently influence
126  // the parameters of all observers!
127  return array("rep_obj_id" => $this->rep_obj_id,
128  "obj_id" => $this->obj_id,
129  "obj_type" => $this->obj_type,
130  "news_id" => $this->news_id);
131  }
+ Here is the caller graph for this function:

◆ getRepObjActivation()

static ilNote::getRepObjActivation (   $a_rep_obj_ids)
static

Get activation for repository objects.

Parameters

Definition at line 877 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by ilObjectListGUI\preloadCommonProperties().

878  {
879  global $DIC;
880 
881  $ilDB = $DIC->database();
882 
883  $set = $ilDB->query("SELECT * FROM note_settings " .
884  " WHERE " . $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer") .
885  " AND obj_id = 0 ");
886  $activations = array();
887  while ($rec = $ilDB->fetchAssoc($set)) {
888  if ($rec["activated"]) {
889  $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
890  }
891  }
892 
893  return $activations;
894  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getSubject()

ilNote::getSubject ( )

get subject

Returns
string subject

Definition at line 209 of file class.ilNote.php.

210  {
211  return $this->subject;
212  }

◆ getText()

ilNote::getText ( )

get text

Returns
string text

Definition at line 189 of file class.ilNote.php.

References $text.

Referenced by sendNotifications().

190  {
191  return $this->text;
192  }
$text
Definition: errorreport.php:18
+ Here is the caller graph for this function:

◆ getType()

ilNote::getType ( )

get type

Returns
int IL_NOTE_PUBLIC | IL_NOTE_PRIVATE

Definition at line 149 of file class.ilNote.php.

References $type.

Referenced by sendNotifications().

150  {
151  return $this->type;
152  }
$type
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNote::getUpdateDate ( )

get update date

Returns
string update date

Definition at line 249 of file class.ilNote.php.

250  {
251  return $this->update_date;
252  }

◆ getUserCount()

static ilNote::getUserCount (   $a_rep_obj_id,
  $a_obj_id,
  $a_type 
)
static

How many users have attached a note/comment to a given object?

Parameters
int$a_rep_obj_idobject id (as in object data)
int$a_obj_id(sub) object id
string$a_type(sub) object type

Definition at line 705 of file class.ilNote.php.

References $a_type, $DIC, and $ilDB.

Referenced by ilBlogPostingGUI\deleteBlogPostingConfirmationScreen(), and ilWikiPageGUI\deleteWikiPageConfirmationScreen().

706  {
707  global $DIC;
708 
709  $ilDB = $DIC->database();
710 
711  $set = $ilDB->queryF(
712  "SELECT count(DISTINCT author) cnt FROM note WHERE " .
713  "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
714  array("integer", "integer", "text"),
715  array((int) $a_rep_obj_id, (int) $a_obj_id, (string) $a_type)
716  );
717  $rec = $ilDB->fetchAssoc($set);
718  return (int) $rec["cnt"];
719  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
global $ilDB
+ Here is the caller graph for this function:

◆ isInRepository()

ilNote::isInRepository ( )

belongs note to repository object?

Returns
bool

Definition at line 311 of file class.ilNote.php.

312  {
313  return !$this->no_repository;
314  }

◆ read()

ilNote::read ( )

Definition at line 371 of file class.ilNote.php.

References $db, $ilDB, getId(), and setAllData().

Referenced by __construct().

372  {
373  $ilDB = $this->db;
374 
375  $q = "SELECT * FROM note WHERE id = " .
376  $ilDB->quote((int) $this->getId(), "integer");
377  $set = $ilDB->query($q);
378  $note_rec = $ilDB->fetchAssoc($set);
379  $this->setAllData($note_rec);
380  }
setAllData($a_note_rec)
set all note data by record array
getId()
get id
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNotifications()

ilNote::sendNotifications (   $a_changed = false)

Send notifications.

Definition at line 900 of file class.ilNote.php.

References $access, $ilSetting, $login, $message, $r, $rep_obj_id, $settings, $title, $type, ilObject\_getAllReferences(), ilLanguageFactory\_getLanguageOfUser(), ilLink\_getLink(), ilLink\_getStaticLink(), ilObjUser\_lookupFullname(), ilObjUser\_lookupId(), ilObjUser\_lookupLogin(), ilObject\_lookupTitle(), getAuthor(), ilUserUtil\getNamePresentation(), getObject(), getText(), getType(), IL_NOTE_PRIVATE, ilWikiPage\lookupTitle(), and ilWikiUtil\makeUrlTitle().

Referenced by create(), and update().

901  {
903  $ilAccess = $this->access;
904 
905  // no notifications for notes
906  if ($this->getType() == IL_NOTE_PRIVATE) {
907  return;
908  }
909 
910  $recipients = $ilSetting->get("comments_noti_recip");
911  $recipients = explode(",", $recipients);
912 
913  // blog: blog_id, 0, "blog"
914  // lm: lm_id, page_id, "pg" (ok)
915  // sahs: sahs_id, node_id, node_type
916  // info_screen: obj_id, 0, obj_type (ok)
917  // portfolio: port_id, page_id, "portfolio_page" (ok)
918  // wiki: wiki_id, wiki_page_id, "wpg" (ok)
919 
920  $obj = $this->getObject();
921  $rep_obj_id = $obj["rep_obj_id"];
922  $sub_obj_id = $obj["obj_id"];
923  $type = $obj["obj_type"];
924 
925  include_once("./Services/Language/classes/class.ilLanguageFactory.php");
926  include_once("./Services/User/classes/class.ilUserUtil.php");
927  include_once("./Services/Mail/classes/class.ilMail.php");
928 
929  // repository objects, no blogs
930  $ref_ids = array();
931  if (($sub_obj_id == 0 and $type != "blp") ||
932  in_array($type, array("pg", "wpg"))) {
933  $obj_title = ilObject::_lookupTitle($rep_obj_id);
934  $type_lv = "obj_" . $type;
936  }
937 
938  if ($type == "wpg") {
939  $type_lv = "obj_wiki";
940  }
941  if ($type == "pg") {
942  $type_lv = "obj_lm";
943  }
944  if ($type == "blp") {
945  $obj_title = ilObject::_lookupTitle($rep_obj_id);
946  $type_lv = "obj_blog";
947  }
948  if ($type == "pfpg") {
949  $obj_title = ilObject::_lookupTitle($rep_obj_id);
950  $type_lv = "portfolio";
951  }
952  if ($type == "dcl") {
953  $obj_title = ilObject::_lookupTitle($rep_obj_id);
954  $type_lv = "obj_dcl";
955  }
956 
957  include_once("./Services/Link/classes/class.ilLink.php");
958  foreach ($recipients as $r) {
959  $login = trim($r);
960  if (($user_id = ilObjUser::_lookupId($login)) > 0) {
961  $link = "";
962  foreach ($ref_ids as $r) {
963  if ($ilAccess->checkAccessOfUser($user_id, "read", "", $r)) {
964  if ($sub_obj_id == 0 and $type != "blog") {
965  $link = ilLink::_getLink($r);
966  } elseif ($type == "wpg") {
967  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
968  include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
969  $title = ilWikiPage::lookupTitle($sub_obj_id);
970  $link = ilLink::_getStaticLink(
971  $r,
972  "wiki",
973  true,
975  );
976  } elseif ($type == "pg") {
977  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=pg_" . $sub_obj_id . "_" . $r;
978  }
979  }
980  }
981  if ($type == "blp") {
982  // todo
983  }
984  if ($type == "pfpg") {
985  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=prtf_" . $rep_obj_id;
986  }
987 
988  // use language of recipient to compose message
989  $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
990  $ulng->loadLanguageModule('note');
991 
992  if ($a_changed) {
993  $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
994  } else {
995  $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
996  }
997  $message = sprintf($ulng->txt('note_comment_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
998 
999  $message .= sprintf($ulng->txt('note_comment_notification_user_has_written'), ilUserUtil::getNamePresentation($this->getAuthor())) . "\n\n";
1000 
1001  $message .= $this->getText() . "\n\n";
1002 
1003  if ($link != "") {
1004  $message .= $ulng->txt('note_comment_notification_link') . ": " . $link . "\n\n";
1005  }
1006 
1007  $message .= $ulng->txt('note_comment_notification_reason') . "\n\n";
1008 
1009  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
1010  $mail_obj->appendInstallationSignature(true);
1011  $mail_obj->sendMail(
1012  ilObjUser::_lookupLogin($user_id),
1013  "",
1014  "",
1015  $subject,
1016  $message,
1017  array(),
1018  array("system")
1019  );
1020  }
1021  }
1022  }
static _lookupLogin($a_user_id)
lookup login
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
$type
getText()
get text
static _lookupFullname($a_user_id)
Lookup Full Name.
static _lookupId($a_user_str)
Lookup id by login.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
getAuthor()
get author
$r
Definition: example_031.php:79
catch(Exception $e) $message
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
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
static _getLanguageOfUser($a_usr_id)
Get language object of user.
global $ilSetting
Definition: privfeed.php:17
$login
Definition: cron.php:13
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAllData()

ilNote::setAllData (   $a_note_rec)

set all note data by record array

Definition at line 397 of file class.ilNote.php.

References setAuthor(), setCreationDate(), setId(), setInRepository(), setLabel(), setObject(), setSubject(), setText(), setType(), and setUpdateDate().

Referenced by read().

398  {
399  $this->setId($a_note_rec["id"]);
400  $this->setObject(
401  $a_note_rec["obj_type"],
402  $a_note_rec["rep_obj_id"],
403  $a_note_rec["obj_id"],
404  $a_note_rec["news_id"]
405  );
406  $this->setType($a_note_rec["type"]);
407  $this->setAuthor($a_note_rec["author"]);
408  $this->setText($a_note_rec["note_text"]);
409  $this->setSubject($a_note_rec["subject"]);
410  $this->setLabel($a_note_rec["label"]);
411  $this->setCreationDate($a_note_rec["creation_date"]);
412  $this->setUpdateDate($a_note_rec["update_date"]);
413  $this->setInRepository(!(bool) $a_note_rec["no_repository"]);
414  }
setSubject($a_subject)
set subject
setCreationDate($a_date)
set creation date
setText($a_text)
set text
setAuthor($a_user_id)
set author
setLabel($a_label)
set label
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0, $a_news_id=0)
set assigned object
setId($a_id)
set id
setInRepository($a_value)
set repository object status
setType($a_type)
set type
setUpdateDate($a_date)
set update date
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAuthor()

ilNote::setAuthor (   $a_user_id)

set author

Parameters
intauthor user id

Definition at line 159 of file class.ilNote.php.

Referenced by setAllData().

160  {
161  $this->author = $a_user_id;
162  }
+ Here is the caller graph for this function:

◆ setCreationDate()

ilNote::setCreationDate (   $a_date)

set creation date

Parameters
stringcreation date

Definition at line 219 of file class.ilNote.php.

Referenced by setAllData().

220  {
221  $this->creation_date = $a_date;
222  }
+ Here is the caller graph for this function:

◆ setId()

ilNote::setId (   $a_id)

set id

Parameters
intnote id

Definition at line 92 of file class.ilNote.php.

Referenced by setAllData().

93  {
94  $this->id = $a_id;
95  }
+ Here is the caller graph for this function:

◆ setInRepository()

ilNote::setInRepository (   $a_value)

set repository object status

Parameters
bool

Definition at line 301 of file class.ilNote.php.

Referenced by setAllData().

302  {
303  return $this->no_repository = !(bool) $a_value;
304  }
+ Here is the caller graph for this function:

◆ setLabel()

ilNote::setLabel (   $a_label)

set label

Parameters
intIL_NOTE_UNLABELED | IL_NOTE_IMPORTANT | IL_NOTE_QUESTION | IL_NOTE_PRO | IL_NOTE_CONTRA

Definition at line 260 of file class.ilNote.php.

Referenced by setAllData().

261  {
262  return $this->label = $a_label;
263  }
+ Here is the caller graph for this function:

◆ setNewsId()

ilNote::setNewsId (   $a_val)

Set news id.

Parameters
int$a_valnews id

Definition at line 281 of file class.ilNote.php.

282  {
283  $this->news_id = $a_val;
284  }

◆ setObject()

ilNote::setObject (   $a_obj_type,
  $a_rep_obj_id,
  $a_obj_id = 0,
  $a_news_id = 0 
)

set assigned object

Parameters
string$a_obj_type
int$a_rep_obj_id
int$a_obj_id
int$a_news_id

Definition at line 115 of file class.ilNote.php.

Referenced by setAllData().

116  {
117  $this->rep_obj_id = $a_rep_obj_id;
118  $this->obj_id = $a_obj_id;
119  $this->obj_type = $a_obj_type;
120  $this->news_id = $a_news_id;
121  }
+ Here is the caller graph for this function:

◆ setSubject()

ilNote::setSubject (   $a_subject)

set subject

Parameters
stringtext

Definition at line 199 of file class.ilNote.php.

Referenced by setAllData().

200  {
201  $this->subject = $a_subject;
202  }
+ Here is the caller graph for this function:

◆ setText()

ilNote::setText (   $a_text)

set text

Parameters
stringtext

Definition at line 179 of file class.ilNote.php.

Referenced by setAllData().

180  {
181  $this->text = $a_text;
182  }
+ Here is the caller graph for this function:

◆ setType()

ilNote::setType (   $a_type)

set type

Parameters
intIL_NOTE_PUBLIC | IL_NOTE_PRIVATE

Definition at line 139 of file class.ilNote.php.

References $a_type.

Referenced by setAllData().

140  {
141  $this->type = $a_type;
142  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ setUpdateDate()

ilNote::setUpdateDate (   $a_date)

set update date

Parameters
stringupdate date

Definition at line 239 of file class.ilNote.php.

Referenced by setAllData().

240  {
241  $this->update_date = $a_date;
242  }
+ Here is the caller graph for this function:

◆ update()

ilNote::update ( )

Definition at line 346 of file class.ilNote.php.

References $db, $ilDB, _lookupUpdateDate(), getId(), ilUtil\now(), and sendNotifications().

347  {
348  $ilDB = $this->db;
349 
350  $ilDB->update("note", array(
351  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
352  "obj_id" => array("integer", (int) $this->obj_id),
353  "news_id" => array("integer", (int) $this->news_id),
354  "obj_type" => array("text", (string) $this->obj_type),
355  "type" => array("integer", (int) $this->type),
356  "author" => array("integer", (int) $this->author),
357  "note_text" => array("clob", (string) $this->text),
358  "subject" => array("text", (string) $this->subject),
359  "label" => array("integer", (int) $this->label),
360  "update_date" => array("timestamp", ilUtil::now()),
361  "no_repository" => array("integer", $this->no_repository)
362  ), array(
363  "id" => array("integer", $this->getId())
364  ));
365 
366  $this->update_date = ilNote::_lookupUpdateDate($this->getId());
367 
368  $this->sendNotifications(true);
369  }
static _lookupUpdateDate($a_id)
lookup update date of note
static now()
Return current timestamp in Y-m-d H:i:s format.
sendNotifications($a_changed=false)
Send notifications.
getId()
get id
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilNote::$access
protected

Definition at line 40 of file class.ilNote.php.

Referenced by sendNotifications().

◆ $db

ilNote::$db
protected

Definition at line 30 of file class.ilNote.php.

Referenced by create(), delete(), read(), and update().

◆ $news_id

ilNote::$news_id
protected

Definition at line 68 of file class.ilNote.php.

Referenced by getNewsId().

◆ $obj_id

ilNote::$obj_id
protected

Definition at line 56 of file class.ilNote.php.

◆ $obj_type

ilNote::$obj_type
protected

Definition at line 63 of file class.ilNote.php.

◆ $rep_obj_id

ilNote::$rep_obj_id = 0
protected

Definition at line 48 of file class.ilNote.php.

Referenced by sendNotifications().

◆ $settings

ilNote::$settings
protected

Definition at line 35 of file class.ilNote.php.

Referenced by sendNotifications().


The documentation for this class was generated from the following file: