Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e8a5e042dd | ||
|
dd2d6da3f3 | ||
|
e65bf3aa88 | ||
|
ede63bea4c | ||
|
46f57fe378 | ||
|
83aa81f0c3 |
43
.gitlab-ci.yml
Normal file
43
.gitlab-ci.yml
Normal file
@ -0,0 +1,43 @@
|
||||
services:
|
||||
- centos/mariadb:latest
|
||||
|
||||
variables:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_DATABASE: homestead
|
||||
|
||||
before_script:
|
||||
# Install dependencies
|
||||
- git submodule update --init --recursive
|
||||
- echo "Load sample DB"
|
||||
|
||||
# We test PHP5.6
|
||||
test:5.5:
|
||||
image: leenooks/php:5.5
|
||||
script:
|
||||
- phpunit --bootstrap=includes/kohana/modules/unittest/bootstrap.php --exclude-group kohana --colors --verbose $@ includes/kohana/modules/unittest/tests.php
|
||||
only:
|
||||
- test
|
||||
tags:
|
||||
- php
|
||||
|
||||
# We test PHP5.6 (good luck with that)
|
||||
#test:5.6:
|
||||
# image: php:5.6
|
||||
# script:
|
||||
# - phpunit --bootstrap=includes/kohana/modules/unittest/bootstrap.php --exclude-group kohana --colors --verbose $@ includes/kohana/modules/unittest/tests.php --site=test
|
||||
# only:
|
||||
# - test
|
||||
# tags:
|
||||
# - php
|
||||
|
||||
# We test PHP7.0 (good luck with that)
|
||||
#test:7.0:
|
||||
# image: php:7.0
|
||||
# script:
|
||||
# - phpunit --bootstrap=includes/kohana/modules/unittest/bootstrap.php --exclude-group kohana --colors --verbose $@ includes/kohana/modules/unittest/tests.php --site=test
|
||||
# only:
|
||||
# - test
|
||||
# tags:
|
||||
# - php
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,6 +7,3 @@
|
||||
[submodule "modules/lnapp"]
|
||||
path = modules/lnapp
|
||||
url = git@dev.leenooks.net:deon/lnapp.git
|
||||
[submodule "modules/lnauth"]
|
||||
path = modules/lnauth
|
||||
url = git@dev.leenooks.net:deon/lnauth.git
|
||||
|
@ -131,7 +131,6 @@ Kohana::$config->attach(new Config_File);
|
||||
*/
|
||||
Kohana::modules(array(
|
||||
'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
|
||||
'lnauth' => MODPATH.'lnauth', // lnAuth Base Authentication Tools
|
||||
'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools
|
||||
'auth' => SMDPATH.'auth', // Basic authentication
|
||||
'cache' => SMDPATH.'cache', // Caching with multiple backends
|
||||
|
@ -1,23 +1,22 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Enahance Kohanas Auth driver.
|
||||
* This class overrides Kohana's Auth
|
||||
*
|
||||
* @package OSB
|
||||
* @category Classes
|
||||
* @category Modifications
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Auth_ORM extends lnAuth_Auth_ORM {
|
||||
/**
|
||||
* 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))));
|
||||
class Auth_ORM extends Kohana_Auth_ORM {
|
||||
// Override Kohana Auth requirement to have a hash_key
|
||||
public function hash($str) {
|
||||
switch ($this->_config['hash_method']) {
|
||||
case '' : return $str;
|
||||
case 'md5': return md5($str);
|
||||
default: return hash_hmac($this->_config['hash_method'], $str, $this->_config['hash_key']);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
233
application/classes/Auth/OSB.php
Normal file
233
application/classes/Auth/OSB.php
Normal file
@ -0,0 +1,233 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -21,7 +21,7 @@ class Company {
|
||||
if (! $this->so->loaded())
|
||||
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
||||
|
||||
Kohana::$environment = (int)$this->so->active;
|
||||
Kohana::$environment = (int)$this->so->status;
|
||||
}
|
||||
|
||||
public static function instance() {
|
||||
@ -34,7 +34,7 @@ class Company {
|
||||
}
|
||||
|
||||
public function admin() {
|
||||
return $this->so->account;
|
||||
return $this->so->account->name();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public function name($variable=NULL) {
|
||||
public function name() {
|
||||
return $this->so->site_details('name');
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,26 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Account extends Controller_TemplateDefault {
|
||||
protected $icon = 'fa fa-users';
|
||||
protected function group() {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
193
application/classes/Controller/Admin/Module.php
Normal file
193
application/classes/Controller/Admin/Module.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?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/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
109
application/classes/Controller/Admin/Module/Method.php
Normal file
109
application/classes/Controller/Admin/Module/Method.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?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)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
@ -20,18 +20,18 @@ class Controller_Admin_Setup extends Controller_TemplateDefault {
|
||||
public function action_edit() {
|
||||
$o = Company::instance()->so();
|
||||
|
||||
if ($this->request->post() AND $o->values($this->request->post())->changed() AND (! $this->save($o)))
|
||||
if ($_POST AND $o->values($_POST)->changed() AND (! $this->save($o)))
|
||||
$o->reload();
|
||||
|
||||
Block::factory()
|
||||
->title('Update Site Configuration')
|
||||
->title_icon('fa fa-wrench')
|
||||
->title_icon('icon-wrench')
|
||||
->type('form-horizontal')
|
||||
->body(View::factory('setup/admin/edit')->set('o',$o));
|
||||
|
||||
Block::factory()
|
||||
->title('Update Module Configuration')
|
||||
->title_icon('fa fa-wrench')
|
||||
->title_icon('icon-wrench')
|
||||
->type('form-horizontal')
|
||||
->body(View::factory('setup/admin/module')->set('o',$o)->set('mid',NULL));
|
||||
}
|
||||
|
@ -11,8 +11,6 @@
|
||||
* @also [logout]
|
||||
*/
|
||||
class Controller_Login extends lnApp_Controller_Login {
|
||||
protected $login_attribute = 'username';
|
||||
|
||||
/**
|
||||
* Enable site registration
|
||||
*
|
||||
@ -25,5 +23,70 @@ class Controller_Login extends lnApp_Controller_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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
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 {
|
||||
}
|
||||
?>
|
@ -20,35 +20,127 @@ class Controller_Reseller_Account extends Controller_Account {
|
||||
* Show a list of accounts
|
||||
*/
|
||||
public function action_list() {
|
||||
$this->meta->title = 'R|Customer List';
|
||||
|
||||
Block::factory()
|
||||
->title(_('Customer List'))
|
||||
->title_icon($this->icon)
|
||||
->body(View::factory('account/list')->set('o',ORM::factory('Account')->where_authorised($this->ao,'id')->find_all()));
|
||||
->title_icon('icon-th-list')
|
||||
->body(Table::factory()
|
||||
->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
|
||||
*/
|
||||
public function action_listlog() {
|
||||
$this->meta->title = 'R|Customer Logins';
|
||||
|
||||
Block::factory()
|
||||
->title(_('Customer List'))
|
||||
->title_icon('fa fa-eye')
|
||||
->body(View::factory('account/listlog')->set('o',ORM::factory('Account_Log')->where_authorised($this->ao)->find_all()));
|
||||
->title(_('Customer Login Activity'))
|
||||
->title_icon('icon-eye-open')
|
||||
->body(Table::factory()
|
||||
->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() {
|
||||
$ao = ORM::factory('Account',$this->request->param('id'));
|
||||
|
||||
if (! $ao->loaded() OR ! $ao->active OR ! Auth::instance()->authorised($ao))
|
||||
if (! $ao->loaded() OR ! $ao->status OR ! Auth::instance()->authorised($ao))
|
||||
throw HTTP_Exception::factory(403,'Account either doesnt exist, or you are not authorised to see it');
|
||||
|
||||
$this->meta->title = 'Customer: '.$ao->name();
|
||||
Block::factory()
|
||||
->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/')),
|
||||
))
|
||||
);
|
||||
|
||||
$this->template->content = View::factory('account/reseller/view')->set('o',$ao);
|
||||
Block::factory()
|
||||
->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/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -19,29 +19,89 @@ class Controller_Reseller_Welcome extends Controller_Welcome {
|
||||
public function action_index() {
|
||||
$t = time();
|
||||
|
||||
// Show outstanding invoices
|
||||
$o = ORM::factory('Invoice');
|
||||
|
||||
Block::factory()
|
||||
->title($this->ao->RTM->display('name'))
|
||||
->body('');
|
||||
|
||||
Block::factory()
|
||||
->title('Invoices Overdue - No Auto Billing')
|
||||
->title_icon('fa fa-pencil-square-o')
|
||||
->title_icon('icon-info-sign')
|
||||
->span(6)
|
||||
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t)));
|
||||
->body(Table::factory()
|
||||
->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()
|
||||
->title('Invoices Overdue - Auto Billing')
|
||||
->title_icon('fa fa-pencil-square-o')
|
||||
->title_icon('icon-info-sign')
|
||||
->span(6)
|
||||
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_overdue_billing($t,TRUE)));
|
||||
->body(Table::factory()
|
||||
->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()
|
||||
->title('Upcoming Invoices')
|
||||
->title_icon('fa fa-pencil-square-o')
|
||||
->title_icon('icon-info-sign')
|
||||
->span(6)
|
||||
->body(View::factory('invoice/list')->set('o',ORM::factory('Invoice')->list_due($t)));
|
||||
->body(Table::factory()
|
||||
->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()
|
||||
->title('Un-applied payments')
|
||||
->title_icon('fa fa-money')
|
||||
->title_icon('icon-info-sign')
|
||||
->span(6)
|
||||
->body(View::factory('payment/list')->set('o',ORM::factory('Payment')->where_authorised()->list_unapplied()));
|
||||
->body(Table::factory()
|
||||
->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/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
57
application/classes/Controller/TemplateDefault.php
Normal file
57
application/classes/Controller/TemplateDefault.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
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() {
|
||||
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));
|
||||
}
|
||||
}
|
||||
?>
|
@ -20,13 +20,13 @@ class Controller_User_Search extends Controller_Search {
|
||||
public function action_ajaxlist() {
|
||||
$result = array();
|
||||
|
||||
if ($this->request->query('term')) {
|
||||
$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($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($this->request->query('term'),'url','id',array('INV %s: %s'=>array('id','account->name()')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
|
||||
if (isset($_REQUEST['term']) AND trim($_REQUEST['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('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('Invoice')->list_autocomplete($_REQUEST['term'],'url','id',array('INV %s: %s'=>array('id','account->name(TRUE)')),array(),array('urlprefix'=>URL::link('user','invoice/view/'))));
|
||||
|
||||
foreach (array('Service_Plugin_Adsl','Service_Plugin_Domain','Service_Plugin_Host') as $o)
|
||||
$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/'))));
|
||||
$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/'))));
|
||||
}
|
||||
|
||||
$this->response->headers('Content-Type','application/json');
|
||||
|
@ -12,15 +12,24 @@
|
||||
class Controller_Welcome extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
public function action_breadcrumb() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
$this->response->body(Session::instance()->get_once('breadcrumb'));
|
||||
}
|
||||
|
||||
public function action_index() {
|
||||
if (! Kohana::$config->load('config')->appname)
|
||||
HTTP::redirect('guide/app');
|
||||
|
||||
$output = '';
|
||||
|
||||
$output = View::factory('pages/welcome');
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/css/pages/welcome.css');
|
||||
|
||||
$this->template->content = View::factory('pages/welcome');
|
||||
$this->template->content = $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
35
application/classes/DB.php
Normal file
35
application/classes/DB.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -12,7 +12,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Database_MySQLi extends Kohana_Database_MySQLi {
|
||||
class Database_MySQL extends Kohana_Database_MySQL {
|
||||
// MySQL uses a backtick for identifiers
|
||||
protected $_identifier = '';
|
||||
}
|
@ -19,19 +19,17 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
|
||||
*/
|
||||
public static function log(Exception $e,$level=Log::EMERGENCY) {
|
||||
try {
|
||||
if (class_exists('Model_Log_Error')) {
|
||||
$eo = ORM::factory('Log_Error');
|
||||
$eo->message = Kohana_Exception::text($e);
|
||||
$eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
|
||||
$eo = ORM::factory('Log_Error');
|
||||
$eo->message = Kohana_Exception::text($e);
|
||||
$eo->account_id = (PHP_SAPI === 'cli' OR ! Auth::instance()->logged_in()) ? NULL : Auth::instance()->get_user()->id;
|
||||
|
||||
if (Request::current()) {
|
||||
$eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller();
|
||||
$eo->method = Request::current()->action();
|
||||
}
|
||||
|
||||
$eo->save();
|
||||
if (Request::current()) {
|
||||
$eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller();
|
||||
$eo->method = Request::current()->action();
|
||||
}
|
||||
|
||||
$eo->save();
|
||||
|
||||
} catch (Exception $x) {
|
||||
return parent::log($e,$level);
|
||||
}
|
||||
@ -50,13 +48,11 @@ class Kohana_Exception extends Kohana_Kohana_Exception {
|
||||
return parent::response($e);
|
||||
|
||||
} else {
|
||||
if (class_exists('SystemMessage')) {
|
||||
SystemMessage::add(array(
|
||||
'title'=>'An Error Occured.',
|
||||
'type'=>'error',
|
||||
'body'=>'Dont panic, its been logged.',
|
||||
));
|
||||
}
|
||||
SystemMessage::add(array(
|
||||
'title'=>'An Error Occured.',
|
||||
'type'=>'error',
|
||||
'body'=>'Dont panic, its been logged.',
|
||||
));
|
||||
|
||||
// We'll redirect to the main page.
|
||||
$response = Response::factory();
|
||||
|
71
application/classes/Menu.php
Normal file
71
application/classes/Menu.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
25
application/classes/Minion/Task.php
Normal file
25
application/classes/Minion/Task.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
?>
|
@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Account extends lnAuth_Model_Account {
|
||||
class Model_Account extends Model_Auth_UserDefault {
|
||||
// Relationships
|
||||
protected $_has_many = array(
|
||||
'user_tokens'=>array('model'=>'user_token'),
|
||||
@ -21,31 +21,48 @@ class Model_Account extends lnAuth_Model_Account {
|
||||
);
|
||||
|
||||
protected $_has_one = array(
|
||||
'country'=>array('foreign_key'=>'id'),
|
||||
'currency'=>array('foreign_key'=>'id'),
|
||||
'language'=>array('foreign_key'=>'id'),
|
||||
'RTM'=>array('far_key'=>'id'),
|
||||
);
|
||||
|
||||
// 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'),
|
||||
// @note: cant use unique emails, since multiple accounts may share the same email
|
||||
// array(array($this, 'unique'), array('email', ':value')),
|
||||
array('min_length', array(':value', 4)),
|
||||
array('max_length', array(':value', 127)),
|
||||
array('email'),
|
||||
),
|
||||
);
|
||||
protected $_display_filters = array(
|
||||
'date_orig'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'date_last'=>array(
|
||||
array('Site::Date',array(':value')),
|
||||
),
|
||||
'status'=>array(
|
||||
array('StaticList_YesNo::get',array(':value',TRUE)),
|
||||
),
|
||||
);
|
||||
|
||||
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();
|
||||
|
||||
/** LOCAL METHODS **/
|
||||
foreach ($this->group->where_active()->find_all() as $go)
|
||||
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
|
||||
@ -56,6 +73,14 @@ class Model_Account extends lnAuth_Model_Account {
|
||||
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
|
||||
*
|
||||
@ -83,33 +108,43 @@ class Model_Account extends lnAuth_Model_Account {
|
||||
return $format ? Currency::display($result) : $result;
|
||||
}
|
||||
|
||||
public function isAdmin() {
|
||||
return ($this->RTM->loaded() AND is_null($this->RTM->parent_id));
|
||||
public function log($message) {
|
||||
// Log a message for this account
|
||||
$alo = ORM::factory('Account_Log');
|
||||
$alo->account_id = $this->id;
|
||||
$alo->ip = Request::$client_ip;
|
||||
$alo->details = $message;
|
||||
$alo->save();
|
||||
|
||||
return $alo->saved();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this account a company account
|
||||
* This function will extract the available methods for this account
|
||||
* This is used both for menu options and method security
|
||||
*/
|
||||
public function isCompany() {
|
||||
return strlen($this->company) > 0;
|
||||
}
|
||||
public function methods() {
|
||||
static $result = array();
|
||||
|
||||
public function isReseller() {
|
||||
return $this->RTM->loaded();
|
||||
// @todo We may want to optimise this with some session caching.
|
||||
if ($result)
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the company name if it exists, otherwise the persons name
|
||||
* Return an account name
|
||||
*/
|
||||
public function name($variable=NULL) {
|
||||
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));
|
||||
public function name($withcompany=FALSE) {
|
||||
return trim(sprintf('%s %s',$this->first_name,$this->last_name).(($withcompany AND $this->company) ? sprintf(' (%s)',$this->company) : ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,22 +159,10 @@ class Model_Account extends lnAuth_Model_Account {
|
||||
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
|
||||
*/
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=array()) {
|
||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||
$ao = Auth::instance()->get_user();
|
||||
|
||||
$this->clear();
|
||||
@ -175,7 +198,7 @@ class Model_Account extends lnAuth_Model_Account {
|
||||
// Restrict results to authorised accounts
|
||||
array_push($limit,array('id','IN',$ao->RTM->customers($ao->RTM)));
|
||||
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,array_merge($options,array('parentbypass'=>TRUE)));
|
||||
return parent::list_autocomplete($term,$index,$value,$label,$limit,$options);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
27
application/classes/Model/Account/Log.php
Normal file
27
application/classes/Model/Account/Log.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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')),
|
||||
),
|
||||
);
|
||||
}
|
||||
?>
|
42
application/classes/Model/Auth/UserDefault.php
Normal file
42
application/classes/Model/Auth/UserDefault.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
?>
|
31
application/classes/Model/Country.php
Normal file
31
application/classes/Model/Country.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
||||
?>
|
19
application/classes/Model/Currency.php
Normal file
19
application/classes/Model/Currency.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?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');
|
||||
}
|
||||
?>
|
@ -8,7 +8,66 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Group extends lnAuth_Model_Group {
|
||||
class Model_Group extends Model_Auth_Role {
|
||||
// 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
|
||||
*/
|
||||
|
25
application/classes/Model/Group/Method.php
Normal file
25
application/classes/Model/Group/Method.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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;
|
||||
}
|
||||
?>
|
19
application/classes/Model/Language.php
Normal file
19
application/classes/Model/Language.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?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');
|
||||
}
|
||||
?>
|
@ -9,6 +9,6 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Log_Error extends ORM {
|
||||
class Model_Log_Error extends ORM_OSB {
|
||||
}
|
||||
?>
|
||||
|
55
application/classes/Model/Module.php
Normal file
55
application/classes/Model/Module.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
?>
|
@ -9,7 +9,28 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Module_Method extends lnAuth_Model_Module_Method {
|
||||
class Model_Module_Method extends ORM_OSB {
|
||||
// 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
|
||||
// @todo This is temporary until all our method names are colon delimited.
|
||||
protected function _load_values(array $values) {
|
||||
@ -22,5 +43,48 @@ class Model_Module_Method extends lnAuth_Model_Module_Method {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
112
application/classes/Model/Module/Method/Token.php
Normal file
112
application/classes/Model/Module/Method/Token.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -9,7 +9,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_RTM extends ORM {
|
||||
class Model_RTM extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'account' => array(),
|
||||
);
|
||||
|
40
application/classes/Model/Record/ID.php
Normal file
40
application/classes/Model/Record/ID.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -12,7 +12,7 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_Setup extends ORM {
|
||||
class Model_Setup extends ORM_OSB {
|
||||
// Setup doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
|
@ -45,9 +45,17 @@ abstract class ORM extends lnApp_ORM {
|
||||
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
|
||||
*/
|
||||
// @todo This function shouldnt be here.
|
||||
public function authorised(Model $o=NULL,Model_Account $ao=NULL,$aid='account_id') {
|
||||
if (is_null($o))
|
||||
$o = $this;
|
||||
@ -139,31 +147,6 @@ abstract class ORM extends lnApp_ORM {
|
||||
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
|
||||
*/
|
||||
@ -181,23 +164,13 @@ abstract class ORM extends lnApp_ORM {
|
||||
* Function help to find records that are active
|
||||
*/
|
||||
final public function list_active($active=TRUE) {
|
||||
$x=($active ? $this->where_active() : $this);
|
||||
$x=($active ? $this->_where_active() : $this);
|
||||
|
||||
return $x->find_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function help to find records that are active
|
||||
*/
|
||||
final public function 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();
|
||||
return $this->_where_active();
|
||||
}
|
||||
|
||||
// @todo This function shouldnt be here.
|
||||
|
14
application/classes/ORM/OSB.php
Normal file
14
application/classes/ORM/OSB.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?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 {
|
||||
}
|
47
application/classes/Request.php
Normal file
47
application/classes/Request.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -13,8 +13,8 @@ class Site extends lnApp_Site {
|
||||
/**
|
||||
* Show a date using a site configured format
|
||||
*/
|
||||
public static function Date($date,$format='') {
|
||||
return (is_null($date) OR ! $date) ? '' : date(($format ? $format : Company::instance()->date_format()),$date);
|
||||
public static function Date($date) {
|
||||
return (is_null($date) OR ! $date) ? '' : date(Company::instance()->date_format(),$date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,21 @@
|
||||
*/
|
||||
class StaticList_ItemType extends StaticList {
|
||||
protected function _table() {
|
||||
return ORM::factory('Invoice_Item')->_types();
|
||||
return array(
|
||||
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) {
|
||||
|
28
application/classes/StaticList/Title.php
Normal file
28
application/classes/StaticList/Title.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
?>
|
@ -18,7 +18,7 @@ class Task_Account_Complete extends Minion_Task {
|
||||
|
||||
foreach ($o->find_all() as $ao) {
|
||||
if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0)
|
||||
$ao->active = 0;
|
||||
$ao->status = 0;
|
||||
|
||||
$ao->save();
|
||||
|
||||
|
@ -23,19 +23,19 @@ class URL extends lnApp_URL {
|
||||
|
||||
foreach (array_reverse(self::$method_directory) as $k=>$v)
|
||||
switch ($k) {
|
||||
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'fa-globe');
|
||||
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'icon-globe');
|
||||
break;
|
||||
|
||||
case 'affiliate':
|
||||
case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'fa-dashboard');
|
||||
case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'icon-th-list');
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
if (is_object(Auth::instance()->get_user()))
|
||||
$result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'fa-user');
|
||||
$result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'icon-user');
|
||||
break;
|
||||
|
||||
default: $result[$k] = array('name'=>$k,'icon'=>'fa-question');
|
||||
default: $result[$k] = array('name'=>$k,'icon'=>'icon-question-sign');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* OSB Configuration - Session Configuration
|
||||
* OSB Configuration - Authentication
|
||||
*
|
||||
* @package OSB
|
||||
* @category Configuration
|
||||
@ -11,8 +11,7 @@
|
||||
*/
|
||||
|
||||
return array(
|
||||
'native' => array(
|
||||
'name'=>'OSB',
|
||||
),
|
||||
'driver' => 'OSB',
|
||||
'hash_method' => 'md5',
|
||||
);
|
||||
?>
|
@ -12,7 +12,7 @@
|
||||
|
||||
return array
|
||||
(
|
||||
'old' => array
|
||||
'default' => array
|
||||
(
|
||||
'type' => 'mysql',
|
||||
'connection' => array(
|
||||
@ -39,46 +39,5 @@ return array
|
||||
'compress' => FALSE,
|
||||
'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,
|
||||
),
|
||||
);
|
||||
?>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
@ -1,17 +0,0 @@
|
||||
<!-- 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/')),
|
||||
));
|
||||
?>
|
@ -1,13 +0,0 @@
|
||||
<!-- 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',
|
||||
));
|
||||
?>
|
@ -1,10 +0,0 @@
|
||||
<!-- 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); ?>
|
14
application/views/account/user/resetpassword.php
Normal file
14
application/views/account/user/resetpassword.php
Normal file
@ -0,0 +1,14 @@
|
||||
<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 -->
|
16
application/views/module/method/admin/add.php
Normal file
16
application/views/module/method/admin/add.php
Normal file
@ -0,0 +1,16 @@
|
||||
<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 -->
|
42
application/views/module/method/admin/edit.php
Normal file
42
application/views/module/method/admin/edit.php
Normal file
@ -0,0 +1,42 @@
|
||||
<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 -->
|
21
application/views/pages/login_reset.php
Normal file
21
application/views/pages/login_reset.php
Normal file
@ -0,0 +1,21 @@
|
||||
<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 -->
|
@ -17,7 +17,7 @@
|
||||
|
||||
<div id="kodoc-header">
|
||||
<div class="container">
|
||||
<a href="http://dev.leenooks.net/" id="kodoc-logo">
|
||||
<a href="http://dev.leenooks.vpn/" id="kodoc-logo">
|
||||
<img src="<?php echo Route::url('docs/media', array('file' => 'img/logo-small.png')) ?>" />
|
||||
</a>
|
||||
<div id="kodoc-menu">
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?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 898371c849356932afe44d00f29f881430792c46
|
||||
Subproject commit 0a7e8b349df4e965b30b3de3af3c23b6bdee40b6
|
0
includes/tcpdf/fonts/README.TXT
Normal file → Executable file
0
includes/tcpdf/fonts/README.TXT
Normal file → Executable file
0
includes/tcpdf/fonts/ZarBold.ctg.z
Normal file → Executable file
0
includes/tcpdf/fonts/ZarBold.ctg.z
Normal file → Executable file
0
includes/tcpdf/fonts/ZarBold.z
Normal file → Executable file
0
includes/tcpdf/fonts/ZarBold.z
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.ctg.z
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.ctg.z
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.php
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.php
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.z
Normal file → Executable file
0
includes/tcpdf/fonts/almohanad.z
Normal file → Executable file
0
includes/tcpdf/fonts/arialunicid0.php
Normal file → Executable file
0
includes/tcpdf/fonts/arialunicid0.php
Normal file → Executable file
0
includes/tcpdf/fonts/courier.php
Normal file → Executable file
0
includes/tcpdf/fonts/courier.php
Normal file → Executable file
0
includes/tcpdf/fonts/helvetica.php
Normal file → Executable file
0
includes/tcpdf/fonts/helvetica.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticab.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticab.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticabi.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticabi.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticai.php
Normal file → Executable file
0
includes/tcpdf/fonts/helveticai.php
Normal file → Executable file
0
includes/tcpdf/fonts/hysmyeongjostdmedium.php
Normal file → Executable file
0
includes/tcpdf/fonts/hysmyeongjostdmedium.php
Normal file → Executable file
0
includes/tcpdf/fonts/kozgopromedium.php
Normal file → Executable file
0
includes/tcpdf/fonts/kozgopromedium.php
Normal file → Executable file
0
includes/tcpdf/fonts/kozminproregular.php
Normal file → Executable file
0
includes/tcpdf/fonts/kozminproregular.php
Normal file → Executable file
0
includes/tcpdf/fonts/msungstdlight.php
Normal file → Executable file
0
includes/tcpdf/fonts/msungstdlight.php
Normal file → Executable file
0
includes/tcpdf/fonts/stsongstdlight.php
Normal file → Executable file
0
includes/tcpdf/fonts/stsongstdlight.php
Normal file → Executable file
0
includes/tcpdf/fonts/symbol.php
Normal file → Executable file
0
includes/tcpdf/fonts/symbol.php
Normal file → Executable file
0
includes/tcpdf/fonts/times.php
Normal file → Executable file
0
includes/tcpdf/fonts/times.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesb.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesb.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesbi.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesbi.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesi.php
Normal file → Executable file
0
includes/tcpdf/fonts/timesi.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ac15.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ac15.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ag15.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ag15.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_aj16.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_aj16.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ak12.php
Normal file → Executable file
0
includes/tcpdf/fonts/uni2cid_ak12.php
Normal file → Executable file
0
includes/tcpdf/fonts/utils/README.TXT
Normal file → Executable file
0
includes/tcpdf/fonts/utils/README.TXT
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1250.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1250.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1251.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1251.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1252.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1252.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1253.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1253.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1254.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1254.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1255.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1255.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1257.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1257.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1258.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp1258.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp874.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/cp874.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-1.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-1.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-11.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-11.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-15.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-15.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-16.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-16.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-2.map
Normal file → Executable file
0
includes/tcpdf/fonts/utils/enc/iso-8859-2.map
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user