ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UploadPoliciesTableUI Class Reference
+ Collaboration diagram for UploadPoliciesTableUI:

Public Member Functions

 __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)
 
 getComponents ()
 

Data Fields

const ACTIVE_FILTER_PARAM = "active_filter"
 

Protected Member Functions

 buildPolicyActions (array $policies)
 
 getAudienceText (int $audience_type, array $audience_data)
 
 getViewControl ()
 
 getDeletionConfirmationModal (UploadPolicy $record)
 
 getPresentablePolicies ()
 

Protected Attributes

const ACTIVE_FILTER_ALL = "all"
 
const ACTIVE_FILTER_ACTIVE = "active"
 
const ACTIVE_FILTER_INACTIVE = "inactive"
 
array $components = []
 

Detailed Description

Author
Lukas Zehnder lukas.nosp@m.@sr..nosp@m.solut.nosp@m.ions

Definition at line 34 of file UploadPoliciesTableUI.php.

Constructor & Destructor Documentation

◆ __construct()

UploadPoliciesTableUI::__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 
)

Definition at line 46 of file UploadPoliciesTableUI.php.

References buildPolicyActions(), getAudienceText(), getPresentablePolicies(), getViewControl(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), null, ILIAS\UI\Component\Table\PresentationRow\withAction(), and ILIAS\UI\Component\Table\PresentationRow\withHeadline().

57  {
58  $policies = $this->getPresentablePolicies();
59  $actions = $this->buildPolicyActions($policies);
60  $table = $this->ui_factory->table()->presentation(
61  $this->language->txt('upload_policies'),
62  [$this->getViewControl()],
63  function (
64  PresentationRow $row,
65  UploadPolicy $record,
66  UIFactory $ui_factory
67  ) use ($actions): PresentationRow {
68  // Create texts for better data presentation in table
69  $upload_limit_text = $record->getUploadLimitInMB() . " MB";
70  $active_text = ($record->isActive()) ? $this->language->txt('yes') : $this->language->txt('no');
71  $audience_text = $this->getAudienceText($record->getAudienceType(), $record->getAudience());
72  $scope_text = $record->getScopeDefinition();
73  $valid_until_text = $record->getValidUntil()?->format('d.m.Y') ?? $this->language->txt(
74  "policy_no_validity_limitation_set"
75  );
76 
77  // Create row with fields and actions
78  $row = $row
79  ->withHeadline($record->getTitle())
80  ->withImportantFields(
81  [
82  $this->language->txt('policy_upload_limit') => $upload_limit_text,
83  $this->language->txt('policy_audience') => $audience_text,
84  $this->language->txt('active') => $active_text
85  ]
86  )
87  ->withContent(
88  $ui_factory->listing()->descriptive(
89  [
90  $this->language->txt('policy_upload_limit') => $upload_limit_text,
91  $this->language->txt('policy_audience') => $audience_text,
92  $this->language->txt('active') => $active_text,
93  $this->language->txt('policy_scope') => $scope_text,
94  $this->language->txt('policy_valid_until') => $valid_until_text,
95  ]
96  )
97  );
98 
99  if (null !== ($dropdown = $actions[$record->getPolicyId()] ?? null)) {
100  return $row->withAction($dropdown);
101  }
102 
103  return $row;
104  }
105  )->withData($policies);
106 
107  $this->components[] = $table;
108  }
getAudienceText(int $audience_type, array $audience_data)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withHeadline(string $headline)
Get a row like this with the given headline.
buildPolicyActions(array $policies)
This describes a Row used in Presentation Table.
withAction($action)
Get a row like this with a button or a dropdown for actions in the expanded row.
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Member Function Documentation

◆ buildPolicyActions()

UploadPoliciesTableUI::buildPolicyActions ( array  $policies)
protected
Parameters
UploadPolicy[]$policies
Returns
Dropdown[]

Definition at line 122 of file UploadPoliciesTableUI.php.

