4 define(
"IL_NOTE_PRIVATE", 1);
 
    5 define(
"IL_NOTE_PUBLIC", 2);
 
    7 define(
"IL_NOTE_UNLABELED", 0);
 
    8 define(
"IL_NOTE_IMPORTANT", 1);
 
    9 define(
"IL_NOTE_QUESTION", 2);
 
   10 define(
"IL_NOTE_PRO", 3);
 
   11 define(
"IL_NOTE_CONTRA", 4);
 
   69         function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0)
 
   71                 $this->rep_obj_id = $a_rep_obj_id;
 
   72                 $this->obj_id = $a_obj_id;
 
   73                 $this->obj_type = $a_obj_type;
 
   78                 return array(
"rep_obj_id" => $this->rep_obj_id,
 
   79                         "obj_id" => $this->obj_id,
 
   80                         "obj_type" => $this->obj_type);
 
   91                 $this->type = $a_type;
 
  111                 $this->author = $a_user_id;
 
  121                 return $this->author;
 
  131                 $this->text = $a_text;
 
  151                 $this->subject = $a_subject;
 
  161                 return $this->subject;
 
  171                 $this->creation_date = $a_date;
 
  181                 return $this->creation_date;
 
  191                 $this->update_date = $a_date;
 
  201                 return $this->update_date;
 
  212                 return $this->label = $a_label;
 
  230                 $this->
