Compare commits

...
This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.

23 Commits
test ... master

Author SHA1 Message Date
Deon George
a27787e0d4 Unknown updates from production 2018-06-13 21:34:58 +10:00
Deon George
e412ca72d0 Clean up add and edit for SSL and adsl 2016-11-30 22:36:43 +11:00
Deon George
378946ee37 Some more fixes as a result of changing status to active 2016-11-28 22:23:42 +11:00
Deon George
8bd409d86f Some fixes as a result of prior commit changing status to active 2016-09-22 10:20:40 +10:00
Deon George
f753dfe502 Enabled bcrypt passwords 2016-09-01 20:58:06 +10:00
Deon George
cd102c6fba Moved more components into lnapp/lnauth sub modules 2016-09-01 20:58:06 +10:00
Deon George
54e4425aa8 Replace status with active in tables 2016-08-31 15:03:40 +10:00
Deon George
34e1e40f04 Inclusion of lnauth module 2016-08-25 23:26:24 +10:00
Deon George
b74fdc930f Ensure site_id is included in ORM::add(), fixed payment revendering, start product category work 2016-08-25 23:26:24 +10:00
Deon George
c1cc6b6f69 Updated Login to use lnapp, and minor update to Invoice 2016-08-18 12:38:53 +10:00
Deon George
07de13f678 Removed redundant functions, some Standardisation work 2016-08-18 12:38:50 +10:00
Deon George
24bb4a701b Revamping invoice PDF rendering and standardisation work 2016-08-18 12:38:01 +10:00
Deon George
a560c5f4fa Revamping invoice rendering 2016-08-18 12:38:01 +10:00
Deon George
7adcd1d983 Removed direct references to $_REQUEST and $_POST 2016-08-18 12:38:00 +10:00
Deon George
5f84d2c14f More Standardisation work. 2016-08-18 12:38:00 +10:00
Deon George
85f08bbb0a Standardisation work, changed accnum() to refnum() 2016-08-18 12:38:00 +10:00
Deon George
e0b45be758 Added meta title to pages 2016-08-18 12:38:00 +10:00
Deon George
f426502707 Fix for invoice with sub-items 2016-08-18 12:36:55 +10:00
Deon George
5ab2d6205f Optimised Service Display, extended SSL module functionality 2016-07-27 14:26:25 +10:00
Deon George
3d3c38b0a0 Fixed charge display and updates 2016-07-25 15:49:28 +10:00
Deon George
21d204f605 Fixed some more bootstrap rendering 2016-07-25 15:49:28 +10:00
Deon George
c29819b6bd Print message that chqs not accepted 2016-07-25 15:49:28 +10:00
Deon George
0c7fe830a3 Many updates as a result of updating lnapp; added SSL service order 2016-06-05 22:35:25 +10:00
289 changed files with 2588 additions and 4032 deletions

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule "modules/lnapp"] [submodule "modules/lnapp"]
path = modules/lnapp path = modules/lnapp
url = git@dev.leenooks.net:deon/lnapp.git url = git@dev.leenooks.net:deon/lnapp.git
[submodule "modules/lnauth"]
path = modules/lnauth
url = git@dev.leenooks.net:deon/lnauth.git

View File

