2008-12-14 02:45:07 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2009-05-13 20:04:58 +00:00
|
|
|
* Copyright (C) 2000-2009 Bharat Mediratta
|
2008-12-14 02:45:07 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* 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_Controller extends Controller {
|
2008-12-20 01:42:18 +00:00
|
|
|
private $theme;
|
|
|
|
|
|
|
|
|
|
public function __construct($theme=null) {
|
2009-10-22 13:09:20 -07:00
|
|
|
if (!(identity::active_user()->admin)) {
|
2009-06-01 22:40:22 -07:00
|
|
|
access::forbidden();
|
2008-12-14 04:39:22 +00:00
|
|
|
}
|
2009-06-01 22:40:22 -07:00
|
|
|
|
2008-12-14 21:50:10 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
}
|
2008-12-15 00:37:31 +00:00
|
|
|
|
2008-12-19 09:47:13 +00:00
|
|
|
public function __call($controller_name, $args) {
|
2008-12-22 04:33:18 +00:00
|
|
|
if (request::method() == "post") {
|
|
|
|
|
access::verify_csrf();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 09:47:13 +00:00
|
|
|
if ($controller_name == "index") {
|
|
|
|
|
$controller_name = "dashboard";
|
|
|
|
|
}
|
2008-12-20 01:42:18 +00:00
|
|
|
$controller_name = "Admin_{$controller_name}_Controller";
|
2008-12-19 09:47:13 +00:00
|
|
|
if ($args) {
|
2008-12-19 22:14:14 +00:00
|
|
|
$method = array_shift($args);
|
2008-12-19 09:47:13 +00:00
|
|
|
} else {
|
|
|
|
|
$method = "index";
|
2008-12-14 21:50:10 +00:00
|
|
|
}
|
2008-12-15 01:48:34 +00:00
|
|
|
|
2008-12-25 22:29:05 +00:00
|
|
|
if (!method_exists($controller_name, $method)) {
|
|
|
|
|
return kohana::show_404();
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-24 04:22:22 +00:00
|
|
|
call_user_func_array(array(new $controller_name, $method), $args);
|
2008-12-14 02:45:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|