diff --git a/app/controllers/siteinfo.php b/app/controllers/siteinfo.php index f43826ba4e62503c1058ff584409a7e54ef2ce62..ab81660bf2541baec0ef3aac696a5b57f0f6bdb1 100644 --- a/app/controllers/siteinfo.php +++ b/app/controllers/siteinfo.php @@ -12,6 +12,9 @@ class SiteinfoController extends StudipController { protected $with_session = true; + /** + * @var Siteinfo + */ private $si; /** @@ -25,13 +28,19 @@ class SiteinfoController extends StudipController $this->si = new Siteinfo(); $this->populate_ids($args); - $this->add_navigation($action); + $detail = $this->si->get_detail($this->currentdetail); + $this->page_is_draft = $detail['draft_status'] ?? false; + $this->page_disabled_nobody = $detail['page_disabled_nobody'] ?? false; if (is_object($GLOBALS['perm']) && $GLOBALS['perm']->have_perm('root')) { $this->setupSidebar(); } else { $action = 'show'; + if ($this->page_is_draft || ($this->page_disabled_nobody && $GLOBALS['user']->id === 'nobody')) { + throw new Trails_Exception(404); + } } + $this->add_navigation($action); PageLayout::setTitle(_('Impressum')); PageLayout::setTabNavigation('/footer/siteinfo'); @@ -47,11 +56,11 @@ class SiteinfoController extends StudipController if (isset($args[1]) && is_numeric($args[1])) { $this->currentdetail = $args[1]; } else { - $this->currentdetail = $this->si->first_detail_id($args[0]); + $this->currentdetail = $this->si->first_detail_id($args[0], !$GLOBALS['perm']->have_perm('root'), $GLOBALS['user']->id === 'nobody'); } } else { $this->currentrubric = $this->si->first_rubric_id(); - $this->currentdetail = $this->si->first_detail_id(); + $this->currentdetail = $this->si->first_detail_id(null, !$GLOBALS['perm']->have_perm('root'), $GLOBALS['user']->id === 'nobody'); } } @@ -67,20 +76,16 @@ class SiteinfoController extends StudipController } foreach ($this->si->get_all_details() as $detail) { - $detail[2] = language_filter($detail[2]); - if ($detail[2] == '') { - $detail[2] = _('unbenannt'); + if ((!$GLOBALS['perm']->have_perm('root') && $detail['draft_status']) + || ($detail['page_disabled_nobody'] && $GLOBALS['user']->id === 'nobody')) { + continue; } - - // check draft status and possibly hide site in navigation - if ($detail[3] == 1 && $GLOBALS['perm']->have_perm('root')) { - - Navigation::addItem('/footer/siteinfo/'.$detail[1].'/'.$detail[0], - new Navigation($detail[2], $this->url_for('siteinfo/show/'.$detail[1].'/'.$detail[0]))); - } else if ($detail[3] != 1) { - Navigation::addItem('/footer/siteinfo/'.$detail[1].'/'.$detail[0], - new Navigation($detail[2], $this->url_for('siteinfo/show/'.$detail[1].'/'.$detail[0]))); + $detail['name'] = language_filter($detail['name']); + if ($detail['name'] == '') { + $detail['name'] = _('unbenannt'); } + Navigation::addItem('/footer/siteinfo/'.$detail['rubric_id'].'/'.$detail['detail_id'], + new Navigation($detail['name'], $this->url_for('siteinfo/show/'.$detail['rubric_id'].'/'.$detail['detail_id']))); } if ($action != 'new') { @@ -96,7 +101,7 @@ class SiteinfoController extends StudipController { $sidebar = Sidebar::get(); - if (empty($GLOBALS['rubrics_empty'])) { + if (count($this->si->get_all_rubrics())) { $actions = new ActionsWidget(); $actions->setTitle(_('Seiten-Aktionen')); @@ -140,11 +145,15 @@ class SiteinfoController extends StudipController throw new AccessDeniedException(); } $this->output = $this->si->get_detail_content_processed($this->currentdetail); + if ($this->page_is_draft) { + PageLayout::postInfo(_('Diese Seite befindet sich im Entwurfsmodus und ist daher noch unsichtbar.')); + } } public function new_action($givenrubric = null) { - $this->edit_rubric = false; + $GLOBALS['perm']->check('root'); + $this->edit_rubric = null; if ($givenrubric === null) { Navigation::addItem('/footer/siteinfo/rubric_new', new AutoNavigation(_('Neue Rubrik'), @@ -160,48 +169,70 @@ class SiteinfoController extends StudipController public function edit_action($givenrubric = null, $givendetail = null) { - $this->edit_rubric = false; + $GLOBALS['perm']->check('root'); + $this->edit_rubric = null; if (is_numeric($givendetail)) { - $this->rubrics = $this->si->get_all_rubrics(); - $this->rubric_id = $this->si->rubric_for_detail($this->currentdetail); - $this->detail_name = $this->si->get_detail_name($this->currentdetail); - $this->content = $this->si->get_detail_content($this->currentdetail); - $this->draft_status = $this->si->get_detail_draft_status($this->currentdetail); + $this->rubrics = $this->si->get_all_rubrics(); + $detail = $this->si->get_detail($this->currentdetail); + $this->rubric_id = $detail['rubric_id']; + $this->detail_name = $detail['name']; + $this->content = $detail['content']; + $this->draft_status = $detail['draft_status']; + $this->page_disabled_nobody = $detail['page_disabled_nobody']; + $this->page_position = $detail['position']; } else { $this->edit_rubric = true; $this->rubric_id = $this->currentrubric; - } - $this->rubric_name = $this->si->rubric_name($this->currentrubric); + } + $rubric = $this->si->rubric($this->currentrubric); + $this->rubric_name = $rubric['name']; + $this->rubric_position = $rubric['position']; } public function save_action() { - $detail_name = Request::get('detail_name'); - $rubric_name = Request::get('rubric_name'); - $content = Request::get('content'); - $rubric_id = Request::int('rubric_id'); - $detail_id = Request::int('detail_id'); - $draft_status = Request::get('draft_status'); + + $GLOBALS['perm']->check('root'); + + CSRFProtection::verifyUnsafeRequest(); + $detail_name = Request::get('detail_name'); + $rubric_name = Request::get('rubric_name'); + $content = Request::get('content'); + $rubric_id = Request::int('rubric_id'); + $detail_id = Request::int('detail_id'); + $draft_status = Request::submitted('draft_status'); + $page_disabled_nobody = Request::submitted('page_disabled_nobody'); + $page_position = Request::int('page_position'); + $rubric_position = Request::int('rubric_position'); if ($rubric_id) { if ($detail_id) { - list($rubric, $detail) = $this->si->save('update_detail', compact('rubric_id', 'detail_name', 'content', 'detail_id', 'draft_status')); + list($rubric, $detail) = $this->si->save('update_detail', compact('rubric_id', 'detail_name', 'content', 'detail_id', 'draft_status', 'page_disabled_nobody', 'page_position')); } else { - if ($content) { - list($rubric, $detail) = $this->si->save('insert_detail', compact('rubric_id', 'detail_name','content', 'draft_status')); + if (isset($content)) { + if (!$page_position) { + $page_position = $this->si->get_detail_max_position($rubric_id) + 1; + } + list($rubric, $detail) = $this->si->save('insert_detail', compact('rubric_id', 'detail_name','content', 'draft_status', 'page_disabled_nobody', 'page_position')); } else { - list($rubric, $detail) = $this->si->save('update_rubric', compact('rubric_id', 'rubric_name')); + list($rubric, $detail) = $this->si->save('update_rubric', compact('rubric_id', 'rubric_name', 'rubric_position')); } } } else { - list($rubric, $detail) = $this->si->save('insert_rubric', compact('rubric_name')); + if (!$rubric_position) { + $rubric_position = $this->si->get_rubric_max_position() + 1; + } + list($rubric, $detail) = $this->si->save('insert_rubric', compact('rubric_name', 'rubric_position')); } $this->redirect('siteinfo/show/' . $rubric . '/' . $detail); } public function delete_action($givenrubric = null, $givendetail = null, $execute = false) { + $GLOBALS['perm']->check('root'); + if ($execute) { + CSRFProtection::verifyUnsafeRequest(); if ($givendetail === 'all') { $this->si->delete('rubric', $this->currentrubric); $this->redirect('siteinfo/show/'); diff --git a/app/views/siteinfo/delete.php b/app/views/siteinfo/delete.php index ea8d94c23a6123657965ecc97d1d37983fb3004c..f538b7eb9204661c0e2371425bee016f938d8195 100644 --- a/app/views/siteinfo/delete.php +++ b/app/views/siteinfo/delete.php @@ -4,9 +4,9 @@ use Studip\Button, Studip\LinkButton; ?> <div class="white" style="padding: 1ex;"> - <? if (!$execute): ?> + <? if (empty($execute)): ?> <div style="text-align: center;padding: 10px;"> - <? if ($detail) :?> + <? if (!empty($detail)) :?> <p><?= _("Wollen Sie die Seite wirklich löschen?") ?></p> <? else : ?> <p><?= _("Wollen Sie die Rubrik mit allen Seiten wirklich löschen?") ?></p> @@ -17,8 +17,11 @@ use Studip\Button, Studip\LinkButton; $abort_url = 'siteinfo/show/'.$currentrubric; $abort_url .= $detail ? "/".$currentdetail : ''; ?> - <?= LinkButton::create(_('Löschen'), $controller->url_for($delete_url)) ?> - <?= LinkButton::createCancel(_('Abbrechen'), $controller->url_for($abort_url)) ?> + <form method="POST" action="<?=$controller->link_for($delete_url)?>"> + <?=CSRFProtection::tokenTag() ?> + <?= Button::create(_('Löschen')) ?> + <?= LinkButton::createCancel(_('Abbrechen'), $controller->url_for($abort_url)) ?> + </form> </div> <div> <hr> diff --git a/app/views/siteinfo/edit.php b/app/views/siteinfo/edit.php index c4a6c5d170610c18fac2cdd90cd998f2f65c4115..7011718c8e8b9fe187796955b0543c250e345978 100644 --- a/app/views/siteinfo/edit.php +++ b/app/views/siteinfo/edit.php @@ -7,19 +7,23 @@ use Studip\Button, Studip\LinkButton; <?= CSRFProtection::tokenTag() ?> <fieldset> <legend> - <? if ($edit_rubric): ?> + <? if(isset($edit_rubric)): ?> <?= _('Rubrik bearbeiten') ?> <? else : ?> <?= _('Seite bearbeiten') ?> <? endif ?> </legend> - <? if ($edit_rubric): ?> + <? if(isset($edit_rubric)): ?> <input type="hidden" name="rubric_id" value="<?= htmlReady($rubric_id) ?>"> <label> <?= _('Titel der Rubrik')?> <input type="text" name="rubric_name" id="rubric_name" value="<?= htmlReady($rubric_name) ?>"> </label> + <label> + <?= _('Position der Rubrik') ?> + <input type="number" name="rubric_position" id="rubric_position" value="<?= (int)$rubric_position ?>"> + </label> <? else: ?> <label> <?= _('Rubrik-Zuordnung')?> @@ -38,10 +42,20 @@ use Studip\Button, Studip\LinkButton; </label> <label> - <input type="checkbox" name="draft_status" id="draft_status" value="1" <?= $draft_status ? 'checked' : ''?>> + <input type="checkbox" name="draft_status" id="draft_status" <?= $draft_status ? 'checked' : ''?>> <?= _('Entwurfsmodus (nur sichtbar für root)') ?> </label> + <label> + <input type="checkbox" name="page_disabled_nobody" id="page_disabled_nobody" <?= $page_disabled_nobody ? 'checked' : ''?>> + <?= _('Seite nicht anzeigen für nicht angemeldete Benutzer') ?> + </label> + + <label> + <?= _('Position der Seite') ?> + <input type="number" name="page_position" id="page_position" value="<?= (int)$page_position ?>"> + </label> + <label> <?= _('Seiteninhalt')?> <textarea style="height: 15em;" name="content" id="content" class="size-l wysiwyg"><?= wysiwygReady($content) ?></textarea> @@ -57,6 +71,6 @@ use Studip\Button, Studip\LinkButton; </footer> </form> - <? if (!$edit_rubric): ?> +<? if(!isset($edit_rubric)): ?> <?= $this->render_partial('siteinfo/help.php') ?> <? endif; ?> diff --git a/app/views/siteinfo/new.php b/app/views/siteinfo/new.php index a2389f8dd272e5fc2f638a28d94dcd5b8a70ef15..766279927c1aabcd24e3055e1d06f3312a918215 100644 --- a/app/views/siteinfo/new.php +++ b/app/views/siteinfo/new.php @@ -11,18 +11,22 @@ use Studip\Button, Studip\LinkButton; <fieldset> <legend> - <? if($edit_rubric): ?> + <? if(isset($edit_rubric)): ?> <?= _('Neue Rubrik anlegen') ?> <? else : ?> <?= _('Neue Seite anlegen') ?> <? endif ?> </legend> - <? if($edit_rubric): ?> + <? if(isset($edit_rubric)): ?> <label> <?= _('Titel der Rubrik') ?> <input type="text" name="rubric_name" id="rubric_name"> </label> + <label> + <?= _('Position der Rubrik') ?> + <input type="number" name="rubric_position" id="rubric_position"> + </label> <? else: ?> <label> <?= _('Rubrik-Zuordnung') ?> @@ -39,13 +43,23 @@ use Studip\Button, Studip\LinkButton; </label> <label> - <input type="checkbox" name="draft_status" id="draft_status" value="1" <?= $draft_status ? 'checked' : ''?>> + <input type="checkbox" name="draft_status" id="draft_status" checked> <?= _('Entwurfsmodus (nur sichtbar für root)') ?> </label> + <label> + <input type="checkbox" name="page_disabled_nobody" id="page_disabled_nobody"> + <?= _('Seite nicht anzeigen für nicht angemeldete Benutzer') ?> + </label> + + <label> + <?= _('Position der Seite') ?> + <input type="number" name="page_position" id="page_position"> + </label> + <label> <?= _('Seiteninhalt') ?> - <textarea style="width: 90%;height: 15em;" name="content" id="content"></textarea><br> + <textarea style="width: 90%;height: 15em;" class="add_toolbar size-l wysiwyg" name="content" id="content"></textarea><br> </label> <? endif ?> </fieldset> @@ -56,6 +70,6 @@ use Studip\Button, Studip\LinkButton; </footer> </form> -<? if(!$edit_rubric): ?> +<? if(!isset($edit_rubric)): ?> <?= $this->render_partial('siteinfo/help') ?> <? endif ?> diff --git a/db/migrations/5.5.13_add_siteinfo_options.php b/db/migrations/5.5.13_add_siteinfo_options.php new file mode 100644 index 0000000000000000000000000000000000000000..46f7db10f9fecac16ae5d03f28e2c3fdc6d76438 --- /dev/null +++ b/db/migrations/5.5.13_add_siteinfo_options.php @@ -0,0 +1,38 @@ +<?php +final class AddSiteinfoOptions extends Migration +{ + public function description() + { + return 'adds options for siteinfo pages'; + } + + public function up() + { + $db = DBManager::get(); + $db->exec(" + ALTER TABLE `siteinfo_details` + ADD `page_disabled_nobody` TINYINT NOT NULL DEFAULT '0' AFTER `draft_status` + "); + $position = 1; + foreach($db->fetchFirst("SELECT rubric_id + FROM siteinfo_rubrics + ORDER BY position, rubric_id ASC") as $rubric_id) { + $db->execute("UPDATE siteinfo_rubrics SET position=? WHERE rubric_id=?", [$position++, $rubric_id]); + $page_position = 1; + foreach($db->fetchFirst("SELECT detail_id + FROM siteinfo_details + WHERE rubric_id = ? + ORDER BY position, detail_id ASC", [$rubric_id]) as $detail_id) { + $db->execute("UPDATE siteinfo_details SET position=? WHERE detail_id=?", [$page_position++, $detail_id]); + } + } + } + + public function down() + { + DBManager::get()->exec(" + ALTER TABLE `siteinfo_details` + DROP `page_disabled_nobody` + "); + } +} diff --git a/db/migrations/5.5.2_add_siteinfo_draft_field.php b/db/migrations/5.5.2_add_siteinfo_draft_field.php index 6437c00a05b6b8b6b8a7f4d1212e908e402742aa..7071e82234b012ce9c2337f68f2fa58a2cab139f 100644 --- a/db/migrations/5.5.2_add_siteinfo_draft_field.php +++ b/db/migrations/5.5.2_add_siteinfo_draft_field.php @@ -9,7 +9,7 @@ class AddSiteinfoDraftField extends Migration { public function up() { - DBManager::get()->exec("ALTER TABLE `siteinfo_details` ADD `draft_status` TINYINT(1) AFTER `position`"); + DBManager::get()->exec("ALTER TABLE `siteinfo_details` ADD `draft_status` TINYINT NOT NULL DEFAULT '0' AFTER `position`"); } public function down() diff --git a/lib/classes/Siteinfo.php b/lib/classes/Siteinfo.php index 73e811f8c14ae28b822f3e7908b77db5853588a5..4722b93a6a0bf1a73ea9e7f2c770b763c0cb727d 100644 --- a/lib/classes/Siteinfo.php +++ b/lib/classes/Siteinfo.php @@ -49,6 +49,7 @@ class Siteinfo { } } + public function get_detail_draft_status($id) { $sql = "SELECT draft_status FROM siteinfo_details @@ -59,14 +60,14 @@ class Siteinfo { return $statement->fetchColumn(); } - function get_detail_name($id) { - $sql = "SELECT name + function get_detail($id) { + $sql = "SELECT * FROM siteinfo_details WHERE detail_id = :id"; $statement = DBManager::get()->prepare($sql); $statement->bindValue(':id', $id, PDO::PARAM_INT); $statement->execute(); - return $statement->fetchColumn(); + return $statement->fetch(PDO::FETCH_ASSOC); } function get_detail_content_processed($id) { @@ -76,18 +77,25 @@ class Siteinfo { } function get_all_details() { - $sql = "SELECT detail_id, rubric_id, name, draft_status + $sql = "SELECT * FROM siteinfo_details ORDER BY position, detail_id ASC"; $result = $this->db->query($sql); return $result->fetchAll(); } - function first_detail_id($rubric = NULL) { + function first_detail_id($rubric = null, $nodraft = null, $nobody = null) { $rubric_id = $rubric ?: $this->first_rubric_id(); $sql = "SELECT detail_id FROM siteinfo_details - WHERE rubric_id = IFNULL(?, rubric_id) + WHERE rubric_id = IFNULL(?, rubric_id)"; + if ($nodraft) { + $sql .= " AND draft_status = 0 "; + } + if ($nobody) { + $sql .= " AND page_disabled_nobody = 0 "; + } + $sql .= " ORDER BY position, detail_id ASC LIMIT 1"; $statement = DBManager::get()->prepare($sql); @@ -98,7 +106,7 @@ class Siteinfo { } function get_all_rubrics() { - $sql = "SELECT rubric_id, name + $sql = "SELECT rubric_id, name, position FROM siteinfo_rubrics ORDER BY position, rubric_id ASC"; $result = $this->db->query($sql); @@ -130,24 +138,37 @@ class Siteinfo { return $statement->fetchColumn(); } - function rubric_name($id) { - $sql = "SELECT name + function rubric($id) { + $sql = "SELECT * FROM siteinfo_rubrics WHERE rubric_id = :id"; $statement = DBManager::get()->prepare($sql); $statement->bindValue(':id', $id, PDO::PARAM_INT); $statement->execute(); - return $statement->fetchColumn(); + return $statement->fetch(PDO::FETCH_ASSOC); + } + + function get_rubric_max_position() + { + return DBManager::get()->fetchColumn("SELECT MAX(position) FROM siteinfo_rubrics"); + } + + function get_detail_max_position($rubric_id) + { + return DBManager::get()->fetchColumn("SELECT MAX(position) FROM siteinfo_details WHERE rubric_id=?", [$rubric_id]); } function save($type, $input) { //distinguish the subject and the action (modification/insertion) $rubric = ''; $detail = ''; + switch ($type) { case 'update_detail': + $old_detail = $this->get_detail($input['detail_id']); $query = "UPDATE siteinfo_details - SET rubric_id = :rubric_id, name = :name, content = :content, draft_status = :draft_status + SET rubric_id = :rubric_id, name = :name, content = :content, + draft_status = :draft_status, position = :position, page_disabled_nobody = :page_disabled_nobody WHERE detail_id = :detail_id"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':rubric_id', $input['rubric_id'], PDO::PARAM_INT); @@ -155,44 +176,55 @@ class Siteinfo { $statement->bindValue(':content', $input['content']); $statement->bindValue(':detail_id', $input['detail_id'], PDO::PARAM_INT); $statement->bindValue(':draft_status', $input['draft_status']); + $statement->bindValue(':position', $input['page_position'], PDO::PARAM_INT); + $statement->bindValue(':page_disabled_nobody', $input['page_disabled_nobody'], PDO::PARAM_BOOL); + $statement->execute(); + $this->renumber_details($input['rubric_id'], $input['detail_id'], $old_detail['position'] <=> $input['page_position']); $rubric = $input['rubric_id']; $detail = $input['detail_id']; break; case 'insert_detail': - $query = "INSERT INTO siteinfo_details (rubric_id, name, content, draft_status) - VALUES (:rubric_id, :name, :content, :draft_status)"; + $query = "INSERT INTO siteinfo_details (rubric_id, name, content, draft_status, position, page_disabled_nobody ) + VALUES (:rubric_id, :name, :content, :draft_status, :position, :page_disabled_nobody)"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':rubric_id', $input['rubric_id'], PDO::PARAM_INT); $statement->bindValue(':name', $input['detail_name']); $statement->bindValue(':content', $input['content']); $statement->bindValue(':draft_status', $input['draft_status']); + $statement->bindValue(':position', $input['page_position'], PDO::PARAM_INT); + $statement->bindValue(':page_disabled_nobody', $input['page_disabled_nobody'], PDO::PARAM_INT); $statement->execute(); + $detail = DBManager::get()->lastInsertId(); + $this->renumber_details($input['rubric_id'], $detail, 1); $rubric = $input['rubric_id']; - $detail = DBManager::get()->lastInsertId(); break; case "update_rubric": + $old_rubric = $this->rubric($input['rubric_id']); $query = "UPDATE siteinfo_rubrics - SET name = :name + SET name = :name, position = :position WHERE rubric_id = :id"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':name', $input['rubric_name']); $statement->bindValue(':id', $input['rubric_id'], PDO::PARAM_INT); + $statement->bindValue(':position', $input['rubric_position'], PDO::PARAM_INT); $statement->execute(); + $this->renumber_rubrics($input['rubric_id'], $old_rubric['position'] <=> $input['rubric_position']); $rubric = $input['rubric_id']; $detail = $this->first_detail_id($rubric); break; case "insert_rubric": - $query = "INSERT INTO siteinfo_rubrics (name) - VALUES (:name)"; + $query = "INSERT INTO siteinfo_rubrics (name, position) + VALUES (:name, :position)"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':name', $input['rubric_name']); + $statement->bindValue(':position', $input['rubric_position'], PDO::PARAM_INT); $statement->execute(); - $rubric = DBManager::get()->lastInsertId(); + $this->renumber_rubrics($rubric, 1); $detail = 0; } return [$rubric, $detail]; @@ -214,6 +246,29 @@ class Siteinfo { $statement->execute([$id]); } } + + public function renumber_rubrics($changed = 0, $direction = 0) + { + $db = DBManager::get(); + $position = 1; + foreach($db->fetchFirst("SELECT rubric_id + FROM siteinfo_rubrics + ORDER BY position, rubric_id=" . (int)$changed . ($direction > 0 ? ' desc' : ' asc')) as $rubric_id) { + $db->execute("UPDATE siteinfo_rubrics SET position=? WHERE rubric_id=?", [$position++, $rubric_id]); + } + } + + public function renumber_details($rubric_id, $changed = 0, $direction = 0) + { + $db = DBManager::get(); + $page_position = 1; + foreach($db->fetchFirst("SELECT detail_id + FROM siteinfo_details + WHERE rubric_id = ? + ORDER BY position, detail_id=" . (int)$changed . ($direction > 0 ? ' desc' : ' asc'), [$rubric_id]) as $detail_id) { + $db->execute("UPDATE siteinfo_details SET position=? WHERE detail_id=?", [$page_position++, $detail_id]); + } + } } class SiteinfoMarkupEngine { diff --git a/lib/navigation/FooterNavigation.php b/lib/navigation/FooterNavigation.php index 462c83a35c48d46d391b0d960cbd92ab62a27c2f..92a9ac8a2767083037f04786f2c4aa4040251cf6 100644 --- a/lib/navigation/FooterNavigation.php +++ b/lib/navigation/FooterNavigation.php @@ -99,13 +99,10 @@ class FooterNavigation extends Navigation $url_parts = explode('/', $url); $detail_id = $url_parts[4]; $si = new Siteinfo(); - try { - $isdraft = $si->get_detail_draft_status($detail_id); - if ($isdraft) { - return ''; - } - } catch (PDOException $e) {} - + $detail = $si->get_detail($detail_id); + if (empty($detail) || !empty($detail['draft_status']) || (!empty($detail['page_disabled_nobody']) && $GLOBALS['user']->id === 'nobody')) { + return ''; + } } return $url; }