@ -131,6 +131,7 @@ Kohana::$config->attach(new Config_File);
*/ */
Kohana::modules(array( Kohana::modules(array(
'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication 'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
'lnauth' => MODPATH.'lnauth', // lnAuth Base Authentication Tools
'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools 'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools
'auth' => SMDPATH.'auth', // Basic authentication 'auth' => SMDPATH.'auth', // Basic authentication
'cache' => SMDPATH.'cache', // Caching with multiple backends 'cache' => SMDPATH.'cache', // Caching with multiple backends

View File

@ -1,22 +1,23 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* This class overrides Kohana's Auth * Enahance Kohanas Auth driver.
* *
* @package OSB * @package OSB
* @category Modifications * @category Classes
* @author Deon George * @author Deon George
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Auth_ORM extends Kohana_Auth_ORM { class Auth_ORM extends lnAuth_Auth_ORM {
// Override Kohana Auth requirement to have a hash_key /**
public function hash($str) { * Determine if a user is authorised to view an account
switch ($this->_config['hash_method']) { *
case '' : return $str; * @param Model_Account Account Ojbect to validate if the current user has access
case 'md5': return md5($str); * @return boolean TRUE if authorised, FALSE if not.
default: return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']); */
} public function authorised(Model_Account $ao) {
return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR in_array($ao->id,$uo->RTM->customers($uo->RTM))));
} }
} }
?> ?>

View File

@ -1,233 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Auth driver.
*
* @package OSB
* @category Classes
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Auth_OSB extends Auth_ORM {
/**
* We need to override Kohana's __construct(), for tasks, which attempt to open a session
* and probably dont have access to PHP sessions path.
* Tasks dont need sessions anyway?
*/
public function __construct($config = array()) {
// Save the config in the object
$this->_config = $config;
if (PHP_SAPI !== 'cli')
parent::__construct($config);
}
/**
* Get the user that a token applies to
*
* This will check that the token is valid (not expired and for the request)
*
* @param $token The token
* @return Model_Account|NULL The user that the token is valid for.
*/
private function _get_token_user($token) {
// This has been implemented, as we sometimes we seem to come here twice
static $uo = NULL;
if (! is_null($uo))
return $uo;
$mmto = ORM::factory('Module_Method_Token',array('token'=>$token));
// Ignore the token if it doesnt exist.
if ($mmto->loaded()) {
// Check that the token is for this URI
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
$mmo = $mo->module_method
->where_open()
->where('name','=',strtolower(Request::current()->directory() ? sprintf('%s:%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()))
// @todo No longer required after all method names have been colon delimited
->or_where('name','=',strtolower(Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()))
->where_close()
->find();
// Ignore the token if this is not the right method.
if ($mmo->id == $mmto->method_id) {
if (! is_null($mmto->date_expire) AND $mmto->date_expire < time()) {
SystemMessage::add(array(
'title'=>_('Token Not Valid'),
'type'=>'warning',
'body'=>_('Token expired')));
Session::instance()->delete('token');
$mmto->delete();
} elseif (! is_null($mmto->uses) AND $mmto->uses < 1) {
SystemMessage::add(array(
'title'=>_('Token Not Valid'),
'type'=>'warning',
'body'=>_('Token expired')));
Session::instance()->delete('token');
$mmto->delete();
} else {
// If this is a usage count token, reduce the count.
if (! is_null($mmto->uses))
$mmto->uses -= 1;
// Record the date this token was used
$mmto->date_last = time();
$mmto->save();
Session::instance()->set('token',$token);
$uo = ORM::factory('Account',$mmto->account_id);
$uo->log(sprintf('Token %s used for method %s [%s]',$mmto->token,$mmto->module_method->id,Request::current()->param('id')));
}
}
}
return $uo;
}
/**
* Logs a user in.
*
* @param string username
* @param string password
* @param boolean enable autologin
* @return boolean
*/
protected function _login($user,$password,$remember) {
if (! is_object($user)) {
$username = $user;
// Load the user
$user = ORM::factory('Account');
$user->where('username','=',$username)->find();
// If no user loaded, return
if (! $user->loaded())
return FALSE;
}
// Create a hashed password
if (is_string($password))
$password = $this->hash($password);
// If the passwords match, perform a login
if ($user->status AND $user->has_any('group',ORM::factory('Group',array('name'=>'Registered Users'))->list_childgrps(TRUE)) AND $user->password === $password) {
// @todo This is not currently used.
if ($remember === TRUE) {
// Create a new autologin token
$token = ORM::factory('User_Token');
// Set token data
$token->user_id = $user->id;
$token->expires = time() + $this->_config['lifetime'];
$token->save();
// Set the autologin cookie
Cookie::set('authautologin', $token->token, $this->_config['lifetime']);
}
// Record our session ID, we may need to update our DB when we get a new ID
$oldsess = session_id();
// Finish the login
$this->complete_login($user);
// Do we need to update databases with our new sesion ID
$sct = Kohana::$config->load('config')->session_change_trigger;
if (session_id() != $oldsess AND count($sct))
foreach ($sct as $t => $c)
if (Config::module_exist($t))
foreach (ORM::factory(ucwords($t))->where($c,'=',$oldsess)->find_all() as $o)
$o->set('session_id',session_id())
->update();
return TRUE;
}
// Login failed
return FALSE;
}
/**
* Determine if a user is authorised to view an account
*
* @param Model_Account Account Ojbect to validate if the current user has access
* @return boolean TRUE if authorised, FALSE if not.
*/
public function authorised(Model_Account $ao) {
return (($uo = $this->get_user()) AND $uo->loaded() AND ($uo == $ao OR in_array($ao->id,$uo->RTM->customers($uo->RTM))));
}
/**
* Gets the currently logged in user from the session.
* Returns NULL if no user is currently logged in.
*
* @param boolean Check token users too
* @return mixed
*/
public function get_user($default=NULL,$tokenuser=TRUE) {
// If we are a CLI, we are not logged in
if (PHP_SAPI === 'cli')
throw new Kohana_Exception('Calling :method from the CLI is not allowed!',array(':method'=>__METHOD__));
// Get the current user
$uo = parent::get_user($default);
// If we are not logged in, see if there is token for the user
if (is_null($uo) AND $tokenuser AND ($token=Session::instance()->get('token')) OR (! empty($_REQUEST['token']) AND $token=$_REQUEST['token']))
$uo = $this->_get_token_user($token);
return $uo;
}
public function get_groups() {
return is_null($x=$this->get_user()) ? ORM::factory('Group')->where('id','=',0)->find_all() : $x->groups();
}
/**
* OSB authentication is controlled via database queries.
*
* This method can be used to test two situations:
* 1) Is the user logged in? ($role == FALSE)
* 2) Can the user run the current controller->action ($role == TRUE)
*
* @param boolean If authentication should be done for this module:method (ie: controller:action).
* @return boolean
*/
public function logged_in($role=NULL,$debug=NULL) {
$status = FALSE;
// If we are a CLI, we are not logged in
if (PHP_SAPI === 'cli')
return $status;
// Get the user from the session
$uo = $this->get_user();
// If we are not a valid user object, then we are not logged in
if (is_object($uo) AND ($uo instanceof Model_Account) AND $uo->loaded())
if (! empty($role)) {
if (($x = Request::current()->mmo()) instanceof Model)
// If the role has the authorisation to run the method
foreach ($x->group->find_all() as $go)
if ($go->id == 0 OR $uo->has_any('group',$go->list_childgrps(TRUE))) {
$status = TRUE;
break;
}
// There is no role, so the method should be allowed to run as anonymous
} else
$status = TRUE;
return $status;
}
}
?>

View File

@ -21,7 +21,7 @@ class Company {
if (! $this->so->loaded()) if (! $this->so->loaded())
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http'))); throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
Kohana::$environment = (int)$this->so->status; Kohana::$environment = (int)$this->so->active;
} }
public static function instance() { public static function instance() {
@ -34,7 +34,7 @@ class Company {
} }
public function admin() { public function admin() {
return $this->so->account->name(); return $this->so->account;
} }
public function address($ln='<br/>') { public function address($ln='<br/>') {
@ -83,7 +83,7 @@ class Company {
return ($x=Kohana::find_file(sprintf('media/site/%s',$this->site()),$path,$suffix)) ? $x : Kohana::find_file('media',$path,$suffix); return ($x=Kohana::find_file(sprintf('media/site/%s',$this->site()),$path,$suffix)) ? $x : Kohana::find_file('media',$path,$suffix);
} }
public function name() { public function name($variable=NULL) {
return $this->so->site_details('name'); return $this->so->site_details('name');
} }

View File

@ -10,26 +10,6 @@
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Controller_Account extends Controller_TemplateDefault { class Controller_Account extends Controller_TemplateDefault {
protected function group() { protected $icon = 'fa fa-users';
// List all available groups for this user.
$output = '';
foreach ($this->ao->groups() as $go)
$output .= sprintf('Group %s: %s<br/>',$go->id,$go->display('name'));
Block::factory()
->title('Group Structure')
->body($output);
// List all available methods for this user.
$output = '';
foreach ($this->ao->methods() as $mmo)
$output .= sprintf('Module: %s, Method %s: %s<br/>',$mmo->module->name,$mmo->name,$mmo->url());
Block::factory()
->title('Available Methods')
->body($output);
}
} }
?> ?>

View File

@ -1,193 +0,0 @@
<?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,
);
protected function _classes($dir,$class,$array=NULL,$key='') {
$result = array();
if (is_null($array)) {
$array = Kohana::list_files('classes');
$array = $array['classes/Controller'];
$key = 'classes/Controller';
}
if (! $class)
return array_keys($array);
if (! $dir) {
if (! empty($array[$key.'/'.$class]))
$result = Arr::merge($result,$this->_classes('','',$array[$key.'/'.$class],$key.'/'.$class));
if (! empty($array[$key.'/'.$class.'.php']))
array_push($result,$key.'/'.$class);
} else {
if (! empty($array[$key.'/'.$dir]))
$result = Arr::merge($result,$this->_classes('',$class,$array[$key.'/'.$dir],$key.'/'.$dir));
if (! empty($array[$key.'/'.$dir.'/'.$class.'.php']))
array_push($result,$key.'/'.$dir.'/'.$class);
}
foreach ($result as $k=>$v)
$result[$k] = str_replace('.php','',str_replace('/','_',preg_replace('/^classes\//','',$v)));
return $result;
}
/**
* Get the list of methods for a class
*/
protected function _methods($class) {
$class = Kohana::classname($class);
// Get a list of methods this module has
$methods = $secure_actions = $auth_required = array();
// List of classes where all our methods are, including this one.
$classes = URL::$method_directory;
array_unshift($classes,'');
foreach ($classes as $c) {
$x = URL::dir($c);
$cp = $this->_classes($x,$class);
foreach ($cp as $cn)
if (class_exists($cn)) {
$sc = preg_replace(sprintf('/^Controller_%s%s_?/',$x ? $x.'_' : '',$class),'',$cn);
$r = new ReflectionClass($cn);
$rdp = $r->getDefaultProperties();
$secure_actions[$cn] = $rdp['secure_actions'];
$auth_required[$cn] = $rdp['auth_required'];
foreach ($r->getMethods() as $method)
if (preg_match('/^action_/',$method->name))
array_push($methods,
str_replace('action_',
#strtolower(($x ? $x.'_' : '').($sc ? $sc.'_' : '')),
strtolower($x.($sc ? '_'.$sc : '').':'),
$method->name)
);
}
}
return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required);
}
/**
* Edit a Module Configuration
*/
public function action_edit() {
$id = $this->request->param('id');
$mo = ORM::factory('Module',$id);
$methods = array();
if (! $mo->loaded()) {
SystemMessage::factory()
->title(_('Invalid Module ID'))
->type('error')
->body(sprintf(_('Module with ID %s doesnt appear to exist?'),$id));
HTTP::redirect(URL::link('admin','module/list'));
}
$mm = $this->_methods($mo->name);
$methods['exist'] = array();
foreach ($mo->module_method->find_all() as $mmo) {
if (in_array($mmo->name,$mm['methods'])) {
$k = array_search($mmo->name,$mm['methods']);
unset($mm['methods'][$k]);
$mmo->status('INDB');
} else
$mmo->status('ORPHAN');
if (! empty($mm['secure_actions'][$mmo->controller()][$mmo->method()]))
unset($mm['secure_actions'][$mmo->controller()][$mmo->method()]);
array_push($methods['exist'],$mmo);
}
$methods['missing'] = array();
foreach ($mm['methods'] as $k=>$method) {
$mmo = ORM::factory('Module_Method');
$mmo->module_id = $mo->id;
$mmo->name = $method;
if (! empty($mm['auth_required'][$mmo->controller()]) AND $mm['auth_required'][$mmo->controller()])
$mmo->status('MISSING');
array_push($methods['missing'],$mmo);
}
Block::factory()
->title(sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')))
->title_icon('icon-cog')
->body(Table::factory()
->data($methods['exist'])
->columns(array(
'id'=>'ID',
'name'=>'Name',
'notes'=>'Notes',
'menu_display'=>'Menu',
'status()'=>'Status',
))
->prepend(array(
'id'=>array('url'=>URL::link('admin','module_method/edit/')),
))
);
Block::factory()
->title(sprintf('%s: %s ',_('Missing Module Methods For'),$mo->display('name')))
->title_icon('icon-exclamation-sign')
->body(Table::factory()
->data($methods['missing'])
->columns(array(
'name'=>'Name',
'status()'=>'Status',
))
->prepend(array(
'name'=>array('url'=>URL::link('admin','module_method/add/'.$mo->id.'/')),
))
);
}
/**
* List our installed modules
*/
public function action_list() {
Block::factory()
->title('Defined Modules')
->title_icon('icon-cog')
->body(Table::factory()
->data(ORM::factory('Module')->where('parent_id','is',NULL)->find_all())
->jssort(TRUE)
->columns(array(
'id'=>'ID',
'name'=>'Name',
'notes'=>'Notes',
'status'=>'Active',
'external'=>'External',
))
->prepend(array(
'id'=>array('url'=>URL::link('admin','module/edit/')),
))
);
}
}
?>

View File

@ -1,109 +0,0 @@
<?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);
$mm = $this->_methods($mo->name);
if (! $mo->loaded() OR ! in_array($method,$mm['methods']))
HTTP::redirect(URL::link('admin','module/list'));
if ($_POST) {
$mmo = $mo->module_method;
$mmo->name = $method;
$mmo->module_id = $mo->id;
$mmo->values($_POST);
if (! $this->save($mmo))
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
HTTP::redirect(URL::link('admin','module/edit/'.$mo->id));
}
Block::factory()
->title(sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($method),strtoupper($mo->name)))
->title_icon('icon-plus-sign')
->type('form-horizontal')
->body(View::factory('module/method/admin/add')
->set('name',$method)
->set('o',$mo)
);
}
/**
* Edit a Module Configuration
*/
public function action_edit() {
$id = $this->request->param('id');
$mmo = ORM::factory('Module_Method',$id);
if (! $mmo->loaded()) {
SystemMessage::factory()
->title(_('Invalid Method ID'))
->type('error')
->body(sprintf(_('Method with ID %s doesnt appear to exist?'),$id));
HTTP::redirect(URL::link('admin','module/list'));
}
if ($_POST) {
$mmo->values($_POST);
if (! $this->save($mmo))
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
foreach (ORM::factory('Group')->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']))) {
$gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
if (! $gmo->delete())
SystemMessage::factory()
->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'])) {
$gmo = ORM::factory('Group_Method')
->values(array(
'method_id'=>$mmo->id,
'group_id'=>$go->id,
));
if (! $this->save($gmo))
SystemMessage::factory()
->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));
}
}
HTTP::redirect(URL::link('admin','module/edit/'.$mmo->module_id));
}
Block::factory()
->title(sprintf(_('Configure access to method (%s::%s)'),$mmo->controller(),$mmo->method()))
->title_icon('icon-plus-sign')
->type('form')
->body(View::factory('module/method/admin/edit')
->set('o',$mmo)
);
}
}
?>

