ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Notes\NotificationsManager Class Reference
+ Collaboration diagram for ILIAS\Notes\NotificationsManager:

Public Member Functions

 __construct (InternalDataService $data, InternalRepoService $repo, InternalDomainService $domain)
 
 sendNotifications (Note $note, bool $a_changed=false)
 Sends all comments to a list of accounts configured in the global administration. More...
 
 notifyObserver (array $observer, string $action, Note $note)
 Notify observers on update/create. More...
 

Protected Attributes

ilAccessHandler $access
 
ilSetting $settings
 
InternalDomainService $domain
 
InternalRepoService $repo
 
InternalDataService $data
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 26 of file class.NotificationsManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notes\NotificationsManager::__construct ( InternalDataService  $data,
InternalRepoService  $repo,
InternalDomainService  $domain 
)

Definition at line 34 of file class.NotificationsManager.php.

References ILIAS\Notes\NotificationsManager\$data, ILIAS\Notes\NotificationsManager\$domain, ILIAS\Notes\NotificationsManager\$repo, ILIAS\Repository\access(), and ILIAS\Repository\settings().

38  {
39  $this->data = $data;
40  $this->repo = $repo;
41  $this->domain = $domain;
42  $this->settings = $domain->settings();
43  $this->access = $domain->access();
44  }
+ Here is the call graph for this function:

Member Function Documentation

◆ notifyObserver()

ILIAS\Notes\NotificationsManager::notifyObserver ( array  $observer,
string  $action,
Note  $note 
)

Notify observers on update/create.

Definition at line 174 of file class.NotificationsManager.php.

References $context, $param, ILIAS\Notes\Note\getContext(), and ILIAS\Notes\Note\getId().

178  : void {
179  foreach ($observer as $item) {
180  $context = $note->getContext();
181  $param[] = $context->getObjId();
182  $param[] = $context->getSubObjId();
183  $param[] = $context->getType();
184  $param[] = $action;
185  $param[] = $note->getId();
186  call_user_func_array($item, $param);
187  }
188  }
$context
Definition: webdav.php:29
$param
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ sendNotifications()

ILIAS\Notes\NotificationsManager::sendNotifications ( Note  $note,
bool  $a_changed = false 
)

Sends all comments to a list of accounts configured in the global administration.

Todo:
: get rid of object type specific code

Definition at line 51 of file class.NotificationsManager.php.

References ILIAS\Notes\NotificationsManager\$access, $context, $message, $ref_id, ILIAS\Notes\NotificationsManager\$settings, ilObject\_getAllReferences(), ilLanguageFactory\_getLanguageOfUser(), ilLink\_getLink(), ilLink\_getStaticLink(), ilObjUser\_lookupFullname(), ilObjUser\_lookupId(), ilObjUser\_lookupLogin(), ilObject\_lookupTitle(), ANONYMOUS_USER_ID, CLIENT_ID, ILIAS\Notes\Note\getAuthor(), ILIAS\Notes\Note\getContext(), ilUserUtil\getNamePresentation(), ILIAS\Notes\Note\getText(), ILIAS\Notes\Note\getType(), ilWikiPage\lookupTitle(), ilWikiUtil\makeUrlTitle(), and ILIAS\Notes\Note\PRIVATE.

