ILIAS  release_8 Revision v8.23
ilNotificationGUI Class Reference
+ Inheritance diagram for ilNotificationGUI:
+ Collaboration diagram for ilNotificationGUI:

Public Member Functions

 __construct (?ilObjUser $user=null, ?ilGlobalTemplateInterface $template=null, ?ilCtrlInterface $controller=null, ?ilLanguage $language=null, ?Container $dic=null)
 
 executeCommand ()
 
 getHandler (string $type)
 
 getOSDNotificationsObject ()
 
 addHandler (string $channel, ilNotificationHandler $handler)
 
 showSettingsObject ()
 

Static Public Member Functions

static _forwards ()
 

Private Member Functions

 getAvailableTypes (array $types=[])
 
 getAvailableChannels (array $types=[])
 

Private Attributes

array $handler = []
 
Container $dic
 
ilObjUser $user
 
ilGlobalTemplateInterface $template
 
ilCtrlInterface $controller
 
ilLanguage $language
 

Detailed Description

Author
Ingmar Szmais iszma.nosp@m.is@d.nosp@m.ataba.nosp@m.y.de

Definition at line 32 of file class.ilNotificationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilNotificationGUI::__construct ( ?ilObjUser  $user = null,
?ilGlobalTemplateInterface  $template = null,
?ilCtrlInterface  $controller = null,
?ilLanguage  $language = null,
?Container  $dic = null 
)

Definition at line 41 of file class.ilNotificationGUI.php.

