ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilNotificationDatabaseHandler Class Reference
+ Collaboration diagram for ilNotificationDatabaseHandler:

Static Public Member Functions

static setUserConfig ($userid, array $configArray)
 Sets the configuration for all given configurations. More...
 
static loadUserConfig ($userid)
 
static enqueueByUsers (ilNotificationConfig $notification, array $userids)
 
static enqueueByListener (ilNotificationConfig $notification, $ref_id)
 
static storeNotification (ilNotificationConfig $notification)
 
static removeNotification ($id)
 
static getUsersByListener ($module, $sender_id)
 
static disableListeners ($module, $sender_id)
 
static enableListeners ($module, $sender_id, array $users=array())
 
static registerChannel ($name, $title, $description, $class, $classfile, $config_type)
 Registers a new notification channel for distributing notifications. More...
 
static registerType ($name, $title, $description, $notification_group, $config_type)
 Registers a new notification type. More...
 
static getAvailableChannels ($config_types=array(), $includeDisabled=false)
 
static getAvailableTypes ($config_types=array())
 
static setConfigTypeForType ($type_name, $config_name)
 
static setConfigTypeForChannel ($channel_name, $config_name)
 
static getUsersWithCustomConfig (array $userid)
 

Static Protected Member Functions

static fillPlaceholders ($results, $vars, $langVarToTypeDict)
 
static findPlaceholders ($pattern, $translation)
 

Static Private Member Functions

static replaceFields ($string, $foundPlaceholders, $params, $startTag, $endTage)
 

Detailed Description

Definition at line 5 of file class.ilNotificationDatabaseHelper.php.

Member Function Documentation

◆ disableListeners()

static ilNotificationDatabaseHandler::disableListeners (   $module,
  $sender_id 
)
static

Definition at line 317 of file class.ilNotificationDatabaseHelper.php.

317 {
318 global $ilDB;
319
320 $query = 'UPDATE '. ilNotificationSetupHelper::$tbl_userlistener .' SET disabled = 1 WHERE module = %s AND sender_id = %s';
321 $types = array('text', 'integer');
322 $values = array($module, $sender_id);
323
324 $ilDB->manipulateF($query, $types, $values);
325 }
global $ilDB

References $ilDB, $query, and ilNotificationSetupHelper\$tbl_userlistener.

Referenced by ilNotificationSystem\toListeners().

+ Here is the caller graph for this function:

◆ enableListeners()

static ilNotificationDatabaseHandler::enableListeners (   $module,
  $sender_id,
array  $users = array() 
)
static

Definition at line 327 of file class.ilNotificationDatabaseHelper.php.

327 {
328 global $ilDB;
329
330 $query = 'UPDATE '. ilNotificationSetupHelper::$tbl_userlistener .' SET disabled = 0 WHERE module = %s AND sender_id = %s';
331
332 if ($users) {
333 $query .= ' ' . $ilDB->in('usr_id', $users);
334 }
335
336 $types = array('text', 'integer');
337 $values = array($module, $sender_id);
338
339 $ilDB->manipulateF($query, $types, $values);
340 }

References $ilDB, $query, and ilNotificationSetupHelper\$tbl_userlistener.

Referenced by ilNotificationSystem\enableListeners(), and ilNotificationSystem\enableUserListeners().

+ Here is the caller graph for this function:

◆ enqueueByListener()

static ilNotificationDatabaseHandler::enqueueByListener ( ilNotificationConfig  $notification,
  $ref_id 
)
static

Definition at line 237 of file class.ilNotificationDatabaseHelper.php.

237 {
238 global $ilDB;
239
240 $notification_id = ilNotificationDatabaseHandler::storeNotification($notification);
241 $valid_until = $notification->getValidForSeconds() ? (time() + $notification->getValidForSeconds()) : 0;
242
243 $query = 'INSERT INTO ' . ilNotificationSetupHelper::$tbl_notification_queue . ' (notification_id, usr_id, valid_until, visible_for) '
244 .' (SELECT %s, usr_id, %s, %s FROM '. ilNotificationSetupHelper::$tbl_userlistener .' WHERE disabled = 0 AND module = %s AND sender_id = %s)';
245
246 $types = array('integer', 'integer', 'integer', 'text', 'integer');
247
248 $values = array($notification_id, $valid_until, $notification->getVisibleForSeconds(), $notification->getType(), $ref_id);
249
250 $ilDB->manipulateF($query, $types, $values);
251 }
static storeNotification(ilNotificationConfig $notification)
$ref_id
Definition: sahs_server.php:39

