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);
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;
233 return $this->no_repository = !(bool)$a_value;
243 return !$this->no_repository;
246 function create($a_use_provided_creation_date =
false)
250 $cd = ($a_use_provided_creation_date)
254 $this->
id = $ilDB->nextId(
"note");
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)
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),
314 "no_repository" =>
array(
"integer", $this->no_repository)
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);
342 $q =
"DELETE FROM note WHERE id = ".
343 $ilDB->quote((
int) $this->
getId(),
"integer");
344 $ilDB->manipulate($q);
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"]);
356 $this->
setText($a_note_rec[
"note_text"]);
358 $this->
setLabel($a_note_rec[
"label"]);
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);
376 return $note_rec[
"creation_date"];
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);
391 return $note_rec[
"update_date"];
399 $a_all_public =
"y", $a_repository_mode =
true, $a_sort_ascending =
false)
404 ?
" AND author = ".$ilDB->quote((
int) $ilUser->getId(),
"integer")
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")
412 if(!$a_repository_mode)
414 $sub_where .=
" AND no_repository = ".$ilDB->quote(1,
"integer");
417 $q =
"SELECT * FROM note WHERE ".
418 " rep_obj_id = ".$ilDB->quote((
int) $a_rep_obj_id,
"integer").
420 " AND type = ".$ilDB->quote((
int)
$a_type,
"integer").
422 " ORDER BY creation_date ";
424 $q .= ((bool)$a_sort_ascending) ?
"ASC" :
"DESC";
426 $set = $ilDB->query($q);
428 while($note_rec = $ilDB->fetchAssoc($set))
432 if (!is_array($a_filter))
434 $a_filter =
array($a_filter);
436 if (!in_array($note_rec[
"id"], $a_filter))
441 $cnt = count($notes);
442 $notes[$cnt] =
new ilNote();
443 $notes[$cnt]->setAllData($note_rec);
456 $q =
"SELECT * FROM note WHERE ".
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";
463 $set = $ilDB->query($q);
465 while($note_rec = $ilDB->fetchAssoc($set))
467 $cnt = count($notes);
468 $notes[$cnt] =
new ilNote();
469 $notes[$cnt]->setAllData($note_rec);
484 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
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";
491 $set = $ilDB->query($q);
493 while($rep_rec = $ilDB->fetchAssoc($set))
498 $reps[] =
array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
505 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE ".
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";
511 $set = $ilDB->query($q);
513 while($rep_rec = $ilDB->fetchAssoc($set))
520 $reps[] =
array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
531 $obj_ids[] = $di[
"obj_id"];
533 if (count($obj_ids) > 0)
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").
")";
539 $set = $ilDB->query($q);
540 while($rec = $ilDB->fetchAssoc($set))
544 foreach ($reps as
$r)
546 if ($r[
"rep_obj_id"] == $rec[
"rep_obj_id"])
556 $reps[] =
array(
"rep_obj_id" => $rec[
"rep_obj_id"]);
567 foreach($reps as $idx => $rep)
569 $has_active_ref =
false;
575 $reps[$idx][
"ref_ids"] = array_values($ref_ids);
579 if(!$tree->isDeleted($ref_id))
581 $has_active_ref =
true;
589 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
590 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
595 $reps[$idx][
"wsp_id"] = $node_id;
597 $has_active_ref =
true;
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"];
640 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
642 "author = ".$ilDB->quote((
int) $ilUser->getId(),
"integer").
") OR ".
644 $ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer");
648 $q .=
" AND obj_id = ".$ilDB->quote(0,
"integer");
651 $q .=
" GROUP BY rep_obj_id, type ";
654 $set = $ilDB->query($q);
655 while ($rec = $ilDB->fetchAssoc($set))
657 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
673 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE ".
675 "author = ".$ilDB->quote((
int) $ilUser->getId(),
"integer").
") OR ".
677 " rep_obj_id = ".$ilDB->quote($a_rep_obj_id,
"integer");
679 if ($a_sub_obj_id !== null)
681 $q .=
" AND obj_id = ".$ilDB->quote($a_sub_obj_id,
"integer");
684 $q .=
" GROUP BY rep_obj_id, type ";
687 $set = $ilDB->query($q);
688 while ($rec = $ilDB->fetchAssoc($set))
690 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
702 static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate =
true)
706 if ($a_obj_type ==
"")
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")
715 if ($rec = $ilDB->fetchAssoc($set))
717 if (($rec[
"activated"] == 0 && $a_activate) ||
718 ($rec[
"activated"] == 1 && !$a_activate))
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")
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").
739 $ilDB->manipulate($q);
754 if ($a_obj_type ==
"")
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")
763 $rec = $ilDB->fetchAssoc($set);
764 return $rec[
"activated"];
777 $set = $ilDB->query(
"SELECT * FROM note_settings ".
778 " WHERE ".$ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer").
780 $activations =
array();
781 while ($rec = $ilDB->fetchAssoc($set))
783 if ($rec[
"activated"])
785 $activations[$rec[
"rep_obj_id"]][$rec[
"obj_type"]] =
true;
806 $recipients = $ilSetting->get(
"comments_noti_recip");
807 $recipients = explode(
",", $recipients);
817 $rep_obj_id = $obj[
"rep_obj_id"];
818 $sub_obj_id = $obj[
"obj_id"];
819 $type = $obj[
"obj_type"];
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");
827 if (($sub_obj_id == 0
and $type !=
"blp") ||
828 in_array($type,
array(
"pg",
"wpg")))
831 $type_lv =
"obj_".$type;
837 $type_lv =
"obj_wiki";
846 $type_lv =
"obj_blog";
851 $type_lv =
"portfolio";
856 $type_lv =
"obj_dcl";
859 include_once(
"./Services/Link/classes/class.ilLink.php");
860 foreach($recipients as
$r)
866 foreach ($ref_ids as $r)
868 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $r))
870 if ($sub_obj_id == 0
and $type !=
"blog")
874 else if ($type ==
"wpg")
876 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
877 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
882 else if ($type ==
"pg")
884 $link = ILIAS_HTTP_PATH.
'/goto.php?client_id='.CLIENT_ID.
"&target=pg_".$sub_obj_id.
"_".
$r;
894 $link = ILIAS_HTTP_PATH.
'/goto.php?client_id='.CLIENT_ID.
"&target=prtf_".$rep_obj_id;
899 $ulng->loadLanguageModule(
'note');
903 $subject = sprintf($ulng->txt(
'note_comment_notification_subjectc'), $obj_title.
" (".$ulng->txt($type_lv).
")");
907 $subject = sprintf($ulng->txt(
'note_comment_notification_subject'), $obj_title.
" (".$ulng->txt($type_lv).
")");
913 $message .= $this->
getText().
"\n\n";
917 $message .= $ulng->txt(
'note_comment_notification_link').
": ".$link.
"\n\n";
920 $message .= $ulng->txt(
'note_comment_notification_reason').
"\n\n";
922 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
923 $mail_obj->appendInstallationSignature(
true);
925 "",
"", $subject, $message,
array(),
array(
"system"));
static _lookupLogin($a_user_id)
lookup login
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
create($a_use_provided_creation_date=false)
setSubject($a_subject)
set subject
static _lookupUpdateDate($a_id)
lookup update date of note
static _getStaticLink($a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
static _lookupFullname($a_user_id)
Lookup Full Name.
static _countNotesAndComments($a_rep_obj_id, $a_sub_obj_id=null)
Get all notes related to a specific object.
setAllData($a_note_rec)
set all note data by record array
static _lookupId($a_user_str)
Lookup id by login.
setCreationDate($a_date)
set creation date
static _lookupTitle($a_id)
lookup object title
getUpdateDate()
get update date
static now()
Return current timestamp in Y-m-d H:i:s format.
sendNotifications($a_changed=false)
Send notifications.
setAuthor($a_user_id)
set author
static _getAllReferences($a_id)
get all reference ids of object
Tree handler for personal workspace.
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:
static getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
How many users have attached a note/comment to a given object?
static _lookupCreationDate($a_id)
lookup creation date of note
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
This class handles base functions for mail handling.
static getRepObjActivation($a_rep_obj_ids)
Get activation for repository objects.
setLabel($a_label)
set label
static _getRelatedObjectsOfUser($a_mode)
get all related objects for user
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
getCreationDate()
get creation date
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
__construct($a_id=0)
constructor
static _getLanguageOfUser($a_usr_id)
Get language object of user.
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?
static activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate=true)
Activate notes feature.
setInRepository($a_value)
set repository object status
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0)
set assigned object
setUpdateDate($a_date)
set update date
static _getLastNotesOfUser()
get last notes of current user
isInRepository()
belongs note to repository object?
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static _countNotesAndCommentsMultiple($a_rep_obj_ids, $a_no_sub_objs=false)
Get all notes related to multiple objcts.