aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFinn Schneider <schneider@data-quest.de>2025-11-27 09:46:32 +0000
committerMurtaza Sultani <sultani@data-quest.de>2025-11-27 10:46:32 +0100
commit1ad670b6663ff7ada3605fd271ee4f9362ab10b5 (patch)
tree84fb595bd48ad9d551121af6055b6f6c409a4521 /app
parentf5539ca0dace099b495b0b03fb50de16a0a73930 (diff)
Resolve "Wiki-Startseite-Umbau"
Closes #5946 Merge request studip/studip!4614
Diffstat (limited to 'app')
-rw-r--r--app/controllers/course/wiki.php139
-rw-r--r--app/views/course/wiki/page.php2
2 files changed, 71 insertions, 70 deletions
diff --git a/app/controllers/course/wiki.php b/app/controllers/course/wiki.php
index 5baa933..6620be1 100644
--- a/app/controllers/course/wiki.php
+++ b/app/controllers/course/wiki.php
@@ -84,7 +84,7 @@ class Course_WikiController extends AuthenticatedController
_('Neue Wiki-Seite anlegen'),
$this->new_pageURL($this->page->id),
Icon::create('add'),
- ['data-dialog' => 'width=700']
+ $this->range->getConfiguration()->WIKI_STARTPAGE_ID ? ['data-dialog' => 'width=700'] : []
);
if ($GLOBALS['perm']->have_studip_perm('tutor', $this->range->id)) {
$actions->addLink(
@@ -255,7 +255,7 @@ class Course_WikiController extends AuthenticatedController
],
'parent_id' => [
'label' => _('Übergeordnete Seite im Inhaltsverzeichnis'),
- 'type' => 'select',
+ 'type' => $this->range->getConfiguration()->WIKI_STARTPAGE_ID == $page->getId() ? 'no' : 'select',
'options' => $options
],
'read_permission' => [
@@ -538,8 +538,14 @@ class Course_WikiController extends AuthenticatedController
throw new AccessDeniedException();
}
CSRFProtection::verifyUnsafeRequest();
+
+ $start_page_id = Request::option('wiki_startpage_id');
+
$this->config = $this->range->getConfiguration();
- $this->config->store('WIKI_STARTPAGE_ID', trim(Request::option('wiki_startpage_id')));
+ $this->config->store('WIKI_STARTPAGE_ID', $start_page_id);
+ $page = WikiPage::find($start_page_id);
+ $page->parent_id = null;
+ $page->store();
if (
$this->config->WIKI_CREATE_PERMISSION === 'all'
|| $GLOBALS['perm']->have_studip_perm($this->config->WIKI_CREATE_PERMISSION, Context::getId())
@@ -1005,69 +1011,65 @@ class Course_WikiController extends AuthenticatedController
'range_id = ? ORDER BY name',
[$this->range->id]
);
- $is_start_page = count($options) <= 1;
- if ($is_start_page) {
- PageLayout::setTitle(_('Wiki-Startseite erstellen'));
+ if (!$this->range->getConfiguration()->WIKI_STARTPAGE_ID) {
+ $page->user_id = User::findCurrent()->getId();
+ $page->name = _('Wiki-Startseite');
+ $page->parent_id = null;
+ $page->range_id = Context::getId();
+ $page->store();
+ $this->range->getConfiguration()->store('WIKI_STARTPAGE_ID', $page->id);
+ $this->redirect($this->editURL($page));
} else {
PageLayout::setTitle(_('Neue Wikiseite erstellen'));
- }
- $this->form = \Studip\Forms\Form::fromSORM(
- $page,
- [
- 'legend' => _('Daten'),
- 'fields' => [
- 'range_id' => [
- 'type' => 'no',
- 'mapper' => function () { return $this->range->id; }
- ],
- 'user_id' => [
- 'type' => 'no',
- 'mapper' => function () { return User::findCurrent()->id; }
- ],
- 'name' => [
- 'required' => !$is_start_page,
- 'label' => _('Name der Seite'),
- 'type' => $is_start_page ? 'no' : 'text',
- 'mapper' => function ($value) use ($is_start_page) {
- return $is_start_page ? 'Wiki-Startseite' : $value;
- },
- 'validate' => function ($value, $input) {
- $name_count = WikiPage::countBySql('`name` = :name AND `range_id` = :range_id', [
- 'name' => $value,
- 'range_id' => $this->range->id
- ]);
- if ($name_count === 0) {
+ $this->form = \Studip\Forms\Form::fromSORM(
+ $page,
+ [
+ 'legend' => _('Daten'),
+ 'fields' => [
+ 'range_id' => [
+ 'type' => 'no',
+ 'mapper' => function () {
+ return $this->range->id;
+ }
+ ],
+ 'user_id' => [
+ 'type' => 'no',
+ 'mapper' => fn() => User::findCurrent()->id,
+ ],
+ 'name' => [
+ 'required' => true,
+ 'label' => _('Name der Seite'),
+ 'type' => 'text',
+ 'validate' => function ($value, $input) {
+ $name_count = WikiPage::countBySql(
+ '`name` = :name AND `range_id` = :range_id',
+ [
+ 'name' => $value,
+ 'range_id' => $this->range->id
+ ]
+ );
+
+ if ($name_count > 0) {
+ return _('Name existiert schon.');
+ }
+
return true;
- } else {
- return _('Name existiert schon.');
}
- }
- ],
- 'parent_id' => [
- 'label' => _('Übergeordnete Seite im Inhaltsverzeichnis'),
- 'type' => 'select',
- 'options' => $options
- ],
- 'autocreate_links' => [
- 'label' => _('Den Seitennamen der neuen Seite automatisch in anderen Wikiseiten verlinken.'),
- 'type' => 'checkbox',
- 'permission' => WikiPage::countBySql("`range_id` = ?", [$this->range->id]) > 0
- ]
- ]
- ],
- $this->allpagesURL()
- )->addStoreCallback(function ($form, $values) {
- $page = $form->getLastPart()->getContextObject();
- $other_pages = WikiPage::countBySQL(
- "`range_id` = :range_id AND `page_id` != :page_id",
- [
- 'page_id' => $page->id,
- 'range_id' => $page->range_id,
+ ],
+ 'parent_id' => [
+ 'label' => _('Übergeordnete Seite im Inhaltsverzeichnis'),
+ 'type' => 'select',
+ 'options' => $options
+ ],
+ 'autocreate_links' => [
+ 'label' => _('Den Seitennamen der neuen Seite automatisch in anderen Wikiseiten verlinken.'),
+ 'type' => 'checkbox',
+ 'permission' => WikiPage::countByRange_id($this->range->id) > 0
+ ]
]
- );
- if ($other_pages == 0) {
- $this->range->getConfiguration()->store('WIKI_STARTPAGE_ID', $page->id);
- }
+ ],
+ $this->allpagesURL()
+ )->addStoreCallback(function ($form, $values) {
if (Request::bool('autocreate_links')) {
$pages = WikiPage::findBySQL(
"`range_id` = :range_id AND `content` LIKE :search",
@@ -1091,13 +1093,14 @@ class Course_WikiController extends AuthenticatedController
}
}
}
- )->setURL($this->new_pageURL($parent_id))
- ->validate();
- if (Request::isPost()) {
- $this->form->store();
- $this->redirect($this->editURL($page));
- } else {
- $this->render_form($this->form);
+ )->setURL($this->new_pageURL($parent_id))
+ ->validate();
+ if (Request::isPost()) {
+ $this->form->store();
+ $this->redirect($this->editURL($page));
+ } else {
+ $this->render_form($this->form);
+ }
}
}
diff --git a/app/views/course/wiki/page.php b/app/views/course/wiki/page.php
index eec58cb..856dc36 100644
--- a/app/views/course/wiki/page.php
+++ b/app/views/course/wiki/page.php
@@ -22,7 +22,6 @@
<div class="wiki-empty-background"></div>
<? else : ?>
<a href="<?= $controller->new_page() ?>"
- data-dialog
class="wiki-empty-background"
title="<?= _('Dieses Wiki ist noch leer. Erstellen Sie die erste Wiki-Seite.') ?>"></a>
<? endif ?>
@@ -31,7 +30,6 @@
<div class="wiki-teaser">
<? else : ?>
<a href="<?= $controller->new_page() ?>"
- data-dialog
class="wiki-teaser">
<? endif ?>
<?= _('Erstelle die erste Wiki-Seite') ?>