summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/upgrader.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/controllers/upgrader.php')
-rw-r--r--modules/gallery/controllers/upgrader.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index e8798de5..0833e253 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -19,7 +19,46 @@
*/
class Upgrader_Controller extends Controller {
public function index() {
+ // Todo: give the admin a chance to log in here
+ if (!user::active()->admin) {
+ access::forbidden();
+ }
+
$view = new View("upgrader.html");
+ $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 (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) {
+ access::forbidden();
+ }
+
+ // Upgrade gallery and user first
+ module::install("gallery");
+ module::install("user");
+
+ // Then upgrade the rest
+ foreach (module::available() as $id => $module) {
+ if ($id == "gallery") {
+ continue;
+ }
+
+ if ($module->active && $module->code_version != $module->version) {
+ module::install($id);
+ }
+ }
+
+ if (php_sapi_name() == "cli") {
+ print "Upgrade complete\n";
+ } else {
+ url::redirect("upgrader?done=1");
+ }
+ }
}