3require_once 
'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
 
   12    public static function getTranslatedLanguageVariablesOfNotificationParameters($vars = array())
 
   19        $langVarToTypeDict = array();
 
   21        foreach ($vars as 
$type => $var) {
 
   29            $where[] = sprintf(
'module = %s AND identifier = %s', 
$ilDB->quote($var->getLanguageModule()), 
$ilDB->quote($var->getName()));
 
   30            $langVarToTypeDict[$var->getName()] = 
$type;
 
   37        $query = 
'SELECT identifier, lang_key, value FROM lng_data WHERE (' . join(
') OR (', $where) . 
')';
 
   43                $results[$row[
'identifier']] = 
new stdClass();
 
   44                $results[$row[
'identifier']]->lang_untouched = array();
 
   45                $results[$row[
'identifier']]->params = array();
 
   47            $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
 
   62        $pattern_old = 
'/##(.+?)##/im';
 
   63        $pattern = 
'/\[(.+?)\]/im';
 
   66            $placeholdersStack = array();
 
   69            foreach (
$res->lang_untouched as $iso2shorthandle => $translation) {
 
   70                $translation = str_replace(
"\\n", 
"\n", $translation);
 
   72                $translation = 
self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), 
'[', 
']');
 
   74                $res->lang[$iso2shorthandle] = 
self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(), 
'##', 
'##');
 
   77            $res->params = array_diff(
 
   79                    call_user_func_array(
'array_merge', $placeholdersStack)
 
   81                array_keys($vars[$langVarToTypeDict[$langVar]]->getParameters())
 
   96        $foundPlaceholders = array();
 
   97        preg_match_all($pattern, $translation, $foundPlaceholders);
 
   98        return (array) $foundPlaceholders[1];
 
  110    private static function replaceFields($string, $foundPlaceholders, $params, $startTag, $endTage)
 
  112        foreach ($foundPlaceholders as $placeholder) {
 
  113            if (array_key_exists(strtoupper($placeholder), $params)) {
 
  114                $string = str_ireplace($startTag . $placeholder . $endTage, $params[strtoupper($placeholder)], $string);
 
  116            if (array_key_exists(strtolower($placeholder), $params)) {
 
  117                $string = str_ireplace($startTag . $placeholder . $endTage, $params[strtolower($placeholder)], $string);
 
  161        $types = array(
'integer');
 
  162        $values = array($userid);
 
  167        foreach ($configArray as 
$type => $channels) {
 
  168            foreach ($channels as $channel => $value) {
 
  175                            'usr_id' => array(
'integer', $userid),
 
  176                            'module' => array(
'text', 
$type),
 
  177                            'channel' => array(
'text', $channel),
 
  191        $types = array(
'integer');
 
  192        $values = array($userid);
 
  199            if (!
$result[$row[
'module']]) {
 
  200                $result[$row[
'module']] = array();
 
  203            $result[$row[
'module']][] = $row[
'channel'];
 
  222        foreach ($userids as $userid) {
 
  226                    'notification_id' => array(
'integer', $notification_id),
 
  227                    'usr_id' => array(
'integer', $userid),
 
  228                    'valid_until' => array(
'integer', $valid_until),
 
  247        $types = array(
'integer', 
'integer', 
'integer', 
'text', 
'integer');
 
  265                    'notification_id' => array(
'integer', $id),
 
  266                    'serialized' => array(
'text', serialize($notification)),
 
  280        $types = array(
'integer');
 
  281        $values = array($id);
 
  293        $types = array(
'text', 
'integer');
 
  294        $values = array($module, $sender_id);
 
  299        while ($row = 
$ilDB->fetchAssoc($rset)) {
 
  300            $users[] = $row[
'usr_id'];
 
  312        $types = array(
'text', 
'integer');
 
  313        $values = array($module, $sender_id);
 
  330        $types = array(
'text', 
'integer');
 
  331        $values = array($module, $sender_id);
 
  357                    'channel_name' => array(
'text', 
$name),
 
  358                    'title' => array(
'text', $title),
 
  359                    'description' => array(
'text', $description),
 
  360                    'class' => array(
'text', $class),
 
  361                    'include' => array(
'text', $classfile),
 
  362                    'config_type' => array(
'text', $config_type),
 
  378    public static function registerType(
$name, $title, $description, $notification_group, $config_type)
 
  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),
 
  404            $query .= 
' WHERE ' . 
$ilDB->in(
'config_type', $config_types, 
false, 
'text');
 
  411        $settings = 
new ilSetting(
'notifications');
 
  413        while ($row = 
$ilDB->fetchAssoc($rset)) {
 
  414            if (!$includeDisabled && !$settings->get(
'enable_' . $row[
'channel_name'])) {
 
  418            $result[$row[
'channel_name']] = array(
 
  419                'name' => $row[
'channel_name'],
 
  420                'title' => $row[
'title'],
 
  421                'description' => $row[
'description'],
 
  422                'handler' => $row[
'class'],
 
  423                'include' => $row[
'include'],
 
  424                'config_type' => $row[
'config_type'],
 
  439            $query .= 
' WHERE ' . 
$ilDB->in(
'config_type', $config_types, 
false, 
'text');
 
  447        while ($row = 
$ilDB->fetchAssoc($rset)) {
 
  448            $result[$row[
'type_name']] = array(
 
  449                'name' => $row[
'type_name'],
 
  450                'title' => $row[
'title'],
 
  451                'description' => $row[
'description'],
 
  452                'group' => $row[
'notification_group'],
 
  453                'config_type' => $row[
'config_type'],
 
  467        $types = array(
'text', 
'text');
 
  468        $values = array($config_name, $type_name);
 
  479        $types = array(
'text', 
'text');
 
  480        $values = array($config_name, $channel_name);
 
  491        $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"';
 
  494        while ($row = 
$ilDB->fetchAssoc($rset)) {
 
  495            $result[$row[
'usr_id']] = (bool) $row[
'value'];
 
An exception for terminatinating execution or to throw for unit testing.
Describes a notification and provides methods for publishing this notification.
static getUsersByListener($module, $sender_id)
static getUsersWithCustomConfig(array $userid)
static registerChannel($name, $title, $description, $class, $classfile, $config_type)
Registers a new notification channel for distributing notifications.
static getAvailableChannels($config_types=array(), $includeDisabled=false)
static replaceFields($string, $foundPlaceholders, $params, $startTag, $endTage)
static storeNotification(ilNotificationConfig $notification)
static loadUserConfig($userid)
static setConfigTypeForType($type_name, $config_name)
static registerType($name, $title, $description, $notification_group, $config_type)
Registers a new notification type.
static enqueueByListener(ilNotificationConfig $notification, $ref_id)
static getAvailableTypes($config_types=array())
static setUserConfig($userid, array $configArray)
Sets the configuration for all given configurations.
static setConfigTypeForChannel($channel_name, $config_name)
static fillPlaceholders($results, $vars, $langVarToTypeDict)
static disableListeners($module, $sender_id)
static enableListeners($module, $sender_id, array $users=array())
static findPlaceholders($pattern, $translation)
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
static removeNotification($id)
static $tbl_notification_queue
static $tbl_notification_data
static $tbl_notification_channels
static $tbl_notification_types
foreach($_POST as $key=> $value) $res