General tidying up
This commit is contained in:
parent
8598408a59
commit
1c66acd7e4
@ -39,7 +39,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
* @var array actions that require a valid user
|
||||
*/
|
||||
protected $secure_actions = array(
|
||||
'menu' => TRUE,
|
||||
'menu' => FALSE,
|
||||
);
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ abstract class Controller_lnApp_TemplateDefault extends Controller_Template {
|
||||
* Default Method to call from the tree menu
|
||||
*/
|
||||
public function action_menu() {
|
||||
$this->template->content = 'See menu on tree';
|
||||
$this->template->content = _('Please choose from the menu.');
|
||||
}
|
||||
|
||||
protected function _headimages() {
|
||||
|
15
application/classes/controller/templatedefault/admin.php
Normal file
15
application/classes/controller/templatedefault/admin.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB User Main home page controller
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Page/Admin
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault_Admin extends Controller_TemplateDefault_User {
|
||||
}
|
||||
?>
|
30
application/classes/controller/templatedefault/user.php
Normal file
30
application/classes/controller/templatedefault/user.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB User Main home page controller
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Page/User
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault_User extends Controller_TemplateDefault {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
// Our acccount object
|
||||
protected $ao;
|
||||
|
||||
public function before() {
|
||||
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
|
||||
throw new Kohana_Exception('Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
|
||||
|
||||
parent::before();
|
||||
|
||||
$this->ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
||||
if (! $this->ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>Auth::instance()->get_user()->id));
|
||||
}
|
||||
}
|
||||
?>
|
@ -10,40 +10,35 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Account extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_User_Account extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'resetpassword'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_resetpassword() {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$ao->id));
|
||||
|
||||
// @todo Fix this next logic, since matches_ifset is not being called when the value is on the form, but empty
|
||||
if (empty($_POST['password_confirm']))
|
||||
$_POST['password_confirm'] = ' ';
|
||||
|
||||
// Store our new values
|
||||
$ao->values($_POST);
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($ao->changed())
|
||||
if ($ao->check()) {
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$ao->save();
|
||||
$this->ao->save();
|
||||
Request::current()->redirect('login');
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
||||
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||
|
||||
if ($output)
|
||||
@ -59,7 +54,7 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
Block::add(array(
|
||||
'title'=>_('Password Reset'),
|
||||
'body'=>View::factory('account/password_reset')
|
||||
->set('record',$ao),
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
|
||||
@ -67,28 +62,23 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
* Show a product
|
||||
*/
|
||||
public function action_edit() {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$ao->id));
|
||||
|
||||
// Store our new values
|
||||
$ao->values($_POST);
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($ao->changed())
|
||||
if ($ao->check()) {
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$ao->save();
|
||||
$this->ao->save();
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($ao->validation()->errors('forms/login') as $field => $error)
|
||||
foreach ($this->ao->validation()->errors('forms/login') as $field => $error)
|
||||
$output .= sprintf('<li><b>%s</b> %s</li>',$field,$error);
|
||||
|
||||
if ($output)
|
||||
@ -102,9 +92,9 @@ class Controller_User_Account extends Controller_TemplateDefault {
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$ao->accnum(),$ao->name(TRUE)),
|
||||
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('account/edit')
|
||||
->set('record',$ao),
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
15
modules/email/classes/controller/email.php
Normal file
15
modules/email/classes/controller/email.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides email management
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Page/Email
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Email extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
@ -10,13 +10,13 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_EmailTemplate extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_Admin_EmailTemplate extends Controller_TemplateDefault_Admin {
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_menu() {
|
||||
}
|
||||
|
||||
/**
|
||||
* List our defined email templates
|
||||
*/
|
||||
|
15
modules/emailtemplate/classes/controller/emailtemplate.php
Normal file
15
modules/emailtemplate/classes/controller/emailtemplate.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides email management
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Page/Email
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_EmailTemplate extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
@ -25,7 +25,7 @@ class Model_EmailTemplate extends ORMOSB {
|
||||
);
|
||||
|
||||
protected $_display_filters = array(
|
||||
'status'=>array(
|
||||
'active'=>array(
|
||||
array('StaticList_YesNo::display',array(':value')),
|
||||
),
|
||||
);
|
||||
|
@ -10,9 +10,9 @@
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Export extends Controller_TemplateDefault {
|
||||
class Controller_Admin_Export extends Controller_TemplateDefault_Admin {
|
||||
protected $control_title = 'Export';
|
||||
public $secure_actions = array(
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
'export'=>TRUE,
|
||||
);
|
||||
|
@ -10,7 +10,7 @@
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Invoice extends Controller_TemplateDefault {
|
||||
class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
|
||||
public function action_convert() {
|
||||
if (Config::sitemode() != KOHANA::DEVELOPMENT)
|
||||
throw new Kohana_Exception(__METHOD__.' can only be run in development');
|
||||
|
@ -10,8 +10,8 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Invoice extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_User_Invoice extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'download'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
@ -21,16 +21,10 @@ class Controller_User_Invoice extends Controller_TemplateDefault {
|
||||
* Show a product
|
||||
*/
|
||||
public function action_list() {
|
||||
$id = Auth::instance()->get_user()->id;
|
||||
$ao = ORM::factory('account',$id);
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$id));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$ao->accnum(),$ao->name(TRUE)),
|
||||
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('invoice/user/list')
|
||||
->set('invoices',$ao->invoice->find_all()),
|
||||
->set('invoices',$this->ao->invoice->find_all()),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE
|
||||
$pdf->drawRemittenceStub();
|
||||
$pdf->drawPaymentMethods();
|
||||
|
||||
if ($this->io->billing_status !=1 && $this->io->suspend_billing != 1 && $this->io->due_date <= time())
|
||||
if ($this->io->billing_status !=1 && $this->io->due_date <= time())
|
||||
$pdf->drawInvoiceDueNotice();
|
||||
elseif($this->io->billing_status == 1)
|
||||
$pdf->drawInvoicePaidNotice();
|
||||
|
@ -10,14 +10,37 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Module extends Controller_Module {
|
||||
class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Our menu method
|
||||
*
|
||||
* We need this method, otherwise we have redirect from our parent
|
||||
* Get the list of methods for a class
|
||||
*/
|
||||
public function action_menu() {
|
||||
$this->template->content = _('See menu on tree');
|
||||
protected function _methods($class) {
|
||||
// Get a list of methods this module has
|
||||
$ch = 'Controller_%s';
|
||||
$methods = array();
|
||||
|
||||
// List of classes where all our methods are, including this one.
|
||||
$classes = Kohana::config('config.method_directory');
|
||||
array_unshift($classes,'');
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$cn = sprintf($ch,$c ? $c.'_'.$class : $class);
|
||||
|
||||
if (class_exists($cn)) {
|
||||
$r = new ReflectionClass($cn);
|
||||
|
||||
foreach ($r->getMethods() as $method)
|
||||
if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
|
||||
array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
|
||||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,42 +11,5 @@
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Module extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'menu'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_menu() {
|
||||
// Redirect us to the admin menu, no user facilities here!
|
||||
Request::current()->redirect('/admin/module/menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of methods for a class
|
||||
*/
|
||||
protected function _methods($class) {
|
||||
// Get a list of methods this module has
|
||||
$ch = 'Controller_%s';
|
||||
$methods = array();
|
||||
|
||||
// List of classes where all our methods are, including this one.
|
||||
$classes = Kohana::config('config.method_directory');
|
||||
array_unshift($classes,'');
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$cn = sprintf($ch,$c ? $c.'_'.$class : $class);
|
||||
|
||||
if (class_exists($cn)) {
|
||||
$r = new ReflectionClass($cn);
|
||||
|
||||
foreach ($r->getMethods() as $method)
|
||||
if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
|
||||
array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
|
||||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
15
modules/payment/classes/controller/payment.php
Normal file
15
modules/payment/classes/controller/payment.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides payment management
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Page/Payment
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Payment extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
@ -10,26 +10,19 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Payment extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_User_Payment extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Show a payments received
|
||||
*/
|
||||
public function action_list() {
|
||||
$id = Auth::instance()->get_user()->id;
|
||||
$ao = ORM::factory('account',$id);
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$id));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Payments For'),$ao->accnum(),$ao->name(TRUE)),
|
||||
'title'=>sprintf('%s: %s - %s',_('Payments For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('payment/user/list')
|
||||
->set('payments',$ao->payment->find_all()),
|
||||
->set('payments',$this->ao->payment->find_all()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Service extends Controller_TemplateDefault {
|
||||
class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
||||
protected $control = array('Services'=>'services');
|
||||
|
||||
public $secure_actions = array(
|
||||
protected $secure_actions = array(
|
||||
'listbycheckout'=>TRUE,
|
||||
'listadslservices'=>TRUE,
|
||||
'listhspaservices'=>TRUE,
|
||||
|
15
modules/service/classes/controller/service.php
Normal file
15
modules/service/classes/controller/service.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides service management
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage Page/Service
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Service extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
@ -10,21 +10,11 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_User_Service extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
class Controller_User_Service extends Controller_TemplateDefault_User {
|
||||
protected $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
);
|
||||
// Our acccount object
|
||||
private $ao;
|
||||
|
||||
public function before() {
|
||||
parent::before();
|
||||
|
||||
$this->ao = ORM::factory('account',Auth::instance()->get_user()->id);
|
||||
if (! $this->ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>Auth::instance()->get_user()->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a product
|
||||
|
Reference in New Issue
Block a user