ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

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

References read().

31  {
32  if ($a_id > 0)
33  {
34  $this->id = $a_id;
35  $this->read();
36  }
37  }
+ 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 669 of file class.ilNote.php.

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

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

670  {
671  global $ilDB, $ilUser;
672 
673  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
674  " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
675  "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
676  " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
677  " rep_obj_id = ".$ilDB->quote($a_rep_obj_id, "integer");
678 
679  if ($a_sub_obj_id !== null)
680  {
681  $q .= " AND obj_id = ".$ilDB->quote($a_sub_obj_id, "integer");
682  }
683 
684  $q .= " GROUP BY rep_obj_id, type ";
685 
686  $cnt = array();
687  $set = $ilDB->query($q);
688  while ($rec = $ilDB->fetchAssoc($set))
689  {
690  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
691  }
692 
693  return $cnt;
694  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
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 636 of file class.ilNote.php.

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

Referenced by ilObjectListGUI\preloadCommonProperties().

637  {
638  global $ilDB, $ilUser;
639 
640  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
641  " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
642  "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
643  " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
644  $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
645 
646  if ($a_no_sub_objs)
647  {
648  $q .= " AND obj_id = ".$ilDB->quote(0, "integer");
649  }
650 
651  $q .= " GROUP BY rep_obj_id, type ";
652 
653  $cnt = array();
654  $set = $ilDB->query($q);
655  while ($rec = $ilDB->fetchAssoc($set))
656  {
657  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
658  }
659 
660  return $cnt;
661  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
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 452 of file class.ilNote.php.

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

Referenced by ilPDNotesBlockGUI\fillDataSection().

453  {
454  global $ilDB, $ilUser;
455 
456  $q = "SELECT * FROM note WHERE ".
457  " type = ".$ilDB->quote((int) IL_NOTE_PRIVATE, "integer").
458  " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer").
459  " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
460  " ORDER BY creation_date DESC";
461 
462  $ilDB->quote($q);
463  $set = $ilDB->query($q);
464  $notes = array();
465  while($note_rec = $ilDB->fetchAssoc($set))
466  {
467  $cnt = count($notes);
468  $notes[$cnt] = new ilNote();
469  $notes[$cnt]->setAllData($note_rec);
470  }
471 
472  return $notes;
473  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
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 397 of file class.ilNote.php.

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

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

400  {
401  global $ilDB, $ilUser;
402 
403  $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
404  ? " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer")
405  : "";
406 
407  $sub_where = (!$a_incl_sub)
408  ? " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
409  " AND obj_type = ".$ilDB->quote((string) $a_obj_type, "text")
410  : "";
411 
412  if(!$a_repository_mode)
413  {
414  $sub_where .= " AND no_repository = ".$ilDB->quote(1, "integer");
415  }
416 
417  $q = "SELECT * FROM note WHERE ".
418  " rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
419  $sub_where.
420  " AND type = ".$ilDB->quote((int) $a_type, "integer").
421  $author_where.
422  " ORDER BY creation_date ";
423 
424  $q .= ((bool)$a_sort_ascending) ? "ASC" : "DESC";
425 
426  $set = $ilDB->query($q);
427  $notes = array();
428  while($note_rec = $ilDB->fetchAssoc($set))
429  {
430  if ($a_filter != "")
431  {
432  if (!is_array($a_filter))
433  {
434  $a_filter = array($a_filter);
435  }
436  if (!in_array($note_rec["id"], $a_filter))
437  {
438  continue;
439  }
440  }
441  $cnt = count($notes);
442  $notes[$cnt] = new ilNote();
443  $notes[$cnt]->setAllData($note_rec);
444  }
445 
446  return $notes;
447  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
Note class.
$a_type
Definition: workflow.php:93
$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 478 of file class.ilNote.php.

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

Referenced by ilPDNotesGUI\view().

479  {
480  global $ilDB, $ilUser, $tree;
481 
482  if ($a_mode == ilPDNotesGUI::PRIVATE_NOTES)
483  {
484  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
485  " type = ".$ilDB->quote((int) IL_NOTE_PRIVATE, "integer").
486  " AND author = ".$ilDB->quote($ilUser->getId(), "integer").
487  " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
488  " ORDER BY rep_obj_id";
489 
490  $ilDB->quote($q);
491  $set = $ilDB->query($q);
492  $reps = array();
493  while($rep_rec = $ilDB->fetchAssoc($set))
494  {
495  // #9343: deleted objects
496  if(ilObject::_lookupType($rep_rec["rep_obj_id"]))
497  {
498  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
499  }
500  }
501  }
502  else
503  {
504  // all objects where the user wrote at least one comment
505  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
506  " type = ".$ilDB->quote((int) IL_NOTE_PUBLIC, "integer").
507  " AND author = ".$ilDB->quote($ilUser->getId(), "integer").
508  " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
509  " ORDER BY rep_obj_id";
510 
511  $set = $ilDB->query($q);
512  $reps = array();
513  while($rep_rec = $ilDB->fetchAssoc($set))
514  {
515  // #9343: deleted objects
516  if ($type = ilObject::_lookupType($rep_rec["rep_obj_id"]))
517  {
518  if (ilNote::commentsActivated($rep_rec["rep_obj_id"], "", $type))
519  {
520  $reps[] = array("rep_obj_id" => $rep_rec["rep_obj_id"]);
521  }
522  }
523  }
524 
525  // additionally all objects on the personal desktop of the user
526  // that have at least on comment
527  $dis = ilObjUser::_lookupDesktopItems($ilUser->getId());
528  $obj_ids = array();
529  foreach($dis as $di)
530  {
531  $obj_ids[] = $di["obj_id"];
532  }
533  if (count($obj_ids) > 0)
534  {
535  $q = "SELECT DISTINCT rep_obj_id FROM note WHERE ".
536  $ilDB->in("rep_obj_id", $obj_ids, false, "integer").
537  " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")";
538 
539  $set = $ilDB->query($q);
540  while($rec = $ilDB->fetchAssoc($set))
541  {
542  $add = true;
543  reset($reps);
544  foreach ($reps as $r)
545  {
546  if ($r["rep_obj_id"] == $rec["rep_obj_id"])
547  {
548  $add = false;
549  }
550  }
551  if ($add)
552  {
553  $type = ilObject::_lookupType($rec["rep_obj_id"]);
554  if (ilNote::commentsActivated($rec["rep_obj_id"], "", $type))
555  {
556  $reps[] = array("rep_obj_id" => $rec["rep_obj_id"]);
557  }
558  }
559  }
560  }
561  }
562 
563  if(sizeof($reps))
564  {
565  // check if notes/comments belong to objects in trash
566  // see ilNoteGUI::showTargets()
567  foreach($reps as $idx => $rep)
568  {
569  $has_active_ref = false;
570 
571  // repository?
572  $ref_ids = ilObject::_getAllReferences($rep["rep_obj_id"]);
573  if($ref_ids)
574  {
575  $reps[$idx]["ref_ids"] = array_values($ref_ids);
576 
577  foreach($ref_ids as $ref_id)
578  {
579  if(!$tree->isDeleted($ref_id))
580  {
581  $has_active_ref = true;
582  break;
583  }
584  }
585  }
586  else
587  {
588  // personal workspace?
589  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
590  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
591  $wsp_tree = new ilWorkspaceTree($ilUser->getId());
592  $node_id = $wsp_tree->lookupNodeId($rep["rep_obj_id"]);
593  if($node_id)
594  {
595  $reps[$idx]["wsp_id"] = $node_id;
596 
597  $has_active_ref = true;
598  }
599  }
600 
601  if(!$has_active_ref)
602  {
603  unset($reps[$idx]);
604  }
605  }
606  }
607 
608  return $reps;
609  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
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?
$ref_id
Definition: sahs_server.php:39
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 367 of file class.ilNote.php.

References $ilDB.

Referenced by create().

368  {
369  global $ilDB;
370 
371  $q = "SELECT * FROM note WHERE id = ".
372  $ilDB->quote((int) $a_id, "integer");
373  $set = $ilDB->query($q);
374  $note_rec = $ilDB->fetchAssoc($set);
375 
376  return $note_rec["creation_date"];
377  }
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 382 of file class.ilNote.php.

References $ilDB.

Referenced by update().

383  {
384  global $ilDB;
385 
386  $q = "SELECT * FROM note WHERE id = ".
387  $ilDB->quote((int) $a_id, "integer");
388  $set = $ilDB->query($q);
389  $note_rec = $ilDB->fetchAssoc($set);
390 
391  return $note_rec["update_date"];
392  }
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 702 of file class.ilNote.php.

References $ilDB.

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

703  {
704  global $ilDB;
705 
706  if ($a_obj_type == "")
707  {
708  $a_obj_type = "-";
709  }
710  $set = $ilDB->query("SELECT * FROM note_settings ".
711  " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
712  " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
713  " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
714  );
715  if ($rec = $ilDB->fetchAssoc($set))
716  {
717  if (($rec["activated"] == 0 && $a_activate) ||
718  ($rec["activated"] == 1 && !$a_activate))
719  {
720  $ilDB->manipulate("UPDATE note_settings SET ".
721  " activated = ".$ilDB->quote((int) $a_activate, "integer").
722  " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
723  " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
724  " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
725  );
726  }
727  }
728  else
729  {
730  if ($a_activate)
731  {
732  $q = "INSERT INTO note_settings ".
733  "(rep_obj_id, obj_id, obj_type, activated) VALUES (".
734  $ilDB->quote((int) $a_rep_obj_id, "integer").",".
735  $ilDB->quote((int) $a_obj_id, "integer").",".
736  $ilDB->quote($a_obj_type, "text").",".
737  $ilDB->quote(1, "integer").
738  ")";
739  $ilDB->manipulate($q);
740  }
741  }
742  }
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 750 of file class.ilNote.php.

References $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().

751  {
752  global $ilDB;
753 
754  if ($a_obj_type == "")
755  {
756  $a_obj_type = "-";
757  }
758  $set = $ilDB->query("SELECT * FROM note_settings ".
759  " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
760  " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
761  " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
762  );
763  $rec = $ilDB->fetchAssoc($set);
764  return $rec["activated"];
765  }
global $ilDB
+ Here is the caller graph for this function:

◆ create()

ilNote::create (   $a_use_provided_creation_date = false)

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

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

247  {
248  global $ilDB;
249 
250  $cd = ($a_use_provided_creation_date)
251  ? $this->getCreationDate()
252  : ilUtil::now();
253 
254  $this->id = $ilDB->nextId("note");
255  /*$q = "INSERT INTO note (id, rep_obj_id, obj_id, obj_type, type,".
256  "author, note_text, subject, label, creation_date) VALUES (".
257  $ilDB->quote($this->id, "integer").",".
258  $ilDB->quote((int) $this->rep_obj_id, "integer").",".
259  $ilDB->quote((int) $this->obj_id, "integer").",".
260  $ilDB->quote((string) $this->obj_type, "text").",".
261  $ilDB->quote((int) $this->type, "integer").",".
262  $ilDB->quote((int) $this->author, "integer").",".
263  $ilDB->quote((string) $this->text, "clob").",".
264  $ilDB->quote((string) $this->subject, "text").",".
265  $ilDB->quote((int) $this->label, "integer").",".
266  $ilDB->now().")";
267  $ilDB->manipulate($q);*/
268 
269  $ilDB->insert("note", array(
270  "id" => array("integer", $this->id),
271  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
272  "obj_id" => array("integer", (int) $this->obj_id),
273  "obj_type" => array("text", (string) $this->obj_type),
274  "type" => array("integer", (int) $this->type),
275  "author" => array("integer", (int) $this->author),
276  "note_text" => array("clob", (string) $this->text),
277  "subject" => array("text", (string) $this->subject),
278  "label" => array("integer", (int) $this->label),
279  "creation_date" => array("timestamp", $cd),
280  "no_repository" => array("integer", $this->no_repository)
281  ));
282 
283  $this->sendNotifications();
284 
285  $this->creation_date = ilNote::_lookupCreationDate($this->getId());
286  }
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 338 of file class.ilNote.php.

References $ilDB, and getId().

339  {
340  global $ilDB;
341 
342  $q = "DELETE FROM note WHERE id = ".
343  $ilDB->quote((int) $this->getId(), "integer");
344  $ilDB->manipulate($q);
345  }
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 119 of file class.ilNote.php.

Referenced by sendNotifications().

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

◆ getCreationDate()

ilNote::getCreationDate ( )

get creation date

Returns
string creation date

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

Referenced by create().

180  {
181  return $this->creation_date;
182  }
+ Here is the caller graph for this function:

◆ getId()

ilNote::getId ( )

get id

Returns
int note id

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

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

55  {
56  return $this->id;
57  }
+ 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 221 of file class.ilNote.php.

222  {
223  return $this->label;
224  }

◆ getObject()

ilNote::getObject ( )

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

References array.

Referenced by sendNotifications().

77  {
78  return array("rep_obj_id" => $this->rep_obj_id,
79  "obj_id" => $this->obj_id,
80  "obj_type" => $this->obj_type);
81  }
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 773 of file class.ilNote.php.

References $ilDB, and array.

Referenced by ilObjectListGUI\preloadCommonProperties().

774  {
775  global $ilDB;
776 
777  $set = $ilDB->query("SELECT * FROM note_settings ".
778  " WHERE ".$ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer").
779  " AND obj_id = 0 ");
780  $activations = array();
781  while ($rec = $ilDB->fetchAssoc($set))
782  {
783  if ($rec["activated"])
784  {
785  $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
786  }
787  }
788 
789  return $activations;
790  }
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 159 of file class.ilNote.php.

160  {
161  return $this->subject;
162  }

◆ getText()

ilNote::getText ( )

get text

Returns
string text

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

References $text.

Referenced by sendNotifications().

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

◆ getType()

ilNote::getType ( )

get type

Returns
int IL_NOTE_PUBLIC | IL_NOTE_PRIVATE

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

Referenced by sendNotifications().

100  {
101  return $this->type;
102  }
+ Here is the caller graph for this function:

◆ getUpdateDate()

ilNote::getUpdateDate ( )

get update date

Returns
string update date

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

200  {
201  return $this->update_date;
202  }

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

References $a_type, $ilDB, and array.

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

619  {
620  global $ilDB;
621 
622  $set = $ilDB->queryF("SELECT count(DISTINCT author) cnt FROM note WHERE ".
623  "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
624  array("integer", "integer", "text"),
625  array((int) $a_rep_obj_id, (int) $a_obj_id, (string)$a_type));
626  $rec = $ilDB->fetchAssoc($set);
627  return (int) $rec["cnt"];
628  }
$a_type
Definition: workflow.php:93
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 241 of file class.ilNote.php.

242  {
243  return !$this->no_repository;
244  }

◆ read()

ilNote::read ( )

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

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

Referenced by __construct().

325  {
326  global $ilDB;
327 
328  $q = "SELECT * FROM note WHERE id = ".
329  $ilDB->quote((int) $this->getId(), "integer");
330  $set = $ilDB->query($q);
331  $note_rec = $ilDB->fetchAssoc($set);
332  $this->setAllData($note_rec);
333  }
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 796 of file class.ilNote.php.

References $ilSetting, $r, $title, 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().

797  {
798  global $ilSetting, $ilAccess;
799 
800  // no notifications for notes
801  if ($this->getType() == IL_NOTE_PRIVATE)
802  {
803  return;
804  }
805 
806  $recipients = $ilSetting->get("comments_noti_recip");
807  $recipients = explode(",", $recipients);
808 
809  // blog: blog_id, 0, "blog"
810  // lm: lm_id, page_id, "pg" (ok)
811  // sahs: sahs_id, node_id, node_type
812  // info_screen: obj_id, 0, obj_type (ok)
813  // portfolio: port_id, page_id, "portfolio_page" (ok)
814  // wiki: wiki_id, wiki_page_id, "wpg" (ok)
815 
816  $obj = $this->getObject();
817  $rep_obj_id = $obj["rep_obj_id"];
818  $sub_obj_id = $obj["obj_id"];
819  $type = $obj["obj_type"];
820 
821  include_once("./Services/Language/classes/class.ilLanguageFactory.php");
822  include_once("./Services/User/classes/class.ilUserUtil.php");
823  include_once("./Services/Mail/classes/class.ilMail.php");
824 
825  // repository objects, no blogs
826  $ref_ids = array();
827  if (($sub_obj_id == 0 and $type != "blp") ||
828  in_array($type, array("pg", "wpg")))
829  {
830  $obj_title = ilObject::_lookupTitle($rep_obj_id);
831  $type_lv = "obj_".$type;
832  $ref_ids = ilObject::_getAllReferences($rep_obj_id);
833  }
834 
835  if ($type == "wpg")
836  {
837  $type_lv = "obj_wiki";
838  }
839  if ($type == "pg")
840  {
841  $type_lv = "obj_lm";
842  }
843  if ($type == "blp")
844  {
845  $obj_title = ilObject::_lookupTitle($rep_obj_id);
846  $type_lv = "obj_blog";
847  }
848  if ($type == "pfpg")
849  {
850  $obj_title = ilObject::_lookupTitle($rep_obj_id);
851  $type_lv = "portfolio";
852  }
853  if ($type == "dcl")
854  {
855  $obj_title = ilObject::_lookupTitle($rep_obj_id);
856  $type_lv = "obj_dcl";
857  }
858 
859  include_once("./Services/Link/classes/class.ilLink.php");
860  foreach($recipients as $r)
861  {
862  $login = trim($r);
863  if (($user_id = ilObjUser::_lookupId($login)) > 0)
864  {
865  $link = "";
866  foreach ($ref_ids as $r)
867  {
868  if ($ilAccess->checkAccessOfUser($user_id, "read", "", $r))
869  {
870  if ($sub_obj_id == 0 and $type != "blog")
871  {
872  $link = ilLink::_getLink($r);
873  }
874  else if ($type == "wpg")
875  {
876  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
877  include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
878  $title = ilWikiPage::lookupTitle($sub_obj_id);
879  $link = ilLink::_getStaticLink($r, "wiki",
880  true, "_".ilWikiUtil::makeUrlTitle($title));
881  }
882  else if ($type == "pg")
883  {
884  $link = ILIAS_HTTP_PATH.'/goto.php?client_id='.CLIENT_ID."&target=pg_".$sub_obj_id."_".$r;
885  }
886  }
887  }
888  if ($type == "blp")
889  {
890  // todo
891  }
892  if ($type == "pfpg")
893  {
894  $link = ILIAS_HTTP_PATH.'/goto.php?client_id='.CLIENT_ID."&target=prtf_".$rep_obj_id;
895  }
896 
897  // use language of recipient to compose message
898  $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
899  $ulng->loadLanguageModule('note');
900 
901  if ($a_changed)
902  {
903  $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title." (".$ulng->txt($type_lv).")");
904  }
905  else
906  {
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  {
917  $message .= $ulng->txt('note_comment_notification_link').": ".$link."\n\n";
918  }
919 
920  $message .= $ulng->txt('note_comment_notification_reason')."\n\n";
921 
922  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
923  $mail_obj->appendInstallationSignature(true);
924  $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id),
925  "", "", $subject, $message, array(), array("system"));
926  }
927  }
928 
929  }
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
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 getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false)
Default behaviour is:
$r
Definition: example_031.php:79
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
This class handles base functions for mail handling.
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 350 of file class.ilNote.php.

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