References $data, ilUploadLimitsOverviewGUI\CMD_EDIT_UPLOAD_POLICY, ILIAS\Repository\ctrl(), getDeletionConfirmationModal(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and UploadPolicy\POLICY_ID.

Referenced by __construct().

122  : array
123  {
124  if (!$this->write_access) {
125  return [];
126  }
127  $dropdowns = [];
128  foreach ($policies as $policy) {
129  // Store policy_id for later use when the table's actions (edit / delete) are used)
130  $this->ctrl->setParameterByClass(
131  ilUploadLimitsOverviewGUI::class,
133  $policy->getPolicyId()
134  );
135 
136  $deletion_modal = $this->getDeletionConfirmationModal($policy);
137  $dropdowns[$policy->getPolicyId()] = $this->ui_factory->dropdown()->standard(
138  [
139  $this->ui_factory->button()->shy(
140  $this->language->txt('edit'),
141  $this->ctrl->getLinkTargetByClass(
142  ilUploadLimitsOverviewGUI::class,
144  )
145  ),
146  $this->ui_factory->button()->shy(
147  $this->language->txt('delete'),
148  $deletion_modal->getShowSignal()
149  )
150  ]
151  );
152 
153  $this->components[] = $deletion_modal;
154  }
155 
156  return $dropdowns;
157  }
getDeletionConfirmationModal(UploadPolicy $record)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAudienceText()

UploadPoliciesTableUI::getAudienceText ( int  $audience_type,
array  $audience_data 
)
protected

Definition at line 185 of file UploadPoliciesTableUI.php.

References UploadPolicy\AUDIENCE_TYPE_ALL_USERS, UploadPolicy\AUDIENCE_TYPE_GLOBAL_ROLE, and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by __construct(), and getDeletionConfirmationModal().

185  : string
186  {
187  switch ($audience_type) {
189  $audience_text = $this->language->txt('all_global_roles');
190  // add selected roles to audience_text
191  if (!empty($audience_data['global_roles'])) {
192  $roles = $this->rbac_review->getRolesForIDs($audience_data['global_roles'], false);
193  $counter = 0;
194  foreach ($roles as $role) {
195  $counter++;
196  $audience_text .= " \"" . $role['title'] . "\"";
197  if ($counter !== count($roles)) {
198  $audience_text .= ",";
199  }
200  }
201  }
202  break;
204  default:
205  $audience_text = $this->language->txt('all_users');
206  break;
207  }
208 
209  return $audience_text;
210  }
const AUDIENCE_TYPE_GLOBAL_ROLE
const AUDIENCE_TYPE_ALL_USERS
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponents()

UploadPoliciesTableUI::getComponents ( )
Returns
Component[]

Definition at line 113 of file UploadPoliciesTableUI.php.

References $components.

113  : array
114  {
115  return $this->components;
116  }

◆ getDeletionConfirmationModal()

UploadPoliciesTableUI::getDeletionConfirmationModal ( UploadPolicy  $record)
protected

Definition at line 239 of file UploadPoliciesTableUI.php.

References ilUploadLimitsOverviewGUI\CMD_DELETE_UPLOAD_POLICY, ILIAS\Repository\ctrl(), UploadPolicy\getAudience(), getAudienceText(), UploadPolicy\getAudienceType(), UploadPolicy\getPolicyId(), UploadPolicy\getScopeDefinition(), UploadPolicy\getTitle(), UploadPolicy\getUploadLimitInMB(), UploadPolicy\getValidUntil(), UploadPolicy\isActive(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by buildPolicyActions().

239  : Interruptive
240  {
241  $upload_limit_text = $record->getUploadLimitInMB() . " MB";
242  $active_text = ($record->isActive()) ? $this->language->txt('yes') : $this->language->txt('no');
243  $audience_text = $this->getAudienceText($record->getAudienceType(), $record->getAudience());
244  $valid_until_text = $record->getValidUntil()?->format('d.m.Y') ?? $this->language->txt(
245  "policy_no_validity_limitation_set"
246  );
247 
248  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
249  (string) $record->getPolicyId(),
250  $this->language->txt('title'),
251  $record->getTitle()
252  );
253 
254  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
255  (string) $record->getPolicyId(),
256  $this->language->txt('policy_upload_limit'),
257  $upload_limit_text
258  );
259 
260  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
261  (string) $record->getPolicyId(),
262  $this->language->txt('policy_audience'),
263  $audience_text
264  );
265 
266  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
267  (string) $record->getPolicyId(),
268  $this->language->txt('active'),
269  $active_text
270  );
271 
272  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
273  (string) $record->getPolicyId(),
274  $this->language->txt('policy_scope'),
275  $record->getScopeDefinition()
276  );
277 
278  $deletion_items[] = $this->ui_factory->modal()->interruptiveItem()->keyValue(
279  (string) $record->getPolicyId(),
280  $this->language->txt('policy_valid_until'),
281  $valid_until_text
282  );
283 
284  return $this->ui_factory->modal()->interruptive(
285  $this->language->txt("delete"),
286  $this->language->txt('policy_confirm_deletion'),
287  $this->ctrl->getLinkTargetByClass(
288  ilUploadLimitsOverviewGUI::class,
290  )
291  )->withAffectedItems(
292  $deletion_items
293  )->withActionButtonLabel($this->language->txt('delete'));
294  }
getAudienceText(int $audience_type, array $audience_data)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPresentablePolicies()

