ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Certificate\Overview\CertificateOverviewTable Class Reference
+ Inheritance diagram for ILIAS\Certificate\Overview\CertificateOverviewTable:
+ Collaboration diagram for ILIAS\Certificate\Overview\CertificateOverviewTable:

Public Member Functions

 __construct (?Factory $ui_factory=null, ?ilUserCertificateRepository $repo=null, ?ilUIService $ui_service=null, ?ilLanguage $lng=null, ServerRequestInterface|RequestInterface|null $request=null, ?\ILIAS\Data\Factory $data_factory=null, ?ilCtrl $ctrl=null, ?Renderer $ui_renderer=null, ?ilAccessHandler $access=null, ?ilObjUser $user=null)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 render ()
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 

Private Member Functions

 mapUiFilterData (array $filter_data)
 
 buildFilter ()
 
 buildTable ()
 
 buildTableRows (array $certificates)
 

Private Attributes

readonly ilUserCertificateRepository $repo
 
readonly ilUIService $ui_service
 
readonly Factory $ui_factory
 
readonly ilLanguage $lng
 
readonly ServerRequestInterface $request
 
readonly ILIAS Data Factory $data_factory
 
readonly ilCtrl ilCtrlInterface $ctrl
 
readonly ILIAS UI Component Input Container Filter Standard $filter
 
readonly Data $table
 
readonly Renderer $ui_renderer
 
readonly ilAccessHandler $access
 
readonly ilObjUser $user
 
readonly DateTimeZone $user_timezone
 

Detailed Description

Definition at line 52 of file CertificateOverviewTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Certificate\Overview\CertificateOverviewTable::__construct ( ?Factory  $ui_factory = null,
?ilUserCertificateRepository  $repo = null,
?ilUIService  $ui_service = null,
?ilLanguage  $lng = null,
ServerRequestInterface|RequestInterface|null  $request = null,
?\ILIAS\Data\Factory  $data_factory = null,
?ilCtrl  $ctrl = null,
?Renderer  $ui_renderer = null,
?ilAccessHandler  $access = null,
?ilObjUser  $user = null 
)

Definition at line 68 of file CertificateOverviewTable.php.

References $DIC, ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Repository\access(), ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), ILIAS\Certificate\Overview\CertificateOverviewTable\buildFilter(), ILIAS\Certificate\Overview\CertificateOverviewTable\buildTable(), ILIAS\Certificate\Overview\CertificateOverviewTable\buildTableRows(), ILIAS\Repository\ctrl(), ILIAS\Repository\filter(), ILIAS\UI\Component\Table\DataRetrieval\getRows(), ILIAS\Data\Order\join(), ILIAS\Repository\lng(), ILIAS\Certificate\Overview\CertificateOverviewTable\mapUiFilterData(), and ILIAS\Repository\user().

79  {
80  global $DIC;
81  $this->ui_factory = $ui_factory ?: $DIC->ui()->factory();
82  $this->repo = $repo ?: new ilUserCertificateRepository();
83  $this->ui_service = $ui_service ?: $DIC->uiService();
84  $this->lng = $lng ?: $DIC->language();
85  $this->request = $request ?: $DIC->http()->request();
86  $this->data_factory = $data_factory ?: new \ILIAS\Data\Factory();
87  $this->ctrl = $ctrl ?: $DIC->ctrl();
88  $this->ui_renderer = $ui_renderer ?: $DIC->ui()->renderer();
89  $this->access = $access ?: $DIC->access();
90  $this->user = $user ?: $DIC->user();
91  $this->user_timezone = new \DateTimeZone($this->user->getTimeZone());
92 
93  $this->filter = $this->buildFilter();
94  $this->table = $this->buildTable();
95  }
global $DIC
Definition: shib_login.php:26
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildFilter()

ILIAS\Certificate\Overview\CertificateOverviewTable::buildFilter ( )
private

Definition at line 171 of file CertificateOverviewTable.php.

References ilObjCertificateSettingsGUI\CMD_CERTIFICATES_OVERVIEW, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by ILIAS\Certificate\Overview\CertificateOverviewTable\__construct().