54  : void {
57 
58  $obj_title = "";
59  $type_lv = "";
60 
61  // no notifications for notes
62  if ($note->getType() === Note::PRIVATE) {
63  return;
64  }
65 
66  $recipients = $settings->get("comments_noti_recip", '');
67  $recipients = explode(",", $recipients);
68 
69  // blog: blog_id, 0, "blog"
70  // lm: lm_id, page_id, "pg" (ok)
71  // sahs: sahs_id, node_id, node_type
72  // info_screen: obj_id, 0, obj_type (ok)
73  // portfolio: port_id, page_id, "portfolio_page" (ok)
74  // wiki: wiki_id, wiki_page_id, "wpg" (ok)
75 
76  $context = $note->getContext();
77  $rep_obj_id = $context->getObjId();
78  $sub_obj_id = $context->getSubObjId();
79  $obj_type = $context->getType();
80 
81  // repository objects, no blogs
82  $ref_ids = array();
83  if (($sub_obj_id === 0 && $obj_type !== "blp") || in_array($obj_type, array("pg", "wpg"), true)) {
84  $obj_title = \ilObject::_lookupTitle($rep_obj_id);
85  $type_lv = "obj_" . $obj_type;
86  $ref_ids = \ilObject::_getAllReferences($rep_obj_id);
87  }
88 
89  if ($obj_type === "wpg") {
90  $type_lv = "obj_wiki";
91  }
92  if ($obj_type === "pg") {
93  $type_lv = "obj_lm";
94  }
95  if ($obj_type === "blp") {
96  $obj_title = \ilObject::_lookupTitle($rep_obj_id);
97  $type_lv = "obj_blog";
98  }
99  if ($obj_type === "pfpg") {
100  $obj_title = \ilObject::_lookupTitle($rep_obj_id);
101  $type_lv = "portfolio";
102  }
103  if ($obj_type === "dcl") {
104  $obj_title = \ilObject::_lookupTitle($rep_obj_id);
105  $type_lv = "obj_dcl";
106  }
107 
108  foreach ($recipients as $r) {
109  $login = trim($r);
110  if (($user_id = \ilObjUser::_lookupId($login)) > 0) {
111  $link = "";
112  foreach ($ref_ids as $ref_id) {
113  if ($access->checkAccessOfUser($user_id, "read", "", $ref_id)) {
114  if ($sub_obj_id === 0 && $obj_type !== "blog") {
115  $link = \ilLink::_getLink($ref_id);
116  } elseif ($obj_type === "wpg") {
117  $title = \ilWikiPage::lookupTitle($sub_obj_id);
118  $link = \ilLink::_getStaticLink(
119  $ref_id,
120  "wiki",
121  true,
122  "_" . \ilWikiUtil::makeUrlTitle($title)
123  );
124  } elseif ($obj_type === "pg") {
125  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=pg_" . $sub_obj_id . "_" . $ref_id;
126  }
127  }
128  }
129  if ($obj_type === "blp") {
130  // todo
131  }
132  if ($obj_type === "pfpg") {
133  $link = ILIAS_HTTP_PATH . '/goto.php?client_id=' . CLIENT_ID . "&target=prtf_" . $rep_obj_id;
134  }
135 
136  // use language of recipient to compose message
137  $ulng = \ilLanguageFactory::_getLanguageOfUser($user_id);
138  $ulng->loadLanguageModule('note');
139 
140  if ($a_changed) {
141  $subject = sprintf($ulng->txt('note_comment_notification_subjectc'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
142  } else {
143  $subject = sprintf($ulng->txt('note_comment_notification_subject'), $obj_title . " (" . $ulng->txt($type_lv) . ")");
144  }
145  $message = sprintf($ulng->txt('note_comment_notification_salutation'), \ilObjUser::_lookupFullname($user_id)) . "\n\n";
146 
147  $message .= sprintf($ulng->txt('note_comment_notification_user_has_written'), \ilUserUtil::getNamePresentation($note->getAuthor())) . "\n\n";
148 
149  $message .= $note->getText() . "\n\n";
150 
151  if ($link !== "") {
152  $message .= $ulng->txt('note_comment_notification_link') . ": " . $link . "\n\n";
153  }
154 
155  $message .= $ulng->txt('note_comment_notification_reason') . "\n\n";
156 
157  $mail_obj = new \ilMail(ANONYMOUS_USER_ID);
158  $mail_obj->appendInstallationSignature(true);
159  $mail_obj->enqueue(
160  \ilObjUser::_lookupLogin($user_id),
161  "",
162  "",
163  $subject,
164  $message,
165  array()
166  );
167  }
168  }
169  }
$context
Definition: webdav.php:29
get(string $a_keyword, ?string $a_default_value=null)
get setting
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static _lookupFullname(int $a_user_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupId($a_user_str)
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
const CLIENT_ID
Definition: constants.php:41
static lookupTitle(int $a_page_id)
static makeUrlTitle(string $a_par)
$message
Definition: xapiexit.php:32
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance) ...
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ILIAS\Notes\NotificationsManager::$access
protected

◆ $data

InternalDataService ILIAS\Notes\NotificationsManager::$data
protected

◆ $domain

InternalDomainService ILIAS\Notes\NotificationsManager::$domain
protected

◆ $repo

InternalRepoService ILIAS\Notes\NotificationsManager::$repo
protected

◆ $settings

ilSetting ILIAS\Notes\NotificationsManager::$settings
protected

The documentation for this class was generated from the following file: