ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Blog\Notification\NotificationManager Class Reference
+ Collaboration diagram for ILIAS\Blog\Notification\NotificationManager:

Public Member Functions

 __construct (protected InternalDomainService $domain)
 
 sendNotification (string $action, bool $in_wsp, int $blog_node_id, int $posting_id, ?string $comment=null)
 

Protected Member Functions

 getBlogObjectId (bool $in_wsp, int $blog_node_id)
 
 sendSystemNotification (bool $in_wsp, int $blog_node_id, string $action, \ilBlogPosting $posting, ?string $comment, array $users, bool $admin_only)
 

Protected Attributes

int $current_user_id
 

Detailed Description

Definition at line 25 of file NotificationManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Blog\Notification\NotificationManager::__construct ( protected InternalDomainService  $domain)

Definition at line 29 of file NotificationManager.php.

31 {
32 $this->current_user_id = $this->domain->user()->getId();
33 }

Member Function Documentation

◆ getBlogObjectId()

ILIAS\Blog\Notification\NotificationManager::getBlogObjectId ( bool  $in_wsp,
int  $blog_node_id 
)
protected

Definition at line 102 of file NotificationManager.php.

102 : ?int
103 {
104 if ($in_wsp) {
105 $tree = new \ilWorkspaceTree($this->current_user_id);
106 return $tree->lookupObjectId($blog_node_id);
107 } else {
108 return \ilObject::_lookupObjId($blog_node_id);
109 }
110 }

◆ sendNotification()

ILIAS\Blog\Notification\NotificationManager::sendNotification ( string  $action,
bool  $in_wsp,
int  $blog_node_id,
int  $posting_id,
?string  $comment = null 
)

Definition at line 35 of file NotificationManager.php.

41 : void {
42 $blog_obj_id = $this->getBlogObjectId($in_wsp, $blog_node_id);
43 if (!$blog_obj_id) {
44 return;
45 }
46
47 $posting = new \ilBlogPosting($posting_id);
48
49 $ignore_threshold = ($action === "comment");
50 $admin_only = false;
51
52 if (!$posting->isApproved()) {
53 $blog_settings = $this->domain->blogSettings()->getByObjId($blog_obj_id);
54 if ($blog_settings?->getApproval()) {
55 switch ($action) {
56 case "update":
57 return;
58
59 case "new":
60 $admin_only = true;
61 $ignore_threshold = true;
62 $action = "approve";
63 break;
64 }
65 }
66 }
67
68 if (!$in_wsp && in_array($action, array("update", "new"))) {
69 $this->domain->news()->handle($posting, ($action === "update"));
70 }
71
74 $blog_obj_id,
75 $posting_id,
76 $ignore_threshold
77 );
78 if (!count($users)) {
79 return;
80 }
81
83 $in_wsp,
84 $blog_node_id,
85 $action,
86 $posting,
88 $users,
89 $admin_only
90 );
91
92 if (count($users)) {
95 $blog_obj_id,
96 $users,
97 $posting_id
98 );
99 }
100 }
$comment
Definition: buildRTE.php:72
sendSystemNotification(bool $in_wsp, int $blog_node_id, string $action, \ilBlogPosting $posting, ?string $comment, array $users, bool $admin_only)
getBlogObjectId(bool $in_wsp, int $blog_node_id)
static updateNotificationTime(int $type, int $id, array $user_ids, ?int $page_id=null, bool $activate_new_entries=true)
Update the last mail timestamp for given object and users.
static getNotificationsForObject(int $type, int $id, ?int $page_id=null, bool $ignore_threshold=false)
Get all users/recipients for given object.

◆ sendSystemNotification()

ILIAS\Blog\Notification\NotificationManager::sendSystemNotification ( bool  $in_wsp,
int  $blog_node_id,
string  $action,
\ilBlogPosting  $posting,
?string  $comment,
array  $users,
bool  $admin_only 
)
protected

Definition at line 112 of file NotificationManager.php.

120 : void {
121 $ntf = new \ilSystemNotification($in_wsp);
122 $ntf->setLangModules(array("blog"));
123 $ntf->setRefId($blog_node_id);
124 $ntf->setChangedByUserId($this->current_user_id);
125 $ntf->setSubjectLangId('blog_change_notification_subject');
126 $ntf->setIntroductionLangId('blog_change_notification_body_' . $action);
127 $ntf->addAdditionalInfo('blog_posting', $posting->getTitle());
128
129 if ($comment) {
130 $ntf->addAdditionalInfo('comment', $comment, true);
131 }
132
133 $ntf->setGotoLangId('blog_change_notification_link');
134 $ntf->setReasonLangId('blog_change_notification_reason');
135
136 $abstract = $posting->getNotificationAbstract();
137 if ($abstract) {
138 $ntf->addAdditionalInfo('content', $abstract, true);
139 }
140
141 $notified = $ntf->sendMailAndReturnRecipients(
142 $users,
143 "_" . $posting->getId(),
144 ($admin_only ? "write" : "read")
145 );
146
147 if (count($notified)) {
150 $posting->getBlogId(),
151 $notified,
152 $posting->getId()
153 );
154 }
155 }

References $comment.

Field Documentation

◆ $current_user_id

int ILIAS\Blog\Notification\NotificationManager::$current_user_id
protected

Definition at line 27 of file NotificationManager.php.


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