diff --git a/application/classes/auth/orm.php b/application/classes/auth/orm.php
new file mode 100644
index 00000000..38b15baa
--- /dev/null
+++ b/application/classes/auth/orm.php
@@ -0,0 +1,22 @@
+_config['hash_method'] == 'md5')
+ return md5($str);
+ else
+ return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']);
+ }
+}
+?>
diff --git a/application/classes/controller/lnapp/default.php b/application/classes/controller/lnapp/default.php
index fe5d1d91..59563de9 100644
--- a/application/classes/controller/lnapp/default.php
+++ b/application/classes/controller/lnapp/default.php
@@ -11,6 +11,14 @@
* @license http://dev.leenooks.net/license.html
*/
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.
* 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 (($this->auth_required !== FALSE && Auth::instance()->logged_in() === FALSE) ||
- (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));
+ (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));
}
public function before() {
@@ -58,16 +66,16 @@ abstract class Controller_lnApp_Default extends Controller {
// Check user auth and role
if ($this->_auth_required()) {
// 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.
// For no AJAX/JSON requests, display an access page
} elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__)) {
- Request::instance()->redirect('login/noaccess');
+ Request::current()->redirect('login/noaccess');
} else {
- Session::instance()->set('afterlogin',Request::instance()->uri());
- Request::instance()->redirect($this->noauth_redirect);
+ Session::instance()->set('afterlogin',Request::detect_uri());
+ Request::current()->redirect($this->noauth_redirect);
}
}
}
diff --git a/application/classes/controller/lnapp/login.php b/application/classes/controller/lnapp/login.php
index 03960694..0ccdc064 100644
--- a/application/classes/controller/lnapp/login.php
+++ b/application/classes/controller/lnapp/login.php
@@ -16,26 +16,20 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
// 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 ($_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 ($status) {
+ if (Auth::instance()->login($_POST['username'],$_POST['password'])) {
// Redirect to the user account
if ($redir = Session::instance()->get('afterlogin')) {
Session::instance()->delete('afterlogin');
- Request::instance()->redirect($redir);
+ Request::current()->redirect($redir);
} else
- Request::instance()->redirect('welcome/index');
+ Request::current()->redirect('welcome/index');
} else {
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->content = Block::factory();
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
@@ -66,7 +59,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
// Redirect to the user account
- Request::instance()->redirect('welcome/index');
+ Request::current()->redirect('welcome/index');
}
// Instantiate a new user
@@ -112,12 +105,10 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
'title'=>_('Register'),
'body'=>View::factory('bregister')
->set('account',$account)
- ->set('errors',$account->validate()->errors()),
- 'style'=>array('css/bregister.css'=>'screen'),
+ ->set('errors',$account->validation()->errors('form/register')),
));
$this->template->control = HTML::anchor($this->request->uri(),'Register',array('id'=>'ajxbody'));
- $this->template->content = Block::factory();
$this->template->left = HTML::anchor('login','Login').'...';
}
@@ -128,7 +119,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
// 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
@@ -172,7 +163,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// Redirect to our password reset, the Auth will validate the 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.
@@ -183,7 +174,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
'style'=>array('css/login.css'=>'screen'),
));
else
- Request::instance()->redirect('login');
+ Request::current()->redirect('login');
} else {
Block::add(array(
@@ -192,13 +183,9 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
'style'=>array('css/login.css'=>'screen'),
));
}
-
- $this->template->content = Block::factory();
}
public function action_noaccess() {
- $this->template->content = ' ';
-
SystemMessage::add(array(
'title'=>_('No access to requested resource'),
'type'=>'error',
diff --git a/application/classes/controller/lnapp/logout.php b/application/classes/controller/lnapp/logout.php
index 7e964ed4..1613d17b 100644
--- a/application/classes/controller/lnapp/logout.php
+++ b/application/classes/controller/lnapp/logout.php
@@ -17,10 +17,10 @@ class Controller_lnApp_Logout extends Controller {
if (Auth::instance()->logged_in()!= 0) {
Auth::instance()->logout();
- Request::instance()->redirect('login');
+ Request::current()->redirect('login');
}
- Request::instance()->redirect('welcome/index');
+ Request::current()->redirect('welcome/index');
}
}
?>
diff --git a/application/classes/controller/lnapp/templatedefault.php b/application/classes/controller/lnapp/templatedefault.php
index 22ef6f1d..09370c1a 100644
--- a/application/classes/controller/lnapp/templatedefault.php
+++ b/application/classes/controller/lnapp/templatedefault.php
@@ -15,10 +15,6 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
* @var string page template
*/
public $template = 'lnapp/default';
- /**
- * @var string page media route as per [Route]
- */
- protected $mediaroute = 'default/media';
/**
* @var object meta object information as per [meta]
*/
@@ -62,8 +58,8 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
return 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) &&
- Auth::instance()->logged_in($this->secure_actions[$this->request->action],get_class($this).'|'.__METHOD__) === FALSE));
+ (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));
}
/**
@@ -74,7 +70,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
*/
public function before() {
// Do not template media files
- if ($this->request->action === 'media') {
+ if ($this->request->action() === 'media') {
$this->auto_render = FALSE;
return;
}
@@ -84,7 +80,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
// Check user auth and role
if ($this->_auth_required()) {
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.
// (We have already checked authorisation.)
@@ -93,24 +89,24 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
SystemMessage::add(array(
'title'=>_('Insufficient Access'),
'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?
- if (Request::$is_ajax) {
+ if ($this->request->is_ajax()) {
echo _('You dont have enough permissions.');
die();
} else
- Request::instance()->redirect('login/noaccess');
+ Request::current()->redirect('login/noaccess');
} else {
- Session::instance()->set('afterlogin',Request::instance()->uri());
- Request::instance()->redirect($this->noauth_redirect);
+ Session::instance()->set('afterlogin',Request::detect_uri());
+ Request::current()->redirect($this->noauth_redirect);
}
}
// For AJAX calls, we dont need to render the complete page.
- if (Request::$is_ajax) {
+ if ($this->request->is_ajax()) {
$this->auto_render = FALSE;
return;
}
@@ -181,20 +177,21 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
$this->template->footer = $this->_footer();
// 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?
- if ($s = $this->_sysmsg() AND (string)$s) {
- $this->request->response = sprintf('
',$s);
- } else
- $this->request->response = '';
+ if ($s = $this->_sysmsg() AND (string)$s)
+ $this->response->body(sprintf('',$s));
# 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
- $this->request->response .= sprintf('',$this->template->content);
+ $this->response->bodyadd(sprintf('',$this->template->content));
}
+ if (isset($this->template->content) AND ! $this->template->content)
+ $this->template->content = Block::factory();
+
parent::after();
}
@@ -244,7 +241,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
*/
final public function action_media() {
// 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
$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
if ($f = Kohana::find_file(sprintf('media/%s',Config::siteid()), $file, $ext)) {
// 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
} elseif ($f = Kohana::find_file('media', $file, $ext)) {
// Send the file content as the response
- $this->request->response = file_get_contents($f);
+ $this->response->body(file_get_contents($f));
} else {
// Return a 404 status
- $this->request->status = 404;
+ $this->response->status(404);
}
// Set the proper headers to allow caching
- $this->request->headers['Content-Type'] = File::mime_by_ext($ext);
- $this->request->headers['Content-Length'] = filesize($f);
- $this->request->headers['Last-Modified'] = date('r', filemtime($f));
+ $this->response->headers('Content-Type',File::mime_by_ext($ext));
+ $this->response->headers('Content-Length',(string)filesize($f));
+ $this->response->headers('Last-Modified',date('r', filemtime($f)));
}
}
?>
diff --git a/application/classes/controller/lnapp/tree.php b/application/classes/controller/lnapp/tree.php
index 43a1d0e3..9d1ca72d 100644
--- a/application/classes/controller/lnapp/tree.php
+++ b/application/classes/controller/lnapp/tree.php
@@ -11,22 +11,20 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_lnApp_Tree extends Controller_Default {
- // Our tree data
- protected $treedata;
/**
* @var string page media route as per [Route]
*/
- protected static $mediaroute = 'default/media';
+ protected static $jsmediaroute = 'default/media';
public function after() {
parent::after();
- $this->request->headers['Content-Type'] = 'application/json';
- $this->request->response = sprintf('[%s]',json_encode($this->treedata));
+ $this->response->headers('Content-Type','application/json');
+ $this->response->body(sprintf('[%s]',json_encode($this->output)));
}
public static function js() {
- $mediapath = Route::get(static::$mediaroute);
+ $mediapath = Route::get(static::$jsmediaroute);
return '
diff --git a/application/classes/controller/tree.php b/application/classes/controller/tree.php
index 2ee2809a..3bc97306 100644
--- a/application/classes/controller/tree.php
+++ b/application/classes/controller/tree.php
@@ -23,7 +23,7 @@ class Controller_Tree extends Controller_lnApp_Tree {
*/
public function action_json($id=null) {
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'))));
return;
@@ -74,10 +74,10 @@ class Controller_Tree extends Controller_lnApp_Tree {
}
}
- $this->treedata = array();
+ $this->output = array();
foreach ($data as $branch) {
- array_push($this->treedata,array(
+ array_push($this->output,array(
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
'state'=>$branch['state'],
'data'=>array('title'=>$branch['name']),
diff --git a/application/classes/controller/welcome.php b/application/classes/controller/welcome.php
index 1569ae3a..d32a8136 100644
--- a/application/classes/controller/welcome.php
+++ b/application/classes/controller/welcome.php
@@ -19,11 +19,8 @@ class Controller_Welcome extends Controller_TemplateDefault {
'footer'=>'lnApp makes building websites easy! '.time(),
));
- if (Auth::instance()->logged_in()) {
- $this->template->control = HTML::anchor('/logout',_('Logout'),array('id'=>'ajxbody'));
- } else {
- $this->template->control = HTML::anchor('/login',_('Login'),array('id'=>'ajxbody'));
-
+ // @todo Show a login/logout on the breadcrumb
+ if (! Auth::instance()->logged_in()) {
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
$("#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();
}
}
?>
diff --git a/application/classes/db.php b/application/classes/db.php
new file mode 100644
index 00000000..cd085078
--- /dev/null
+++ b/application/classes/db.php
@@ -0,0 +1,30 @@
+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());
+ }
+}
+?>
diff --git a/application/classes/form.php b/application/classes/form.php
new file mode 100644
index 00000000..7091ae2e
--- /dev/null
+++ b/application/classes/form.php
@@ -0,0 +1,19 @@
+
diff --git a/application/classes/http/exception/404.php b/application/classes/http/exception/404.php
new file mode 100644
index 00000000..45c70027
--- /dev/null
+++ b/application/classes/http/exception/404.php
@@ -0,0 +1,30 @@
+_('Page not found'),
+ 'type'=>'error',
+ 'body'=>sprintf(_('The page [%s] you requested was not found?'),Request::detect_uri()),
+ ));
+
+ Request::factory()->redirect('/welcome');
+ }
+}
diff --git a/application/classes/lnapp/breadcrumb.php b/application/classes/lnapp/breadcrumb.php
index 25b32a0b..04125f57 100644
--- a/application/classes/lnapp/breadcrumb.php
+++ b/application/classes/lnapp/breadcrumb.php
@@ -49,7 +49,7 @@ class lnApp_Breadcrumb extends HTMLRender {
protected function render() {
$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) {
$output .= static::$_spacer;
diff --git a/application/classes/lnapp/config.php b/application/classes/lnapp/config.php
index 8389266b..33369cf1 100644
--- a/application/classes/lnapp/config.php
+++ b/application/classes/lnapp/config.php
@@ -11,7 +11,7 @@
* @copyright (c) 2010 Deon George
* @license http://dev.leenooks.net/license.html
*/
-abstract class lnApp_Config extends Kohana {
+abstract class lnApp_Config extends Kohana_Config {
/**
* Return our site name
*/
diff --git a/application/classes/orm.php b/application/classes/orm.php
new file mode 100644
index 00000000..bd44924c
--- /dev/null
+++ b/application/classes/orm.php
@@ -0,0 +1,76 @@
+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;
+ }
+}
+?>
diff --git a/application/classes/ormosb.php b/application/classes/ormosb.php
index b8a3b7e6..f9105477 100644
--- a/application/classes/ormosb.php
+++ b/application/classes/ormosb.php
@@ -15,80 +15,32 @@ abstract class ORMOSB extends ORM {
* @var string Database to connect to
*/
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 $_updated_column = array('column'=>'date_last','format'=>TRUE);
- protected $_callbacks = array(
- 'id'=>array('get_next_id'),
- 'site_id'=>array('set_site_id'),
- );
-
- /**
- * 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;
+ // @todo Rules are no longer used?
+ public function rules() {
+ 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')),
+ ),
+ );
}
/**
* Our child models should provide an invoice display, this is shown
* on printed invoices.
+ *
+ * @todo This is no longer used I think?
*/
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__));
}
- /**
- * 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
* 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 string $func Name of function to call
* @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) {
switch ($func) {
@@ -121,31 +74,30 @@ abstract class ORMOSB extends ORM {
* @param array Validate object
* @param string Primary Key
*/
- public function get_next_id(Validate $array,$field) {
- if (! is_null($array[$field]))
+ public static function get_next_id(Validation $array,$model,$field) {
+ if (! is_null($model->$field))
return TRUE;
- $this->_changed[$field] = $field;
+ $model->_changed[$field] = $field;
$ido = ORM::factory('module')
- ->where('name','=',$this->_table_name)
+ ->where('name','=',$model->_table_name)
->find();
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;
}
- public function set_site_id(Validate $array,$field) {
- if (! is_null($array[$field]))
+ public static function set_site_id(Validation $array,$model,$field) {
+ if (! is_null($model->$field))
return TRUE;
- // @todo This should be a config item
- $this->_changed[$field] = $field;
- $array[$field] = Config::siteid();
+ $model->_changed[$field] = $field;
+ $model->$field = Config::siteid();
return TRUE;
}
diff --git a/application/classes/response.php b/application/classes/response.php
new file mode 100644
index 00000000..be5debcd
--- /dev/null
+++ b/application/classes/response.php
@@ -0,0 +1,19 @@
+_body .= (string) $content;
+ }
+}
+?>
diff --git a/application/classes/validate.php b/application/classes/valid.php
similarity index 64%
rename from application/classes/validate.php
rename to application/classes/valid.php
index 2fdf9286..a4046c30 100644
--- a/application/classes/validate.php
+++ b/application/classes/valid.php
@@ -9,21 +9,19 @@
* @copyright (c) 2010 Deon George
* @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.
* Field is ignored if it is blank.
*
- * This function is only invoked anyway when the value is set as per
- * $this->_empty_rules
- *
- * @param string field value
+ * @param array array of values
+ * @param string field name
* @param string field name to match
* @return boolean
*/
- protected function matches_ifset($value, $match)
- {
- return ($value === $this[$match]);
+ public static function matches_ifset($array, $field, $match)
+ {
+ return isset($array[$match]) ? ($array[$field] === $array[$match]) : TRUE;
}
}
?>
diff --git a/application/config/auth.php b/application/config/auth.php
index a85bd580..749377ab 100644
--- a/application/config/auth.php
+++ b/application/config/auth.php
@@ -9,12 +9,12 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
+
return array(
'driver' => 'OSB',
'hash_method' => 'md5',
- 'salt_pattern' => null,
+ 'hash_key' => '',
'lifetime' => 1209600,
'session_key' => 'auth_user',
- 'forced_key' => 'auth_forced',
);
?>
diff --git a/modules/account/classes/auth/osb.php b/modules/account/classes/auth/osb.php
index 6991452d..d5868c8a 100644
--- a/modules/account/classes/auth/osb.php
+++ b/modules/account/classes/auth/osb.php
@@ -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: %s, Module: %s, Method: %s, Role: %s, Status: %s, Data: %s',
- $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: %s, Module: %s, Method: %s, Status: %s, Data: %s',
- $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();
}
}
diff --git a/modules/account/classes/controller/user/account.php b/modules/account/classes/controller/user/account.php
index fe94904e..92551338 100644
--- a/modules/account/classes/controller/user/account.php
+++ b/modules/account/classes/controller/user/account.php
@@ -39,21 +39,21 @@ class Controller_User_Account extends Controller_TemplateDefault {
));
$ao->save();
- Request::instance()->redirect('login');
+ Request::current()->redirect('login');
} else {
+ $output = '';
+ foreach ($ao->validation()->errors('forms/login') as $field => $error)
+ $output .= sprintf('%s %s',$field,$error);
+
+ if ($output)
+ $output = sprintf('',$output);
+
SystemMessage::add(array(
'title'=>_('Record NOT updated'),
'type'=>'error',
- 'body'=>_('Your updates didnt pass validation.')
+ 'body'=>_('Your updates didnt pass validation.').'
'.$output,
));
-
- foreach ($ao->validate()->errors('form_errors') as $field => $error)
- SystemMessage::add(array(
- 'title'=>$field,
- 'type'=>'error',
- 'body'=>$error,
- ));
}
Block::add(array(
@@ -61,8 +61,6 @@ class Controller_User_Account extends Controller_TemplateDefault {
'body'=>View::factory('account/password_reset')
->set('record',$ao),
));
-
- $this->template->content = Block::factory();
}
/**
@@ -89,18 +87,18 @@ class Controller_User_Account extends Controller_TemplateDefault {
$ao->save();
} else {
+ $output = '';
+ foreach ($ao->validation()->errors('forms/login') as $field => $error)
+ $output .= sprintf('%s %s',$field,$error);
+
+ if ($output)
+ $output = sprintf('',$output);
+
SystemMessage::add(array(
'title'=>_('Record NOT updated'),
'type'=>'error',
- 'body'=>_('Your updates didnt pass validation.')
+ 'body'=>_('Your updates didnt pass validation.').'
'.$output,
));
-
- foreach ($ao->validate()->errors('form_errors') as $field => $error)
- SystemMessage::add(array(
- 'title'=>$field,
- 'type'=>'error',
- 'body'=>$error,
- ));
}
Block::add(array(
@@ -108,8 +106,6 @@ class Controller_User_Account extends Controller_TemplateDefault {
'body'=>View::factory('account/edit')
->set('record',$ao),
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/account/classes/model/account.php b/modules/account/classes/model/account.php
index 62e51545..106b93e3 100644
--- a/modules/account/classes/model/account.php
+++ b/modules/account/classes/model/account.php
@@ -18,9 +18,6 @@ class Model_Account extends Model_Auth_UserDefault {
'service' => array(),
);
- // Complete our login
- public function complete_login() {}
-
/**
* Return an account name
*/
diff --git a/modules/account/classes/model/auth/roledefault.php b/modules/account/classes/model/auth/roledefault.php
index 6594c674..fa357f32 100644
--- a/modules/account/classes/model/auth/roledefault.php
+++ b/modules/account/classes/model/auth/roledefault.php
@@ -9,46 +9,5 @@
* @license http://dev.leenooks.net/license.html
*/
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;
- }
}
?>
diff --git a/modules/account/classes/model/auth/userdefault.php b/modules/account/classes/model/auth/userdefault.php
index de051c63..a7a9476f 100644
--- a/modules/account/classes/model/auth/userdefault.php
+++ b/modules/account/classes/model/auth/userdefault.php
@@ -9,32 +9,34 @@
* @license http://dev.leenooks.net/license.html
*/
class Model_Auth_UserDefault extends Model_Auth_User {
- protected $_table_names_plural = false;
-
// Validation rules
- protected $_rules = array(
- 'username' => array(
- 'not_empty' => NULL,
- 'min_length' => array(4),
- 'max_length' => array(32),
- ),
- 'password' => array(
- 'not_empty' => NULL,
- 'min_length' => array(5),
- 'max_length' => array(42),
- ),
- 'password_confirm' => array(
- 'matches_ifset' => array('password'),
- ),
- 'email' => array(
- 'not_empty' => NULL,
- 'min_length' => array(4),
- 'max_length' => array(127),
- 'email' => NULL,
- ),
- );
+ public function rules() {
+ return array(
+ 'username' => array(
+ array('not_empty'),
+ array('min_length', array(':value', 4)),
+ array('max_length', array(':value', 32)),
+ ),
+ 'password' => array(
+ array('not_empty'),
+ array('min_length', array(':value', 5)),
+ array('max_length', array(':value', 32)),
+ ),
+ 'email' => array(
+ array('not_empty'),
+ array('min_length', array(':value', 4)),
+ array('max_length', array(':value', 127)),
+ array('email'),
+ ),
+ // @todo To test
+ 'password_confirm' => array(
+ array('matches_ifset', array(':validation', 'password', 'password_confirm')),
+ ),
+ );
+ }
// Validation callbacks
+ // @todo _callbacks no longer used
protected $_callbacks = array(
'username' => array('username_available'),
'email' => array('email_available'),
@@ -51,6 +53,7 @@ class Model_Auth_UserDefault extends Model_Auth_User {
* here.
*
* We can also do some other post-login actions here.
+ * @todo Maybe we can do our session update here.
*/
public function complete_login() {}
diff --git a/modules/cart/classes/controller/cart.php b/modules/cart/classes/controller/cart.php
index 2213d5fb..c1df38a8 100644
--- a/modules/cart/classes/controller/cart.php
+++ b/modules/cart/classes/controller/cart.php
@@ -25,11 +25,9 @@ class Controller_Cart extends Controller_TemplateDefault {
// @todo - this should be a global config item
$mediapath = Route::get('default/media');
- $block = new block;
-
// If the cart is empty, we'll return here.
if (! Cart::instance()->contents()->count_all())
- $block->add(array(
+ Block::add(array(
'title'=>_('Empty Cart'),
'body'=>_('The cart is empty')
));
@@ -61,7 +59,8 @@ class Controller_Cart extends Controller_TemplateDefault {
->set('mediapath',$mediapath);
// 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)));
// @todo JS validation will need to verify data before submission
@@ -70,14 +69,12 @@ class Controller_Cart extends Controller_TemplateDefault {
$output .= ''.Form::submit('submit',_('Checkout')).'
';
$output .= Form::close();
- $block->add(array(
+ Block::add(array(
'title'=>_('Your Items'),
'body'=>$output,
));
}
- $this->template->content = $block;
-
// Suppress our right hand tab
$this->template->right = ' ';
}
@@ -99,7 +96,7 @@ class Controller_Cart extends Controller_TemplateDefault {
echo Kohana::debug($cart->validate()->errors());
if ($cart->saved())
- Request::instance()->redirect('cart/index');
+ Request::current()->redirect('cart/index');
else
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
}
diff --git a/modules/cart/classes/model/cart.php b/modules/cart/classes/model/cart.php
index cd6e9ae9..5a9b6b2a 100644
--- a/modules/cart/classes/model/cart.php
+++ b/modules/cart/classes/model/cart.php
@@ -15,11 +15,16 @@ class Model_Cart extends ORMOSB {
'product'=>array(),
);
- protected $_formats = array(
- 'recurr_schedule'=>array('StaticList_RecurSchedule::display'=>array()),
- );
-
// Cart doesnt use the update column
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')),
+ ),
+ );
}
?>
diff --git a/modules/checkout/classes/controller/checkout.php b/modules/checkout/classes/controller/checkout.php
index d49010da..992272c5 100644
--- a/modules/checkout/classes/controller/checkout.php
+++ b/modules/checkout/classes/controller/checkout.php
@@ -24,13 +24,12 @@ class Controller_Checkout extends Controller_TemplateDefault {
// @todo - this should be a global config item
$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
// If the cart is empty, we'll return here.
if (! Cart::instance()->contents()->count_all())
- $block->add(array(
+ Block::add(array(
'title'=>_('Empty Cart'),
'body'=>_('The cart is empty')
));
@@ -58,7 +57,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
}
$output .= '';
- $block->add(array(
+ Block::add(array(
'title'=>_('Your Items'),
'body'=>$output,
));
@@ -67,7 +66,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
->payment_options_cart();
// @todo Country value should come from somewhere?
- $block->add(array(
+ Block::add(array(
'title'=>_('Order Total'),
'body'=>View::factory('cart/checkout_total')
->set('cart',Cart::instance())
@@ -91,14 +90,12 @@ class Controller_Checkout extends Controller_TemplateDefault {
$output .= '';
$output .= Form::close();
- $block->add(array(
+ Block::add(array(
'title'=>_('Available Payment Methods'),
'body'=>$output,
));
}
- $this->template->content = $block;
-
// Suppress our right hand tab
$this->template->right = ' ';
}
diff --git a/modules/emailtemplate/classes/controller/admin/emailtemplate.php b/modules/emailtemplate/classes/controller/admin/emailtemplate.php
index 3d5f08d6..e4b7a341 100644
--- a/modules/emailtemplate/classes/controller/admin/emailtemplate.php
+++ b/modules/emailtemplate/classes/controller/admin/emailtemplate.php
@@ -35,8 +35,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
'title'=>_('Available Email Templates'),
'body'=>$output,
));
-
- $this->template->content = Block::factory();
}
/**
@@ -71,8 +69,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
'title'=>_('Available Email Templates'),
'body'=>$output,
));
-
- $this->template->content = Block::factory();
}
/**
@@ -82,7 +78,7 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
$eto = ORM::factory('emailtemplate',$id);
if (! $eto->loaded())
- Request::instance()->redirect('admin/emailtemplate/list');
+ Request::current()->redirect('admin/emailtemplate/list');
$output = '';
@@ -124,8 +120,6 @@ class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
'title'=>sprintf(_('Edit Template '),$eto->name),
'body'=>$output,
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/export/classes/controller/admin/export.php b/modules/export/classes/controller/admin/export.php
index 7e00dfb9..e298f726 100644
--- a/modules/export/classes/controller/admin/export.php
+++ b/modules/export/classes/controller/admin/export.php
@@ -45,7 +45,7 @@ class Controller_Admin_Export extends Controller_TemplateDefault {
->export($daysago);
if (count($payments)) {
- $output = Form::open(Request::instance()->uri(array('action'=>'export')));
+ $output = Form::open(Request::current()->uri(array('action'=>'export')));
$output .= '';
$output .= View::factory('export/payment/header')
@@ -72,8 +72,6 @@ class Controller_Admin_Export extends Controller_TemplateDefault {
'body'=>$output,
));
- $this->template->content = Block::factory();
-
# Nothing to export
} else {
SystemMessage::add(array(
diff --git a/modules/export/classes/export.php b/modules/export/classes/export.php
index 36f40183..38ce8971 100644
--- a/modules/export/classes/export.php
+++ b/modules/export/classes/export.php
@@ -16,7 +16,7 @@ class Export {
public function __construct() {
$this->plugin = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this));
- $this->request = Request::instance();
+ $this->request = Request::current();
}
}
?>
diff --git a/modules/invoice/classes/controller/user/invoice.php b/modules/invoice/classes/controller/user/invoice.php
index 0b50eebe..86f1a6d4 100644
--- a/modules/invoice/classes/controller/user/invoice.php
+++ b/modules/invoice/classes/controller/user/invoice.php
@@ -31,8 +31,6 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
'body'=>View::factory('invoice/list')
->set('invoices',$ao->invoice->find_all()),
));
-
- $this->template->content = Block::factory();
}
/**
diff --git a/modules/invoice/classes/model/invoice.php b/modules/invoice/classes/model/invoice.php
index 4a6e6e7e..780413ed 100644
--- a/modules/invoice/classes/model/invoice.php
+++ b/modules/invoice/classes/model/invoice.php
@@ -261,9 +261,9 @@ class Model_Invoice extends ORMOSB {
return $this->invoice_items[$c];
}
- public function save() {
+ public function save(Validation $validation = NULL) {
// Save the invoice
- parent::save();
+ parent::save($validation);
// Need to save the associated items and their taxes
if ($this->saved()) {
diff --git a/modules/module/classes/controller/admin/module.php b/modules/module/classes/controller/admin/module.php
index 6ee48956..4e83d7d8 100644
--- a/modules/module/classes/controller/admin/module.php
+++ b/modules/module/classes/controller/admin/module.php
@@ -39,8 +39,6 @@ class Controller_Admin_Module extends Controller_Module {
'title'=>_('Currently installed modules'),
'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)),
'body'=>$output,
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/module/classes/controller/admin/module/method.php b/modules/module/classes/controller/admin/module/method.php
index 438ce62c..369f263e 100644
--- a/modules/module/classes/controller/admin/module/method.php
+++ b/modules/module/classes/controller/admin/module/method.php
@@ -37,7 +37,7 @@ class Controller_Admin_Module_Method extends Controller_Module {
'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 {
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)),
'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)),
'body'=>$output,
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/module/classes/controller/module.php b/modules/module/classes/controller/module.php
index 8a8328e7..844222a3 100644
--- a/modules/module/classes/controller/module.php
+++ b/modules/module/classes/controller/module.php
@@ -19,7 +19,7 @@ class Controller_Module extends Controller_TemplateDefault {
public function action_menu() {
// Redirect us to the admin menu, no user facilities here!
- Request::instance()->redirect('/admin/module/menu');
+ Request::current()->redirect('/admin/module/menu');
}
/**
diff --git a/modules/product/classes/controller/product.php b/modules/product/classes/controller/product.php
index 577ca1af..200e66e6 100644
--- a/modules/product/classes/controller/product.php
+++ b/modules/product/classes/controller/product.php
@@ -20,7 +20,7 @@ class Controller_Product extends Controller_TemplateDefault {
$cat = ORM::factory('product_category',$id);
if (! $cat->loaded())
- Request::instance()->redirect('welcome/index');
+ Request::current()->redirect('welcome/index');
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('cat',$cat->id),
));
-
- $this->template->content = Block::factory();
}
/**
@@ -48,7 +46,7 @@ class Controller_Product extends Controller_TemplateDefault {
$po = ORM::factory('product',$id);
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);
@@ -58,7 +56,7 @@ class Controller_Product extends Controller_TemplateDefault {
// If the product category doesnt exist, or doesnt match the product
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);
}
@@ -68,8 +66,6 @@ class Controller_Product extends Controller_TemplateDefault {
'body'=>View::factory('product/view')
->set('record',$po),
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/product/classes/controller/product/category.php b/modules/product/classes/controller/product/category.php
index 389bab7d..1615733a 100644
--- a/modules/product/classes/controller/product/category.php
+++ b/modules/product/classes/controller/product/category.php
@@ -20,14 +20,13 @@ class Controller_Product_Category extends Controller_TemplateDefault {
'body'=>View::factory('product/category/list')
->set('results',$this->_get_categories()),
));
-
- $this->template->content = Block::factory();
}
/**
* Obtain a list of our categories
* @todo Only show categories according to the users group memeberhsip
* @todo Obey sort order
+ * @todo Move this to the model
*/
private function _get_categories() {
return ORM::factory('product_category')
diff --git a/modules/service/classes/controller/admin/service.php b/modules/service/classes/controller/admin/service.php
index 903a9cf8..3c2bb007 100644
--- a/modules/service/classes/controller/admin/service.php
+++ b/modules/service/classes/controller/admin/service.php
@@ -89,8 +89,6 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
'type'=>'file',
'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
@@ -186,8 +184,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
'type'=>'file',
'data'=>'css/list.css',
));
-
- $this->template->content = Block::factory();
}
public function action_listhspaservices() {
@@ -268,8 +264,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
'type'=>'file',
'data'=>'css/list.css',
));
-
- $this->template->content = Block::factory();
}
/**
@@ -375,8 +369,6 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
'type'=>'file',
'data'=>'css/list.css',
));
-
- $this->template->content = Block::factory();
}
private function process(array $file) {
diff --git a/modules/service/classes/controller/user/service.php b/modules/service/classes/controller/user/service.php
index 885f8e61..d22d5737 100644
--- a/modules/service/classes/controller/user/service.php
+++ b/modules/service/classes/controller/user/service.php
@@ -35,8 +35,6 @@ class Controller_User_Service extends Controller_TemplateDefault {
'body'=>View::factory('service/list')
->set('services',$this->ao->service->find_all()),
));
-
- $this->template->content = Block::factory();
}
public function action_view($id) {
@@ -103,8 +101,6 @@ class Controller_User_Service extends Controller_TemplateDefault {
->set('product_info',$product_info)
->set('product_detail',$product_detail),
));
-
- $this->template->content = Block::factory();
}
}
?>
diff --git a/modules/service/classes/model/service.php b/modules/service/classes/model/service.php
index 3dfa5d74..2314a13e 100644
--- a/modules/service/classes/model/service.php
+++ b/modules/service/classes/model/service.php
@@ -24,13 +24,22 @@ class Model_Service extends ORMOSB {
'account'=>array(),
);
- protected $_formats = array(
- 'active'=>array('StaticList_YesNo::display'=>array()),
- 'date_next_invoice'=>array('Config::date'=>array()),
- 'recur_schedule'=>array('StaticList_RecurSchedule::display'=>array()),
+ /**
+ * Filters used to format the display of values into friendlier values
+ */
+ 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(
- 'Tax::add'=>array(),
- 'Currency::display'=>array(),
+ array('Tax::add',array(':value')),
+ array('Currency::display',array(':value')),
),
);
diff --git a/modules/static_page/classes/controller/staticpage.php b/modules/static_page/classes/controller/staticpage.php
index 9bc63c85..332e75ff 100644
--- a/modules/static_page/classes/controller/staticpage.php
+++ b/modules/static_page/classes/controller/staticpage.php
@@ -19,18 +19,15 @@ class Controller_StaticPage extends Controller_TemplateDefault {
$sp = ORM::factory('staticpage',$id);
if (! $sp->loaded())
- Request::instance()->redirect('staticpage_category/index');
+ Request::current()->redirect('staticpage_category/index');
- array_push($this->_control,
- 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()));
+ Breadcrumb::name($this->request->uri(),$sp->staticpage_translate->find()->title);
Block::add(array(
- 'title'=>$sp->staticpage_translate->title,
+ 'title'=>$sp->staticpage_translate->find()->title,
'body'=>View::factory('staticpage/view')
->set('record',$sp),
));
-
- $this->template->content = Block::factory();
}
}
+?>
diff --git a/modules/static_page/classes/controller/staticpage/category.php b/modules/static_page/classes/controller/staticpage/category.php
index 2d513404..75a24fc0 100644
--- a/modules/static_page/classes/controller/staticpage/category.php
+++ b/modules/static_page/classes/controller/staticpage/category.php
@@ -11,22 +11,15 @@
* @license http://dev.leenooks.net/license.html
*/
class Controller_StaticPage_Category extends Controller_TemplateDefault {
- protected $_control = array(
- array('Site Index'=>'staticpage_category'),
- );
-
/**
* By default show a menu of available categories
*/
public function action_index() {
-
Block::add(array(
'title'=>_('Site Index Categories'),
'body'=>View::factory('staticpage/category/list')
->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);
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(
'title'=>sprintf('%s: %s',_('Category'),$spc->name),
'body'=>View::factory('staticpage/category/view')
->set('results',$this->_get_category($spc->id)),
));
-
- $this->template->content = Block::factory();
}
/**
diff --git a/modules/static_page/views/staticpage/category/list.php b/modules/static_page/views/staticpage/category/list.php
index 6934e5e9..2a115152 100644
--- a/modules/static_page/views/staticpage/category/list.php
+++ b/modules/static_page/views/staticpage/category/list.php
@@ -1,7 +1,8 @@
+