. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Notifications settings configuration class */ class NotificationSettingConfig extends CommonDBTM { public $table = 'glpi_configs'; protected $displaylist = false; static $rightname = 'config'; public function update(array $input, $history = 1, $options = []) { if (isset($input['use_notifications'])) { $config = new Config(); $tmp = [ 'id' => 1, 'use_notifications' => $input['use_notifications'] ]; $config->update($tmp); //disable all notifications types if notifications has been disabled if ($tmp['use_notifications'] == 0) { $modes = Notification_NotificationTemplate::getModes(); foreach (array_keys($modes) as $mode) { $input['notifications_' . $mode] = 0; } } } $config = new Config(); foreach ($input as $k => $v) { if (substr($k, 0, strlen('notifications_')) === 'notifications_') { $tmp = [ 'id' => 1, $k => $v ]; $config->update($tmp); } } } /** * Show configuration form * * @return string|void */ public function showForm($options = []) { global $CFG_GLPI; if (!isset($options['display'])) { $options['display'] = true; } $modes = Notification_NotificationTemplate::getModes(); $out = ''; $modes_settings = []; if (Session::haveRight("config", UPDATE)) { $out .= "