19 declare(strict_types=1);
57 protected bool $write_access
61 $table = $this->ui_factory->table()->presentation(
62 $this->
language->txt(
'upload_policies'),
70 $upload_limit_text = $record->getUploadLimitInMB() .
" MB";
71 $active_text = ($record->isActive()) ? $this->
language->txt(
'yes') : $this->
language->txt(
'no');
72 $audience_text = $this->
getAudienceText($record->getAudienceType(), $record->getAudience());
73 $scope_text = $record->getScopeDefinition();
74 $valid_until_text = $record->getValidUntil()?->format(
'd.m.Y') ?? $this->
language->txt(
75 "policy_no_validity_limitation_set" 81 ->withImportantFields(
83 $this->
language->txt(
'policy_upload_limit') => $upload_limit_text,
84 $this->
language->txt(
'policy_audience') => $audience_text,
85 $this->
language->txt(
'active') => $active_text
89 $ui_factory->listing()->descriptive(
91 $this->
language->txt(
'policy_upload_limit') => $upload_limit_text,
92 $this->
language->txt(
'policy_audience') => $audience_text,
93 $this->
language->txt(
'active') => $active_text,
94 $this->
language->txt(
'policy_scope') => $scope_text,
95 $this->
language->txt(
'policy_valid_until') => $valid_until_text,
100 if (null !== ($dropdown = $actions[$record->getPolicyId()] ?? null)) {
106 )->withData($policies);
108 $this->components[] = $table;
125 if(!$this->write_access) {
129 foreach ($policies as $policy) {
131 $this->
ctrl->setParameterByClass(
132 ilUploadLimitsOverviewGUI::class,
134 $policy->getPolicyId()
138 $dropdowns[$policy->getPolicyId()] = $this->ui_factory->dropdown()->standard(
140 $this->ui_factory->button()->shy(
142 $this->
ctrl->getLinkTargetByClass(
143 ilUploadLimitsOverviewGUI::class,
147 $this->ui_factory->button()->shy(
149 $deletion_modal->getShowSignal()
154 $this->components[] = $deletion_modal;
160 protected function filterData(
string $filter_value, array
$data): array
163 switch ($filter_value) {
164 case self::ACTIVE_FILTER_ACTIVE:
165 $active_value =
true;
167 case self::ACTIVE_FILTER_INACTIVE:
168 $active_value =
false;
170 case self::ACTIVE_FILTER_ALL:
178 foreach ($data as $data_entry) {
179 if ($data_entry->isActive() === $active_value) {
180 $filtered_data[] = $data_entry;
183 return $filtered_data;
188 switch ($audience_type) {
190 $audience_text = $this->
language->txt(
'all_global_roles');
192 if (!empty($audience_data[
'global_roles'])) {
193 $roles = $this->rbac_review->getRolesForIDs($audience_data[
'global_roles'],
false);
195 foreach ($roles as $role) {
197 $audience_text .=
" \"" . $role[
'title'] .
"\"";
198 if ($counter !== count($roles)) {
199 $audience_text .=
",";
206 $audience_text = $this->
language->txt(
'all_users');
210 return $audience_text;
215 $target = $this->
ctrl->getLinkTargetByClass(
216 ilUploadLimitsOverviewGUI::class,
220 $active_control_element = self::ACTIVE_FILTER_ALL;
221 if ($this->
http->wrapper()->query()->has(self::ACTIVE_FILTER_PARAM)) {
222 $active_control_element = $this->
http->wrapper()->query()->retrieve(
223 self::ACTIVE_FILTER_PARAM,
224 $this->
refinery->kindlyTo()->string()
228 $actions_prefix = $target .
"&" . self::ACTIVE_FILTER_PARAM .
"=";
230 $this->
language->txt(self::ACTIVE_FILTER_ALL) => $actions_prefix . self::ACTIVE_FILTER_ALL,
231 $this->
language->txt(self::ACTIVE_FILTER_ACTIVE) => $actions_prefix . self::ACTIVE_FILTER_ACTIVE,
232 $this->
language->txt(self::ACTIVE_FILTER_INACTIVE) => $actions_prefix . self::ACTIVE_FILTER_INACTIVE
235 return $this->ui_factory->viewControl()->mode($actions,
'policy_filter')->withActive(
236 $this->
language->txt($active_control_element)
246 "policy_no_validity_limitation_set" 250 . $this->
language->txt(
'policy_upload_limit') . $upload_limit_text .
"<br/>" 251 . $this->
language->txt(
'policy_audience') . $audience_text .
"<br/>" 252 . $this->
language->txt(
'active') . $active_text .
"<br/>" 254 . $this->
language->txt(
'policy_valid_until') . $valid_until_text;
256 $deletion_item = $this->ui_factory->modal()->interruptiveItem()->standard(
261 return $this->ui_factory->modal()->interruptive(
263 $this->
language->txt(
'policy_confirm_deletion'),
264 $this->
ctrl->getLinkTargetByClass(
265 ilUploadLimitsOverviewGUI::class,
268 )->withAffectedItems(
270 )->withActionButtonLabel($this->
language->txt(
'delete'));
278 $policy_data = $this->upload_policy_db_repository->getAll();
280 if ($this->
http->wrapper()->query()->has(self::ACTIVE_FILTER_PARAM)) {
281 $policy_data = $this->filterData(
282 $this->
http->wrapper()->query()->retrieve(
283 self::ACTIVE_FILTER_PARAM,
284 $this->
refinery->kindlyTo()->string()
An entity that renders components to a string output.
const ACTIVE_FILTER_ACTIVE
const ACTIVE_FILTER_PARAM
const AUDIENCE_TYPE_GLOBAL_ROLE
getDeletionConfirmationModal(UploadPolicy $record)
getAudienceText(int $audience_type, array $audience_data)
static http()
Fetches the global http state from ILIAS.
const CMD_DELETE_UPLOAD_POLICY
const CMD_EDIT_UPLOAD_POLICY
withHeadline(string $headline)
Get a row like this with the given headline.
const AUDIENCE_TYPE_ALL_USERS
buildPolicyActions(array $policies)
This describes a Row used in Presentation Table.
This describes a Mode Control.
withAction($action)
Get a row like this with a button or a dropdown for actions in the expanded row.
__construct(protected UploadPolicyDBRepository $upload_policy_db_repository, protected ilCtrlInterface $ctrl, protected HttpServices $http, protected ilLanguage $language, protected ilGlobalTemplateInterface $main_tpl, protected ilRbacReview $rbac_review, protected RefineryFactory $refinery, protected UIFactory $ui_factory, protected Renderer $ui_renderer, protected bool $write_access)
const ACTIVE_FILTER_INACTIVE
Refinery Factory $refinery