ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNotificationConfig.php
Go to the documentation of this file.
1 <?php
2 
4 
5  private $type;
6 
7  private $link;
8  private $linktarget = '_self';
9 
10  private $title;
11 
12  private $iconPath;
13 
16 
17  private $disableAfterDelivery = false;
18  private $validForSeconds = 0;
19 
20  private $handlerParams = array();
21 
22  public function __construct($type) {
23  $this->type = $type;
24  }
25 
26  public function getType() {
27  return $this->type;
28  }
29 
30  public function setAutoDisable($value) {
31  $this->disableAfterDelivery = $value;
32  }
33 
34  public function hasDisableAfterDeliverySet() {
35  return (bool) $this->disableAfterDelivery;
36  }
37 
38  public function setLink($link) {
39  $this->link = $link;
40  }
41 
42  public function getLink() {
43  return $this->link;
44  }
45 
46  public function setIconPath($path) {
47  $this->iconPath = $path;
48  }
49 
50  public function getIconPath() {
51  return $this->iconPath;
52  }
53 
54  public function setTitleVar($name, $parameters = array(), $language_module = 'notification') {
55  $this->title = new ilNotificationParameter($name, $parameters, $language_module);
56  }
57 
58  public function getTitleVar() {
59  return $this->title->getName();
60  }
61 
62  public function setShortDescriptionVar($name, $parameters = array(), $language_module = 'notification') {
63  $this->short_description = new ilNotificationParameter($name, $parameters, $language_module);
64  }
65 
66  public function getShortDescriptionVar() {
67  return $this->short_description->getName();
68  }
69 
70  public function setLongDescriptionVar($name, $parameters = array(), $language_module = 'notification') {
71  $this->long_description = new ilNotificationParameter($name, $parameters, $language_module);
72  }
73 
74  public function getLongDescriptionVar() {
75  return $this->long_description->getName();
76  }
77 
78  public function getLanguageParameters() {
79  return array(
80  'title' => $this->title,
81  'longDescription' => $this->long_description,
82  'shortDescription' => $this->short_description,
83  );
84  }
85 
86  public function getLinktarget() {
87  return $this->linktarget;
88  }
89 
90  public function setLinktarget($linktarget) {
91  $this->linktarget = $linktarget;
92  }
93 
94  public function setValidForSeconds($seconds) {
95  $this->validForSeconds = $seconds;
96  }
97 
98  public function getValidForSeconds() {
100  }
101 
102  protected function beforeSendToUsers(){
103 
104  }
105 
106  protected function afterSendToUsers(){
107 
108  }
109 
110  protected function beforeSendToListeners(){
111 
112  }
113 
114  protected function afterSendToListeners(){
115 
116  }
117 
118  final public function notifyByUsers(array $recipients, $processAsync = false) {
119  require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
120  $this->beforeSendToUsers();
121  ilNotificationSystem::sendNotificationToUsers($this, $recipients, $processAsync);
122  $this->afterSendToUsers();
123  }
124 
125  final public function notifyByListeners($ref_id, $processAsync = false) {
126  require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
127  $this->beforeSendToListeners();
129  $this->afterSendToListeners();
130  }
131 
132  final public function notifyByRoles(array $roles, $processAsync = false) {
133  require_once 'Services/Notifications/classes/class.ilNotificationSystem.php';
134  //$this->beforeSendToListeners();
135  ilNotificationSystem::sendNotificationToRoles($this, $roles, $processAsync);
136  //$this->afterSendToListeners();
137  }
138 
139  public function getUserInstance(ilObjUser $user, $languageVars, $defaultLanguage) {
140  $notificationObject = new ilNotificationObject($this, $user);
141 
142  $title = '';
143  $short = '';
144  $long = '';
145 
146  if ($languageVars[$this->title->getName()]->lang[$user->getLanguage()]) {
147  $title = $languageVars[$this->title->getName()]->lang[$user->getLanguage()];
148  }
149  else if ($languageVars[$this->title->getName()]->lang[$defaultLanguage]) {
150  $title = $languageVars[$this->title->getName()]->lang[$defaultLanguage];
151  }
152  else {
153  $title = $this->title->getName();
154  }
155 
156  if ($languageVars[$this->short_description->getName()]->lang[$user->getLanguage()]) {
157  $short = $languageVars[$this->short_description->getName()]->lang[$user->getLanguage()];
158  }
159  else if ($languageVars[$this->short_description->getName()]->lang[$defaultLanguage]) {
160  $short = $languageVars[$this->short_description->getName()]->lang[$defaultLanguage];
161  }
162  else {
163  $short = $this->short_description->getName();
164  }
165 
166  if ($languageVars[$this->long_description->getName()]->lang[$user->getLanguage()]) {
167  $long = $languageVars[$this->long_description->getName()]->lang[$user->getLanguage()];
168  }
169  else if ($languageVars[$this->long_description->getName()]->lang[$defaultLanguage]) {
170  $long = $languageVars[$this->long_description->getName()]->lang[$defaultLanguage];
171  }
172  else {
173  $long = $this->long_description->getName();
174  }
175 
176  $notificationObject->title = $title;
177  $notificationObject->shortDescription = $short;
178  $notificationObject->longDescription = $long;
179 
180  $notificationObject->iconPath = $this->iconPath;
181 
182  return $notificationObject;
183  }
184 
185  public function setHandlerParam($name, $value) {
186  if (strpos($name, '.')) {
187  $nsParts = explode('.', $name, 2);
188  $ns = $nsParts[0];
189  $field = $nsParts[1];
190  $this->handlerParams[$ns][$field] = $value;
191  }
192  else {
193  $this->handlerParams[''][$name] = $value;
194  }
195  }
196 
197  public function getHandlerParams() {
198  return $this->handlerParams;
199  }
200 
201  public function unsetHandlerParam($name) {
202  unset($this->handlerParams[$name]);
203  }
204 }
205 
207 
213 
217  public $user;
218 
219  public $title;
222  public $link;
223  public $linktarget;
224  public $iconPath;
226 
228 
229  $this->baseNotification = $baseNotification;
230  $this->user = $user;
231 
232  $this->link = $this->baseNotification->getLink();
233  $this->linktarget = $this->baseNotification->getLinktarget();
234  $this->handlerParams = $this->baseNotification->getHandlerParams();
235  }
236 
237  public function __sleep() {
238  return array('title', 'shortDescription', 'longDescription', 'iconPath', 'link', 'linktarget', 'handlerParams');
239  }
240 
241 }
242 
243 
245 
246  private $name;
247  private $parameters = array();
248  private $language_module = array();
249 
250  public function __construct($name, $parameters = array(), $language_module = 'notification') {
251  $this->name = $name;
252  $this->parameters = $parameters;
253  $this->language_module = $language_module;
254  }
255 
256  public function getName() {
257  return $this->name;
258  }
259 
260  public function getParameters() {
261  return $this->parameters;
262  }
263 
264  public function getLanguageModule() {
265  return $this->language_module;
266  }
267 }