References $ilDB, $query, $ref_id, ilNotificationSetupHelper\$tbl_notification_queue, ilNotificationSetupHelper\$tbl_userlistener, ilNotificationConfig\getType(), ilNotificationConfig\getValidForSeconds(), ilNotificationConfig\getVisibleForSeconds(), and storeNotification().

Referenced by ilNotificationSystem\toListeners().

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

◆ enqueueByUsers()

static ilNotificationDatabaseHandler::enqueueByUsers ( ilNotificationConfig  $notification,
array  $userids 
)
static

Definition at line 213 of file class.ilNotificationDatabaseHelper.php.

214 {
215 if(!$userids)
216 return;
217
218 global $ilDB;
219
220 $notification_id = ilNotificationDatabaseHandler::storeNotification($notification);
221 $valid_until = $notification->getValidForSeconds() ? (time() + $notification->getValidForSeconds()) : 0;
222
223 foreach($userids as $userid)
224 {
225 $ilDB->insert(
227 array(
228 'notification_id' => array('integer', $notification_id),
229 'usr_id' => array('integer', $userid),
230 'valid_until' => array('integer', $valid_until),
231 'visible_for' => array('integer', $notification->getVisibleForSeconds())
232 )
233 );
234 }
235 }

References $ilDB, ilNotificationSetupHelper\$tbl_notification_queue, ilNotificationConfig\getValidForSeconds(), ilNotificationConfig\getVisibleForSeconds(), and storeNotification().

Referenced by ilNotificationSystem\toUsers().

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

◆ fillPlaceholders()

static ilNotificationDatabaseHandler::fillPlaceholders (   $results,
  $vars,
  $langVarToTypeDict 
)
staticprotected
Parameters
array$results
array$vars
array$langVarToTypeDict
Returns
array mixed

Definition at line 66 of file class.ilNotificationDatabaseHelper.php.

67 {
68 $pattern_old = '/##(.+?)##/im';
69 $pattern = '/\[(.+?)\]/im';
70
71 foreach($results as $langVar => $res)
72 {
73 $placeholdersStack = array();
74 $res->lang = array();
75
76 foreach($res->lang_untouched as $iso2shorthandle => $translation)
77 {
78 $translation = str_replace("\\n", "\n", $translation);
79 $placeholdersStack[] = self::findPlaceholders($pattern, $translation);
80 $translation = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), '[', ']');
81 $placeholdersStack[] = self::findPlaceholders($pattern_old, $translation);
82 $res->lang[$iso2shorthandle] = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), '##', '##');
83 }
84
85 $res->params = array_diff(
86 array_unique(
87 call_user_func_array('array_merge', $placeholdersStack)
88 ),
89 array_keys($vars[$langVarToTypeDict[$langVar]]->getParameters())
90 );
91 }
92
93 return $results;
94 }
static replaceFields($string, $foundPlaceholders, $params, $startTag, $endTage)
static findPlaceholders($pattern, $translation)
$results

References $res, $results, findPlaceholders(), and replaceFields().

+ Here is the call graph for this function:

◆ findPlaceholders()

static ilNotificationDatabaseHandler::findPlaceholders (   $pattern,
  $translation 
)
staticprotected
Parameters
string$pattern
string$translation
Returns
array

Definition at line 102 of file class.ilNotificationDatabaseHelper.php.

103 {
104 $foundPlaceholders = array();
105 preg_match_all($pattern, $translation, $foundPlaceholders);
106 return (array)$foundPlaceholders[1];
107 }

Referenced by fillPlaceholders().

+ Here is the caller graph for this function:

◆ getAvailableChannels()

static ilNotificationDatabaseHandler::getAvailableChannels (   $config_types = array(),
  $includeDisabled = false 
)
static

Definition at line 396 of file class.ilNotificationDatabaseHelper.php.

