diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2025-12-19 08:44:03 +0100 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2025-12-19 08:44:03 +0100 |
| commit | 1c78a3b0a73e72d34714fa749aff293dbda6b4d2 (patch) | |
| tree | a6638fb62ef5e672b0e326ebeb204e8f47afafeb /app | |
| parent | 4e8a808e1a3a0c6698afaacf50173051bcf1dcee (diff) | |
Resolve "Deeplinks und Definition von Kurz-URLs"
Closes #5896
Merge request studip/studip!4570
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/course/details.php | 10 | ||||
| -rw-r--r-- | app/controllers/course/enrolment.php | 29 | ||||
| -rw-r--r-- | app/controllers/course/overview.php | 2 | ||||
| -rw-r--r-- | app/controllers/short_urls.php | 33 | ||||
| -rw-r--r-- | app/controllers/u.php | 17 | ||||
| -rw-r--r-- | app/views/course/enrolment/apply.php | 3 |
6 files changed, 88 insertions, 6 deletions
diff --git a/app/controllers/course/details.php b/app/controllers/course/details.php index d8ac254..969c34d 100644 --- a/app/controllers/course/details.php +++ b/app/controllers/course/details.php @@ -223,16 +223,22 @@ class Course_DetailsController extends AuthenticatedController PageLayout::postInfo(_('Die Anmeldung ist verbindlich, Teilnehmende können sich nicht selbst austragen.')); } } + + $params = []; + if (Request::int('from_short_url')) { + $params['from_short_url'] = Request::int('from_short_url'); + } + $links->addLink( $abo_msg, - $this->url_for("course/enrolment/apply/{$this->course->id}"), + $this->url_for("course/enrolment/apply/{$this->course->id}", $params), Icon::create('door-enter'), ['data-dialog' => 'size=big'] ); $this->links[] = [ 'label' => $abo_msg, - 'url' => $this->url_for("course/enrolment/apply/{$this->course->id}"), + 'url' => $this->url_for("course/enrolment/apply/{$this->course->id}", $params), 'attributes' => ['data-dialog' => 'size=big'], ]; diff --git a/app/controllers/course/enrolment.php b/app/controllers/course/enrolment.php index b3c7ee3..49d547d 100644 --- a/app/controllers/course/enrolment.php +++ b/app/controllers/course/enrolment.php @@ -49,7 +49,17 @@ class Course_EnrolmentController extends AuthenticatedController || ($enrolment_info->getCodeword() === 'free_access' && !User::findCurrent()) ) ) { - $redirect_url = URLHelper::getUrl('dispatch.php/course/go', ['to' => $this->course_id]); + if (Request::int('from_short_url')) { + $link = ShortUrl::find(Request::int('from_short_url')); + if ($link) { + $redirect_url = URLHelper::getUrl($link->path); + } else { + $redirect_url = URLHelper::getUrl('dispatch.php/course/go', ['to' => $this->course_id]); + } + } else { + $redirect_url = URLHelper::getUrl('dispatch.php/course/go', ['to' => $this->course_id]); + } + if (Request::isXhr()) { $this->response->add_header('X-Location', $redirect_url); $this->render_nothing(); @@ -252,16 +262,29 @@ class Course_EnrolmentController extends AuthenticatedController if (!empty($course) && $course->admission_prelim) { $this->relocate(URLHelper::getLink('dispatch.php/course/details', ['sem_id' => $this->course_id])); } else { - $this->relocate(URLHelper::getLink('dispatch.php/course/go', ['to' => $this->course_id])); + if (Request::int('from_short_url')) { + $url = ShortUrl::find(Request::int('from_short_url')); + + if ($url) { + $this->relocate(URLHelper::getUrl($url->path)); + } + } else { + $this->relocate(URLHelper::getLink('dispatch.php/course/go', ['to' => $this->course->id])); + } } } elseif ($enrol_user) { + $params = ['apply' => 1]; + if (Request::int('from_short_url')) { + $params['from_short_url'] = Request::int('from_short_url'); + } + PageLayout::postQuestion( sprintf( _('Wollen Sie sich zu der Veranstaltung "%s" wirklich anmelden?'), htmlReady(Course::find($this->course_id)->name) ), - $this->action_url("apply/{$this->course_id}", ['apply' => 1]), + $this->action_url("apply/{$this->course_id}", $params), $this->action_url("apply/{$this->course_id}", ['decline' => 1]) ); diff --git a/app/controllers/course/overview.php b/app/controllers/course/overview.php index 4313cdc..fc0f441 100644 --- a/app/controllers/course/overview.php +++ b/app/controllers/course/overview.php @@ -109,7 +109,7 @@ class Course_OverviewController extends AuthenticatedController } $connections = StudygroupCourse::countBySql( - "`studygroup_id` = :cid OR `course_id` = :cid", + "`studygroup_id` = :cid OR `course_id` = :cid", [ 'cid' => $this->course_id ] diff --git a/app/controllers/short_urls.php b/app/controllers/short_urls.php new file mode 100644 index 0000000..e9fa843 --- /dev/null +++ b/app/controllers/short_urls.php @@ -0,0 +1,33 @@ +<?php + +use Studip\Forms\Form; + +class ShortUrlsController extends AuthenticatedController +{ + public function before_filter(&$action, &$args) + { + parent::before_filter($action, $args); + $this->current_user = User::findCurrent(); + } + + public function index_action(): void + { + PageLayout::setTitle(_('Meine Kurzlinks')); + Navigation::activateItem('/contents/short_urls/overview'); + + $this->render_vue_app( + Studip\VueApp::create('short-urls/ShortUrlList') + ->withStore('shortUrlsStore', 'useShortUrlsStore') + ); + } + + public function create_action(): void + { + PageLayout::setTitle(_('Link zur aktuellen Seite erstellen')); + + $this->render_vue_app( + Studip\VueApp::create('short-urls/ShortUrlLink') + ->withProps(['isInContext' => Context::isCourse() && Context::get()->hasCourseSet()]) + ); + } +} diff --git a/app/controllers/u.php b/app/controllers/u.php new file mode 100644 index 0000000..76cd35e --- /dev/null +++ b/app/controllers/u.php @@ -0,0 +1,17 @@ +<?php + +class UController extends AuthenticatedController +{ + public function r_action(string $short_url_alias): void + { + $short_url = ShortUrl::findOneBySQL('alias = ?', [$short_url_alias]); + + if (!$short_url) { + PageLayout::postError(_('Dieser Kurzlink existiert nicht.')); + $this->redirect($this->url_for('start')); + return; + } + + $this->redirect(URLHelper::getURL($short_url->path, ['from_short_url' => $short_url->id])); + } +} diff --git a/app/views/course/enrolment/apply.php b/app/views/course/enrolment/apply.php index 6e1f910..d890f8a 100644 --- a/app/views/course/enrolment/apply.php +++ b/app/views/course/enrolment/apply.php @@ -11,6 +11,9 @@ <? if ($admission_form): ?> <form name="apply_admission" action="<?= $controller->action_link("apply/{$course_id}") ?>" method="post"> <?= $admission_form ?> + <? if (Request::int('from_short_url')) : ?> + <input type="hidden" name="from_short_url" value="<?= Request::int('from_short_url') ?>"> + <? endif ?> <div data-dialog-button> <?= Studip\Button::createAccept(_('OK'), 'apply', ['data-dialog' => 'size=big']) ?> <?= Studip\Button::createCancel(_('Abbrechen'), 'cancel') ?> |
