19 declare(strict_types=1);
28 self::VIEW_SELECTED_ITEMS,
29 self::VIEW_RECOMMENDED_CONTENT,
30 self::VIEW_MY_MEMBERSHIPS,
31 self::VIEW_LEARNING_SEQUENCES,
32 self::VIEW_MY_STUDYPROGRAMME,
36 self::VIEW_SELECTED_ITEMS =>
'favourites',
37 self::VIEW_RECOMMENDED_CONTENT =>
'recommended_content',
38 self::VIEW_MY_MEMBERSHIPS =>
'memberships',
39 self::VIEW_LEARNING_SEQUENCES =>
'learning_sequences',
40 self::VIEW_MY_STUDYPROGRAMME =>
'study_programmes',
44 self::PRESENTATION_LIST,
45 self::PRESENTATION_TILE
49 self::SORT_BY_LOCATION,
51 self::SORT_BY_START_DATE,
52 self::SORT_BY_ALPHABET,
56 self::VIEW_SELECTED_ITEMS => [
57 self::SORT_BY_LOCATION,
59 self::SORT_BY_ALPHABET,
61 self::VIEW_RECOMMENDED_CONTENT => [
62 self::SORT_BY_LOCATION,
64 self::SORT_BY_ALPHABET,
66 self::VIEW_MY_MEMBERSHIPS => [
67 self::SORT_BY_LOCATION,
69 self::SORT_BY_ALPHABET,
70 self::SORT_BY_START_DATE,
72 self::VIEW_LEARNING_SEQUENCES => [
73 self::SORT_BY_LOCATION,
74 self::SORT_BY_ALPHABET,
76 self::VIEW_MY_STUDYPROGRAMME => [
77 self::SORT_BY_LOCATION,
78 self::SORT_BY_ALPHABET,
83 self::VIEW_SELECTED_ITEMS => [
84 self::PRESENTATION_LIST,
85 self::PRESENTATION_TILE
87 self::VIEW_RECOMMENDED_CONTENT => [
88 self::PRESENTATION_LIST,
89 self::PRESENTATION_TILE
91 self::VIEW_MY_MEMBERSHIPS => [
92 self::PRESENTATION_LIST,
93 self::PRESENTATION_TILE
95 self::VIEW_LEARNING_SEQUENCES => [
96 self::PRESENTATION_LIST,
97 self::PRESENTATION_TILE
99 self::VIEW_MY_STUDYPROGRAMME => [
100 self::PRESENTATION_LIST,
101 self::PRESENTATION_TILE
115 int $view = self::VIEW_SELECTED_ITEMS,
121 $this->
settings = $settings ?? $DIC->settings();
124 $this->currentView = $view;
130 return self::VIEW_MY_MEMBERSHIPS;
135 return self::VIEW_SELECTED_ITEMS;
140 return self::VIEW_MY_STUDYPROGRAMME;
145 return self::VIEW_LEARNING_SEQUENCES;
150 return self::VIEW_RECOMMENDED_CONTENT;
155 return self::PRESENTATION_LIST;
160 return self::PRESENTATION_TILE;
170 return $this->currentView === self::VIEW_RECOMMENDED_CONTENT;
185 return $this->currentView === self::VIEW_LEARNING_SEQUENCES;
190 return self::SORT_BY_START_DATE;
195 return self::SORT_BY_LOCATION;
200 return self::SORT_BY_TYPE;
205 return self::SORT_BY_ALPHABET;
210 return self::$availableSortOptionsByView[$view] ?? [];
215 $sorting = $this->
settings->get(
'pd_def_sort_view_' . $view, self::SORT_BY_LOCATION);
227 return self::$availableViews;
235 return self::$availablePresentationsByView[$view];
240 if (!in_array($type, $active,
true)) {
246 $this->
settings->set(
'pd_def_sort_view_' . $view, $type);
247 $this->
settings->set(
'pd_active_sort_view_' . $view, serialize($active));
255 $val = $this->
settings->get(
'pd_active_sort_view_' . $view);
256 if ($val ===
'' || $val ===
null) {
259 $active_sortings = unserialize($val, [
'allowed_classes' =>
false]);
263 fn(
string $sorting):
bool => in_array(
276 if (!in_array($default, $active,
true)) {
277 $active[] = $default;
279 $this->
settings->set(
'pd_def_pres_view_' . $view, $default);
280 $this->
settings->set(
'pd_active_pres_view_' . $view, serialize($active));
285 return $this->
settings->get(
'pd_def_pres_view_' . $view,
'list');
293 $val = $this->
settings->get(
'pd_active_pres_view_' . $view,
'');
297 : unserialize($val, [
'allowed_classes' =>
false]);
305 $this->
settings->set(
'pd_view_positions', serialize($positions));
313 $val = $this->
settings->get(
'pd_view_positions',
'');
315 ? self::$availableViews
316 : unserialize($val, [
'allowed_classes' =>
false]);
361 return (
int) $this->
settings->get(
'disable_my_memberships',
'0') === 0;
366 return (
int) $this->
settings->get(
'disable_my_offers',
'0') === 0;
371 $this->
settings->set(
'disable_my_memberships', $status ?
'0' :
'1');
376 $this->
settings->set(
'disable_my_offers', $status ?
'0' :
'1');
396 $this->
settings->set(
'personal_items_default_view', (
string) $view);
401 $this->validViews = self::$availableViews;
409 $mode = $this->actor->getPref(
'pd_view_pres_' . $this->currentView);
420 $mode = $this->actor->getPref(
'pd_order_items_' . $this->currentView);
434 return array_intersect(
445 if (!$this->
access->canChangePresentation($this->actor->getId())) {
448 return array_intersect(
457 $this->actor->writePref(
458 'pd_view_pres_' . $this->currentView,
467 $this->actor->writePref(
468 'pd_order_items_' . $this->currentView,
491 return in_array($view, $this->validViews,
true);
536 return (
int) $this->
settings->get(
'disable_learning_sequences',
'1') === 0;
541 return (
int) $this->
settings->get(
'disable_study_programmes',
'1') === 0;
546 $this->
settings->set(
'disable_learning_sequences', $status ?
'0' :
'1');
551 $this->
settings->set(
'disable_study_programmes', $status ?
'0' :
'1');
556 return self::$viewNames[$view];
isSelectedItemsViewActive()
storeViewSorting(int $view, string $type, array $active)
getEffectiveSortingMode()
enableSelectedItems(bool $status)
static array $availableSortOptions
getRecommendedContentView()
string $currentSortOption
enableView(int $view, bool $status)
static array $availablePresentationsByView
isRecommendedContentViewActive()
getEffectivePresentationMode()
getTilePresentationMode()
static array $availableViews
__construct(ilObjUser $actor, int $view=self::VIEW_SELECTED_ITEMS, ?Setting $settings=null, ?DashboardAccess $access=null)
getDefaultSortingByView(int $view)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
enableMemberships(bool $status)
isLearningSequenceViewActive()
getActivePresentationsByView(int $view)
getActiveSortingsByView(int $view)
setViewPositions(array $positions)
storeDefaultView(int $view)
storeViewPresentation(int $view, string $default, array $active)
enabledLearningSequences()
enableLearningSequences(bool $status)
string $currentPresentationOption
static array Setting $settings
getSelectableSortingModes()
getListPresentationMode()
enabledRecommendedContent()
getDefaultPresentationByView(int $view)
storeActorSortingMode(string $sortingMode)
storeActorPresentationMode(string $presentationMode)
getLearningSequenceView()
isMembershipsViewActive()
getAvailablePresentationsByView(int $view)
isStudyProgrammeViewActive()
enableStudyProgrammes(bool $status)
getAvailableSortOptionsByView(int $view)
getSelectablePresentationModes()
static array $availableSortOptionsByView
static array $availablePresentations