ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPDSelectedItemsBlockMembershipsProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ilObjUser $actor;
24 protected ilTree $tree;
28
29 public function __construct(ilObjUser $actor)
30 {
31 global $DIC;
32
33 $this->actor = $actor;
34 $this->tree = $DIC->repositoryTree();
35 $this->access = $DIC->access();
36 $this->settings = $DIC->settings();
38 $DIC->database(),
40 );
41 }
42
43 protected function getObjectsByMembership(array $objTypes = []): array
44 {
45 $short_desc = $this->settings->get('rep_shorten_description');
46 $short_desc_max_length = (int) $this->settings->get('rep_shorten_description_length');
47
48 if (!is_array($objTypes) || $objTypes === []) {
49 $objTypes = $this->repository->getValidObjectTypes();
50 }
51
52 $references = [];
53 foreach ($this->repository->getForUser($this->actor, $objTypes, $this->actor->getLanguage()) as $item) {
54 $refId = $item->getRefId();
55 $objId = $item->getObjId();
56 $parentRefId = $item->getParentRefId();
57 $title = $item->getTitle();
58 $parentTreeLftValue = $item->getParentLftTree();
59 $parentTreeLftValue = sprintf('%010d', $parentTreeLftValue);
60
61 if (!$this->access->checkAccess('visible', '', $refId)) {
62 continue;
63 }
64
65 $periodStart = $periodEnd = null;
66 if ($item->getPeriodStart() !== null && $item->getPeriodEnd() !== null) {
67 if ($item->objectPeriodHasTime()) {
68 $periodStart = new ilDateTime($item->getPeriodStart()->getTimestamp(), IL_CAL_UNIX);
69 $periodEnd = new ilDateTime($item->getPeriodEnd()->getTimestamp(), IL_CAL_UNIX);
70 } else {
71 $periodStart = new ilDate($item->getPeriodStart()->format('Y-m-d'), IL_CAL_DATE);
72 $periodEnd = new ilDate($item->getPeriodEnd()->format('Y-m-d'), IL_CAL_DATE);
73 }
74 }
75
76 $description = $item->getDescription();
77 if ($short_desc && $short_desc_max_length !== 0) {
78 $description = ilStr::shortenTextExtended($description, $short_desc_max_length, true);
79 }
80
81 $references[$parentTreeLftValue . $title . $refId] = [
82 'ref_id' => $refId,
83 'obj_id' => $objId,
84 'type' => $item->getType(),
85 'title' => $title,
86 'description' => $description,
87 'parent_ref' => $parentRefId,
88 'start' => $periodStart,
89 'end' => $periodEnd
90 ];
91 }
92 ksort($references);
93
94 return $references;
95 }
96
97 public function getItems(array $object_type_white_list = []): array
98 {
99 return $this->getObjectsByMembership($object_type_white_list);
100 }
101}
const IL_CAL_DATE
const IL_CAL_UNIX
@classDescription Date and time handling
Class for single dates.
User class.
ilPDSelectedItemsBlockMembershipsObjectRepository $repository
ILIAS Setting Class.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const RECOVERY_FOLDER_ID
Definition: constants.php:37
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
global $DIC
Definition: shib_login.php:26
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58