19 declare(strict_types=1);
49 $this->db = $DIC->database();
50 $this->
access = $DIC->access();
51 $this->
user = $DIC->user();
52 $this->tree = $DIC->repositoryTree();
74 return $this->objPost->getThreadId();
79 return $this->objPost->getId();
94 return $this->closest_container !== null;
109 return $this->objPost->getSubject();
114 return $this->objPost->getMessage();
119 return $this->objPost->getDisplayUserId();
124 return $this->objPost->getCreateDate();
129 return $this->objPost->getChangeDate();
134 return $this->objPost->isCensored();
139 return $this->objPost->getCensoredDate();
144 return $this->objPost->getCensorshipComment();
154 return $this->objPost->getUserAlias();
164 return $this->objPost->getImportName();
169 return $this->objPost->getUpdateUserId();
174 if ($this->post_user_name === null) {
191 if ($this->update_user_name === null) {
204 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() === 0
205 && $this->objPost->getPosAuthorId() === $this->objPost->getUpdateUserId()) {
206 return $this->objPost->getUserAlias();
227 protected function read(): void
236 $cacheKey = $this->notificationCache->createKeyByValues([
241 if (
false === $this->notificationCache->exists($cacheKey)) {
242 $result = $this->db->queryF(
244 SELECT thr_subject FROM frm_threads 247 [$this->objPost->getThreadId()]
250 $row = $this->db->fetchAssoc($result);
251 $this->notificationCache->store($cacheKey, $row);
254 $row = $this->notificationCache->fetch($cacheKey);
255 $this->thread_title = $row[
'thr_subject'];
260 $cacheKey = $this->notificationCache->createKeyByValues([
265 if (
false === $this->notificationCache->exists($cacheKey)) {
266 $result = $this->db->queryF(
268 SELECT top_pk, top_name, frm_settings.anonymized FROM frm_data 269 INNER JOIN frm_settings ON top_frm_fk = frm_settings.obj_id 270 WHERE top_frm_fk = %s',
275 $row = $this->db->fetchAssoc($result);
282 $this->notificationCache->store($cacheKey, $row);
285 $row = $row ?? $this->notificationCache->fetch($cacheKey);
286 $this->forum_id = (
int) $row[
'top_pk'];
287 $this->forum_title = (string) $row[
'top_name'];
288 $this->closest_container = $row[
'closest_container'] ?? null;
290 $this->is_anonymized = (bool) $row[
'anonymized'];
295 $cacheKey = $this->notificationCache->createKeyByValues([
300 if (
false === $this->notificationCache->exists($cacheKey)) {
301 $ref_id = $this->tree->checkForParentType($frm_ref_id,
'crs');
302 if (!($ref_id > 0)) {
303 $ref_id = $this->tree->checkForParentType($frm_ref_id,
'grp');
308 $this->notificationCache->store($cacheKey,
$container);
324 foreach ($filesOfPost as $attachment) {
325 $this->attachments[$attachment[
'path']] = $attachment[
'name'];
326 $fileDataMail->copyAttachmentFile($attachment[
'path'], $attachment[
'name']);
338 $cacheKey = $this->notificationCache->createKeyByValues([
345 if (
false === $this->notificationCache->exists($cacheKey)) {
347 if ($event_type === 0) {
348 $condition =
' OR frm_notification.interested_events >= ' . $this->db->quote(0,
'integer');
351 $res = $this->db->queryF(
353 SELECT frm_notification.user_id FROM frm_notification, frm_data 354 WHERE frm_data.top_pk = %s 355 AND frm_notification.frm_id = frm_data.top_frm_fk 356 AND frm_notification.user_id != %s 357 AND (frm_notification.interested_events & %s ' . $condition .
') 358 GROUP BY frm_notification.user_id ',
359 [
'integer',
'integer',
'integer'],
364 $this->notificationCache->store($cacheKey, $rcps);
367 $rcps = $this->notificationCache->fetch($cacheKey);
369 return array_unique($rcps);
383 $cacheKey = $this->notificationCache->createKeyByValues([
390 if (
false === $this->notificationCache->exists($cacheKey)) {
392 if ($event_type === 0) {
393 $condition =
' OR interested_events >= ' . $this->db->quote(0,
'integer');
396 $res = $this->db->queryF(
398 SELECT frm_notification.user_id 399 FROM frm_notification 400 INNER JOIN frm_threads ON frm_threads.thr_pk = frm_notification.thread_id 401 WHERE frm_notification.thread_id = %s 402 AND frm_notification.user_id != %s 403 AND (frm_notification.interested_events & %s ' . $condition .
')',
404 [
'integer',
'integer',
'integer'],
409 $this->notificationCache->store($cacheKey, $usrIds);
412 return (array) $this->notificationCache->fetch($cacheKey);
418 public function getPostAnsweredRecipients(): array
420 $cacheKey = $this->notificationCache->createKeyByValues([
422 $this->objPost->getParentId()
425 if (
false === $this->notificationCache->exists($cacheKey)) {
426 $parent_objPost =
new ilForumPost($this->objPost->getParentId());
428 $this->notificationCache->store($cacheKey, $parent_objPost);
432 $parent_objPost = $this->notificationCache->fetch($cacheKey);
444 $cacheKey = $this->notificationCache->createKeyByValues([
449 if (
false === $this->notificationCache->exists($cacheKey)) {
452 $this->notificationCache->store($cacheKey, $rcps);
455 $rcps = $this->notificationCache->fetch($cacheKey);
457 return (array) $rcps;
476 $cacheKey = $this->notificationCache->createKeyByValues([
481 if (!$this->notificationCache->exists($cacheKey)) {
485 return $this->notificationCache->fetch($cacheKey);
497 while ($row = $this->db->fetchAssoc($statement)) {
498 foreach ($refIds as
$refId) {
499 if ($this->
access->checkAccessOfUser((
int) $row[
'user_id'],
'read',
'', $refId)) {
500 $usrIds[] = (
int) $row[
'user_id'];
510 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() === 0
511 && $this->objPost->getPosAuthorId() === $this->
user->getId()) {
512 return $this->objPost->getUserAlias();
515 return $this->
user->getLogin();
521 switch ($notification_type) {
getPostUserName(ilLanguage $user_lang)
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
getRefIdsByObjId(int $objId)
createRecipientArray(ilDBStatement $statement)
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _getAllReferences(int $id)
get all reference ids for object ID
getPostActivationRecipients()
getThreadNotificationRecipients(int $notification_type)
setPosAuthorId(int $pos_author_id)
const TYPE_THREAD_DELETED
Class ilForumNotificationDataProvider.
getPostUpdateUserName(ilLanguage $user_lang)
static _lookupObjId(int $ref_id)
getForumNotificationRecipients(int $notification_type)
determineClosestContainer(int $frm_ref_id)
getEventType(int $notification_type)
static isSendAttachmentsByMailEnabled()
providesClosestContainer()
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilForumNotificationCache.
ilForumNotificationCache $notificationCache
Interface ilForumNotificationMailData.
ilObject $closest_container
This class handles all operations on files for the forum object.
static _getModerators(int $a_ref_id)
__construct(ilForumPost $objPost, int $ref_id, ilForumNotificationCache $notificationCache)
const TYPE_POST_UNCENSORED