diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-10 07:42:00 -0700 |
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-10 07:42:00 -0700 |
| commit | a3c9104568704b5e626c9ac9b95921c8a67ef79a (patch) | |
| tree | 23be8f92ec3119c9fbc37eea5629fa8f5c11f1d2 /modules/gallery/controllers | |
| parent | 1f1cb01a967b508374ec9202815cb190bf4ea463 (diff) | |
| parent | 66014819b4e7fd8a5438eb800675641f7d213e27 (diff) | |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/controllers')
| -rw-r--r-- | modules/gallery/controllers/packager.php (renamed from modules/gallery/controllers/package.php) | 10 | ||||
| -rw-r--r-- | modules/gallery/controllers/upgrader.php | 39 |
2 files changed, 45 insertions, 4 deletions
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 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"); + } + } } |
