ILIAS  release_8 Revision v8.24
class.ilPDSelectedItemsBlockMembershipsProvider.php
Go to the documentation of this file.
1<?php
2
20{
21 protected ilObjUser $actor;
22 protected ilTree $tree;
26
27 public function __construct(ilObjUser $actor)
28 {
29 global $DIC;
30
31 $this->actor = $actor;
32 $this->tree = $DIC->repositoryTree();
33 $this->access = $DIC->access();
34 $this->settings = $DIC->settings();
36 $DIC->database(),
38 );
39 }
40
44 protected function getObjectsByMembership(array $objTypes = []): array
45 {
46 $short_desc = $this->settings->get("rep_shorten_description");
47 $short_desc_max_length = (int) $this->settings->get("rep_shorten_description_length");
48
49 if (!is_array($objTypes) || $objTypes === []) {
50 $objTypes = $this->repository->getValidObjectTypes();
51 }
52
53 $references = [];
54 foreach ($this->repository->getForUser($this->actor, $objTypes, $this->actor->getLanguage()) as $item) {
55 $refId = $item->getRefId();
56 $objId = $item->getObjId();
57 $parentRefId = $item->getParentRefId();
58 $title = $item->getTitle();
59 $parentTreeLftValue = $item->getParentLftTree();
60 $parentTreeLftValue = sprintf("%010d", $parentTreeLftValue);
61
62 if (!$this->access->checkAccess('visible', '', $refId)) {
63 continue;
64 }
65
66 $periodStart = $periodEnd = null;
67 if ($item->getPeriodStart() !== null && $item->getPeriodEnd() !== null) {
68 if ($item->objectPeriodHasTime()) {
69 $periodStart = new ilDateTime($item->getPeriodStart()->getTimestamp(), IL_CAL_UNIX);
70 $periodEnd = new ilDateTime($item->getPeriodEnd()->getTimestamp(), IL_CAL_UNIX);
71 } else {
72 $periodStart = new ilDate($item->getPeriodStart()->format('Y-m-d'), IL_CAL_DATE);
73 $periodEnd = new ilDate($item->getPeriodEnd()->format('Y-m-d'), IL_CAL_DATE);
74 }
75 }
76
77 $description = $item->getDescription();
78 if ($short_desc && $short_desc_max_length !== 0) {
79 $description = ilStr::shortenTextExtended($description, $short_desc_max_length, true);
80 }
81
82 $references[$parentTreeLftValue . $title . $refId] = [
83 'ref_id' => $refId,
84 'obj_id' => $objId,
85 'type' => $item->getType(),
86 'title' => $title,
87 'description' => $description,
88 'parent_ref' => $parentRefId,
89 'start' => $periodStart,
90 'end' => $periodEnd
91 ];
92 }
93 ksort($references);
94
95 return $references;
96 }
97
98 public function getItems(array $object_type_white_list = array()): array
99 {
100 return $this->getObjectsByMembership($object_type_white_list);
101 }
102}
const IL_CAL_DATE
const IL_CAL_UNIX
@classDescription Date and time handling
Class for single dates.
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilPDSelectedItemsBlockMembershipsObjectRepository $repository
getObjectsByMembership(array $objTypes=[])
Gets all objects the current user is member of.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const RECOVERY_FOLDER_ID
Definition: constants.php:37
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$objId
Definition: xapitoken.php:57
$refId
Definition: xapitoken.php:58