id = $ilDB->nextId(
"note");
 
  245                 $ilDB->insert(
"note", array(
 
  246                         "id" => array(
"integer", $this->
id),
 
  247                         "rep_obj_id" => array(
"integer", (
int) $this->rep_obj_id),
 
  248                         "obj_id" => array(
"integer", (
int) $this->obj_id),
 
  249                         "obj_type" => array(
"text", (
string) $this->obj_type),
 
  250                         "type" => array(
"integer", (
int) $this->type),
 
  251                         "author" => array(
"integer", (
int) $this->author),
 
  252                         "note_text" => array(
"clob", (
string) $this->text),
 
  253                         "subject" => array(
"text", (
string) $this->subject),
 
  254                         "label" => array(
"integer", (
int) $this->label),
 
  255                         "creation_date" => array(
"timestamp", 
ilUtil::now())
 
  277                 $ilDB->update(
"note", array(
 
  278                         "rep_obj_id" => array(
"integer", (
int) $this->rep_obj_id),
 
  279                         "obj_id" => array(
"integer", (
int) $this->obj_id),
 
  280                         "obj_type" => array(
"text", (
string) $this->obj_type),
 
  281                         "type" => array(
"integer", (
int) $this->type),
 
  282                         "author" => array(
"integer", (
int) $this->author),
 
  283                         "note_text" => array(
"clob", (
string) $this->text),
 
  284                         "subject" => array(
"text", (
string) $this->subject),
 
  285                         "label" => array(
"integer", (
int) $this->label),
 
  288                         "id" => array(
"integer", $this->
getId())
 
  298                 $q = 
"SELECT * FROM note WHERE id = ".
 
  299                         $ilDB->quote((
int) $this->
getId(), 
"integer");
 
  300                 $set = $ilDB->query($q);
 
  301                 $note_rec = $ilDB->fetchAssoc($set);
 
  312                 $q = 
"DELETE FROM note WHERE id = ".
 
  313                         $ilDB->quote((
int) $this->
getId(), 
"integer");
 
  314                 $ilDB->manipulate($q);
 
  322                 $this->
setId($a_note_rec[
"id"]);
 
  323                 $this->
setObject($a_note_rec[
"obj_type"], $a_note_rec[
"rep_obj_id"], $a_note_rec[
"obj_id"]);
 
  324                 $this->
setType($a_note_rec[
"type"]);
 
  326                 $this->
setText($a_note_rec[
"note_text"]);
 
  328                 $this->
setLabel($a_note_rec[
"label"]);
 
  340                 $q = 
"SELECT * FROM note WHERE id = ".
 
  341                         $ilDB->quote((
int) $this->
getId(), 
"integer");
 
  342                 $set = $ilDB->query($q);
 
  343                 $note_rec = $ilDB->fetchAssoc($set);
 
  345                 return $note_rec[
"creation_date"];
 
  355                 $q = 
"SELECT * FROM note WHERE id = ".
 
  356                         $ilDB->quote((
int) $this->
getId(), 
"integer");
 
  357                 $set = $ilDB->query($q);
 
  358                 $note_rec = $ilDB->fetchAssoc($set);
 
  360                 return $note_rec[
"update_date"];
 
  370                 global 
$ilDB, $ilUser;
 
  373                         ? 
" AND author = ".$ilDB->quote((
int) $ilUser->getId(), 
"integer")
 
  376                 $sub_where = (!$a_incl_sub)
 
  377                         ? 
" AND obj_id = ".$ilDB->quote((
int) $a_obj_id, 
"integer").
 
  378                           " AND obj_type = ".$ilDB->quote((
string) $a_obj_type, 
"text")
 
  381                 $q = 
"SELECT * FROM note WHERE ".
 
  382                         " rep_obj_id = ".$ilDB->quote((
int) $a_rep_obj_id, 
"integer").
 
  384                         " AND type = ".$ilDB->quote((
int) $a_type, 
"integer").
 
  386                         " ORDER BY creation_date DESC";
 
  388                 $set = $ilDB->query($q);
 
  390                 while($note_rec = $ilDB->fetchAssoc($set))
 
  394                                 if (!is_array($a_filter))
 
  396                                         $a_filter = array($a_filter);
 
  398                                 if (!in_array($note_rec[
"id"], $a_filter))
 
  403                         $cnt = count($notes);
 
  404                         $notes[$cnt] = 
new ilNote();
 
  405                         $notes[$cnt]->setAllData($note_rec);
 
  416                 global 
$ilDB, $ilUser;
 
  418                 $q = 
"SELECT * FROM note WHERE ".
 
  420                         " AND author = ".$ilDB->quote((
int) $ilUser->getId(), 
"integer").
 
  421                         " ORDER BY creation_date DESC";
 
  424                 $set = $ilDB->query($q);
 
  426                 while($note_rec = $ilDB->fetchAssoc($set))
 
  428                         $cnt = count($notes);
 
  429                         $notes[$cnt] = 
new ilNote();
 
  430                         $notes[$cnt]->setAllData($note_rec);
 
  441                 global 
$ilDB, $ilUser;
 
  445                         $q = 
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
 
  447                                 " AND author = ".$ilDB->quote($ilUser->getId(), 
"integer").
 
  448                                 " ORDER BY rep_obj_id";
 
  451                         $set = $ilDB->query($q);
 
  453                         while($rep_rec = $ilDB->fetchAssoc($set))
 
  455                                 $reps[] = array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
 
  461                         $q = 
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
 
  463                                 " AND author = ".$ilDB->quote($ilUser->getId(), 
"integer").
 
  464                                 " ORDER BY rep_obj_id";
 
  466                         $set = $ilDB->query($q);
 
  468                         while($rep_rec = $ilDB->fetchAssoc($set))
 
  470                                 $reps[] = array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
 
  479                                 $obj_ids[] = $di[
"obj_id"];
 
  481                         if (count($obj_ids) > 0)
 
  483                                 $q = 
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
 
  484                                         $ilDB->in(
"rep_obj_id", $obj_ids, 
false, 
"integer");
 
  486                                 $set = $ilDB->query($q);
 
  487                                 while($rec = $ilDB->fetchAssoc($set))
 
  491                                         foreach ($reps as $r)
 
  493                                                 if ($r[
"rep_obj_id"] == $rec[
"rep_obj_id"])
 
  500                                                 $reps[] = array(
"rep_obj_id" => $rec[
"rep_obj_id"]);
 
  520                 $set = $ilDB->queryF(
"SELECT count(DISTINCT author) cnt FROM note WHERE ".
 
  521                         "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
 
  522                         array(
"integer", 
"integer", 
"text"),
 
  523                         array((
int)$a_rep_obj_id, (
int)$a_obj_id, (
string)$a_type));
 
  524                 $rec = $ilDB->fetchAssoc($set);
 
  526                 return (
int) $rec[
"cnt"];