Skip to content

Instantly share code, notes, and snippets.

@rjmackay
Created May 10, 2012 04:56
Show Gist options
  • Save rjmackay/2651105 to your computer and use it in GitHub Desktop.
Save rjmackay/2651105 to your computer and use it in GitHub Desktop.
Ushahidi MY_Controller
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Base Controller
* Enforces basic access control, ie. for private deployments
*
* PHP version 5
* LICENSE: This source file is subject to LGPL license
* that is available through the world-wide-web at the following URI:
* http://www.gnu.org/copyleft/lesser.html
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi - http://source.ushahididev.com
* @subpackage Controllers
* @copyright Ushahidi - http://www.ushahidi.com
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
*/
abstract class Controller extends Controller_Core {
public function __construct()
{
parent::__construct();
$this->auth = new Auth();
if (! $this->auth->logged_id()) {
$this->auth->auto_login();
}
$controller_whitelist = array(
'login',
'riverid'
);
if (Kohana::config('settings.private_deployment'))
{
if (!$this->auth->logged_in('login') AND ! in_array(Router::$controller, $controller_whitelist))
{
url::redirect('login');
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment