Application cleanup
This commit is contained in:
parent
077c1923f3
commit
067af280af
@ -10,65 +10,6 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Auth_OSB extends Auth_ORM {
|
class Auth_OSB extends Auth_ORM {
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
// 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 (Config::sitemode() == Kohana::DEVELOPMENT)
|
|
||||||
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Debug::vars(array('user'=>$uo->username,'r'=>$role))));
|
|
||||||
|
|
||||||
if (! empty($role) AND Request::current()->mmo()) {
|
|
||||||
// If the role has the authorisation to run the method
|
|
||||||
$gmo = ORM::factory('Group_Method')
|
|
||||||
->where('method_id','=',Request::current()->mmo()->id);
|
|
||||||
|
|
||||||
foreach ($gmo->find_all() as $gm)
|
|
||||||
// $gm->group->id == 0 means all users.
|
|
||||||
if ($gm->group->id == 0 OR $uo->has_any('group',$gm->group->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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) {
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user that a token applies to
|
* Get the user that a token applies to
|
||||||
*
|
*
|
||||||
@ -103,7 +44,6 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
'type'=>'warning',
|
'type'=>'warning',
|
||||||
'body'=>_('Token expired')));
|
'body'=>_('Token expired')));
|
||||||
|
|
||||||
// @todo Log the token deletion
|
|
||||||
Session::instance()->delete('token');
|
Session::instance()->delete('token');
|
||||||
$mmto->delete();
|
$mmto->delete();
|
||||||
|
|
||||||
@ -113,7 +53,6 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
'type'=>'warning',
|
'type'=>'warning',
|
||||||
'body'=>_('Token expired')));
|
'body'=>_('Token expired')));
|
||||||
|
|
||||||
// @todo Log the token deletion
|
|
||||||
Session::instance()->delete('token');
|
Session::instance()->delete('token');
|
||||||
$mmto->delete();
|
$mmto->delete();
|
||||||
|
|
||||||
@ -210,5 +149,64 @@ class Auth_OSB extends Auth_ORM {
|
|||||||
public function authorised(Model_Account $ao) {
|
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))));
|
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) {
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
// 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 (Config::sitemode() == Kohana::DEVELOPMENT)
|
||||||
|
SystemMessage::add(array('title'=>'Debug','type'=>'debug','body'=>Debug::vars(array('user'=>$uo->username,'r'=>$role))));
|
||||||
|
|
||||||
|
if (! empty($role) AND Request::current()->mmo()) {
|
||||||
|
// If the role has the authorisation to run the method
|
||||||
|
$gmo = ORM::factory('Group_Method')
|
||||||
|
->where('method_id','=',Request::current()->mmo()->id);
|
||||||
|
|
||||||
|
foreach ($gmo->find_all() as $gm)
|
||||||
|
// $gm->group->id == 0 means all users.
|
||||||
|
if ($gm->group->id == 0 OR $uo->has_any('group',$gm->group->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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -115,8 +115,6 @@ class Config extends Kohana_Config {
|
|||||||
// We need to know our site here, so that we can subsequently load our enabled modules.
|
// We need to know our site here, so that we can subsequently load our enabled modules.
|
||||||
if (PHP_SAPI === 'cli') {
|
if (PHP_SAPI === 'cli') {
|
||||||
if (! ($site = Minion_CLI::options('site'))) {
|
if (! ($site = Minion_CLI::options('site'))) {
|
||||||
// @todo Need to figure out how to make this CLI error nicer.
|
|
||||||
#throw new Minion_Exception_InvalidTask(_('Cant figure out the site, use --site= for CLI'));
|
|
||||||
echo _('Cant figure out the site, use --site= for CLI')."\n";
|
echo _('Cant figure out the site, use --site= for CLI')."\n";
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Controller_Account extends Controller_TemplateDefault {
|
class Controller_Account extends Controller_TemplateDefault {
|
||||||
public function action_group() {
|
protected function group() {
|
||||||
// List all available groups for this user.
|
// List all available groups for this user.
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
*/
|
*/
|
||||||
class Controller_Admin_Account extends Controller_Account {
|
class Controller_Admin_Account extends Controller_Account {
|
||||||
protected $secure_actions = array(
|
protected $secure_actions = array(
|
||||||
'group'=>FALSE, // @todo Testing
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -72,22 +72,21 @@ class Controller_Login extends lnApp_Controller_Login {
|
|||||||
|
|
||||||
// Show our token screen even if the email was invalid.
|
// Show our token screen even if the email was invalid.
|
||||||
if (isset($_POST['username']))
|
if (isset($_POST['username']))
|
||||||
Block::add(array(
|
Block::factory()
|
||||||
'title'=>_('Reset your password'),
|
->body(View::factory('pages/login_reset_sent'));
|
||||||
'body'=>View::factory('login_reset_sent'),
|
|
||||||
'style'=>array('css/login.css'=>'screen'),
|
|
||||||
));
|
|
||||||
else
|
else
|
||||||
HTTP::redirect('login');
|
HTTP::redirect('login');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Block::add(array(
|
Block::factory()
|
||||||
'title'=>_('Reset your password'),
|
->body(View::factory('pages/login_reset'));
|
||||||
'body'=>View::factory('login_reset'),
|
|
||||||
'style'=>array('css/login.css'=>'screen'),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Style::factory()
|
||||||
|
->type('file')
|
||||||
|
->data('media/theme/baseadmin/css/pages/login.css');
|
||||||
|
|
||||||
$this->template->shownavbar = FALSE;
|
$this->template->shownavbar = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
|||||||
|
|
||||||
if ($this->auth_required) {
|
if ($this->auth_required) {
|
||||||
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
|
if (! count($this->secure_actions) OR (! isset($this->secure_actions[Request::current()->action()])))
|
||||||
throw new Kohana_Exception('Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
|
throw HTTP_Exception::factory(403,'Class has no security defined :class, or no security configured for :method',array(':class'=>get_class($this),':method'=>Request::current()->action()));
|
||||||
|
|
||||||
$this->ao = Auth::instance()->get_user();
|
$this->ao = Auth::instance()->get_user();
|
||||||
|
|
||||||
@ -39,8 +39,9 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
|||||||
parent::before();
|
parent::before();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo To rework
|
||||||
public function after() {
|
public function after() {
|
||||||
$dc = Kohana::$config->load('config','user_default_method');
|
$dc = 'u/welcome/index';
|
||||||
$m = sprintf('%s/%s',Request::current()->directory(),Request::current()->controller());
|
$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(Request::current()->directory(),sprintf('%s/%s',Request::current()->directory(),$dc),FALSE);
|
||||||
@ -51,22 +52,15 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This will filter a search query to only return those accounts for a reseller
|
* This will filter a search query to only return those accounts for a reseller
|
||||||
|
* @todo Swap the order of these params and make flid necessary
|
||||||
*/
|
*/
|
||||||
protected function filter($o,$af,$sort=NULL,$afid=NULL) {
|
protected function filter($o,array $fl,$sort=NULL,$flid=NULL) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach ($o as $x) {
|
foreach ($o as $x)
|
||||||
if (! is_null($afid) AND isset($x->$afid)) {
|
if (! is_null($flid) AND isset($x->$flid) AND in_array($x->$flid,$fl))
|
||||||
if ((is_array($af) AND in_array($x->$afid,$af)) OR ($x->$afid == $af))
|
|
||||||
array_push($result,$x);
|
array_push($result,$x);
|
||||||
|
|
||||||
} elseif (method_exists($x,'list_reseller')) {
|
|
||||||
if (in_array($af,$x->list_reseller()))
|
|
||||||
array_push($result,$x);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sort)
|
if ($sort)
|
||||||
Sort::MAsort($result,$sort);
|
Sort::MAsort($result,$sort);
|
||||||
|
|
||||||
|
@ -12,6 +12,12 @@
|
|||||||
class Controller_Welcome extends Controller_TemplateDefault {
|
class Controller_Welcome extends Controller_TemplateDefault {
|
||||||
protected $auth_required = FALSE;
|
protected $auth_required = FALSE;
|
||||||
|
|
||||||
|
public function action_breadcrumb() {
|
||||||
|
$this->auto_render = FALSE;
|
||||||
|
|
||||||
|
$this->response->body(Session::instance()->get_once('breadcrumb'));
|
||||||
|
}
|
||||||
|
|
||||||
public function action_index() {
|
public function action_index() {
|
||||||
if (! Kohana::$config->load('config')->appname)
|
if (! Kohana::$config->load('config')->appname)
|
||||||
HTTP::redirect('guide/app');
|
HTTP::redirect('guide/app');
|
||||||
@ -25,11 +31,5 @@ class Controller_Welcome extends Controller_TemplateDefault {
|
|||||||
|
|
||||||
$this->template->content = $output;
|
$this->template->content = $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action_breadcrumb() {
|
|
||||||
$this->auto_render = FALSE;
|
|
||||||
|
|
||||||
$this->response->body(Session::instance()->get_once('breadcrumb'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides Country routines
|
|
||||||
*
|
|
||||||
* @package OSB
|
|
||||||
* @category Helpers
|
|
||||||
* @author Deon George
|
|
||||||
* @copyright (c) 2009-2013 Open Source Billing
|
|
||||||
* @license http://dev.osbill.net/license.html
|
|
||||||
*/
|
|
||||||
class Country {
|
|
||||||
public static function icon($cid) {
|
|
||||||
$co = ORM::factory('Country',$cid);
|
|
||||||
|
|
||||||
return HTML::image(sprintf('media/img/country/%s.png',strtolower($co->two_code)),array('alt'=>$co->currency()->symbol));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,52 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is for rendering the tinyMCE editor
|
|
||||||
*
|
|
||||||
* @package OSB
|
|
||||||
* @category Helpers
|
|
||||||
* @author Deon George
|
|
||||||
* @copyright (c) 2009-2013 Open Source Billing
|
|
||||||
* @license http://dev.osbill.net/license.html
|
|
||||||
*/
|
|
||||||
class Editor {
|
|
||||||
private static $added = FALSE;
|
|
||||||
|
|
||||||
public static function add() {
|
|
||||||
if (static::$added)
|
|
||||||
return;
|
|
||||||
|
|
||||||
static::$added = TRUE;
|
|
||||||
|
|
||||||
Script::add(array(
|
|
||||||
'type'=>'file',
|
|
||||||
'data'=>'js/jquery-1.4.2.js',
|
|
||||||
));
|
|
||||||
Script::add(array(
|
|
||||||
'type'=>'file',
|
|
||||||
'data'=>'js/tiny_mce/tiny_mce.js',
|
|
||||||
));
|
|
||||||
Script::add(array(
|
|
||||||
'type'=>'stdin',
|
|
||||||
'data'=>'
|
|
||||||
tinyMCE.init({
|
|
||||||
mode : "specific_textareas",
|
|
||||||
editor_selector : "mceEditor",
|
|
||||||
theme : "advanced",
|
|
||||||
plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print",
|
|
||||||
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
|
|
||||||
theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
|
|
||||||
theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
|
|
||||||
theme_advanced_buttons3_add_before : "tablecontrols,separator",
|
|
||||||
theme_advanced_buttons3_add : "iespell,media,advhr",
|
|
||||||
theme_advanced_toolbar_location : "bottom",
|
|
||||||
theme_advanced_toolbar_align : "center",
|
|
||||||
plugin_insertdate_dateFormat : "%Y-%m-%d",
|
|
||||||
plugin_insertdate_timeFormat : "%H:%M:%S",
|
|
||||||
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
|
|
||||||
relative_urls: "true",
|
|
||||||
width : "100%"
|
|
||||||
});'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -51,22 +51,6 @@ abstract class Kohana extends Kohana_Core {
|
|||||||
return $x;
|
return $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @compat Restore KH 3.1 functionality
|
|
||||||
* @var boolean True if Kohana is running from the command line
|
|
||||||
*/
|
|
||||||
public static $is_cli = FALSE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @compat Restore KH 3.1 functionality
|
|
||||||
*/
|
|
||||||
public static function init(array $settings = NULL) {
|
|
||||||
parent::init($settings);
|
|
||||||
|
|
||||||
// Determine if we are running in a command line environment
|
|
||||||
Kohana::$is_cli = (PHP_SAPI === 'cli');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override Kohana's shutdown_handler()
|
* Override Kohana's shutdown_handler()
|
||||||
*
|
*
|
||||||
|
@ -10,22 +10,6 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Menu {
|
class Menu {
|
||||||
public static function items($type) {
|
|
||||||
$result = array();
|
|
||||||
|
|
||||||
if (empty(URL::$method_directory[$type]))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
$uo = Auth::instance()->get_user();
|
|
||||||
|
|
||||||
foreach ($uo->methods() as $mmo)
|
|
||||||
if ($mmo->menu_display AND preg_match('/^'.$type.'_/',$mmo->name))
|
|
||||||
if (empty($result[$mmo->id]))
|
|
||||||
$result[$mmo->id] = $mmo;
|
|
||||||
|
|
||||||
return static::collapse($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function collapse(array $array) {
|
private static function collapse(array $array) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
@ -46,6 +30,22 @@ class Menu {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function items($type) {
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
if (empty(URL::$method_directory[$type]))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
$uo = Auth::instance()->get_user();
|
||||||
|
|
||||||
|
foreach ($uo->methods() as $mmo)
|
||||||
|
if ($mmo->menu_display AND preg_match('/^'.$type.'_/',$mmo->name))
|
||||||
|
if (empty($result[$mmo->id]))
|
||||||
|
$result[$mmo->id] = $mmo;
|
||||||
|
|
||||||
|
return static::collapse($result);
|
||||||
|
}
|
||||||
|
|
||||||
public static function ul(array $result,array $append=NULL,$sub=FALSE) {
|
public static function ul(array $result,array $append=NULL,$sub=FALSE) {
|
||||||
$output = $sub ? '<ul class="dropdown-menu">' : '<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">';
|
$output = $sub ? '<ul class="dropdown-menu">' : '<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">';
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
abstract class Minion_Task extends Kohana_Minion_Task {
|
abstract class Minion_Task extends Kohana_Minion_Task {
|
||||||
protected $_options = array(
|
protected $_options = array(
|
||||||
'site'=>NULL,
|
'site'=>NULL,
|
||||||
|
'id'=>NULL,
|
||||||
|
'force'=>FALSE,
|
||||||
|
'verbose'=>FALSE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -97,7 +97,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function log($message) {
|
public function log($message) {
|
||||||
// Log the logout
|
// Log a message for this account
|
||||||
$alo = ORM::factory('Account_Log');
|
$alo = ORM::factory('Account_Log');
|
||||||
$alo->account_id = $this->id;
|
$alo->account_id = $this->id;
|
||||||
$alo->ip = Request::$client_ip;
|
$alo->ip = Request::$client_ip;
|
||||||
@ -147,7 +147,7 @@ class Model_Account extends Model_Auth_UserDefault {
|
|||||||
return $active ? $o->where_active()->find_all() : $o->find_all();
|
return $active ? $o->where_active()->find_all() : $o->find_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function services_count($active=TRUE,$afid=NULL) {
|
public function services_count($active=TRUE) {
|
||||||
return $this->services($active)->count();
|
return $this->services($active)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class Model_Auth_UserDefault extends Model_Auth_User {
|
|||||||
// Columns to ignore
|
// Columns to ignore
|
||||||
protected $_ignored_columns = array('password_confirm');
|
protected $_ignored_columns = array('password_confirm');
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Complete our login
|
* Complete our login
|
||||||
*
|
*
|
||||||
* For some database logins, we may not want to record the user last login
|
* For some database logins, we may not want to record the user last login
|
||||||
@ -53,24 +53,9 @@ class Model_Auth_UserDefault extends Model_Auth_User {
|
|||||||
* here.
|
* here.
|
||||||
*
|
*
|
||||||
* We can also do some other post-login actions here.
|
* We can also do some other post-login actions here.
|
||||||
* @todo Maybe we can do our session update here.
|
|
||||||
*/
|
*/
|
||||||
public function complete_login() {
|
public function complete_login() {
|
||||||
return $this->log('Logged In');
|
return $this->log('Logged In');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Debug function to see that has() finds
|
|
||||||
* @todo This function could be removed
|
|
||||||
*/
|
|
||||||
public function has_list($alias, $model) {
|
|
||||||
// Return list of matches
|
|
||||||
return DB::select()
|
|
||||||
->from($this->_has_many[$alias]['through'])
|
|
||||||
->where($this->_has_many[$alias]['foreign_key'], '=', $this->pk())
|
|
||||||
->where($this->_has_many[$alias]['far_key'], '=', $model->pk())
|
|
||||||
->execute($this->_db)
|
|
||||||
->as_array();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -10,10 +10,14 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Country extends ORM_OSB {
|
class Model_Country extends ORM_OSB {
|
||||||
|
protected $_has_one = array(
|
||||||
|
'currency'=>array('far_key'=>'id'),
|
||||||
|
);
|
||||||
|
|
||||||
protected $_form = array('id'=>'id','value'=>'name');
|
protected $_form = array('id'=>'id','value'=>'name');
|
||||||
|
|
||||||
public function currency() {
|
public static function icon() {
|
||||||
return ORM::factory('Currency')->where('country_id','=',$this->id)->find();
|
return HTML::image(sprintf('media/img/country/%s.png',strtolower($this->two_code)),array('alt'=>$this->currency->symbol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -14,23 +14,10 @@ class Model_Group extends Model_Auth_RoleDefault {
|
|||||||
'account'=>array('through'=>'account_group'),
|
'account'=>array('through'=>'account_group'),
|
||||||
'module_method'=>array('through'=>'group_method','far_key'=>'method_id'),
|
'module_method'=>array('through'=>'group_method','far_key'=>'method_id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_sorting = array(
|
protected $_sorting = array(
|
||||||
'name'=>'ASC',
|
'name'=>'ASC',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Validation rules
|
|
||||||
protected $_rules = array(
|
|
||||||
'name' => array(
|
|
||||||
'not_empty' => NULL,
|
|
||||||
'min_length' => array(4),
|
|
||||||
'max_length' => array(32),
|
|
||||||
),
|
|
||||||
'description' => array(
|
|
||||||
'max_length' => array(255),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
protected $_display_filters = array(
|
protected $_display_filters = array(
|
||||||
'status'=>array(
|
'status'=>array(
|
||||||
array('StaticList_YesNo::get',array(':value')),
|
array('StaticList_YesNo::get',array(':value')),
|
||||||
|
@ -14,13 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
class Model_Module extends ORM_OSB {
|
class Model_Module extends ORM_OSB {
|
||||||
// Relationships
|
// Relationships
|
||||||
protected $_has_many = array(
|
|
||||||
'module_method'=>array('far_key'=>'id'),
|
|
||||||
);
|
|
||||||
protected $_has_one = array(
|
protected $_has_one = array(
|
||||||
'record_id'=>array('model'=>'Record_ID','far_key'=>'id'),
|
'record_id'=>array('model'=>'Record_ID','far_key'=>'id'),
|
||||||
);
|
);
|
||||||
|
protected $_has_many = array(
|
||||||
|
'module_method'=>array('far_key'=>'id'),
|
||||||
|
);
|
||||||
protected $_sorting = array(
|
protected $_sorting = array(
|
||||||
'status'=>'DESC',
|
'status'=>'DESC',
|
||||||
'name'=>'ASC',
|
'name'=>'ASC',
|
||||||
|
@ -13,7 +13,6 @@ class Model_RTM extends ORM_OSB {
|
|||||||
protected $_belongs_to = array(
|
protected $_belongs_to = array(
|
||||||
'account' => array(),
|
'account' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_has_many = array(
|
protected $_has_many = array(
|
||||||
'customer' => array('model'=>'account','far_key'=>'id','foreign_key'=>'rtm_id'),
|
'customer' => array('model'=>'account','far_key'=>'id','foreign_key'=>'rtm_id'),
|
||||||
'agent' => array('model'=>'rtm','far_key'=>'id','foreign_key'=>'parent_id'),
|
'agent' => array('model'=>'rtm','far_key'=>'id','foreign_key'=>'parent_id'),
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
* @author Deon George
|
* @author Deon George
|
||||||
* @copyright (c) 2009-2013 Open Source Billing
|
* @copyright (c) 2009-2013 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
* @todo Rename to Record/ID.php
|
|
||||||
*/
|
*/
|
||||||
class Model_Record_ID extends ORM_OSB {
|
class Model_Record_ID extends ORM_OSB {
|
||||||
protected $_primary_key = 'module_id';
|
protected $_primary_key = 'module_id';
|
||||||
@ -16,7 +15,6 @@ class Model_Record_ID extends ORM_OSB {
|
|||||||
protected $_created_column = FALSE;
|
protected $_created_column = FALSE;
|
||||||
protected $_updated_column = FALSE;
|
protected $_updated_column = FALSE;
|
||||||
|
|
||||||
// @todo we need $mid here, since if there is no record, we cant figure out the module that called us.
|
|
||||||
public function next_id($mid) {
|
public function next_id($mid) {
|
||||||
if (is_null($this->id)) {
|
if (is_null($this->id)) {
|
||||||
$this->module_id = $mid;
|
$this->module_id = $mid;
|
||||||
@ -34,7 +32,7 @@ class Model_Record_ID extends ORM_OSB {
|
|||||||
$this->id++;
|
$this->id++;
|
||||||
|
|
||||||
if (! $this->save())
|
if (! $this->save())
|
||||||
throw new Koahan_Exception(_('Unable to increase ID for :table'),array(':table'=>$mid));
|
throw HTTP_Exception::factory(501,'Unable to increase ID for :table',array(':table'=>$mid));
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,20 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
private $_formated = FALSE;
|
private $_formated = FALSE;
|
||||||
// Our filters used to display values in a friendly format
|
// Our filters used to display values in a friendly format
|
||||||
protected $_display_filters = array();
|
protected $_display_filters = array();
|
||||||
|
// Tables that do not have a site_id column
|
||||||
|
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add our OSB site_id to each SELECT query
|
||||||
|
* @see parent::__build()
|
||||||
|
*/
|
||||||
|
final protected function _build($type) {
|
||||||
|
// Exclude tables without site ID's
|
||||||
|
if (! in_array($this->_table_name,ORM::$no_site_id_tables))
|
||||||
|
$this->where($this->_object_name.'.site_id','=',Company::instance()->site());
|
||||||
|
|
||||||
|
return parent::_build($type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format fields for display purposes
|
* Format fields for display purposes
|
||||||
@ -33,6 +47,13 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
$this->_formated = TRUE;
|
$this->_formated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function help to find records that are active
|
||||||
|
*/
|
||||||
|
protected function _where_active() {
|
||||||
|
return $this->where('status','=',TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
public function clear() {
|
public function clear() {
|
||||||
$this->_formated = FALSE;
|
$this->_formated = FALSE;
|
||||||
$this->_object_formated = array();
|
$this->_object_formated = array();
|
||||||
@ -40,23 +61,6 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
return parent::clear();
|
return parent::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a formated columns, as per the model definition
|
|
||||||
*/
|
|
||||||
public function display($column) {
|
|
||||||
// Trigger a load of the record.
|
|
||||||
$value = $this->__get($column);
|
|
||||||
|
|
||||||
// If some of our fields need to be formated for display purposes.
|
|
||||||
if (! $this->_formated AND $this->_display_filters)
|
|
||||||
$this->_format();
|
|
||||||
|
|
||||||
if (isset($this->_object_formated[$column]))
|
|
||||||
return $this->_object_formated[$column];
|
|
||||||
else
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override KH's ORM count_relations() function, to include our site_id in the query.
|
* Override KH's ORM count_relations() function, to include our site_id in the query.
|
||||||
*
|
*
|
||||||
@ -94,21 +98,21 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
return (int) $count;
|
return (int) $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** OSB SPECIFIC ENHANCEMENTS **/
|
|
||||||
|
|
||||||
// Tables that do not have a site_id column
|
|
||||||
public static $no_site_id_tables = array('setup','country','currency','language','tax');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add our OSB site_id to each SELECT query
|
* Return a formated columns, as per the model definition
|
||||||
* @see parent::__build()
|
|
||||||
*/
|
*/
|
||||||
final protected function _build($type) {
|
public function display($column) {
|
||||||
// Exclude tables without site ID's
|
// Trigger a load of the record.
|
||||||
if (! in_array($this->_table_name,ORM::$no_site_id_tables))
|
$value = $this->__get($column);
|
||||||
$this->where($this->_object_name.'.site_id','=',Company::instance()->site());
|
|
||||||
|
|
||||||
return parent::_build($type);
|
// If some of our fields need to be formated for display purposes.
|
||||||
|
if (! $this->_formated AND $this->_display_filters)
|
||||||
|
$this->_format();
|
||||||
|
|
||||||
|
if (isset($this->_object_formated[$column]))
|
||||||
|
return $this->_object_formated[$column];
|
||||||
|
else
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,6 +122,9 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
return $this->_where_active()->find_all();
|
return $this->_where_active()->find_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is our AJAX helper, used by module list_autocomplete()
|
||||||
|
*/
|
||||||
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
public function list_autocomplete($term,$index,$value,array $label,array $limit=array(),array $options=NULL) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
@ -174,13 +181,6 @@ abstract class ORM extends Kohana_ORM {
|
|||||||
return $x;
|
return $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function help to find records that are active
|
|
||||||
*/
|
|
||||||
protected function _where_active() {
|
|
||||||
return $this->where('status','=',TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function where_active() {
|
public function where_active() {
|
||||||
return $this->_where_active();
|
return $this->_where_active();
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@ abstract class ORM_OSB extends ORM {
|
|||||||
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
|
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
|
||||||
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
|
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
|
||||||
|
|
||||||
// Our attribute values that need to be stored as serialized
|
// Our attributes used in forms.
|
||||||
protected $_serialize_column = array();
|
protected $_form = array();
|
||||||
|
|
||||||
// Our attributes that should be converted to NULL when empty
|
// Our attributes that should be converted to NULL when empty
|
||||||
protected $_nullifempty = array();
|
protected $_nullifempty = array();
|
||||||
|
|
||||||
// Our attributes used in forms.
|
// Our attribute values that need to be stored as serialized
|
||||||
protected $_form = array();
|
protected $_serialize_column = array();
|
||||||
|
|
||||||
// Rules to assist with site ID and getting next record ID for inserts.
|
// Rules to assist with site ID and getting next record ID for inserts.
|
||||||
public function rules() {
|
public function rules() {
|
||||||
@ -39,19 +39,6 @@ abstract class ORM_OSB extends ORM {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Try and (un)serialize our data, and if it fails, just return it.
|
|
||||||
*/
|
|
||||||
private function _serialize($data,$set=FALSE) {
|
|
||||||
try {
|
|
||||||
return $set ? serialize($data) : unserialize($data);
|
|
||||||
|
|
||||||
// Maybe the data serialized?
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve and Store DB BLOB data.
|
* Retrieve and Store DB BLOB data.
|
||||||
*/
|
*/
|
||||||
@ -65,6 +52,55 @@ abstract class ORM_OSB extends ORM {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto process some data as it comes from the database
|
||||||
|
* @see parent::__get()
|
||||||
|
*/
|
||||||
|
public function __get($column) {
|
||||||
|
if (array_key_exists($column,$this->_table_columns)) {
|
||||||
|
// If the column is a blob, we'll decode it automatically
|
||||||
|
if (
|
||||||
|
$this->_table_columns[$column]['data_type'] == 'blob'
|
||||||
|
AND ! is_null($this->_object[$column])
|
||||||
|
AND ! isset($this->_changed[$column])
|
||||||
|
AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])
|
||||||
|
) {
|
||||||
|
|
||||||
|
// In case our blob hasnt been saved as one.
|
||||||
|
try {
|
||||||
|
$this->_object[$column] = $this->_blob($this->_object[$column]);
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
|
HTTP_Exception::factory(501,Kohana_Exception::text($e));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_table_columns[$column]['auto_convert'] = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the column is a serialized object, we'll unserialize it.
|
||||||
|
if (
|
||||||
|
in_array($column,$this->_serialize_column)
|
||||||
|
AND is_string($this->_object[$column])
|
||||||
|
AND ! is_null($this->_object[$column])
|
||||||
|
AND ! isset($this->_changed[$column])
|
||||||
|
AND (! isset($this->_table_columns[$column]['unserialized']) OR ! $this->_table_columns[$column]['unserialized'])
|
||||||
|
) {
|
||||||
|
|
||||||
|
// In case our object hasnt been saved as serialized.
|
||||||
|
try {
|
||||||
|
$this->_object[$column] = unserialize($this->_object[$column]);
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
|
HTTP_Exception::factory(501,Kohana_Exception::text($e));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_table_columns[$column]['unserialized'] = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::__get($column);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a column is marked to be nullified if it is empty, this is where it is done.
|
* If a column is marked to be nullified if it is empty, this is where it is done.
|
||||||
*/
|
*/
|
||||||
@ -86,82 +122,15 @@ abstract class ORM_OSB extends ORM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto process some data as it comes from the database
|
* Try and (un)serialize our data, and if it fails, just return it.
|
||||||
* @see parent::__get()
|
|
||||||
*/
|
*/
|
||||||
public function __get($column) {
|
private function _serialize($data,$set=FALSE) {
|
||||||
if (array_key_exists($column,$this->_table_columns)) {
|
|
||||||
// If the column is a blob, we'll decode it automatically
|
|
||||||
if (
|
|
||||||
$this->_table_columns[$column]['data_type'] == 'blob'
|
|
||||||
AND ! is_null($this->_object[$column])
|
|
||||||
AND ! isset($this->_changed[$column])
|
|
||||||
AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
// In case our blob hasnt been saved as one.
|
|
||||||
try {
|
try {
|
||||||
$this->_object[$column] = $this->_blob($this->_object[$column]);
|
return $set ? serialize($data) : unserialize($data);
|
||||||
}
|
|
||||||
catch(Exception $e) {
|
|
||||||
// @todo Log this exception
|
|
||||||
echo Kohana_Exception::text($e), "\n";
|
|
||||||
echo debug_print_backtrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_table_columns[$column]['auto_convert'] = TRUE;
|
// Maybe the data serialized?
|
||||||
}
|
} catch (Exception $e) {
|
||||||
|
return $data;
|
||||||
// If the column is a serialized object, we'll unserialize it.
|
|
||||||
if (
|
|
||||||
in_array($column,$this->_serialize_column)
|
|
||||||
AND is_string($this->_object[$column])
|
|
||||||
AND ! is_null($this->_object[$column])
|
|
||||||
AND ! isset($this->_changed[$column])
|
|
||||||
AND (! isset($this->_table_columns[$column]['unserialized']) OR ! $this->_table_columns[$column]['unserialized'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
// In case our object hasnt been saved as serialized.
|
|
||||||
try {
|
|
||||||
$this->_object[$column] = unserialize($this->_object[$column]);
|
|
||||||
}
|
|
||||||
catch(Exception $e) {
|
|
||||||
// @todo Log this exception
|
|
||||||
echo Kohana_Exception::text($e), "\n";
|
|
||||||
echo debug_print_backtrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_table_columns[$column]['unserialized'] = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::__get($column);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will enhance the [Validate::filter], since it always passes
|
|
||||||
* the value as the first argument and sometimes functions need that to not
|
|
||||||
* be the first argument.
|
|
||||||
*
|
|
||||||
* Currently this implements:
|
|
||||||
* [date()][date-ref]
|
|
||||||
*
|
|
||||||
* [date-ref]: http://www.php.net/date
|
|
||||||
*
|
|
||||||
* This function will throw an exception if called without a function
|
|
||||||
* defined.
|
|
||||||
*
|
|
||||||
* @param mixed $val Value to be processed
|
|
||||||
* @param string $func Name of function to call
|
|
||||||
* @param string $arg Other arguments for the function
|
|
||||||
* @todo This has probably changed in KH 3.1
|
|
||||||
*/
|
|
||||||
final public static function x_filters($val,$func,$arg) {
|
|
||||||
switch ($func) {
|
|
||||||
case 'date':
|
|
||||||
return date($arg,$val);
|
|
||||||
default:
|
|
||||||
throw new Exception(sprintf(_('Unknown function: %s (%s,%s)'),$func,$arg,$val));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,19 +164,6 @@ abstract class ORM_OSB extends ORM {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the site ID attribute for each row update
|
|
||||||
*/
|
|
||||||
final public static function set_site_id($model,$field) {
|
|
||||||
if (! is_null($model->$field))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
$model->_changed[$field] = $field;
|
|
||||||
$model->$field = Company::instance()->site();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function keyget($column,$key=NULL) {
|
public function keyget($column,$key=NULL) {
|
||||||
if (is_null($key) OR ! is_array($this->$column))
|
if (is_null($key) OR ! is_array($this->$column))
|
||||||
return $this->$column;
|
return $this->$column;
|
||||||
@ -249,6 +205,19 @@ abstract class ORM_OSB extends ORM {
|
|||||||
return parent::save($validation);
|
return parent::save($validation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the site ID attribute for each row update
|
||||||
|
*/
|
||||||
|
final public static function set_site_id($model,$field) {
|
||||||
|
if (! is_null($model->$field))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
$model->_changed[$field] = $field;
|
||||||
|
$model->$field = Company::instance()->site();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
public function status($render=FALSE) {
|
public function status($render=FALSE) {
|
||||||
if (! isset($this->_table_columns['status']))
|
if (! isset($this->_table_columns['status']))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -13,10 +13,6 @@ abstract class StaticList {
|
|||||||
// Our Static Items List
|
// Our Static Items List
|
||||||
abstract protected function _table();
|
abstract protected function _table();
|
||||||
|
|
||||||
// To get an individual item from the table
|
|
||||||
// @note This must be declared in the child class due to static scope
|
|
||||||
//abstract public static function get($value);
|
|
||||||
|
|
||||||
// Due to static scope, sometimes we need to call this function from the child class.
|
// Due to static scope, sometimes we need to call this function from the child class.
|
||||||
protected function _get($id) {
|
protected function _get($id) {
|
||||||
$table = $this->_table();
|
$table = $this->_table();
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class extends Minions Tasks to require the site option
|
|
||||||
*
|
|
||||||
* @package OSB
|
|
||||||
* @category Helpers
|
|
||||||
* @author Deon George
|
|
||||||
* @copyright (c) 2009-2013 Open Source Billing
|
|
||||||
* @license http://dev.osbill.net/license.html
|
|
||||||
*/
|
|
||||||
abstract class Task extends Minion_Task {
|
|
||||||
protected $_options = array(
|
|
||||||
'site'=>NULL,
|
|
||||||
'id'=>NULL,
|
|
||||||
'force'=>FALSE,
|
|
||||||
'verbose'=>FALSE,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
?>
|
|
@ -9,7 +9,7 @@
|
|||||||
* @copyright (c) 2009-2013 Open Source Billing
|
* @copyright (c) 2009-2013 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Task_Account_Complete extends Task {
|
class Task_Account_Complete extends Minion_Task {
|
||||||
protected function _execute(array $params) {
|
protected function _execute(array $params) {
|
||||||
$c = 0;
|
$c = 0;
|
||||||
|
|
||||||
@ -18,8 +18,7 @@ class Task_Account_Complete extends Task {
|
|||||||
|
|
||||||
foreach ($o->find_all() as $ao) {
|
foreach ($o->find_all() as $ao) {
|
||||||
if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0)
|
if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0)
|
||||||
// @todo Cant update status=0, problem with sessions in CLI
|
$ao->status = 0;
|
||||||
echo $ao->id.',';
|
|
||||||
|
|
||||||
$ao->save();
|
$ao->save();
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ class Task_Account_Complete extends Task {
|
|||||||
$c++;
|
$c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf('%s services updated',$c);
|
printf("%s services made inactive\n",$c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -22,21 +22,6 @@ class URL extends Kohana_URL {
|
|||||||
return (Request::current() AND ((Auth::instance()->logged_in() AND ! empty(URL::$method_directory[strtolower(Request::current()->directory())])) OR in_array(strtolower(Request::current()->controller()),array('login'))));
|
return (Request::current() AND ((Auth::instance()->logged_in() AND ! empty(URL::$method_directory[strtolower(Request::current()->directory())])) OR in_array(strtolower(Request::current()->controller()),array('login'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper to provide a URL::site() link based on function
|
|
||||||
*/
|
|
||||||
public static function link($dir,$src,$site=FALSE) {
|
|
||||||
if (! $dir)
|
|
||||||
return $src;
|
|
||||||
|
|
||||||
if (! array_key_exists($dir,URL::$method_directory))
|
|
||||||
throw new Kohana_Exception('Unknown directory :dir for :src',array(':dir'=>$dir,':src'=>$src));
|
|
||||||
|
|
||||||
$x = URL::$method_directory[$dir].'/'.$src;
|
|
||||||
|
|
||||||
return $site ? URL::site($x) : $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to reveal the real directory for a URL
|
* Function to reveal the real directory for a URL
|
||||||
*/
|
*/
|
||||||
@ -54,6 +39,21 @@ class URL extends Kohana_URL {
|
|||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to provide a URL::site() link based on function
|
||||||
|
*/
|
||||||
|
public static function link($dir,$src,$site=FALSE) {
|
||||||
|
if (! $dir)
|
||||||
|
return $src;
|
||||||
|
|
||||||
|
if (! array_key_exists($dir,URL::$method_directory))
|
||||||
|
throw new Kohana_Exception('Unknown directory :dir for :src',array(':dir'=>$dir,':src'=>$src));
|
||||||
|
|
||||||
|
$x = URL::$method_directory[$dir].'/'.$src;
|
||||||
|
|
||||||
|
return $site ? URL::site($x) : $x;
|
||||||
|
}
|
||||||
|
|
||||||
public static function navbar() {
|
public static function navbar() {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@ class XML extends XML_Core {
|
|||||||
* Collapse an XML object into a simple array
|
* Collapse an XML object into a simple array
|
||||||
*/
|
*/
|
||||||
public function collapse(XML $xml=NULL) {
|
public function collapse(XML $xml=NULL) {
|
||||||
|
$result = array();
|
||||||
|
|
||||||
if (is_null($xml))
|
if (is_null($xml))
|
||||||
$xml = $this;
|
$xml = $this;
|
||||||
$result = array();
|
|
||||||
|
|
||||||
foreach ($xml->as_array() as $j=>$k) {
|
foreach ($xml->as_array() as $j=>$k) {
|
||||||
$v = $xml->$j->value();
|
$v = $xml->$j->value();
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OSB Configuration - Cache Driver
|
|
||||||
*
|
|
||||||
* @package OSB
|
|
||||||
* @subpackage Cache
|
|
||||||
* @category Configuration
|
|
||||||
* @author Deon George
|
|
||||||
* @copyright (c) 2010 Open Source Billing
|
|
||||||
* @license http://dev.osbill.net/license.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'apc' => array(
|
|
||||||
'driver' => 'apc',
|
|
||||||
'default_expire' => 3600,
|
|
||||||
),
|
|
||||||
|
|
||||||
'file' => array(
|
|
||||||
'driver' => 'file',
|
|
||||||
'cache_dir' => Kohana::$cache_dir ? Kohana::$cache_dir : APPPATH.'cache/',
|
|
||||||
'default_expire' => 3600,
|
|
||||||
'ignore_on_delete' => array(
|
|
||||||
'.gitignore',
|
|
||||||
'.git',
|
|
||||||
'.htaccess',
|
|
||||||
'.svn'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
?>
|
|
@ -1,46 +0,0 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
||||||
|
|
||||||
return array
|
|
||||||
(
|
|
||||||
// Enable the API browser. TRUE or FALSE
|
|
||||||
'api_browser' => TRUE,
|
|
||||||
|
|
||||||
// Enable these packages in the API browser. TRUE for all packages, or a string of comma seperated packages, using 'None' for a class with no @package
|
|
||||||
// Example: 'api_packages' => 'Kohana,Kohana/Database,Kohana/ORM,None',
|
|
||||||
'api_packages' => TRUE,
|
|
||||||
|
|
||||||
// Enables Disqus comments on the API and User Guide pages
|
|
||||||
'show_comments' => Kohana::$environment === Kohana::PRODUCTION,
|
|
||||||
|
|
||||||
// Leave this alone
|
|
||||||
'modules' => array(
|
|
||||||
|
|
||||||
'kohana' => array('enabled'=>FALSE),
|
|
||||||
'auth' => array('enabled'=>FALSE),
|
|
||||||
'cache' => array('enabled'=>FALSE),
|
|
||||||
'database' => array('enabled'=>FALSE),
|
|
||||||
'minion' => array('enabled'=>FALSE),
|
|
||||||
'orm' => array('enabled'=>FALSE),
|
|
||||||
'pagination' => array('enabled'=>FALSE),
|
|
||||||
// This should be the path to this modules userguide pages, without the 'guide/'. Ex: '/guide/modulename/' would be 'modulename'
|
|
||||||
'userguide' => array(
|
|
||||||
|
|
||||||
// Whether this modules userguide pages should be shown
|
|
||||||
'enabled' => TRUE,
|
|
||||||
|
|
||||||
// The name that should show up on the userguide index page
|
|
||||||
'name' => 'Userguide',
|
|
||||||
|
|
||||||
// A short description of this module, shown on the index page
|
|
||||||
'description' => 'Documentation viewer and api generation.',
|
|
||||||
|
|
||||||
// Copyright message, shown in the footer for this module
|
|
||||||
'copyright' => '© 2008–2012 Kohana Team',
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
// Set transparent class name segments
|
|
||||||
'transparent_prefixes' => array(
|
|
||||||
'Kohana' => TRUE,
|
|
||||||
)
|
|
||||||
);
|
|
@ -1,16 +0,0 @@
|
|||||||
<br/>
|
|
||||||
<?php echo Form::open(); ?>
|
|
||||||
<table class="login">
|
|
||||||
<tr><td><b>User Name:</b></td></tr>
|
|
||||||
<tr><td><?php echo Form::input('username',NULL,array('id'=>'login-uid','size'=>40));?></td></tr>
|
|
||||||
<tr><td colspan="2"> </td></tr>
|
|
||||||
<tr><td><b>Password:</b></td></tr>
|
|
||||||
<tr><td><?php echo Form::password('password',NULL,array('id'=>'login-pwd','size'=>40));?></td></tr>
|
|
||||||
<tr><td colspan="2"> </td></tr>
|
|
||||||
<!-- @todo Password reset ability should be a config option (or auto detected) -->
|
|
||||||
<tr><td colspan="2"><?php echo HTML::anchor('login/reset',_('Forgot your password?')); ?></td></tr>
|
|
||||||
<tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Authenticate'),array('class'=>'form_button'));?></td></tr>
|
|
||||||
</table>
|
|
||||||
<?php echo Form::close(); ?>
|
|
||||||
<!-- @todo The following focus() is not ajax/jscript friendly -->
|
|
||||||
<script type="text/javascript">document.getElementById('login-uid').focus();</script>
|
|
@ -1,14 +0,0 @@
|
|||||||
<div style="text-align: center;">
|
|
||||||
<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>
|
|
||||||
<p>To start this process, please enter your email address.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php echo Form::open(); ?>
|
|
||||||
<table class="login">
|
|
||||||
<tr><td><b>Username</b></td></tr>
|
|
||||||
<tr><td><?php echo Form::input('username',NULL,array('id'=>'login-uid','size'=>40));?></td></tr>
|
|
||||||
<tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Reset'),array('class'=>'form_button'));?></td></tr>
|
|
||||||
</table>
|
|
||||||
<?php echo Form::close(); ?>
|
|
||||||
<!-- @todo The following focus() is not ajax/jscript friendly -->
|
|
||||||
<script type="text/javascript">document.getElementById('login-uid').focus();</script>
|
|
@ -1,13 +0,0 @@
|
|||||||
<div style="text-align: center;">
|
|
||||||
<p>You should have received an email with a pass code. Please enter that pass code here.</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php echo Form::open(); ?>
|
|
||||||
<table class="login">
|
|
||||||
<tr><td><b>Pass code</b></td></tr>
|
|
||||||
<tr><td><?php echo Form::input('token',NULL,array('id'=>'login-pwd','size'=>40));?></td></tr>
|
|
||||||
<tr><td colspan="2" style="text-align: center;"><?php echo Form::submit('submit',_('Reset'),array('class'=>'form_button'));?></td></tr>
|
|
||||||
</table>
|
|
||||||
<?php echo Form::close(); ?>
|
|
||||||
<!-- @todo The following focus() is not ajax/jscript friendly -->
|
|
||||||
<script type="text/javascript">document.getElementById('login-pwd').focus();</script>
|
|
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">
|
||||||
|
<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 email address.</p>
|
||||||
|
<div class="field">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" />
|
||||||
|
</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 -->
|
19
application/views/pages/login_reset_sent.php
Normal file
19
application/views/pages/login_reset_sent.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<div class="account-container stacked">
|
||||||
|
<div class="content clearfix">
|
||||||
|
<form method="post">
|
||||||
|
<h1>Reset Password</h1>
|
||||||
|
|
||||||
|
<div class="login-fields">
|
||||||
|
<p>You should have received an email with a pass code. Please enter that pass code here.</p>
|
||||||
|
<div class="field">
|
||||||
|
<label for="token">Pass Code:</label>
|
||||||
|
<input type="text" id="token" name="token" value="" placeholder="Token" class="login password-field" />
|
||||||
|
</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 -->
|
Reference in New Issue
Block a user