View File

@ -20,18 +20,18 @@ class Controller_Admin_Setup extends Controller_TemplateDefault {
public function action_edit() { public function action_edit() {
$o = Company::instance()->so(); $o = Company::instance()->so();
if ($_POST AND $o->values($_POST)->changed() AND (! $this->save($o))) if ($this->request->post() AND $o->values($this->request->post())->changed() AND (! $this->save($o)))
$o->reload(); $o->reload();
Block::factory() Block::factory()
->title('Update Site Configuration') ->title('Update Site Configuration')
->title_icon('icon-wrench') ->title_icon('fa fa-wrench')
->type('form-horizontal') ->type('form-horizontal')
->body(View::factory('setup/admin/edit')->set('o',$o)); ->body(View::factory('setup/admin/edit')->set('o',$o));
Block::factory() Block::factory()
->title('Update Module Configuration') ->title('Update Module Configuration')
->title_icon('icon-wrench') ->title_icon('fa fa-wrench')
->type('form-horizontal') ->type('form-horizontal')
->body(View::factory('setup/admin/module')->set('o',$o)->set('mid',NULL)); ->body(View::factory('setup/admin/module')->set('o',$o)->set('mid',NULL));
} }

View File

@ -11,6 +11,8 @@
* @also [logout] * @also [logout]
*/ */
class Controller_Login extends lnApp_Controller_Login { class Controller_Login extends lnApp_Controller_Login {
protected $login_attribute = 'username';
/** /**
* Enable site registration * Enable site registration
* *
@ -23,70 +25,5 @@ class Controller_Login extends lnApp_Controller_Login {
HTTP::redirect('login'); 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']))
$output = View::factory('pages/login_reset_sent');
else
HTTP::redirect('login');
} else {
$output = View::factory('pages/login_reset');
}
Style::factory()
->type('file')
->data('media/theme/baseadmin/css/pages/login.css');
$this->template->content = $output;
$this->template->shownavbar = FALSE;
}
} }
?> ?>

View File

@ -1,14 +0,0 @@
<?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 {
}
?>

View File

@ -20,127 +20,35 @@ class Controller_Reseller_Account extends Controller_Account {
* Show a list of accounts * Show a list of accounts
*/ */
public function action_list() { public function action_list() {
$this->meta->title = 'R|Customer List';
Block::factory() Block::factory()
->title(_('Customer List')) ->title(_('Customer List'))
->title_icon('icon-th-list') ->title_icon($this->icon)
->body(Table::factory() ->body(View::factory('account/list')->set('o',ORM::factory('Account')->where_authorised($this->ao,'id')->find_all()));
->data(ORM::factory('Account')->where_authorised($this->ao,'id')->find_all())
->jssort('customer')
->columns(array(
'id'=>'ID',
'status'=>'Active',
'accnum()'=>'Num',
'name(TRUE)'=>'Account',
'email'=>'Email',
'invoices_due_total(NULL,TRUE)'=>'Invoices',
'service->list_count()'=>'Services',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','account/view/')),
))
);
} }
/** /**
* Show a list of account logins * Show a list of account logins
*/ */
public function action_listlog() { public function action_listlog() {
$this->meta->title = 'R|Customer Logins';
Block::factory() Block::factory()
->title(_('Customer Login Activity')) ->title(_('Customer List'))
->title_icon('icon-eye-open') ->title_icon('fa fa-eye')
->body(Table::factory() ->body(View::factory('account/listlog')->set('o',ORM::factory('Account_Log')->where_authorised($this->ao)->find_all()));
->data(ORM::factory('Account_Log')->where_authorised($this->ao)->find_all())
->page_items(25)
->columns(array(
'id'=>'ID',
'date_orig'=>'Date',
'account->name()'=>'Account',
'ip'=>'IP Address',
'details'=>'Details',
))
);
} }
public function action_view() { public function action_view() {
$ao = ORM::factory('Account',$this->request->param('id')); $ao = ORM::factory('Account',$this->request->param('id'));
if (! $ao->loaded() OR ! $ao->status OR ! Auth::instance()->authorised($ao)) if (! $ao->loaded() OR ! $ao->active OR ! Auth::instance()->authorised($ao))
throw HTTP_Exception::factory(403,'Account either doesnt exist, or you are not authorised to see it'); throw HTTP_Exception::factory(403,'Account either doesnt exist, or you are not authorised to see it');
Block::factory() $this->meta->title = 'Customer: '.$ao->name();
->title(sprintf('Active Service for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body(Table::factory()
->data($ao->service->list_active())
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
Block::factory() $this->template->content = View::factory('account/reseller/view')->set('o',$ao);
->title(sprintf('Invoices Due Account: %s (%s)',$ao->accnum(),$ao->invoice->list_due_total(TRUE)))
->title_icon('icon-info-sign')
->span(6)
->body(Table::factory()
->data($ao->invoice->list_due())
->columns(array(
'id'=>'ID',
'due_date'=>'Date Due',
'total(TRUE)'=>'Invoice Total',
'due(TRUE)'=>'Amount Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
Block::factory()
->title(sprintf('Services Expiring for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body(Table::factory()
->data($ao->service->list_expiring())
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
'expire(TRUE)'=>'Date',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
$i = Invoice::instance();
foreach ($ao->service->list_active() as $io)
if (! $io->suspend_billing AND ! $io->external_billing)
$i->add_service($io);
Block::factory()
->title(sprintf('Next Invoice Items for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body($i->render('html','body',array('noid'=>TRUE)));
Block::factory()
->title(sprintf('InActive Services for Account: %s',$ao->accnum()))
->title_icon('icon-info-sign')
->span(6)
->body(Table::factory()
->data($ao->service->where('status','!=',1)->or_where('status','IS',null)->find_all())
->columns(array(
'id'=>'ID',
'service_name()'=>'Service',
'date_end'=>'Date',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','service/view/')),
))
);
} }
} }
?> ?>

View File

@ -19,89 +19,29 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
public function action_index() { public function action_index() {
$t = time(); $t = time();
// Show outstanding invoices
$o = ORM::factory('Invoice');
Block::factory()
->title($this->ao->RTM->display('name'))
->body('');
Block::factory() Block::factory()
->title('Invoices Overdue - No Auto Billing') ->title('Invoices Overdue - No Auto Billing')
->title_icon('icon-info-sign') ->title_icon('fa fa-pencil-square-o')
->span(6) ->span(6)
->body(Table::factory() ->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t)));
->data($o->list_overdue_billing($t))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
Block::factory() Block::factory()
->title('Invoices Overdue - Auto Billing') ->title('Invoices Overdue - Auto Billing')
->title_icon('icon-info-sign') ->title_icon('fa fa-pencil-square-o')
->span(6) ->span(6)
->body(Table::factory() ->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t,TRUE)));
->data($o->list_overdue_billing($t,TRUE))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
Block::factory() Block::factory()
->title('Upcoming Invoices') ->title('Upcoming Invoices')
->title_icon('icon-info-sign') ->title_icon('fa fa-pencil-square-o')
->span(6) ->span(6)
->body(Table::factory() ->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_due($t)));
->data($o->list_due(time()))
->columns(array(
'id'=>'ID',
'due_date'=>'Due',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'total(TRUE)'=>'Total',
'due(TRUE)'=>'Due',
))
->prepend(array(
'id'=>array('url'=>URL::link('user','invoice/view/')),
))
);
Block::factory() Block::factory()
->title('Un-applied payments') ->title('Un-applied payments')
->title_icon('icon-info-sign') ->title_icon('fa fa-money')
->span(6) ->span(6)
->body(Table::factory() ->body(View::factory('payment/list')->set('o',ORM::factory('Payment')->where_authorised()->list_unapplied()));
->data(ORM::factory('Payment')->where_authorised()->list_unapplied())
->columns(array(
'id'=>'ID',
'date_payment'=>'Pay Date',
'account->accnum()'=>'Num',
'account->name()'=>'Account',
'account->display("status")'=>'Active',
'total(TRUE)'=>'Total',
'balance(TRUE)'=>'Balance',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','payment/view/')),
))
);
} }
/** /**

View File

@ -1,57 +0,0 @@
<?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
*/
abstract class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
protected $auth_required = TRUE;
// @todo To rework
public function after() {
$dc = URL::link('user','welcome/index');
$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();
}
protected function save(Model $o) {
try {
return $o->save();
} catch (ORM_Validation_Exception $e) {
SystemMessage::factory()
->title('Record NOT updated')
->type('error')
->body(join('<br/>',array_values($e->errors('models'))));
return FALSE;
}
}
protected function setup(array $config_items=array()) {
$mo = ORM::factory('Module',array('name'=>Request::current()->controller()));
if (! $mo->loaded())
throw HTTP_Exception::factory(501,'Unknown module :module',array(':module'=>Request::current()->controller()));
if ($_POST AND isset($_POST['module_config'][$mo->id]))
Config::instance()->module_config($mo->name,$_POST['module_config'][$mo->id])->save();
if ($config_items) {
Block::factory()
->title('Update Module Configuration')
->title_icon('icon-wrench')
->type('form-horizontal')
->body(View::factory('setup/admin/module')->set('o',Company::instance()->so())->set('mid',$mo->id));
}
}
}
?>

View File

@ -1,104 +0,0 @@
<?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() {
if ($_POST AND $this->ao->values($_POST)->changed() AND (! $this->save($this->ao)))
$this->ao->reload();
Block::factory()
->title(sprintf('Account: %s',$this->ao->accnum()))
->title_icon('icon-wrench')
->type('form-horizontal')
->body(View::factory('account/user/edit')->set('o',$this->ao));
}
public function action_resetpassword() {
if ($this->request->post()) {
$validation = Validation::factory($this->request->post())
->rule('password','not_empty')
->rule('password','min_length',array(':value',6))
->rule('password_confirm','matches',array(':validation',':field','password'));
// Store our new values
$this->ao->values($this->request->post());
if (! $validation->check())
SystemMessage::factory()
->title(_('Record NOT updated'))
->type('error')
->body(_('Your password didnt pass validation.'));
// Run validation and save
elseif ($this->ao->changed())
if ($this->ao->save()) {
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your account record has been updated.'));
// Log the password reset
$this->ao->log('Password reset');
HTTP::redirect('login');
}
}
if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure())
Script::factory()
->type('src')
->data('media/js/jquery/jquery.validate-1.11.1.min.js');
else
Script::factory()
->type('src')
->data('http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js');
Script::factory()
->type('stdin')
->data('
$("#reset").validate({
wrapper: "div",
errorElement: "span",
rules: {
password_confirm: {
equalTo: "input[name=password]",
},
},
highlight: function(element) {
$(element).parents(".control-group").removeClass("success").addClass("error");
},
success: function(element) {
$(element).parents(".control-group").removeClass("error").addClass("success");
},
errorPlacement: function(error, element) {
error.appendTo(element.parents(".controls"));
}
});
');
Block::factory()
->title(sprintf('Password Reset: %s',$this->ao->accnum()))
->title_icon('icon-cog')
->id('reset')
->type('form-horizontal')
->body(View::factory('account/user/resetpassword')->set('o',$this->ao));
}
}
?>

View File

@ -20,13 +20,13 @@ class Controller_User_Search extends Controller_Search {
public function action_ajaxlist() { public function action_ajaxlist() {
$result = array(); $result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) { if ($this->request->query('term')) {
$result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($_REQUEST['term'],'url','id',array('ACC %s: %s'=>array('id','name(TRUE)')),array(),array('urlprefix'=>URL::link('reseller','account/view/')))); $result = Arr::merge($result,ORM::factory('Account')->list_autocomplete($this->request->query('term'),'url','id',array('ACC %s: %s'=>array('id','name()')),array(),array('urlprefix'=>URL::link('reseller','account/view/'))));
$result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($_REQUEST['term'],'url','id',array('SVC %s: %s'=>array('id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/')))); $result = Arr::merge($result,ORM::factory('Service')->list_autocomplete($this->request->query('term'),'url','id',array('SVC %s: %s'=>array('id','name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
$result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>URL::link('user','invoice/view/')))); $result = Arr::merge($result,ORM::factory('Invoice')->list_autocomplete($this->request->query('term'),'url','id',array('INV %s: %s'=>array('id','account->name()')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o) foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
$result = Arr::merge($result,ORM::factory($o)->list_autocomplete($_REQUEST['term'],'url','service_id',array('SVC %s: %s'=>array('service_id','service_name()')),array(),array('urlprefix'=>URL::link('user','service/view/')))); $result = Arr::merge($result,ORM::factory($o)->list_autocomplete($this->request->query('term'),'url','service_id',array('SVC %s: %s'=>array('service_id','service->name()')),array(),array('urlprefix'=>URL::link('user','service/view/'))));
} }
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');

View File

@ -12,24 +12,15 @@
class Controller_Welcome extends Controller_TemplateDefault { class Controller_Welcome extends Controller_TemplateDefault {
protected $auth_required = FALSE; protected $auth_required = FALSE;
public function action_breadcrumb() {
$this->auto_render = FALSE;
$this->response->body(Session::instance()->get_once('breadcrumb'));
}
public function action_index() { public function action_index() {
if (! Kohana::$config->load('config')->appname) if (! Kohana::$config->load('config')->appname)
HTTP::redirect('guide/app'); HTTP::redirect('guide/app');
$output = '';
$output = View::factory('pages/welcome');
Style::factory() Style::factory()
->type('file') ->type('file')
->data('media/css/pages/welcome.css'); ->data('media/css/pages/welcome.css');
$this->template->content = $output; $this->template->content = View::factory('pages/welcome');
} }
} }
?> ?>

View File

@ -1,35 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's DB
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class DB extends Kohana_DB {
// Add the site_id to the delete query
public static function delete($table = NULL)
{
$db = new Database_Query_Builder_Delete($table);
if (! in_array($table,ORM::$no_site_id_tables))
return $db->where($table.'.site_id','=',Company::instance()->site());
else
return $db;
}
// Add the site_id to the update query
final public static function update($table = NULL)
{
$db = new Database_Query_Builder_Update($table);
if (! in_array($table,ORM::$no_site_id_tables))
return $db->where($table.'.site_id','=',Company::instance()->site());
else
return $db;
}
}
?>

View File

@ -12,7 +12,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Database_MySQL extends Kohana_Database_MySQL { class Database_MySQLi extends Kohana_Database_MySQLi {
// MySQL uses a backtick for identifiers // MySQL uses a backtick for identifiers
protected $_identifier = ''; protected $_identifier = '';
} }

View File

@ -19,6 +19,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
*/ */
public static function log(Exception $e,$level=Log::EMERGENCY) { public static function log(Exception $e,$level=Log::EMERGENCY) {
try { try {
if (class_exists('Model_Log_Error')) {
$eo = ORM::factory('Log_Error'); $eo = ORM::factory('Log_Error');
$eo->message = Kohana_Exception::text($e); $eo->message = Kohana_Exception::text($e);
$eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id; $eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
@ -29,6 +30,7 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
} }
$eo->save(); $eo->save();
}
} catch (Exception $x) { } catch (Exception $x) {
return parent::log($e,$level); return parent::log($e,$level);
@ -48,11 +50,13 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
return parent::response($e); return parent::response($e);
} else { } else {
if (class_exists('SystemMessage')) {
SystemMessage::add(array( SystemMessage::add(array(
'title'=>'An Error Occured.', 'title'=>'An Error Occured.',
'type'=>'error', 'type'=>'error',
'body'=>'Dont panic, its been logged.', 'body'=>'Dont panic, its been logged.',
)); ));
}
// We'll redirect to the main page. // We'll redirect to the main page.
$response = Response::factory(); $response = Response::factory();

View File

@ -1,71 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is used to create our Menu/Navbars
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Menu extends lnApp_Menu {
private static function collapse(array $array) {
$result = array();
foreach ($array as $mmo) {
if (isset($result[$mmo->module->name])) {
if (! is_array($result[$mmo->module->name]))
$result[$mmo->module->name] = array($result[$mmo->module->name]);
array_push($result[$mmo->module->name],$mmo);
continue;
} else {
$result[$mmo->module->name] = $mmo;
}
}
return $result;
}
public static function items($type) {
$result = array();
if (empty(URL::$method_directory[$type]))
return NULL;
$ao = Auth::instance()->get_user();
if (is_object($ao))
foreach ($ao->methods() as $mmo)
if ($mmo->menu_display AND $type == $mmo->directory())
if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
return self::collapse($result);
}
public static function ul($type,array $result,array $append=NULL,$sub=FALSE,$method=NULL) {
$output = $sub ? '<ul class="dropdown-menu">' : '<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">';
foreach ($result as $k => $v)
if (is_array($v))
$output .= sprintf('<li class="dropdown-submenu">%s%s',HTML::anchor('#',$k,array('nocg'=>TRUE)),self::ul($type,$v,NULL,TRUE).'</li>');
else
$output .= '<li>'.HTML::anchor($v->url(),$v->menu_display(),array('tabindex'=>-1,'nocg'=>TRUE)).'</li>';
if ($append) {
$output .= '<li class="divider"></li>';
foreach ($append as $k => $v)
$output .= sprintf('<li>%s</li>',HTML::anchor($k,$v,array('nocg'=>TRUE)));
}
$output .= '</ul>';
return $output;
}
}
?>

View File

@ -1,25 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's Minion CLI Module
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Minion_Task extends Kohana_Minion_Task {
protected $_sysoptions = array(
'site'=>NULL,
);
/**
* Override our __construct so that we can specify options in each class file
*/
protected function __construct() {
// Populate $_accepted_options based on keys from $_options
$this->_accepted_options = array_keys(Arr::merge($this->_sysoptions,$this->_options));
}
}
?>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Account extends Model_Auth_UserDefault { class Model_Account extends lnAuth_Model_Account {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'user_tokens'=>array('model'=>'user_token'), 'user_tokens'=>array('model'=>'user_token'),
@ -21,48 +21,31 @@ class Model_Account extends Model_Auth_UserDefault {
); );
protected $_has_one = array( protected $_has_one = array(
'country'=>array('foreign_key'=>'id'),
'currency'=>array('foreign_key'=>'id'),
'language'=>array('foreign_key'=>'id'),
'RTM'=>array('far_key'=>'id'), 'RTM'=>array('far_key'=>'id'),
); );
protected $_display_filters = array( // Validation rules
'date_orig'=>array( public function rules() {
array('Site::Date',array(':value')), return array(
'username' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 256)),
), ),
'date_last'=>array( 'email' => array(
array('Site::Date',array(':value')), array('not_empty'),
), // @note: cant use unique emails, since multiple accounts may share the same email
'status'=>array( // array(array($this, 'unique'), array('email', ':value')),
array('StaticList_YesNo::get',array(':value',TRUE)), array('min_length', array(':value', 4)),
array('max_length', array(':value', 127)),
array('email'),
), ),
); );
protected $_form = array('id'=>'id','value'=>'name(TRUE)');
protected $_save_message = TRUE;
/**
* Our account number format
*/
public function accnum() {
return sprintf('%s-%04s',Company::instance()->site(TRUE),$this->id);
} }
/** /** REQUIRED ABSTRACT METHODS **/
* Get the groups that an account belongs to
*/
public function groups() {
$result = array();
foreach ($this->group->where_active()->find_all() as $go) /** LOCAL METHODS **/
foreach ($go->list_parentgrps(TRUE) as $cgo)
if (empty($result[$cgo->id]))
$result[$cgo->id] = $cgo;
return $result;
}
/** /**
* Get a list of all invoices for this account * Get a list of all invoices for this account
@ -73,14 +56,6 @@ class Model_Account extends Model_Auth_UserDefault {
return $processed ? $o->find_all() : $o->where_unprocessed()->find_all(); return $processed ? $o->find_all() : $o->where_unprocessed()->find_all();
} }
public function isAdmin() {
return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
}
public function isReseller() {
return $this->RTM->loaded();
}
/** /**
* Get a list of due invoices for this account * Get a list of due invoices for this account
* *
@ -108,43 +83,33 @@ class Model_Account extends Model_Auth_UserDefault {
return $format ? Currency::display($result) : $result; return $format ? Currency::display($result) : $result;
} }
public function log($message) { public function isAdmin() {
// Log a message for this account return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
$alo = ORM::factory('Account_Log');
$alo->account_id = $this->id;
$alo->ip = Request::$client_ip;
$alo->details = $message;
$alo->save();
return $alo->saved();
} }
/** /**
* This function will extract the available methods for this account * Is this account a company account
* This is used both for menu options and method security
*/ */
public function methods() { public function isCompany() {
static $result = array(); return strlen($this->company) > 0;
}
// @todo We may want to optimise this with some session caching. public function isReseller() {
if ($result) return $this->RTM->loaded();
return $result;
foreach ($this->groups() as $go)
foreach ($go->module_method->find_all() as $mmo)
if (empty($result[$mmo->id]))
$result[$mmo->id] = $mmo;
Sort::MAsort($result,'module->name,menu_display');
return $result;
} }
/** /**
* Return an account name * Returns the company name if it exists, otherwise the persons name
*/ */
public function name($withcompany=FALSE) { public function name($variable=NULL) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : '')); return $this->isCompany() ? $this->company : $this->namesub();
}
/*
* Returns the persons name
*/
public function namesub($variable=NULL) {
return trim(sprintf('%s %s',$this->first_name,$this->last_name));
} }
/** /**
@ -159,10 +124,22 @@ class Model_Account extends Model_Auth_UserDefault {
return $sk.sprintf('%s %s',$this->last_name,$this->first_name); return $sk.sprintf('%s %s',$this->last_name,$this->first_name);
} }
/**
* Generate a token for non-login authorised functinos
*/
public function token($token_expire,$module,$method,$uses) {
return ORM::factory('Module_Method_Token')
->method(array($module,$method))
->account($this)
->uses($uses)
->expire(time()+$token_expire*60)
->generate();
}
/** /**
* Search for accounts matching a term * Search for accounts matching a term
*/ */
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) { public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
$ao = Auth::instance()->get_user(); $ao = Auth::instance()->get_user();
$this->clear(); $this->clear();
@ -198,7 +175,7 @@ class Model_Account extends Model_Auth_UserDefault {
// Restrict results to authorised accounts // Restrict results to authorised accounts
array_push($limit,array('id','IN',$ao->RTM->customers($ao->RTM))); array_push($limit,array('id','IN',$ao->RTM->customers($ao->RTM)));
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options); return parent::list_autocomplete($term,$index,$value,$label,$limit,array_merge($options,array('parentbypass'=>TRUE)));
} }
} }
?> ?>

