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)
32 $where[] = sprintf(
'module = %s AND identifier = %s', $ilDB->quote($var->getLanguageModule()), $ilDB->quote($var->getName()));
33 $langVarToTypeDict[$var->getName()] = $type;
41 $query =
'SELECT identifier, lang_key, value FROM lng_data WHERE (' . join(
') OR (', $where) .
')';
45 while(
$row = $ilDB->fetchAssoc(
$res))
49 $results[$row[
'identifier']] =
new stdClass();
53 $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
56 return self::fillPlaceholders(
$results, $vars, $langVarToTypeDict);
68 $pattern_old =
'/##(.+?)##/im';
69 $pattern =
'/\[(.+?)\]/im';
73 $placeholdersStack =
array();
76 foreach(
$res->lang_untouched as $iso2shorthandle => $translation)
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(),
'##',
'##');
85 $res->params = array_diff(
87 call_user_func_array(
'array_merge', $placeholdersStack)
89 array_keys($vars[$langVarToTypeDict[$langVar]]->getParameters())
104 $foundPlaceholders =
array();
105 preg_match_all($pattern, $translation, $foundPlaceholders);
106 return (
array)$foundPlaceholders[1];
120 foreach($foundPlaceholders as $placeholder)
122 if(array_key_exists(strtoupper($placeholder),
$params))
124 $string = str_ireplace($startTag . $placeholder . $endTage,
$params[strtoupper($placeholder)], $string);
126 if(array_key_exists(strtolower($placeholder),
$params))
128 $string = str_ireplace($startTag . $placeholder . $endTage,
$params[strtolower($placeholder)], $string);
162 $channels = self::getAvailableChannels(
array(
'set_by_user'));
163 $types = self::getAvailableTypes(
array(
'set_by_user'));
170 $types =
array(
'integer');
171 $values =
array($userid);
174 $ilDB->manipulateF(
$query, $types, $values);
176 foreach ($configArray as $type => $channels) {
177 foreach ($channels as $channel => $value) {
183 'usr_id' =>
array(
'integer', $userid),
184 'module' =>
array(
'text', $type),
185 'channel' =>
array(
'text', $channel),
196 $types =
array(
'integer');
197 $values =
array($userid);
199 $res = $ilDB->queryF(
$query, $types, $values);
203 while (
$row = $ilDB->fetchAssoc(
$res)) {
207 $result[$row[
'module']][] = $row[
'channel'];
223 foreach($userids as $userid)
228 'notification_id' =>
array(
'integer', $notification_id),
229 'usr_id' =>
array(
'integer', $userid),
230 'valid_until' =>
array(
'integer', $valid_until),
246 $types =
array(
'integer',
'integer',
'integer',
'text',
'integer');
250 $ilDB->manipulateF(
$query, $types, $values);
283 'notification_id' =>
array(
'integer', $id),
284 'serialized' =>
array(
'text', serialize($notification)),
295 $types =
array(
'integer');
296 $values =
array($id);
298 $ilDB->manipulateF(
$query, $types, $values);
305 $types =
array(
'text',
'integer');
306 $values =
array($module, $sender_id);
310 $rset = $ilDB->queryF(
$query, $types, $values);
311 while(
$row = $ilDB->fetchAssoc($rset)) {
312 $users[] =
$row[
'usr_id'];
321 $types =
array(
'text',
'integer');
322 $values =
array($module, $sender_id);
324 $ilDB->manipulateF(
$query, $types, $values);
333 $query .=
' ' . $ilDB->in(
'usr_id', $users);
336 $types =
array(
'text',
'integer');
337 $values =
array($module, $sender_id);
339 $ilDB->manipulateF(
$query, $types, $values);
360 'channel_name' =>
array(
'text', $name),
362 'description' =>
array(
'text', $description),
363 'class' =>
array(
'text', $class),
364 'include' =>
array(
'text', $classfile),
365 'config_type' =>
array(
'text', $config_type),
381 public static function registerType($name,
$title, $description, $notification_group, $config_type) {
387 'type_name' =>
array(
'text', $name),
389 'description' =>
array(
'text', $description),
390 'notification_group' =>
array(
'text', $notification_group),
391 'config_type' =>
array(
'text', $config_type),
401 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
403 $rset = $ilDB->query(
$query);
407 $settings =
new ilSetting(
'notifications');
409 while (
$row = $ilDB->fetchAssoc($rset)) {
410 if (!$includeDisabled && !$settings->get(
'enable_' .
$row[
'channel_name']))
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'],
431 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
434 $rset = $ilDB->query(
$query);
438 while (
$row = $ilDB->fetchAssoc($rset)) {
440 'name' => $row[
'type_name'],
441 'title' => $row[
'title'],
442 'description' => $row[
'description'],
443 'group' => $row[
'notification_group'],
444 'config_type' => $row[
'config_type'],
454 $types =
array(
'text',
'text');
455 $values =
array($config_name, $type_name);
456 $ilDB->manipulateF(
$query, $types, $values);
462 $types =
array(
'text',
'text');
463 $values =
array($config_name, $channel_name);
464 $ilDB->manipulateF(
$query, $types, $values);
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);
473 while(
$row = $ilDB->fetchAssoc($rset)) {
static enqueueByUsers(ilNotificationConfig $notification, array $userids)
static $tbl_notification_queue
static $tbl_notification_types
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)
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)
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)