3declare(strict_types=1);
54 if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
55 $this->handler[$channel] = [];
58 $this->handler[$channel][] =
$handler;
66 if ($processAsync ===
false) {
73 $user_by_handler = [];
74 if (isset($types[$notification->
getType()][
'config_type'])) {
75 if ($types[$notification->
getType()][
'config_type'] ===
'set_by_user') {
77 $channelsByAdmin =
false;
78 foreach ($it as $usr_id =>
$data) {
79 if (!isset($channels[
'channel']) || !$channels[
$data[
'channel']]) {
82 if (!isset($user_by_handler[
$data[
'channel']]) || !$user_by_handler[
$data[
'channel']]) {
83 $user_by_handler[
$data[
'channel']] = [];
85 $user_by_handler[
$data[
'channel']][] = $usr_id;
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]) {
94 $user_by_handler[$channel] = $users;
102 foreach ($user_by_handler as
$handler => $h_users) {
104 foreach ($h_users as $userId) {
105 if (!isset($userCache[$userId]) || !$userCache[$userId]) {
110 $userCache[$userId] = $user;
112 $user = $userCache[$userId];
116 $h->notify($instance);
127 if ($processAsync ===
false) {
143 foreach ($roles as $role) {
144 $users[] = $this->rbacReview->assignedUsers($role);
146 $users = array_unique(array_merge(...$users));
148 $this->
toUsers($notification, $users, $processAsync);
158 $DIC->notifications()->system()->toUsers($notification, $users, $processAsync);
164 $DIC->notifications()->system()->toListeners($notification,
$ref_id, $processAsync);
173 $DIC->notifications()->system()->toRoles($notification, $roles, $processAsync);
188 public function clear(
string $channel =
''): void
191 if ($channel !==
'') {
192 $channels = [$this->handler[$channel]] ?? [];
194 foreach ($channels as
$c) {
hasDisableAfterDeliverySet()
getUserInstance(ilObjUser $user, array $languageVars, string $defaultLanguage)
static getAvailableTypes(array $config_types=[])
static disableListeners(string $module, int $sender_id)
static enableListeners(string $module, $sender_id, array $users=[])
static getUsersWithCustomConfig(array $userid)
static getAvailableChannels(array $config_types=[], bool $includeDisabled=false)
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
static enqueueByListener(ilNotificationConfig $notification, int $ref_id)
static getUsersByListener(string $module, int $sender_id)
static getTranslatedLanguageVariablesOfNotificationParameters(array $vars=[])
static loadUserConfig(int $userid)
static sendNotificationToUsers(ilNotificationConfig $notification, array $users, bool $processAsync=false)
clear(string $channel='')
toListeners(ilNotificationConfig $notification, int $ref_id, bool $processAsync=false)
__construct(ilRbacReview $rbacReview=null)
static sendNotificationToRoles(ilNotificationConfig $notification, array $roles, bool $processAsync=false)
toUsers(ilNotificationConfig $notification, array $users, bool $processAsync=false)
static sendNotificationToListeners(ilNotificationConfig $notification, int $ref_id, bool $processAsync=false)
static enableUserListeners(string $module, int $ref_id, array $users)
addHandler(string $channel, ilNotificationHandler $handler)
static enableListeners(string $module, int $ref_id)
toRoles(ilNotificationConfig $notification, array $roles, bool $processAsync=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
class ilRbacReview Contains Review functions of core Rbac.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...