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();
50 $results[$row[
'identifier']]->lang_untouched = array();
51 $results[$row[
'identifier']]->params = array();
53 $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
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);
80 $translation =
self::replaceFields($translation, $placeholdersStack[count($placeholdersStack) - 1], $vars[$langVarToTypeDict[$langVar]]->getParameters(),
'[',
']');
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];
118 private static function replaceFields($string, $foundPlaceholders, $params, $startTag, $endTage)
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);
146 $types = array(
'integer');
147 $values = array($userid);
148 $ilDB->manipulateF(
$query, $types, $values);
150 foreach ($configArray as $type => $channels) {
151 foreach ($channels as $channel => $value) {
157 'usr_id' => array(
'integer', $userid),
158 'module' => array(
'text', $type),
159 'channel' => array(
'text', $channel),
170 $types = array(
'integer');
171 $values = array($userid);
173 $res = $ilDB->queryF(
$query, $types, $values);
177 while (
$row = $ilDB->fetchAssoc(
$res)) {
179 $result[$row[
'module']] = array();
181 $result[$row[
'module']][] = $row[
'channel'];
196 foreach($userids as $userid) {
200 'notification_id' => array(
'integer', $notification_id),
201 'usr_id' => array(
'integer', $userid),
202 'valid_until' => array(
'integer', $valid_until),
218 $types = array(
'integer',
'integer',
'text',
'integer');
220 $values = array($notification_id, $valid_until, $notification->
getType(),
$ref_id);
222 $ilDB->manipulateF(
$query, $types, $values);
255 'notification_id' => array(
'integer', $id),
256 'serialized' => array(
'text', serialize($notification)),
267 $types = array(
'integer');
268 $values = array($id);
270 $ilDB->manipulateF(
$query, $types, $values);
277 $types = array(
'text',
'integer');
278 $values = array($module, $sender_id);
282 $rset = $ilDB->queryF(
$query, $types, $values);
283 while(
$row = $ilDB->fetchAssoc($rset)) {
284 $users[] =
$row[
'usr_id'];
293 $types = array(
'text',
'integer');
294 $values = array($module, $sender_id);
296 $ilDB->manipulateF(
$query, $types, $values);
305 $query .=
' ' . $ilDB->in(
'usr_id', $users);
308 $types = array(
'text',
'integer');
309 $values = array($module, $sender_id);
311 $ilDB->manipulateF(
$query, $types, $values);
320 'channel_name' => array(
'text', $name),
321 'title' => array(
'text',
$title),
322 'description' => array(
'text', $description),
323 'class' => array(
'text', $class),
324 'include' => array(
'text', $classfile),
325 'config_type' => array(
'text', $config_type),
330 public static function registerType($name,
$title, $description, $notification_group, $config_type) {
336 'type_name' => array(
'text', $name),
337 'title' => array(
'text',
$title),
338 'description' => array(
'text', $description),
339 'notification_group' => array(
'text', $notification_group),
340 'config_type' => array(
'text', $config_type),
350 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
352 $rset = $ilDB->query(
$query);
356 $settings =
new ilSetting(
'notifications');
358 while (
$row = $ilDB->fetchAssoc($rset)) {
359 if (!$includeDisabled && !$settings->get(
'enable_' .
$row[
'channel_name']))
363 'name' => $row[
'channel_name'],
364 'title' => $row[
'title'],
365 'description' => $row[
'description'],
366 'handler' => $row[
'class'],
367 'include' => $row[
'include'],
368 'config_type' => $row[
'config_type'],
380 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
383 $rset = $ilDB->query(
$query);
387 while (
$row = $ilDB->fetchAssoc($rset)) {
389 'name' => $row[
'type_name'],
390 'title' => $row[
'title'],
391 'description' => $row[
'description'],
392 'group' => $row[
'notification_group'],
393 'config_type' => $row[
'config_type'],
403 $types = array(
'text',
'text');
404 $values = array($config_name, $type_name);
405 $ilDB->manipulateF(
$query, $types, $values);
411 $types = array(
'text',
'text');
412 $values = array($config_name, $channel_name);
413 $ilDB->manipulateF(
$query, $types, $values);
419 $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"';
420 $rset = $ilDB->query(
$query);
422 while(
$row = $ilDB->fetchAssoc($rset)) {