UploadPoliciesTableUI::getPresentablePolicies ( )
protected
Returns
UploadPolicy[]

Definition at line 299 of file UploadPoliciesTableUI.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by __construct().

299  : array
300  {
301  $policy_data = $this->upload_policy_db_repository->getAll();
302 
303  if ($this->http->wrapper()->query()->has(self::ACTIVE_FILTER_PARAM)) {
304  return $this->filterData(
305  $this->http->wrapper()->query()->retrieve(
306  self::ACTIVE_FILTER_PARAM,
307  $this->refinery->kindlyTo()->string()
308  ),
309  $policy_data
310  );
311  }
312 
313  return $policy_data;
314  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getViewControl()

UploadPoliciesTableUI::getViewControl ( )
protected

Definition at line 212 of file UploadPoliciesTableUI.php.

References ilUploadLimitsOverviewGUI\CMD_INDEX, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\refinery().

Referenced by __construct().

212  : Mode
213  {
214  $target = $this->ctrl->getLinkTargetByClass(
215  ilUploadLimitsOverviewGUI::class,
217  );
218 
219  $active_control_element = self::ACTIVE_FILTER_ALL;
220  if ($this->http->wrapper()->query()->has(self::ACTIVE_FILTER_PARAM)) {
221  $active_control_element = $this->http->wrapper()->query()->retrieve(
222  self::ACTIVE_FILTER_PARAM,
223  $this->refinery->kindlyTo()->string()
224  );
225  }
226 
227  $actions_prefix = $target . "&" . self::ACTIVE_FILTER_PARAM . "=";
228  $actions = [
229  $this->language->txt(self::ACTIVE_FILTER_ALL) => $actions_prefix . self::ACTIVE_FILTER_ALL,
230  $this->language->txt(self::ACTIVE_FILTER_ACTIVE) => $actions_prefix . self::ACTIVE_FILTER_ACTIVE,
231  $this->language->txt(self::ACTIVE_FILTER_INACTIVE) => $actions_prefix . self::ACTIVE_FILTER_INACTIVE
232  ];
233 
234  return $this->ui_factory->viewControl()->mode($actions, 'policy_filter')->withActive(
235  $this->language->txt($active_control_element)
236  );
237  }
static http()
Fetches the global http state from ILIAS.
This describes a Mode Control.
Definition: Mode.php:28
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $components

array UploadPoliciesTableUI::$components = []
protected

Definition at line 44 of file UploadPoliciesTableUI.php.

Referenced by getComponents().

◆ ACTIVE_FILTER_ACTIVE

const UploadPoliciesTableUI::ACTIVE_FILTER_ACTIVE = "active"
protected

Definition at line 38 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_ALL

const UploadPoliciesTableUI::ACTIVE_FILTER_ALL = "all"
protected

Definition at line 37 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_INACTIVE

const UploadPoliciesTableUI::ACTIVE_FILTER_INACTIVE = "inactive"
protected

Definition at line 39 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_PARAM

const UploadPoliciesTableUI::ACTIVE_FILTER_PARAM = "active_filter"

Definition at line 36 of file UploadPoliciesTableUI.php.


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