ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 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...
 
 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)
 get all notes related to a specific 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)
 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)
 Are comments activated for object? More...
 
static getRepObjActivation ($a_rep_obj_ids)
 Get activation for repository objects. More...
 

Protected Attributes

 $db
 
 $settings
 
 $access
 

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

Constructor & Destructor Documentation

◆ __construct()

ilNote::__construct (   $a_id = 0)

constructor

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

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

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  }
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ _countNotesAndComments()

static ilNote::_countNotesAndComments (   $a_rep_obj_id,
  $a_sub_obj_id = null 
)
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 684 of file class.ilNote.php.

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

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

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
global $DIC
Definition: saml.php:7
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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 650 of file class.ilNote.php.

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

Referenced by ilObjectListGUI\preloadCommonProperties().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
global $DIC
Definition: saml.php:7
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _getLastNotesOfUser()

static ilNote::_getLastNotesOfUser ( )
static

get last notes of current user

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

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

Referenced by ilPDNotesBlockGUI\fillDataSection().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
global $DIC
Definition: saml.php:7
Note class.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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 
)
static

get all notes related to a specific object

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

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

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

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
global $DIC
Definition: saml.php:7
Note class.
$a_type
Definition: workflow.php:92
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
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 508 of file class.ilNote.php.

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

Referenced by ilPDNotesGUI\view().

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  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
$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:5
$ilUser
Definition: imgupload.php:18
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
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type)
Are comments activated for object?
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 386 of file class.ilNote.php.

References $DIC, and $ilDB.

Referenced by create().

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

References $DIC, and $ilDB.

Referenced by update().

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  }
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 718 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().

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  }
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 
)
static

Are comments activated for object?

Parameters

Definition at line 764 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().

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

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

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  }
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
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilNote::delete ( )

delete note

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

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

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

Referenced by sendNotifications().

139  {
140  return $this->author;
141  }
+ Here is the caller graph for this function:

◆ getCreationDate()

ilNote::getCreationDate ( )

get creation date

Returns
string creation date

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

Referenced by create().

199  {
200  return $this->creation_date;
201  }
+ Here is the caller graph for this function:

◆ getId()

ilNote::getId ( )

get id

Returns
int note id

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

References $id.

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

74  {
75  return $this->id;
76  }
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 240 of file class.ilNote.php.

241  {
242  return $this->label;
243  }

◆ getObject()

ilNote::getObject ( )

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

References array.

Referenced by sendNotifications().

96  {
97  return array("rep_obj_id" => $this->rep_obj_id,
98  "obj_id" => $this->obj_id,
99  "obj_type" => $this->obj_type);
100  }
Create styles array
The data for the language used.
+ 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 789 of file class.ilNote.php.

References $DIC, $ilDB, and array.

Referenced by ilObjectListGUI\preloadCommonProperties().

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  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getSubject()

ilNote::getSubject ( )

get subject

Returns
string subject

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

179  {
180  return $this->subject;
181  }

◆ getText()

ilNote::getText ( )

get text

Returns
string text

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

References $text.

Referenced by sendNotifications().

159  {
160  return $this->text;
161  }
$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 118 of file class.ilNote.php.

References $type.

Referenced by sendNotifications().

119  {
120  return $this->type;
121  }
$type
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNote::getUpdateDate ( )

get update date

Returns
string update date

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

219  {
220  return $this->update_date;
221  }

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

References $a_type, $DIC, $ilDB, and array.

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

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  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ isInRepository()

ilNote::isInRepository ( )

belongs note to repository object?

Returns
bool

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

261  {
262  return !$this->no_repository;
263  }

◆ read()

ilNote::read ( )

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

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

Referenced by __construct().

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

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

Referenced by create(), and update().

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  }
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:4
$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.
This class handles base functions for mail handling.
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
Create styles array
The data for the language used.
static _getLanguageOfUser($a_usr_id)
Get language object of user.
global $ilSetting
Definition: privfeed.php:17
+ 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 369 of file class.ilNote.php.

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

Referenced by read().

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  }
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
setId($a_id)
set id
setInRepository($a_value)
set repository object status
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0)
set assigned object
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 128 of file class.ilNote.php.

Referenced by setAllData().

129  {
130  $this->author = $a_user_id;
131  }
+ Here is the caller graph for this function:

◆ setCreationDate()

ilNote::setCreationDate (   $a_date)

set creation date

Parameters
stringcreation date

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

Referenced by setAllData().

189  {
190  $this->creation_date = $a_date;
191  }
+ Here is the caller graph for this function:

◆ setId()

ilNote::setId (   $a_id)

set id

Parameters
intnote id

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

Referenced by setAllData().

64  {
65  $this->id = $a_id;
66  }
+ Here is the caller graph for this function:

◆ setInRepository()

ilNote::setInRepository (   $a_value)

set repository object status

Parameters
bool

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

Referenced by setAllData().

251  {
252  return $this->no_repository = !(bool) $a_value;
253  }
+ 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 229 of file class.ilNote.php.

Referenced by setAllData().

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

◆ setObject()

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

set assigned object

Parameters
$a_typestring type of the object (e.g st,pg,crs ...)
$a_rep_obj_idint object id (NOT ref_id!) of repository object (e.g for page objects the obj_id of the learning module; for personal desktop this is set to 0)
$a_obj_idint object id (e.g for page objects the obj_id of the page object) for, this is set to 0 for normal repository objects like forums ...

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

Referenced by setAllData().

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

◆ setSubject()

ilNote::setSubject (   $a_subject)

set subject

Parameters
stringtext

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

Referenced by setAllData().

169  {
170  $this->subject = $a_subject;
171  }
+ Here is the caller graph for this function:

◆ setText()

ilNote::setText (   $a_text)

set text

Parameters
stringtext

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

Referenced by setAllData().

149  {
150  $this->text = $a_text;
151  }
+ 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 108 of file class.ilNote.php.

References $a_type.

Referenced by setAllData().

109  {
110  $this->type = $a_type;
111  }
$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 208 of file class.ilNote.php.

Referenced by setAllData().

209  {
210  $this->update_date = $a_date;
211  }
+ Here is the caller graph for this function:

◆ update()

ilNote::update ( )

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

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

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  }
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
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilNote::$access
protected

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

Referenced by sendNotifications().

◆ $db

ilNote::$db
protected

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

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

◆ $settings

ilNote::$settings
protected

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

Referenced by sendNotifications().


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