From 63c0cf521f8097b0dadaf1228176dc38c7d897f6 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 15 May 2014 18:28:24 +0200 Subject: Working on config.tgz composition through config modules --- modules/sysconfig.inc.php | 81 ++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 44 deletions(-) (limited to 'modules/sysconfig.inc.php') diff --git a/modules/sysconfig.inc.php b/modules/sysconfig.inc.php index c883eb68..faa26787 100644 --- a/modules/sysconfig.inc.php +++ b/modules/sysconfig.inc.php @@ -1,37 +1,29 @@ preprocess(); } -if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'activate') { - if (!Util::verifyToken()) { - Util::redirect('?do=sysconfig'); - } +// Action "activate" (set sysconfig as active) +if ($action === 'activate') { if (!User::hasPermission('superadmin')) { Message::addError('no-permission'); Util::redirect('?do=sysconfig'); @@ -55,15 +47,19 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'activate') { Util::redirect('?do=sysconfig'); } +/** + * Render module; called by main script when this module page should render + * its content. + */ function render_module() { - if (!isset($_REQUEST['action'])) $_REQUEST['action'] = 'list'; - switch ($_REQUEST['action']) { - case 'remotelist': - list_remote_configs(); + global $action, $handler; + switch ($action) { + case 'addmodule': + $handler->render(); break; case 'list': - list_configs(); + rr_list_configs(); break; default: Message::addError('invalid-action', $_REQUEST['action']); @@ -71,25 +67,23 @@ function render_module() } } -function list_configs() +function rr_list_configs() { if (!User::hasPermission('superadmin')) { Message::addError('no-permission'); return; } - $current = ''; - if (file_exists(CONFIG_HTTP_DIR . '/default/config.tgz')) $current = realpath(CONFIG_HTTP_DIR . '/default/config.tgz'); - $files = array(); - foreach (glob(CONFIG_TGZ_LIST_DIR . '/*.tgz') as $file) { - $files[] = array( - 'file' => basename($file), - 'current' => ($current === realpath($file)) + $res = Database::simpleQuery("SELECT title FROM configtgz_module ORDER BY title ASC"); + $modules = array(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $modules[] = array( + 'module' => $row['title'] ); } - Render::addTemplate('page-tgz-list', array('files' => $files, 'token' => Session::get('token'))); + Render::addTemplate('page-sysconfig-main', array('modules' => $modules, 'token' => Session::get('token'))); } -function list_remote_configs() +function rr_list_remote_configs() { if (!User::hasPermission('superadmin')) { Message::addError('no-permission'); @@ -111,4 +105,3 @@ function list_remote_configs() } Render::addTemplate('page-remote-tgz-list', array('files' => $list)); } - -- cgit v1.2.3-55-g7522