ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ItemPresentationManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
34{
35 protected ?string $lang = null;
36 protected bool $include_empty_blocks;
38 protected ?bool $can_order = null;
40 protected ?bool $can_manage = null;
43 protected ?array $type_grps = null;
44 protected ?ItemSetManager $item_set = null;
45 protected \ilContainer $container;
48
49 public function __construct(
54 bool $include_empty_blocks = true,
55 ?string $lang = null
56 ) {
57 $this->container = $container;
58 $this->domain = $domain;
59 $this->container_user_filter = $container_user_filter;
60 $this->repo_clipboard = $repo_clipboard;
61 $this->mode_manager = $domain->content()->mode($container);
62 $this->include_empty_blocks = $include_empty_blocks;
63 $this->lang = $lang;
64
65 // sequence from view manager
66 }
67
68 public function canManageItems(): bool
69 {
70 if (!is_null($this->can_manage)) {
71 return $this->can_manage;
72 }
73 $user = $this->domain->user();
74 $rbacsystem = $this->domain->rbac()->system();
75 if ($user->getId() === ANONYMOUS_USER_ID || !is_object($this->container)) {
76 return false;
77 }
78
79 if ($rbacsystem->checkAccess("write", $this->container->getRefId()) ||
80 $this->container->getHiddenFilesFound() ||
81 $this->repo_clipboard->hasEntries()) {
82 $this->can_manage = true;
83 return true;
84 }
85 $this->init();
86 $this->can_manage = false;
87 /* this is time consuming and probably not necessary
88 foreach ($this->item_set->getAllRefIds() as $ref_id) {
89 if ($this->can_manage === true) {
90 break;
91 }
92 if ($rbacsystem->checkAccess("delete", $ref_id)) {
93 $this->can_manage = true;
94 }
95 }*/
96 return $this->can_manage;
97 }
98
102 public function canOrderItems(): bool
103 {
104 $user = $this->domain->user();
105 $rbacsystem = $this->domain->rbac()->system();
106
107 if (is_null($this->can_order)) {
108 $this->can_order = false;
109 if ($user->getId() !== ANONYMOUS_USER_ID &&
110 is_object($this->container) &&
111 $rbacsystem->checkAccess("write", $this->container->getRefId())) {
112 $this->can_order = (\ilContainerSortingSettings::_lookupSortMode($this->container->getId()) === \ilContainer::SORT_MANUAL);
113 }
114 }
115 return $this->can_order;
116 }
117
121 public function isActiveItemOrdering(string $type): bool
122 {
123 // see #43205
124 if ($this->mode_manager->isActiveItemOrdering()) {
125 if ($type === "sess" && $this->container->getViewMode() === \ilContainer::VIEW_SESSIONS) {
126 return false;
127 }
128 return true;
129 }
130 return false;
131 }
132
133 public function forceSessionOrderingByDate(): bool
134 {
135 // see #43205
136 return ($this->container->getViewMode() === \ilContainer::VIEW_SESSIONS ||
137 $this->container->getOrderType() !== \ilContainer::SORT_MANUAL);
138 }
139
140
145 protected function isClassificationFilterActive(): bool
146 {
147 $ref_id = $this->container->getRefId();
148 // apply container classification filters
149 $classification = $this->domain->classification($ref_id);
151 $this->container->getRefId(),
152 $this->container->getId(),
153 $this->container->getType()
154 ) as $class_provider) {
155 $id = get_class($class_provider);
156 $current = $classification->getSelectionOfProvider($id);
157 if ($current) {
158 return true;
159 }
160 }
161 return false;
162 }
163
167 public function filteredSubtree(): bool
168 {
169 return $this->isClassificationFilterActive() && in_array(
170 $this->container->getType(),
171 ["grp", "crs"]
172 );
173 }
174
175 protected function init(): void
176 {
177 // already initialised?
178 if (!is_null($this->item_set)) {
179 return;
180 }
181
182 // get view
183 $view = $this->domain->content()->view($this->container);
184 // get item set
185 $ref_id = $this->container->getRefId();
186 if ($this->filteredSubtree()) {
187 $this->item_set = $this->domain->content()->itemSetTree($ref_id, $this->container_user_filter);
188 } else {
189 $this->item_set = $this->domain->content()->itemSetFlat(
190 $ref_id,
191 $this->container_user_filter,
193 $view instanceof ObjectiveViewManager
194 );
195 }
196
197 // get item block sequence generator
198 $this->sequence_generator = $this->domain->content()->itemBlockSequenceGenerator(
199 $this->container,
200 $view->getBlockSequence(),
201 $this->item_set,
202 $this->include_empty_blocks,
203 $this->lang
204 );
205 }
206
207 public function hasItems(): bool
208 {
209 $this->init();
210 return $this->item_set->hasItems();
211 }
212
214 {
215 $this->init();
216 return $this->sequence_generator->getSequence();
217 }
218
219 public function getPageEmbeddedBlockIds(): array
220 {
221 $this->init();
222 return $this->sequence_generator->getPageEmbeddedBlockIds();
223 }
224
225 public function getRawDataByRefId(int $ref_id): ?array
226 {
227 $this->init();
228 return $this->item_set->getRawDataByRefId($ref_id);
229 }
230
231 public function getAllRefIds(): ?array
232 {
233 $this->init();
234 return $this->item_set->getAllRefIds();
235 }
236
237 public function getRefIdsOfType(string $type): array
238 {
239 $this->init();
240 return $this->item_set->getRefIdsOfType($type);
241 }
242}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$classification
__construct(InternalDomainService $domain, \ilContainer $container, ?\ilContainerUserFilter $container_user_filter, ClipboardManager $repo_clipboard, bool $include_empty_blocks=true, ?string $lang=null)
isActiveItemOrdering(string $type)
Are we currently in ordering view and the items can be ordered?
Manages items in repository clipboard.
static getValidProviders(int $a_parent_ref_id, int $a_parent_obj_id, string $a_parent_obj_type)
Get all valid providers (for parent container)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilContainer.
const ANONYMOUS_USER_ID
Definition: constants.php:27
$ref_id
Definition: ltiauth.php:66