Updated OSB to work with KH 3.1
This commit is contained in:
parent
6d256839fc
commit
9dda9f43f4
22
application/classes/auth/orm.php
Normal file
22
application/classes/auth/orm.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Auth
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Auth_ORM extends Kohana_Auth_ORM {
|
||||||
|
// Override Kohana Auth requirement to have a hash_key
|
||||||
|
public function hash($str) {
|
||||||
|
if ($this->_config['hash_method'] == 'md5')
|
||||||
|
return md5($str);
|
||||||
|
else
|
||||||
|
return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -11,6 +11,14 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
abstract class Controller_lnApp_Default extends Controller {
|
abstract class Controller_lnApp_Default extends Controller {
|
||||||
|
/**
|
||||||
|
* The variable that our output is stored in
|
||||||
|
*/
|
||||||
|
protected $output = NULL;
|
||||||
|
/**
|
||||||
|
* @var string page media route as per [Route]
|
||||||
|
*/
|
||||||
|
protected $mediaroute = 'default/media';
|
||||||
/**
|
/**
|
||||||
* Controls access to this controller.
|
* Controls access to this controller.
|
||||||
* Can be set to a string or an array, for example 'login' or array('login', 'admin')
|
* Can be set to a string or an array, for example 'login' or array('login', 'admin')
|
||||||
@ -48,8 +56,8 @@ abstract class Controller_lnApp_Default extends Controller {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
|
return (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
|
||||||
(is_array($this->secure_actions) && array_key_exists($this->request->action,$this->secure_actions) &&
|
(is_array($this->secure_actions) && array_key_exists($this->request->action(),$this->secure_actions) &&
|
||||||
Auth::instance()->logged_in($this->secure_actions[$this->request->action]) === FALSE));
|
Auth::instance()->logged_in($this->secure_actions[$this->request->action()]) === FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function before() {
|
public function before() {
|
||||||
@ -58,16 +66,16 @@ abstract class Controller_lnApp_Default extends Controller {
|
|||||||
// Check user auth and role
|
// Check user auth and role
|
||||||
if ($this->_auth_required()) {
|
if ($this->_auth_required()) {
|
||||||
// For AJAX/JSON requests, authorisation is controlled in the method.
|
// For AJAX/JSON requests, authorisation is controlled in the method.
|
||||||
if (Request::$is_ajax && $this->request->action === 'json') {
|
if (Request::current()->is_ajax() && $this->request->action() === 'json') {
|
||||||
// Nothing required.
|
// Nothing required.
|
||||||
|
|
||||||
// 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::instance()->redirect('login/noaccess');
|
Request::current()->redirect('login/noaccess');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Session::instance()->set('afterlogin',Request::instance()->uri());
|
Session::instance()->set('afterlogin',Request::detect_uri());
|
||||||
Request::instance()->redirect($this->noauth_redirect);
|
Request::current()->redirect($this->noauth_redirect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,26 +16,20 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
// If user already signed-in
|
// If user already signed-in
|
||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a post and $_POST is not empty
|
// If there is a post and $_POST is not empty
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
// Instantiate a new user
|
|
||||||
$user = ORM::factory('account');
|
|
||||||
|
|
||||||
// Check Auth
|
|
||||||
$status = $user->login($_POST);
|
|
||||||
|
|
||||||
// If the post data validates using the rules setup in the user model
|
// If the post data validates using the rules setup in the user model
|
||||||
if ($status) {
|
if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
if ($redir = Session::instance()->get('afterlogin')) {
|
if ($redir = Session::instance()->get('afterlogin')) {
|
||||||
Session::instance()->delete('afterlogin');
|
Session::instance()->delete('afterlogin');
|
||||||
Request::instance()->redirect($redir);
|
Request::current()->redirect($redir);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
@ -53,7 +47,6 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$this->template->control = HTML::anchor($this->request->uri(),'Login',array('id'=>'ajxbody'));
|
$this->template->control = HTML::anchor($this->request->uri(),'Login',array('id'=>'ajxbody'));
|
||||||
$this->template->content = Block::factory();
|
|
||||||
|
|
||||||
Script::add(array('type'=>'stdin','data'=>'
|
Script::add(array('type'=>'stdin','data'=>'
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -66,7 +59,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
// If user already signed-in
|
// If user already signed-in
|
||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instantiate a new user
|
// Instantiate a new user
|
||||||
@ -112,12 +105,10 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
'title'=>_('Register'),
|
'title'=>_('Register'),
|
||||||
'body'=>View::factory('bregister')
|
'body'=>View::factory('bregister')
|
||||||
->set('account',$account)
|
->set('account',$account)
|
||||||
->set('errors',$account->validate()->errors()),
|
->set('errors',$account->validation()->errors('form/register')),
|
||||||
'style'=>array('css/bregister.css'=>'screen'),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->control = HTML::anchor($this->request->uri(),'Register',array('id'=>'ajxbody'));
|
$this->template->control = HTML::anchor($this->request->uri(),'Register',array('id'=>'ajxbody'));
|
||||||
$this->template->content = Block::factory();
|
|
||||||
$this->template->left = HTML::anchor('login','Login').'...';
|
$this->template->left = HTML::anchor('login','Login').'...';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +119,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
// If user already signed-in
|
// If user already signed-in
|
||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
// Redirect to the user account
|
// Redirect to the user account
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user posted their details to reset their password
|
// If the user posted their details to reset their password
|
||||||
@ -172,7 +163,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
// Redirect to our password reset, the Auth will validate the token.
|
// Redirect to our password reset, the Auth will validate the token.
|
||||||
} elseif (! empty($_REQUEST['token'])) {
|
} elseif (! empty($_REQUEST['token'])) {
|
||||||
Request::instance()->redirect(sprintf('user/account/resetpassword?token=%s',$_REQUEST['token']));
|
Request::current()->redirect(sprintf('user/account/resetpassword?token=%s',$_REQUEST['token']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show our token screen even if the email was invalid.
|
// Show our token screen even if the email was invalid.
|
||||||
@ -183,7 +174,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
'style'=>array('css/login.css'=>'screen'),
|
'style'=>array('css/login.css'=>'screen'),
|
||||||
));
|
));
|
||||||
else
|
else
|
||||||
Request::instance()->redirect('login');
|
Request::current()->redirect('login');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
@ -192,13 +183,9 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
|
|||||||
'style'=>array('css/login.css'=>'screen'),
|
'style'=>array('css/login.css'=>'screen'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_noaccess() {
|
public function action_noaccess() {
|
||||||
$this->template->content = ' ';
|
|
||||||
|
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>_('No access to requested resource'),
|
'title'=>_('No access to requested resource'),
|
||||||
'type'=>'error',
|
'type'=>'error',
|
||||||
|
@ -17,10 +17,10 @@ class Controller_lnApp_Logout extends Controller {
|
|||||||
if (Auth::instance()->logged_in()!= 0) {
|
if (Auth::instance()->logged_in()!= 0) {
|
||||||
Auth::instance()->logout();
|
Auth::instance()->logout();
|
||||||
|
|
||||||
Request::instance()->redirect('login');
|
Request::current()->redirect('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -15,10 +15,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
* @var string page template
|
* @var string page template
|
||||||
*/
|
*/
|
||||||
public $template = 'lnapp/default';
|
public $template = 'lnapp/default';
|
||||||
/**
|
|
||||||
* @var string page media route as per [Route]
|
|
||||||
*/
|
|
||||||
protected $mediaroute = 'default/media';
|
|
||||||
/**
|
/**
|
||||||
* @var object meta object information as per [meta]
|
* @var object meta object information as per [meta]
|
||||||
*/
|
*/
|
||||||
@ -62,8 +58,8 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
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) ||
|
||||||
(is_array($this->secure_actions) && array_key_exists($this->request->action,$this->secure_actions) &&
|
(is_array($this->secure_actions) && array_key_exists($this->request->action(),$this->secure_actions) &&
|
||||||
Auth::instance()->logged_in($this->secure_actions[$this->request->action],get_class($this).'|'.__METHOD__) === FALSE));
|
Auth::instance()->logged_in($this->secure_actions[$this->request->action()],get_class($this).'|'.__METHOD__) === FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +70,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
*/
|
*/
|
||||||
public function before() {
|
public function before() {
|
||||||
// Do not template media files
|
// Do not template media files
|
||||||
if ($this->request->action === 'media') {
|
if ($this->request->action() === 'media') {
|
||||||
$this->auto_render = FALSE;
|
$this->auto_render = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,7 +80,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
// Check user auth and role
|
// Check user auth and role
|
||||||
if ($this->_auth_required()) {
|
if ($this->_auth_required()) {
|
||||||
if (Kohana::$is_cli)
|
if (Kohana::$is_cli)
|
||||||
throw new Kohana_Exception('Cant run :method, authentication not possible',array(':method'=>$this->request->action));
|
throw new Kohana_Exception('Cant run :method, authentication not possible',array(':method'=>$this->request->action()));
|
||||||
|
|
||||||
// If auth is required and the user is logged in, then they dont have access.
|
// If auth is required and the user is logged in, then they dont have access.
|
||||||
// (We have already checked authorisation.)
|
// (We have already checked authorisation.)
|
||||||
@ -93,24 +89,24 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>_('Insufficient Access'),
|
'title'=>_('Insufficient Access'),
|
||||||
'type'=>'debug',
|
'type'=>'debug',
|
||||||
'body'=>Kohana::debug(array('required'=>$this->auth_required,'action'=>$this->request->action,'user'=>Auth::instance()->get_user()->username)),
|
'body'=>Kohana::debug(array('required'=>$this->auth_required,'action'=>$this->request->action(),'user'=>Auth::instance()->get_user()->username)),
|
||||||
));
|
));
|
||||||
|
|
||||||
// @todo Login No Access redirects are not handled in JS?
|
// @todo Login No Access redirects are not handled in JS?
|
||||||
if (Request::$is_ajax) {
|
if ($this->request->is_ajax()) {
|
||||||
echo _('You dont have enough permissions.');
|
echo _('You dont have enough permissions.');
|
||||||
die();
|
die();
|
||||||
} else
|
} else
|
||||||
Request::instance()->redirect('login/noaccess');
|
Request::current()->redirect('login/noaccess');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Session::instance()->set('afterlogin',Request::instance()->uri());
|
Session::instance()->set('afterlogin',Request::detect_uri());
|
||||||
Request::instance()->redirect($this->noauth_redirect);
|
Request::current()->redirect($this->noauth_redirect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For AJAX calls, we dont need to render the complete page.
|
// For AJAX calls, we dont need to render the complete page.
|
||||||
if (Request::$is_ajax) {
|
if ($this->request->is_ajax()) {
|
||||||
$this->auto_render = FALSE;
|
$this->auto_render = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -181,20 +177,21 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
$this->template->footer = $this->_footer();
|
$this->template->footer = $this->_footer();
|
||||||
|
|
||||||
// For any ajax rendered actions, we'll need to capture the content and put it in the response
|
// For any ajax rendered actions, we'll need to capture the content and put it in the response
|
||||||
} elseif (Request::$is_ajax && isset($this->template->content) && ! $this->request->response) {
|
} elseif ($this->request->is_ajax() && isset($this->template->content) && ! $this->response->body()) {
|
||||||
// @todo move this formatting to a view?
|
// @todo move this formatting to a view?
|
||||||
if ($s = $this->_sysmsg() AND (string)$s) {
|
if ($s = $this->_sysmsg() AND (string)$s)
|
||||||
$this->request->response = sprintf('<table class="sysmsg"><tr><td>%s</td></tr></table>',$s);
|
$this->response->body(sprintf('<table class="sysmsg"><tr><td>%s</td></tr></table>',$s));
|
||||||
} else
|
|
||||||
$this->request->response = '';
|
|
||||||
|
|
||||||
# In case there any style sheets or scrpits for this render.
|
# In case there any style sheets or scrpits for this render.
|
||||||
$this->request->response .= Style::factory();
|
$this->response->bodyadd(Style::factory());
|
||||||
|
|
||||||
# Get the response body
|
# Get the response body
|
||||||
$this->request->response .= sprintf('<table class="content"><tr><td>%s</td></tr></table>',$this->template->content);
|
$this->response->bodyadd(sprintf('<table class="content"><tr><td>%s</td></tr></table>',$this->template->content));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($this->template->content) AND ! $this->template->content)
|
||||||
|
$this->template->content = Block::factory();
|
||||||
|
|
||||||
parent::after();
|
parent::after();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +241,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
*/
|
*/
|
||||||
final public function action_media() {
|
final public function action_media() {
|
||||||
// Generate and check the ETag for this file
|
// Generate and check the ETag for this file
|
||||||
$this->request->check_cache(sha1($this->request->uri));
|
$this->response->check_cache(NULL,$this->request);
|
||||||
|
|
||||||
// Get the file path from the request
|
// Get the file path from the request
|
||||||
$file = $this->request->param('file');
|
$file = $this->request->param('file');
|
||||||
@ -258,22 +255,22 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
|||||||
// First try and find media files for the site_id
|
// First try and find media files for the site_id
|
||||||
if ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
|
if ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
|
||||||
// Send the file content as the response
|
// Send the file content as the response
|
||||||
$this->request->response = file_get_contents($f);
|
$this->response->body(file_get_contents($f));
|
||||||
|
|
||||||
// If not found try a default media file
|
// If not found try a default media file
|
||||||
} elseif ($f = Kohana::find_file('media', $file, $ext)) {
|
} elseif ($f = Kohana::find_file('media', $file, $ext)) {
|
||||||
// Send the file content as the response
|
// Send the file content as the response
|
||||||
$this->request->response = file_get_contents($f);
|
$this->response->body(file_get_contents($f));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Return a 404 status
|
// Return a 404 status
|
||||||
$this->request->status = 404;
|
$this->response->status(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the proper headers to allow caching
|
// Set the proper headers to allow caching
|
||||||
$this->request->headers['Content-Type'] = File::mime_by_ext($ext);
|
$this->response->headers('Content-Type',File::mime_by_ext($ext));
|
||||||
$this->request->headers['Content-Length'] = filesize($f);
|
$this->response->headers('Content-Length',(string)filesize($f));
|
||||||
$this->request->headers['Last-Modified'] = date('r', filemtime($f));
|
$this->response->headers('Last-Modified',date('r', filemtime($f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -11,22 +11,20 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Controller_lnApp_Tree extends Controller_Default {
|
class Controller_lnApp_Tree extends Controller_Default {
|
||||||
// Our tree data
|
|
||||||
protected $treedata;
|
|
||||||
/**
|
/**
|
||||||
* @var string page media route as per [Route]
|
* @var string page media route as per [Route]
|
||||||
*/
|
*/
|
||||||
protected static $mediaroute = 'default/media';
|
protected static $jsmediaroute = 'default/media';
|
||||||
|
|
||||||
public function after() {
|
public function after() {
|
||||||
parent::after();
|
parent::after();
|
||||||
|
|
||||||
$this->request->headers['Content-Type'] = 'application/json';
|
$this->response->headers('Content-Type','application/json');
|
||||||
$this->request->response = sprintf('[%s]',json_encode($this->treedata));
|
$this->response->body(sprintf('[%s]',json_encode($this->output)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function js() {
|
public static function js() {
|
||||||
$mediapath = Route::get(static::$mediaroute);
|
$mediapath = Route::get(static::$jsmediaroute);
|
||||||
|
|
||||||
return '
|
return '
|
||||||
<div id="tree" class=""></div>
|
<div id="tree" class=""></div>
|
||||||
|
@ -23,7 +23,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
*/
|
*/
|
||||||
public function action_json($id=null) {
|
public function action_json($id=null) {
|
||||||
if ($this->_auth_required()) {
|
if ($this->_auth_required()) {
|
||||||
$this->treedata = array('attr'=>array('id'=>'a_login'),
|
$this->output = array('attr'=>array('id'=>'a_login'),
|
||||||
'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('/login'))));
|
'data'=>array('title'=>_('Please Login').'...','attr'=>array('id'=>'N_login','href'=>URL::site('/login'))));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -74,10 +74,10 @@ class Controller_Tree extends Controller_lnApp_Tree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->treedata = array();
|
$this->output = array();
|
||||||
|
|
||||||
foreach ($data as $branch) {
|
foreach ($data as $branch) {
|
||||||
array_push($this->treedata,array(
|
array_push($this->output,array(
|
||||||
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
|
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
|
||||||
'state'=>$branch['state'],
|
'state'=>$branch['state'],
|
||||||
'data'=>array('title'=>$branch['name']),
|
'data'=>array('title'=>$branch['name']),
|
||||||
|
@ -19,11 +19,8 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
|||||||
'footer'=>'lnApp makes building websites easy! '.time(),
|
'footer'=>'lnApp makes building websites easy! '.time(),
|
||||||
));
|
));
|
||||||
|
|
||||||
if (Auth::instance()->logged_in()) {
|
// @todo Show a login/logout on the breadcrumb
|
||||||
$this->template->control = HTML::anchor('/logout',_('Logout'),array('id'=>'ajxbody'));
|
if (! Auth::instance()->logged_in()) {
|
||||||
} else {
|
|
||||||
$this->template->control = HTML::anchor('/login',_('Login'),array('id'=>'ajxbody'));
|
|
||||||
|
|
||||||
Script::add(array('type'=>'stdin','data'=>'
|
Script::add(array('type'=>'stdin','data'=>'
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#ajxbody").click(function() {$("#ajBODY").load("'.URL::site('/login').'",null,function(x,s,r) {}); return false;});
|
$("#ajxbody").click(function() {$("#ajBODY").load("'.URL::site('/login').'",null,function(x,s,r) {}); return false;});
|
||||||
@ -31,8 +28,6 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
|||||||
});'
|
});'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
30
application/classes/db.php
Normal file
30
application/classes/db.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's DB
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class DB extends Kohana_DB {
|
||||||
|
// Add the site_id to the delete query
|
||||||
|
public static function delete($table = NULL)
|
||||||
|
{
|
||||||
|
$db = new Database_Query_Builder_Delete($table);
|
||||||
|
|
||||||
|
return $db->where($table.'.site_id','=',Config::siteid());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the site_id to the update query
|
||||||
|
final public static function update($table = NULL)
|
||||||
|
{
|
||||||
|
$db = new Database_Query_Builder_Update($table);
|
||||||
|
|
||||||
|
return $db->where($table.'.site_id','=',Config::siteid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
19
application/classes/form.php
Normal file
19
application/classes/form.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Form
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Form extends Kohana_Form {
|
||||||
|
// Enable 3.0 features, default to current URI for empty Form::open()
|
||||||
|
public static function open($action = NULL, array $attributes = NULL) {
|
||||||
|
return parent::open(is_null($action) ? Request::detect_uri() : $action,$attributes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
30
application/classes/http/exception/404.php
Normal file
30
application/classes/http/exception/404.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's 404 Exception
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
|
||||||
|
public function __construct($message, array $variables = NULL, $code = 0)
|
||||||
|
{
|
||||||
|
set_exception_handler(array(get_class($this),'handler'));
|
||||||
|
parent::__construct($message, $variables, (int) $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function handler(Exception $e)
|
||||||
|
{
|
||||||
|
SystemMessage::add(array(
|
||||||
|
'title'=>_('Page not found'),
|
||||||
|
'type'=>'error',
|
||||||
|
'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
|
||||||
|
));
|
||||||
|
|
||||||
|
Request::factory()->redirect('/welcome');
|
||||||
|
}
|
||||||
|
}
|
@ -49,7 +49,7 @@ class lnApp_Breadcrumb extends HTMLRender {
|
|||||||
protected function render() {
|
protected function render() {
|
||||||
$output = HTML::anchor('/',_('Home'));
|
$output = HTML::anchor('/',_('Home'));
|
||||||
|
|
||||||
$data = empty(static::$_data['path']) ? explode('/',Request::instance()->uri) : static::$_data['path'];
|
$data = empty(static::$_data['path']) ? explode('/',preg_replace('/^\//','',Request::detect_uri())) : static::$_data['path'];
|
||||||
|
|
||||||
foreach ($data as $k => $v) {
|
foreach ($data as $k => $v) {
|
||||||
$output .= static::$_spacer;
|
$output .= static::$_spacer;
|
||||||
|
@ -11,7 +11,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
|
||||||
*/
|
*/
|
||||||
abstract class lnApp_Config extends Kohana {
|
abstract class lnApp_Config extends Kohana_Config {
|
||||||
/**
|
/**
|
||||||
* Return our site name
|
* Return our site name
|
||||||
*/
|
*/
|
||||||
|
76
application/classes/orm.php
Normal file
76
application/classes/orm.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's ORM
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class ORM extends Kohana_ORM {
|
||||||
|
protected $_table_names_plural = false;
|
||||||
|
private $_object_formated = array();
|
||||||
|
private $_formated = FALSE;
|
||||||
|
// Our filters used to display values in a friendly format
|
||||||
|
protected $_display_filters = array();
|
||||||
|
|
||||||
|
// Override check() so that it doesnt throw an exception.
|
||||||
|
// @todo Need to figure out how to show the items that fail validation
|
||||||
|
final public function check(Validation $extra_validation = NULL) {
|
||||||
|
// Determine if any external validation failed
|
||||||
|
$extra_errors = ($extra_validation AND ! $extra_validation->check());
|
||||||
|
|
||||||
|
// Always build a new validation object
|
||||||
|
$this->_validation();
|
||||||
|
|
||||||
|
$array = $this->_validation;
|
||||||
|
|
||||||
|
if (($this->_valid = $array->check()) === FALSE OR $extra_errors)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add our OSB site_id to each SELECT query
|
||||||
|
final protected function _build($type) {
|
||||||
|
$this->where($this->_table_name.'.site_id','=',Config::siteid());
|
||||||
|
|
||||||
|
return parent::_build($type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format fields for display purposes
|
||||||
|
*
|
||||||
|
* @param string column name
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
private function _format() {
|
||||||
|
foreach ($this->_display_filters as $column => $formats)
|
||||||
|
$this->_object_formated[$column] = $this->run_filter($column,$this->__get($column),array($column=>$formats));
|
||||||
|
|
||||||
|
$this->_formated = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a formated columns, as per the model definition
|
||||||
|
*/
|
||||||
|
public function display($column) {
|
||||||
|
// Trigger a load of the record.
|
||||||
|
$value = $this->__get($column);
|
||||||
|
|
||||||
|
// If some of our fields need to be formated for display purposes.
|
||||||
|
if ($this->_loaded AND ! $this->_formated AND $this->_display_filters)
|
||||||
|
$this->_format();
|
||||||
|
|
||||||
|
if (isset($this->_object_formated[$column]))
|
||||||
|
return $this->_object_formated[$column];
|
||||||
|
else
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -15,80 +15,32 @@ abstract class ORMOSB extends ORM {
|
|||||||
* @var string Database to connect to
|
* @var string Database to connect to
|
||||||
*/
|
*/
|
||||||
protected $_db = 'default';
|
protected $_db = 'default';
|
||||||
protected $_object_formated = array();
|
|
||||||
protected $_formated = FALSE;
|
|
||||||
protected $_formats = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var boolean Database names plural configuration
|
|
||||||
*/
|
|
||||||
protected $_table_names_plural = false;
|
|
||||||
|
|
||||||
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
|
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
|
||||||
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
|
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
|
||||||
|
|
||||||
protected $_callbacks = array(
|
// @todo Rules are no longer used?
|
||||||
'id'=>array('get_next_id'),
|
public function rules() {
|
||||||
'site_id'=>array('set_site_id'),
|
return array(
|
||||||
|
'id'=>array(
|
||||||
|
array('ORMOSB::get_next_id',array(':validation',':model',':field')),
|
||||||
|
),
|
||||||
|
'site_id'=>array(
|
||||||
|
array('ORMOSB::set_site_id',array(':validation',':model',':field')),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Format fields for display purposes
|
|
||||||
*
|
|
||||||
* @param string column name
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
protected function _format() {
|
|
||||||
$format = Validate::factory($this->_object);
|
|
||||||
|
|
||||||
foreach ($this->_formats as $column => $formats)
|
|
||||||
$format->filters($column,$formats);
|
|
||||||
|
|
||||||
if ($format->check())
|
|
||||||
foreach ($format as $column => $value)
|
|
||||||
$this->_object_formated[$column] = $value;
|
|
||||||
|
|
||||||
$this->_formated = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a formated columns, as per the model definition
|
|
||||||
*/
|
|
||||||
public function display($column) {
|
|
||||||
// Trigger a load of the record.
|
|
||||||
$value = $this->__get($column);
|
|
||||||
|
|
||||||
// If some of our fields need to be formated for display purposes.
|
|
||||||
if ($this->_loaded AND ! $this->_formated AND $this->_formats)
|
|
||||||
$this->_format();
|
|
||||||
|
|
||||||
if (isset($this->_object_formated[$column]))
|
|
||||||
return $this->_object_formated[$column];
|
|
||||||
else
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our child models should provide an invoice display, this is shown
|
* Our child models should provide an invoice display, this is shown
|
||||||
* on printed invoices.
|
* on printed invoices.
|
||||||
|
*
|
||||||
|
* @todo This is no longer used I think?
|
||||||
*/
|
*/
|
||||||
public function invoice_display() {
|
public function invoice_display() {
|
||||||
throw new Kohana_Exception(':module has not configured an :method, but has made the call',array(':module'=>get_class($this),'method'=>__METHOD__));
|
throw new Kohana_Exception(':module has not configured an :method, but has made the call',array(':module'=>get_class($this),'method'=>__METHOD__));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Override the _load_result() function so that our site ID is automatically
|
|
||||||
* added to the SQL query
|
|
||||||
* @todo This is not picked up by all queries. Need to investigate why
|
|
||||||
* @todo This is not being done by inserts
|
|
||||||
*/
|
|
||||||
protected function _load_result($multiple = FALSE)
|
|
||||||
{
|
|
||||||
$this->_db_builder->where($this->_table_name.'.site_id','=',Config::siteid());
|
|
||||||
|
|
||||||
return parent::_load_result($multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will enhance the [Validate::filter], since it always passes
|
* This function will enhance the [Validate::filter], since it always passes
|
||||||
* the value as the first argument and sometimes functions need that to not
|
* the value as the first argument and sometimes functions need that to not
|
||||||
@ -105,6 +57,7 @@ abstract class ORMOSB extends ORM {
|
|||||||
* @param mixed $val Value to be processed
|
* @param mixed $val Value to be processed
|
||||||
* @param string $func Name of function to call
|
* @param string $func Name of function to call
|
||||||
* @param string $arg Other arguments for the function
|
* @param string $arg Other arguments for the function
|
||||||
|
* @todo This has probably changed in KH 3.1
|
||||||
*/
|
*/
|
||||||
final public static function _filters($val,$func,$arg) {
|
final public static function _filters($val,$func,$arg) {
|
||||||
switch ($func) {
|
switch ($func) {
|
||||||
@ -121,31 +74,30 @@ abstract class ORMOSB extends ORM {
|
|||||||
* @param array Validate object
|
* @param array Validate object
|
||||||
* @param string Primary Key
|
* @param string Primary Key
|
||||||
*/
|
*/
|
||||||
public function get_next_id(Validate $array,$field) {
|
public static function get_next_id(Validation $array,$model,$field) {
|
||||||
if (! is_null($array[$field]))
|
if (! is_null($model->$field))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
$this->_changed[$field] = $field;
|
$model->_changed[$field] = $field;
|
||||||
|
|
||||||
$ido = ORM::factory('module')
|
$ido = ORM::factory('module')
|
||||||
->where('name','=',$this->_table_name)
|
->where('name','=',$model->_table_name)
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
if (! $ido->loaded())
|
if (! $ido->loaded())
|
||||||
throw new Kohana_Exception('Problem getting record_id for :table',array(':table'=>$this->_table_name));
|
throw new Kohana_Exception('Problem getting record_id for :table',array(':table'=>$model->_table_name));
|
||||||
|
|
||||||
$array[$field] = $ido->record_id->next_id($ido->id);
|
$model->$field = $ido->record_id->next_id($ido->id);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_site_id(Validate $array,$field) {
|
public static function set_site_id(Validation $array,$model,$field) {
|
||||||
if (! is_null($array[$field]))
|
if (! is_null($model->$field))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// @todo This should be a config item
|
$model->_changed[$field] = $field;
|
||||||
$this->_changed[$field] = $field;
|
$model->$field = Config::siteid();
|
||||||
$array[$field] = Config::siteid();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
19
application/classes/response.php
Normal file
19
application/classes/response.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Response
|
||||||
|
*
|
||||||
|
* @package OSB/Modifications
|
||||||
|
* @category Classes
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Response extends Kohana_Response {
|
||||||
|
// Append to the body.
|
||||||
|
public function bodyadd($content) {
|
||||||
|
$this->_body .= (string) $content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -9,21 +9,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
|
||||||
*/
|
*/
|
||||||
class Validate extends Kohana_Validate {
|
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.
|
||||||
*
|
*
|
||||||
* This function is only invoked anyway when the value is set as per
|
* @param array array of values
|
||||||
* $this->_empty_rules
|
* @param string field name
|
||||||
*
|
|
||||||
* @param string field value
|
|
||||||
* @param string field name to match
|
* @param string field name to match
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function matches_ifset($value, $match)
|
public static function matches_ifset($array, $field, $match)
|
||||||
{
|
{
|
||||||
return ($value === $this[$match]);
|
return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -9,12 +9,12 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'driver' => 'OSB',
|
'driver' => 'OSB',
|
||||||
'hash_method' => 'md5',
|
'hash_method' => 'md5',
|
||||||
'salt_pattern' => null,
|
'hash_key' => '',
|
||||||
'lifetime' => 1209600,
|
'lifetime' => 1209600,
|
||||||
'session_key' => 'auth_user',
|
'session_key' => 'auth_user',
|
||||||
'forced_key' => 'auth_forced',
|
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
@ -35,19 +35,19 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
|
|
||||||
if (! empty($role)) {
|
if (! empty($role)) {
|
||||||
// Get the module details
|
// 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) {
|
if (! $module->loaded() OR ! $module->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',
|
||||||
'type'=>'warning',
|
'type'=>'warning',
|
||||||
'body'=>sprintf('Module not defined: %s',Request::instance()->controller),
|
'body'=>sprintf('Module not defined: %s',Request::current()->controller()),
|
||||||
));
|
));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (Request::instance()->directory)
|
if (Request::current()->directory())
|
||||||
$method_name = sprintf('%s_%s',Request::instance()->directory,Request::instance()->action);
|
$method_name = sprintf('%s_%s',Request::current()->directory(),Request::current()->action());
|
||||||
else
|
else
|
||||||
$method_name = Request::instance()->action;
|
$method_name = Request::current()->action();
|
||||||
|
|
||||||
// Get the method number
|
// Get the method number
|
||||||
$method = ORM::factory('module_method',array('module_id'=>$module->id,'name'=>$method_name));
|
$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(
|
SystemMessage::add(array(
|
||||||
'title'=>'Method is not defined or active in the Database',
|
'title'=>'Method is not defined or active in the Database',
|
||||||
'type'=>'warning',
|
'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 {
|
} else {
|
||||||
@ -93,7 +93,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
'title'=>'Debug',
|
'title'=>'Debug',
|
||||||
'type'=>'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>',
|
'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
|
// There is no role, so the method should be allowed to run as anonymous
|
||||||
} else {
|
} else {
|
||||||
@ -102,7 +102,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
'title'=>'Debug',
|
'title'=>'Debug',
|
||||||
'type'=>'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>',
|
'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;
|
$status = TRUE;
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
*/
|
*/
|
||||||
private function _get_token_user($token) {
|
private function _get_token_user($token) {
|
||||||
$mmto = ORM::factory('module_method_token',array('token'=>$token));
|
$mmto = ORM::factory('module_method_token',array('token'=>$token));
|
||||||
$request = Request::instance();
|
$request = Request::current();
|
||||||
$user = FALSE;
|
$user = FALSE;
|
||||||
|
|
||||||
if ($mmto->loaded()) {
|
if ($mmto->loaded()) {
|
||||||
@ -196,7 +196,7 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
$username = $user;
|
$username = $user;
|
||||||
|
|
||||||
// Load the user
|
// Load the user
|
||||||
$user = ORM::factory('user');
|
$user = ORM::factory('account');
|
||||||
$user->where($user->unique_key($username), '=', $username)->find();
|
$user->where($user->unique_key($username), '=', $username)->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +232,10 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
$orm = ORM::factory($t)
|
$orm = ORM::factory($t)
|
||||||
->where($c,'=',$oldsess);
|
->where($c,'=',$oldsess);
|
||||||
|
|
||||||
$orm->session_id = session_id();
|
// @todo There must be a way that ORM can update multiple records with 1 SQL
|
||||||
$orm->save_all();
|
foreach ($orm->find_all() as $o)
|
||||||
|
$o->set('session_id',session_id())
|
||||||
|
->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,20 +39,20 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$ao->save();
|
$ao->save();
|
||||||
Request::instance()->redirect('login');
|
Request::current()->redirect('login');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$output = '';
|
||||||
|
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||||
|
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||||
|
|
||||||
|
if ($output)
|
||||||
|
$output = sprintf('<ul>%s</ul>',$output);
|
||||||
|
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>_('Record NOT updated'),
|
'title'=>_('Record NOT updated'),
|
||||||
'type'=>'error',
|
'type'=>'error',
|
||||||
'body'=>_('Your updates didnt pass validation.')
|
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
||||||
));
|
|
||||||
|
|
||||||
foreach ($ao->validate()->errors('form_errors') as $field => $error)
|
|
||||||
SystemMessage::add(array(
|
|
||||||
'title'=>$field,
|
|
||||||
'type'=>'error',
|
|
||||||
'body'=>$error,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,8 +61,6 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('account/password_reset')
|
'body'=>View::factory('account/password_reset')
|
||||||
->set('record',$ao),
|
->set('record',$ao),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,17 +87,17 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
|||||||
$ao->save();
|
$ao->save();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$output = '';
|
||||||
|
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||||
|
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||||
|
|
||||||
|
if ($output)
|
||||||
|
$output = sprintf('<ul>%s</ul>',$output);
|
||||||
|
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
'title'=>_('Record NOT updated'),
|
'title'=>_('Record NOT updated'),
|
||||||
'type'=>'error',
|
'type'=>'error',
|
||||||
'body'=>_('Your updates didnt pass validation.')
|
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
||||||
));
|
|
||||||
|
|
||||||
foreach ($ao->validate()->errors('form_errors') as $field => $error)
|
|
||||||
SystemMessage::add(array(
|
|
||||||
'title'=>$field,
|
|
||||||
'type'=>'error',
|
|
||||||
'body'=>$error,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +106,6 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('account/edit')
|
'body'=>View::factory('account/edit')
|
||||||
->set('record',$ao),
|
->set('record',$ao),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -18,9 +18,6 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
'service' => array(),
|
'service' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Complete our login
|
|
||||||
public function complete_login() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an account name
|
* Return an account name
|
||||||
*/
|
*/
|
||||||
|
@ -9,46 +9,5 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Auth_RoleDefault extends Model_Auth_Role {
|
class Model_Auth_RoleDefault extends Model_Auth_Role {
|
||||||
protected $_table_names_plural = false;
|
|
||||||
|
|
||||||
protected $_object_formated = array();
|
|
||||||
protected $_formated = FALSE;
|
|
||||||
protected $_formats = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Format fields for display purposes
|
|
||||||
*
|
|
||||||
* @param string column name
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
protected function _format() {
|
|
||||||
$format = Validate::factory($this->_object);
|
|
||||||
|
|
||||||
foreach ($this->_formats as $column => $formats)
|
|
||||||
$format->filters($column,$formats);
|
|
||||||
|
|
||||||
if ($format->check())
|
|
||||||
foreach ($format as $column => $value)
|
|
||||||
$this->_object_formated[$column] = $value;
|
|
||||||
|
|
||||||
$this->_formated = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a formated columns, as per the model definition
|
|
||||||
*/
|
|
||||||
public function display($column) {
|
|
||||||
// Trigger a load of the record.
|
|
||||||
$value = $this->__get($column);
|
|
||||||
|
|
||||||
// If some of our fields need to be formated for display purposes.
|
|
||||||
if ($this->_loaded AND ! $this->_formated AND $this->_formats)
|
|
||||||
$this->_format();
|
|
||||||
|
|
||||||
if (isset($this->_object_formated[$column]))
|
|
||||||
return $this->_object_formated[$column];
|
|
||||||
else
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -9,32 +9,34 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Auth_UserDefault extends Model_Auth_User {
|
class Model_Auth_UserDefault extends Model_Auth_User {
|
||||||
protected $_table_names_plural = false;
|
|
||||||
|
|
||||||
// Validation rules
|
// Validation rules
|
||||||
protected $_rules = array(
|
public function rules() {
|
||||||
|
return array(
|
||||||
'username' => array(
|
'username' => array(
|
||||||
'not_empty' => NULL,
|
array('not_empty'),
|
||||||
'min_length' => array(4),
|
array('min_length', array(':value', 4)),
|
||||||
'max_length' => array(32),
|
array('max_length', array(':value', 32)),
|
||||||
),
|
),
|
||||||
'password' => array(
|
'password' => array(
|
||||||
'not_empty' => NULL,
|
array('not_empty'),
|
||||||
'min_length' => array(5),
|
array('min_length', array(':value', 5)),
|
||||||
'max_length' => array(42),
|
array('max_length', array(':value', 32)),
|
||||||
),
|
|
||||||
'password_confirm' => array(
|
|
||||||
'matches_ifset' => array('password'),
|
|
||||||
),
|
),
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'not_empty' => NULL,
|
array('not_empty'),
|
||||||
'min_length' => array(4),
|
array('min_length', array(':value', 4)),
|
||||||
'max_length' => array(127),
|
array('max_length', array(':value', 127)),
|
||||||
'email' => NULL,
|
array('email'),
|
||||||
|
),
|
||||||
|
// @todo To test
|
||||||
|
'password_confirm' => array(
|
||||||
|
array('matches_ifset', array(':validation', 'password', 'password_confirm')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Validation callbacks
|
// Validation callbacks
|
||||||
|
// @todo _callbacks no longer used
|
||||||
protected $_callbacks = array(
|
protected $_callbacks = array(
|
||||||
'username' => array('username_available'),
|
'username' => array('username_available'),
|
||||||
'email' => array('email_available'),
|
'email' => array('email_available'),
|
||||||
@ -51,6 +53,7 @@ class Model_Auth_UserDefault extends Model_Auth_User {
|
|||||||
* here.
|
* here.
|
||||||
*
|
*
|
||||||
* We can also do some other post-login actions here.
|
* We can also do some other post-login actions here.
|
||||||
|
* @todo Maybe we can do our session update here.
|
||||||
*/
|
*/
|
||||||
public function complete_login() {}
|
public function complete_login() {}
|
||||||
|
|
||||||
|
@ -25,11 +25,9 @@ class Controller_Cart extends Controller_TemplateDefault {
|
|||||||
// @todo - this should be a global config item
|
// @todo - this should be a global config item
|
||||||
$mediapath = Route::get('default/media');
|
$mediapath = Route::get('default/media');
|
||||||
|
|
||||||
$block = new block;
|
|
||||||
|
|
||||||
// If the cart is empty, we'll return here.
|
// If the cart is empty, we'll return here.
|
||||||
if (! Cart::instance()->contents()->count_all())
|
if (! Cart::instance()->contents()->count_all())
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Empty Cart'),
|
'title'=>_('Empty Cart'),
|
||||||
'body'=>_('The cart is empty')
|
'body'=>_('The cart is empty')
|
||||||
));
|
));
|
||||||
@ -61,7 +59,8 @@ class Controller_Cart extends Controller_TemplateDefault {
|
|||||||
->set('mediapath',$mediapath);
|
->set('mediapath',$mediapath);
|
||||||
|
|
||||||
// If we are a plugin product, we might need more information
|
// If we are a plugin product, we might need more information
|
||||||
if ($item->product->prod_plugin AND method_exists($item->product->prod_plugin_file,'product_cart')) {
|
// @todo If an admin, show a system message if cart_info doesnt exist.
|
||||||
|
if ($item->product->prod_plugin AND method_exists($item->product->prod_plugin_file,'product_cart') AND Kohana::find_file('views',sprintf('%s/cart_info',strtolower($item->product->prod_plugin_file)))) {
|
||||||
$output .= View::factory(sprintf('%s/cart_info',strtolower($item->product->prod_plugin_file)));
|
$output .= View::factory(sprintf('%s/cart_info',strtolower($item->product->prod_plugin_file)));
|
||||||
|
|
||||||
// @todo JS validation will need to verify data before submission
|
// @todo JS validation will need to verify data before submission
|
||||||
@ -70,14 +69,12 @@ class Controller_Cart extends Controller_TemplateDefault {
|
|||||||
$output .= '<div>'.Form::submit('submit',_('Checkout')).'</div>';
|
$output .= '<div>'.Form::submit('submit',_('Checkout')).'</div>';
|
||||||
$output .= Form::close();
|
$output .= Form::close();
|
||||||
|
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Your Items'),
|
'title'=>_('Your Items'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->content = $block;
|
|
||||||
|
|
||||||
// Suppress our right hand tab
|
// Suppress our right hand tab
|
||||||
$this->template->right = ' ';
|
$this->template->right = ' ';
|
||||||
}
|
}
|
||||||
@ -99,7 +96,7 @@ class Controller_Cart extends Controller_TemplateDefault {
|
|||||||
echo Kohana::debug($cart->validate()->errors());
|
echo Kohana::debug($cart->validate()->errors());
|
||||||
|
|
||||||
if ($cart->saved())
|
if ($cart->saved())
|
||||||
Request::instance()->redirect('cart/index');
|
Request::current()->redirect('cart/index');
|
||||||
else
|
else
|
||||||
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
|
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,16 @@ class Model_Cart extends ORMOSB {
|
|||||||
'product'=>array(),
|
'product'=>array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_formats = array(
|
|
||||||
'recurr_schedule'=>array('StaticList_RecurSchedule::display'=>array()),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cart doesnt use the update column
|
// Cart doesnt use the update column
|
||||||
protected $_updated_column = FALSE;
|
protected $_updated_column = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters used to format the display of values into friendlier values
|
||||||
|
*/
|
||||||
|
protected $_display_filters = array(
|
||||||
|
'recurr_schedule'=>array(
|
||||||
|
array('StaticList_RecurSchedule::display',array(':value')),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -24,13 +24,12 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
// @todo - this should be a global config item
|
// @todo - this should be a global config item
|
||||||
$mediapath = Route::get('default/media');
|
$mediapath = Route::get('default/media');
|
||||||
$block = new block;
|
|
||||||
|
|
||||||
// @todo Items in the cart dont have account_id if they were put in the cart when the user was not logged in
|
// @todo Items in the cart dont have account_id if they were put in the cart when the user was not logged in
|
||||||
|
|
||||||
// If the cart is empty, we'll return here.
|
// If the cart is empty, we'll return here.
|
||||||
if (! Cart::instance()->contents()->count_all())
|
if (! Cart::instance()->contents()->count_all())
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Empty Cart'),
|
'title'=>_('Empty Cart'),
|
||||||
'body'=>_('The cart is empty')
|
'body'=>_('The cart is empty')
|
||||||
));
|
));
|
||||||
@ -58,7 +57,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
|||||||
}
|
}
|
||||||
$output .= '</table>';
|
$output .= '</table>';
|
||||||
|
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Your Items'),
|
'title'=>_('Your Items'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
@ -67,7 +66,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
|||||||
->payment_options_cart();
|
->payment_options_cart();
|
||||||
|
|
||||||
// @todo Country value should come from somewhere?
|
// @todo Country value should come from somewhere?
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Order Total'),
|
'title'=>_('Order Total'),
|
||||||
'body'=>View::factory('cart/checkout_total')
|
'body'=>View::factory('cart/checkout_total')
|
||||||
->set('cart',Cart::instance())
|
->set('cart',Cart::instance())
|
||||||
@ -91,14 +90,12 @@ class Controller_Checkout extends Controller_TemplateDefault {
|
|||||||
$output .= '</table>';
|
$output .= '</table>';
|
||||||
$output .= Form::close();
|
$output .= Form::close();
|
||||||
|
|
||||||
$block->add(array(
|
Block::add(array(
|
||||||
'title'=>_('Available Payment Methods'),
|
'title'=>_('Available Payment Methods'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->content = $block;
|
|
||||||
|
|
||||||
// Suppress our right hand tab
|
// Suppress our right hand tab
|
||||||
$this->template->right = ' ';
|
$this->template->right = ' ';
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
|
|||||||
'title'=>_('Available Email Templates'),
|
'title'=>_('Available Email Templates'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,8 +69,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
|
|||||||
'title'=>_('Available Email Templates'),
|
'title'=>_('Available Email Templates'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +78,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
|
|||||||
$eto = ORM::factory('emailtemplate',$id);
|
$eto = ORM::factory('emailtemplate',$id);
|
||||||
|
|
||||||
if (! $eto->loaded())
|
if (! $eto->loaded())
|
||||||
Request::instance()->redirect('admin/emailtemplate/list');
|
Request::current()->redirect('admin/emailtemplate/list');
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
@ -124,8 +120,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
|
|||||||
'title'=>sprintf(_('Edit Template '),$eto->name),
|
'title'=>sprintf(_('Edit Template '),$eto->name),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -45,7 +45,7 @@ class Controller_Admin_Export extends Controller_TemplateDefault {
|
|||||||
->export($daysago);
|
->export($daysago);
|
||||||
|
|
||||||
if (count($payments)) {
|
if (count($payments)) {
|
||||||
$output = Form::open(Request::instance()->uri(array('action'=>'export')));
|
$output = Form::open(Request::current()->uri(array('action'=>'export')));
|
||||||
$output .= '<table class="box-left">';
|
$output .= '<table class="box-left">';
|
||||||
|
|
||||||
$output .= View::factory('export/payment/header')
|
$output .= View::factory('export/payment/header')
|
||||||
@ -72,8 +72,6 @@ class Controller_Admin_Export extends Controller_TemplateDefault {
|
|||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
|
|
||||||
# Nothing to export
|
# Nothing to export
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
|
@ -16,7 +16,7 @@ class Export {
|
|||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->plugin = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this));
|
$this->plugin = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this));
|
||||||
$this->request = Request::instance();
|
$this->request = Request::current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -31,8 +31,6 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('invoice/list')
|
'body'=>View::factory('invoice/list')
|
||||||
->set('invoices',$ao->invoice->find_all()),
|
->set('invoices',$ao->invoice->find_all()),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -261,9 +261,9 @@ class Model_Invoice extends ORMOSB {
|
|||||||
return $this->invoice_items[$c];
|
return $this->invoice_items[$c];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save(Validation $validation = NULL) {
|
||||||
// Save the invoice
|
// Save the invoice
|
||||||
parent::save();
|
parent::save($validation);
|
||||||
|
|
||||||
// Need to save the associated items and their taxes
|
// Need to save the associated items and their taxes
|
||||||
if ($this->saved()) {
|
if ($this->saved()) {
|
||||||
|
@ -39,8 +39,6 @@ class Controller_Admin_Module extends Controller_Module {
|
|||||||
'title'=>_('Currently installed modules'),
|
'title'=>_('Currently installed modules'),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,8 +92,6 @@ class Controller_Admin_Module extends Controller_Module {
|
|||||||
'title'=>sprintf(_('%s Methods'),strtoupper($mo->name)),
|
'title'=>sprintf(_('%s Methods'),strtoupper($mo->name)),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -37,7 +37,7 @@ class Controller_Admin_Module_Method extends Controller_Module {
|
|||||||
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
||||||
));
|
));
|
||||||
|
|
||||||
Request::instance()->redirect(sprintf('admin/module/edit/%s',$mo->id));
|
Request::current()->redirect(sprintf('admin/module/edit/%s',$mo->id));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SystemMessage::add(array(
|
SystemMessage::add(array(
|
||||||
@ -56,8 +56,6 @@ class Controller_Admin_Module_Method extends Controller_Module {
|
|||||||
'title'=>sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($mmo->name),strtoupper($mo->name)),
|
'title'=>sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($mmo->name),strtoupper($mo->name)),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,8 +129,6 @@ class Controller_Admin_Module_Method extends Controller_Module {
|
|||||||
'title'=>sprintf(_('%s->%s Method'),strtoupper($mmo->module->name),strtoupper($mmo->name)),
|
'title'=>sprintf(_('%s->%s Method'),strtoupper($mmo->module->name),strtoupper($mmo->name)),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -19,7 +19,7 @@ class Controller_Module extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
public function action_menu() {
|
public function action_menu() {
|
||||||
// Redirect us to the admin menu, no user facilities here!
|
// Redirect us to the admin menu, no user facilities here!
|
||||||
Request::instance()->redirect('/admin/module/menu');
|
Request::current()->redirect('/admin/module/menu');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,7 @@ class Controller_Product extends Controller_TemplateDefault {
|
|||||||
$cat = ORM::factory('product_category',$id);
|
$cat = ORM::factory('product_category',$id);
|
||||||
|
|
||||||
if (! $cat->loaded())
|
if (! $cat->loaded())
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
|
|
||||||
Breadcrumb::name($this->request->uri(),$cat->name);
|
Breadcrumb::name($this->request->uri(),$cat->name);
|
||||||
|
|
||||||
@ -30,8 +30,6 @@ class Controller_Product extends Controller_TemplateDefault {
|
|||||||
->set('results',$this->_get_category($cat->id))
|
->set('results',$this->_get_category($cat->id))
|
||||||
->set('cat',$cat->id),
|
->set('cat',$cat->id),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +46,7 @@ class Controller_Product extends Controller_TemplateDefault {
|
|||||||
$po = ORM::factory('product',$id);
|
$po = ORM::factory('product',$id);
|
||||||
|
|
||||||
if (! $po->loaded())
|
if (! $po->loaded())
|
||||||
Request::instance()->redirect('product_category/index');
|
Request::current()->redirect('product_category/index');
|
||||||
|
|
||||||
Breadcrumb::name($this->request->uri(),$po->product_translate->find()->name);
|
Breadcrumb::name($this->request->uri(),$po->product_translate->find()->name);
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ class Controller_Product extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
// If the product category doesnt exist, or doesnt match the product
|
// If the product category doesnt exist, or doesnt match the product
|
||||||
if (! $co->loaded() OR ! in_array($co->id,unserialize($po->avail_category_id)))
|
if (! $co->loaded() OR ! in_array($co->id,unserialize($po->avail_category_id)))
|
||||||
Request::instance()->redirect('product_category/index');
|
Request::current()->redirect('product_category/index');
|
||||||
|
|
||||||
Breadcrumb::name('product/view',$co->name);
|
Breadcrumb::name('product/view',$co->name);
|
||||||
}
|
}
|
||||||
@ -68,8 +66,6 @@ class Controller_Product extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('product/view')
|
'body'=>View::factory('product/view')
|
||||||
->set('record',$po),
|
->set('record',$po),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -20,14 +20,13 @@ class Controller_Product_Category extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('product/category/list')
|
'body'=>View::factory('product/category/list')
|
||||||
->set('results',$this->_get_categories()),
|
->set('results',$this->_get_categories()),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain a list of our categories
|
* Obtain a list of our categories
|
||||||
* @todo Only show categories according to the users group memeberhsip
|
* @todo Only show categories according to the users group memeberhsip
|
||||||
* @todo Obey sort order
|
* @todo Obey sort order
|
||||||
|
* @todo Move this to the model
|
||||||
*/
|
*/
|
||||||
private function _get_categories() {
|
private function _get_categories() {
|
||||||
return ORM::factory('product_category')
|
return ORM::factory('product_category')
|
||||||
|
@ -89,8 +89,6 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
|
|||||||
'type'=>'file',
|
'type'=>'file',
|
||||||
'data'=>'css/list.css',
|
'data'=>'css/list.css',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@todo this should really be in a different class, since adsl wont be part of the main app
|
//@todo this should really be in a different class, since adsl wont be part of the main app
|
||||||
@ -186,8 +184,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
|||||||
'type'=>'file',
|
'type'=>'file',
|
||||||
'data'=>'css/list.css',
|
'data'=>'css/list.css',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_listhspaservices() {
|
public function action_listhspaservices() {
|
||||||
@ -268,8 +264,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
|||||||
'type'=>'file',
|
'type'=>'file',
|
||||||
'data'=>'css/list.css',
|
'data'=>'css/list.css',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -375,8 +369,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
|||||||
'type'=>'file',
|
'type'=>'file',
|
||||||
'data'=>'css/list.css',
|
'data'=>'css/list.css',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function process(array $file) {
|
private function process(array $file) {
|
||||||
|
@ -35,8 +35,6 @@ class Controller_User_Service extends Controller_TemplateDefault {
|
|||||||
'body'=>View::factory('service/list')
|
'body'=>View::factory('service/list')
|
||||||
->set('services',$this->ao->service->find_all()),
|
->set('services',$this->ao->service->find_all()),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_view($id) {
|
public function action_view($id) {
|
||||||
@ -103,8 +101,6 @@ class Controller_User_Service extends Controller_TemplateDefault {
|
|||||||
->set('product_info',$product_info)
|
->set('product_info',$product_info)
|
||||||
->set('product_detail',$product_detail),
|
->set('product_detail',$product_detail),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -24,13 +24,22 @@ class Model_Service extends ORMOSB {
|
|||||||
'account'=>array(),
|
'account'=>array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_formats = array(
|
/**
|
||||||
'active'=>array('StaticList_YesNo::display'=>array()),
|
* Filters used to format the display of values into friendlier values
|
||||||
'date_next_invoice'=>array('Config::date'=>array()),
|
*/
|
||||||
'recur_schedule'=>array('StaticList_RecurSchedule::display'=>array()),
|
protected $_display_filters = array(
|
||||||
|
'active'=>array(
|
||||||
|
array('StaticList_YesNo::display',array(':value')),
|
||||||
|
),
|
||||||
|
'date_next_invoice'=>array(
|
||||||
|
array('Config::date',array(':value')),
|
||||||
|
),
|
||||||
|
'recur_schedule'=>array(
|
||||||
|
array('StaticList_RecurSchedule::display',array(':value')),
|
||||||
|
),
|
||||||
'price'=>array(
|
'price'=>array(
|
||||||
'Tax::add'=>array(),
|
array('Tax::add',array(':value')),
|
||||||
'Currency::display'=>array(),
|
array('Currency::display',array(':value')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -19,18 +19,15 @@ class Controller_StaticPage extends Controller_TemplateDefault {
|
|||||||
$sp = ORM::factory('staticpage',$id);
|
$sp = ORM::factory('staticpage',$id);
|
||||||
|
|
||||||
if (! $sp->loaded())
|
if (! $sp->loaded())
|
||||||
Request::instance()->redirect('staticpage_category/index');
|
Request::current()->redirect('staticpage_category/index');
|
||||||
|
|
||||||
array_push($this->_control,
|
Breadcrumb::name($this->request->uri(),$sp->staticpage_translate->find()->title);
|
||||||
array($sp->staticpage_category->name=>sprintf('staticpage_category/view/'.$sp->static_page_category_id)));
|
|
||||||
array_push($this->_control,array($sp->staticpage_translate->title=>$this->request->uri()));
|
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>$sp->staticpage_translate->title,
|
'title'=>$sp->staticpage_translate->find()->title,
|
||||||
'body'=>View::factory('staticpage/view')
|
'body'=>View::factory('staticpage/view')
|
||||||
->set('record',$sp),
|
->set('record',$sp),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
@ -11,22 +11,15 @@
|
|||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Controller_StaticPage_Category extends Controller_TemplateDefault {
|
class Controller_StaticPage_Category extends Controller_TemplateDefault {
|
||||||
protected $_control = array(
|
|
||||||
array('Site Index'=>'staticpage_category'),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By default show a menu of available categories
|
* By default show a menu of available categories
|
||||||
*/
|
*/
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>_('Site Index Categories'),
|
'title'=>_('Site Index Categories'),
|
||||||
'body'=>View::factory('staticpage/category/list')
|
'body'=>View::factory('staticpage/category/list')
|
||||||
->set('results',$this->_get_categories()),
|
->set('results',$this->_get_categories()),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,17 +31,15 @@ class Controller_StaticPage_Category extends Controller_TemplateDefault {
|
|||||||
$spc = ORM::factory('staticpage_category',$id);
|
$spc = ORM::factory('staticpage_category',$id);
|
||||||
|
|
||||||
if (! $spc->loaded())
|
if (! $spc->loaded())
|
||||||
Request::instance()->redirect('welcome/index');
|
Request::current()->redirect('welcome/index');
|
||||||
|
|
||||||
array_push($this->_control,array($spc->name=>$this->request->uri()));
|
Breadcrumb::name($this->request->uri(),$spc->name);
|
||||||
|
|
||||||
Block::add(array(
|
Block::add(array(
|
||||||
'title'=>sprintf('%s: %s',_('Category'),$spc->name),
|
'title'=>sprintf('%s: %s',_('Category'),$spc->name),
|
||||||
'body'=>View::factory('staticpage/category/view')
|
'body'=>View::factory('staticpage/category/view')
|
||||||
->set('results',$this->_get_category($spc->id)),
|
->set('results',$this->_get_category($spc->id)),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->template->content = Block::factory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
<!-- @todo Move this back into the controller, so that we only have HTML views -->
|
||||||
<table width="100%" border="0">
|
<table width="100%" border="0">
|
||||||
<?php foreach ($results as $value) {?>
|
<?php foreach ($results as $value) {?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="menu"><a href="<?echo URL::site(Request::instance()->uri(array('action'=>'view','id'=>$value->id)));?>"><?php echo $value->name?></a></td>
|
<td class="menu"><a href="<?echo URL::site(Request::current()->uri(array('action'=>'view','id'=>$value->id)));?>"><?php echo $value->name?></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?}?>
|
<?}?>
|
||||||
</table>
|
</table>
|
||||||
|
Reference in New Issue
Block a user