3 require_once
'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
12 public static function getTranslatedLanguageVariablesOfNotificationParameters($vars = array())
16 $ilDB = $DIC->database();
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) .
')';
44 $results[$row[
'identifier']]->lang_untouched = array();
45 $results[$row[
'identifier']]->params = array();
47 $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
50 return self::fillPlaceholders(
$results, $vars, $langVarToTypeDict);
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);
71 $placeholdersStack[] = self::findPlaceholders($pattern, $translation);
72 $translation = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(),
'[',
']');
73 $placeholdersStack[] = self::findPlaceholders($pattern_old, $translation);
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];
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);
151 $ilDB = $DIC->database();
154 $channels = self::getAvailableChannels(array(
'set_by_user'));
155 $types = self::getAvailableTypes(array(
'set_by_user'));
161 $types = array(
'integer');
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),
188 $ilDB = $DIC->database();
191 $types = array(
'integer');
200 $result[$row[
'module']] = array();
203 $result[$row[
'module']][] = $row[
'channel'];
217 $ilDB = $DIC->database();
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),
239 $ilDB = $DIC->database();
247 $types = array(
'integer',
'integer',
'integer',
'text',
'integer');
258 $ilDB = $DIC->database();
265 'notification_id' => array(
'integer',
$id),
266 'serialized' => array(
'text', serialize($notification)),
277 $ilDB = $DIC->database();
280 $types = array(
'integer');
290 $ilDB = $DIC->database();
293 $types = array(
'text',
'integer');
299 while (
$row =
$ilDB->fetchAssoc($rset)) {
309 $ilDB = $DIC->database();
312 $types = array(
'text',
'integer');
322 $ilDB = $DIC->database();
330 $types = array(
'text',
'integer');
352 $ilDB = $DIC->database();
357 'channel_name' => array(
'text',
$name),
358 'title' => array(
'text',
$title),
360 'class' => array(
'text', $class),
361 'include' => array(
'text', $classfile),
362 'config_type' => array(
'text', $config_type),
382 $ilDB = $DIC->database();
387 'type_name' => array(
'text',
$name),
388 'title' => array(
'text',
$title),
390 'notification_group' => array(
'text', $notification_group),
391 'config_type' => array(
'text', $config_type),
400 $ilDB = $DIC->database();
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'])) {
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'],
435 $ilDB = $DIC->database();
439 $query .=
' WHERE ' .
$ilDB->in(
'config_type', $config_types,
false,
'text');
447 while (
$row =
$ilDB->fetchAssoc($rset)) {
449 'name' => $row[
'type_name'],
450 'title' => $row[
'title'],
451 'description' => $row[
'description'],
452 'group' => $row[
'notification_group'],
453 'config_type' => $row[
'config_type'],
464 $ilDB = $DIC->database();
467 $types = array(
'text',
'text');
468 $values = array($config_name, $type_name);
476 $ilDB = $DIC->database();
479 $types = array(
'text',
'text');
480 $values = array($config_name, $channel_name);
489 $ilDB = $DIC->database();
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)) {
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
static $tbl_notification_queue
static $tbl_notification_types
if(empty($userids)) $userid
if(!array_key_exists('StateId', $_REQUEST)) $id
static getUsersWithCustomConfig(array $userid)
static registerChannel($name, $title, $description, $class, $classfile, $config_type)
Registers a new notification channel for distributing notifications.
static storeNotification(ilNotificationConfig $notification)
static getUsersByListener($module, $sender_id)
if($modEnd===false) $module
static registerType($name, $title, $description, $notification_group, $config_type)
Registers a new notification type.
Describes a notification and provides methods for publishing this notification.
static setConfigTypeForChannel($channel_name, $config_name)
static setConfigTypeForType($type_name, $config_name)
foreach($_POST as $key=> $value) $res
static disableListeners($module, $sender_id)
static $tbl_notification_channels
static enqueueByListener(ilNotificationConfig $notification, $ref_id)
static findPlaceholders($pattern, $translation)
static replaceFields($string, $foundPlaceholders, $params, $startTag, $endTage)
static fillPlaceholders($results, $vars, $langVarToTypeDict)
static getAvailableTypes($config_types=array())
static $tbl_notification_data
static setUserConfig($userid, array $configArray)
Sets the configuration for all given configurations.
static getAvailableChannels($config_types=array(), $includeDisabled=false)
static loadUserConfig($userid)
static enableListeners($module, $sender_id, array $users=array())
static removeNotification($id)