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