19 declare(strict_types=1);
50 $this->db = $DIC->database();
51 $this->
access = $DIC->access();
52 $this->
user = $DIC->user();
53 $this->tree = $DIC->repositoryTree();
70 return $this->objPost->getThreadId();
75 return $this->objPost->getId();
90 return $this->closest_container !==
null;
105 return $this->objPost->getSubject();
110 return $this->objPost->getMessage();
115 return $this->objPost->getDisplayUserId();
120 return $this->objPost->getCreateDate();
125 return $this->objPost->getChangeDate();
130 return $this->objPost->isCensored();
135 return $this->objPost->getCensoredDate();
140 return $this->objPost->getCensorshipComment();
153 return $this->objPost->getUserAlias();
163 return $this->objPost->getImportName();
168 return $this->objPost->getUpdateUserId();
173 if ($this->post_user_name ===
null) {
190 if ($this->update_user_name ===
null) {
203 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() === 0
204 && $this->objPost->getPosAuthorId() === $this->objPost->getUpdateUserId()) {
205 return $this->objPost->getUserAlias();
226 protected function read(): void
235 $cacheKey = $this->notificationCache->createKeyByValues([
240 if (!$this->notificationCache->exists($cacheKey)) {
241 $result = $this->db->queryF(
243 SELECT thr_subject FROM frm_threads 246 [$this->objPost->getThreadId()]
249 $row = $this->db->fetchAssoc($result);
250 $this->notificationCache->store($cacheKey, $row);
253 $row = $this->notificationCache->fetch($cacheKey);
254 $this->thread_title = $row[
'thr_subject'];
259 $cacheKey = $this->notificationCache->createKeyByValues([
264 if (!$this->notificationCache->exists($cacheKey)) {
265 $result = $this->db->queryF(
267 SELECT top_pk, top_name, frm_settings.anonymized FROM frm_data 268 INNER JOIN frm_settings ON top_frm_fk = frm_settings.obj_id 269 WHERE top_frm_fk = %s',
274 $row = $this->db->fetchAssoc($result);
281 $this->notificationCache->store($cacheKey, $row);
284 $row ??= $this->notificationCache->fetch($cacheKey);
285 $this->forum_id = (
int) $row[
'top_pk'];
286 $this->forum_title = (string) $row[
'top_name'];
287 $this->closest_container = $row[
'closest_container'] ??
null;
289 $this->is_anonymized = (bool) $row[
'anonymized'];
294 $cacheKey = $this->notificationCache->createKeyByValues([
299 if (!$this->notificationCache->exists($cacheKey)) {
300 $ref_id = $this->tree->checkForParentType($frm_ref_id,
'crs');
302 $ref_id = $this->tree->checkForParentType($frm_ref_id,
'grp');
307 $this->notificationCache->store($cacheKey,
$container);
323 foreach ($filesOfPost as $attachment) {
324 $this->attachments[$attachment[
'path']] = $attachment[
'name'];
325 $fileDataMail->copyAttachmentFile($attachment[
'path'], $attachment[
'name']);
336 $cacheKey = $this->notificationCache->createKeyByValues([
343 if (!$this->notificationCache->exists($cacheKey)) {
345 if ($event_type === 0) {
346 $condition =
' OR frm_notification.interested_events >= ' . $this->db->quote(0,
'integer');
349 $res = $this->db->queryF(
351 SELECT frm_notification.user_id FROM frm_notification, frm_data 352 WHERE frm_data.top_pk = %s 353 AND frm_notification.frm_id = frm_data.top_frm_fk 354 AND frm_notification.user_id != %s 355 AND (frm_notification.interested_events & %s ' . $condition .
') 356 GROUP BY frm_notification.user_id ',
357 [
'integer',
'integer',
'integer'],
362 $this->notificationCache->store($cacheKey, $rcps);
365 $rcps = $this->notificationCache->fetch($cacheKey);
367 return array_unique($rcps);
380 $cacheKey = $this->notificationCache->createKeyByValues([
387 if (!$this->notificationCache->exists($cacheKey)) {
389 if ($event_type === 0) {
390 $condition =
' OR interested_events >= ' . $this->db->quote(0,
'integer');
393 $res = $this->db->queryF(
395 SELECT frm_notification.user_id 396 FROM frm_notification 397 INNER JOIN frm_threads ON frm_threads.thr_pk = frm_notification.thread_id 398 WHERE frm_notification.thread_id = %s 399 AND frm_notification.user_id != %s 400 AND (frm_notification.interested_events & %s ' . $condition .
')',
401 [
'integer',
'integer',
'integer'],
406 $this->notificationCache->store($cacheKey, $usrIds);
409 return (array) $this->notificationCache->fetch($cacheKey);
415 public function getPostAnsweredRecipients(): array
417 $cacheKey = $this->notificationCache->createKeyByValues([
419 $this->objPost->getParentId()
422 if (!$this->notificationCache->exists($cacheKey)) {
423 $parent_objPost =
new ilForumPost($this->objPost->getParentId());
425 $this->notificationCache->store($cacheKey, $parent_objPost);
429 $parent_objPost = $this->notificationCache->fetch($cacheKey);
441 $cacheKey = $this->notificationCache->createKeyByValues([
446 if (!$this->notificationCache->exists($cacheKey)) {
449 $this->notificationCache->store($cacheKey, $rcps);
452 $rcps = $this->notificationCache->fetch($cacheKey);
454 return (array) $rcps;
467 $cacheKey = $this->notificationCache->createKeyByValues([
472 if (!$this->notificationCache->exists($cacheKey)) {
476 return $this->notificationCache->fetch($cacheKey);
487 while ($row = $this->db->fetchAssoc($statement)) {
488 foreach ($refIds as
$refId) {
489 if ($this->
access->checkAccessOfUser((
int) $row[
'user_id'],
'read',
'', $refId)) {
490 $usrIds[] = (
int) $row[
'user_id'];
500 if ($this->objPost->getUserAlias() && $this->objPost->getDisplayUserId() === 0
501 && $this->objPost->getPosAuthorId() === $this->
user->getId()) {
502 return $this->objPost->getUserAlias();
505 return $this->
user->getLogin();
510 return match ($notification_type) {
getPostUserName(ilLanguage $user_lang)
getPublicUserInformation(ilForumAuthorInformation $authorinfo)
getRefIdsByObjId(int $objId)
createRecipientArray(ilDBStatement $statement)
readonly ilDBInterface $db
readonly ilAccessHandler $access
This class handles all operations on files (attachments) in directory ilias_data/mail.
__construct(public ilForumPost $objPost, protected int $ref_id, private readonly ilForumNotificationCache $notificationCache)
static _getAllReferences(int $id)
get all reference ids for object ID
getPostActivationRecipients()
getThreadNotificationRecipients(int $notification_type)
const TYPE_THREAD_DELETED
Class ilForumNotificationDataProvider.
getPostUpdateUserName(ilLanguage $user_lang)
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
Interface ilForumNotificationMailData.
ilObject $closest_container
static _getModerators(int $a_ref_id)
const TYPE_POST_UNCENSORED