3 declare(strict_types=1);
    28     protected \ilDBInterface 
$db;
    44         $id = $db->nextId(
"note");
    46         $db->insert(
"note", array(
    47             "id" => array(
"integer", 
$id),
    48             "rep_obj_id" => array(
"integer", 
$context->getObjId()),
    49             "obj_id" => array(
"integer", 
$context->getSubObjId()),
    50             "obj_type" => array(
"text", 
$context->getType()),
    51             "news_id" => array(
"integer", 
$context->getNewsId()),
    52             "type" => array(
"integer", $note->
getType()),
    53             "author" => array(
"integer", $note->
getAuthor()),
    54             "note_text" => array(
"clob", $note->
getText()),
    56             "no_repository" => array(
"integer", (
int) !
$context->getInRepository()),
    65         $q = 
"DELETE FROM note WHERE id = " .
    66             $db->quote($id, 
"integer");
    77         $db->update(
"note", array(
    78             "note_text" => array(
"clob", $text),
    79             "update_date" => array(
"timestamp", $update_date),
    81             "id" => array(
"integer", $id)
    95             "SELECT * FROM note " .
   100         if ($rec = $db->fetchAssoc($set)) {
   108         return $this->data->note(
   110             $this->data->context(
   111                 (
int) $rec[
"rep_obj_id"],
   112                 (
int) $rec[
"obj_id"],
   114                 (
int) $rec[
"news_id"],
   115                 !$rec[
"no_repository"]
   117             (string) $rec[
"note_text"],
   118             (
int) $rec[
"author"],
   120             $rec[
"creation_date"],
   122             (
int) $rec[
"recipient"]
   133         bool $incl_sub = 
false,
   135         bool $ascending = 
false,
   139         string $search_text = 
""   143         $author_where = ($author > 0)
   144             ? 
" AND author = " . $db->
quote($author, 
"integer")
   148             ? 
" rep_obj_id = " . $db->quote($context->
getObjId(), 
"integer")
   149             : 
" " . $db->in(
"rep_obj_id", $obj_ids, 
false, 
"integer");
   151         $sub_where .= ($context && !$incl_sub)
   152             ? 
" AND note.obj_id = " . $db->quote($context->
getSubObjId(), 
"integer") .
   153             " AND note.obj_type = " . $db->quote($context->
getType(), 
"text")
   157             $sub_where .= 
" AND creation_date > " . $db->quote($since, 
"timestamp");
   163                 " AND news_id = " . $db->quote($context->
getNewsId(), 
"integer");
   165             $sub_where .= 
" AND no_repository = " . $db->quote(!$context->
getInRepository(), 
"integer");
   170         if ($search_text !== 
"") {
   171             $sub_where .= 
" AND (" . $db->like(
"note_text", 
"text", 
"%" . $search_text . 
"%");
   172             $join = 
" JOIN usr_data ud ON (author = ud.usr_id)";
   173             $join .= 
" LEFT JOIN object_data od ON (rep_obj_id = od.obj_id)";
   174             $sub_where .= 
" OR " . $db->like(
"ud.lastname", 
"text", 
"%" . $search_text . 
"%");
   175             $sub_where .= 
" OR " . $db->like(
"ud.firstname", 
"text", 
"%" . $search_text . 
"%");
   176             $sub_where .= 
" OR " . $db->like(
"ud.login", 
"text", 
"%" . $search_text . 
"%");
   177             $sub_where .= 
" OR " . $db->like(
"od.title", 
"text", 
"%" . $search_text . 
"%");
   181         $fields = $count ? 
"count(*) cnt" : 
"note.*";
   182         $query = 
"SELECT $fields FROM note $join WHERE " .
   184             " AND note.type = " . $db->quote($type, 
"integer") .
   187             " ORDER BY creation_date ";
   188         $query .= ($ascending) ? 
"ASC" : 
"DESC";
   199         bool $incl_sub = 
false,
   201         bool $ascending = 
false,
   203         string $search_text = 
""   219         $set = $db->query($query);
   221         while ($note_rec = $db->fetchAssoc($set)) {
   234         bool $incl_sub = 
false,
   236         bool $ascending = 
false,
   238         string $search_text = 
""   254         $set = $db->query($query);
   256         while ($note_rec = $db->fetchAssoc($set)) {
   265         bool $incl_sub = 
false,
   279         $set = $db->query($query);
   280         $rec = $db->fetchAssoc($set);
   281         return (
int) $rec[
"cnt"];
   293         $q = 
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
   294             " type = " . $db->quote($type, 
"integer") .
   295             " AND author = " . $db->quote($user_id, 
"integer") .
   296             " AND (no_repository IS NULL OR no_repository < " . $db->quote(1, 
"integer") . 
")";
   298         $set = $db->query(
$q);
   300         while ($rec = $db->fetchAssoc($set)) {
   301             $ids[] = (
int) $rec[
"rep_obj_id"];
   314         $q = 
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
   315             $db->in(
"rep_obj_id", $obj_ids, 
false, 
"integer") .
   316             " AND type = " . $db->quote($type, 
"integer") .
   317             " AND (no_repository IS NULL OR no_repository < " . $db->quote(1, 
"integer") . 
")";
   319         $set = $db->query(
$q);
   321         while ($rec = $db->fetchAssoc($set)) {
   322             $ids[] = (
int) $rec[
"rep_obj_id"];
   338             "SELECT count(DISTINCT author) cnt FROM note WHERE " .
   339             "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
   340             array(
"integer", 
"integer", 
"text"),
   341             array($obj_id, $sub_obj_id, $obj_type)
   343         $rec = $db->fetchAssoc($set);
   344         return (
int) $rec[
"cnt"];
   355         bool $no_sub_objs = 
false   359         $q = 
"SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
   360             " ((type = " . $db->quote(
Note::PRIVATE, 
"integer") . 
" AND " .
   361             "author = " . $db->quote($user_id, 
"integer") . 
") OR " .
   362             " type = " . $db->quote(
Note::PUBLIC, 
"integer") . 
") AND " .
   363             $db->in(
"rep_obj_id", $obj_ids, 
false, 
"integer");
   366             $q .= 
" AND obj_id = " . $db->quote(0, 
"integer");
   369         $q .= 
" GROUP BY rep_obj_id, type ";
   372         $set = $db->query(
$q);
   373         while ($rec = $db->fetchAssoc($set)) {
   374             $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
 getQuery(?Context $context, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, bool $count=false, string $since="", array $obj_ids=[], string $search_text="")
Get query. 
 
__construct(InternalDataService $data, \ilDBInterface $db)
 
getById(int $id)
Get note by id. 
 
quote($value, string $type)
 
static now()
Return current timestamp in Y-m-d H:i:s format. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getRelatedObjIdsOfUser(int $user_id, int $type)
 
getNoteFromRecord(array $rec)
 
queryF(string $query, array $types, array $values)
 
getNotesForObjIds(array $obj_ids, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, string $since="", string $search_text="")
Get all notes related to a specific object. 
 
updateNoteText(int $id, string $text)
 
getNrOfNotesForContext(Context $context, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0)
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
getNotesForContext(Context $context, int $type=Note::PRIVATE, bool $incl_sub=false, int $author=0, bool $ascending=false, string $since="", string $search_text="")
Get all notes related to a specific object. 
 
countNotesAndCommentsMultipleObjects(array $obj_ids, int $user_id, bool $no_sub_objs=false)
Get all notes related to multiple repository objects. 
 
InternalDataService $data
 
filterObjectsWithNotes(array $obj_ids, int $type)
 
getUserCount(int $obj_id, int $sub_obj_id, string $obj_type)
How many users have attached a note/comment to a given object?