ILIAS  release_8 Revision v8.23
ilNotificationSettingsTable.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 namespace ILIAS\Notifications;
22 
23 use ilLanguage;
24 use ilTable2GUI;
25 
30 {
31  private array $channels;
32  private array $userdata;
33 
34  private bool $adminMode;
35  private bool $editable = true;
36 
38 
39  public function __construct(
40  ?object $a_ref,
41  string $title,
42  array $channels,
43  array $userdata,
44  bool $adminMode = false,
45  ilLanguage $language = null
46  ) {
47  if ($language === null) {
48  global $DIC;
49  $language = $DIC->language();
50  }
51  $this->language = $language;
52 
53  $this->language->loadLanguageModule('notification');
54 
55  $this->channels = $channels;
56  $this->userdata = $userdata;
57  $this->adminMode = $adminMode;
58 
59  parent::__construct($a_ref, $title);
60  $this->setTitle($this->language->txt('notification_options'));
61 
62  $this->setId('notifications_settings');
63 
64  $this->addColumn($this->language->txt('notification_target'), '', '');
65 
66  foreach ($channels as $key => $channel) {
67  $this->addColumn(
68  $this->language->txt(
69  'notc_' . $channel['title']
70  ),
71  '',
72  '20%',
73  false,
74  ''
75  );
76  }
77 
78  $this->setRowTemplate('tpl.type_line.html', 'Services/Notifications');
79  $this->setSelectAllCheckbox('');
80  }
81 
82  public function setEditable(bool $editable): void
83  {
84  $this->editable = $editable;
85  }
86 
87  public function isEditable(): bool
88  {
89  return $this->editable;
90  }
91 
92  protected function fillRow(array $a_set): void
93  {
94  $this->tpl->setVariable('NOTIFICATION_TARGET', $this->language->txt('nott_' . $a_set['title']));
95 
96  foreach ($this->channels as $channeltype => $channel) {
97  if (array_key_exists($a_set['name'], $this->userdata) && in_array(
98  $channeltype,
99  $this->userdata[$a_set['name']],
100  true
101  )) {
102  $this->tpl->touchBlock('notification_cell_checked');
103  }
104 
105  if (!$this->isEditable()) {
106  $this->tpl->touchBlock('notification_cell_disabled');
107  }
108 
109  $this->tpl->setCurrentBlock('notification_cell');
110 
111  if (
112  $this->adminMode &&
113  isset($channel['config_type'], $a_set['config_type']) &&
114  $channel['config_type'] === 'set_by_user' &&
115  $a_set['config_type'] === 'set_by_user'
116  ) {
117  $this->tpl->setVariable('NOTIFICATION_SET_BY_USER_CELL', 'optionSetByUser');
118  }
119 
120  $this->tpl->setVariable('CHANNEL', $channeltype);
121  $this->tpl->setVariable('TYPE', $a_set['name']);
122 
123  $this->tpl->parseCurrentBlock();
124  }
125  }
126 }
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setId(string $a_val)
global $DIC
Definition: feed.php:28
__construct(?object $a_ref, string $title, array $channels, array $userdata, bool $adminMode=false, ilLanguage $language=null)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
string $key
Consumer key/client ID value.
Definition: System.php:193
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...