19declare(strict_types=1);
29 self::SORT_MANUALLY => [
'top',
'bot'],
38 protected readonly
int $view = self::VIEW_SELECTED_ITEMS,
131 return self::AVAILABLE_SORT_OPTIONS_BY_VIEW[$view] ?? [];
136 $sorting = $this->
settings->get(
'pd_def_sort_view_' . $view, self::SORT_BY_LOCATION);
156 return self::AVAILABLE_PRESENTATION_BY_VIEW[$view];
161 if (!in_array($type, $active,
true)) {
167 $this->
settings->set(
'pd_def_sort_view_' . $view, $type);
168 $this->
settings->set(
'pd_active_sort_view_' . $view, serialize($active));
173 foreach (
$options as $sorting => $option) {
176 'pd_sort_options_' . $view .
'_' . $sorting,
187 $val = $this->
settings->get(
'pd_active_sort_view_' . $view);
188 if ($val ===
'' || $val ===
null) {
191 $active_sortings = unserialize($val, [
'allowed_classes' =>
false]);
195 fn(
string $sorting):
bool => in_array(
208 if (!in_array($default, $active,
true)) {
209 $active[] = $default;
211 $this->
settings->set(
'pd_def_pres_view_' . $view, $default);
212 $this->
settings->set(
'pd_active_pres_view_' . $view, serialize($active));
217 return $this->
settings->get(
'pd_def_pres_view_' . $view,
'list');
225 $val = $this->
settings->get(
'pd_active_pres_view_' . $view,
'');
229 : unserialize($val, [
'allowed_classes' =>
false]);
237 $this->
settings->set(
'pd_view_positions', serialize($positions));
245 $val = $this->
settings->get(
'pd_view_positions',
'');
248 : unserialize($val, [
'allowed_classes' =>
false]);
287 throw new InvalidArgumentException(
'Unknown view: $view');
293 return (
int) $this->
settings->get(
'disable_my_memberships',
'0') === 0;
298 return (
int) $this->
settings->get(
'disable_my_offers',
'0') === 0;
303 $this->
settings->set(
'disable_my_memberships', $status ?
'0' :
'1');
308 $this->
settings->set(
'disable_my_offers', $status ?
'0' :
'1');
328 $this->
settings->set(
'personal_items_default_view', (
string) $view);
339 $mode = $this->actor->getPref(
'pd_view_pres_' . $this->view);
350 $mode = $this->actor->getPref(
'pd_order_items_' . $this->view);
364 return array_intersect(
375 if (!$this->
access->canChangePresentation($this->actor->getId())) {
378 return array_intersect(
387 $this->actor->writePref(
388 'pd_view_pres_' . $this->view,
397 $this->actor->writePref(
398 'pd_order_items_' . $this->view,
421 return in_array($view, self::AVAILABLE_VIEWS,
true);
466 return (
int) $this->
settings->get(
'disable_learning_sequences',
'1') === 0;
471 return (
int) $this->
settings->get(
'disable_study_programmes',
'1') === 0;
476 $this->
settings->set(
'disable_learning_sequences', $status ?
'0' :
'1');
481 $this->
settings->set(
'disable_study_programmes', $status ?
'0' :
'1');
486 return self::VIEW_NAMES[$view];
495 $key =
'pd_order_data_' . $this->
getView() .
'_' . $mode;
496 return in_array($mode, self::$has_data,
true) ?
497 json_decode($this->actor->getPref($key) ?:
'[]',
true, 2) :
509 if (in_array($mode, self::$has_options,
true)) {
510 $this->actor->writePref(
'pd_order_data_' . $this->
getView() .
'_' . $mode, json_encode(
$data));
516 return self::$options_by_sortation[$sortation] ?? [];
524 return array_merge(...array_map(fn($sorting) => [
525 $sorting => json_decode(
526 $this->
settings->get(
'pd_sort_options_' . $view .
'_' . $sorting) ?:
'[]',
530 ], self::$has_options));
isStudyProgrammeViewActive()
storeActorPresentationMode(string $presentationMode)
enabledRecommendedContent()
enableView(int $view, bool $status)
storeViewSorting(int $view, string $type, array $active)
getActiveSortingsByView(int $view)
getDefaultPresentationByView(int $view)
enableLearningSequences(bool $status)
string $current_presentation_option
getTilePresentationMode()
enableMemberships(bool $status)
storeDefaultView(int $view)
enabledLearningSequences()
getDefaultSortingByView(int $view)
getEffectiveSortingMode()
getAvailableOptionsBySortation(string $sortation)
enableSelectedItems(bool $status)
getEffectivePresentationMode()
storeActorSortingData(array $data)
getSortingOptionsByView(int $view)
enableStudyProgrammes(bool $status)
getRecommendedContentView()
getActivePresentationsByView(int $view)
setViewPositions(array $positions)
isRecommendedContentViewActive()
isSelectedItemsViewActive()
getListPresentationMode()
getEffectiveSortingData()
string $current_sort_option
getSelectableSortingModes()
storeViewPresentation(int $view, string $default, array $active)
static array $options_by_sortation
getLearningSequenceView()
static array $has_options
__construct(protected readonly ilObjUser $actor, protected readonly int $view=self::VIEW_SELECTED_ITEMS, ?Setting $settings=null, protected readonly DashboardAccess $access=new DashboardAccess())
getEffectiveSortingOptions()
storeActorSortingMode(string $sortingMode)
isMembershipsViewActive()
storeViewSortingOptions(int $view, array $options)
getAvailableSortOptionsByView(int $view)
getAvailablePresentationsByView(int $view)
getSelectablePresentationModes()
isLearningSequenceViewActive()
const VIEW_RECOMMENDED_CONTENT
const VIEW_MY_STUDYPROGRAMME
const VIEW_SELECTED_ITEMS
const VIEW_MY_MEMBERSHIPS
const VIEW_LEARNING_SEQUENCES