Referenced by read().

351  {
352  $this->setId($a_note_rec["id"]);
353  $this->setObject($a_note_rec["obj_type"], $a_note_rec["rep_obj_id"], $a_note_rec["obj_id"]);
354  $this->setType($a_note_rec["type"]);
355  $this->setAuthor($a_note_rec["author"]);
356  $this->setText($a_note_rec["note_text"]);
357  $this->setSubject($a_note_rec["subject"]);
358  $this->setLabel($a_note_rec["label"]);
359  $this->setCreationDate($a_note_rec["creation_date"]);
360  $this->setUpdateDate($a_note_rec["update_date"]);
361  $this->setInRepository(!(bool)$a_note_rec["no_repository"]);
362  }
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 109 of file class.ilNote.php.

Referenced by setAllData().

110  {
111  $this->author = $a_user_id;
112  }
+ Here is the caller graph for this function:

◆ setCreationDate()

ilNote::setCreationDate (   $a_date)

set creation date

Parameters
stringcreation date

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

Referenced by setAllData().

170  {
171  $this->creation_date = $a_date;
172  }
+ Here is the caller graph for this function:

◆ setId()

ilNote::setId (   $a_id)

set id

Parameters
intnote id

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

Referenced by setAllData().

45  {
46  $this->id = $a_id;
47  }
+ Here is the caller graph for this function:

◆ setInRepository()

ilNote::setInRepository (   $a_value)

set repository object status

Parameters
bool

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

Referenced by setAllData().

232  {
233  return $this->no_repository = !(bool)$a_value;
234  }
+ 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 210 of file class.ilNote.php.

Referenced by setAllData().

211  {
212  return $this->label = $a_label;
213  }
+ 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 69 of file class.ilNote.php.

Referenced by setAllData().

70  {
71  $this->rep_obj_id = $a_rep_obj_id;
72  $this->obj_id = $a_obj_id;
73  $this->obj_type = $a_obj_type;
74  }
+ Here is the caller graph for this function:

◆ setSubject()

ilNote::setSubject (   $a_subject)

set subject

Parameters
stringtext

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

Referenced by setAllData().

150  {
151  $this->subject = $a_subject;
152  }
+ Here is the caller graph for this function:

◆ setText()

ilNote::setText (   $a_text)

set text

Parameters
stringtext

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

Referenced by setAllData().

130  {
131  $this->text = $a_text;
132  }
+ 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 89 of file class.ilNote.php.

References $a_type.

Referenced by setAllData().

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

◆ setUpdateDate()

ilNote::setUpdateDate (   $a_date)

set update date

Parameters
stringupdate date

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

Referenced by setAllData().

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

