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);
49 $this->db = $DIC->database();
51 $this->access = $DIC->access();
88 public function setObject($a_obj_type, $a_rep_obj_id, $a_obj_id = 0)
90 $this->rep_obj_id = $a_rep_obj_id;
91 $this->obj_id = $a_obj_id;
92 $this->obj_type = $a_obj_type;
97 return array(
"rep_obj_id" => $this->rep_obj_id,
98 "obj_id" => $this->obj_id,
99 "obj_type" => $this->obj_type);
130 $this->author = $a_user_id;
140 return $this->author;
150 $this->text = $a_text;
170 $this->subject = $a_subject;
180 return $this->subject;
190 $this->creation_date = $a_date;
200 return $this->creation_date;
210 $this->update_date = $a_date;
220 return $this->update_date;
231 return $this->label = $a_label;
252 return $this->no_repository = !(bool) $a_value;
262 return !$this->no_repository;
265 public function create($a_use_provided_creation_date =
false)
269 $cd = ($a_use_provided_creation_date)
273 $this->
id =
$ilDB->nextId(
"note");
289 "id" =>
array(
"integer", $this->
id),
290 "rep_obj_id" =>
array(
"integer", (
int) $this->rep_obj_id),
291 "obj_id" =>
array(
"integer", (
int) $this->obj_id),
292 "obj_type" =>
array(
"text", (
string) $this->obj_type),
293 "type" =>
array(
"integer", (
int) $this->type),
294 "author" =>
array(
"integer", (
int) $this->author),
295 "note_text" =>
array(
"clob", (
string) $this->text),
296 "subject" =>
array(
"text", (
string) $this->subject),
297 "label" =>
array(
"integer", (
int) $this->label),
298 "creation_date" =>
array(
"timestamp", $cd),
299 "no_repository" =>
array(
"integer", $this->no_repository)
324 "rep_obj_id" =>
array(
"integer", (
int) $this->rep_obj_id),
325 "obj_id" =>
array(
"integer", (
int) $this->obj_id),
326 "obj_type" =>
array(
"text", (
string) $this->obj_type),
327 "type" =>
array(
"integer", (
int) $this->type),
328 "author" =>
array(
"integer", (
int) $this->author),
329 "note_text" =>
array(
"clob", (
string) $this->text),
330 "subject" =>
array(
"text", (
string) $this->subject),
331 "label" =>
array(
"integer", (
int) $this->label),
333 "no_repository" =>
array(
"integer", $this->no_repository)
347 $q =
"SELECT * FROM note WHERE id = " .
348 $ilDB->quote((
int) $this->
getId(),
"integer");
349 $set =
$ilDB->query($q);
350 $note_rec =
$ilDB->fetchAssoc($set);
357 public function delete()
361 $q =
"DELETE FROM note WHERE id = " .
362 $ilDB->quote((
int) $this->
getId(),
"integer");
363 $ilDB->manipulate($q);
371 $this->
setId($a_note_rec[
"id"]);
372 $this->
setObject($a_note_rec[
"obj_type"], $a_note_rec[
"rep_obj_id"], $a_note_rec[
"obj_id"]);
373 $this->
setType($a_note_rec[
"type"]);
375 $this->
setText($a_note_rec[
"note_text"]);
377 $this->
setLabel($a_note_rec[
"label"]);
390 $ilDB = $DIC->database();
392 $q =
"SELECT * FROM note WHERE id = " .
393 $ilDB->quote((
int) $a_id,
"integer");
394 $set =
$ilDB->query($q);
395 $note_rec =
$ilDB->fetchAssoc($set);
397 return $note_rec[
"creation_date"];
407 $ilDB = $DIC->database();
409 $q =
"SELECT * FROM note WHERE id = " .
410 $ilDB->quote((
int) $a_id,
"integer");
411 $set =
$ilDB->query($q);
412 $note_rec =
$ilDB->fetchAssoc($set);
414 return $note_rec[
"update_date"];
428 $a_repository_mode =
true,
429 $a_sort_ascending =
false 433 $ilDB = $DIC->database();
437 ?
" AND author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer")
440 $sub_where = (!$a_incl_sub)
441 ?
" AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
442 " AND obj_type = " .
$ilDB->quote((
string) $a_obj_type,
"text")
445 if (!$a_repository_mode) {
446 $sub_where .=
" AND no_repository = " .
$ilDB->quote(1,
"integer");
449 $q =
"SELECT * FROM note WHERE " .
450 " rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
452 " AND type = " .
$ilDB->quote((
int)
$a_type,
"integer") .
454 " ORDER BY creation_date ";
456 $q .= ((bool) $a_sort_ascending) ?
"ASC" :
"DESC";
458 $set =
$ilDB->query($q);
460 while ($note_rec =
$ilDB->fetchAssoc($set)) {
461 if ($a_filter !=
"") {
462 if (!is_array($a_filter)) {
463 $a_filter =
array($a_filter);
465 if (!in_array($note_rec[
"id"], $a_filter)) {
469 $cnt = count($notes);
470 $notes[$cnt] =
new ilNote();
471 $notes[$cnt]->setAllData($note_rec);
484 $ilDB = $DIC->database();
487 $q =
"SELECT * FROM note WHERE " .
489 " AND author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
490 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
491 " ORDER BY creation_date DESC";
494 $set =
$ilDB->query($q);
496 while ($note_rec =
$ilDB->fetchAssoc($set)) {
497 $cnt = count($notes);
498 $notes[$cnt] =
new ilNote();
499 $notes[$cnt]->setAllData($note_rec);
512 $ilDB = $DIC->database();
514 $tree = $DIC->repositoryTree();
517 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
519 " AND author = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
520 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
521 " ORDER BY rep_obj_id";
524 $set =
$ilDB->query($q);
526 while ($rep_rec =
$ilDB->fetchAssoc($set)) {
529 $reps[] =
array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
534 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
536 " AND author = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
537 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")" .
538 " ORDER BY rep_obj_id";
540 $set =
$ilDB->query($q);
542 while ($rep_rec =
$ilDB->fetchAssoc($set)) {
546 $reps[] =
array(
"rep_obj_id" => $rep_rec[
"rep_obj_id"]);
555 foreach ($dis as $di) {
556 $obj_ids[] = $di[
"obj_id"];
558 if (count($obj_ids) > 0) {
559 $q =
"SELECT DISTINCT rep_obj_id FROM note WHERE " .
560 $ilDB->in(
"rep_obj_id", $obj_ids,
false,
"integer") .
561 " AND (no_repository IS NULL OR no_repository < " .
$ilDB->quote(1,
"integer") .
")";
563 $set =
$ilDB->query($q);
564 while ($rec =
$ilDB->fetchAssoc($set)) {
567 foreach ($reps as
$r) {
568 if ($r[
"rep_obj_id"] == $rec[
"rep_obj_id"]) {
575 $reps[] =
array(
"rep_obj_id" => $rec[
"rep_obj_id"]);
585 foreach ($reps as $idx => $rep) {
586 $has_active_ref =
false;
591 $reps[$idx][
"ref_ids"] = array_values($ref_ids);
593 foreach ($ref_ids as $ref_id) {
594 if (!$tree->isDeleted($ref_id)) {
595 $has_active_ref =
true;
601 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
602 include_once
"Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
606 $reps[$idx][
"wsp_id"] = $node_id;
608 $has_active_ref =
true;
612 if (!$has_active_ref) {
632 $ilDB = $DIC->database();
634 $set =
$ilDB->queryF(
635 "SELECT count(DISTINCT author) cnt FROM note WHERE " .
636 "rep_obj_id = %s AND obj_id = %s AND obj_type = %s",
637 array(
"integer",
"integer",
"text"),
638 array((
int) $a_rep_obj_id, (
int) $a_obj_id, (
string)
$a_type)
640 $rec =
$ilDB->fetchAssoc($set);
641 return (
int) $rec[
"cnt"];
654 $ilDB = $DIC->database();
657 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
659 "author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
") OR " .
661 $ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer");
663 if ($a_no_sub_objs) {
664 $q .=
" AND obj_id = " .
$ilDB->quote(0,
"integer");
667 $q .=
" GROUP BY rep_obj_id, type ";
670 $set =
$ilDB->query($q);
671 while ($rec =
$ilDB->fetchAssoc($set)) {
672 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
688 $ilDB = $DIC->database();
691 $q =
"SELECT count(id) c, rep_obj_id, type FROM note WHERE " .
693 "author = " .
$ilDB->quote((
int)
$ilUser->getId(),
"integer") .
") OR " .
695 " rep_obj_id = " .
$ilDB->quote($a_rep_obj_id,
"integer");
697 if ($a_sub_obj_id !== null) {
698 $q .=
" AND obj_id = " .
$ilDB->quote($a_sub_obj_id,
"integer");
701 $q .=
" GROUP BY rep_obj_id, type ";
704 $set =
$ilDB->query($q);
705 while ($rec =
$ilDB->fetchAssoc($set)) {
706 $cnt[$rec[
"rep_obj_id"]][$rec[
"type"]] = $rec[
"c"];
718 public static function activateComments($a_rep_obj_id, $a_obj_id, $a_obj_type, $a_activate =
true)
722 $ilDB = $DIC->database();
724 if ($a_obj_type ==
"") {
728 "SELECT * FROM note_settings " .
729 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
730 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
731 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
733 if ($rec =
$ilDB->fetchAssoc($set)) {
734 if (($rec[
"activated"] == 0 && $a_activate) ||
735 ($rec[
"activated"] == 1 && !$a_activate)) {
737 "UPDATE note_settings SET " .
738 " activated = " .
$ilDB->quote((
int) $a_activate,
"integer") .
739 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
740 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
741 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
746 $q =
"INSERT INTO note_settings " .
747 "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
748 $ilDB->quote((
int) $a_rep_obj_id,
"integer") .
"," .
749 $ilDB->quote((
int) $a_obj_id,
"integer") .
"," .
750 $ilDB->quote($a_obj_type,
"text") .
"," .
751 $ilDB->quote(1,
"integer") .
753 $ilDB->manipulate($q);
768 $ilDB = $DIC->database();
770 if ($a_obj_type ==
"") {
774 "SELECT * FROM note_settings " .
775 " WHERE rep_obj_id = " .
$ilDB->quote((
int) $a_rep_obj_id,
"integer") .
776 " AND obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
777 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text")
779 $rec =
$ilDB->fetchAssoc($set);
780 return $rec[
"activated"];
793 $ilDB = $DIC->database();
795 $set =
$ilDB->query(
"SELECT * FROM note_settings " .
796 " WHERE " .
$ilDB->in(
"rep_obj_id", $a_rep_obj_ids,
false,
"integer") .
798 $activations =
array();
799 while ($rec =
$ilDB->fetchAssoc($set)) {
800 if ($rec[
"activated"]) {
801 $activations[$rec[
"rep_obj_id"]][$rec[
"obj_type"]] =
true;
822 $recipients =
$ilSetting->get(
"comments_noti_recip");
823 $recipients = explode(
",", $recipients);
833 $rep_obj_id = $obj[
"rep_obj_id"];
834 $sub_obj_id = $obj[
"obj_id"];
835 $type = $obj[
"obj_type"];
837 include_once(
"./Services/Language/classes/class.ilLanguageFactory.php");
838 include_once(
"./Services/User/classes/class.ilUserUtil.php");
839 include_once(
"./Services/Mail/classes/class.ilMail.php");
843 if (($sub_obj_id == 0 and
$type !=
"blp") ||
846 $type_lv =
"obj_" .
$type;
850 if (
$type ==
"wpg") {
851 $type_lv =
"obj_wiki";
856 if (
$type ==
"blp") {
858 $type_lv =
"obj_blog";
860 if (
$type ==
"pfpg") {
862 $type_lv =
"portfolio";
864 if (
$type ==
"dcl") {
866 $type_lv =
"obj_dcl";
869 include_once(
"./Services/Link/classes/class.ilLink.php");
870 foreach ($recipients as
$r) {
874 foreach ($ref_ids as $r) {
875 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $r)) {
876 if ($sub_obj_id == 0 and
$type !=
"blog") {
878 } elseif (
$type ==
"wpg") {
879 include_once(
"./Modules/Wiki/classes/class.ilWikiPage.php");
880 include_once(
"./Modules/Wiki/classes/class.ilWikiUtil.php");
888 } elseif (
$type ==
"pg") {
889 $link = ILIAS_HTTP_PATH .
'/goto.php?client_id=' . CLIENT_ID .
"&target=pg_" . $sub_obj_id .
"_" .
$r;
893 if (
$type ==
"blp") {
896 if (
$type ==
"pfpg") {
897 $link = ILIAS_HTTP_PATH .
'/goto.php?client_id=' . CLIENT_ID .
"&target=prtf_" . $rep_obj_id;
902 $ulng->loadLanguageModule(
'note');
905 $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";
916 $message .= $ulng->txt(
'note_comment_notification_link') .
": " . $link .
"\n\n";
919 $message .= $ulng->txt(
'note_comment_notification_reason') .
"\n\n";
921 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
922 $mail_obj->appendInstallationSignature(
true);
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 _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.
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 _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.
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 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 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:
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
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
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.