ILIAS  release_4-4 Revision
ilNote Class Reference

Note class. More...

+ Collaboration diagram for ilNote:

Public Member Functions

 ilNote ($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...
 
 _lookupCreationDate ($a_id)
 lookup creation date of note More...
 
 _lookupUpdateDate ($a_id)
 lookup update date of note More...
 
 _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)
 get all notes related to a specific object More...
 
 _getLastNotesOfUser ()
 get last notes of current user More...
 
 _getRelatedObjectsOfUser ($a_mode)
 get all related objects for user More...
 

Static Public Member Functions

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.

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

References $ilUser, IL_NOTE_PRIVATE, and IL_NOTE_PUBLIC.

Referenced by ilObjectListGUI\getHeaderAction().

660  {
661  global $ilDB, $ilUser;
662 
663  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
664  " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
665  "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
666  " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
667  " rep_obj_id = ".$ilDB->quote($a_rep_obj_id, "integer");
668 
669  if ($a_sub_obj_id !== null)
670  {
671  $q .= " AND obj_id = ".$ilDB->quote($a_sub_obj_id, "integer");
672  }
673 
674  $q .= " GROUP BY rep_obj_id, type ";
675 
676  $cnt = array();
677  $set = $ilDB->query($q);
678  while ($rec = $ilDB->fetchAssoc($set))
679  {
680  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
681  }
682 
683  return $cnt;
684  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
global $ilUser
Definition: imgupload.php:15
+ 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 626 of file class.ilNote.php.

References $ilUser, IL_NOTE_PRIVATE, and IL_NOTE_PUBLIC.

Referenced by ilObjectListGUI\preloadCommonProperties().

627  {
628  global $ilDB, $ilUser;
629 
630  $q = "SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
631  " ((type = ".$ilDB->quote(IL_NOTE_PRIVATE, "integer")." AND ".
632  "author = ".$ilDB->quote((int) $ilUser->getId(), "integer").") OR ".
633  " type = ".$ilDB->quote(IL_NOTE_PUBLIC, "integer").") AND ".
634  $ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer");
635 
636  if ($a_no_sub_objs)
637  {
638  $q .= " AND obj_id = ".$ilDB->quote(0, "integer");
639  }
640 
641  $q .= " GROUP BY rep_obj_id, type ";
642 
643  $cnt = array();
644  $set = $ilDB->query($q);
645  while ($rec = $ilDB->fetchAssoc($set))
646  {
647  $cnt[$rec["rep_obj_id"]][$rec["type"]] = $rec["c"];
648  }
649 
650  return $cnt;
651  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
const IL_NOTE_PUBLIC
Definition: class.ilNote.php:5
global $ilUser
Definition: imgupload.php:15
+ Here is the caller graph for this function:

◆ _getLastNotesOfUser()

ilNote::_getLastNotesOfUser ( )

get last notes of current user

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

References $ilUser, IL_NOTE_PRIVATE, and ilNote().

Referenced by ilPDNotesBlockGUI\fillDataSection().

447  {
448  global $ilDB, $ilUser;
449 
450  $q = "SELECT * FROM note WHERE ".
451  " type = ".$ilDB->quote((int) IL_NOTE_PRIVATE, "integer").
452  " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer").
453  " AND (no_repository IS NULL OR no_repository < ".$ilDB->quote(1, "integer").")".
454  " ORDER BY creation_date DESC";
455 
456  $ilDB->quote($q);
457  $set = $ilDB->query($q);
458  $notes = array();
459  while($note_rec = $ilDB->fetchAssoc($set))
460  {
461  $cnt = count($notes);
462  $notes[$cnt] = new ilNote();
463  $notes[$cnt]->setAllData($note_rec);
464  }
465 
466  return $notes;
467  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
ilNote($a_id=0)
constructor
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getNotesOfObject()

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 
)

get all notes related to a specific object

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

References $ilUser, IL_NOTE_PRIVATE, and ilNote().

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

396  {
397  global $ilDB, $ilUser;
398 
399  $author_where = ($a_type == IL_NOTE_PRIVATE || $a_all_public == "n")
400  ? " AND author = ".$ilDB->quote((int) $ilUser->getId(), "integer")
401  : "";
402 
403  $sub_where = (!$a_incl_sub)
404  ? " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
405  " AND obj_type = ".$ilDB->quote((string) $a_obj_type, "text")
406  : "";
407 
408  if(!$a_repository_mode)
409  {
410  $sub_where .= " AND no_repository = ".$ilDB->quote(1, "integer");
411  }
412 
413  $q = "SELECT * FROM note WHERE ".
414  " rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
415  $sub_where.
416  " AND type = ".$ilDB->quote((int) $a_type, "integer").
417  $author_where.
418  " ORDER BY creation_date DESC";
419 
420  $set = $ilDB->query($q);
421  $notes = array();
422  while($note_rec = $ilDB->fetchAssoc($set))
423  {
424  if ($a_filter != "")
425  {
426  if (!is_array($a_filter))
427  {
428  $a_filter = array($a_filter);
429  }
430  if (!in_array($note_rec["id"], $a_filter))
431  {
432  continue;
433  }
434  }
435  $cnt = count($notes);
436  $notes[$cnt] = new ilNote();
437  $notes[$cnt]->setAllData($note_rec);
438  }
439 
440  return $notes;
441  }
const IL_NOTE_PRIVATE
Definition: class.ilNote.php:4
ilNote($a_id=0)
constructor
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRelatedObjectsOfUser()

ilNote::_getRelatedObjectsOfUser (   $a_mode)

get all related objects for user

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

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

Referenced by ilPDNotesGUI\view().

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

◆ _lookupCreationDate()

ilNote::_lookupCreationDate (   $a_id)

lookup creation date of note

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

References getId().

Referenced by create().

364  {
365  global $ilDB;
366 
367  $q = "SELECT * FROM note WHERE id = ".
368  $ilDB->quote((int) $this->getId(), "integer");
369  $set = $ilDB->query($q);
370  $note_rec = $ilDB->fetchAssoc($set);
371 
372  return $note_rec["creation_date"];
373  }
getId()
get id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupUpdateDate()

ilNote::_lookupUpdateDate (   $a_id)

lookup update date of note

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

References getId().

Referenced by update().

379  {
380  global $ilDB;
381 
382  $q = "SELECT * FROM note WHERE id = ".
383  $ilDB->quote((int) $this->getId(), "integer");
384  $set = $ilDB->query($q);
385  $note_rec = $ilDB->fetchAssoc($set);
386 
387  return $note_rec["update_date"];
388  }
getId()
get id
+ Here is the call graph for this function:
+ 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 692 of file class.ilNote.php.

Referenced by ilNoteGUI\activateComments(), and ilNoteGUI\deactivateComments().

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

Referenced by _getRelatedObjectsOfUser(), ilNoteGUI\getNotesHTML(), ilNoteGUI\ilNoteGUI(), ilObjectGUI\initHeaderAction(), and ilObjectListGUI\isCommentsActivated().

741  {
742  global $ilDB;
743 
744  if ($a_obj_type == "")
745  {
746  $a_obj_type = "-";
747  }
748  $set = $ilDB->query("SELECT * FROM note_settings ".
749  " WHERE rep_obj_id = ".$ilDB->quote((int) $a_rep_obj_id, "integer").
750  " AND obj_id = ".$ilDB->quote((int) $a_obj_id, "integer").
751  " AND obj_type = ".$ilDB->quote($a_obj_type, "text")
752  );
753  $rec = $ilDB->fetchAssoc($set);
754  return $rec["activated"];
755  }
+ 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 _lookupCreationDate(), getCreationDate(), getId(), and ilUtil\now().

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->creation_date = ilNote::_lookupCreationDate($this->getId());
284  }
_lookupCreationDate($a_id)
lookup creation date of note
static now()
Return current timestamp in Y-m-d H:i:s format.
getId()
get id
getCreationDate()
get creation date
+ Here is the call graph for this function:

◆ delete()

ilNote::delete ( )

delete note

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

References getId().

335  {
336  global $ilDB;
337 
338  $q = "DELETE FROM note WHERE id = ".
339  $ilDB->quote((int) $this->getId(), "integer");
340  $ilDB->manipulate($q);
341  }
getId()
get id
+ 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.

120  {
121  return $this->author;
122  }

◆ 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 _lookupCreationDate(), _lookupUpdateDate(), 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.

77  {
78  return array("rep_obj_id" => $this->rep_obj_id,
79  "obj_id" => $this->obj_id,
80  "obj_type" => $this->obj_type);
81  }

◆ getRepObjActivation()

static ilNote::getRepObjActivation (   $a_rep_obj_ids)
static

Get activation for repository objects.

Parameters

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

Referenced by ilObjectListGUI\preloadCommonProperties().

764  {
765  global $ilDB;
766 
767  $set = $ilDB->query("SELECT * FROM note_settings ".
768  " WHERE ".$ilDB->in("rep_obj_id", $a_rep_obj_ids, false, "integer").
769  " AND obj_id = 0 ");
770  $activations = array();
771  while ($rec = $ilDB->fetchAssoc($set))
772  {
773  if ($rec["activated"])
774  {
775  $activations[$rec["rep_obj_id"]][$rec["obj_type"]] = true;
776  }
777  }
778 
779  return $activations;
780  }
+ 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.

