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);
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)) {
205 $result[$row[
'module']] = array();
207 $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),
244 $types = array(
'integer',
'integer',
'text',
'integer');
246 $values = array($notification_id, $valid_until, $notification->
getType(),
$ref_id);
248 $ilDB->manipulateF(
$query, $types, $values);
281 'notification_id' => array(
'integer', $id),
282 'serialized' => array(
'text', serialize($notification)),
293 $types = array(
'integer');
294 $values = array($id);
296 $ilDB->manipulateF(
$query, $types, $values);
303 $types = array(
'text',
'integer');
304 $values = array($module, $sender_id);
308 $rset = $ilDB->queryF(
$query, $types, $values);
309 while(
$row = $ilDB->fetchAssoc($rset)) {
310 $users[] =
$row[
'usr_id'];
319 $types = array(
'text',
'integer');
320 $values = array($module, $sender_id);
322 $ilDB->manipulateF(
$query, $types, $values);
331 $query .=
' ' . $ilDB->in(
'usr_id', $users);
334 $types = array(
'text',
'integer');
335 $values = array($module, $sender_id);
337 $ilDB->manipulateF(
$query, $types, $values);
358 'channel_name' => array(
'text', $name),
359 'title' => array(
'text',
$title),
360 'description' => array(
'text', $description),
361 'class' => array(
'text', $class),
362 'include' => array(
'text', $classfile),
363 'config_type' => array(
'text', $config_type),
379 public static function registerType($name,
$title, $description, $notification_group, $config_type) {
385 'type_name' => array(
'text', $name),
386 'title' => array(
'text',
$title),
387 'description' => array(
'text', $description),
388 'notification_group' => array(
'text', $notification_group),
389 'config_type' => array(
'text', $config_type),
399 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
401 $rset = $ilDB->query(
$query);
405 $settings =
new ilSetting(
'notifications');
407 while (
$row = $ilDB->fetchAssoc($rset)) {
408 if (!$includeDisabled && !$settings->get(
'enable_' .
$row[
'channel_name']))
412 'name' => $row[
'channel_name'],
413 'title' => $row[
'title'],
414 'description' => $row[
'description'],
415 'handler' => $row[
'class'],
416 'include' => $row[
'include'],
417 'config_type' => $row[
'config_type'],
429 $query .=
' WHERE ' . $ilDB->in(
'config_type', $config_types,
false,
'text');
432 $rset = $ilDB->query(
$query);
436 while (
$row = $ilDB->fetchAssoc($rset)) {
438 'name' => $row[
'type_name'],
439 'title' => $row[
'title'],
440 'description' => $row[
'description'],
441 'group' => $row[
'notification_group'],
442 'config_type' => $row[
'config_type'],
452 $types = array(
'text',
'text');
453 $values = array($config_name, $type_name);
454 $ilDB->manipulateF(
$query, $types, $values);
460 $types = array(
'text',
'text');
461 $values = array($config_name, $channel_name);
462 $ilDB->manipulateF(
$query, $types, $values);
468 $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"';
469 $rset = $ilDB->query(
$query);
471 while(
$row = $ilDB->fetchAssoc($rset)) {