ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 35 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 47 of file UploadPoliciesTableUI.php.

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

58  {
59  $policies = $this->getPresentablePolicies();
60  $actions = $this->buildPolicyActions($policies);
61  $table = $this->ui_factory->table()->presentation(
62  $this->language->txt('upload_policies'),
63  [$this->getViewControl()],
64  function (
65  PresentationRow $row,
66  UploadPolicy $record,
67  UIFactory $ui_factory
68  ) use ($actions): PresentationRow {
69  // Create texts for better data presentation in table
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"
76  );
77 
78  // Create row with fields and actions
79  $row = $row
80  ->withHeadline($record->getTitle())
81  ->withImportantFields(
82  [
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
86  ]
87  )
88  ->withContent(
89  $ui_factory->listing()->descriptive(
90  [
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,
96  ]
97  )
98  );
99 
100  if (null !== ($dropdown = $actions[$record->getPolicyId()] ?? null)) {
101  $row = $row->withAction($dropdown);
102  }
103 
104  return $row;
105  }
106  )->withData($policies);
107 
108  $this->components[] = $table;
109  }
getAudienceText(int $audience_type, array $audience_data)
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.
+ 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 123 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().

123  : array
124  {
125  if(!$this->write_access) {
126  return [];
127  }
128  $dropdowns = [];
129  foreach ($policies as $policy) {
130  // Store policy_id for later use when the table's actions (edit / delete) are used)
131  $this->ctrl->setParameterByClass(
132  ilUploadLimitsOverviewGUI::class,
134  $policy->getPolicyId()
135  );
136 
137  $deletion_modal = $this->getDeletionConfirmationModal($policy);
138  $dropdowns[$policy->getPolicyId()] = $this->ui_factory->dropdown()->standard(
139  [
140  $this->ui_factory->button()->shy(
141  $this->language->txt('edit'),
142  $this->ctrl->getLinkTargetByClass(
143  ilUploadLimitsOverviewGUI::class,
145  )
146  ),
147  $this->ui_factory->button()->shy(
148  $this->language->txt('delete'),
149  $deletion_modal->getShowSignal()
150  )
151  ]
152  );
153 
154  $this->components[] = $deletion_modal;
155  }
156 
157  return $dropdowns;
158  }
getDeletionConfirmationModal(UploadPolicy $record)
+ 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 186 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().

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

◆ getComponents()

UploadPoliciesTableUI::getComponents ( )
Returns
Component[]

Definition at line 114 of file UploadPoliciesTableUI.php.

References $components.

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

◆ getDeletionConfirmationModal()

UploadPoliciesTableUI::getDeletionConfirmationModal ( UploadPolicy  $record)
protected

Definition at line 240 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().

240  : Interruptive
241  {
242  $upload_limit_text = $record->getUploadLimitInMB() . " MB";
243  $active_text = ($record->isActive()) ? $this->language->txt('yes') : $this->language->txt('no');
244  $audience_text = $this->getAudienceText($record->getAudienceType(), $record->getAudience());
245  $valid_until_text = $record->getValidUntil()?->format('d.m.Y') ?? $this->language->txt(
246  "policy_no_validity_limitation_set"
247  );
248 
249  $item_text = $this->language->txt('title') . $record->getTitle() . "<br/>"
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/>"
253  . $this->language->txt('policy_scope') . $record->getScopeDefinition() . "<br/>"
254  . $this->language->txt('policy_valid_until') . $valid_until_text;
255 
256  $deletion_item = $this->ui_factory->modal()->interruptiveItem()->standard(
257  (string) $record->getPolicyId(),
258  $item_text
259  );
260 
261  return $this->ui_factory->modal()->interruptive(
262  $this->language->txt("delete"),
263  $this->language->txt('policy_confirm_deletion'),
264  $this->ctrl->getLinkTargetByClass(
265  ilUploadLimitsOverviewGUI::class,
267  )
268  )->withAffectedItems(
269  [$deletion_item]
270  )->withActionButtonLabel($this->language->txt('delete'));
271  }
getAudienceText(int $audience_type, array $audience_data)
+ 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 276 of file UploadPoliciesTableUI.php.

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

Referenced by __construct().

276  : array
277  {
278  $policy_data = $this->upload_policy_db_repository->getAll();
279 
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()
285  ),
286  $policy_data
287  );
288  }
289 
290  return $policy_data;
291  }
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 213 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().

213  : Mode
214  {
215  $target = $this->ctrl->getLinkTargetByClass(
216  ilUploadLimitsOverviewGUI::class,
218  );
219 
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()
225  );
226  }
227 
228  $actions_prefix = $target . "&" . self::ACTIVE_FILTER_PARAM . "=";
229  $actions = [
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
233  ];
234 
235  return $this->ui_factory->viewControl()->mode($actions, 'policy_filter')->withActive(
236  $this->language->txt($active_control_element)
237  );
238  }
static http()
Fetches the global http state from ILIAS.
This describes a Mode Control.
Definition: Mode.php:28
+ 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 45 of file UploadPoliciesTableUI.php.

Referenced by getComponents().

◆ ACTIVE_FILTER_ACTIVE

const UploadPoliciesTableUI::ACTIVE_FILTER_ACTIVE = "active"
protected

Definition at line 39 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_ALL

const UploadPoliciesTableUI::ACTIVE_FILTER_ALL = "all"
protected

Definition at line 38 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_INACTIVE

const UploadPoliciesTableUI::ACTIVE_FILTER_INACTIVE = "inactive"
protected

Definition at line 40 of file UploadPoliciesTableUI.php.

◆ ACTIVE_FILTER_PARAM

const UploadPoliciesTableUI::ACTIVE_FILTER_PARAM = "active_filter"

Definition at line 37 of file UploadPoliciesTableUI.php.


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