Fixes to OSB to work with KH 3.3
This commit is contained in:
parent
ea36639638
commit
6db02ae77d
@ -2,7 +2,7 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
# Installation directory
|
# Installation directory
|
||||||
RewriteBase /
|
RewriteBase /osb/
|
||||||
|
|
||||||
# Protect hidden files from being viewed
|
# Protect hidden files from being viewed
|
||||||
<Files .*>
|
<Files .*>
|
||||||
@ -11,7 +11,7 @@ RewriteBase /
|
|||||||
</Files>
|
</Files>
|
||||||
|
|
||||||
# Protect application and system files from being viewed
|
# Protect application and system files from being viewed
|
||||||
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
|
RewriteRule ^(?:application|modules|includes/kohana)\b.* index.php/$0 [L]
|
||||||
|
|
||||||
# Allow any files or directories that exist to be displayed directly
|
# Allow any files or directories that exist to be displayed directly
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
@ -22,7 +22,7 @@ else
|
|||||||
* @link http://kohanaframework.org/guide/using.configuration
|
* @link http://kohanaframework.org/guide/using.configuration
|
||||||
* @link http://www.php.net/manual/timezones
|
* @link http://www.php.net/manual/timezones
|
||||||
*/
|
*/
|
||||||
date_default_timezone_set('America/Chicago');
|
date_default_timezone_set('Australia/Melbourne');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default locale.
|
* Set the default locale.
|
||||||
@ -90,9 +90,9 @@ if (isset($_SERVER['KOHANA_ENV']))
|
|||||||
* - boolean expose set the X-Powered-By header FALSE
|
* - boolean expose set the X-Powered-By header FALSE
|
||||||
*/
|
*/
|
||||||
Kohana::init(array(
|
Kohana::init(array(
|
||||||
'base_url' => '/osb',
|
'base_url' => '/osb/',
|
||||||
'index_file' => '',
|
|
||||||
'caching' => TRUE,
|
'caching' => TRUE,
|
||||||
|
'index_file' => '',
|
||||||
));
|
));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,14 +114,14 @@ Kohana::modules(array(
|
|||||||
'cron' => SMDPATH.'cron', // Kohana Cron Module
|
'cron' => SMDPATH.'cron', // Kohana Cron Module
|
||||||
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
|
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
|
||||||
'database' => SMDPATH.'database', // Database access
|
'database' => SMDPATH.'database', // Database access
|
||||||
// 'image' => SMDPATH.'image', // Image manipulation
|
|
||||||
// 'minion' => MODPATH.'minion', // CLI Tasks
|
|
||||||
'orm' => SMDPATH.'orm', // Object Relationship Mapping
|
|
||||||
// 'unittest' => SMDPATH.'unittest', // Unit testing
|
|
||||||
'userguide' => SMDPATH.'userguide', // User guide and API documentation
|
|
||||||
'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework
|
|
||||||
'gchart' => MODPATH.'gchart', // Google Chart Module
|
'gchart' => MODPATH.'gchart', // Google Chart Module
|
||||||
|
// 'image' => SMDPATH.'image', // Image manipulation
|
||||||
|
'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework
|
||||||
|
'minion' => SMDPATH.'minion', // CLI Tasks
|
||||||
|
'orm' => SMDPATH.'orm', // Object Relationship Mapping
|
||||||
'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework
|
'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework
|
||||||
|
// 'unittest' => SMDPATH.'unittest', // Unit testing
|
||||||
|
// 'userguide' => SMDPATH.'userguide', // User guide and API documentation
|
||||||
'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
|
'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ Kohana::modules(array_merge(Kohana::modules(),Config::modules()));
|
|||||||
*/
|
*/
|
||||||
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
|
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
|
||||||
array(
|
array(
|
||||||
'directory' => '('.implode('|',Kohana::config('config.method_directory')).')'
|
'directory' => '('.implode('|',Kohana::$config->load('config')->method_directory).')'
|
||||||
))
|
))
|
||||||
->defaults(array(
|
->defaults(array(
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
@ -152,7 +152,7 @@ Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
|
|||||||
* Set the routes. Each route must have a minimum of a name, a URI and a set of
|
* Set the routes. Each route must have a minimum of a name, a URI and a set of
|
||||||
* defaults for the URI.
|
* defaults for the URI.
|
||||||
*/
|
*/
|
||||||
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id' => '[a-zA-Z0-9_.-]+'))
|
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-]+'))
|
||||||
->defaults(array(
|
->defaults(array(
|
||||||
'controller' => 'welcome',
|
'controller' => 'welcome',
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
|
@ -30,12 +30,12 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
// If we are not a valid user object, then we are not logged in
|
// If we are not a valid user object, then we are not logged in
|
||||||
if (is_object($user) AND $user instanceof Model_Account AND $user->loaded()) {
|
if (is_object($user) AND $user instanceof Model_Account AND $user->loaded()) {
|
||||||
|
|
||||||
if (Config::sitemode() == Kohana::DEVELOPMENT && Kohana::config('config.site_debug'))
|
if (Config::sitemode() == Kohana::DEVELOPMENT && Kohana::$config->load('config')->site_debug)
|
||||||
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Kohana::debug(array('user'=>$user->username,'r'=>$role))));
|
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Kohana::debug(array('user'=>$user->username,'r'=>$role))));
|
||||||
|
|
||||||
if (! empty($role)) {
|
if (! empty($role)) {
|
||||||
// Get the module details
|
// Get the module details
|
||||||
$mo = ORM::factory('module',array('name'=>Request::current()->controller()));
|
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
|
||||||
if (! $mo->loaded() OR ! $mo->status) {
|
if (! $mo->loaded() OR ! $mo->status) {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>'Module is not defined or active in the Database',
|
'title'=>'Module is not defined or active in the Database',
|
||||||
@ -50,7 +50,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
$method_name = Request::current()->action();
|
$method_name = Request::current()->action();
|
||||||
|
|
||||||
// Get the method number
|
// Get the method number
|
||||||
$mmo = ORM::factory('module_method',array('module_id'=>$mo->id,'name'=>$method_name));
|
$mmo = ORM::factory('Module_Method',array('module_id'=>$mo->id,'name'=>$method_name));
|
||||||
if (! $mmo->loaded()) {
|
if (! $mmo->loaded()) {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>'Method is not defined or active in the Database',
|
'title'=>'Method is not defined or active in the Database',
|
||||||
@ -60,7 +60,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// If the role has the authorisation to run the method
|
// If the role has the authorisation to run the method
|
||||||
$gmo = ORM::factory('group_method')
|
$gmo = ORM::factory('Group_Method')
|
||||||
->where('method_id','=',$mmo->id);
|
->where('method_id','=',$mmo->id);
|
||||||
|
|
||||||
$roles = '';
|
$roles = '';
|
||||||
@ -152,14 +152,14 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
if (! is_null($user))
|
if (! is_null($user))
|
||||||
return $user;
|
return $user;
|
||||||
|
|
||||||
$mmto = ORM::factory('module_method_token',array('token'=>$token));
|
$mmto = ORM::factory('Module_Method_Token',array('token'=>$token));
|
||||||
$user = FALSE;
|
$user = FALSE;
|
||||||
|
|
||||||
// Ignore the token if it doesnt exist.
|
// Ignore the token if it doesnt exist.
|
||||||
if ($mmto->loaded()) {
|
if ($mmto->loaded()) {
|
||||||
// Check that the token is for this URI
|
// Check that the token is for this URI
|
||||||
$mo = ORM::factory('module',array('name'=>Request::current()->controller()));
|
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
|
||||||
$mmo = ORM::factory('module_method',array(
|
$mmo = ORM::factory('Module_Method',array(
|
||||||
'module_id'=>$mo->id,
|
'module_id'=>$mo->id,
|
||||||
'name'=>Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()
|
'name'=>Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()
|
||||||
));
|
));
|
||||||
@ -197,7 +197,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
|
|
||||||
Session::instance()->set('token',$token);
|
Session::instance()->set('token',$token);
|
||||||
|
|
||||||
$user = ORM::factory('account',$mmto->account_id);
|
$user = ORM::factory('Account',$mmto->account_id);
|
||||||
$user->log(sprintf('Token %s used for method %s [%s]',$mmto->token,$mmto->module_method->name(),Request::current()->param('id')));
|
$user->log(sprintf('Token %s used for method %s [%s]',$mmto->token,$mmto->module_method->name(),Request::current()->param('id')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,17 +221,23 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
$username = $user;
|
$username = $user;
|
||||||
|
|
||||||
// Load the user
|
// Load the user
|
||||||
$user = ORM::factory('account');
|
$user = ORM::factory('Account');
|
||||||
$user->where('username','=',$username)->find();
|
$user->where('username','=',$username)->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_string($password))
|
||||||
|
{
|
||||||
|
// Create a hashed password
|
||||||
|
$password = $this->hash($password);
|
||||||
|
}
|
||||||
|
|
||||||
// If the passwords match, perform a login
|
// If the passwords match, perform a login
|
||||||
if ($user->status AND $user->has_any('group',ORM::factory('group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
|
if ($user->status AND $user->has_any('group',ORM::factory('Group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password)
|
||||||
{
|
{
|
||||||
if ($remember === TRUE)
|
if ($remember === TRUE)
|
||||||
{
|
{
|
||||||
// Create a new autologin token
|
// Create a new autologin token
|
||||||
$token = ORM::factory('user_token');
|
$token = ORM::factory('User_Token');
|
||||||
|
|
||||||
// Set token data
|
// Set token data
|
||||||
$token->user_id = $user->id;
|
$token->user_id = $user->id;
|
||||||
@ -250,7 +256,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
|
|
||||||
// Do we need to update databases with our new sesion ID
|
// Do we need to update databases with our new sesion ID
|
||||||
// @todo figure out where this is best to go
|
// @todo figure out where this is best to go
|
||||||
$session_change_trigger = array('cart'=>'session_id');
|
$session_change_trigger = array('Cart'=>'session_id');
|
||||||
|
|
||||||
if (count($session_change_trigger) AND (session_id() != $oldsess)) {
|
if (count($session_change_trigger) AND (session_id() != $oldsess)) {
|
||||||
foreach ($session_change_trigger as $t => $c) {
|
foreach ($session_change_trigger as $t => $c) {
|
@ -1,4 +1,4 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
class Breadcrumb extends lnApp_Breadcrumb {}
|
class BreadCrumb extends lnApp_BreadCrumb {}
|
||||||
?>
|
?>
|
16
application/classes/Cache.php
Normal file
16
application/classes/Cache.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Cache
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class Cache extends Kohana_Cache {
|
||||||
|
public static $default = 'apc';
|
||||||
|
}
|
||||||
|
?>
|
@ -60,12 +60,12 @@ class Company {
|
|||||||
|
|
||||||
public static function bsb() {
|
public static function bsb() {
|
||||||
// @todo Details should be obtained from DB
|
// @todo Details should be obtained from DB
|
||||||
return Kohana::config('config.bsb');
|
return Kohana::$config->load('config')->bsb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function account() {
|
public static function account() {
|
||||||
// @todo Details should be obtained from DB
|
// @todo Details should be obtained from DB
|
||||||
return Kohana::config('config.accnum');
|
return Kohana::$config->load('config')->accnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function taxid() {
|
public static function taxid() {
|
@ -15,12 +15,55 @@ class Config extends lnApp_Config {
|
|||||||
public $so;
|
public $so;
|
||||||
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @compat Restore KH 3.1 functionality
|
||||||
|
* @var Kohana_Config Singleton static instance
|
||||||
|
*/
|
||||||
|
protected static $_instance;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
// We need to know our site here, so that we can subsequently load our enabled modules.
|
||||||
|
if (Kohana::$is_cli) {
|
||||||
|
if (! $site = Minion_CLI::options('site'))
|
||||||
|
// @todo Need to figure out how to make this CLI error nicer.
|
||||||
|
throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI'));
|
||||||
|
else
|
||||||
|
$_SERVER['SERVER_NAME'] = $site;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the singleton instance of Config.
|
||||||
|
*
|
||||||
|
* $config = Config::instance();
|
||||||
|
*
|
||||||
|
* @return Config
|
||||||
|
* @compat Restore KH 3.1 functionality
|
||||||
|
*/
|
||||||
|
public static function instance() {
|
||||||
|
if (Config::$_instance === NULL)
|
||||||
|
// Create a new instance
|
||||||
|
Config::$_instance = new Config;
|
||||||
|
|
||||||
|
return Config::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
/** Overloaded methods **/
|
/** Overloaded methods **/
|
||||||
|
|
||||||
public static function date($date) {
|
public static function date($date) {
|
||||||
return date(Config::instance()->loadsite()->so->date_format,($date ? $date : time()));
|
return date(Config::instance()->loadsite()->so->date_format,($date ? $date : time()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a date using a site configured format
|
||||||
|
* @note We need this function here, since we call static:: methods, which need to resolve to the child class.
|
||||||
|
*/
|
||||||
|
public static function datetime($date) {
|
||||||
|
return sprintf('%s %s',static::date($date),static::time($date));
|
||||||
|
}
|
||||||
|
|
||||||
public static function siteid($format=FALSE) {
|
public static function siteid($format=FALSE) {
|
||||||
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
|
return $format ? sprintf('%02s',Config::instance()->loadsite()->so->id) : Config::instance()->loadsite()->so->id;
|
||||||
}
|
}
|
||||||
@ -45,7 +88,7 @@ class Config extends lnApp_Config {
|
|||||||
if ($this->so AND $this->so->loaded())
|
if ($this->so AND $this->so->loaded())
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$this->so = ORM::factory('setup',array('url'=>URL::base('http')));
|
$this->so = ORM::factory('Setup',array('url'=>URL::base('http')));
|
||||||
|
|
||||||
if (! $this->so->loaded())
|
if (! $this->so->loaded())
|
||||||
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
||||||
@ -65,7 +108,7 @@ class Config extends lnApp_Config {
|
|||||||
static $return = array();
|
static $return = array();
|
||||||
|
|
||||||
if (! count($return))
|
if (! count($return))
|
||||||
foreach (ORM::factory('module')->list_active() as $mo)
|
foreach (ORM::factory('Module')->list_external() as $mo)
|
||||||
$return[$mo->name] = MODPATH.$mo->name;
|
$return[$mo->name] = MODPATH.$mo->name;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
@ -21,7 +21,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
|
|||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
|
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
|
||||||
$return += ORM::factory('account')->list_autocomplete($_REQUEST['term']);
|
$return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
|
||||||
|
|
||||||
$this->auto_render = FALSE;
|
$this->auto_render = FALSE;
|
||||||
$this->response->headers('Content-Type','application/json');
|
$this->response->headers('Content-Type','application/json');
|
||||||
@ -35,7 +35,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
|
|||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Account Login Log'),
|
'title'=>_('Account Login Log'),
|
||||||
'body'=>Table::display(
|
'body'=>Table::display(
|
||||||
ORM::factory('account_log')->order_by('id','DESC')->find_all(),
|
ORM::factory('Account_Log')->order_by('id','DESC')->find_all(),
|
||||||
25,
|
25,
|
||||||
array(
|
array(
|
||||||
'id'=>array('label'=>'ID'),
|
'id'=>array('label'=>'ID'),
|
||||||
@ -57,7 +57,7 @@ class Controller_Admin_Account extends Controller_TemplateDefault_Admin {
|
|||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Customer List'),
|
'title'=>_('Customer List'),
|
||||||
'body'=>Table::display(
|
'body'=>Table::display(
|
||||||
ORM::factory('account')->list_active(),
|
ORM::factory('Account')->list_active(),
|
||||||
25,
|
25,
|
||||||
array(
|
array(
|
||||||
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
|
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
|
@ -26,11 +26,11 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
|
|||||||
$methods = array();
|
$methods = array();
|
||||||
|
|
||||||
// List of classes where all our methods are, including this one.
|
// List of classes where all our methods are, including this one.
|
||||||
$classes = Kohana::config('config.method_directory');
|
$classes = Kohana::$config->load('config')->method_directory;
|
||||||
array_unshift($classes,'');
|
array_unshift($classes,'');
|
||||||
|
|
||||||
foreach ($classes as $c) {
|
foreach ($classes as $c) {
|
||||||
$cn = sprintf($ch,$c ? $c.'_'.$class : $class);
|
$cn = sprintf($ch,$c ? ucfirst($c).'_'.ucfirst($class) : $class);
|
||||||
|
|
||||||
if (class_exists($cn)) {
|
if (class_exists($cn)) {
|
||||||
$r = new ReflectionClass($cn);
|
$r = new ReflectionClass($cn);
|
||||||
@ -48,7 +48,7 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
|
|||||||
* List our installed modules
|
* List our installed modules
|
||||||
*/
|
*/
|
||||||
public function action_list() {
|
public function action_list() {
|
||||||
$mo = ORM::factory('module');
|
$mo = ORM::factory('Module');
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Defined Modules'),
|
'title'=>_('Defined Modules'),
|
||||||
@ -74,7 +74,7 @@ class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
|
|||||||
*/
|
*/
|
||||||
public function action_edit() {
|
public function action_edit() {
|
||||||
$mid = $this->request->param('id');
|
$mid = $this->request->param('id');
|
||||||
$mo = ORM::factory('module',$mid);
|
$mo = ORM::factory('Module',$mid);
|
||||||
|
|
||||||
if (! $mo->loaded()) {
|
if (! $mo->loaded()) {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
@ -14,9 +14,12 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
/**
|
/**
|
||||||
* Add a method to the database
|
* Add a method to the database
|
||||||
*/
|
*/
|
||||||
public function action_add($mid,$method) {
|
public function action_add() {
|
||||||
$mo = ORM::factory('module',$mid);
|
$id = $this->request->param('id');
|
||||||
$mmo = ORM::factory('module_method');
|
$method = $this->request->param('sid');
|
||||||
|
|
||||||
|
$mo = ORM::factory('Module',$id);
|
||||||
|
$mmo = ORM::factory('Module_Method');
|
||||||
|
|
||||||
if (! $mo->loaded() OR ! in_array($method,$this->_methods($mo->name)))
|
if (! $mo->loaded() OR ! in_array($method,$this->_methods($mo->name)))
|
||||||
throw new Kohana_Exception('Method (:method) does not exist in :class',array(':method'=>$method,':class'=>$mo->name));
|
throw new Kohana_Exception('Method (:method) does not exist in :class',array(':method'=>$method,':class'=>$mo->name));
|
||||||
@ -37,7 +40,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
||||||
));
|
));
|
||||||
|
|
||||||
Request::current()->redirect(sprintf('admin/module/edit/%s',$mo->id));
|
HTTP::redirect(sprintf('admin/module/edit/%s',$mo->id));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
@ -65,7 +68,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
*/
|
*/
|
||||||
public function action_edit() {
|
public function action_edit() {
|
||||||
$mid = $this->request->param('id');
|
$mid = $this->request->param('id');
|
||||||
$mmo = ORM::factory('module_method',$mid);
|
$mmo = ORM::factory('Module_Method',$mid);
|
||||||
|
|
||||||
if (! $mmo->loaded()) {
|
if (! $mmo->loaded()) {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
@ -80,13 +83,13 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
// The groups that can run this method.
|
// The groups that can run this method.
|
||||||
$groups = ORM::factory('group');
|
$groups = ORM::factory('Group');
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
foreach ($groups->find_all() as $go) {
|
foreach ($groups->find_all() as $go) {
|
||||||
// If the group was defined and no longer
|
// If the group was defined and no longer
|
||||||
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) {
|
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) {
|
||||||
$gm = ORM::factory('group_method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
|
$gm = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
|
||||||
|
|
||||||
if (! $gm->delete())
|
if (! $gm->delete())
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
@ -97,7 +100,7 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
|
|
||||||
// If the group was not defined and now is
|
// If the group was not defined and now is
|
||||||
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) {
|
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) {
|
||||||
$gm = ORM::factory('group_method')
|
$gm = ORM::factory('Group_Method')
|
||||||
->values(array(
|
->values(array(
|
||||||
'method_id'=>$mmo->id,
|
'method_id'=>$mmo->id,
|
||||||
'group_id'=>$go->id,
|
'group_id'=>$go->id,
|
@ -51,7 +51,7 @@ class Controller_Admin_Setup extends Controller_TemplateDefault_Admin {
|
|||||||
$output .= View::factory($this->viewpath().'/module/head');
|
$output .= View::factory($this->viewpath().'/module/head');
|
||||||
|
|
||||||
foreach ($o->module_config as $mid => $detail) {
|
foreach ($o->module_config as $mid => $detail) {
|
||||||
$mo = ORM::factory('module',$mid);
|
$mo = ORM::factory('Module',$mid);
|
||||||
|
|
||||||
$output .= View::factory($this->viewpath().'/module/body')
|
$output .= View::factory($this->viewpath().'/module/body')
|
||||||
->set('mo',$mo);
|
->set('mo',$mo);
|
@ -16,11 +16,11 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
$ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
$ao = ORM::factory('Account',Auth::instance()->get_user()->id);
|
||||||
$t = time();
|
$t = time();
|
||||||
|
|
||||||
// Show outstanding invoices
|
// Show outstanding invoices
|
||||||
$o = ORM::factory('invoice');
|
$o = ORM::factory('Invoice');
|
||||||
|
|
||||||
Block_Sub::add(array(
|
Block_Sub::add(array(
|
||||||
'title'=>'Invoices Overdue - No Auto Billing',
|
'title'=>'Invoices Overdue - No Auto Billing',
|
||||||
@ -83,7 +83,7 @@ class Controller_Admin_Welcome extends Controller_TemplateDefault_Admin {
|
|||||||
Block_Sub::add(array(
|
Block_Sub::add(array(
|
||||||
'title'=>'Unapplied Payments',
|
'title'=>'Unapplied Payments',
|
||||||
'body'=>Table::display(
|
'body'=>Table::display(
|
||||||
ORM::factory('payment')->list_unapplied(),
|
ORM::factory('Payment')->list_unapplied(),
|
||||||
25,
|
25,
|
||||||
array(
|
array(
|
||||||
'date_payment'=>array('label'=>'Pay Date'),
|
'date_payment'=>array('label'=>'Pay Date'),
|
@ -22,7 +22,7 @@ class Controller_Affiliate_Account extends Controller_TemplateDefault_Affiliate
|
|||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Customer List'),
|
'title'=>_('Customer List'),
|
||||||
'body'=>Table::display(
|
'body'=>Table::display(
|
||||||
$this->filter(ORM::factory('account')->list_active(),$this->ao->affiliate->id,'sortkey(TRUE)'),
|
$this->filter(ORM::factory('Account')->list_active(),$this->ao->affiliate->id,'sortkey(TRUE)'),
|
||||||
25,
|
25,
|
||||||
array(
|
array(
|
||||||
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
|
'id'=>array('label'=>'ID','url'=>'user/account/view/'),
|
@ -3,7 +3,7 @@
|
|||||||
class Controller_Debug extends Controller_TemplateDefault {
|
class Controller_Debug extends Controller_TemplateDefault {
|
||||||
public function before() {
|
public function before() {
|
||||||
if (! in_array(Config::sitemode(),array(Kohana::DEVELOPMENT,Kohana::TESTING)))
|
if (! in_array(Config::sitemode(),array(Kohana::DEVELOPMENT,Kohana::TESTING)))
|
||||||
$this->request->redirect();
|
HTTP::redirect();
|
||||||
|
|
||||||
parent::before();
|
parent::before();
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ class Controller_Login extends lnApp_Controller_Login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate a new user
|
// Instantiate a new user
|
||||||
$account = ORM::factory('account');
|
$account = ORM::factory('Account');
|
||||||
|
|
||||||
// If there is a post and $_POST is not empty
|
// If there is a post and $_POST is not empty
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
@ -42,7 +42,7 @@ class Controller_Login extends lnApp_Controller_Login {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ido = ORM::factory('module')
|
$ido = ORM::factory('Module')
|
||||||
->where('name','=','account')
|
->where('name','=','account')
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ class Controller_Login extends lnApp_Controller_Login {
|
|||||||
// If the user posted their details to reset their password
|
// If the user posted their details to reset their password
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
// If the username is correct, create a method token
|
// If the username is correct, create a method token
|
||||||
if (! empty($_POST['username']) AND ($ao=ORM::factory('account',array('username'=>$_POST['username']))) AND $ao->loaded()) {
|
if (! empty($_POST['username']) AND ($ao=ORM::factory('Account',array('username'=>$_POST['username']))) AND $ao->loaded()) {
|
||||||
$mmto = ORM::factory('module_method_token')
|
$mmto = ORM::factory('Module_Method_Token')
|
||||||
->method(array('account','user_resetpassword'))
|
->method(array('account','user_resetpassword'))
|
||||||
->account($ao)
|
->account($ao)
|
||||||
->uses(2)
|
->uses(2)
|
@ -35,8 +35,8 @@ class Controller_TemplateDefault_User extends Controller_TemplateDefault {
|
|||||||
$dc = 'welcome/index';
|
$dc = 'welcome/index';
|
||||||
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
|
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
|
||||||
|
|
||||||
Breadcrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||||
Breadcrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||||
|
|
||||||
parent::after();
|
parent::after();
|
||||||
}
|
}
|
@ -46,7 +46,7 @@ class Controller_Tree extends lnApp_Controller_Tree {
|
|||||||
if (preg_match('/_/',$id))
|
if (preg_match('/_/',$id))
|
||||||
list($id,$idx) = explode('_',$id,2);
|
list($id,$idx) = explode('_',$id,2);
|
||||||
|
|
||||||
$mo = ORM::factory('module',$id);
|
$mo = ORM::factory('Module',$id);
|
||||||
|
|
||||||
$methods = array();
|
$methods = array();
|
||||||
if ($mo->loaded()) {
|
if ($mo->loaded()) {
|
@ -38,7 +38,7 @@ class Controller_User_Account extends Controller_TemplateDefault_User {
|
|||||||
// Log the password reset
|
// Log the password reset
|
||||||
$this->ao->log('Password reset');
|
$this->ao->log('Password reset');
|
||||||
|
|
||||||
Request::current()->redirect('login');
|
HTTP::redirect('login');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$output = '';
|
$output = '';
|
@ -16,7 +16,7 @@ class Controller_User_Welcome extends Controller_TemplateDefault_User {
|
|||||||
);
|
);
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
$ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
$ao = ORM::factory('Account',Auth::instance()->get_user()->id);
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>sprintf('%s: %s %s',$ao->accnum(),$ao->first_name,$ao->last_name),
|
'title'=>sprintf('%s: %s %s',$ao->accnum(),$ao->first_name,$ao->last_name),
|
@ -14,11 +14,11 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
|||||||
protected $auth_required = FALSE;
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
if (! Kohana::config('config.appname'))
|
if (! Kohana::$config->load('config')->appname)
|
||||||
Request::current()->redirect('guide/app');
|
HTTP::redirect('guide/app');
|
||||||
|
|
||||||
// @todo This should be in the DB or something.
|
// @todo This should be in the DB or something.
|
||||||
Request::current()->redirect('product/categorys');
|
HTTP::redirect('product/categorys');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_breadcrumb() {
|
public function action_breadcrumb() {
|
16
application/classes/Cookie.php
Normal file
16
application/classes/Cookie.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Cookie
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Cookie extends Kohana_Cookie {
|
||||||
|
public static $salt = 'OSB';
|
||||||
|
}
|
||||||
|
?>
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
class Country {
|
class Country {
|
||||||
public static function icon($cid) {
|
public static function icon($cid) {
|
||||||
$co = ORM::factory('country',$cid);
|
$co = ORM::factory('Country',$cid);
|
||||||
|
|
||||||
return HTML::image(sprintf('media/img/country/%s.png',strtolower($co->two_code)),array('alt'=>$co->currency()->symbol));
|
return HTML::image(sprintf('media/img/country/%s.png',strtolower($co->two_code)),array('alt'=>$co->currency()->symbol));
|
||||||
}
|
}
|
@ -11,10 +11,10 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
||||||
public function __construct($message, array $variables = NULL, $code = 0)
|
public function __construct($message = NULL, array $variables = NULL, Exception $previous = NULL)
|
||||||
{
|
{
|
||||||
set_exception_handler(array(get_class($this),'handler'));
|
set_exception_handler(array(get_class($this),'handler'));
|
||||||
parent::__construct($message, $variables, (int) $code);
|
parent::__construct($message, $variables, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function handler(Exception $e)
|
public static function handler(Exception $e)
|
||||||
@ -25,7 +25,7 @@ class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
|||||||
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
|
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
|
||||||
));
|
));
|
||||||
|
|
||||||
Request::factory()->redirect('welcome');
|
HTTP::redirect('welcome');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -10,7 +10,23 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Kohana extends Kohana_Core {
|
abstract class Kohana extends Kohana_Core {
|
||||||
|
/**
|
||||||
|
* @compat Restore KH 3.1 functionality
|
||||||
|
* @var boolean True if Kohana is running from the command line
|
||||||
|
*/
|
||||||
|
public static $is_cli = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @compat Restore KH 3.1 functionality
|
||||||
|
*/
|
||||||
|
public static function init(array $settings = NULL) {
|
||||||
|
parent::init($settings);
|
||||||
|
|
||||||
|
// Determine if we are running in a command line environment
|
||||||
|
Kohana::$is_cli = (PHP_SAPI === 'cli');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override Kohana's shutdown_handler()
|
* Override Kohana's shutdown_handler()
|
||||||
*
|
*
|
||||||
@ -22,7 +38,7 @@ class Kohana extends Kohana_Core {
|
|||||||
public static function shutdown_handler() {
|
public static function shutdown_handler() {
|
||||||
// If caching isnt enabled, we can skip this anyway
|
// If caching isnt enabled, we can skip this anyway
|
||||||
if (! Kohana::$caching)
|
if (! Kohana::$caching)
|
||||||
return parent::shutdown_handler();;
|
return parent::shutdown_handler();
|
||||||
|
|
||||||
Kohana::$caching = FALSE;
|
Kohana::$caching = FALSE;
|
||||||
$result = parent::shutdown_handler();
|
$result = parent::shutdown_handler();
|
18
application/classes/Minion/Task.php
Normal file
18
application/classes/Minion/Task.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Minion CLI Module
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class Minion_Task extends Kohana_Minion_Task {
|
||||||
|
protected $_options = array(
|
||||||
|
'site'=>NULL,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
@ -79,7 +79,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
|
|
||||||
public function isAdmin() {
|
public function isAdmin() {
|
||||||
// @todo Define admins in the config file or DB
|
// @todo Define admins in the config file or DB
|
||||||
$admins = array(ORM::factory('group',array('name'=>'Root')));
|
$admins = array(ORM::factory('Group',array('name'=>'Root')));
|
||||||
|
|
||||||
return $this->has('group',$admins);
|
return $this->has('group',$admins);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
|
|
||||||
public function log($message) {
|
public function log($message) {
|
||||||
// Log the logout
|
// Log the logout
|
||||||
$alo = ORM::factory('account_log');
|
$alo = ORM::factory('Account_Log');
|
||||||
$alo->account_id = $this->id;
|
$alo->account_id = $this->id;
|
||||||
$alo->ip = Request::$client_ip;
|
$alo->ip = Request::$client_ip;
|
||||||
$alo->details = $message;
|
$alo->details = $message;
|
@ -1,15 +1,15 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides task management
|
* OSB Affiliate
|
||||||
*
|
*
|
||||||
* @package lnApp
|
* @package OSB
|
||||||
* @subpackage Page/Task
|
* @subpackage Modules
|
||||||
* @category Controllers
|
* @category Models
|
||||||
* @author Deon George
|
* @author Deon George
|
||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Controller_Task extends Controller_TemplateDefault {
|
class Model_Affiliate extends ORM_OSB {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -59,13 +59,6 @@ class Model_Auth_UserDefault extends Model_Auth_User {
|
|||||||
return $this->log('Logged In');
|
return $this->log('Logged In');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test to see if a record has been changed
|
|
||||||
*/
|
|
||||||
public function changed() {
|
|
||||||
return (count($this->_changed));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug function to see that has() finds
|
* Debug function to see that has() finds
|
||||||
* @todo This function could be removed
|
* @todo This function could be removed
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
class Model_Country extends ORM_OSB {
|
class Model_Country extends ORM_OSB {
|
||||||
public function currency() {
|
public function currency() {
|
||||||
return ORM::factory('currency')->where('country_id','=',$this->id)->find();
|
return ORM::factory('Currency')->where('country_id','=',$this->id)->find();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -47,7 +47,7 @@ class Model_Group extends Model_Auth_RoleDefault {
|
|||||||
if (! $this->loaded())
|
if (! $this->loaded())
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
foreach (ORM::factory('group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) {
|
foreach (ORM::factory('Group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) {
|
||||||
array_push($return,$go);
|
array_push($return,$go);
|
||||||
|
|
||||||
$return = array_merge($return,$go->list_childgrps());
|
$return = array_merge($return,$go->list_childgrps());
|
||||||
@ -69,7 +69,7 @@ class Model_Group extends Model_Auth_RoleDefault {
|
|||||||
if (! $this->loaded())
|
if (! $this->loaded())
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
foreach (ORM::factory('group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) {
|
foreach (ORM::factory('Group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) {
|
||||||
array_push($return,$go);
|
array_push($return,$go);
|
||||||
|
|
||||||
$return = array_merge($return,$go->list_parentgrps());
|
$return = array_merge($return,$go->list_parentgrps());
|
@ -35,5 +35,9 @@ class Model_Module extends ORM_OSB {
|
|||||||
array('StaticList_YesNo::display',array(':value')),
|
array('StaticList_YesNo::display',array(':value')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function list_external() {
|
||||||
|
return $this->_where_active()->where('external','=',TRUE)->find_all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -28,9 +28,9 @@ class Model_Module_Method_Token extends ORM_OSB {
|
|||||||
|
|
||||||
if (! $method instanceof Model_Module_Method) {
|
if (! $method instanceof Model_Module_Method) {
|
||||||
if (is_numeric($module))
|
if (is_numeric($module))
|
||||||
$mo = ORM::factory('module',$module);
|
$mo = ORM::factory('Module',$module);
|
||||||
elseif (is_string($module))
|
elseif (is_string($module))
|
||||||
$mo = ORM::factory('module',array('name'=>$module));
|
$mo = ORM::factory('Module',array('name'=>$module));
|
||||||
elseif (! $module instanceof Model_Module)
|
elseif (! $module instanceof Model_Module)
|
||||||
throw new Kohana_Exception('Unknown module :module',array(':module'=>serialize($module)));
|
throw new Kohana_Exception('Unknown module :module',array(':module'=>serialize($module)));
|
||||||
else
|
else
|
||||||
@ -40,9 +40,9 @@ class Model_Module_Method_Token extends ORM_OSB {
|
|||||||
throw new Kohana_Exception('Unknown module :module - not loaded?',array(':module'=>$mo->id));
|
throw new Kohana_Exception('Unknown module :module - not loaded?',array(':module'=>$mo->id));
|
||||||
|
|
||||||
if (is_numeric($method))
|
if (is_numeric($method))
|
||||||
$mmo = ORM::factory('module_method',$method);
|
$mmo = ORM::factory('Module_Method',$method);
|
||||||
elseif (is_string($method))
|
elseif (is_string($method))
|
||||||
$mmo = ORM::factory('module_method',array('name'=>$method,'module_id'=>$mo->id));
|
$mmo = ORM::factory('Module_Method',array('name'=>$method,'module_id'=>$mo->id));
|
||||||
else
|
else
|
||||||
throw new Kohana_Exception('Unknown method :method',array(':method'=>serialize($method)));
|
throw new Kohana_Exception('Unknown method :method',array(':method'=>serialize($method)));
|
||||||
} else
|
} else
|
||||||
@ -59,7 +59,7 @@ class Model_Module_Method_Token extends ORM_OSB {
|
|||||||
public function account($account) {
|
public function account($account) {
|
||||||
if (! $account instanceof Model_Account) {
|
if (! $account instanceof Model_Account) {
|
||||||
if (is_numeric($account))
|
if (is_numeric($account))
|
||||||
$ao = ORM::factory('account',$account);
|
$ao = ORM::factory('Account',$account);
|
||||||
else
|
else
|
||||||
throw new Kohana_Exception('Unknown account :account',array(':account'=>serialize($account)));
|
throw new Kohana_Exception('Unknown account :account',array(':account'=>serialize($account)));
|
||||||
} else
|
} else
|
||||||
@ -88,7 +88,7 @@ class Model_Module_Method_Token extends ORM_OSB {
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Check we dont already have a valid token
|
// Check we dont already have a valid token
|
||||||
$mmto = ORM::factory('module_method_token')
|
$mmto = ORM::factory('Module_Method_Token')
|
||||||
->where('account_id','=',$this->account_id)
|
->where('account_id','=',$this->account_id)
|
||||||
->where('method_id','=',$this->method_id)
|
->where('method_id','=',$this->method_id)
|
||||||
->find();
|
->find();
|
@ -21,7 +21,7 @@ class Model_Record_Id extends ORM_OSB {
|
|||||||
$this->module_id = $mid;
|
$this->module_id = $mid;
|
||||||
|
|
||||||
// We'll get the next ID as the MAX(id) of the table
|
// We'll get the next ID as the MAX(id) of the table
|
||||||
$mo = ORM::factory('module',$mid);
|
$mo = ORM::factory('Module',$mid);
|
||||||
|
|
||||||
$max = DB::select(array('MAX(id)','id'))
|
$max = DB::select(array('MAX(id)','id'))
|
||||||
->from($mo->name)
|
->from($mo->name)
|
@ -42,7 +42,7 @@ class Model_Setup extends ORM_OSB {
|
|||||||
if (! $this->loaded() OR (is_null($value) AND ! $this->module_config))
|
if (! $this->loaded() OR (is_null($value) AND ! $this->module_config))
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
$mo = ORM::factory('module')->where('name','=',$key)->find();
|
$mo = ORM::factory('Module')->where('name','=',$key)->find();
|
||||||
|
|
||||||
if (! $mo->loaded())
|
if (! $mo->loaded())
|
||||||
throw new Kohana_Exception('Unknown module :name',array(':name'=>$key));
|
throw new Kohana_Exception('Unknown module :name',array(':name'=>$key));
|
@ -22,7 +22,7 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
final protected function _build($type) {
|
final protected function _build($type) {
|
||||||
// Exclude tables without site ID's
|
// Exclude tables without site ID's
|
||||||
if (! in_array($this->_table_name,Config::$no_site_id_tables))
|
if (! in_array($this->_table_name,Config::$no_site_id_tables))
|
||||||
$this->where($this->_table_name.'.site_id','=',Config::siteid());
|
$this->where($this->_object_name.'.site_id','=',Config::siteid());
|
||||||
|
|
||||||
return parent::_build($type);
|
return parent::_build($type);
|
||||||
}
|
}
|
||||||
@ -58,12 +58,22 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override KH's ORM has() function, to include our site_id in the query.
|
* Override KH's ORM count_relations() function, to include our site_id in the query.
|
||||||
*
|
*
|
||||||
* This is a copy of KH's ORM has() function, with the addition of a where
|
* This is a copy of KH's ORM count_relations() function, with the addition of a where
|
||||||
* clause to include the site id.
|
* clause to include the site id.
|
||||||
*/
|
*/
|
||||||
public function has($alias, $far_keys) {
|
public function count_relations($alias, $far_keys = NULL)
|
||||||
|
{
|
||||||
|
if ($far_keys === NULL)
|
||||||
|
{
|
||||||
|
return (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found'))
|
||||||
|
->from($this->_has_many[$alias]['through'])
|
||||||
|
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
||||||
|
->where('site_id', '=', Config::siteid())
|
||||||
|
->execute($this->_db)->get('records_found');
|
||||||
|
}
|
||||||
|
|
||||||
$far_keys = ($far_keys instanceof ORM) ? $far_keys->pk() : $far_keys;
|
$far_keys = ($far_keys instanceof ORM) ? $far_keys->pk() : $far_keys;
|
||||||
|
|
||||||
// We need an array to simplify the logic
|
// We need an array to simplify the logic
|
||||||
@ -71,9 +81,9 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
|
|
||||||
// Nothing to check if the model isn't loaded or we don't have any far_keys
|
// Nothing to check if the model isn't loaded or we don't have any far_keys
|
||||||
if ( ! $far_keys OR ! $this->_loaded)
|
if ( ! $far_keys OR ! $this->_loaded)
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
$count = (int) DB::select(array('COUNT("*")', 'records_found'))
|
$count = (int) DB::select(array(DB::expr('COUNT(*)'), 'records_found'))
|
||||||
->from($this->_has_many[$alias]['through'])
|
->from($this->_has_many[$alias]['through'])
|
||||||
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
||||||
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
|
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
|
||||||
@ -81,32 +91,7 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
->execute($this->_db)->get('records_found');
|
->execute($this->_db)->get('records_found');
|
||||||
|
|
||||||
// Rows found need to match the rows searched
|
// Rows found need to match the rows searched
|
||||||
return $count === count($far_keys);
|
return (int) $count;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests if this object has a relationship to a different model,
|
|
||||||
* or an array of different models.
|
|
||||||
*
|
|
||||||
* // Check for any of the following roles
|
|
||||||
* $model->has('roles', array(1, 2, 3, 4));
|
|
||||||
*
|
|
||||||
* @param string $alias Alias of the has_many "through" relationship
|
|
||||||
* @param mixed $far_keys An array of primary keys
|
|
||||||
* @return Database_Result
|
|
||||||
*/
|
|
||||||
public function has_any($alias, array $far_keys) {
|
|
||||||
// Nothing to check if the model isn't loaded or we don't have any far_keys
|
|
||||||
if ( ! $far_keys)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// Rows found need to match the rows searched
|
|
||||||
return (int) DB::select(array('COUNT("*")', 'records_found'))
|
|
||||||
->from($this->_has_many[$alias]['through'])
|
|
||||||
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
|
||||||
->where($this->_has_many[$alias]['far_key'], 'IN', $far_keys)
|
|
||||||
->where('site_id', '=', Config::siteid())
|
|
||||||
->execute($this->_db)->get('records_found');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _where_active() {
|
protected function _where_active() {
|
||||||
@ -116,6 +101,5 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
public function where_active() {
|
public function where_active() {
|
||||||
return $this->_where_active();
|
return $this->_where_active();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -80,7 +80,7 @@ abstract class ORM_OSB extends ORM {
|
|||||||
|
|
||||||
$model->_changed[$field] = $field;
|
$model->_changed[$field] = $field;
|
||||||
|
|
||||||
$ido = ORM::factory('module')
|
$ido = ORM::factory('Module')
|
||||||
->where('name','=',$model->_table_name)
|
->where('name','=',$model->_table_name)
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
|
19
application/classes/Task.php
Normal file
19
application/classes/Task.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class extends Minions Tasks to require the site option
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class Task extends Minion_Task {
|
||||||
|
protected $_options = array(
|
||||||
|
'site'=>NULL,
|
||||||
|
'id'=>NULL,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
@ -9,7 +9,7 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Valid extends Kohana_Valid {
|
abstract class Valid extends Kohana_Valid {
|
||||||
/**
|
/**
|
||||||
* Checks if a field matches the value of another field, if it is set.
|
* Checks if a field matches the value of another field, if it is set.
|
||||||
* Field is ignored if it is blank.
|
* Field is ignored if it is blank.
|
@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
class Cache extends Kohana_Cache {
|
|
||||||
public static $default = 'apc';
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,7 +1,7 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is for rendering a breadcrumb menu.
|
* This class is for rendering a BreadCrumb menu.
|
||||||
*
|
*
|
||||||
* @package lnApp
|
* @package lnApp
|
||||||
* @subpackage Page
|
* @subpackage Page
|
||||||
@ -10,17 +10,19 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
abstract class lnApp_Breadcrumb extends HTMLRender {
|
abstract class lnApp_BreadCrumb extends HTMLRender {
|
||||||
protected static $_data = array();
|
protected static $_data = array();
|
||||||
protected static $_spacer = ' » ';
|
protected static $_spacer = ' » ';
|
||||||
protected static $_required_keys = array('body');
|
protected static $_required_keys = array('body');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the breadcrumb path
|
* Set the BreadCrumb path
|
||||||
*
|
*
|
||||||
* @param array Block attributes
|
* @param array Block attributes
|
||||||
*/
|
*/
|
||||||
public static function set($path) {
|
public static function set($path) {
|
||||||
|
$path = strtolower($path);
|
||||||
|
|
||||||
if (is_string($path))
|
if (is_string($path))
|
||||||
static::$_data['path'] = explode('/',$path);
|
static::$_data['path'] = explode('/',$path);
|
||||||
elseif (is_array($path))
|
elseif (is_array($path))
|
||||||
@ -43,6 +45,9 @@ abstract class lnApp_Breadcrumb extends HTMLRender {
|
|||||||
* Enable specifying the URL for a path
|
* Enable specifying the URL for a path
|
||||||
*/
|
*/
|
||||||
public static function URL($path,$url,$override=TRUE) {
|
public static function URL($path,$url,$override=TRUE) {
|
||||||
|
$path = strtolower($path);
|
||||||
|
$url = strtolower($url);
|
||||||
|
|
||||||
if (isset(static::$_data['url'][$path]) AND ! $override)
|
if (isset(static::$_data['url'][$path]) AND ! $override)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -52,14 +57,14 @@ abstract class lnApp_Breadcrumb extends HTMLRender {
|
|||||||
/**
|
/**
|
||||||
* Return an instance of this class
|
* Return an instance of this class
|
||||||
*
|
*
|
||||||
* @return Breadcrumb
|
* @return BreadCrumb
|
||||||
*/
|
*/
|
||||||
public static function factory() {
|
public static function factory() {
|
||||||
return new Breadcrumb;
|
return new BreadCrumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render this Breadcrumb
|
* Render this BreadCrumb
|
||||||
*/
|
*/
|
||||||
protected function render() {
|
protected function render() {
|
||||||
$output = '<ul id="breadcrumb">';
|
$output = '<ul id="breadcrumb">';
|
@ -24,13 +24,6 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
public function __construct() {
|
public function __construct() {
|
||||||
if (defined('PHPUNITTEST'))
|
if (defined('PHPUNITTEST'))
|
||||||
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
|
$_SERVER['SERVER_NAME'] = PHPUNITTEST;
|
||||||
|
|
||||||
elseif (Kohana::$is_cli) {
|
|
||||||
if (! $site = CLI::options('site'))
|
|
||||||
throw new Kohana_Exception(_('Cant figure out the site, use --site= for CLI'));
|
|
||||||
else
|
|
||||||
$_SERVER['SERVER_NAME'] = $site['site'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,14 +37,14 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
* Work out our site ID for multiehosting
|
* Work out our site ID for multiehosting
|
||||||
*/
|
*/
|
||||||
public static function siteid() {
|
public static function siteid() {
|
||||||
return Kohana::Config('config.site.id');
|
return Kohana::$config->load('config.site.id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work out our site mode (dev,test,prod)
|
* Work out our site mode (dev,test,prod)
|
||||||
*/
|
*/
|
||||||
public static function sitemode() {
|
public static function sitemode() {
|
||||||
return Kohana::Config('config.site.mode');
|
return Kohana::$config->load('config.site.mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sitemodeverbose() {
|
public static function sitemodeverbose() {
|
||||||
@ -66,13 +59,13 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function submode() {
|
public static function submode() {
|
||||||
$submode = Kohana::Config('config.debug.submode');
|
$submode = Kohana::$config->load('config.debug.submode');
|
||||||
|
|
||||||
return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE;
|
return (isset($submode[Request::$client_ip])) ? $submode[Request::$client_ip] : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sitename() {
|
public static function sitename() {
|
||||||
return Kohana::Config('config.site.name');
|
return Kohana::$config->load('config')->site_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called in Invoice/Emailing to embed the file.
|
// Called in Invoice/Emailing to embed the file.
|
||||||
@ -98,21 +91,21 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
* Return our caching mechanism
|
* Return our caching mechanism
|
||||||
*/
|
*/
|
||||||
public static function cachetype() {
|
public static function cachetype() {
|
||||||
return is_null(Kohana::config('config.cache_type')) ? 'file' : Kohana::config('config.cache_type');
|
return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a date using a site configured format
|
* Show a date using a site configured format
|
||||||
*/
|
*/
|
||||||
public static function date($date) {
|
public static function date($date) {
|
||||||
return $date ? date(Kohana::config('config.date_format'),$date) : '>Not Set<';
|
return $date ? date(Kohana::$config->load('config')->date_format,$date) : '>Not Set<';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a date using a site configured format
|
* Show a date using a site configured format
|
||||||
*/
|
*/
|
||||||
public static function time($date) {
|
public static function time($date) {
|
||||||
return date(Kohana::config('config.time_format'),$date);
|
return date(Kohana::$config->load('config')->time_format,$date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +122,7 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
* @return mixed|array - Email to send test emails to
|
* @return mixed|array - Email to send test emails to
|
||||||
*/
|
*/
|
||||||
public static function testmail($template) {
|
public static function testmail($template) {
|
||||||
$config = Kohana::config('config.email_admin_only');
|
$config = Kohana::$config->load('config')->email_admin_only;
|
||||||
|
|
||||||
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
|
if (is_null($config) OR ! is_array($config) OR empty($config[$template]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -138,7 +131,7 @@ abstract class lnApp_Config extends Kohana_Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function theme() {
|
public static function theme() {
|
||||||
return Kohana::config('config.theme');
|
return Kohana::$config->load('config')->theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -52,7 +52,7 @@ abstract class lnApp_Controller_Default extends Controller {
|
|||||||
*/
|
*/
|
||||||
protected function _auth_required() {
|
protected function _auth_required() {
|
||||||
// If our global configurable is disabled, then continue
|
// If our global configurable is disabled, then continue
|
||||||
if (! Kohana::Config('config.method_security'))
|
if (! Kohana::$config->load('config')->method_security)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
|
return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
|
||||||
@ -71,11 +71,11 @@ abstract class lnApp_Controller_Default extends Controller {
|
|||||||
|
|
||||||
// For no AJAX/JSON requests, display an access page
|
// For no AJAX/JSON requests, display an access page
|
||||||
} elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) {
|
} elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) {
|
||||||
Request::current()->redirect('login/noaccess');
|
HTTP::redirect('login/noaccess');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Session::instance()->set('afterlogin',Request::detect_uri());
|
Session::instance()->set('afterlogin',Request::detect_uri());
|
||||||
Request::current()->redirect($this->noauth_redirect);
|
HTTP::redirect($this->noauth_redirect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ abstract class lnApp_Controller_Default extends Controller {
|
|||||||
parent::after();
|
parent::after();
|
||||||
|
|
||||||
// Generate and check the ETag for this file
|
// Generate and check the ETag for this file
|
||||||
$this->response->check_cache(NULL,$this->request);
|
$this->check_cache(sha1($this->response->body()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
70
application/classes/lnApp/Controller/Login.php
Normal file
70
application/classes/lnApp/Controller/Login.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides login capability
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @subpackage Page/Login
|
||||||
|
* @category Controllers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
* @also [logout]
|
||||||
|
*/
|
||||||
|
class lnApp_Controller_Login extends Controller_TemplateDefault {
|
||||||
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
|
public function action_index() {
|
||||||
|
// If user already signed-in
|
||||||
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
|
// Redirect to the user account
|
||||||
|
HTTP::redirect('user/welcome/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is a post and $_POST is not empty
|
||||||
|
if ($_POST) {
|
||||||
|
// Store our details in a session key
|
||||||
|
Session::instance()->set(Kohana::$config->load('auth')->session_key,$_POST['username']);
|
||||||
|
Session::instance()->set('password',$_POST['password']);
|
||||||
|
|
||||||
|
// If the post data validates using the rules setup in the user model
|
||||||
|
if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
|
||||||
|
// Redirect to the user account
|
||||||
|
if ($redir = Session::instance()->get('afterlogin')) {
|
||||||
|
Session::instance()->delete('afterlogin');
|
||||||
|
HTTP::redirect($redir);
|
||||||
|
|
||||||
|
} else
|
||||||
|
HTTP::redirect('user/welcome/index');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SystemMessage::add(array(
|
||||||
|
'title'=>_('Invalid username or password'),
|
||||||
|
'type'=>'error',
|
||||||
|
'body'=>_('The username or password was invalid.')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>_('Login to server'),
|
||||||
|
'body'=>View::factory('login'),
|
||||||
|
'style'=>array('css/login.css'=>'screen'),
|
||||||
|
));
|
||||||
|
|
||||||
|
Script::add(array('type'=>'stdin','data'=>'
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#ajxbody").click(function() {$("#ajBODY").load("'.$this->request->uri().'/"); return false;});
|
||||||
|
});'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function action_noaccess() {
|
||||||
|
SystemMessage::add(array(
|
||||||
|
'title'=>_('No access to requested resource'),
|
||||||
|
'type'=>'error',
|
||||||
|
'body'=>_('You do not have access to the requested resource, please contact your administrator.')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -19,10 +19,10 @@ class lnApp_Controller_Logout extends Controller {
|
|||||||
Auth::instance()->logout();
|
Auth::instance()->logout();
|
||||||
$ao->log('Logged Out');
|
$ao->log('Logged Out');
|
||||||
|
|
||||||
Request::current()->redirect('login');
|
HTTP::redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
Request::current()->redirect('welcome/index');
|
HTTP::redirect('welcome/index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -52,7 +52,8 @@ abstract class lnApp_Controller_Media extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate and check the ETag for this file
|
// Generate and check the ETag for this file
|
||||||
$this->response->check_cache(NULL,$this->request);
|
if (Kohana::$environment === Kohana::PRODUCTION OR Kohana::$config->load('debug')->etag)
|
||||||
|
$this->check_cache(sha1($this->response->body()));
|
||||||
|
|
||||||
// Set the proper headers to allow caching
|
// Set the proper headers to allow caching
|
||||||
$this->response->headers('Content-Type',File::mime_by_ext($ext));
|
$this->response->headers('Content-Type',File::mime_by_ext($ext));
|
@ -61,7 +61,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
*/
|
*/
|
||||||
protected function _auth_required() {
|
protected function _auth_required() {
|
||||||
// If our global configurable is disabled, then continue
|
// If our global configurable is disabled, then continue
|
||||||
if (! Kohana::Config('config.method_security'))
|
if (! Kohana::$config->load('config')->method_security)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) ||
|
return (($this->auth_required !== FALSE && Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__) === FALSE) ||
|
||||||
@ -83,7 +83,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actions that start with ajax, should only be ajax
|
// Actions that start with ajax, should only be ajax
|
||||||
if (! Kohana::Config('debug.ajax') AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax())
|
if (! Kohana::$config->load('debug')->ajax AND preg_match('/^ajax/',Request::current()->action()) AND ! Request::current()->is_ajax())
|
||||||
die();
|
die();
|
||||||
|
|
||||||
parent::before();
|
parent::before();
|
||||||
@ -108,11 +108,11 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
echo _('You dont have enough permissions.');
|
echo _('You dont have enough permissions.');
|
||||||
die();
|
die();
|
||||||
} else
|
} else
|
||||||
Request::current()->redirect('login/noaccess');
|
HTTP::redirect('login/noaccess');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Session::instance()->set('afterlogin',Request::detect_uri());
|
Session::instance()->set('afterlogin',Request::detect_uri());
|
||||||
Request::current()->redirect($this->noauth_redirect);
|
HTTP::redirect($this->noauth_redirect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind our template meta variable
|
// Bind our template meta variable
|
||||||
$this->meta = new meta;
|
$this->meta = new Meta;
|
||||||
View::bind_global('meta',$this->meta);
|
View::bind_global('meta',$this->meta);
|
||||||
|
|
||||||
// Add our logo
|
// Add our logo
|
||||||
@ -159,10 +159,10 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
|
|
||||||
if ($this->auto_render) {
|
if ($this->auto_render) {
|
||||||
// Application Title
|
// Application Title
|
||||||
if ($mo=ORM::factory('module',array('name'=>Request::current()->controller())) AND $mo->loaded())
|
if ($mo=ORM::factory('Module',array('name'=>Request::current()->controller())) AND $mo->loaded())
|
||||||
$this->meta->title = sprintf('%s: %s',Kohana::Config('config.appname'),$mo->display('name'));
|
$this->meta->title = sprintf('%s: %s',Kohana::$config->load('config')->appname,$mo->display('name'));
|
||||||
else
|
else
|
||||||
$this->meta->title = Kohana::Config('config.appname');
|
$this->meta->title = Kohana::$config->load('config')->appname;
|
||||||
$this->template->title = '';
|
$this->template->title = '';
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
@ -196,7 +196,7 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
$this->response->bodyadd(Style::factory());
|
$this->response->bodyadd(Style::factory());
|
||||||
|
|
||||||
// Since we are ajax, we should re-render the breadcrumb
|
// Since we are ajax, we should re-render the breadcrumb
|
||||||
Session::instance()->set('breadcrumb',(string)Breadcrumb::factory());
|
Session::instance()->set('breadcrumb',(string)BreadCrumb::factory());
|
||||||
$this->response->bodyadd(Script::add(array('type'=>'stdin','data'=>'$().ready($("#ajCONTROL").load("'.URL::site('welcome/breadcrumb').'",null,function(x,s,r) {}));')));
|
$this->response->bodyadd(Script::add(array('type'=>'stdin','data'=>'$().ready($("#ajCONTROL").load("'.URL::site('welcome/breadcrumb').'",null,function(x,s,r) {}));')));
|
||||||
|
|
||||||
// In case there any javascript for this render.
|
// In case there any javascript for this render.
|
||||||
@ -209,8 +209,8 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
parent::after();
|
parent::after();
|
||||||
|
|
||||||
// Generate and check the ETag for this file
|
// Generate and check the ETag for this file
|
||||||
if (Kohana::$environment === Kohana::PRODUCTION)
|
if (Kohana::$environment === Kohana::PRODUCTION OR Kohana::$config->load('debug')->etag)
|
||||||
$this->response->check_cache(NULL,$this->request);
|
$this->check_cache(sha1($this->response->body()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,15 +258,17 @@ abstract class lnApp_Controller_TemplateDefault extends Controller_Template {
|
|||||||
public function viewpath($plugin='') {
|
public function viewpath($plugin='') {
|
||||||
$request = Request::current();
|
$request = Request::current();
|
||||||
|
|
||||||
$path = '';
|
$path = $request->controller();
|
||||||
$path .= $request->controller();
|
|
||||||
if ($request->directory())
|
if ($request->directory())
|
||||||
$path .= ($path ? '/' : '').$request->directory();
|
$path .= ($path ? '/' : '').$request->directory();
|
||||||
|
|
||||||
if ($plugin)
|
if ($plugin)
|
||||||
$path .= ($path ? '/' : '').$plugin;
|
$path .= ($path ? '/' : '').$plugin;
|
||||||
$path .= ($path ? '/' : '').$request->action();;
|
|
||||||
|
|
||||||
return $path;
|
$path .= ($path ? '/' : '').$request->action();
|
||||||
|
|
||||||
|
return strtolower($path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user