Updated OSB to work with KH 3.1

This commit is contained in:
Deon George
2011-05-14 17:35:33 +10:00
parent 6d256839fc
commit 9dda9f43f4
42 changed files with 397 additions and 347 deletions

View File

@@ -35,19 +35,19 @@ class Auth_OSB extends Auth_ORM {
if (! empty($role)) {
// Get the module details
$module = ORM::factory('module',array('name'=>Request::instance()->controller));
$module = ORM::factory('module',array('name'=>Request::current()->controller()));
if (! $module->loaded() OR ! $module->status) {
SystemMessage::add(array(
'title'=>'Module is not defined or active in the Database',
'type'=>'warning',
'body'=>sprintf('Module not defined: %s',Request::instance()->controller),
'body'=>sprintf('Module not defined: %s',Request::current()->controller()),
));
} else {
if (Request::instance()->directory)
$method_name = sprintf('%s_%s',Request::instance()->directory,Request::instance()->action);
if (Request::current()->directory())
$method_name = sprintf('%s_%s',Request::current()->directory(),Request::current()->action());
else
$method_name = Request::instance()->action;
$method_name = Request::current()->action();
// Get the method number
$method = ORM::factory('module_method',array('module_id'=>$module->id,'name'=>$method_name));
@@ -55,7 +55,7 @@ class Auth_OSB extends Auth_ORM {
SystemMessage::add(array(
'title'=>'Method is not defined or active in the Database',
'type'=>'warning',
'body'=>sprintf('Method not defined: %s for %s',Request::instance()->action,$module->name),
'body'=>sprintf('Method not defined: %s for %s',Request::current()->action(),$module->name),
));
} else {
@@ -93,7 +93,7 @@ class Auth_OSB extends Auth_ORM {
'title'=>'Debug',
'type'=>'debug',
'body'=>sprintf('A-User: <b>%s</b>, Module: <b>%s</b>, Method: <b>%s</b>, Role: <b>%s</b>, Status: <b>%s</b>, Data: <b>%s</b>',
$user->username,Request::instance()->controller,Request::instance()->action,$role,$status,$debug)));
$user->username,Request::current()->controller(),Request::current()->action(),$role,$status,$debug)));
// There is no role, so the method should be allowed to run as anonymous
} else {
@@ -102,7 +102,7 @@ class Auth_OSB extends Auth_ORM {
'title'=>'Debug',
'type'=>'debug',
'body'=>sprintf('B-User: <b>%s</b>, Module: <b>%s</b>, Method: <b>%s</b>, Status: <b>%s</b>, Data: <b>%s</b>',
$user->username,Request::instance()->controller,Request::instance()->action,'No Role Default Access',$debug)));
$user->username,Request::current()->controller(),Request::current()->action(),'No Role Default Access',$debug)));
$status = TRUE;
}
@@ -149,7 +149,7 @@ class Auth_OSB extends Auth_ORM {
*/
private function _get_token_user($token) {
$mmto = ORM::factory('module_method_token',array('token'=>$token));
$request = Request::instance();
$request = Request::current();
$user = FALSE;
if ($mmto->loaded()) {
@@ -196,7 +196,7 @@ class Auth_OSB extends Auth_ORM {
$username = $user;
// Load the user
$user = ORM::factory('user');
$user = ORM::factory('account');
$user->where($user->unique_key($username), '=', $username)->find();
}
@@ -232,8 +232,10 @@ class Auth_OSB extends Auth_ORM {
$orm = ORM::factory($t)
->where($c,'=',$oldsess);
$orm->session_id = session_id();
$orm->save_all();
// @todo There must be a way that ORM can update multiple records with 1 SQL
foreach ($orm->find_all() as $o)
$o->set('session_id',session_id())
->update();
}
}