ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
PermanentLinkManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
36 {
40 
41  public function __construct(
42  InternalDomainService $domain,
44  ) {
45  global $DIC;
47  $this->static_url = $DIC['static_url'];
48 
49  $this->domain = $domain;
50  $this->gui = $gui;
51  }
52 
53  /*
54  public function goto(
55  string $target,
56  string $raw
57  ): void {
58 
59  $main_tpl = $this->gui->ui()->mainTemplate();
60  $request = $this->gui->request();
61  $ass_id = $request->getAssId();
62 
63  $lng = $this->domain->lng();
64  $ilAccess = $this->domain->access();
65  $ilCtrl = $this->gui->ctrl();
66 
67  //we don't have baseClass here...
68  $ilCtrl->setTargetScript("ilias.php");
69 
70  //ilExerciseMailNotification has links to:
71  // "Assignments", "Submission and Grades" and Downnoad the NEW files if the assignment type is "File Upload".
72  $parts = explode("_", $raw);
73  $action = null;
74  $member = null;
75  if (!$ass_id) {
76  $ass_id = (int) ($parts[1] ?? 0);
77 
78  switch (end($parts)) {
79  case "download":
80  case "setdownload":
81  $action = $parts[3] ?? "";
82  $member = $parts[2];
83  break;
84 
85  case "given":
86  $action = $parts[3] ?? "";
87  $peer_id = (int) ($parts[2] ?? 0);
88  break;
89 
90  case "grades":
91  case "received":
92  $action = $parts[2] ?? "";
93  break;
94  }
95  }
96 
97  $ilCtrl->setParameterByClass(\ilExerciseHandlerGUI::class, "ref_id", $target);
98 
99  if ($ilAccess->checkAccess("read", "", (int) $target)) {
100  $ilCtrl->setParameterByClass(\ilExerciseHandlerGUI::class, "target", $raw);
101 
102  if ($ass_id > 0) {
103  $ilCtrl->setParameterByClass(\ilExerciseManagementGUI::class, "ass_id", $ass_id);
104  }
105 
106  switch ($action) {
107  case "grades":
108  $ilCtrl->redirectByClass(
109  [\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class, \ilExerciseManagementGUI::class],
110  "members"
111  );
112  break;
113 
114  case "setdownload":
115  $ilCtrl->setParameterByClass(\ilExerciseHandlerGUI::class, "member_id", $member);
116  $ilCtrl->redirectByClass(
117  array(\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class, \ilExerciseManagementGUI::class),
118  "waitingDownload"
119  );
120  break;
121 
122  case "given":
123  $ilCtrl->setParameterByClass(\ilObjExerciseGUI::class, "ass_id", $ass_id);
124  $ilCtrl->setParameterByClass(\ilObjExerciseGUI::class, "peer_id", $peer_id);
125  $ilCtrl->redirectByClass(
126  array(\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class, \ilAssignmentPresentationGUI::class,
127  \ilExSubmissionGUI::class, \ilExPeerReviewGUI::class),
128  "editPeerReviewItem"
129  );
130  break;
131 
132  case "received":
133  $ilCtrl->setParameterByClass(\ilObjExerciseGUI::class, "ass_id", $ass_id);
134  $ilCtrl->redirectByClass(
135  array(\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class, \ilAssignmentPresentationGUI::class,
136  \ilExSubmissionGUI::class, \ilExPeerReviewGUI::class),
137  "showReceivedPeerReview"
138  );
139  break;
140 
141  default:
142  if ($ass_id > 0) {
143  $ilCtrl->setParameterByClass(\ilObjExerciseGUI::class, "ass_id", $ass_id);
144  $ilCtrl->redirectByClass(
145  [\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class, \ilAssignmentPresentationGUI::class],
146  ""
147  );
148  }
149  $ilCtrl->redirectByClass(
150  [\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class],
151  "showOverview"
152  );
153  break;
154 
155  }
156  } elseif ($ilAccess->checkAccess("visible", "", (int) $target)) {
157  $ilCtrl->redirectByClass(
158  [\ilExerciseHandlerGUI::class, \ilObjExerciseGUI::class],
159  "infoScreen"
160  );
161  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
162  $main_tpl->setOnScreenMessage('failure', sprintf(
163  $lng->txt("msg_no_perm_read_item"),
164  \ilObject::_lookupTitle(\ilObject::_lookupObjId((int) $target))
165  ), true);
166  \ilObjectGUI::_gotoRepositoryRoot();
167  }
168  }*/
169 
170  protected function _setPermanentLink(array $append): void
171  {
172  $request = $this->gui->request();
173  $ref_id = $request->getRefId();
174  $uri = $this->static_url->builder()->build(
175  'exc', // namespace
176  $ref_id > 0 ? new ReferenceId($ref_id) : null, // ref_id
177  $append // additional parameters
178  );
179  PageContentProvider::setPermaLink((string) $uri);
180  }
181 
182  public function setPermanentLink(): void
183  {
184  $request = $this->gui->request();
185  $this->_setPermanentLink(
186  $this->getDefaultAppend(
187  $request->getAssId()
188  )
189  );
190  }
191 
192  public function getDefaultAppend(int $ass_id): array
193  {
194  $append = [];
195  if ($ass_id > 0) {
196  $append[] = $ass_id;
197  }
198  return $append;
199  }
200 
201  public function getPermanentLink(int $ref_id, int $ass_id): string
202  {
203  $append = $this->getDefaultAppend($ass_id);
204  return $this->_getPermanentLink($ref_id, $append);
205  }
206 
207  protected function _getPermanentLink(int $ref_id, array $append): string
208  {
209  $uri = $this->static_url->builder()->build(
210  'exc', // namespace
211  $ref_id > 0 ? new ReferenceId($ref_id) : null, // ref_id
212  $append // additional parameters
213  );
214 
215  return (string) $uri;
216  }
217 
218  public function getDownloadSubmissionLink(int $ref_id, int $ass_id, int $user_id): string
219  {
220  return $this->_getPermanentLink($ref_id, [$ass_id, $user_id, "setdownload"]);
221  }
222 
223  public function setGradesPermanentLink(): void
224  {
225  $request = $this->gui->request();
226  $this->_setPermanentLink(
227  $this->getGradesAppend(
228  $request->getAssId()
229  )
230  );
231  }
232 
233  public function getGradesLink(int $ref_id, int $ass_id): string
234  {
235  return $this->_getPermanentLink($ref_id, [$ass_id, "grades"]);
236  }
237 
238  public function getGradesAppend(int $ass_id): array
239  {
240  return [$ass_id, "grades"];
241  }
242 
243  public function setGivenFeedbackPermanentLink(): void
244  {
245  $request = $this->gui->request();
246  $this->_setPermanentLink(
247  $this->getGivenFeedbackAppend(
248  $request->getAssId(),
249  $request->getPeerId()
250  )
251  );
252  }
253 
254  public function getGivenFeedbackLink(int $ref_id, int $ass_id, int $peer_id): string
255  {
256  return $this->_getPermanentLink($ref_id, [$ass_id, $peer_id, "given"]);
257  }
258 
259  public function getGivenFeedbackAppend(int $ass_id, int $peer_id): array
260  {
261  return [$ass_id, $peer_id, "given"];
262  }
263 
264  public function setReceivedFeedbackPermanentLink(): void
265  {
266  $request = $this->gui->request();
267  $this->_setPermanentLink(
269  $request->getAssId()
270  )
271  );
272  }
273 
274  public function getReceivedFeedbackLink(int $ref_id, int $ass_id): string
275  {
276  return $this->_getPermanentLink($ref_id, [$ass_id, "received"]);
277  }
278 
279  public function getReceivedFeedbackAppend(int $ass_id): array
280  {
281  return [$ass_id, "received"];
282  }
283 
284  public function getOpenSubmissionsLink(int $ref_id, int $ass_id, int $user_id): string
285  {
286  return $this->_getPermanentLink($ref_id, [$ass_id, $user_id, "opensubmission"]);
287  }
288 
289 }
Exercise UI frontend presentation service class.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
global $DIC
Definition: shib_login.php:22
static setPermaLink(string $perma_link)