396 {
397 global $ilDB;
398
399 $query = 'SELECT channel_name, title, description, class, include, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_channels;
400 if ($config_types)
401 $query .= ' WHERE ' . $ilDB->in('config_type', $config_types, false, 'text');
402
403 $rset = $ilDB->query($query);
404
405 $result = array();
406
407 $settings = new ilSetting('notifications');
408
409 while ($row = $ilDB->fetchAssoc($rset)) {
410 if (!$includeDisabled && !$settings->get('enable_' . $row['channel_name']))
411 continue;
412
413 $result[$row['channel_name']] = array (
414 'name' => $row['channel_name'],
415 'title' => $row['title'],
416 'description' => $row['description'],
417 'handler' => $row['class'],
418 'include' => $row['include'],
419 'config_type' => $row['config_type'],
420 );
421 }
422
423 return $result;
424 }
$result
ILIAS Setting Class.

References $ilDB, $query, $result, $row, and ilNotificationSetupHelper\$tbl_notification_channels.

Referenced by ilNotificationGUI\getAvailableChannels(), ilNotificationAdminSettingsForm\getGeneralSettingsForm(), setUserConfig(), ilObjNotificationAdminGUI\showChannelsObject(), ilObjNotificationAdminGUI\showConfigMatrixObject(), and ilNotificationSystem\toUsers().

+ Here is the caller graph for this function:

◆ getAvailableTypes()

static ilNotificationDatabaseHandler::getAvailableTypes (   $config_types = array())
static

Definition at line 426 of file class.ilNotificationDatabaseHelper.php.

426 {
427 global $ilDB;
428
429 $query = 'SELECT type_name, title, description, notification_group, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_types;
430 if ($config_types)
431 $query .= ' WHERE ' . $ilDB->in('config_type', $config_types, false, 'text');
432
433
434 $rset = $ilDB->query($query);
435
436 $result = array();
437
438 while ($row = $ilDB->fetchAssoc($rset)) {
439 $result[$row['type_name']] = array (
440 'name' => $row['type_name'],
441 'title' => $row['title'],
442 'description' => $row['description'],
443 'group' => $row['notification_group'],
444 'config_type' => $row['config_type'],
445 );
446 }
447
448 return $result;
449 }

References $ilDB, $query, $result, $row, and ilNotificationSetupHelper\$tbl_notification_types.

Referenced by ilNotificationGUI\getAvailableTypes(), setUserConfig(), ilObjNotificationAdminGUI\showConfigMatrixObject(), ilObjNotificationAdminGUI\showTypesObject(), and ilNotificationSystem\toUsers().

+ Here is the caller graph for this function:

◆ getUsersByListener()

static ilNotificationDatabaseHandler::getUsersByListener (   $module,
  $sender_id 
)
static

Definition at line 301 of file class.ilNotificationDatabaseHelper.php.

301 {
302 global $ilDB;
303
304 $query = 'SELECT usr_id FROM '. ilNotificationSetupHelper::$tbl_userlistener .' WHERE disabled = 0 AND module = %s AND sender_id = %s';
305 $types = array('text', 'integer');
306 $values = array($module, $sender_id);
307
308 $users = array();
309
310 $rset = $ilDB->queryF($query, $types, $values);
311 while($row = $ilDB->fetchAssoc($rset)) {
312 $users[] = $row['usr_id'];
313 }
314 return $users;
315 }

References $ilDB, $query, $row, and ilNotificationSetupHelper\$tbl_userlistener.

Referenced by ilNotificationSystem\toListeners().

+ Here is the caller graph for this function:

◆ getUsersWithCustomConfig()

static ilNotificationDatabaseHandler::getUsersWithCustomConfig ( array  $userid)
static

Definition at line 468 of file class.ilNotificationDatabaseHelper.php.

468 {
469 global $ilDB;
470 $query = 'SELECT usr_id, value FROM usr_pref WHERE ' . $ilDB->in('usr_id', $userid, false, 'integer') . ' AND keyword="use_custom_notification_setting" AND value="1"';
471 $rset = $ilDB->query($query);
472 $result = array();
473 while($row = $ilDB->fetchAssoc($rset)) {
474 $result[$row['usr_id']] = (bool)$row['value'];
475 }
476 return $result;
477 }

References $ilDB, $query, $result, and $row.

Referenced by ilNotificationSystem\toUsers().

+ Here is the caller graph for this function:

◆ loadUserConfig()

static ilNotificationDatabaseHandler::loadUserConfig (   $userid)
static

