ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
 $no_repository = 0
 

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 79 of file class.ilNote.php.

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

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  }
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46
+ 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 768 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().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 734 of file class.ilNote.php.

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

Referenced by ilObjectListGUI\preloadCommonProperties().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:6
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 522 of file class.ilNote.php.

References $a_type, $DIC, and $ilDB.

Referenced by ilMembershipCronNotificationsData\load().

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  }
Note class.
$a_type
Definition: workflow.php:92
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _getLastNotesOfUser()

static ilNote::_getLastNotesOfUser ( )
static

get last notes of current user

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

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

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
Note class.
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46

◆ _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 458 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().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:5
Note class.
$a_type
Definition: workflow.php:92
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _getRelatedObjectsOfUser()

static ilNote::_getRelatedObjectsOfUser (   $a_mode)
static

get all related objects for user

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

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

Referenced by ilPDNotesGUI\view().

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  }
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
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
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
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 424 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by create().

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  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ _lookupUpdateDate()

static ilNote::_lookupUpdateDate (   $a_id)
static

lookup update date of note

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

References $DIC, and $ilDB.

Referenced by update().

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  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 809 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().

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  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ 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 855 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().

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  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ create()

ilNote::create (   $a_use_provided_creation_date = false)

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

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

322  {
323  $ilDB = $this->db;
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  }
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 390 of file class.ilNote.php.

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

391  {
392  $ilDB = $this->db;
393 
394  $q = "DELETE FROM note WHERE id = " .
395  $ilDB->quote((int) $this->getId(), "integer");
396  $ilDB->manipulate($q);
397  }
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 174 of file class.ilNote.php.

Referenced by sendNotifications().

175  {
176  return $this->author;
177  }
+ Here is the caller graph for this function:

◆ getCreationDate()

ilNote::getCreationDate ( )

get creation date

Returns
string creation date

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

Referenced by create().

235  {
236  return $this->creation_date;
237  }
+ Here is the caller graph for this function:

◆ getId()

ilNote::getId ( )

get id

Returns
int note id

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

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

108  {
109  return $this->id;
110  }
+ 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 276 of file class.ilNote.php.

277  {
278  return $this->label;
279  }

◆ getNewsId()

ilNote::getNewsId ( )

Get news id.

Returns
int news id

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

References $news_id.

297  {
298  return $this->news_id;
299  }

◆ getObject()

ilNote::getObject ( )

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

Referenced by sendNotifications().

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  }
+ 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 884 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by ilObjectListGUI\preloadCommonProperties().

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  }
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getSubject()

ilNote::getSubject ( )

get subject

Returns
string subject

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

215  {
216  return $this->subject;
217  }

◆ getText()

ilNote::getText ( )

get text

Returns
string text

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

Referenced by sendNotifications().

195  {
196  return $this->text;
197  }
+ Here is the caller graph for this function:

◆ getType()

ilNote::getType ( )

get type

Returns
int IL_NOTE_PUBLIC | IL_NOTE_PRIVATE

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

References $type.

Referenced by sendNotifications().

155  {
156  return $this->type;
157  }
$type
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNote::getUpdateDate ( )

get update date

Returns
string update date

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

255  {
256  return $this->update_date;
257  }

◆ 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 712 of file class.ilNote.php.

References $a_type, $DIC, and $ilDB.

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

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  }
$a_type
Definition: workflow.php:92
global $ilDB
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ isInRepository()

ilNote::isInRepository ( )

belongs note to repository object?

Returns
bool

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

References $no_repository.

317  {
318  return !$this->no_repository;
319  }

◆ read()

ilNote::read ( )

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

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

Referenced by __construct().

377  {
378  $ilDB = $this->db;
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  }
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 907 of file class.ilNote.php.

References $access, $ilSetting, $login, $message, $rep_obj_id, $settings, $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, ILIAS_HTTP_PATH, ilWikiPage\lookupTitle(), and ilWikiUtil\makeUrlTitle().

Referenced by create(), and update().

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"))) {
940  $obj_title = ilObject::_lookupTitle($rep_obj_id);
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") {
952  $obj_title = ilObject::_lookupTitle($rep_obj_id);
953  $type_lv = "obj_blog";
954  }
955  if ($type == "pfpg") {
956  $obj_title = ilObject::_lookupTitle($rep_obj_id);
957  $type_lv = "portfolio";
958  }
959  if ($type == "dcl") {
960  $obj_title = ilObject::_lookupTitle($rep_obj_id);
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);
977  $link = ilLink::_getStaticLink(
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
996  $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
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  }
static _lookupLogin($a_user_id)
lookup login
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
$login
Definition: cron.php:13
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
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
$message
Definition: xapiexit.php:14
+ 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 402 of file class.ilNote.php.

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

Referenced by read().

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  }
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 164 of file class.ilNote.php.

Referenced by setAllData().

165  {
166  $this->author = $a_user_id;
167  }
+ Here is the caller graph for this function:

◆ setCreationDate()

ilNote::setCreationDate (   $a_date)

set creation date

Parameters
stringcreation date

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

Referenced by setAllData().

225  {
226  $this->creation_date = $a_date;
227  }
+ Here is the caller graph for this function:

◆ setId()

ilNote::setId (   $a_id)

set id

Parameters
intnote id

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

Referenced by setAllData().

98  {
99  $this->id = $a_id;
100  }
+ Here is the caller graph for this function:

◆ setInRepository()

ilNote::setInRepository (   $a_value)

set repository object status

Parameters
bool

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

Referenced by setAllData().

307  {
308  return $this->no_repository = !(bool) $a_value;
309  }
+ 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 265 of file class.ilNote.php.

Referenced by setAllData().

266  {
267  return $this->label = $a_label;
268  }
+ Here is the caller graph for this function:

◆ setNewsId()

ilNote::setNewsId (   $a_val)

Set news id.

Parameters
int$a_valnews id

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

287  {
288  $this->news_id = $a_val;
289  }

◆ 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 120 of file class.ilNote.php.

Referenced by setAllData().

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  }
+ Here is the caller graph for this function:

◆ setSubject()

ilNote::setSubject (   $a_subject)

set subject

Parameters
stringtext

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

Referenced by setAllData().

205  {
206  $this->subject = $a_subject;
207  }
+ Here is the caller graph for this function:

◆ setText()

ilNote::setText (   $a_text)

set text

Parameters
stringtext

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

Referenced by setAllData().

185  {
186  $this->text = $a_text;
187  }
+ 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 144 of file class.ilNote.php.

References $a_type.

Referenced by setAllData().

145  {
146  $this->type = $a_type;
147  }
$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 244 of file class.ilNote.php.

Referenced by setAllData().

245  {
246  $this->update_date = $a_date;
247  }
+ Here is the caller graph for this function:

◆ update()

ilNote::update ( )

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

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

352  {
353  $ilDB = $this->db;
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  }
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().

◆ $no_repository

ilNote::$no_repository = 0
protected

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

Referenced by isInRepository().

◆ $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: