Open Source Billing
This commit is contained in:
33
application/classes/Controller/Account.php
Normal file
33
application/classes/Controller/Account.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides account management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Account extends Controller_TemplateDefault {
|
||||
public function action_group() {
|
||||
$output = '';
|
||||
|
||||
$cg = $this->ao->group->find_all();
|
||||
|
||||
foreach ($cg as $go) {
|
||||
$output .= sprintf('Group %s: %s<br/>',$go->id,$go->display('name'));
|
||||
|
||||
foreach ($go->list_childgrps(TRUE) as $cgo)
|
||||
$output .= sprintf('- %s: %s (%s)<br/>',$cgo->id,$cgo->display('name'),$cgo->parent_id);
|
||||
|
||||
$output .= sprintf('END Group %s<br/><br/>',$go->id);
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>'Group Structure',
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
17
application/classes/Controller/Admin/Account.php
Normal file
17
application/classes/Controller/Admin/Account.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Admin Account management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Account extends Controller_Account {
|
||||
protected $secure_actions = array(
|
||||
'group'=>FALSE, // @todo Testing
|
||||
);
|
||||
}
|
||||
?>
|
130
application/classes/Controller/Admin/Module.php
Normal file
130
application/classes/Controller/Admin/Module.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides MODULE management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Module extends Controller_Module {
|
||||
protected $secure_actions = array(
|
||||
'add'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* 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 = URL::$method_directory;
|
||||
array_unshift($classes,'');
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$cn = Kohana::classname('Controller_'.$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* List our installed modules
|
||||
*/
|
||||
public function action_list() {
|
||||
$mo = ORM::factory('Module');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Defined Modules'),
|
||||
'body'=>Table::display(
|
||||
$mo->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','module/edit/')),
|
||||
'name'=>array('label'=>'Name'),
|
||||
'status'=>array('label'=>'Active'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'list',
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Module Configuration
|
||||
*
|
||||
* @todo Highlight those methods that have security, but the class does not have auth_required set to YES or the method isnt defined in secure_actions
|
||||
*/
|
||||
public function action_edit() {
|
||||
$mid = $this->request->param('id');
|
||||
$mo = ORM::factory('Module',$mid);
|
||||
|
||||
if (! $mo->loaded()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Invalid Module ID'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('Module with ID %s doesnt appear to exist?'),$mid),
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$methods = $this->_methods($mo->name);
|
||||
|
||||
// Show methods defined in the DB already.
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')),
|
||||
'body'=>Table::display(
|
||||
$mo->module_method->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','module_method/edit/')),
|
||||
'name'=>array('label'=>'Name'),
|
||||
'notes'=>array('label'=>'Notes'),
|
||||
'menu_display'=>array('label'=>'Menu'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'list',
|
||||
)),
|
||||
));
|
||||
|
||||
// Show new methods NOT defined in the DB already.
|
||||
foreach ($mo->module_method->find_all() as $meo)
|
||||
if (($method = array_search($meo->name,$methods)) !== false)
|
||||
unset($methods[$method]);
|
||||
|
||||
if (count($methods))
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s ',_('Undefined Module Methods For'),$mo->display('name')),
|
||||
'body'=>Table::display(
|
||||
$methods,
|
||||
25,
|
||||
array(
|
||||
'__VALUE__'=>array('label'=>'Name','url'=>URL::link('admin','module_method/add/'.$mo->id)),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'list',
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
137
application/classes/Controller/Admin/Module/Method.php
Normal file
137
application/classes/Controller/Admin/Module/Method.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides MODULE management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
||||
/**
|
||||
* Add a method to the database
|
||||
*/
|
||||
public function action_add() {
|
||||
$id = $this->request->param('id');
|
||||
$method = $this->request->param('sid');
|
||||
|
||||
$mo = ORM::factory('Module',$id);
|
||||
$mmo = ORM::factory('Module_Method');
|
||||
|
||||
if (! $mo->loaded() OR ! in_array($method,$this->_methods($mo->name)))
|
||||
throw new Kohana_Exception('Method (:method) does not exist in :class',array(':method'=>$method,':class'=>$mo->name));
|
||||
|
||||
$mmo->name = $method;
|
||||
$mmo->module_id = $mo->id;
|
||||
$mmo->values($_POST);
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($_POST AND $mmo->values($_POST)->check()) {
|
||||
$mmo->save();
|
||||
|
||||
if ($mmo->saved()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Method Added'),
|
||||
'type'=>'info',
|
||||
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
||||
));
|
||||
|
||||
HTTP::redirect(URL::link('admin','/module/edit/'.$mo->id));
|
||||
|
||||
} else {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Method Not Saved'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('Unable to define Method %s to database?'),$mmo->name),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$output .= View::factory('module/admin/method_add')
|
||||
->set('module',$mo)
|
||||
->set('method',$mmo);
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($mmo->name),strtoupper($mo->name)),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Module Configuration
|
||||
*
|
||||
* @param int $mid Module ID
|
||||
*/
|
||||
public function action_edit() {
|
||||
$mid = $this->request->param('id');
|
||||
$mmo = ORM::factory('Module_Method',$mid);
|
||||
|
||||
if (! $mmo->loaded()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Invalid Method ID'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('Method with ID %s doesnt appear to exist?'),$mid),
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
// The groups that can run this method.
|
||||
$groups = ORM::factory('Group');
|
||||
|
||||
if ($_POST) {
|
||||
foreach ($groups->find_all() as $go) {
|
||||
// If the group was defined and no longer
|
||||
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) {
|
||||
$gm = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
|
||||
|
||||
if (! $gm->delete())
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Unable to DELETE Group Method'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('Unable to delete Group Method for method %s and group %s'),$mmo->name,$go->name),
|
||||
));
|
||||
|
||||
// If the group was not defined and now is
|
||||
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) {
|
||||
$gm = ORM::factory('Group_Method')
|
||||
->values(array(
|
||||
'method_id'=>$mmo->id,
|
||||
'group_id'=>$go->id,
|
||||
));
|
||||
|
||||
if (! $gm->check() OR ! $gm->save())
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Unable to SAVE Group Method'),
|
||||
'type'=>'error',
|
||||
'body'=>sprintf(_('Unable to save Group Method for method %s and group %s'),$mmo->name,$go->name),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
|
||||
$output .= View::factory('module/admin/method_detail_head');
|
||||
foreach ($groups->find_all() as $go) {
|
||||
$output .= View::factory('module/admin/method_detail_body')
|
||||
->set('group',$go)
|
||||
->set('defined',$mmo->has('group',$go));
|
||||
}
|
||||
$output .= View::factory('module/admin/method_detail_foot');
|
||||
|
||||
$output .= '<div>'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'</div>';
|
||||
$output .= Form::close();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf(_('%s->%s Method'),strtoupper($mmo->module->name),strtoupper($mmo->name)),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
73
application/classes/Controller/Admin/Setup.php
Normal file
73
application/classes/Controller/Admin/Setup.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Siet Configuration Setup
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Setup extends Controller_TemplateDefault {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* View/Update the site configuration
|
||||
*/
|
||||
public function action_edit() {
|
||||
$o = Company::instance()->so();
|
||||
$output = '';
|
||||
|
||||
if ($_POST) {
|
||||
// Entry updated
|
||||
if ($o->values($_POST)->check() AND $o->save())
|
||||
SystemMessage::add(array(
|
||||
'title'=>'Site Configuration Recorded',
|
||||
'type'=>'info',
|
||||
'body'=>'Site Config successfully recorded.',
|
||||
));
|
||||
}
|
||||
|
||||
$output .= Form::open();
|
||||
|
||||
// site_details
|
||||
$output .= View::factory($this->viewpath())
|
||||
->set('o',$o);;
|
||||
|
||||
$output .= '<div>'.Form::submit('submit','submit',array('class'=>'form_button')).'</div>';
|
||||
$output .= Form::close();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Update Site Configuration'),
|
||||
'body'=>$output,
|
||||
));
|
||||
|
||||
// module_config
|
||||
$output = '';
|
||||
$output .= View::factory($this->viewpath().'/module/head');
|
||||
|
||||
foreach ($o->module_config as $mid => $detail) {
|
||||
$mo = ORM::factory('Module',$mid);
|
||||
|
||||
$output .= View::factory($this->viewpath().'/module/body')
|
||||
->set('mo',$mo);
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
$("div[id='.$mo->name.']").load("'.URL::link('admin',$mo->name.'/setup',TRUE).'");
|
||||
});'
|
||||
));
|
||||
}
|
||||
|
||||
$output .= View::factory($this->viewpath().'/module/foot');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Update Module Specific Configuration'),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
130
application/classes/Controller/Admin/Welcome.php
Normal file
130
application/classes/Controller/Admin/Welcome.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB Admin Main home page
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
public $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
$t = time();
|
||||
|
||||
// Show outstanding invoices
|
||||
$o = ORM::factory('Invoice');
|
||||
|
||||
Block_Sub::add(array(
|
||||
'title'=>'Invoices Overdue - No Auto Billing',
|
||||
'body'=>Table::display(
|
||||
$o->list_overdue_billing($t),
|
||||
25,
|
||||
array(
|
||||
'due_date'=>array('label'=>'Due Date'),
|
||||
'account->accnum()'=>array('label'=>'Num'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'account->display("status")'=>array('label'=>'Active'),
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
||||
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
||||
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
||||
),
|
||||
array('page'=>TRUE)),
|
||||
'position'=>1,
|
||||
'order'=>1,
|
||||
));
|
||||
|
||||
Block_Sub::add(array(
|
||||
'title'=>'Invoices Overdue - Auto Billing',
|
||||
'body'=>Table::display(
|
||||
$o->list_overdue_billing($t,TRUE),
|
||||
25,
|
||||
array(
|
||||
'due_date'=>array('label'=>'Due Date'),
|
||||
'account->accnum()'=>array('label'=>'Num'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'account->display("status")'=>array('label'=>'Active'),
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
||||
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
||||
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
||||
),
|
||||
array('page'=>TRUE)),
|
||||
'position'=>2,
|
||||
'order'=>1,
|
||||
));
|
||||
|
||||
Block_Sub::add(array(
|
||||
'title'=>'Invoices Due',
|
||||
'body'=>Table::display(
|
||||
$o->list_due(),
|
||||
25,
|
||||
array(
|
||||
'due_date'=>array('label'=>'Due Date'),
|
||||
'account->accnum()'=>array('label'=>'Num'),
|
||||
'account->name()'=>array('label'),
|
||||
'account->display("status")'=>array('label'=>'Active'),
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')),
|
||||
'total(TRUE)'=>array('label'=>'Total','class'=>'right'),
|
||||
'due(TRUE)'=>array('label'=>'Amount Due','class'=>'right'),
|
||||
),
|
||||
array('show_other'=>'due()')),
|
||||
'position'=>3,
|
||||
'order'=>1,
|
||||
));
|
||||
|
||||
// Show un-applied payments
|
||||
Block_Sub::add(array(
|
||||
'title'=>'Unapplied Payments',
|
||||
'body'=>Table::display(
|
||||
ORM::factory('Payment')->list_unapplied(),
|
||||
25,
|
||||
array(
|
||||
'date_payment'=>array('label'=>'Pay Date'),
|
||||
'account->accnum()'=>array('label'=>'Num'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'account->display("status")'=>array('label'=>'Active'),
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','payment/view/')),
|
||||
'total_amt'=>array('label'=>'Total','class'=>'right'),
|
||||
'balance(TRUE)'=>array('label'=>'Balance','class'=>'right'),
|
||||
),
|
||||
array('show_other'=>'balance()')),
|
||||
'position'=>1,
|
||||
'order'=>2,
|
||||
));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s %s',$this->ao->accnum(),$this->ao->first_name,$this->ao->last_name),
|
||||
'subtitle'=>_('Administrator Overview'),
|
||||
'body'=>(string)Block_Sub::factory(),
|
||||
));
|
||||
|
||||
// We are a site administrator
|
||||
$output = '';
|
||||
if ($this->ao->rtm_id == NULL) {
|
||||
$rtmo = ORM::factory('RTM',array('account_id','=',$this->ao->id))->find();
|
||||
|
||||
// Quick validation, if we are an admin, we should have an entry in the RTM table.
|
||||
if (! $rtmo->loaded())
|
||||
throw new Kohana_Exception('User :aid not set up properly',array(':aid'=>$this->ao->id));
|
||||
|
||||
$output = View::factory('welcome/admin')
|
||||
->set('o',$rtmo);
|
||||
|
||||
} else {
|
||||
$rtmo = ORM::factory('RTM',$this->ao->rtm_id);
|
||||
}
|
||||
|
||||
if ($output)
|
||||
Block::add(array(
|
||||
'title'=>sprintf('Reseller %s',$this->ao->display('company')),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
36
application/classes/Controller/Debug.php
Normal file
36
application/classes/Controller/Debug.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Debug extends Controller_TemplateDefault {
|
||||
public function before() {
|
||||
if (! in_array(Config::sitemode(),array(Kohana::DEVELOPMENT,Kohana::TESTING)))
|
||||
HTTP::redirect();
|
||||
|
||||
parent::before();
|
||||
}
|
||||
|
||||
public function action_site() {
|
||||
$output = '';
|
||||
|
||||
$output .= debug::vars(array(
|
||||
'm'=>__METHOD__,
|
||||
'site'=>Config::site(),
|
||||
'siteID'=>Company::instance()->site(),
|
||||
'siteMode'=>Config::sitemodeverbose(),
|
||||
'modules'=>Config::appmodules(),
|
||||
));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Site debug'),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
92
application/classes/Controller/Login.php
Normal file
92
application/classes/Controller/Login.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides login capability
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
* @also [logout]
|
||||
*/
|
||||
class Controller_Login extends lnApp_Controller_Login {
|
||||
/**
|
||||
* Enable site registration
|
||||
*
|
||||
* @todo Needs to be written
|
||||
*/
|
||||
public function action_register() {
|
||||
// If user already signed-in
|
||||
if (Auth::instance()->logged_in())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
HTTP::redirect('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable user password reset
|
||||
*/
|
||||
public function action_reset() {
|
||||
// Minutes to keep our token
|
||||
$token_expire = 15;
|
||||
|
||||
// If user already signed-in
|
||||
if (Auth::instance()->logged_in())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
// If the user posted their details to reset their password
|
||||
if ($_POST) {
|
||||
// If the username is correct, create a method token
|
||||
if (! empty($_POST['username']) AND ($ao=ORM::factory('Account',array('username'=>$_POST['username']))) AND $ao->loaded()) {
|
||||
$mmto = ORM::factory('Module_Method_Token')
|
||||
->method(array('account','user_resetpassword'))
|
||||
->account($ao)
|
||||
->uses(2)
|
||||
->expire(time()+$token_expire*60);
|
||||
|
||||
if ($mmto->generate()) {
|
||||
// Send our email with the token
|
||||
// @todo Need to provide an option if Email_Template is not installed/activited.
|
||||
// @todo Need to provide an option if account_reset_password template doesnt exist.
|
||||
$et = Email_Template::instance('account_reset_password');
|
||||
$et->to = array('account'=>array($mmto->account_id));
|
||||
$et->variables = array(
|
||||
'SITE'=>URL::base(TRUE,TRUE),
|
||||
'SITE_ADMIN'=>Company::instance()->admin(),
|
||||
'SITE_NAME'=>Company::instance()->name(),
|
||||
'TOKEN'=>$mmto->token,
|
||||
'TOKEN_EXPIRE_MIN'=>$token_expire,
|
||||
'USER_NAME'=>sprintf('%s %s',$mmto->account->first_name,$mmto->account->last_name),
|
||||
);
|
||||
$et->send();
|
||||
|
||||
// Log the password reset
|
||||
$ao->log('Password reset token sent');
|
||||
}
|
||||
|
||||
// Redirect to our password reset, the Auth will validate the token.
|
||||
} elseif (! empty($_REQUEST['token'])) {
|
||||
HTTP::redirect(URL::link('user','account/resetpassword?token='.$_REQUEST['token']));
|
||||
}
|
||||
|
||||
// Show our token screen even if the email was invalid.
|
||||
if (isset($_POST['username']))
|
||||
Block::add(array(
|
||||
'title'=>_('Reset your password'),
|
||||
'body'=>View::factory('login_reset_sent'),
|
||||
'style'=>array('css/login.css'=>'screen'),
|
||||
));
|
||||
else
|
||||
HTTP::redirect('login');
|
||||
|
||||
} else {
|
||||
Block::add(array(
|
||||
'title'=>_('Reset your password'),
|
||||
'body'=>View::factory('login_reset'),
|
||||
'style'=>array('css/login.css'=>'screen'),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
14
application/classes/Controller/Module.php
Normal file
14
application/classes/Controller/Module.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides MODULE management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Module extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
81
application/classes/Controller/Reseller/Account.php
Normal file
81
application/classes/Controller/Reseller/Account.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Reseller Account management
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Reseller
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Reseller_Account extends Controller_Account {
|
||||
protected $secure_actions = array(
|
||||
'ajaxlist'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'listlog'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Used by AJAX calls to find accounts
|
||||
* @note list_autocomplete() will limit to authorised accounts
|
||||
*/
|
||||
public function action_ajaxlist() {
|
||||
$result = array();
|
||||
|
||||
if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
|
||||
$result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
|
||||
|
||||
$this->auto_render = FALSE;
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
$this->response->body(json_encode(array_values($result)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of accounts
|
||||
*/
|
||||
public function action_list() {
|
||||
Block::add(array(
|
||||
'title'=>_('Customer List'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'sortkey(TRUE)','id'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
|
||||
'accnum()'=>array('label'=>'Num'),
|
||||
'name(TRUE)'=>array('label'=>'Account'),
|
||||
'email'=>array('label'=>'Email'),
|
||||
'invoices_due_total(NULL,TRUE)'=>array('label'=>'Invoices','class'=>'right'),
|
||||
'services_count(TRUE)'=>array('label'=>'Services','class'=>'right'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('reseller','invoice/list'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of account logins
|
||||
*/
|
||||
public function action_listlog() {
|
||||
Block::add(array(
|
||||
'title'=>_('Account Login Log'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID'),
|
||||
'date_orig'=>array('label'=>'Date'),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'ip'=>array('label'=>'IP Address'),
|
||||
'details'=>array('label'=>'Details'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
)),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
25
application/classes/Controller/Reseller/Welcome.php
Normal file
25
application/classes/Controller/Reseller/Welcome.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* lnApp Main home page
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Reseller
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Reseller_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('welcome/reseller'),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
134
application/classes/Controller/TemplateDefault.php
Normal file
134
application/classes/Controller/TemplateDefault.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides the default template controller for rendering pages.
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
// Our acccount object
|
||||
protected $ao;
|
||||
|
||||
public function __construct(Request $request, Response $response) {
|
||||
if (Config::theme())
|
||||
$this->template = Config::theme().'/page';
|
||||
|
||||
return parent::__construct($request,$response);
|
||||
}
|
||||
|
||||
protected function _headimages() {
|
||||
// This is where we should be able to change our country
|
||||
// @todo To implement
|
||||
$co = Config::country();
|
||||
HeadImages::add(array(
|
||||
'img'=>sprintf('img/country/%s.png',strtolower($co->two_code)),
|
||||
'attrs'=>array('onclick'=>"target='_blank';",'title'=>$co->display('name'))
|
||||
));
|
||||
|
||||
return HeadImages::factory();
|
||||
}
|
||||
|
||||
protected function _left() {
|
||||
if ($this->template->left)
|
||||
return $this->template->left;
|
||||
|
||||
elseif (Auth::instance()->logged_in(NULL,get_class($this).'|'.__METHOD__))
|
||||
return Controller_Tree::js();
|
||||
}
|
||||
|
||||
protected function _right() {
|
||||
return ($this->template->right) ? $this->template->right : '';
|
||||
}
|
||||
|
||||
public function before() {
|
||||
// If our action doesnt exist, no point processing any further.
|
||||
if (! method_exists($this,'action_'.Request::current()->action()))
|
||||
return;
|
||||
|
||||
if ($this->auth_required) {
|
||||
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()));
|
||||
|
||||
$this->ao = Auth::instance()->get_user();
|
||||
|
||||
if (! is_null($this->ao) AND (is_string($this->ao) OR ! $this->ao->loaded()))
|
||||
throw HTTP_Exception::factory(501,'Account doesnt exist :account ?',array(':account'=>(is_string($this->ao) OR is_null($this->ao)) ? $this->ao : Auth::instance()->get_user()->id));
|
||||
}
|
||||
|
||||
parent::before();
|
||||
}
|
||||
|
||||
public function after() {
|
||||
$dc = Kohana::$config->load('config','user_default_method');
|
||||
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
|
||||
|
||||
BreadCrumb::URL(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||
BreadCrumb::URL($m,method_exists($this,'action_menu') ? $m.'/menu' : sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||
|
||||
parent::after();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will filter a search query to only return those accounts for a reseller
|
||||
*/
|
||||
protected function filter($o,$af,$sort=NULL,$afid=NULL) {
|
||||
$result = array();
|
||||
|
||||
foreach ($o as $x) {
|
||||
if (! is_null($afid) AND isset($x->$afid)) {
|
||||
if ((is_array($af) AND in_array($x->$afid,$af)) OR ($x->$afid == $af))
|
||||
array_push($result,$x);
|
||||
|
||||
} elseif (method_exists($x,'list_reseller')) {
|
||||
if (in_array($af,$x->list_reseller()))
|
||||
array_push($result,$x);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($sort)
|
||||
Sort::MAsort($result,$sort);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function setup(array $config_items=array()) {
|
||||
$module = Request::current()->controller();
|
||||
|
||||
if ($_POST AND isset($_POST['module_config'][$module]))
|
||||
Config::instance()->module_config($module,$_POST['module_config'][$module])->save();
|
||||
|
||||
if ($config_items) {
|
||||
$output = '';
|
||||
$mc = Config::instance()->module_config($module);
|
||||
|
||||
$output .= Form::open();
|
||||
$output .= View::factory('setup/admin/module/head');
|
||||
|
||||
foreach ($config_items as $k=>$v)
|
||||
$output .= View::factory('setup/admin/module/body')
|
||||
->set('module',$module)
|
||||
->set('mc',$mc)
|
||||
->set('key',$k)
|
||||
->set('info',$v)
|
||||
->set('val',isset($mc[$k]) ? $mc[$k] : '');
|
||||
|
||||
$output .= View::factory('setup/admin/module/foot');
|
||||
|
||||
$output .= Form::submit('submit',_('Submit'),array('class'=>'form_button'));
|
||||
$output .= Form::close();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',strtoupper($module),_('Configuration')),
|
||||
'body'=>$output,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
23
application/classes/Controller/TemplateDefault/Admin.php
Normal file
23
application/classes/Controller/TemplateDefault/Admin.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* lnApp User Main home page controller
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Admin
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault_Admin extends Controller_TemplateDefault_User {
|
||||
public function after() {
|
||||
SystemMessage::add(array(
|
||||
'title'=>'Retire this class extension',
|
||||
'type'=>'info',
|
||||
'body'=>__METHOD__,
|
||||
));
|
||||
|
||||
return parent::after();
|
||||
}
|
||||
}
|
||||
?>
|
23
application/classes/Controller/TemplateDefault/Affiliate.php
Normal file
23
application/classes/Controller/TemplateDefault/Affiliate.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB User Main home page controller
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/Affiliate
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault_Affiliate extends Controller_TemplateDefault_User {
|
||||
public function after() {
|
||||
SystemMessage::add(array(
|
||||
'title'=>'Retire this class extension',
|
||||
'type'=>'info',
|
||||
'body'=>__METHOD__,
|
||||
));
|
||||
|
||||
return parent::after();
|
||||
}
|
||||
}
|
||||
?>
|
14
application/classes/Controller/TemplateDefault/User.php
Normal file
14
application/classes/Controller/TemplateDefault/User.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* lnApp User Main home page controller
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_TemplateDefault_User extends Controller_TemplateDefault {
|
||||
}
|
||||
?>
|
131
application/classes/Controller/Tree.php
Normal file
131
application/classes/Controller/Tree.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class extends renders OSB menu tree.
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Tree extends lnApp_Controller_Tree {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
/**
|
||||
* Draw the Tree Menu
|
||||
*
|
||||
* The incoming ID is either a Branch B_x or a Node N_x
|
||||
* Where X is actually the module.
|
||||
*
|
||||
* @param array $data Tree data passed in by inherited methods
|
||||
*/
|
||||
public function action_json(array $data=array()) {
|
||||
// Get the user details
|
||||
$id = (is_null($this->request->param('id')) AND isset($_REQUEST['id'])) ? substr($_REQUEST['id'],2) : $this->request->param('id');
|
||||
$user = Auth::instance()->get_user();
|
||||
|
||||
if ($user) {
|
||||
if (! $id) {
|
||||
$modules = array();
|
||||
foreach ($user->groups() as $go)
|
||||
foreach ($go->list_parentgrps(TRUE) as $cgo)
|
||||
foreach ($cgo->module_method->find_all() as $mmo)
|
||||
if ($mmo->menu_display AND empty($modules[$mmo->module_id]))
|
||||
$modules[$mmo->module_id] = $mmo->module;
|
||||
|
||||
Sort::MAsort($modules,'name');
|
||||
|
||||
foreach ($modules as $id => $mo)
|
||||
if (! $mo->parent_id)
|
||||
array_push($data,array('id'=>$id,'name'=>$mo->name,'state'=>'closed'));
|
||||
|
||||
} else {
|
||||
$idx = NULL;
|
||||
if (preg_match('/_/',$id))
|
||||
list($id,$idx) = explode('_',$id,2);
|
||||
|
||||
$mo = ORM::factory('Module',$id);
|
||||
|
||||
$methods = array();
|
||||
if ($mo->loaded()) {
|
||||
foreach ($mo->module_method->find_all() as $mmo)
|
||||
if ($mmo->menu_display)
|
||||
foreach ($mmo->group->find_all() as $gmo)
|
||||
if ($user->has_any('group',$gmo->list_childgrps(TRUE)))
|
||||
$methods[$mmo->id] = $mmo;
|
||||
|
||||
Sort::MASort($modules,'name');
|
||||
|
||||
$subdata = array();
|
||||
foreach ($methods as $id => $mmo) {
|
||||
if (preg_match('/_/',$mmo->name)) {
|
||||
list($mode,$action) = explode('_',$mmo->name);
|
||||
|
||||
$url = URL::link($mode,$mmo->module->name.'/'.$action,TRUE);
|
||||
|
||||
} else {
|
||||
$url = URL::site($mmo->module->name.'/'.$mmo->name);
|
||||
}
|
||||
|
||||
// We can split our menus into sub menus using the _ char.
|
||||
if (preg_match('/_/',$mmo->name)) {
|
||||
list($sub,$name) = explode('_',$mmo->name,2);
|
||||
$subdata[$sub][$name]['name'] = preg_replace('/^(.*: )/','',$mmo->notes);
|
||||
$subdata[$sub][$name]['id'] = sprintf('%s_%s',$mmo->module_id,$id);
|
||||
$subdata[$sub][$name]['href'] = (empty($details['page']) ? $url : $details['page']);
|
||||
|
||||
} else {
|
||||
// We dont want to show these items again, if we can through on a submenu
|
||||
if (! $idx)
|
||||
array_push($data,array(
|
||||
'id'=>sprintf('%s_%s',$mmo->module_id,$id),
|
||||
'name'=>$mmo->name,
|
||||
'state'=>'none',
|
||||
'attr_id'=>sprintf('%s_%s',$mmo->module->name,$id),
|
||||
'attr_href'=>(empty($details['page']) ? $url : $details['page'])
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// If our sub menus only have 1 branch, then we'll display it as normal.
|
||||
if (count($subdata) == 1) {
|
||||
$sk = array_keys($subdata);
|
||||
$idx = array_shift($sk);
|
||||
}
|
||||
|
||||
if ($idx)
|
||||
foreach ($subdata[$idx] as $k=>$v) {
|
||||
array_push($data,array(
|
||||
'id'=>$v['id'],
|
||||
'name'=>$v['name'],
|
||||
'state'=>'none',
|
||||
'attr_id'=>$v['id'],
|
||||
'attr_href'=>$v['href']
|
||||
));
|
||||
}
|
||||
|
||||
else
|
||||
foreach ($subdata as $t=>$x)
|
||||
array_push($data,array('id'=>$mmo->module_id.'_'.$t,'name'=>$t,'state'=>'closed'));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output = array();
|
||||
|
||||
foreach ($data as $branch) {
|
||||
array_push($this->output,array(
|
||||
'attr'=>array('id'=>sprintf('B_%s',$branch['id'])),
|
||||
'state'=>$branch['state'],
|
||||
'data'=>array('title'=>$branch['name']),
|
||||
'attr'=>array('id'=>sprintf('N_%s',$branch['id']),'href'=>empty($branch['attr_href']) ? URL::site(sprintf('%s/menu',$branch['name'])) : $branch['attr_href']),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return parent::action_json($data);
|
||||
}
|
||||
}
|
||||
?>
|
104
application/classes/Controller/User/Account.php
Normal file
104
application/classes/Controller/User/Account.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides User Account Update functions
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_User_Account extends Controller_Account {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'resetpassword'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Enable User to Edit their Account Details
|
||||
*/
|
||||
public function action_edit() {
|
||||
// Store our new values
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$this->ao->save();
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($this->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(
|
||||
'title'=>_('Record NOT updated'),
|
||||
'type'=>'error',
|
||||
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
||||
));
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Account Edit'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory($this->viewpath())
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
|
||||
public function action_resetpassword() {
|
||||
// @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
|
||||
$this->ao->values($_POST);
|
||||
|
||||
// Run validation and save
|
||||
if ($this->ao->changed())
|
||||
if ($this->ao->check()) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>_('Record updated'),
|
||||
'type'=>'info',
|
||||
'body'=>_('Your account record has been updated.')
|
||||
));
|
||||
|
||||
$this->ao->save();
|
||||
|
||||
// Log the password reset
|
||||
$this->ao->log('Password reset');
|
||||
|
||||
HTTP::redirect('login');
|
||||
|
||||
} else {
|
||||
$output = '';
|
||||
foreach ($this->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(
|
||||
'title'=>_('Record NOT updated'),
|
||||
'type'=>'error',
|
||||
'body'=>_('Your updates didnt pass validation.').'<br/>'.$output,
|
||||
));
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Password Reset'),
|
||||
'body'=>View::factory($this->viewpath())
|
||||
->set('record',$this->ao),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
25
application/classes/Controller/User/Welcome.php
Normal file
25
application/classes/Controller/User/Welcome.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* lnApp Main home page
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers/User
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_User_Welcome extends Controller_Welcome {
|
||||
protected $auth_required = TRUE;
|
||||
protected $secure_actions = array(
|
||||
'index'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_index() {
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||
'body'=>View::factory('welcome/user'),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
29
application/classes/Controller/Welcome.php
Normal file
29
application/classes/Controller/Welcome.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB Main home page
|
||||
*
|
||||
* @package OSB
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Welcome extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_index() {
|
||||
if (! Kohana::$config->load('config')->appname)
|
||||
HTTP::redirect('guide/app');
|
||||
|
||||
// @todo This should be in the DB or something.
|
||||
HTTP::redirect('product/categorys');
|
||||
}
|
||||
|
||||
public function action_breadcrumb() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$this->response->body(Session::instance()->get_once('breadcrumb'));
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user