ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilNotificationSettingsTable.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Notifications;
22 
23 use ilLanguage;
24 use ilTable2GUI;
26 
31 {
32  private bool $editable = true;
33 
34  private readonly ilLanguage $language;
35 
40  public function __construct(
41  ilNotificationGUI $a_ref,
42  string $title,
43  private readonly array $channels,
44  private readonly array $usr_data,
45  private readonly bool $adminMode = false,
46  ?ilLanguage $language = null
47  ) {
48  if ($language === null) {
49  global $DIC;
50  $language = $DIC->language();
51  }
52  $this->language = $language;
53 
54  $this->language->loadLanguageModule('notification');
55 
56  parent::__construct($a_ref, $title);
57  $this->setTitle($this->language->txt('notification_options'));
58 
59  $this->setId('notifications_settings');
60 
61  $this->addColumn($this->language->txt('notification_target'), '', '');
62 
63  foreach ($channels as $channel) {
64  $this->addColumn(
65  $this->language->txt(
66  'notc_' . $channel['title']
67  ),
68  '',
69  '20%',
70  false,
71  ''
72  );
73  }
74 
75  $this->setRowTemplate('tpl.type_line.html', 'components/ILIAS/Notifications');
76  $this->setSelectAllCheckbox('');
77  }
78 
79  public function setEditable(bool $editable): void
80  {
81  $this->editable = $editable;
82  }
83 
84  public function isEditable(): bool
85  {
86  return $this->editable;
87  }
88 
89  protected function fillRow(array $a_set): void
90  {
91  $this->tpl->setVariable('NOTIFICATION_TARGET', $this->language->txt('nott_' . $a_set['title']));
92 
93  foreach ($this->channels as $channeltype => $channel) {
94  if (array_key_exists($a_set['name'], $this->usr_data) && in_array(
95  $channeltype,
96  $this->usr_data[$a_set['name']],
97  true
98  )) {
99  $this->tpl->touchBlock('notification_cell_checked');
100  }
101 
102  if (!$this->isEditable()) {
103  $this->tpl->touchBlock('notification_cell_disabled');
104  }
105 
106  $this->tpl->setCurrentBlock('notification_cell');
107 
108  if (
109  $this->adminMode &&
110  isset($channel['config_type'], $a_set['config_type']) &&
111  $channel['config_type'] === 'set_by_user' &&
112  $a_set['config_type'] === 'set_by_user'
113  ) {
114  $this->tpl->setVariable('NOTIFICATION_SET_BY_USER_CELL', 'optionSetByUser');
115  }
116 
117  $this->tpl->setVariable('CHANNEL', $channeltype);
118  $this->tpl->setVariable('TYPE', $a_set['name']);
119 
120  $this->tpl->parseCurrentBlock();
121  }
122  }
123 }
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setId(string $a_val)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(ilNotificationGUI $a_ref, string $title, private readonly array $channels, private readonly array $usr_data, private readonly bool $adminMode=false, ?ilLanguage $language=null)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:22
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)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41