From 89370704762a0c9b76c3ad9d69ef0a737229e351 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 21 Apr 2017 18:23:11 +0200 Subject: [dozmod] Make images pending deletion an extra section --- modules-available/dozmod/page.inc.php | 61 +++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'modules-available/dozmod') diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 7f1e6ee3..9635aef1 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -32,7 +32,25 @@ class Page_DozMod extends Page Util::redirect('?do=Main'); } + /* execute actions */ + $action = Request::post('action', false, 'string'); + + if ($action === 'mail') { + $this->mailHandler(); + } elseif ($action === 'runtime') { + $this->runtimeHandler(); + } elseif ($action === 'delimages') { + $result = $this->handleDeleteImages(); + if (!empty($result)) { + Message::addInfo('delete-images', $result); + } + Util::redirect('?do=DozMod'); + } elseif ($action !== false) { + Util::traceError('Invalid action: ' . $action); + } + /* add sub-menus */ + Dashboard::addSubmenu('?do=dozmod§ion=expiredimages', Dictionary::translate('submenu_expiredimages', true)); Dashboard::addSubmenu('?do=dozmod§ion=mailconfig', Dictionary::translate('submenu_mailconfig', true)); Dashboard::addSubmenu('?do=dozmod§ion=templates', Dictionary::translate('submenu_templates', true)); Dashboard::addSubmenu('?do=dozmod§ion=runtimeconfig', Dictionary::translate('submenu_runtime', true)); @@ -44,37 +62,34 @@ class Page_DozMod extends Page $this->subPage->doPreprocess(); return; } - - /* execute actions */ - $action = Request::post('action'); - - if ($action === 'mail') { - $this->mailHandler(); - } - if ($action === 'runtime') { - $this->runtimeHandler(); - } - if ($action === 'delimages') { - $result = $this->handleDeleteImages(); - if (!empty($result)) { - Message::addInfo('delete-images', $result); - } - Util::redirect('?do=DozMod'); - } } protected function doRender() { - $this->listDeletePendingImages(); - /* different pages for different sections */ if ($this->subPage !== false) { $this->subPage->doRender(); return; } - $section = Request::get('section', 'mailconfig', 'string'); + $section = Request::get('section', false, 'string'); + + if ($section === false || $section === 'expiredimages') { + $expiredImages = $this->loadExpiredImages(); + if ($section === false && empty($expiredImages)) { + $section = 'mailconfig'; + } else { + $section = 'expiredimages'; + } + } + if ($section === 'expiredimages') { + if (empty($expiredImages)) { + Message::addSuccess('no-expired-images'); + } else { + Render::addTemplate('images-delete', array('images' => $expiredImages)); + } + } if ($section === 'mailconfig') { // Mail config $mailConf = Database::queryFirst('SELECT value FROM sat.configuration WHERE parameter = :param', array('param' => 'mailconfig')); @@ -140,7 +155,7 @@ class Page_DozMod extends Page Render::addTemplate('blockstats', $data); } - private function listDeletePendingImages() + private function loadExpiredImages() { $res = Database::simpleQuery("SELECT b.displayname," . " own.firstname, own.lastname, own.email," @@ -168,9 +183,7 @@ class Page_DozMod extends Page $row['filesize'] = Util::readableFileSize($row['filesize']); $rows[] = $row; } - if (empty($rows)) - return; - Render::addTemplate('images-delete', array('images' => $rows)); + return $rows; } private function cleanMailArray() -- cgit v1.2.3-55-g7522