References $controller, $DIC, $dic, $language, $template, $user, ILIAS\DI\Container\ctrl(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\DI\Container\language(), ILIAS\DI\Container\ui(), ILIAS\Repository\user(), and ILIAS\DI\Container\user().

47  {
48  if ($dic === null) {
49  global $DIC;
50  $dic = $DIC;
51  }
52  $this->dic = $dic;
53 
54  if ($user === null) {
55  $user = $dic->user();
56  }
57  $this->user = $user;
58 
59  if ($template === null) {
60  $template = $dic->ui()->mainTemplate();
61  }
62  $this->template = $template;
63 
64  if ($controller === null) {
65  $controller = $dic->ctrl();
66  }
67  $this->controller = $controller;
68 
69  if ($language === null) {
70  $language = $dic->language();
71  }
72  $this->language = $language;
73  }
user()
Get the current user.
Definition: Container.php:62
global $DIC
Definition: feed.php:28
language()
Get interface to the i18n service.
Definition: Container.php:86
ilGlobalTemplateInterface $template
ctrl()
Get the interface to the control structure.
Definition: Container.php:54
ui()
Get the interface to get services from UI framework.
Definition: Container.php:118
+ Here is the call graph for this function:

Member Function Documentation

◆ _forwards()

static ilNotificationGUI::_forwards ( )
static

Definition at line 75 of file class.ilNotificationGUI.php.

75  : array
76  {
77  return [];
78  }

◆ addHandler()

ilNotificationGUI::addHandler ( string  $channel,
ilNotificationHandler  $handler 
)

Definition at line 127 of file class.ilNotificationGUI.php.

References $handler.

127  : void
128  {
129  if (!array_key_exists($channel, $this->handler) || !is_array($this->handler[$channel])) {
130  $this->handler[$channel] = [];
131  }
132 
133  $this->handler[$channel][] = $handler;
134  }

◆ executeCommand()

ilNotificationGUI::executeCommand ( )

Definition at line 80 of file class.ilNotificationGUI.php.

80  : void
81  {
82  if (!$this->controller->getCmd()) {
83  return;
84  }
85 
86  $cmd = $this->controller->getCmd() . 'Object';
87  $this->$cmd();
88  }

◆ getAvailableChannels()

ilNotificationGUI::getAvailableChannels ( array  $types = [])
private

Definition at line 103 of file class.ilNotificationGUI.php.

Referenced by showSettingsObject().

103  : array
104  {
105  return ilNotificationDatabaseHandler::getAvailableChannels($types);
106  }
+ Here is the caller graph for this function:

◆ getAvailableTypes()

ilNotificationGUI::getAvailableTypes ( array  $types = [])
private

Definition at line 98 of file class.ilNotificationGUI.php.

Referenced by showSettingsObject().

98  : array
99  {
100  return ilNotificationDatabaseHandler::getAvailableTypes($types);
101  }
+ Here is the caller graph for this function:

◆ getHandler()

ilNotificationGUI::getHandler ( string  $type)
Returns
mixed

Definition at line 93 of file class.ilNotificationGUI.php.

References $type.

94  {
95  return $this->handler[$type];
96  }
$type

◆ getOSDNotificationsObject()

ilNotificationGUI::getOSDNotificationsObject ( )

Definition at line 108 of file class.ilNotificationGUI.php.

References ilSession\enableWebAccessWithoutSession().

108  : void
109  {
111  $toasts = [];
112  foreach ($this->dic->globalScreen()->collector()->toasts()->getToasts() as $toast) {
113  $renderer = $toast->getRenderer();
114  $toasts[] = $renderer->getToastComponentForItem($toast);
115  }
116 
117  $this->dic->http()->saveResponse(
118  $this->dic->http()->response()
119  ->withBody(Streams::ofString(
120  $this->dic->ui()->renderer()->renderAsync($toasts)
121  ))
122  );
123  $this->dic->http()->sendResponse();
124  $this->dic->http()->close();
125  }
static enableWebAccessWithoutSession(bool $enable_web_access_without_session)
+ Here is the call graph for this function:

◆ showSettingsObject()

ilNotificationGUI::showSettingsObject ( )

Definition at line 136 of file class.ilNotificationGUI.php.

References getAvailableChannels(), getAvailableTypes(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ilCheckboxInputGUI\setValue(), and ILIAS\Repository\user().

136  : void
137  {
138  $userTypes = ilNotificationDatabaseHandler::loadUserConfig($this->user->getId());
139 
140  $this->language->loadLanguageModule('notification');
141 
142  $form = new ilPropertyFormGUI();
143  $chk = new ilCheckboxInputGUI($this->language->txt('enable_custom_notification_configuration'), 'enable_custom_notification_configuration');
144  $chk->setValue('1');
145  $chk->setChecked($this->dic->refinery()->kindlyTo()->int()->transform($this->user->getPref('use_custom_notification_setting')) === 1);
146  $form->addItem($chk);
147 
148  $form->setFormAction($this->controller->getFormAction($this, 'showSettingsObject'));
149  $form->addCommandButton('saveCustomizingOption', $this->language->txt('save'));
150  $form->addCommandButton('showSettings', $this->language->txt('cancel'));
151 
152  $table = new ilNotificationSettingsTable($this, 'a title', $this->getAvailableChannels(['set_by_user']), $userTypes);
153 
154  $table->setFormAction($this->controller->getFormAction($this, 'saveSettings'));
155  $table->setData($this->getAvailableTypes(['set_by_user']));
156 
157  if (
158  $this->dic->refinery()->kindlyTo()->int()->transform(
159  $this->user->getPref('use_custom_notification_setting')
160  ) === 1
161  ) {
162  $table->addCommandButton('saveSettings', $this->language->txt('save'));
163  $table->addCommandButton('showSettings', $this->language->txt('cancel'));
164  $table->setEditable(true);
165  } else {
166  $table->setEditable(false);
167  }
168 
169  $this->template->setContent($form->getHtml() . $table->getHTML());
170  }
getAvailableChannels(array $types=[])
This class represents a checkbox property in a property form.
getAvailableTypes(array $types=[])
+ Here is the call graph for this function:

Field Documentation

◆ $controller

ilCtrlInterface ilNotificationGUI::$controller
private

Definition at line 38 of file class.ilNotificationGUI.php.

Referenced by __construct().

◆ $dic

Container ilNotificationGUI::$dic
private

Definition at line 35 of file class.ilNotificationGUI.php.

Referenced by __construct().

◆ $handler

array ilNotificationGUI::$handler = []
private

Definition at line 34 of file class.ilNotificationGUI.php.

Referenced by addHandler().

◆ $language

ilLanguage ilNotificationGUI::$language
private

Definition at line 39 of file class.ilNotificationGUI.php.

Referenced by __construct().

◆ $template

ilGlobalTemplateInterface ilNotificationGUI::$template
private

Definition at line 37 of file class.ilNotificationGUI.php.

Referenced by __construct().

◆ $user

ilObjUser ilNotificationGUI::$user
private

Definition at line 36 of file class.ilNotificationGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: