Server : Apache/2.4.41 (Ubuntu) System : Linux journalup 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/lib/pkp/classes/notification/ |
<?php /** * @file classes/notification/NotificationSettingsDAO.inc.php * * Copyright (c) 2014-2020 Simon Fraser University * Copyright (c) 2000-2020 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class NotificationSettingsDAO * @ingroup notification * @see Notification * * @brief Operations for retrieving and modifying Notification metadata. */ import('classes.notification.Notification'); class NotificationSettingsDAO extends DAO { /** * Update a notification's metadata * @param $notificationId int * @return $params array */ function getNotificationSettings($notificationId) { $result = $this->retrieve( 'SELECT * FROM notification_settings WHERE notification_id = ?', (int) $notificationId ); $params = array(); while (!$result->EOF) { $row = $result->GetRowAssoc(false); $name = $row['setting_name']; $value = $this->convertFromDB($row['setting_value'], $row['setting_type']); $locale = $row['locale']; if ($locale == '') $params[$name] = $value; else $params[$name][$locale] = $value; $result->MoveNext(); } $result->Close(); return $params; } /** * Store a notification's metadata * @param $notificationId int * @param $name string * @param $value string * @param $isLocalized boolean optional * @param $type string optional * @param $params array */ function updateNotificationSetting($notificationId, $name, $value, $isLocalized = false, $type = null) { $keyFields = array('setting_name', 'locale', 'notification_id'); if (!$isLocalized) { $value = $this->convertToDB($value, $type); $this->replace('notification_settings', array( 'notification_id' => (int) $notificationId, 'setting_name' => $name, 'setting_value' => $value, 'setting_type' => $type, 'locale' => '' ), $keyFields ); } else { if (is_array($value)) foreach ($value as $locale => $localeValue) { $this->update('DELETE FROM notification_settings WHERE notification_id = ? AND setting_name = ? AND locale = ?', array($notificationId, $name, $locale)); if (empty($localeValue)) continue; $type = null; $this->update('INSERT INTO notification_settings (notification_id, setting_name, setting_value, setting_type, locale) VALUES (?, ?, ?, ?, ?)', array( (int) $notificationId, $name, $this->convertToDB($localeValue, $type), $type, $locale ) ); } } } /** * Delete all settings for a notification * @param $notificationId */ function deleteSettingsByNotificationId($notificationId) { return $this->update('DELETE FROM notification_settings WHERE notification_id = ?', (int) $notificationId); } }