140  {
141  return $this->text;
142  }

◆ getType()

ilNote::getType ( )

get type

Returns
int IL_NOTE_PUBLIC | IL_NOTE_PRIVATE

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

100  {
101  return $this->type;
102  }

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

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

609  {
610  global $ilDB;
611 
612  $set = $ilDB->queryF("SELECT count(DISTINCT author) cnt FROM note WHERE ".
613  "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
614  array("integer", "integer", "text"),
615  array((int) $a_rep_obj_id, (int) $a_obj_id, (string)$a_type));
616  $rec = $ilDB->fetchAssoc($set);
617  return (int) $rec["cnt"];
618  }
+ Here is the caller graph for this function:

◆ ilNote()

ilNote::ilNote (   $a_id = 0)

constructor

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

References read().

Referenced by _getLastNotesOfUser(), and _getNotesOfObject().

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:
+ 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 320 of file class.ilNote.php.

References getId(), and setAllData().

Referenced by ilNote().

321  {
322  global $ilDB;
323 
324  $q = "SELECT * FROM note WHERE id = ".
325  $ilDB->quote((int) $this->getId(), "integer");
326  $set = $ilDB->query($q);
327  $note_rec = $ilDB->fetchAssoc($set);
328  $this->setAllData($note_rec);
329  }
setAllData($a_note_rec)
set all note data by record array
getId()
get id
+ 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 346 of file class.ilNote.php.

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

Referenced by read().

347  {
348  $this->setId($a_note_rec["id"]);
349  $this->setObject($a_note_rec["obj_type"], $a_note_rec["rep_obj_id"], $a_note_rec["obj_id"]);
350  $this->setType($a_note_rec["type"]);
351  $this->setAuthor($a_note_rec["author"]);
352  $this->setText($a_note_rec["note_text"]);
353  $this->setSubject($a_note_rec["subject"]);
354  $this->setLabel($a_note_rec["label"]);
355  $this->setCreationDate($a_note_rec["creation_date"]);
356  $this->setUpdateDate($a_note_rec["update_date"]);
357  $this->setInRepository(!(bool)$a_note_rec["no_repository"]);
358  }
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.

Referenced by setAllData().

90  {
91  $this->type = $a_type;
92  }
+ 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 286 of file class.ilNote.php.

References _lookupUpdateDate(), getId(), and ilUtil\now().

287  {
288  global $ilDB;
289 
290  /*$q = "UPDATE note SET ".
291  "rep_obj_id = ".$ilDB->quote((int) $this->rep_obj_id, "integer").",".
292  "obj_id = ".$ilDB->quote((int) $this->obj_id, "integer").",".
293  "obj_type = ".$ilDB->quote((string) $this->obj_type, "text").",".
294  "type = ".$ilDB->quote((int) $this->type, "integer").",".
295  "author = ".$ilDB->quote((int) $this->author,"integer").",".
296  "note_text = ".$ilDB->quote((string) $this->text, "clob").",".
297  "subject = ".$ilDB->quote((string) $this->subject, "text").",".
298  "update_date = ".$ilDB->now().",".
299  "label = ".$ilDB->quote((int) $this->label, "integer").
300  "WHERE id =".$ilDB->quote((int) $this->getId(), "integer");
301  $ilDB->manipulate($q);*/
302  $ilDB->update("note", array(
303  "rep_obj_id" => array("integer", (int) $this->rep_obj_id),
304  "obj_id" => array("integer", (int) $this->obj_id),
305  "obj_type" => array("text", (string) $this->obj_type),
306  "type" => array("integer", (int) $this->type),
307  "author" => array("integer", (int) $this->author),
308  "note_text" => array("clob", (string) $this->text),
309  "subject" => array("text", (string) $this->subject),
310  "label" => array("integer", (int) $this->label),
311  "update_date" => array("timestamp", ilUtil::now()),
312  "no_repository" => array("integer", $this->no_repository)
313  ), array(
314  "id" => array("integer", $this->getId())
315  ));
316 
317  $this->update_date = ilNote::_lookupUpdateDate($this->getId());
318  }
_lookupUpdateDate($a_id)
lookup update date of note
static now()
Return current timestamp in Y-m-d H:i:s format.
getId()
get id
+ Here is the call graph for this function:

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