23 require_once
'Services/Notifications/classes/class.ilNotificationEchoHandler.php';
24 require_once
'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
25 require_once
'Services/Notifications/classes/class.ilNotificationMailHandler.php';
35 if (!self::$instance) {
36 self::$instance =
new self();
38 return self::$instance;
49 if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
50 $this->handler[$channel] =
array();
53 $this->handler[$channel][] =
$handler;
66 require_once
'Services/Notifications/classes/class.ilNotificationUserIterator.php';
67 require_once
'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
71 if ($processAsync ==
false) {
78 foreach (
$users as $user_id) {
79 if ($usersWithCustomConfig[$user_id]) {
89 $lang = ilNotificationDatabaseHandler::getTranslatedLanguageVariablesOfNotificationParameters($notification->
getLanguageParameters());
91 $user_by_handler =
array();
95 if ($types[$notification->
getType()][
'config_type'] ==
'set_by_user') {
98 $channelsByAdmin =
false;
101 foreach ($it as $usr_id =>
$data) {
103 if (!$channels[
$data[
'channel']]) {
107 if (!$user_by_handler[$data[
'channel']]) {
108 $user_by_handler[$data[
'channel']] =
array();
111 $user_by_handler[$data[
'channel']][] = $usr_id;
115 elseif ($types[$notification->
getType()][
'config_type'] !=
'disabled') {
116 $channelsByAdmin =
true;
119 if (isset($adminConfig[$notification->
getType()])) {
120 foreach ($adminConfig[$notification->
getType()] as $channel) {
121 if (!$channels[$channel]) {
124 $user_by_handler[$channel] =
$users;
130 $userCache =
array();
136 foreach (
$users as $userId) {
137 if (!$userCache[$userId]) {
139 if (!$user || !($user instanceof \
ilObjUser)) {
142 $userCache[$userId] = $user;
144 $user = $userCache[$userId];
174 require_once
'Services/Notifications/classes/class.ilNotificationUserIterator.php';
175 require_once
'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
177 if ($processAsync ==
false) {
179 self::toUsers($notification,
$users,
false);
199 require_once
'Services/Notifications/classes/class.ilNotificationUserIterator.php';
200 require_once
'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
205 foreach ($roles as $role) {
206 $users[] = $rbacreview->assignedUsers($role);
209 $users = array_unique(call_user_func_array(
'array_merge',
$users));
211 self::toUsers($notification,
$users, $processAsync);
223 self::getInstance()->toUsers($notification,
$users, $processAsync);
235 self::getInstance()->toListeners($notification, $ref_id, $processAsync);
247 self::getInstance()->toRoles($notification, $roles, $processAsync);
252 require_once
'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
261 require_once
'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
addHandler($channel, ilNotificationHandler $handler)
Registers a new handler for the given channel name.
Notification handler for sending notifications the to recipients email address.
toRoles(ilNotificationConfig $notification, array $roles, $processAsync=false)
Send a notification to a list of roles.
wrapper for iterating a list of user settings by providing the user ids
static sendNotificationToUsers(ilNotificationConfig $notification, $users, $processAsync=false)
static enableListeners($module, $ref_id)
toUsers(ilNotificationConfig $notification, $users, $processAsync=false)
Creates the user notifications and send them.
static getUsersWithCustomConfig(array $userid)
static getUsersByListener($module, $sender_id)
Base class for notification handlers.
hasDisableAfterDeliverySet()
if($modEnd===false) $module
Describes a notification and provides methods for publishing this notification.
toListeners(ilNotificationConfig $notification, $ref_id, $processAsync=false)
Sends the notification to all listener which are subscribed to the given ref_id.
static disableListeners($module, $sender_id)
static enqueueByListener(ilNotificationConfig $notification, $ref_id)
Basic notification handler that dumps basic notification information to stdout.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
Main notification handling routines for sending notifications to recipients.
static enableUserListeners($module, $ref_id, array $users)
static getAvailableTypes($config_types=array())
static sendNotificationToRoles(ilNotificationConfig $notification, array $roles, $processAsync=false)
static getAvailableChannels($config_types=array(), $includeDisabled=false)
static sendNotificationToListeners(ilNotificationConfig $notification, $ref_id, $processAsync=false)
getUserInstance(ilObjUser $user, $languageVars, $defaultLanguage)
static loadUserConfig($userid)
static enableListeners($module, $sender_id, array $users=array())