ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilNotificationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Services/Object/classes/class.ilObjectGUI.php';
5require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
6require_once 'Services/Notifications/classes/class.ilNotificationHandler.php';
7
16{
17 private $handler = array();
18
20 private $user;
21
23 private $template;
24
26 private $controller;
27
29 private $language;
30
32 private $locatorGUI;
33
43 public function __construct(
44 \ilUser $user = null,
45 \ilTemplate $template = null,
46 \ilCtrl $controller = null,
47 \ilLanguage $language = null,
49 \ILIAS\DI\Container $dic = null
50 ) {
51 if ($dic === null) {
52 global $DIC;
53 $dic = $DIC;
54 }
55
56 if ($user === null) {
57 $user = $dic->user();
58 }
59 $this->user = $user;
60
61 if ($template === null) {
62 $template = $dic->ui()->mainTemplate();
63 }
64 $this->template = $template;
65
66 if ($controller === null) {
67 $controller = $dic->ctrl();
68 }
69 $this->controller = $controller;
70
71 if ($language === null) {
72 $language = $dic->language();
73 }
74 $this->language = $language;
75
76 if ($locatorGUI === null) {
77 $locatorGUI = $dic['ilLocator'];
78 }
79 $this->locatorGUI = $locatorGUI;
80
81 $this->type = "not";
82
83 require_once 'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
84 }
85
86 public static function _forwards()
87 {
88 return array();
89 }
90
91 public function executeCommand()
92 {
93 if (!$this->controller->getCmd()) {
94 return;
95 }
96
97 $cmd = $this->controller->getCmd() . 'Object';
98 $this->$cmd();
99 }
100
101 public function getHandler($type)
102 {
103 return $this->handler[$type];
104 }
105
106 private function getAvailableTypes($types = array())
107 {
109 }
110
111 private function getAvailableChannels($types = array())
112 {
114 }
115
124 {
126
127 if ($this->user->getId() == ANONYMOUS_USER_ID) {
128 return '{}';
129 }
130
131 require_once 'Services/Notifications/classes/class.ilNotificationEchoHandler.php';
132 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
133
135 $this->user->getId(),
136 true,
137 (int) $_REQUEST['max_age']
138 );
139
140 $result = new stdClass();
141 $result->notifications = $notifications;
142 $result->server_time = time();
143 echo json_encode($result);
144 exit;
145 }
146
148 {
150
151 require_once 'Services/Notifications/classes/class.ilNotificationEchoHandler.php';
152 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
153
154 ilNotificationOSDHandler::removeNotification($_REQUEST['notification_id']);
155
156 exit;
157 }
158
159 public function addHandler($channel, ilNotificationHandler $handler)
160 {
161 if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
162 $this->handler[$channel] = array();
163 }
164
165 $this->handler[$channel][] = $handler;
166 }
167
169 {
170 if ($_POST['enable_custom_notification_configuration']) {
171 $this->user->writePref('use_custom_notification_setting', 1);
172 } else {
173 $this->user->writePref('use_custom_notification_setting', 0);
174 }
175
176 $this->showSettingsObject();
177 }
178
179 public function showSettingsObject()
180 {
181 require_once 'Services/Notifications/classes/class.ilNotificationSettingsTable.php';
182 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
183
184 $userTypes = ilNotificationDatabaseHandler::loadUserConfig($this->user->getId());
185
186 $this->language->loadLanguageModule('notification');
187
188 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
189 $form = new ilPropertyFormGUI();
190 $chk = new ilCheckboxInputGUI($this->language->txt('enable_custom_notification_configuration'), 'enable_custom_notification_configuration');
191 $chk->setValue('1');
192 $chk->setChecked($this->user->getPref('use_custom_notification_setting') == 1);
193 $form->addItem($chk);
194
195 $form->setFormAction($this->controller->getFormAction($this, 'showSettingsObject'));
196 $form->addCommandButton('saveCustomizingOption', $this->language->txt('save'));
197 $form->addCommandButton('showSettings', $this->language->txt('cancel'));
198
199 $table = new ilNotificationSettingsTable($this, 'a title', $this->getAvailableChannels(array('set_by_user')), $userTypes);
200
201 $table->setFormAction($this->controller->getFormAction($this, 'saveSettings'));
202 $table->setData($this->getAvailableTypes(array('set_by_user')));
203
204 if ($this->user->getPref('use_custom_notification_setting') == 1) {
205 $table->addCommandButton('saveSettings', $this->language->txt('save'));
206 $table->addCommandButton('showSettings', $this->language->txt('cancel'));
207 $table->setEditable(true);
208 } else {
209 $table->setEditable(false);
210 }
211
212 $this->template->setContent($form->getHtml() . $table->getHTML());
213 }
214
215 public function addLocatorItems()
216 {
217 if (is_object($this->object)) {
218 $this->locatorGUI->addItem(
219 $this->object->getTitle(),
220 $this->controller->getLinkTarget($this, ''),
221 '',
222 $_GET["ref_id"]
223 );
224 }
225 }
226
227 private function saveSettingsObject()
228 {
229 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
230
232 $this->user->getId(),
233 $_REQUEST['notification'] ? $_REQUEST['notification'] : array()
234 );
235
236 $this->showSettingsObject();
237 }
238}
$result
user()
Definition: user.php:4
exit
Definition: backend.php:16
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class provides processing control methods.
language handling
locator handling class
static getAvailableChannels($config_types=array(), $includeDisabled=false)
static setUserConfig($userid, array $configArray)
Sets the configuration for all given configurations.
getOSDNotificationsObject()
Returns the pending on screen notifications for a user request.
getAvailableTypes($types=array())
addHandler($channel, ilNotificationHandler $handler)
getAvailableChannels($types=array())
__construct(\ilUser $user=null, \ilTemplate $template=null, \ilCtrl $controller=null, \ilLanguage $language=null, \ilLocatorGUI $locatorGUI=null, \ILIAS\DI\Container $dic=null)
@access public
Base class for notification handlers.
static removeNotification($notification_osd_id)
Removes a notifcation and triggers a follow up notification to remove the notification from the brows...
static getNotificationsForUser($user_id, $append_osd_id_to_link=true, $max_age_seconds=0)
This class represents a property form user interface.
static enableWebAccessWithoutSession($enable_web_access_without_session)
special template class to simplify handling of ITX/PEAR
Class HTTPServicesTest.
Class BaseForm.
$type
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7