ILIAS  release_8 Revision v8.24
class.ilForumNotificationTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29 private array $notification_modals = [];
30 private \ILIAS\UI\Factory $ui_factory;
32
33 public function __construct(ilForumSettingsGUI $settings_gui, string $cmd, string $type)
34 {
35 global $DIC;
36
37 $this->ui_factory = $DIC->ui()->factory();
38 $this->ui_renderer = $DIC->ui()->renderer();
39
40 $this->lng = $DIC->language();
41 $this->ctrl = $DIC->ctrl();
42 $this->mainTemplate = $DIC->ui()->mainTemplate();
43
44 $this->setId('frmev_' . $settings_gui->getRefId() . substr($type, 0, 3));
45
46 parent::__construct($settings_gui, $cmd);
47
48 $this->setTitle($this->lng->txt(strtolower($type)));
49 $this->setRowTemplate('tpl.forums_members_row.html', 'Modules/Forum');
50 $this->setFormAction($this->ctrl->getFormAction($settings_gui, 'showMembers'));
51
52 $this->addColumn('', '', '1%', true);
53 $this->addColumn($this->lng->txt('login'), '', '20%');
54 $this->addColumn($this->lng->txt('firstname'), '', '20%');
55 $this->addColumn($this->lng->txt('lastname'), '', '20%');
56 $this->addColumn($this->lng->txt('allow_user_toggle_noti'), '', '20%');
57 $this->addColumn($this->lng->txt('actions'), '', '20%');
58 $this->setSelectAllCheckbox('user_id');
59
60 $this->addMultiCommand('enableHideUserToggleNoti', $this->lng->txt('enable_hide_user_toggle'));
61 $this->addMultiCommand('disableHideUserToggleNoti', $this->lng->txt('disable_hide_user_toggle'));
62 }
63
64 private function getIcon(int $user_toggle_noti): string
65 {
66 $icon_ok = $this->ui_factory->symbol()->icon()->custom(
67 ilUtil::getImagePath('icon_ok.svg'),
68 $this->lng->txt('enabled')
69 );
70 $icon_not_ok = $this->ui_factory->symbol()->icon()->custom(
71 ilUtil::getImagePath('icon_not_ok.svg'),
72 $this->lng->txt('disabled')
73 );
74 $icon = $user_toggle_noti === 0 ? $icon_ok : $icon_not_ok;
75
76 return $this->ui_renderer->render($icon);
77 }
78
79 protected function fillRow(array $a_set): void
80 {
81 $this->tpl->setVariable('VAL_USER_ID', $a_set['user_id']);
82 $this->tpl->setVariable('VAL_LOGIN', $a_set['login']);
83 $this->tpl->setVariable('VAL_FIRSTNAME', $a_set['firstname']);
84 $this->tpl->setVariable('VAL_LASTNAME', $a_set['lastname']);
85
86 $icon_ok = $this->getIcon((int) $a_set['user_toggle_noti']);
87 $this->tpl->setVariable('VAL_USER_TOGGLE_NOTI', $icon_ok);
88
89 $this->populateWithModal($a_set);
90 }
91
93 {
94 $interested_events = $row['interested_events'];
95
97 $this->ctrl->getFormAction($this->parent_obj, 'saveEventsForUser'),
98 [
99 'hidden_value' => json_encode([
100 'usr_id' => $row['usr_id_events']
101 ], JSON_THROW_ON_ERROR),
102 'notify_modified' => (bool) ($interested_events & ilForumNotificationEvents::UPDATED),
103 'notify_censored' => (bool) ($interested_events & ilForumNotificationEvents::CENSORED),
104 'notify_uncensored' => (bool) ($interested_events & ilForumNotificationEvents::UNCENSORED),
105 'notify_post_deleted' => (bool) ($interested_events & ilForumNotificationEvents::POST_DELETED),
106 'notify_thread_deleted' => (bool) ($interested_events & ilForumNotificationEvents::THREAD_DELETED),
107 ],
108 $this->ui_factory,
109 $this->lng
110 );
111 }
112
113 private function populateWithModal(array $row): void
114 {
115 $notificationsModal = $this->ui_factory->modal()->roundtrip(
116 $this->lng->txt('notification_settings'),
117 $this->eventsFormBuilder($row)->build()
118 )->withActionButtons([
119 $this->ui_factory->button()
120 ->primary($this->lng->txt('save'), '#')
121 ->withOnLoadCode(function (string $id) use ($row): string {
122 return "
123 $('#$id').closest('.modal').find('form').addClass('ilForumNotificationSettingsForm');
124 $('#$id').closest('.modal').find('form .il-standard-form-header, .il-standard-form-footer').remove();
125 $('#$id').click(function() { $(this).closest('.modal').find('form').submit(); return false; });
126 ";
127 })
128 ]);
129
130 $showNotificationSettingsBtn = $this->ui_factory->button()
131 ->shy($this->lng->txt('notification_settings'), '#')
132 ->withOnClick(
133 $notificationsModal->getShowSignal()
134 );
135
136 $this->notification_modals[] = $notificationsModal;
137
138 $this->tpl->setVariable('VAL_NOTIFICATION', $this->ui_renderer->render($showNotificationSettingsBtn));
139 }
140
141 public function render(): string
142 {
143 return parent::render() . $this->ui_renderer->render($this->notification_modals);
144 }
145}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
Class ilForumNotificationTableGUI.
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(ilForumSettingsGUI $settings_gui, string $cmd, string $type)
Class ilForumSettingsGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type