5 define(
"IL_NOTE_PRIVATE", 1);
6 define(
"IL_NOTE_PUBLIC", 2);
8 define(
"IL_NOTE_UNLABELED", 0);
9 define(
"IL_NOTE_IMPORTANT", 1);
10 define(
"IL_NOTE_QUESTION", 2);
11 define(
"IL_NOTE_PRO", 3);
12 define(
"IL_NOTE_CONTRA", 4);
78 $this->db = $DIC->database();
80 $this->access = $DIC->access();
115 public function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0, $a_news_id = 0)
117 $this->rep_obj_id = $a_rep_obj_id;
118 $this->obj_id = $a_obj_id;
119 $this->obj_type = $a_obj_type;
120 $this->news_id = $a_news_id;
127 return array(
"rep_obj_id" => $this->rep_obj_id,
128 "obj_id" => $this->obj_id,
129 "obj_type" => $this->obj_type,
130 "news_id" => $this->news_id);
161 $this->author = $a_user_id;
171 return $this->author;
181 $this->text = $a_text;
201 $this->subject = $a_subject;
211 return $this->subject;
221 $this->creation_date = $a_date;
231 return $this->creation_date;
241 $this->update_date = $a_date;
251 return $this->update_date;
262 return $this->label = $a_label;
283 $this->news_id = $a_val;
303 return $this->no_repository = !(bool) $a_value;
313 return !$this->no_repository;
316 public function create($a_use_provided_creation_date =
false)
320 $cd = ($a_use_provided_creation_date)
324 $this->
id =
$ilDB->nextId(
"note");
326 $ilDB->insert(
"note", array(
327 "id" => array(
"integer", $this->
id),
328 "rep_obj_id" => array(
"integer", (
int) $this->rep_obj_id),
329 "obj_id" => array(
"integer", (
int) $this->obj_id),
330 "obj_type" => array(
"text", (
string) $this->obj_type),
331 "news_id" => array(
"integer", (
int) $this->news_id),
332 "type" => array(
"integer", (
int) $this->type),
333 "author" => array(
"integer", (
int) $this->author),
334 "note_text" => array(
"clob", (
string) $this->text),
335 "subject" => array(
"text", (
string) $this->subject),
336 "label" => array(
"integer", (
int) $this->label),
337 "creation_date" => array(
"timestamp", $cd),
338 "no_repository" => array(
"integer", $this->no_repository)
350 $ilDB->update(
"note", array(
351 "rep_obj_id" => array(
"integer", (
int) $this->rep_obj_id),
352 "obj_id" => array(
"integer", (
int) $this->obj_id),
353 "news_id" => array(
"integer", (
int) $this->news_id),
354 "obj_type" => array(
"text", (
string) $this->obj_type),
355 "type" => array(
"integer", (
int) $this->type),
356 "author" => array(
"integer", (
int) $this->author),
357 "note_text" => array(
"clob", (
string) $this->text),
358 "subject" => array(
"text", (
string) $this->subject),
359 "label" => array(
"integer", (
int) $this->label),
360 "update_date" => array(
"timestamp",
ilUtil::now()),
361 "no_repository" => array(
"integer", $this->no_repository)
363 "id" => array(
"integer", $this->
getId())
375 $q =
"SELECT * FROM note WHERE id = " .
376 $ilDB->quote((
int) $this->
getId(),
"integer");
377 $set =
$ilDB->query($q);
378 $note_rec =
$ilDB->fetchAssoc($set);
385 public function delete()
389 $q =
"DELETE FROM note WHERE id = " .
390 $ilDB->quote((
int) $this->
getId(),
"integer");
391 $ilDB->manipulate($q);
399 $this->
setId($a_note_rec[
"id"]);
401 $a_note_rec[
"obj_type"],
402 $a_note_rec[
"rep_obj_id"],
403 $a_note_rec[
"obj_id"],
404 $a_note_rec[
"news_id"]
406 $this->
setType($a_note_rec[
"type"]);
408 $this->
setText($a_note_rec[
"note_text"]);
410 $this->
setLabel($a_note_rec[
"label"]);
423 $ilDB = $DIC->database();
425 $q =
"SELECT * FROM note WHERE id = " .
426 $ilDB->quote((
int) $a_id,
"integer");
427 $set =
$ilDB->query($q);
428 $note_rec =
$ilDB->fetchAssoc($set);
430 return $note_rec[
"creation_date"];
440 $ilDB = $DIC->database();
442 $q =
"SELECT * FROM note WHERE id = " .
443 $ilDB->quote((
int) $a_id,
"integer");
444 $set =
$ilDB->query($q);
445 $note_rec =
$ilDB->fetchAssoc($set);
447 return $note_rec[
"update_date"];
461 $a_repository_mode =
true,
462 $a_sort_ascending =
false,
467 $ilDB = $DIC->database();
471 ?
" AND author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer")
474 $sub_where = (!$a_incl_sub)
475 ?
" AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
476 " AND obj_type = " .
$ilDB->quote((
string) $a_obj_type,
"text")
480 " AND news_id = " .
$ilDB->quote((
int) $a_news_id,
"integer");
483 $sub_where .=
" AND no_repository = " .
$ilDB->quote(!$a_repository_mode,
"integer");
485 $q =
"SELECT * FROM note WHERE " .
486 " rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
488 " AND type = " .
$ilDB->quote((
int)
$a_type,
"integer") .
491 " ORDER BY creation_date ";
493 $q .= ((bool) $a_sort_ascending) ?
"ASC" :
"DESC";
495 $set =
$ilDB->query($q);
497 while ($note_rec =
$ilDB->fetchAssoc($set)) {
498 if ($a_filter !=
"") {
499 if (!is_array($a_filter)) {
500 $a_filter = array($a_filter);
502 if (!in_array($note_rec[
"id"], $a_filter)) {
506 $cnt = count($notes);
507 $notes[$cnt] =
new ilNote();
508 $notes[$cnt]->setAllData($note_rec);
521 $a_sort_ascending =
false,
526 $ilDB = $DIC->database();
528 $sub_where = (!$a_incl_sub)
529 ?
" AND obj_id = " .
$ilDB->quote((
int) 0,
"integer") :
"";
531 if ($a_since !=
"") {
532 $sub_where .=
" AND creation_date > " .
$ilDB->quote($a_since,
"timestamp");
535 $sub_where .=
" AND no_repository = " .
$ilDB->quote(0,
"integer");
537 $q =
"SELECT * FROM note WHERE " .
538 " rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
540 " AND type = " .
$ilDB->quote((
int)
$a_type,
"integer") .
541 " ORDER BY creation_date ";
543 $q .= ((bool) $a_sort_ascending) ?
"ASC" :
"DESC";
544 $set =
$ilDB->query($q);
546 while ($note_rec =
$ilDB->fetchAssoc($set)) {
547 $cnt = count($notes);
548 $notes[$cnt] =
new ilNote();
549 $notes[$cnt]->setAllData($note_rec);
561 $ilDB = $DIC->database();
564 $q =
"SELECT * FROM note WHERE " .
566 " AND author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
567 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
568 " ORDER BY creation_date DESC";
571 $set =
$ilDB->query($q);
573 while ($note_rec =
$ilDB->fetchAssoc($set)) {
574 $cnt = count($notes);
575 $notes[$cnt] =
new ilNote();
576 $notes[$cnt]->setAllData($note_rec);
589 $ilDB = $DIC->database();
591 $tree = $DIC->repositoryTree();
594 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
596 " AND author = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
597 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
598 " ORDER BY rep_obj_id";
601 $set =
$ilDB->query($q);
603 while ($rep_rec =
$ilDB->fetchAssoc($set)) {
606 $reps[] = array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
611 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
613 " AND author = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
614 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
615 " ORDER BY rep_obj_id";
617 $set =
$ilDB->query($q);
619 while ($rep_rec =
$ilDB->fetchAssoc($set)) {
623 $reps[] = array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
632 foreach ($dis as $di) {
633 $obj_ids[] = $di[
"obj_id"];
635 if (count($obj_ids) > 0) {
636 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
637 $ilDB->in(
"rep_obj_id", $obj_ids,
false,
"integer") .
638 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")";
640 $set =
$ilDB->query($q);
641 while ($rec =
$ilDB->fetchAssoc($set)) {
644 foreach ($reps as
$r) {
645 if ($r[
"rep_obj_id"] == $rec[
"rep_obj_id"]) {
652 $reps[] = array(
"rep_obj_id" => $rec[
"rep_obj_id"]);
662 foreach ($reps as $idx => $rep) {
663 $has_active_ref =
false;
668 $reps[$idx][
"ref_ids"] = array_values($ref_ids);
670 foreach ($ref_ids as $ref_id) {
671 if (!
$tree->isDeleted($ref_id)) {
672 $has_active_ref =
true;
678 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
679 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
683 $reps[$idx][
"wsp_id"] = $node_id;
685 $has_active_ref =
true;
689 if (!$has_active_ref) {
709 $ilDB = $DIC->database();
711 $set =
$ilDB->queryF(
712 "SELECT count(DISTINCT author) cnt FROM note WHERE " .
713 "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
714 array(
"integer",
"integer",
"text"),
715 array((
int) $a_rep_obj_id, (
int) $a_obj_id, (
string)
$a_type)
717 $rec =
$ilDB->fetchAssoc($set);
718 return (
int) $rec[
"cnt"];
731 $ilDB = $DIC->database();
734 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
736 "author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
") OR " .
738 $ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer");
740 if ($a_no_sub_objs) {
741 $q .=
" AND obj_id = " .
$ilDB->quote(0,
"integer");
744 $q .=
" GROUP BY rep_obj_id, type ";
747 $set =
$ilDB->query($q);
748 while ($rec =
$ilDB->fetchAssoc($set)) {
749 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
763 $a_sub_obj_id = null,
769 $ilDB = $DIC->database();
772 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
774 "author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
") OR " .
776 " rep_obj_id = " .
$ilDB->quote($a_rep_obj_id,
"integer");
778 if ($a_sub_obj_id !== null) {
779 $q .=
" AND obj_id = " .
$ilDB->quote($a_sub_obj_id,
"integer");
780 $q .=
" AND obj_type = " .
$ilDB->quote($a_obj_type,
"text");
783 $q .=
" AND news_id = " .
$ilDB->quote($a_news_id,
"integer");
785 $q .=
" GROUP BY rep_obj_id, type ";
788 $set =
$ilDB->query($q);
789 while ($rec =
$ilDB->fetchAssoc($set)) {
790 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
802 public static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate =
true)
806 $ilDB = $DIC->database();
808 if ($a_obj_type ==
"") {
812 "SELECT * FROM note_settings " .
813 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
814 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
815 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
817 if ($rec =
$ilDB->fetchAssoc($set)) {
818 if (($rec[
"activated"] == 0 && $a_activate) ||
819 ($rec[
"activated"] == 1 && !$a_activate)) {
821 "UPDATE note_settings SET " .
822 " activated = " .
$ilDB->quote((
int) $a_activate,
"integer") .
823 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
824 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
825 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
830 $q =
"INSERT INTO note_settings " .
831 "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
832 $ilDB->quote((
int) $a_rep_obj_id,
"integer") .
"," .
833 $ilDB->quote((
int) $a_obj_id,
"integer") .
"," .
834 $ilDB->quote($a_obj_type,
"text") .
"," .
835 $ilDB->quote(1,
"integer") .
837 $ilDB->manipulate($q);
852 $ilDB = $DIC->database();
854 if ($a_news_id > 0) {
858 if ($a_obj_type ==
"") {
862 "SELECT * FROM note_settings " .
863 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
864 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
865 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
867 $rec =
$ilDB->fetchAssoc($set);
868 return $rec[
"activated"];
881 $ilDB = $DIC->database();
883 $set =
$ilDB->query(
"SELECT * FROM note_settings " .
884 " WHERE " .
$ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer") .
886 $activations = array();
887 while ($rec =
$ilDB->fetchAssoc($set)) {
888 if ($rec[
"activated"]) {
889 $activations[$rec[
"rep_obj_id"]][$rec[
"obj_type"]] =
true;
910 $recipients =
$ilSetting->get(
"comments_noti_recip");
911 $recipients = explode(
",", $recipients);
922 $sub_obj_id = $obj[
"obj_id"];
923 $type = $obj[
"obj_type"];
925 include_once(
"./Services/Language/classes/class.ilLanguageFactory.php");
926 include_once(
"./Services/User/classes/class.ilUserUtil.php");
927 include_once(
"./Services/Mail/classes/class.ilMail.php");
931 if (($sub_obj_id == 0
and $type !=
"blp") ||
932 in_array(
$type, array(
"pg",
"wpg"))) {
934 $type_lv =
"obj_" .
$type;
938 if (
$type ==
"wpg") {
939 $type_lv =
"obj_wiki";
944 if (
$type ==
"blp") {
946 $type_lv =
"obj_blog";
948 if (
$type ==
"pfpg") {
950 $type_lv =
"portfolio";
952 if (
$type ==
"dcl") {
954 $type_lv =
"obj_dcl";
957 include_once(
"./Services/Link/classes/class.ilLink.php");
958 foreach ($recipients as
$r) {
962 foreach ($ref_ids as $r) {
963 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $r)) {
964 if ($sub_obj_id == 0
and $type !=
"blog") {
966 } elseif (
$type ==
"wpg") {
967 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
968 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
976 } elseif (
$type ==
"pg") {
977 $link = ILIAS_HTTP_PATH .
'/goto.php?client_id=' . CLIENT_ID .
"&target=pg_" . $sub_obj_id .
"_" .
$r;
981 if (
$type ==
"blp") {
984 if (
$type ==
"pfpg") {
985 $link = ILIAS_HTTP_PATH .
'/goto.php?client_id=' . CLIENT_ID .
"&target=prtf_" .
$rep_obj_id;
990 $ulng->loadLanguageModule(
'note');
993 $subject = sprintf($ulng->txt(
'note_comment_notification_subjectc'), $obj_title .
" (" . $ulng->txt($type_lv) .
")");
995 $subject = sprintf($ulng->txt(
'note_comment_notification_subject'), $obj_title .
" (" . $ulng->txt($type_lv) .
")");
1001 $message .= $this->
getText() .
"\n\n";
1004 $message .= $ulng->txt(
'note_comment_notification_link') .
": " . $link .
"\n\n";
1007 $message .= $ulng->txt(
'note_comment_notification_reason') .
"\n\n";
1009 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
1010 $mail_obj->appendInstallationSignature(
true);
1011 $mail_obj->sendMail(
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)
static commentsActivated($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_news_id=0)
Are comments activated for object?
setSubject($a_subject)
set subject
static _lookupUpdateDate($a_id)
lookup update date of note
static _lookupFullname($a_user_id)
Lookup Full Name.
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
setAllData($a_note_rec)
set all note data by record array
if(!array_key_exists('StateId', $_REQUEST)) $id
static _getAllNotesOfSingleRepObject( $a_rep_obj_id, $a_type=IL_NOTE_PRIVATE, $a_incl_sub=false, $a_sort_ascending=false, $a_since="")
get all notes related to a single repository object
static _lookupId($a_user_str)
Lookup id by login.
setCreationDate($a_date)
set creation date
static _lookupTitle($a_id)
lookup object title
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, $a_news_id=0)
get all notes related to a specific object
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.
catch(Exception $e) $message
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 _countNotesAndComments( $a_rep_obj_id, $a_sub_obj_id=null, $a_obj_type="", $a_news_id=0)
Get all notes related to a specific object.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
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 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, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
setObject($a_obj_type, $a_rep_obj_id, $a_obj_id=0, $a_news_id=0)
set assigned object
getCreationDate()
get creation date
lookupNodeId($a_obj_id)
Get node id for object id.
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
setNewsId($a_val)
Set news id.
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
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.