19declare(strict_types=1);
46 $lang_var_to_type_dict = [];
48 foreach ($vars as $type => $var) {
50 'module = %s AND identifier = %s',
51 $ilDB->quote($var->getLanguageModule()),
52 $ilDB->quote($var->getName())
55 $lang_var_to_type_dict[$var->getName()] = $type;
62 $query =
'SELECT identifier, lang_key, value FROM lng_data WHERE (' . implode(
') OR (', $where) .
')';
67 if (!isset(
$results[$row[
'identifier']])) {
68 $results[$row[
'identifier']] =
new stdClass();
69 $results[$row[
'identifier']]->lang_untouched = [];
70 $results[$row[
'identifier']]->params = [];
72 $results[$row[
'identifier']]->lang_untouched[$row[
'lang_key']] = $row[
'value'];
86 $pattern_old =
'/##(.+?)##/im';
87 $pattern =
'/\[(.+?)\]/im';
90 $placeholders_stack = [];
93 foreach (
$res->lang_untouched as $iso2_short_handle => $translation) {
94 $translation = str_replace(
"\\n",
"\n", (
string) $translation);
98 $placeholders_stack[count($placeholders_stack) - 1],
99 $vars[$lang_var_to_type_dict[$lang_var]]->getParameters(),
106 $placeholders_stack[count($placeholders_stack) - 1],
107 $vars[$lang_var_to_type_dict[$lang_var]]->getParameters(),
113 $res->params = array_diff(
115 array_merge(...$placeholders_stack)
117 array_keys($vars[$lang_var_to_type_dict[$lang_var]]->getParameters())
129 $foundPlaceholders = [];
130 preg_match_all($pattern, $translation, $foundPlaceholders);
132 return (array) $foundPlaceholders[1];
141 array $foundPlaceholders,
147 foreach ($foundPlaceholders as $placeholder) {
148 if (array_key_exists(strtoupper($placeholder),
$params)) {
149 $result = str_ireplace($startTag . $placeholder . $endTage,
$params[strtoupper($placeholder)], $result);
151 if (array_key_exists(strtolower($placeholder),
$params)) {
152 $result = str_ireplace($startTag . $placeholder . $endTage,
$params[strtolower($placeholder)], $result);
167 if ($userid !== -1) {
168 $channels = self::getAvailableChannels([
'set_by_user']);
169 $types = self::getAvailableTypes([
'set_by_user']);
184 $ilDB->manipulateF($query, $types, $values);
186 foreach ($configArray as $type => $channels) {
187 foreach ($channels as $channel => $value) {
216 $res =
$ilDB->queryF($query, $types, $values);
221 if (!isset($result[$row[
'module']])) {
222 $result[$row[
'module']] = [];
225 $result[$row[
'module']][] = $row[
'channel'];
244 $notification_id = self::storeNotification($notification);
247 foreach ($usr_ids as $userid) {
266 $notification_id = self::storeNotification($notification);
288 $ilDB->manipulateF($query, $types, $values);
320 $ilDB->manipulateF($query, $types, $values);
334 $values = [$module, $sender_id];
338 $rset =
$ilDB->queryF($query, $types, $values);
339 while ($row =
$ilDB->fetchAssoc($rset)) {
340 $users[] = (
int) $row[
'usr_id'];
354 $values = [$module, $sender_id];
356 $ilDB->manipulateF($query, $types, $values);
362 public static function enableListeners(
string $module,
int $sender_id, array $users = []): void
375 $values = [$module, $sender_id];
377 $ilDB->manipulateF($query, $types, $values);
407 string $notification_group,
416 'notification_group' => [
ilDBConstants::T_TEXT, $notification_group],
432 $query =
'SELECT channel_name, title, description, class, include, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_channels;
437 $rset =
$ilDB->query($query);
441 $settings =
new ilSetting(
'notifications');
443 while ($row =
$ilDB->fetchAssoc($rset)) {
444 if (!$include_disabled && !$settings->get(
'enable_' . $row[
'channel_name'])) {
448 $result[$row[
'channel_name']] = [
449 'name' => $row[
'channel_name'],
450 'title' => $row[
'title'],
451 'description' => $row[
'description'],
452 'handler' => $row[
'class'],
453 'include' => $row[
'include'],
454 'config_type' => $row[
'config_type'],
471 $query =
'SELECT type_name, title, description, notification_group, config_type FROM ' . ilNotificationSetupHelper::$tbl_notification_types;
476 $rset =
$ilDB->query($query);
480 while ($row =
$ilDB->fetchAssoc($rset)) {
481 $result[$row[
'type_name']] = [
482 'name' => $row[
'type_name'],
483 'title' => $row[
'title'],
484 'description' => $row[
'description'],
485 'group' => $row[
'notification_group'],
486 'config_type' => $row[
'config_type'],
499 $query =
'UPDATE ' . ilNotificationSetupHelper::$tbl_notification_types .
' SET config_type = %s WHERE type_name = %s';
501 $values = [$config_name, $type_name];
502 $ilDB->manipulateF($query, $types, $values);
511 $query =
'UPDATE ' . ilNotificationSetupHelper::$tbl_notification_channels .
' SET config_type = %s WHERE channel_name = %s';
513 $values = [$config_name, $channel_name];
514 $ilDB->manipulateF($query, $types, $values);
527 $query =
'SELECT usr_id, value FROM usr_pref WHERE ' .
$ilDB->in(
532 ) .
' AND keyword = ' .
$ilDB->quote(
533 'use_custom_notification_setting',
535 ) .
' AND value = ' .
$ilDB->quote(
539 $rset =
$ilDB->query($query);
541 while ($row =
$ilDB->fetchAssoc($rset)) {
542 $result[(
int) $row[
'usr_id']] = (
bool) $row[
'value'];
545 $missing_usr_ids = array_diff(
550 $result = $result + array_combine(
552 array_fill(0, count($missing_usr_ids),
false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
description of a localized parameter this information is used locate translations while processing no...
static registerChannel(ilDBInterface $db, string $name, string $title, string $description, string $class, string $classfile, string $config_type)
static getAvailableTypes(array $config_types=[])
static setUserConfig(int $userid, array $configArray)
static disableListeners(string $module, int $sender_id)
static getAvailableChannels(array $config_types=[], bool $include_disabled=false)
static setConfigTypeForChannel(string $channel_name, string $config_name)
static registerType(ilDBInterface $db, string $name, string $title, string $description, string $notification_group, string $config_type)
static fillPlaceholders(array $results, array $vars, array $lang_var_to_type_dict)
static enableListeners(string $module, int $sender_id, array $users=[])
static storeNotification(ilNotificationConfig $notification)
static findPlaceholders(string $pattern, string $translation)
static removeNotification(int $id)
static getUsersWithCustomConfig(array $usr_ids)
static enqueueByListener(ilNotificationConfig $notification, int $ref_id)
static getUsersByListener(string $module, int $sender_id)
static getTranslatedLanguageVariablesOfNotificationParameters(array $vars=[])
static enqueueByUsers(ilNotificationConfig $notification, array $usr_ids)
static setConfigTypeForType(string $type_name, string $config_name)
static replaceFields(string $string, array $foundPlaceholders, array $params, string $startTag, string $endTage)
static loadUserConfig(int $userid)
static string $tbl_notification_data
static string $tbl_userconfig
static string $tbl_notification_queue
static string $tbl_userlistener
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params