3 require_once
'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
12 public static function getTranslatedLanguageVariablesOfNotificationParameters($vars =
array())
20 $langVarToTypeDict =
array();
22 foreach ($vars as
$type => $var) {
30 $where[] = sprintf(
'module = %s AND identifier = %s', $ilDB->quote($var->getLanguageModule()), $ilDB->quote($var->getName()));
31 $langVarToTypeDict[$var->getName()] =
$type;
38 $query =
'SELECT identifier, lang_key, value FROM lng_data WHERE (' . join(
') OR (', $where) .
')';
42 while (
$row = $ilDB->fetchAssoc(
$res)) {
44 $results[$row[
'identifier']] =
new stdClass();
48 $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
51 return self::fillPlaceholders(
$results, $vars, $langVarToTypeDict);
63 $pattern_old =
'/##(.+?)##/im';
64 $pattern =
'/\[(.+?)\]/im';
67 $placeholdersStack =
array();
70 foreach (
$res->lang_untouched as $iso2shorthandle => $translation) {
71 $translation = str_replace(
"\\n",
"\n", $translation);
72 $placeholdersStack[] = self::findPlaceholders($pattern, $translation);
73 $translation = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(),
'[',
']');
74 $placeholdersStack[] = self::findPlaceholders($pattern_old, $translation);
75 $res->lang[$iso2shorthandle] = self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(),
'##',
'##');
78 $res->params = array_diff(
80 call_user_func_array(
'array_merge', $placeholdersStack)
82 array_keys($vars[$langVarToTypeDict[$langVar]]->getParameters())
97 $foundPlaceholders =
array();
98 preg_match_all($pattern, $translation, $foundPlaceholders);
99 return (
array) $foundPlaceholders[1];
113 foreach ($foundPlaceholders as $placeholder) {
114 if (array_key_exists(strtoupper($placeholder),
$params)) {
115 $string = str_ireplace($startTag . $placeholder . $endTage,
$params[strtoupper($placeholder)], $string);
117 if (array_key_exists(strtolower($placeholder),
$params)) {
118 $string = str_ireplace($startTag . $placeholder . $endTage,
$params[strtolower($placeholder)], $string);
153 $channels = self::getAvailableChannels(
array(
'set_by_user'));
154 $types = self::getAvailableTypes(
array(
'set_by_user'));
160 $types =
array(
'integer');
164 $ilDB->manipulateF(
$query, $types, $values);
166 foreach ($configArray as
$type => $channels) {
167 foreach ($channels as $channel => $value) {
176 'channel' =>
array(
'text', $channel),
188 $types =
array(
'integer');
191 $res = $ilDB->queryF(
$query, $types, $values);
195 while (
$row = $ilDB->fetchAssoc(
$res)) {
200 $result[$row[
'module']][] = $row[
'channel'];
217 foreach ($userids as
$userid) {
221 'notification_id' =>
array(
'integer', $notification_id),
222 'usr_id' =>
array(
'integer', $userid),
223 'valid_until' =>
array(
'integer', $valid_until),
240 $types =
array(
'integer',
'integer',
'integer',
'text',
'integer');
244 $ilDB->manipulateF(
$query, $types, $values);
278 'notification_id' =>
array(
'integer',
$id),
279 'serialized' =>
array(
'text', serialize($notification)),
291 $types =
array(
'integer');
294 $ilDB->manipulateF(
$query, $types, $values);
302 $types =
array(
'text',
'integer');
307 $rset = $ilDB->queryF(
$query, $types, $values);
308 while (
$row = $ilDB->fetchAssoc($rset)) {
319 $types =
array(
'text',
'integer');
322 $ilDB->manipulateF(
$query, $types, $values);
335 $types =
array(
'text',
'integer');
338 $ilDB->manipulateF(
$query, $types, $values);
363 'class' =>
array(
'text', $class),
364 'include' =>
array(
'text', $classfile),
365 'config_type' =>
array(
'text', $config_type),
391 'notification_group' =>
array(
'text', $notification_group),
392 'config_type' =>
array(
'text', $config_type),
403 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
406 $rset = $ilDB->query(
$query);
410 $settings =
new ilSetting(
'notifications');
412 while (
$row = $ilDB->fetchAssoc($rset)) {
413 if (!$includeDisabled && !$settings->get(
'enable_' .
$row[
'channel_name'])) {
418 'name' => $row[
'channel_name'],
419 'title' => $row[
'title'],
420 'description' => $row[
'description'],
421 'handler' => $row[
'class'],
422 'include' => $row[
'include'],
423 'config_type' => $row[
'config_type'],
436 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
440 $rset = $ilDB->query(
$query);
444 while (
$row = $ilDB->fetchAssoc($rset)) {
446 'name' => $row[
'type_name'],
447 'title' => $row[
'title'],
448 'description' => $row[
'description'],
449 'group' => $row[
'notification_group'],
450 'config_type' => $row[
'config_type'],
461 $types =
array(
'text',
'text');
462 $values =
array($config_name, $type_name);
463 $ilDB->manipulateF(
$query, $types, $values);
470 $types =
array(
'text',
'text');
471 $values =
array($config_name, $channel_name);
472 $ilDB->manipulateF(
$query, $types, $values);
479 $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"';
480 $rset = $ilDB->query(
$query);
482 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)
Create styles array
The data for the language used.
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)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static loadUserConfig($userid)
static enableListeners($module, $sender_id, array $users=array())
static removeNotification($id)