24 define(
"IL_NOTE_PRIVATE", 1);
25 define(
"IL_NOTE_PUBLIC", 2);
27 define(
"IL_NOTE_UNLABELED", 0);
28 define(
"IL_NOTE_IMPORTANT", 1);
29 define(
"IL_NOTE_QUESTION", 2);
30 define(
"IL_NOTE_PRO", 3);
31 define(
"IL_NOTE_CONTRA", 4);
89 function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0)
91 $this->rep_obj_id = $a_rep_obj_id;
92 $this->obj_id = $a_obj_id;
93 $this->obj_type = $a_obj_type;
98 return array(
"rep_obj_id" => $this->rep_obj_id,
99 "obj_id" => $this->obj_id,
100 "obj_type" => $this->obj_type);
111 $this->type = $a_type;
131 $this->author = $a_user_id;
141 return $this->author;
151 $this->text = $a_text;
171 $this->subject = $a_subject;
181 return $this->subject;
191 $this->creation_date = $a_date;
201 return $this->creation_date;
211 $this->update_date = $a_date;
221 return $this->update_date;
232 return $this->label = $a_label;
250 $q =
"INSERT INTO note (rep_obj_id, obj_id, obj_type, type,".
251 "author, text, subject, label, creation_date) VALUES (".
252 $ilDB->quote($this->rep_obj_id).
",".
253 $ilDB->quote($this->obj_id).
",".
254 $ilDB->quote($this->obj_type).
",".
255 $ilDB->quote($this->type).
",".
256 $ilDB->quote($this->author).
",".
257 $ilDB->quote($this->text).
",".
258 $ilDB->quote($this->subject).
",".
259 $ilDB->quote($this->label).
",".
263 $this->
id = $ilDB->getLastInsertId();
271 $q =
"UPDATE note SET ".
272 "rep_obj_id = ".$ilDB->quote($this->rep_obj_id).
",".
273 "obj_id = ".$ilDB->quote($this->obj_id).
",".
274 "obj_type = ".$ilDB->quote($this->obj_type).
",".
275 "type = ".$ilDB->quote($this->type).
",".
276 "author = ".$ilDB->quote($this->author).
",".
277 "text = ".$ilDB->quote($this->text).
",".
278 "subject = ".$ilDB->quote($this->subject).
",".
279 "update_date = now(),".
280 "label = ".$ilDB->quote($this->label).
281 "WHERE id =".$ilDB->quote($this->
getId());
292 $q =
"SELECT * FROM note WHERE id = ".
293 $ilDB->quote($this->
getId());
294 $set = $ilDB->query($q);
306 $q =
"DELETE FROM note WHERE id = ".
307 $ilDB->quote($this->
getId());
316 $this->
setId($a_note_rec[
"id"]);
317 $this->
setObject($a_note_rec[
"obj_type"], $a_note_rec[
"rep_obj_id"], $a_note_rec[
"obj_id"]);
318 $this->
setType($a_note_rec[
"type"]);
320 $this->
setText($a_note_rec[
"text"]);
322 $this->
setLabel($a_note_rec[
"label"]);
334 $q =
"SELECT * FROM note WHERE id = ".
335 $ilDB->quote($this->
getId());
336 $set = $ilDB->query($q);
339 return $note_rec[
"creation_date"];
349 $q =
"SELECT * FROM note WHERE id = ".
350 $ilDB->quote($this->
getId());
351 $set = $ilDB->query($q);
354 return $note_rec[
"update_date"];
364 global $ilDB, $ilUser;
367 ?
" AND author = ".$ilDB->quote($ilUser->getId())
370 $sub_where = (!$a_incl_sub)
371 ?
" AND obj_id = ".$ilDB->quote($a_obj_id).
372 " AND obj_type = ".$ilDB->quote($a_obj_type)
375 $q =
"SELECT * FROM note WHERE ".
376 " rep_obj_id = ".$ilDB->quote($a_rep_obj_id).
378 " AND type = ".$ilDB->quote($a_type).
380 " ORDER BY creation_date DESC";
382 $set = $ilDB->query($q);
388 if (!is_array($a_filter))
390 $a_filter = array($a_filter);
392 if (!in_array($note_rec[
"id"], $a_filter))
397 $cnt = count($notes);
398 $notes[$cnt] =
new ilNote();
399 $notes[$cnt]->setAllData($note_rec);
410 global $ilDB, $ilUser;
412 $q =
"SELECT * FROM note WHERE ".
414 " AND author = ".$ilDB->quote($ilUser->getId()).
415 " ORDER BY creation_date DESC";
418 $set = $ilDB->query($q);
422 $cnt = count($notes);
423 $notes[$cnt] =
new ilNote();
424 $notes[$cnt]->setAllData($note_rec);
435 global $ilDB, $ilUser;
437 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
439 " AND author = ".$ilDB->quote($ilUser->getId()).
440 " ORDER BY rep_obj_id";
443 $set = $ilDB->query($q);
447 $reps[] = array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
464 $st = $ilDB->prepare(
"SELECT count(DISTINCT author) cnt FROM note WHERE ".
465 "rep_obj_id = ? AND obj_id = ? AND obj_type = ?",
466 array(
"integer",
"integer",
"text"));
468 $set = $ilDB->execute($st, array($a_rep_obj_id, $a_obj_id, $a_type));
469 $rec = $ilDB->fetchAssoc($set);
471 return (
int) $rec[
"cnt"];