ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilNotificationDatabaseHandler Class Reference
+ Collaboration diagram for ilNotificationDatabaseHandler:

Static Public Member Functions

static setUserConfig ($userid, array $configArray)
 Sets the configuration for all given configurations.
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.
static registerType ($name, $title, $description, $notification_group, $config_type)
 Registers a new notification type.
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

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

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

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

Referenced by ilNotificationSystem\toListeners().

{
global $ilDB;
$query = 'UPDATE '. ilNotificationSetupHelper::$tbl_userlistener .' SET disabled = 1 WHERE module = %s AND sender_id = %s';
$types = array('text', 'integer');
$values = array($module, $sender_id);
$ilDB->manipulateF($query, $types, $values);
}

+ Here is the caller graph for this function:

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

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

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

{
global $ilDB;
$query = 'UPDATE '. ilNotificationSetupHelper::$tbl_userlistener .' SET disabled = 0 WHERE module = %s AND sender_id = %s';
if ($users) {
$query .= ' ' . $ilDB->in('usr_id', $users);
}
$types = array('text', 'integer');
$values = array($module, $sender_id);
$ilDB->manipulateF($query, $types, $values);
}
static ilNotificationDatabaseHandler::enqueueByListener ( ilNotificationConfig  $notification,
  $ref_id 
)
static

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

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

Referenced by ilNotificationSystem\toListeners().

{
global $ilDB;
$notification_id = ilNotificationDatabaseHandler::storeNotification($notification);
$valid_until = $notification->getValidForSeconds() ? (time() + $notification->getValidForSeconds()) : 0;
$query = 'INSERT INTO ' . ilNotificationSetupHelper::$tbl_notification_queue . ' (notification_id, usr_id, valid_until) '
.' (SELECT %s, usr_id, %s FROM '. ilNotificationSetupHelper::$tbl_userlistener .' WHERE disabled = 0 AND module = %s AND sender_id = %s)';
$types = array('integer', 'integer', 'text', 'integer');
$values = array($notification_id, $valid_until, $notification->getType(), $ref_id);
$ilDB->manipulateF($query, $types, $values);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

Referenced by ilNotificationSystem\toUsers().

{
if (!$userids)
return;
global $ilDB;
$notification_id = ilNotificationDatabaseHandler::storeNotification($notification);
$valid_until = $notification->getValidForSeconds() ? (time() + $notification->getValidForSeconds()) : 0;
foreach($userids as $userid) {
$ilDB->insert(
array(
'notification_id' => array('integer', $notification_id),
'usr_id' => array('integer', $userid),
'valid_until' => array('integer', $valid_until),
)
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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

{
$pattern_old = '/##(.+?)##/im';
$pattern = '/\[(.+?)\]/im';
foreach($results as $langVar => $res)
{
$placeholdersStack = array();
$res->lang = array();
foreach($res->lang_untouched as $iso2shorthandle => $translation)
{
$translation = str_replace("\\n", "\n", $translation);
$placeholdersStack[] = self::findPlaceholders($pattern, $translation);
$translation = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), '[', ']');
$placeholdersStack[] = self::findPlaceholders($pattern_old, $translation);
$res->lang[$iso2shorthandle] = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), '##', '##');
}
$res->params = array_diff(
array_unique(
call_user_func_array('array_merge', $placeholdersStack)
),
array_keys($vars[$langVarToTypeDict[$langVar]]->getParameters())
);
}
return $results;
}

+ Here is the call graph for this function:

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

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

Referenced by fillPlaceholders().

{
$foundPlaceholders = array();
preg_match_all($pattern, $translation, $foundPlaceholders);
return (array)$foundPlaceholders[1];
}

+ Here is the caller graph for this function:

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

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

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

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

{
global $ilDB;
$query = 'SELECT channel_name, title, description, class, include, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_channels;
if ($config_types)
$query .= ' WHERE ' . $ilDB->in('config_type', $config_types, false, 'text');
$rset = $ilDB->query($query);
$result = array();
$settings = new ilSetting('notifications');
while ($row = $ilDB->fetchAssoc($rset)) {
if (!$includeDisabled && !$settings->get('enable_' . $row['channel_name']))
continue;
$result[$row['channel_name']] = array (
'name' => $row['channel_name'],
'title' => $row['title'],
'description' => $row['description'],
'handler' => $row['class'],
'include' => $row['include'],
'config_type' => $row['config_type'],
);
}
return $result;
}

+ Here is the caller graph for this function:

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

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

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

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

{
global $ilDB;
$query = 'SELECT type_name, title, description, notification_group, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_types;
if ($config_types)
$query .= ' WHERE ' . $ilDB->in('config_type', $config_types, false, 'text');
$rset = $ilDB->query($query);
$result = array();
while ($row = $ilDB->fetchAssoc($rset)) {
$result[$row['type_name']] = array (
'name' => $row['type_name'],
'title' => $row['title'],
'description' => $row['description'],
'group' => $row['notification_group'],
'config_type' => $row['config_type'],
);
}
return $result;
}