Definition at line 192 of file class.ilNotificationDatabaseHelper.php.

192 {
193 global $ilDB;
194
195 $query = 'SELECT module, channel FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE usr_id = %s';
196 $types = array('integer');
197 $values = array($userid);
198
199 $res = $ilDB->queryF($query, $types, $values);
200
201 $result = array();
202
203 while ($row = $ilDB->fetchAssoc($res)) {
204 if (!$result[$row['module']])
205 $result[$row['module']] = array();
206
207 $result[$row['module']][] = $row['channel'];
208 }
209
210 return $result;
211 }

References $ilDB, $query, $res, $result, $row, and ilNotificationSetupHelper\$tbl_userconfig.

Referenced by ilObjNotificationAdminGUI\showConfigMatrixObject(), ilNotificationGUI\showSettingsObject(), and ilNotificationSystem\toUsers().

+ Here is the caller graph for this function:

◆ registerChannel()

static ilNotificationDatabaseHandler::registerChannel (   $name,
  $title,
  $description,
  $class,
  $classfile,
  $config_type 
)
static

Registers a new notification channel for distributing notifications.

@global ilDB $ilDB

Parameters
type$nametechnical name of the type
type$titlehuman readable title for configuration guis
type$descriptionnot yet used human readable description
type$classclass name of the handler class
type$classfileclass file location of the handler class
type$config_type'set_by_user' or 'set_by_admin'; restricts if users can override the configuartion for this channel

Definition at line 354 of file class.ilNotificationDatabaseHelper.php.

354 {
355 global $ilDB;
356
357 $ilDB->insert(
359 array(
360 'channel_name' => array('text', $name),
361 'title' => array('text', $title),
362 'description' => array('text', $description),
363 'class' => array('text', $class),
364 'include' => array('text', $classfile),
365 'config_type' => array('text', $config_type),
366 )
367 );
368 }

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_channels.

Referenced by ilNotificationSetupHelper\registerChannel().

+ Here is the caller graph for this function:

◆ registerType()

static ilNotificationDatabaseHandler::registerType (   $name,
  $title,
  $description,
  $notification_group,
  $config_type 
)
static

Registers a new notification type.

@global ilDB $ilDB

Parameters
string$nametechnical name of the type
string$titlehuman readable title for configuration guis
string$descriptionnot yet used human readable description
string$notification_groupnot yet used group
string$config_type'set_by_user' or 'set_by_admin'; restricts if users can override the configuartion for this type

Definition at line 381 of file class.ilNotificationDatabaseHelper.php.

381 {
382 global $ilDB;
383
384 $ilDB->insert(
386 array(
387 'type_name' => array('text', $name),
388 'title' => array('text', $title),
389 'description' => array('text', $description),
390 'notification_group' => array('text', $notification_group),
391 'config_type' => array('text', $config_type),
392 )
393 );
394 }

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_types.

Referenced by ilNotificationSetupHelper\registerType().

+ Here is the caller graph for this function:

◆ removeNotification()

static ilNotificationDatabaseHandler::removeNotification (   $id)
static

Definition at line 291 of file class.ilNotificationDatabaseHelper.php.

291 {
292 global $ilDB;
293
294 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_data . ' WHERE notification_id = ?';
295 $types = array('integer');
296 $values = array($id);
297
298 $ilDB->manipulateF($query, $types, $values);
299 }

References $ilDB, $query, and ilNotificationSetupHelper\$tbl_notification_data.

◆ replaceFields()

static ilNotificationDatabaseHandler::replaceFields (   $string,
  $foundPlaceholders,
  $params,
  $startTag,
  $endTage 
)
staticprivate
Parameters
string$string
array$foundPlaceholders
array$params
string$startTag
string$endTag
Returns
string

Definition at line 118 of file class.ilNotificationDatabaseHelper.php.

119 {
120 foreach($foundPlaceholders as $placeholder)
121 {
122 if(array_key_exists(strtoupper($placeholder), $params))
123 {
124 $string = str_ireplace($startTag . $placeholder . $endTage, $params[strtoupper($placeholder)], $string);
125 }
126 if(array_key_exists(strtolower($placeholder), $params))
127 {
128 $string = str_ireplace($startTag . $placeholder . $endTage, $params[strtolower($placeholder)], $string);
129 }
130 }
131 return $string;
132 }
$params
Definition: example_049.php:96

