ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLSLaunchlinksBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public const PERM_PARTICIPATE = 'participate';
29 public const PERM_UNPARTICIPATE = 'unparticipate';
30
36
37 public function __construct(
38 protected ilLanguage $lng,
39 protected ilAccess $access,
40 protected ilCtrl $ctrl,
41 protected ILIAS\UI\Factory $ui_factory,
42 protected int $lso_ref_id,
43 protected int $usr_id,
44 protected $first_access,
45 protected ilLearningSequenceRoles $roles,
46 protected ilLSLearnerItemsQueries $ls_items
47 ) {
48 }
49
50 protected function mayJoin(): bool
51 {
52 return $this->access->checkAccess(self::PERM_PARTICIPATE, '', $this->lso_ref_id);
53 }
54
55 public function currentUserMayUnparticipate(): bool
56 {
57 return $this->mayUnparticipate();
58 }
59
60 protected function mayUnparticipate(): bool
61 {
62 return $this->access->checkAccess(self::PERM_UNPARTICIPATE, '', $this->lso_ref_id);
63 }
64
65 protected function isMember(): bool
66 {
67 return $this->roles->isMember($this->usr_id);
68 }
69
70 protected function hasCompleted(): bool
71 {
72 return $this->roles->isCompletedByUser($this->usr_id);
73 }
74
75 protected function getLink(string $cmd): string
76 {
77 return $this->ctrl->getLinkTargetByClass('ilObjLearningSequenceLearnerGUI', $cmd);
78 }
79
80 public function getLinks(): array
81 {
82 $cmd = $this->ctrl->getCmd();
83 $links = [];
84
85 if (!$this->isMember() && $this->mayJoin()) {
86 if (!$this->ls_items->hasItems()) {
87 return [];
88 }
89 return [[
90 $this->lng->txt("lso_player_start"),
91 $this->getLink(self::CMD_START),
92 true
93 ]];
94 }
95
96 if (!$this->hasCompleted() && $this->ls_items->hasItems()) {
97 $label = "lso_player_resume";
98 if ($this->first_access === -1) {
99 $label = "lso_player_start";
100 }
101 $links[] = [
102 $this->lng->txt($label),
103 $this->getLink(self::CMD_VIEW),
104 true
105 ];
106 } else {
107 if ($this->ls_items->hasItems()) {
108 $links[] = [
109 $this->lng->txt("lso_player_review"),
110 $this->getLink(self::CMD_VIEW),
111 true
112 ];
113 }
114
115 if ($cmd === self::CMD_STANDARD) {
116 $links[] = [
117 $this->lng->txt("lso_player_extro"),
118 $this->getLink(self::CMD_EXTRO),
119 false
120 ];
121 }
122 if ($cmd === self::CMD_EXTRO) {
123 $links[] = [
124 $this->lng->txt("lso_player_abstract"),
125 $this->getLink(self::CMD_STANDARD),
126 false
127 ];
128 }
129 }
130
131 if ($this->mayUnparticipate()) {
132 $links[] = [
133 $this->lng->txt("unparticipate"),
134 $this->getLink(self::CMD_UNSUBSCRIBE),
135 false
136 ];
137 }
138
139 return $links;
140 }
141
142 public function getLaunchbuttonsComponent(): array
143 {
144 $buttons = [];
145 foreach ($this->getLinks() as $idx => $entry) {
146 list($label, $link, $primary) = $entry;
147 if ($primary) {
148 $buttons[] = $this->ui_factory->button()->primary($label, $link);
149 } else {
150 $buttons[] = $this->ui_factory->button()->standard($label, $link);
151 }
152 }
153 return $buttons;
154 }
155}
return true
Class ilAccessHandler Checks access for ILIAS objects.
Class ilCtrl provides processing control methods.
Builds the links to join/(re-)start the LearningSequence.
__construct(protected ilLanguage $lng, protected ilAccess $access, protected ilCtrl $ctrl, protected ILIAS\UI\Factory $ui_factory, protected int $lso_ref_id, protected int $usr_id, protected $first_access, protected ilLearningSequenceRoles $roles, protected ilLSLearnerItemsQueries $ls_items)
This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LS...
language handling
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31