+ Here is the caller graph for this function:

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

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

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

Referenced by ilNotificationSystem\toListeners().

{
global $ilDB;
$query = 'SELECT usr_id FROM '. ilNotificationSetupHelper::$tbl_userlistener .' WHERE disabled = 0 AND module = %s AND sender_id = %s';
$types = array('text', 'integer');
$values = array($module, $sender_id);
$users = array();
$rset = $ilDB->queryF($query, $types, $values);
while($row = $ilDB->fetchAssoc($rset)) {
$users[] = $row['usr_id'];
}
return $users;
}

+ Here is the caller graph for this function:

static ilNotificationDatabaseHandler::getUsersWithCustomConfig ( array  $userid)
static

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

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

Referenced by ilNotificationSystem\toUsers().

{
global $ilDB;
$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"';
$rset = $ilDB->query($query);
$result = array();
while($row = $ilDB->fetchAssoc($rset)) {
$result[$row['usr_id']] = (bool)$row['value'];
}
return $result;
}

+ Here is the caller graph for this function:

static ilNotificationDatabaseHandler::loadUserConfig (   $userid)
static

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

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

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

{
global $ilDB;
$query = 'SELECT module, channel FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE usr_id = %s';
$types = array('integer');
$values = array($userid);
$res = $ilDB->queryF($query, $types, $values);
$result = array();
while ($row = $ilDB->fetchAssoc($res)) {
if (!$result[$row['module']])
$result[$row['module']] = array();
$result[$row['module']][] = $row['channel'];
}
return $result;
}

+ Here is the caller graph for this function:

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

Registers a new notification channel for distributing notifications.

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 352 of file class.ilNotificationDatabaseHelper.php.

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_channels.

{
global $ilDB;
$ilDB->insert(
array(
'channel_name' => array('text', $name),
'title' => array('text', $title),
'description' => array('text', $description),
'class' => array('text', $class),
'include' => array('text', $classfile),
'config_type' => array('text', $config_type),
)
);
}
static ilNotificationDatabaseHandler::registerType (   $name,
  $title,
  $description,
  $notification_group,
  $config_type 
)
static

Registers a new notification type.

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 379 of file class.ilNotificationDatabaseHelper.php.

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_types.

{
global $ilDB;
$ilDB->insert(
array(
'type_name' => array('text', $name),
'title' => array('text', $title),
'description' => array('text', $description),
'notification_group' => array('text', $notification_group),
'config_type' => array('text', $config_type),
)
);
}
static ilNotificationDatabaseHandler::removeNotification (   $id)
static

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

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

{
global $ilDB;
$query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_notification_data . ' WHERE notification_id = ?';
$types = array('integer');
$values = array($id);
$ilDB->manipulateF($query, $types, $values);
}
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.

Referenced by fillPlaceholders().

{
foreach($foundPlaceholders as $placeholder)
{
if(array_key_exists(strtoupper($placeholder), $params))
{
$string = str_ireplace($startTag . $placeholder . $endTage, $params[strtoupper($placeholder)], $string);
}
if(array_key_exists(strtolower($placeholder), $params))
{
$string = str_ireplace($startTag . $placeholder . $endTage, $params[strtolower($placeholder)], $string);
}
}
return $string;
}

+ Here is the caller graph for this function:

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

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

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

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

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

+ Here is the caller graph for this function:

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

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

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

Referenced by ilObjNotificationAdminGUI\saveTypesObject().

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

+ Here is the caller graph for this function:

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).

ilDB $ilDB

Parameters
int$userid
array$configArray

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

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

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

{
global $ilDB;
if ($userid != -1) {
$channels = self::getAvailableChannels(array('set_by_user'));
$types = self::getAvailableTypes(array('set_by_user'));
$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');
}
else {
$query = 'DELETE FROM ' . ilNotificationSetupHelper::$tbl_userconfig . ' WHERE usr_id=%s';
}
$types = array('integer');
$values = array($userid);
// delete old settings
$ilDB->manipulateF($query, $types, $values);
foreach ($configArray as $type => $channels) {
foreach ($channels as $channel => $value) {
if (!$value)
continue;
$ilDB->insert(
array(
'usr_id' => array('integer', $userid),
'module' => array('text', $type),
'channel' => array('text', $channel),
)
);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilNotificationDatabaseHandler::storeNotification ( ilNotificationConfig  $notification)
static

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

References $ilDB, and ilNotificationSetupHelper\$tbl_notification_data.

Referenced by enqueueByListener(), and enqueueByUsers().

{
global $ilDB;
$ilDB->insert(
array(
'notification_id' => array('integer', $id),
'serialized' => array('text', serialize($notification)),
)
);
return $id;
}

+ Here is the caller graph for this function:


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