References $params.

Referenced by fillPlaceholders().

+ Here is the caller graph for this function:

◆ setConfigTypeForChannel()

static ilNotificationDatabaseHandler::setConfigTypeForChannel (   $channel_name,
  $config_name 
)
static

Definition at line 459 of file class.ilNotificationDatabaseHelper.php.

459 {
460 global $ilDB;
461 $query = 'UPDATE ' . ilNotificationSetupHelper::$tbl_notification_channels . ' SET config_type = %s WHERE channel_name = %s';
462 $types = array('text', 'text');
463 $values = array($config_name, $channel_name);
464 $ilDB->manipulateF($query, $types, $values);
465 }

References $ilDB, $query, and ilNotificationSetupHelper\$tbl_notification_channels.

Referenced by ilObjNotificationAdminGUI\saveChannelsObject(), and ilObjNotificationAdminGUI\saveGeneralSettingsObject().

+ Here is the caller graph for this function:

◆ setConfigTypeForType()

static ilNotificationDatabaseHandler::setConfigTypeForType (   $type_name,
  $config_name 
)
static

Definition at line 451 of file class.ilNotificationDatabaseHelper.php.

451 {
452 global $ilDB;
453 $query = 'UPDATE ' . ilNotificationSetupHelper::$tbl_notification_types . ' SET config_type = %s WHERE type_name = %s';
454 $types = array('text', 'text');
455 $values = array($config_name, $type_name);
456 $ilDB->manipulateF($query, $types, $values);
457 }

References $ilDB, $query, and ilNotificationSetupHelper\$tbl_notification_types.

Referenced by ilObjNotificationAdminGUI\saveTypesObject().

+ Here is the caller graph for this function:

◆ setUserConfig()

static ilNotificationDatabaseHandler::setUserConfig (   $userid,
array  $configArray 
)
static

Sets the configuration for all given configurations.

Old configurations are completly removed before the new are inserted.

structure of $configArray

array( 'chat_invitation' => array( 'mail' => true, 'osd' => false ), 'adobeconnect_invitation' => array( 'mail' => true, 'osd' => true ), );

If the userid is -1, the settings are stored as general settings (default values or used if configuration type is set_by_admin).

@global ilDB $ilDB

Parameters
int$userid
array$configArray

Definition at line 158 of file class.ilNotificationDatabaseHelper.php.

158 {
159 global $ilDB;
160
161 if ($userid != -1) {
162 $channels = self::getAvailableChannels(array('set_by_user'));
163 $types = self::getAvailableTypes(array('set_by_user'));
164 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE usr_id=%s AND ' . $ilDB->in('module', array_keys($types), false, 'text') . ' AND ' . $ilDB->in('channel', array_keys($channels), false, 'text');
165 }
166 else {
167 $query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE usr_id=%s';
168 }
169
170 $types = array('integer');
171 $values = array($userid);
172
173 // delete old settings
174 $ilDB->manipulateF($query, $types, $values);
175
176 foreach ($configArray as $type => $channels) {
177 foreach ($channels as $channel => $value) {
178 if (!$value)
179 continue;
180 $ilDB->insert(
182 array(
183 'usr_id' => array('integer', $userid),
184 'module' => array('text', $type),
185 'channel' => array('text', $channel),
186 )
187 );
188 }
189 }
190 }
static getAvailableChannels($config_types=array(), $includeDisabled=false)

References $ilDB, $query, ilNotificationSetupHelper\$tbl_userconfig, getAvailableChannels(), and getAvailableTypes().

Referenced by ilObjNotificationAdminGUI\saveConfigMatrixObject(), and ilNotificationGUI\saveSettingsObject().

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

◆ storeNotification()

static ilNotificationDatabaseHandler::storeNotification ( ilNotificationConfig  $notification)
static

Definition at line 275 of file class.ilNotificationDatabaseHelper.php.

275 {
276 global $ilDB;
277
279
280 $ilDB->insert(
282 array(
283 'notification_id' => array('integer', $id),
284 'serialized' => array('text', serialize($notification)),
285 )
286 );
287
288 return $id;
289 }

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_data.

Referenced by enqueueByListener(), and enqueueByUsers().

+ Here is the caller graph for this function:

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