ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
23 public function __construct()
24 {
25 $this->type = "not";
26
27 require_once 'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
28 }
29
30 public static function _forwards()
31 {
32 return array();
33 }
34
35 public function executeCommand()
36 {
37 global $ilCtrl;
38
39 if (!$ilCtrl->getCmd()) {
40 return;
41 }
42
43 $cmd = $ilCtrl->getCmd() . 'Object';
44 $this->$cmd();
45 }
46
47 public function getHandler($type)
48 {
49 return $this->handler[$type];
50 }
51
52 private function getAvailableTypes($types = array())
53 {
55 }
56
57 private function getAvailableChannels($types = array())
58 {
60 }
61
69 public function getOSDNotificationsObject()
70 {
71 global $ilUser;
72
74
75 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
76 return '{}';
77 }
78
79 require_once 'Services/Notifications/classes/class.ilNotificationEchoHandler.php';
80 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
81
82 $notifications = ilNotificationOSDHandler::getNotificationsForUser($ilUser->getId(), true, (int) $_REQUEST['max_age']);
83 $result = new stdClass();
84 $result->notifications = $notifications;
85 $result->server_time = time();
86 echo json_encode($result);
87 exit;
88 }
89
91 {
92 global $ilUser;
93
95
96 require_once 'Services/Notifications/classes/class.ilNotificationEchoHandler.php';
97 require_once 'Services/Notifications/classes/class.ilNotificationOSDHandler.php';
98
99 ilNotificationOSDHandler::removeNotification($_REQUEST['notification_id']);
100
101 exit;
102 }
103
104 public function addHandler($channel, ilNotificationHandler $handler)
105 {
106 if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
107 $this->handler[$channel] = array();
108 }
109
110 $this->handler[$channel][] = $handler;
111 }
112
114 {
115 global $ilUser;
116
117 if ($_POST['enable_custom_notification_configuration']) {
118 $ilUser->writePref('use_custom_notification_setting', 1);
119 } else {
120 $ilUser->writePref('use_custom_notification_setting', 0);
121 }
122
123 $this->showSettingsObject();
124 }
125
126 public function showSettingsObject()
127 {
128 global $tpl, $ilCtrl, $ilUser, $lng;
129
130 require_once 'Services/Notifications/classes/class.ilNotificationSettingsTable.php';
131 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
132
134
135 $lng->loadLanguageModule('notification');
136
137 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
138 $form = new ilPropertyFormGUI();
139 $chk = new ilCheckboxInputGUI($lng->txt('enable_custom_notification_configuration'), 'enable_custom_notification_configuration');
140 $chk->setValue('1');
141 $chk->setChecked($ilUser->getPref('use_custom_notification_setting') == 1);
142 $form->addItem($chk);
143
144 $form->setFormAction($ilCtrl->getFormAction($this, 'showSettingsObject'));
145 $form->addCommandButton('saveCustomizingOption', $lng->txt('save'));
146 $form->addCommandButton('showSettings', $lng->txt('cancel'));
147
148 $table = new ilNotificationSettingsTable($this, 'a title', $this->getAvailableChannels(array('set_by_user')), $userTypes);
149
150 $table->setFormAction($ilCtrl->getFormAction($this, 'saveSettings'));
151 $table->setData($this->getAvailableTypes(array('set_by_user')));
152
153 if ($ilUser->getPref('use_custom_notification_setting') == 1) {
154 $table->addCommandButton('saveSettings', $lng->txt('save'));
155 $table->addCommandButton('showSettings', $lng->txt('cancel'));
156 $table->setEditable(true);
157 } else {
158 $table->setEditable(false);
159 }
160
161 $tpl->setContent($form->getHtml() . $table->getHTML());
162 }
163
164 private function saveSettingsObject()
165 {
166 global $ilUser, $ilCtrl;
167 require_once 'Services/Notifications/classes/class.ilNotificationDatabaseHelper.php';
168
169 ilNotificationDatabaseHandler::setUserConfig($ilUser->getId(), $_REQUEST['notification'] ? $_REQUEST['notification'] : array());
170 $this->showSettingsObject();
171 }
172
173 public function addLocatorItems()
174 {
175 global $ilLocator, $ilCtrl;
176
177 if (is_object($this->object)) {
178 $ilLocator->addItem($this->object->getTitle(), $ilCtrl->getLinkTarget($this, ''), '', $_GET["ref_id"]);
179 }
180 }
181}
$result
$tpl
Definition: ilias.php:10
$_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.
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())
__construct()
Constructor @access public.
addHandler($channel, ilNotificationHandler $handler)
getAvailableChannels($types=array())
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)
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$type
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
$ilUser
Definition: imgupload.php:18