View File

@ -1,27 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Account Login Logging
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Account_Log extends ORM_OSB {
protected $_belongs_to = array(
'account'=>array(),
);
protected $_sorting = array(
'id'=>'DESC',
);
protected $_display_filters = array(
'date_orig'=>array(
array('Site::Datetime',array(':value')),
),
);
}
?>

View File

@ -1,42 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Auth_UserDefault extends Model_Auth_User {
// Validation rules
public function rules() {
return array(
'username' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 256)),
),
'email' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 127)),
array('email'),
),
);
}
/**
* Complete our login
*
* For some database logins, we may not want to record the user last login
* details in the repository, so we just override that parent function
* here.
*
* We can also do some other post-login actions here.
*/
public function complete_login() {
return $this->log('Logged In');
}
}
?>

View File

@ -1,31 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Country Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Country extends ORM_OSB {
protected $_has_one = array(
'currency'=>array('far_key'=>'id'),
);
protected $_has_many = array(
'tax'=>array('far_key'=>'id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
public static function icon() {
return HTML::image(sprintf('media/img/country/%s.png',strtolower($this->two_code)),array('alt'=>$this->currency->symbol));
}
}
?>

View File

@ -1,19 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Currency Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Currency extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@ -8,66 +8,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Group extends Model_Auth_Role { class Model_Group extends lnAuth_Model_Group {
// Relationships
protected $_has_many = array(
'account'=>array('through'=>'account_group'),
'module_method'=>array('through'=>'group_method','far_key'=>'method_id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_display_filters = array(
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
);
/**
* This function will, given a group, list all of the children that
* are also related to this group, in the group heirarchy.
*/
public function list_childgrps($incParent=FALSE) {
$result = array();
if (! $this->loaded())
return $result;
foreach (ORM::factory('Group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) {
array_push($result,$go);
$result = array_merge($result,$go->list_childgrps());
}
if ($incParent)
array_push($result,$this);
return $result;
}
/**
* This function will, given a group, list all of the parent that
* are also related to this group, in the group heirarchy.
*/
public function list_parentgrps($incParent=FALSE) {
$result = array();
if (! $this->loaded())
return $result;
foreach (ORM::factory('Group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) {
array_push($result,$go);
$result = array_merge($result,$go->list_parentgrps());
}
if ($incParent)
array_push($result,$this);
return $result;
}
/** /**
* Get a list of groups that have their own pricing * Get a list of groups that have their own pricing
*/ */

View File

@ -1,25 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Application Module Method Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Group_Method extends ORM_OSB {
// Relationships
protected $_has_one = array(
'record_id'=>array(),
);
protected $_belongs_to = array(
'group'=>array(),
);
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
}
?>

View File

@ -1,19 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Language Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Language extends ORM_OSB {
protected $_sorting = array(
'name'=>'ASC',
);
protected $_form = array('id'=>'id','value'=>'name');
}
?>

View File

@ -9,6 +9,6 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Log_Error extends ORM_OSB { class Model_Log_Error extends ORM {
} }
?> ?>

View File

@ -1,55 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Application Module Model
*
* This module must remain in applications/ as it is used very early in the
* OSB initialisation.
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Module extends ORM_OSB {
// Relationships
protected $_has_one = array(
'record_id'=>array('model'=>'Record_ID','far_key'=>'id'),
);
protected $_has_many = array(
'module_method'=>array('far_key'=>'id'),
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_display_filters = array(
'external'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
'name'=>array(
array('strtoupper',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
),
);
/**
* Return an instance of this Module's Model
*
* @param $id PK of Model
*/
public function instance($id=NULL) {
if (! $this->loaded())
throw new Kohana_Exception('Cant call an instance of a model when it is not loaded');
return ORM::factory(Kohana::classname($this->name),$id);
}
public function list_external() {
return $this->_where_active()->where('external','=',TRUE)->find_all();
}
}
?>

View File

@ -9,28 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Module_Method extends ORM_OSB { class Model_Module_Method extends lnAuth_Model_Module_Method {
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
// Relationships
protected $_belongs_to = array(
'module'=>array(),
);
protected $_has_one = array(
'record_id'=>array(),
);
protected $_has_many = array(
'group'=>array('through'=>'group_method','foreign_key'=>'method_id')
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $status;
// Temporarily adjust our name // Temporarily adjust our name
// @todo This is temporary until all our method names are colon delimited. // @todo This is temporary until all our method names are colon delimited.
protected function _load_values(array $values) { protected function _load_values(array $values) {
@ -43,48 +22,5 @@ class Model_Module_Method extends ORM_OSB {
return $this; return $this;
} }
public function controller_sub() {
return substr_count($this->name,'_') ? substr($this->name,($x=strpos($this->name,'_')),strpos($this->name,':')-$x) : '';
}
public function controller() {
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name).$this->controller_sub());
}
public function directory() {
return substr($this->name,0,substr_count($this->name,'_') ? strpos($this->name,'_') : strpos($this->name,':'));
}
/**
* Calculate the description for this method on any menu link
*/
public function menu_display() {
// @todo The test for value equal 1 is for legacy, remove when all updated.
if ($this->menu_display AND $this->menu_display != 1)
return $this->menu_display;
else
return sprintf('%s: %s',$this->module->name,$this->name);
}
public function method() {
return substr($this->name,strpos($this->name,':')+1);
}
public function status($status=NULL) {
if ($status)
$this->status = $status;
return $this->status;
}
public function url() {
if (! preg_match('/:/',$this->name))
return NULL;
list($type,$action) = preg_split('/:/',$this->name,2);
return URL::link($this->directory(),$this->module->name.$this->controller_sub().'/'.$action);
}
} }
?> ?>

View File

@ -1,112 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Application Module Method Token Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Module_Method_Token extends ORM_OSB {
// This module doesnt keep track of column updates automatically
protected $_updated_column = FALSE;
// Relationships
protected $_belongs_to = array(
'account'=>array(),
'module_method'=>array('foreign_key'=>'method_id'),
);
protected $_has_one = array(
'record_id'=>array(),
);
public function method(array $modmeth) {
list($module,$method) = $modmeth;
if (! $method instanceof Model_Module_Method) {
if (is_numeric($module))
$mo = ORM::factory('Module',$module);
elseif (is_string($module))
$mo = ORM::factory('Module',array('name'=>$module));
elseif (! $module instanceof Model_Module)
throw new Kohana_Exception('Unknown module :module',array(':module'=>serialize($module)));
else
$mo = $module;
if (! $mo->loaded())
throw new Kohana_Exception('Unknown module :module - not loaded?',array(':module'=>$mo->id));
if (is_numeric($method))
$mmo = ORM::factory('Module_Method',$method);
elseif (is_string($method))
$mmo = ORM::factory('Module_Method',array('name'=>$method,'module_id'=>$mo->id));
else
throw new Kohana_Exception('Unknown method :method',array(':method'=>serialize($method)));
} else
$mmo = $method;
if (! $mmo->loaded())
throw new Kohana_Exception('Unknown method :method - not loaded?',array(':method'=>$mmo->id));
$this->method_id = $mmo->id;
return $this;
}
public function account($account) {
if (! $account instanceof Model_Account) {
if (is_numeric($account))
$ao = ORM::factory('Account',$account);
else
throw new Kohana_Exception('Unknown account :account',array(':account'=>serialize($account)));
} else
$ao = $account;
$this->account_id = $ao->id;
return $this;
}
public function uses($uses) {
$this->uses = $uses;
return $this;
}
public function expire($expire) {
$this->date_expire = $expire;
return $this;
}
// @todo Login Reset: When called within a timelimit (so existing token already exists), is returning true but password reset emails have blanks where the tokens are
public function generate() {
if (! $this->account_id OR ! $this->method_id OR ! ($this->date_expire OR $this->uses))
return NULL;
// Check we dont already have a valid token
$mmto = ORM::factory('Module_Method_Token')
->where('account_id','=',$this->account_id)
->where('method_id','=',$this->method_id)
->find();
if ($mmto->loaded()) {
// Check that the token is still good
if ((is_null($mmto->date_expire) OR $mmto->date_expire > time()) AND (is_null($mmto->uses) OR $mmto->uses > 0)) {
$this->token = $mmto->token;
return $this->token;
// Token expired
} else
$mmto->delete();
}
$this->token = md5(sprintf('%s:%s:%s',$this->account_id,$this->method_id,time()));
$this->save();
return $this->saved() ? $this->token : NULL;
}
}
?>

View File

@ -9,7 +9,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_RTM extends ORM_OSB { class Model_RTM extends ORM {
protected $_belongs_to = array( protected $_belongs_to = array(
'account' => array(), 'account' => array(),
); );

View File

@ -1,40 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Record_ID extends ORM_OSB {
protected $_primary_key = 'module_id';
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
public function next_id($mid) {
if (is_null($this->id)) {
$this->module_id = $mid;
// We'll get the next ID as the MAX(id) of the table
$mo = ORM::factory('Module',$mid);
$max = DB::select(array('MAX(id)','id'))
->from($mo->name)
->where('site_id','=',Company::instance()->site());
$this->id = $max->execute()->get('id');
}
$this->id++;
if (! $this->save())
throw HTTP_Exception::factory(501,'Unable to increase ID for :table',array(':table'=>$mid));
return $this->id;
}
}
?>

View File

@ -12,7 +12,7 @@
* @copyright (c) 2009-2013 Open Source Billing * @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html * @license http://dev.osbill.net/license.html
*/ */
class Model_Setup extends ORM_OSB { class Model_Setup extends ORM {
// Setup doesnt use the update column // Setup doesnt use the update column
protected $_updated_column = FALSE; protected $_updated_column = FALSE;

View File

@ -45,17 +45,9 @@ abstract class ORM extends lnApp_ORM {
return parent::_build($type); return parent::_build($type);
} }
/**
* Function help to find records that are active
*/
final protected function _where_active() {
return $this->where('status','=',TRUE);
}
/** /**
* Determine if the account is authoised by the user * Determine if the account is authoised by the user
*/ */
// @todo This function shouldnt be here.
public function authorised(Model $o=NULL,Model_Account $ao=NULL,$aid='account_id') { public function authorised(Model $o=NULL,Model_Account $ao=NULL,$aid='account_id') {
if (is_null($o)) if (is_null($o))
$o = $this; $o = $this;
@ -147,6 +139,31 @@ abstract class ORM extends lnApp_ORM {
return ORM::factory('Module',array('name'=>$this->_table_name)); return ORM::factory('Module',array('name'=>$this->_table_name));
} }
/**
* Name value return for the record
*
* @param $variable to enable further processing to determine name, eg: language
*/
public function name($variable=NULL) {
return sprintf('Unknown [%s]',$this->id);
}
/**
* Sub-Name value return for the record
*
* @param $variable to enable further processing to determine name, eg: language
*/
public function namesub($variable=NULL) {
return sprintf('Unknown [%s]',$this->id);
}
/**
* A reference number relating to the object
*/
public function refnum($short=FALSE) {
return ($short ? '' : 'x').sprintf('%06s',$this->id);
}
/** /**
* Set the site ID attribute for each row update * Set the site ID attribute for each row update
*/ */
@ -164,13 +181,23 @@ abstract class ORM extends lnApp_ORM {
* Function help to find records that are active * Function help to find records that are active
*/ */
final public function list_active($active=TRUE) { final public function list_active($active=TRUE) {
$x=($active ? $this->_where_active() : $this); $x=($active ? $this->where_active() : $this);
return $x->find_all(); return $x->find_all();
} }
/**
* Function help to find records that are active
*/
final public function where_active() { final public function where_active() {
return $this->_where_active(); return $this->where($this->_table_name.'.active','=',TRUE);
}
/**
* Function help to find records that are inactive
*/
final public function where_inactive() {
return $this->where_open()->where($this->_table_name.'.active','=',FALSE)->or_where($this->_table_name.'.active','IS',NULL)->where_close();
} }
// @todo This function shouldnt be here. // @todo This function shouldnt be here.

View File

@ -1,14 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's [ORM] class to create defaults for OSB.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
* @deprecate
*/
abstract class ORM_OSB extends ORM {
}

View File

@ -1,47 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Request. Uses the [Route] class to determine what
* [Controller] to send the request to.
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Request extends lnApp_Request {
/**
* Get our Module_Method object for this request
*/
public function mmo() {
static $result = FALSE;
if (is_null($result) OR $result)
return $result;
$result = NULL;
list($c,$x) = substr_count($this->_controller,'_') ? explode('_',$this->_controller,2) : array($this->_controller,'');
$mo = ORM::factory('Module',array('name'=>$c));
if ($mo->loaded() AND $mo->status) {
$method = strtolower($this->_directory ? sprintf('%s:%s',$this->_directory.($x ? '_'.$x : ''),$this->_action) : $this->_action);
// Get the method number
$mmo = $mo->module_method
->where_open()
->where('name','=',$method)
->or_where('name','=',str_replace(':','_',$method)) // @todo This is temporary until all our method names have a colon delimiter
->where_close()
->find();
if ($mmo->loaded())
$result = $mmo;
}
return $result;
}
}
?>

View File

@ -13,8 +13,8 @@ class Site extends lnApp_Site {
/** /**
* Show a date using a site configured format * Show a date using a site configured format
*/ */
public static function Date($date) { public static function Date($date,$format='') {
return (is_null($date) OR ! $date) ? '' : date(Company::instance()->date_format(),$date); return (is_null($date) OR ! $date) ? '' : date(($format ? $format : Company::instance()->date_format()),$date);
} }
/** /**

View File

@ -11,21 +11,7 @@
*/ */
class StaticList_ItemType extends StaticList { class StaticList_ItemType extends StaticList {
protected function _table() { protected function _table() {
return array( return ORM::factory('Invoice_Item')->_types();
0=>_('Product/Service Charge'), // Line Charge Topic on Invoice, eg: Service Name
1=>_('Hardware'),
2=>_('Service Relocation Fee'),
3=>_('Service Change Fee'),
4=>_('Service Connection Fee'),
5=>_('Excess Usage'), // Excess Service Item, of item 0
6=>_('Service Cancellation Fee'),
7=>_('Extra Product/Service Charge'), // Service Billing in advance
8=>_('Product Addition'), // Additional Product Customisation
124=>_('Late Payment Fee'),
125=>_('Payment Fee'), // Payment processing fee
126=>_('Other'),
127=>_('Rounding'),
);
} }
public static function get($value) { public static function get($value) {

View File

@ -1,28 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class renders Person Title responses and forms.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class StaticList_Title extends StaticList {
protected function _table() {
return array(
'mr'=>_('Mr'),
'ms'=>_('Ms'),
'mrs'=>_('Mrs'),
'miss'=>_('Miss'),
'dr'=>_('Dr'),
'prof'=>_('Prof')
);
}
public static function get($value) {
return self::factory()->_get($value);
}
}
?>

View File

@ -18,7 +18,7 @@ class Task_Account_Complete extends Minion_Task {
foreach ($o->find_all() as $ao) { foreach ($o->find_all() as $ao) {
if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0) if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0)
$ao->status = 0; $ao->active = 0;
$ao->save(); $ao->save();

View File

@ -23,19 +23,19 @@ class URL extends lnApp_URL {
foreach (array_reverse(self::$method_directory) as $k=>$v) foreach (array_reverse(self::$method_directory) as $k=>$v)
switch ($k) { switch ($k) {
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'icon-globe'); case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe');
break; break;
case 'affiliate': case 'affiliate':
case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'icon-th-list'); case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'fa-dashboard');
break; break;
case 'user': case 'user':
if (is_object(Auth::instance()->get_user())) if (is_object(Auth::instance()->get_user()))
$result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'icon-user'); $result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'fa-user');
break; break;
default: $result[$k] = array('name'=>$k,'icon'=>'icon-question-sign'); default: $result[$k] = array('name'=>$k,'icon'=>'fa-question');
} }
return $result; return $result;

View File

@ -12,7 +12,7 @@
return array return array
( (
'default' => array 'old' => array
( (
'type' => 'mysql', 'type' => 'mysql',
'connection' => array( 'connection' => array(
@ -39,5 +39,46 @@ return array
'compress' => FALSE, 'compress' => FALSE,
'profiling' => TRUE, 'profiling' => TRUE,
), ),
'pdo' => array(
'type' => 'PDO',
'connection' => array(
/**
* The following options are available for PDO:
*
* string dsn Data Source Name
* string username database username
* string password database password
* boolean persistent use persistent connections?
*/
'dsn' => 'mysql:host=localhost;dbname=database',
'username' => 'username',
'password' => 'password',
'persistent' => FALSE,
),
/**
* The following extra options are available for PDO:
*
* string identifier set the escaping identifier
*/
'table_prefix' => 'ab_',
'charset' => 'utf8',
'caching' => FALSE,
),
'default' => array(
'type' => 'MySQLi',
'connection' => array(
'hostname' => 'localhost',
'username' => 'username',
'password' => 'password',
'persistent' => FALSE,
'database' => 'database',
'ssl' => NULL,
),
'table_prefix' => 'ab_',
'charset' => 'utf8',
'caching' => FALSE,
'compress' => FALSE,
'profiling' => TRUE,
),
); );
?> ?>

View File

@ -1,7 +1,7 @@
<?php defined('SYSPATH') or die('No direct access allowed.'); <?php defined('SYSPATH') or die('No direct access allowed.');
/** /**
* OSB Configuration - Authentication * OSB Configuration - Session Configuration
* *
* @package OSB * @package OSB
* @category Configuration * @category Configuration
@ -11,7 +11,8 @@
*/ */
return array( return array(
'driver' => 'OSB', 'native' => array(
'hash_method' => 'md5', 'name'=>'OSB',
),
); );
?> ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,17 @@
<!-- o = Array of Account -->
<?php echo Table::factory()
->data($o)
->jssort('customer')
->columns(array(
'id'=>'ID',
'active'=>'Active',
'refnum()'=>'Num',
'name()'=>'Account',
'email'=>'Email',
'invoices_due_total(NULL,TRUE)'=>'Invoices',
'service->find_all()->count()'=>'Services',
))
->prepend(array(
'id'=>array('url'=>URL::link('reseller','account/view/')),
));
?>

View File

@ -0,0 +1,13 @@
<!-- o = Array of Model_Account_Log -->
<?php echo Table::factory()
->data($o)
->page_items(25)
->columns(array(
'id'=>'ID',
'date_orig'=>'Date',
'account->refnum()'=>'Acc ID',
'account->name()'=>'Acc Name',
'ip'=>'IP Address',
'details'=>'Details',
));
?>

View File

@ -0,0 +1,10 @@
<!-- o = Model_Account -->
<?php echo View::factory('welcome/user/view')->set('o',$o); ?>
<?php echo Block::factory()
->title(sprintf('InActive Services for Account: %s',$o->refnum()))
->title_icon('fa fa-barcode')
->span(6)
->body(View::factory('service/user/list/inactive')->set('o',$o->service->where_inactive()->find_all())); ?>
<?php echo View::factory('invoice/user/next')->set('o',$o); ?>

View File

@ -1,14 +0,0 @@
<div class="span11">
<fieldset>
<legend>Reset Password</legend>
<?php echo Form::input('password','',array('label'=>'Password','type'=>'password','required','minlength'=>8)); ?>
<?php echo Form::input('password_confirm','',array('label'=>'Confirm','type'=>'password','required','minlength'=>8)); ?>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Update</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,16 +0,0 @@
<div class="span11">
<fieldset>
<legend>Add Method</legend>
<?php echo Form::input('name',$name,array('label'=>'Method','disabled')); ?>
<?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?>
<?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,42 +0,0 @@
<div class="span5">
<fieldset>
<legend>Method Details</legend>
<?php echo Form::input('notes',$o->notes,array('label'=>'Description','placeholder'=>'Method Description','class'=>'span5')); ?>
<?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
</fieldset>
</div> <!-- /span -->
<div class="span6">
<fieldset>
<legend>Method Security</legend>
<table class="table table-striped table-condensed table-hover" id="list-table">
<thead><tr>
<th>Method</th>
<th>Notes</th>
<th>Group Active</th>
<th>Method Enable</th>
</tr></thead>
<tbody>
<?php foreach (ORM::factory('Group')->find_all() as $go) : ?>
<tr>
<td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td>
<td><?php echo $go->display('notes'); ?></td>
<td><?php echo $go->display('status'); ?></td>
<td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go)); ?></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</fieldset>
<div class="row">
<div class="offset2">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</div>
</div> <!-- /span -->

View File

@ -1,21 +0,0 @@
<div class="account-container stacked">
<div class="content clearfix">
<form method="post" action="<?php echo URL::site('login/reset'); ?>">
<h1>Reset Password</h1>
<p>If you have forgotten your password, we can issue you a temporary access code via email that will allow you to change your password.</p>
<div class="login-fields">
<p>To start this process, please enter your Username. If you dont know your Username, please contact us.</p>
<div class="field">
<label for="username">Username:</label>
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" required/>
</div> <!-- /field -->
</div> <!-- /login-fields -->
<div class="login-actions">
<button class="button btn btn-warning btn-large">Reset</button>
</div> <!-- /login-actions -->
</form>
</div> <!-- /content -->
</div> <!-- /account-container -->

View File

@ -17,7 +17,7 @@
<div id="kodoc-header"> <div id="kodoc-header">
<div class="container"> <div class="container">
<a href="http://dev.leenooks.vpn/" id="kodoc-logo"> <a href="http://dev.leenooks.net/" id="kodoc-logo">
<img src="<?php echo Route::url('docs/media', array('file' => 'img/logo-small.png')) ?>" /> <img src="<?php echo Route::url('docs/media', array('file' => 'img/logo-small.png')) ?>" />
</a> </a>
<div id="kodoc-menu"> <div id="kodoc-menu">

View File

@ -0,0 +1,17 @@
<?php echo Block::factory()
->title(sprintf('Active Services Account: %s',$o->refnum()))
->title_icon('fa fa-barcode')
->span(6)
->body(View::factory('service/user/list/brief')->set('o',$o->service->list_active())); ?>
<?php echo Block::factory()
->title(sprintf('Invoices Due Account: %s (%s)',$o->refnum(),$o->invoice->list_due_total(TRUE)))
->title_icon('fa fa-money')
->span(6)
->body(View::factory('invoice/user/list/due')->set('o',$o->invoice->list_due())); ?>
<?php echo Block::factory()
->title(sprintf('Expiring Services Account: %s',$o->refnum()))
->title_icon('fa fa-barcode')
->span(6)
->body(View::factory('service/user/list/expiring')->set('o',$o->service->list_expiring())); ?>

@ -1 +1 @@
Subproject commit 0a7e8b349df4e965b30b3de3af3c23b6bdee40b6 Subproject commit 898371c849356932afe44d00f29f881430792c46

0
includes/tcpdf/fonts/README.TXT Executable file → Normal file
View File

0
includes/tcpdf/fonts/ZarBold.ctg.z Executable file → Normal file
View File

0
includes/tcpdf/fonts/ZarBold.z Executable file → Normal file
View File

0
includes/tcpdf/fonts/almohanad.ctg.z Executable file → Normal file
View File

0
includes/tcpdf/fonts/almohanad.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/almohanad.z Executable file → Normal file
View File

0
includes/tcpdf/fonts/arialunicid0.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/courier.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/helvetica.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/helveticab.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/helveticabi.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/helveticai.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/hysmyeongjostdmedium.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/kozgopromedium.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/kozminproregular.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/msungstdlight.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/stsongstdlight.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/symbol.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/times.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/timesb.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/timesbi.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/timesi.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/uni2cid_ac15.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/uni2cid_ag15.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/uni2cid_aj16.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/uni2cid_ak12.php Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/README.TXT Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1250.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1251.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1252.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1253.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1254.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1255.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1257.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp1258.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/cp874.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-1.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-11.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-15.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-16.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-2.map Executable file → Normal file
View File

0
includes/tcpdf/fonts/utils/enc/iso-8859-4.map Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More