diff options
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/admin_maintenance.php | 8 | ||||
-rw-r--r-- | modules/gallery/controllers/admin_theme_options.php (renamed from modules/gallery/controllers/admin_theme_details.php) | 6 | ||||
-rw-r--r-- | modules/gallery/controllers/packager.php (renamed from modules/gallery/controllers/package.php) | 10 | ||||
-rw-r--r-- | modules/gallery/controllers/upgrader.php | 29 |
4 files changed, 36 insertions, 17 deletions
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index c169de75..7c5934a3 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -61,7 +61,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { log::info("tasks", t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), - html::anchor(url::site("admin/maintenance"), t("maintenance"))); + html::anchor("admin/maintenance", t("maintenance"))); print $view; } @@ -81,7 +81,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { log::info("tasks", t("Task %task_name resumed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), - html::anchor(url::site("admin/maintenance"), t("maintenance"))); + html::anchor("admin/maintenance", t("maintenance"))); print $view; } @@ -152,14 +152,14 @@ class Admin_Maintenance_Controller extends Admin_Controller { case "success": log::success("tasks", t("Task %task_name completed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), - html::anchor(url::site("admin/maintenance"), t("maintenance"))); + html::anchor("admin/maintenance", t("maintenance"))); message::success(t("Task completed successfully")); break; case "error": log::error("tasks", t("Task %task_name failed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), - html::anchor(url::site("admin/maintenance"), t("maintenance"))); + html::anchor("admin/maintenance", t("maintenance"))); message::success(t("Task failed")); break; } diff --git a/modules/gallery/controllers/admin_theme_details.php b/modules/gallery/controllers/admin_theme_options.php index 97696df5..2716ed93 100644 --- a/modules/gallery/controllers/admin_theme_details.php +++ b/modules/gallery/controllers/admin_theme_options.php @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Admin_Theme_Details_Controller extends Admin_Controller { +class Admin_Theme_Options_Controller extends Admin_Controller { public function index() { $view = new Admin_View("admin.html"); - $view->content = new View("admin_theme_details.html"); + $view->content = new View("admin_theme_options.html"); $view->content->form = theme::get_edit_form_admin(); print $view; } @@ -58,7 +58,7 @@ class Admin_Theme_Details_Controller extends Admin_Controller { module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value); message::success(t("Updated theme details")); - url::redirect("admin/theme_details"); + url::redirect("admin/theme_options"); } else { $view = new Admin_View("admin.html"); $view->content = $form; diff --git a/modules/gallery/controllers/package.php b/modules/gallery/controllers/packager.php index f5146fc8..da0a7983 100644 --- a/modules/gallery/controllers/package.php +++ b/modules/gallery/controllers/packager.php @@ -17,12 +17,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Package_Controller extends Controller { - function index() { - if (PHP_SAPI != 'cli') { - Kohana::show_404(); +class Packager_Controller extends Controller { + function package() { + if (PHP_SAPI != "cli") { + access::forbidden(); } + $_SERVER["HTTP_HOST"] = "example.com"; + try { $this->_reset(); // empty and reinstall the standard modules $this->_dump_database(); // Dump the database diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index 0d5bb4f6..5eb96fdd 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -19,20 +19,33 @@ */ class Upgrader_Controller extends Controller { public function index() { - // Todo: give the admin a chance to log in here - if (!user::active()->admin) { - access::forbidden(); + $session = Session::instance(); + + // Make sure we have an upgrade token + if (!($upgrade_token = $session->get("upgrade_token", null))) { + $session->set("upgrade_token", $upgrade_token = md5(rand())); + } + + // If the upgrade token exists, then bless this session + if (file_exists(TMPPATH . $upgrade_token)) { + $session->set("can_upgrade", true); + @unlink(TMPPATH . $upgrade_token); } $view = new View("upgrader.html"); + $view->can_upgrade = user::active()->admin || $session->get("can_upgrade"); + $view->upgrade_token = $upgrade_token; $view->available = module::available(); $view->done = Input::instance()->get("done"); print $view; } public function upgrade() { - // Todo: give the admin a chance to log in here - if (!user::active()->admin) { + if (php_sapi_name() == "cli") { + // @todo this may screw up some module installers, but we don't have a better answer at + // this time. + $_SERVER["HTTP_HOST"] = "example.com"; + } else if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } @@ -51,6 +64,10 @@ class Upgrader_Controller extends Controller { } } - url::redirect("upgrader?done=1"); + if (php_sapi_name() == "cli") { + print "Upgrade complete\n"; + } else { + url::redirect("upgrader?done=1"); + } } } |