ILIAS  release_8 Revision v8.24
ILIAS\Notifications\ilNotificationSystem Class Reference
+ Collaboration diagram for ILIAS\Notifications\ilNotificationSystem:

Public Member Functions

 __construct (ilRbacReview $rbacReview=null)
 
 toUsers (ilNotificationConfig $notification, array $users, bool $processAsync=false)
 
 clear (string $channel='')
 

Static Public Member Functions

static sendNotificationToUsers (ilNotificationConfig $notification, array $users, bool $processAsync=false)
 
static sendNotificationToListeners (ilNotificationConfig $notification, int $ref_id, bool $processAsync=false)
 
static sendNotificationToRoles (ilNotificationConfig $notification, array $roles, bool $processAsync=false)
 
static enableListeners (string $module, int $ref_id)
 
static enableUserListeners (string $module, int $ref_id, array $users)
 

Private Member Functions

 addHandler (string $channel, ilNotificationHandler $handler)
 
 toListeners (ilNotificationConfig $notification, int $ref_id, bool $processAsync=false)
 
 toRoles (ilNotificationConfig $notification, array $roles, bool $processAsync=false)
 

Private Attributes

array $handler = []
 
string $defaultLanguage = 'en'
 
ilRbacReview $rbacReview
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Notifications\ilNotificationSystem::__construct ( ilRbacReview  $rbacReview = null)

Definition at line 40 of file ilNotificationSystem.php.

41 {
42 $this->addHandler('osd', new ilNotificationOSDHandler());
43 $this->addHandler('mail', new ilNotificationMailHandler());
44 if ($rbacReview === null) {
45 global $DIC;
46 $rbacReview = $DIC->rbac()->review();
47 }
48 $this->rbacReview = $rbacReview;
49 }
addHandler(string $channel, ilNotificationHandler $handler)
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Notifications\ilNotificationSystem\$rbacReview, and ILIAS\Notifications\ilNotificationSystem\addHandler().

+ Here is the call graph for this function:

Member Function Documentation

◆ addHandler()

ILIAS\Notifications\ilNotificationSystem::addHandler ( string  $channel,
ilNotificationHandler  $handler 
)
private

Definition at line 52 of file ilNotificationSystem.php.

52 : void
53 {
54 if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
55 $this->handler[$channel] = [];
56 }
57
58 $this->handler[$channel][] = $handler;
59 }

References ILIAS\Notifications\ilNotificationSystem\$handler.

Referenced by ILIAS\Notifications\ilNotificationSystem\__construct().

+ Here is the caller graph for this function:

◆ clear()

ILIAS\Notifications\ilNotificationSystem::clear ( string  $channel = '')

Definition at line 188 of file ilNotificationSystem.php.

188 : void
189 {
190 $channels = $this->handler;
191 if ($channel !== '') {
192 $channels = [$this->handler[$channel]] ?? [];
193 }
194 foreach ($channels as $c) {
195 foreach ($c as $handler) {
196 $handler->clear();
197 }
198 }
199 }
$c
Definition: cli.php:38

References $c, and ILIAS\Notifications\ilNotificationSystem\$handler.

◆ enableListeners()

static ILIAS\Notifications\ilNotificationSystem::enableListeners ( string  $module,
int  $ref_id 
)
static

Definition at line 176 of file ilNotificationSystem.php.

176 : void
177 {
179 }
static enableListeners(string $module, $sender_id, array $users=[])
$ref_id
Definition: ltiauth.php:67

References $ref_id, and ILIAS\Notifications\ilNotificationDatabaseHandler\enableListeners().

+ Here is the call graph for this function:

◆ enableUserListeners()

static ILIAS\Notifications\ilNotificationSystem::enableUserListeners ( string  $module,
int  $ref_id,
array  $users 
)
static

Definition at line 181 of file ilNotificationSystem.php.

181 : void
182 {
183 if ($users) {
185 }
186 }

References $ref_id, and ILIAS\Notifications\ilNotificationDatabaseHandler\enableListeners().

+ Here is the call graph for this function:

◆ sendNotificationToListeners()

static ILIAS\Notifications\ilNotificationSystem::sendNotificationToListeners ( ilNotificationConfig  $notification,
int  $ref_id,
bool  $processAsync = false 
)
static

Definition at line 161 of file ilNotificationSystem.php.

161 : void
162 {
163 global $DIC;
164 $DIC->notifications()->system()->toListeners($notification, $ref_id, $processAsync);
165 }

References $DIC, and $ref_id.

Referenced by ILIAS\Notifications\Model\ilNotificationConfig\notifyByListeners().

+ Here is the caller graph for this function:

◆ sendNotificationToRoles()

static ILIAS\Notifications\ilNotificationSystem::sendNotificationToRoles ( ilNotificationConfig  $notification,
array  $roles,
bool  $processAsync = false 
)
static
Parameters
int[]$roles

Definition at line 170 of file ilNotificationSystem.php.

170 : void
171 {
172 global $DIC;
173 $DIC->notifications()->system()->toRoles($notification, $roles, $processAsync);
174 }

References $DIC.

Referenced by ILIAS\Notifications\Model\ilNotificationConfig\notifyByRoles().

+ Here is the caller graph for this function:

◆ sendNotificationToUsers()

static ILIAS\Notifications\ilNotificationSystem::sendNotificationToUsers ( ilNotificationConfig  $notification,
array  $users,
bool  $processAsync = false 
)
static
Deprecated:
Parameters
int[]$users

Definition at line 155 of file ilNotificationSystem.php.

155 : void
156 {
157 global $DIC;
158 $DIC->notifications()->system()->toUsers($notification, $users, $processAsync);
159 }

References $DIC.

Referenced by ILIAS\Notifications\Model\ilNotificationConfig\notifyByUsers().