◆ update()

ilNote::update ( )

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

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

289  {
290  global $ilDB;
291 
292  /*$q = "UPDATE note SET ".
293  "rep_obj_id = ".$ilDB->quote((int) $this->rep_obj_id, "integer").",".
294  "obj_id = ".$ilDB->quote((int) $this->obj_id, "integer").",".
295  "obj_type = ".$ilDB->quote((string) $this->obj_type, "text").",".
296  "type = ".$ilDB->quote((int) $this->type, "integer").",".
297  "author = ".$ilDB->quote((int) $this->author,"integer").",".
298  "note_text = ".$ilDB->quote((string) $this->text, "clob").",".
299  "subject = ".$ilDB->quote((string) $this->subject, "text").",".
300  "update_date = ".$ilDB->now().",".
301  "label = ".$ilDB->quote((int) $this->label, "integer").
302  "WHERE id =".$ilDB->quote((int) $this->getId(), "integer");
303  $ilDB->manipulate($q);*/
304  $ilDB->update("note", array(
305  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
306  "obj_id" => array("integer", (int) $this->obj_id),
307  "obj_type" => array("text", (string) $this->obj_type),
308  "type" => array("integer", (int) $this->type),
309  "author" => array("integer", (int) $this->author),
310  "note_text" => array("clob", (string) $this->text),
311  "subject" => array("text", (string) $this->subject),
312  "label" => array("integer", (int) $this->label),
313  "update_date" => array("timestamp", ilUtil::now()),
314  "no_repository" => array("integer", $this->no_repository)
315  ), array(
316  "id" => array("integer", $this->getId())
317  ));
318 
319  $this->update_date = ilNote::_lookupUpdateDate($this->getId());
320 
321  $this->sendNotifications(true);
322  }
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:

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