ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once './Services/Object/classes/class.ilObjectGUI.php';
5 require_once 'Services/Notifications/classes/class.ilNotificationConfig.php';
6 require_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  static 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 
92  public function removeOSDNotificationsObject()
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 
101  ilNotificationOSDHandler::removeNotification($_REQUEST['notification_id']);
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 
114  private function saveCustomizingOptionObject()
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 
137  $userTypes = ilNotificationDatabaseHandler::loadUserConfig($ilUser->getId());
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 
180  function addLocatorItems()
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 }
getOSDNotificationsObject()
Returns the pending on screen notifications for a user request.
static enableWebAccessWithoutSession($enable_web_access_without_session)
static removeNotification($notification_osd_id)
Removes a notifcation and triggers a follow up notification to remove the notification from the brows...
$result
This class represents a property form user interface.
$_GET["client_id"]
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
Base class for notification handlers.
getAvailableChannels($types=array())
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
__construct()
Constructor public.
setValue($a_value)
Set Value.
$ilUser
Definition: imgupload.php:18
addHandler($channel, ilNotificationHandler $handler)
Create styles array
The data for the language used.
static getNotificationsForUser($user_id, $append_osd_id_to_link=true, $max_age_seconds=0)
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
static setUserConfig($userid, array $configArray)
Sets the configuration for all given configurations.
static getAvailableChannels($config_types=array(), $includeDisabled=false)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getAvailableTypes($types=array())
$_POST["username"]