+ Here is the caller graph for this function:

◆ toListeners()

ILIAS\Notifications\ilNotificationSystem::toListeners ( ilNotificationConfig  $notification,
int  $ref_id,
bool  $processAsync = false 
)
private

Definition at line 125 of file ilNotificationSystem.php.

125 : void
126 {
127 if ($processAsync === false) {
129 if ($notification->hasDisableAfterDeliverySet()) {
131 }
132 } else {
134 }
135 }
static enqueueByListener(ilNotificationConfig $notification, int $ref_id)

References $ref_id, ILIAS\Notifications\ilNotificationDatabaseHandler\disableListeners(), ILIAS\Notifications\ilNotificationDatabaseHandler\enqueueByListener(), ILIAS\Notifications\Model\ilNotificationConfig\getType(), ILIAS\Notifications\ilNotificationDatabaseHandler\getUsersByListener(), and ILIAS\Notifications\Model\ilNotificationConfig\hasDisableAfterDeliverySet().

+ Here is the call graph for this function:

◆ toRoles()

ILIAS\Notifications\ilNotificationSystem::toRoles ( ilNotificationConfig  $notification,
array  $roles,
bool  $processAsync = false 
)
private
Parameters
int[]$roles

Definition at line 140 of file ilNotificationSystem.php.

140 : void
141 {
142 $users = [];
143 foreach ($roles as $role) {
144 $users[] = $this->rbacReview->assignedUsers($role);
145 }
146 $users = array_unique(array_merge(...$users));
147
148 $this->toUsers($notification, $users, $processAsync);
149 }
toUsers(ilNotificationConfig $notification, array $users, bool $processAsync=false)

References ILIAS\Notifications\ilNotificationSystem\toUsers().

+ Here is the call graph for this function:

◆ toUsers()

ILIAS\Notifications\ilNotificationSystem::toUsers ( ilNotificationConfig  $notification,
array  $users,
bool  $processAsync = false 
)
Parameters
int[]$users

Definition at line 64 of file ilNotificationSystem.php.

64 : void
65 {
66 if ($processAsync === false) {
68 $usersWithCustomConfig = ilNotificationDatabaseHandler::getUsersWithCustomConfig($users);
72
73 $user_by_handler = [];
74 if (isset($types[$notification->getType()]['config_type'])) {
75 if ($types[$notification->getType()]['config_type'] === 'set_by_user') {
76 $it = new ilNotificationUserIterator($notification->getType(), $users);
77 $channelsByAdmin = false;
78 foreach ($it as $usr_id => $data) {
79 if (!isset($channels['channel']) || !$channels[$data['channel']]) {
80 continue;
81 }
82 if (!isset($user_by_handler[$data['channel']]) || !$user_by_handler[$data['channel']]) {
83 $user_by_handler[$data['channel']] = [];
84 }
85 $user_by_handler[$data['channel']][] = $usr_id;
86 }
87 } elseif ($types[$notification->getType()]['config_type'] !== 'disabled') {
88 $channelsByAdmin = true;
89 if (isset($adminConfig[$notification->getType()])) {
90 foreach ($adminConfig[$notification->getType()] as $channel) {
91 if (!isset($channels[$channel]) || !$channels[$channel]) {
92 continue;
93 }
94 $user_by_handler[$channel] = $users;
95 }
96 }
97 }
98 }
99
100 $userCache = [];
101
102 foreach ($user_by_handler as $handler => $h_users) {
103 $handler = $this->handler[$handler];
104 foreach ($h_users as $userId) {
105 if (!isset($userCache[$userId]) || !$userCache[$userId]) {
106 $user = ilObjectFactory::getInstanceByObjId($userId, false);
107 if (!($user instanceof ilObjUser)) {
108 continue;
109 }
110 $userCache[$userId] = $user;
111 }
112 $user = $userCache[$userId];
113
114 $instance = $notification->getUserInstance($user, $lang, $this->defaultLanguage);
115 foreach ($handler as $h) {
116 $h->notify($instance);
117 }
118 }
119 }
120 } else {
122 }
123 }
getUserInstance(ilObjUser $user, array $languageVars, string $defaultLanguage)
static getAvailableChannels(array $config_types=[], bool $includeDisabled=false)
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
User class.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
$lang
Definition: xapiexit.php:26

References $data, ILIAS\Notifications\ilNotificationSystem\$handler, $lang, ILIAS\Notifications\ilNotificationDatabaseHandler\enqueueByUsers(), ILIAS\Notifications\ilNotificationDatabaseHandler\getAvailableChannels(), ILIAS\Notifications\ilNotificationDatabaseHandler\getAvailableTypes(), ilObjectFactory\getInstanceByObjId(), ILIAS\Notifications\Model\ilNotificationConfig\getLanguageParameters(), ILIAS\Notifications\ilNotificationDatabaseHandler\getTranslatedLanguageVariablesOfNotificationParameters(), ILIAS\Notifications\Model\ilNotificationConfig\getType(), ILIAS\Notifications\Model\ilNotificationConfig\getUserInstance(), ILIAS\Notifications\ilNotificationDatabaseHandler\getUsersWithCustomConfig(), and ILIAS\Notifications\ilNotificationDatabaseHandler\loadUserConfig().

Referenced by ILIAS\Notifications\ilNotificationSystem\toRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $defaultLanguage

string ILIAS\Notifications\ilNotificationSystem::$defaultLanguage = 'en'
private

Definition at line 37 of file ilNotificationSystem.php.

◆ $handler

array ILIAS\Notifications\ilNotificationSystem::$handler = []
private

◆ $rbacReview

ilRbacReview ILIAS\Notifications\ilNotificationSystem::$rbacReview
private

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