171  : \ILIAS\UI\Component\Input\Container\Filter\Standard
172  {
173  return $this->ui_service->filter()->standard(
174  'certificates_overview_filter',
175  $this->ctrl->getLinkTargetByClass(
176  ilObjCertificateSettingsGUI::class,
178  ),
179  [
180  'certificate_id' => $this->ui_factory->input()->field()->text($this->lng->txt('certificate_id')),
181  'issue_date' => $this->ui_factory->input()->field()
182  ->duration($this->lng->txt('certificate_issue_date'))
183  ->withFormat($this->user->getDateTimeFormat())
184  ->withUseTime(true),
185  'object' => $this->ui_factory->input()->field()->text($this->lng->txt('obj')),
186  'obj_id' => $this->ui_factory->input()->field()->text($this->lng->txt('object_id')),
187  'owner' => $this->ui_factory->input()->field()->text($this->lng->txt('owner')),
188  ],
189  [true, true, true, true, true],
190  true,
191  true
192  );
193  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTable()

ILIAS\Certificate\Overview\CertificateOverviewTable::buildTable ( )
private

Definition at line 195 of file CertificateOverviewTable.php.

References ilObjCertificateSettingsGUI\CMD_DOWNLOAD_CERTIFICATE, ILIAS\Repository\ctrl(), ILIAS\Data\Order\DESC, ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by ILIAS\Certificate\Overview\CertificateOverviewTable\__construct().

195  : Data
196  {
197  $ui_table = $this->ui_factory->table();
198 
199  return $ui_table->data(
200  $this,
201  $this->lng->txt('certificates'),
202  [
203  'certificate_id' => $ui_table->column()->text($this->lng->txt('certificate_id')),
204  'issue_date' => $ui_table->column()->date($this->lng->txt('certificate_issue_date'), $this->user->getDateTimeFormat()),
205  'object' => $ui_table->column()->text($this->lng->txt('obj')),
206  'obj_id' => $ui_table->column()->text($this->lng->txt('object_id')),
207  'owner' => $ui_table->column()->text($this->lng->txt('owner'))
208  ],
209  )
210  ->withOrder(new Order('issue_date', Order::DESC))
211  ->withId('certificateOverviewTable')
212  ->withRequest($this->request)
213  ->withActions($this->buildTableActions());
214  }
const DESC
Definition: Order.php:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTableRows()

ILIAS\Certificate\Overview\CertificateOverviewTable::buildTableRows ( array  $certificates)
private
Parameters
ilUserCertificate[]$certificates
Returns
list<array{"id": int, "certificate": string, "issue_date": int, "object": string, "obj_id": string, "owner": string}>

Definition at line 257 of file CertificateOverviewTable.php.

References $refId, ilObject\_getAllReferences(), ilObjUser\_lookupLogin(), ilObject\_lookupTitle(), and ILIAS\Repository\access().

Referenced by ILIAS\Certificate\Overview\CertificateOverviewTable\__construct().

257  : array
258  {
259  $table_rows = [];
260 
261  $ref_id_cache = [];
262  $owner_cache = [];
263  $object_title_cache = [];
264 
265  foreach ($certificates as $certificate) {
266  if (!isset($ref_id_cache[$certificate->getObjId()])) {
267  $ref_id_cache[$certificate->getObjId()] = ilObject::_getAllReferences($certificate->getObjId());
268  }
269  $ref_ids = $ref_id_cache[$certificate->getObjId()];
270 
271  if (!isset($object_title_cache[$certificate->getObjId()])) {
272  $object_title = ilObject::_lookupTitle($certificate->getObjId());
273  foreach ($ref_ids as $refId) {
274  if ($this->access->checkAccess('read', '', $refId)) {
275  $object_title = $this->ui_renderer->render(
276  $this->ui_factory->link()->standard($object_title, ilLink::_getLink($refId))
277  );
278  break;
279  }
280  }
281 
282  $object_title_cache[$certificate->getObjId()] = $object_title;
283  }
284 
285 
286 
287  if (!isset($owner_cache[$certificate->getUserId()])) {
288  $owner_cache[$certificate->getUserId()] = ilObjUser::_lookupLogin($certificate->getUserId());
289  }
290 
291  $table_rows[] = [
292  'id' => $certificate->getId(),
293  'certificate_id' => $certificate->getCertificateId()->asString(),
294  'issue_date' => $certificate->getAcquiredTimestamp(),
295  'object' => $object_title_cache[$certificate->getObjId()],
296  'obj_id' => (string) $certificate->getObjId(),
297  'owner' => $owner_cache[$certificate->getUserId()],
298  ];
299  }
300 
301  return $table_rows;
302  }
static _getAllReferences(int $id)
get all reference ids for object ID
$refId
Definition: xapitoken.php:58
static _lookupTitle(int $obj_id)
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTotalRowCount()

ILIAS\Certificate\Overview\CertificateOverviewTable::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 163 of file CertificateOverviewTable.php.

References ILIAS\Repository\filter(), and ILIAS\Certificate\Overview\CertificateOverviewTable\mapUiFilterData().

163  : ?int
164  {
165  $ui_filter_data = $this->mapUiFilterData($this->ui_service->filter()->getData($this->filter));
166 
167  return $this->repo->fetchCertificatesForOverviewCount($ui_filter_data);
168  }
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

◆ mapUiFilterData()

ILIAS\Certificate\Overview\CertificateOverviewTable::mapUiFilterData ( array  $filter_data)
private
Parameters
array{certificate_idnull|string, issue_date: string[], object: null|string, owner: null|string} $filter_data
Returns
array{certificate_id: null|string, issue_date: array{from: null|DateTimeImmutable, to: null|DateTimeImmutable}, object: null|string, owner: null|string} $filter_data

Definition at line 132 of file CertificateOverviewTable.php.

References ILIAS\Repository\int(), and null.

Referenced by ILIAS\Certificate\Overview\CertificateOverviewTable\__construct(), and ILIAS\Certificate\Overview\CertificateOverviewTable\getTotalRowCount().

132  : array
133  {
134  if (isset($filter_data['issue_date']) && $filter_data['issue_date'] !== '') {
135  try {
136  $from = new DateTimeImmutable($filter_data['issue_date'][0], $this->user_timezone);
137  } catch (Throwable) {
138  $from = null;
139  }
140 
141  try {
142  $to = new DateTimeImmutable($filter_data['issue_date'][1], $this->user_timezone);
143  $seconds_to_add = 59 - (int) $to->format('s');
144  $to = $to->modify("+$seconds_to_add seconds");
145  } catch (Throwable) {
146  $to = null;
147  }
148 
149  $filter_data['issue_date'] = [
150  'from' => $from,
151  'to' => $to
152  ];
153  } else {
154  $filter_data['issue_date'] = [
155  'from' => null,
156  'to' => null
157  ];
158  }
159 
160  return $filter_data;
161  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ILIAS\Certificate\Overview\CertificateOverviewTable::render ( )

Definition at line 304 of file CertificateOverviewTable.php.

References ILIAS\Repository\filter().

304  : string
305  {
306  return $this->ui_renderer->render([$this->filter, $this->table]);
307  }
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
+ Here is the call graph for this function:

Field Documentation

◆ $access

readonly ilAccessHandler ILIAS\Certificate\Overview\CertificateOverviewTable::$access
private

Definition at line 64 of file CertificateOverviewTable.php.

◆ $ctrl

readonly ilCtrl ilCtrlInterface ILIAS\Certificate\Overview\CertificateOverviewTable::$ctrl
private

Definition at line 60 of file CertificateOverviewTable.php.

◆ $data_factory

readonly ILIAS Data Factory ILIAS\Certificate\Overview\CertificateOverviewTable::$data_factory
private

Definition at line 59 of file CertificateOverviewTable.php.

◆ $filter

readonly ILIAS UI Component Input Container Filter Standard ILIAS\Certificate\Overview\CertificateOverviewTable::$filter
private

Definition at line 61 of file CertificateOverviewTable.php.

◆ $lng

readonly ilLanguage ILIAS\Certificate\Overview\CertificateOverviewTable::$lng
private

Definition at line 57 of file CertificateOverviewTable.php.

◆ $repo

readonly ilUserCertificateRepository ILIAS\Certificate\Overview\CertificateOverviewTable::$repo
private

Definition at line 54 of file CertificateOverviewTable.php.

◆ $request

readonly ServerRequestInterface ILIAS\Certificate\Overview\CertificateOverviewTable::$request
private

Definition at line 58 of file CertificateOverviewTable.php.

◆ $table

readonly Data ILIAS\Certificate\Overview\CertificateOverviewTable::$table
private

Definition at line 62 of file CertificateOverviewTable.php.

◆ $ui_factory

readonly Factory ILIAS\Certificate\Overview\CertificateOverviewTable::$ui_factory
private

Definition at line 56 of file CertificateOverviewTable.php.

◆ $ui_renderer

readonly Renderer ILIAS\Certificate\Overview\CertificateOverviewTable::$ui_renderer
private

Definition at line 63 of file CertificateOverviewTable.php.

◆ $ui_service

readonly ilUIService ILIAS\Certificate\Overview\CertificateOverviewTable::$ui_service
private

Definition at line 55 of file CertificateOverviewTable.php.

◆ $user

readonly ilObjUser ILIAS\Certificate\Overview\CertificateOverviewTable::$user
private

Definition at line 65 of file CertificateOverviewTable.php.

◆ $user_timezone

readonly DateTimeZone ILIAS\Certificate\Overview\CertificateOverviewTable::$user_timezone
private

Definition at line 66 of file CertificateOverviewTable.php.


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