Updated for new lnApp

This commit is contained in:
Deon George 2014-08-25 14:41:07 +10:00
parent 52e94c6e7d
commit c1b1485c10
44 changed files with 208 additions and 481 deletions

View File

@ -115,7 +115,7 @@ Kohana::$config->attach(new Config_File);
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'lnapp' => MODPATH.'lnApp', // lnApp Base Application Tools
'lnapp' => MODPATH.'lnapp', // lnApp Base Application Tools
'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
'auth' => SMDPATH.'auth', // Basic authentication
'cache' => SMDPATH.'cache', // Caching with multiple backends

View File

@ -77,10 +77,6 @@ class Company {
return $this->so->language;
}
public function logo() {
return Config::logo();
}
public function logo_file() {
list ($path,$suffix) = explode('.',Config::$logo);
@ -119,10 +115,6 @@ class Company {
return $this->so->site_details('address2') ? implode($ln,array($this->so->site_details('address1'),$this->so->site_details('address2'))) : $this->so->site_details('address1');
}
public function sitemode() {
return $this->so->status;
}
public function taxid() {
// Tax ID details are stored in invoice config
$mc = $this->so->module_config('invoice');

View File

@ -49,62 +49,10 @@ class Config extends Kohana_Config {
return Config::$_instance;
}
/**
* Return our caching mechanism
*/
public static function cachetype() {
return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type;
}
public static function copywrite() {
return '(c) Open Source Billing Development Team';
}
public static function country() {
return Company::instance()->country();
}
/**
* Show a date using a site configured format
*/
public static function date($date) {
return (is_null($date) OR ! $date) ? '' : date(Company::instance()->date_format(),$date);
}
/**
* Show a date using a site configured format
* @note We need this function here, since we call self:: methods, which need to resolve to the child class.
*/
public static function datetime($date) {
return sprintf('%s %s',self::date($date),self::time($date));
}
public static function language() {
return Company::instance()->language();
}
/**
* The URI to show for the login prompt.
* Normally if the user is logged in, we can replace it with something else
*/
public static function login_uri() {
return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor(URL::link('user','account/edit'),$ao->name()) : HTML::anchor('login',_('Login'));
}
public static function logout_uri() {
return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? HTML::anchor('logout','Logout',array('class'=>'lnk_logout')) : '';
}
public static function logo() {
return HTML::image(self::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo')));
}
public static function logo_uri($protocol=NULL) {
list ($path,$suffix) = explode('.',self::$logo);
return URL::site(Route::get('default/media')->uri(array('file'=>$path.'.'.$suffix),array('alt'=>self::sitename())),$protocol);
}
/**
* Find a list of all database enabled modules
*
@ -141,24 +89,6 @@ class Config extends Kohana_Config {
return array_key_exists(strtolower($module),self::modules()) ? TRUE : FALSE;
}
/**
* Work out our site ID for multiehosting
*/
public static function siteid($format=FALSE) {
return Company::instance()->site($format);
}
/**
* Work out our site mode (dev,test,prod)
*/
public static function sitemode() {
return Company::instance()->sitemode();
}
public static function sitename() {
return Company::instance()->name();
}
/**
* See if our emails for the template should be sent to configured admin(s)
*
@ -173,17 +103,5 @@ class Config extends Kohana_Config {
else
return $config[$template];
}
public static function theme() {
// If we are using user admin pages (and login), we'll choose the admin theme.
return 'theme/'.(URL::admin_url() ? Kohana::$config->load('config')->theme_admin : Kohana::$config->load('config')->theme);
}
/**
* Show a date using a site configured format
*/
public static function time($date) {
return date(Company::instance()->time_format(),($date ? $date : time()));
}
}
?>

View File

@ -1,36 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
*
* @package OSB
* @category Controllers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Debug extends Controller_TemplateDefault {
public function before() {
if (! in_array(Config::sitemode(),array(Kohana::DEVELOPMENT,Kohana::TESTING)))
HTTP::redirect();
parent::before();
}
public function action_site() {
$output = '';
$output .= debug::vars(array(
'm'=>__METHOD__,
'site'=>Config::site(),
'siteID'=>Company::instance()->site(),
'siteMode'=>Config::sitemodeverbose(),
'modules'=>Config::appmodules(),
));
Block::add(array(
'title'=>_('Site debug'),
'body'=>$output,
));
}
}
?>

View File

@ -37,9 +37,9 @@ abstract class Kohana extends Kohana_Core {
$prefixes = array('');
// Our search order.
array_unshift($prefixes,Config::theme().'/');
array_unshift($prefixes,sprintf('site/%s/',Config::siteid()));
array_unshift($prefixes,sprintf('site/%s/%s/',Config::siteid(),Config::theme()));
array_unshift($prefixes,Site::Theme().'/');
array_unshift($prefixes,sprintf('site/%s/',Site::ID()));
array_unshift($prefixes,sprintf('site/%s/%s/',Site::ID(),Site::Theme()));
foreach ($prefixes as $p)
if ($x = parent::find_file($dir,$p.$file,$ext,$array))

View File

@ -29,10 +29,10 @@ class Model_Account extends Model_Auth_UserDefault {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_last'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),

View File

@ -20,7 +20,7 @@ class Model_Account_Log extends ORM_OSB {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);
}

View File

@ -22,6 +22,11 @@ class Model_Setup extends ORM_OSB {
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
);
protected $_compress_column = array(
'module_config',
'site_details',
);
protected $_save_message = TRUE;
// Validation rules

View File

@ -15,23 +15,6 @@ abstract class ORM_OSB extends ORM {
*/
protected $_db = 'default';
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
// Our attributes used in forms.
protected $_form = array();
// Our attributes that should be converted to NULL when empty
protected $_nullifempty = array();
// Our attribute values that need to be stored as serialized
protected $_serialize_column = array();
// If we need to load any sub items on loading this model
protected $_sub_items = array();
protected $_sub_items_load = array();
protected $_sub_items_sorted = FALSE;
// Rules to assist with site ID and getting next record ID for inserts.
public function rules() {
return array(
@ -44,136 +27,12 @@ abstract class ORM_OSB extends ORM {
);
}
/**
* Retrieve and Store DB BLOB data.
*/
private function _blob($data,$set=FALSE) {
try {
return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {
return $this->_serialize($data,$set);
}
}
/**
* 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);
}
/**
* Intercept our object load, so that we can load our subitems
*/
protected function _load_values(array $values) {
parent::_load_values($values);
$sort = FALSE;
if ($this->_loaded AND $this->_sub_items_load AND count($this->_sub_items_load) == 1)
foreach ($this->_sub_items_load as $item => $sort)
$this->_sub_items = $this->$item->find_all()->as_array();
if ($sort) {
Sort::MAsort($this->_sub_items,$sort);
$this->_sub_items_sorted = TRUE;
}
return $this;
}
/**
* If a column is marked to be nullified if it is empty, this is where it is done.
*/
private function _nullifempty(array $array) {
foreach ($array as $k=>$v) {
if (is_array($v)) {
if (is_null($x=$this->_nullifempty($v)))
unset($array[$k]);
else
$array[$k] = $x;
} elseif (! $v AND $v !== 0 AND $v !== '0')
unset($array[$k]);
}
return count($array) ? $array : NULL;
}
/**
* 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;
}
}
public function config($key) {
$mc = Config::instance()->module_config($this->_object_name);
return empty($mc[$key]) ? '' : $mc[$key];
}
public function dump() {
$result = array();
$result['this'] = $this->object();
foreach ($this->_sub_items as $o)
$result['sub'][] = $o->dump();
return $result;
}
/**
* Get Next record id
*
@ -209,31 +68,6 @@ abstract class ORM_OSB extends ORM {
return ORM::factory('Module',array('name'=>$this->_table_name));
}
public function save(Validation $validation=NULL) {
// Find any fields that have changed, and process them.
if ($this->_changed)
foreach ($this->_changed as $c) {
// Any fields that are blobs, and encode them.
if (! is_null($this->_object[$c]) AND $this->_table_columns[$c]['data_type'] == 'blob') {
$this->_object[$c] = $this->_blob($this->_object[$c],TRUE);
// We need to reset our auto_convert flag
if (isset($this->_table_columns[$c]['auto_convert']))
$this->_table_columns[$c]['auto_convert'] = FALSE;
// Any fields that should be seriailzed, we'll do that.
} elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) {
$this->_object[$c] = serialize($this->_object[$c]);
}
// Test if the value has still changed
if ($this->_original_values AND $this->_object[$c] == $this->_original_values[$c])
unset($this->_changed[$c]);
}
return parent::save($validation);
}
/**
* Set the site ID attribute for each row update
*/
@ -247,28 +81,6 @@ abstract class ORM_OSB extends ORM {
return TRUE;
}
public function subitems() {
return $this->_sub_items;
}
/**
* Override the Kohana processing so we can null values if required.
*/
public function values(array $values,array $expected=NULL) {
foreach ($values as $k=>$v) {
// Convert to NULL
if (in_array($k,$this->_nullifempty)) {
if (is_array($v))
$values[$k] = $this->_nullifempty($v);
elseif (! $v AND $v !== 0 AND $v !== '0')
$values[$k] = NULL;
}
}
return parent::values($values,$expected);
}
/**
* Function help to find records that are active
*/

View File

@ -118,7 +118,7 @@ class Period {
if ($df)
foreach (array('start','date','end') as $key)
$result[$key] = Config::date($result[$key]);
$result[$key] = Site::Date($result[$key]);
return $result;
}

View File

@ -0,0 +1,39 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for Site Information
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Site extends lnApp_Site {
/**
* Show a date using a site configured format
*/
public static function Date($date) {
return (is_null($date) OR ! $date) ? '' : date(Company::instance()->date_format(),$date);
}
/**
* Work out our site ID for multihosting
*/
public static function ID($format=FALSE) {
return Company::instance()->site($format);
}
public static function Theme() {
// If we are using user admin pages (and login), we'll choose the admin theme.
return 'theme/'.(URL::admin_url() ? Kohana::$config->load('config')->theme_admin : Kohana::$config->load('config')->theme);
}
/**
* Show a date using a site configured format
*/
public static function Time($date) {
return date(Company::instance()->time_format(),($date ? $date : time()));
}
}
?>

View File

@ -1,66 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class renders standard lists and their values
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class StaticList {
// Our Static Items List
abstract protected function _table();
// Due to static scope, sometimes we need to call this function from the child class.
protected function _get($id) {
$table = $this->_table();
if (! $table)
return 'No Table';
elseif (! $id AND empty($table[$id]))
return '';
elseif (empty($table[$id]))
return sprintf('No Value (%s)',$id);
else
return $table[$id];
}
/**
* Setup our class instantiation
* @note This must be declared in the child class due to static scope
*/
public static function factory() {
$x = get_called_class();
return new $x;
}
/**
* Renders form input
*
* @param string Form name to render
* @param string Default value to populate in the Form input.
*/
public static function form($name,$default='',$addblank=FALSE,array $attributes=NULL) {
$table = self::factory()->_table();
if ($addblank)
$table = array_merge(array(''=>'&nbsp;'),$table);
return Form::Select($name,$table,$default,$attributes);
}
/**
* Lists our available keys
*/
public static function keys() {
return array_keys(self::factory()->_table());
}
public static function table() {
return self::factory()->_table();
}
}
?>

View File

@ -1,29 +0,0 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This is class renders Yes/No 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_YesNo extends StaticList {
protected function _table() {
return array(
0=>_('No'),
1=>_('Yes'),
);
}
public static function get($value,$format=FALSE) {
if (! $value)
$value = 0;
return $format ? View::factory(Config::theme().'/label/bool')
->set('label',$value ? 'label-success' : '')
->set('column',self::factory()->_get($value)) : $value;
}
}
?>

View File

@ -0,0 +1,42 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class adds reseller/affilate support
*
* @package OSB
* @category Modifications
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.osbill.net/license.html
*/
class URL extends lnApp_URL {
// Our method paths for different functions
public static $method_directory = array(
'admin'=>'a',
'reseller'=>'r',
'affiliate'=>'f',
'user'=>'u',
);
public static function navbar() {
$result = array();
foreach (array_reverse(self::$method_directory) as $k=>$v)
switch ($k) {
case 'admin': $result[$k] = array('name'=>'Administrator','icon'=>'icon-globe');
break;
case 'affiliate':
case 'reseller': $result[$k] = array('name'=>'Reseller','icon'=>'icon-th-list');
break;
case 'user': $result[$k] = array('name'=>Auth::instance()->get_user()->name(),'icon'=>'icon-user');
break;
default: $result[$k] = array('name'=>$k,'icon'=>'icon-question-sign');
}
return $result;
}
}
?>

View File

@ -12,8 +12,6 @@
return array
(
'ajax'=>FALSE, // AJAX actions can only be run by ajax calls if set to FALSE
'etag'=>FALSE, // Force generating ETAGS
'checkout_notify'=>FALSE, // Test mode to test a particular checkout_notify item
'disabled_noaccess_redirect'=>FALSE, // Disable redirect when noaccess
'email_admin_only'=> array( // Override emails and send them to an admin instead
@ -23,7 +21,6 @@ return array
// 'deon@leenooks.net'=>'Deon George',
),
'invoice'=>0, // Number of invoices to generate in a pass
'site'=>FALSE, // Glogal site debug
'show_errors'=>FALSE, // Show errors instead of logging in the DB.
'show_inactive'=>FALSE, // Show Inactive Items
'task_sim'=>FALSE, // Simulate running tasks

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title><?php echo $meta->title; ?></title>
<title><?php echo Site::Appname(); ?></title>
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="<?php echo $meta->language; ?>" />
@ -19,12 +19,12 @@
echo HTML::style('media/theme/bootstrap/css/bootstrap-responsive.min.css');
echo HTML::style('media/vendor/font-awesome/css/font-awesome.min.css');
} else {
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css');
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css');
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css');
echo HTML::style(Site::Protocol('netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css'));
echo HTML::style(Site::Protocol('netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css'));
echo HTML::style(Site::Protocol('netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css'));
}
echo HTML::style($meta->secure().'fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,800italic,400,600,800');
echo HTML::style(Site::Protocol('fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,800italic,400,600,800'));
echo HTML::style('media/css/ui-lightness/jquery-ui-1.10.0.custom.min.css');
echo HTML::style('media/theme/baseadmin/css/base-admin-2.css');
echo HTML::style('media/theme/baseadmin/css/base-admin-2-responsive.css');
@ -39,13 +39,14 @@
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><i class="icon-cog"></i> </a>
<a class="brand" href="<?php echo URL::site(); ?>"><?php echo Config::sitename(); ?><sup></sup></a>
<a class="brand" href="<?php echo URL::site(); ?>"><?php echo Site::Appname(); ?><sup></sup></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<?php echo $navbar; ?>
</ul>
<?php if (class_exists('Controller_Search')) : ?>
<div class="navbar-search pull-right">
<div class="navbar-search-addon">
<i class="icon-search"></i>
@ -53,6 +54,7 @@
<input type="text" name="search-query" class="search-query" placeholder="Search" data-provide="typeahead">
</div>
</div>
<?php endif ?>
</div><!--/.nav-collapse -->
</div> <!-- /container -->
@ -69,15 +71,15 @@
<div class="subnav-collapse collapse">
<ul class="mainnav">
<li class="">
<a href="<?php echo URL::link('user','welcome',TRUE); ?>"><i class="icon-home"></i> <span>Home</span></a>
<a href="<?php echo URL::link('user','welcome',TRUE); ?>"><i class="icon-home"></i><span>Home</span></a>
</li>
<?php if (($ao = Auth::instance()->get_user()) AND $ao->isAdmin()) : ?>
<?php if (class_exists('Auth') AND ($ao = Auth::instance()->get_user()) AND $ao->isAdmin()) : ?>
<li class="">
<a href="<?php echo URL::link('admin','welcome',TRUE); ?>"><i class="icon-tasks"></i> <span>Admin</span></a>
<a href="<?php echo URL::link('admin','welcome',TRUE); ?>"><i class="icon-tasks"></i><span>Admin</span></a>
</li>
<?php elseif ($ao->isReseller()) : ?>
<li class="">
<a href="<?php echo URL::link('reseller','welcome',TRUE); ?>"><i class="icon-tasks"></i> <span>Reseller</span></a>
<a href="<?php echo URL::link('reseller','welcome',TRUE); ?>"><i class="icon-tasks"></i><span>Reseller</span></a>
</li>
<?php endif ?>
</ul>
@ -111,9 +113,9 @@
echo HTML::script('media/theme/bootstrap/js/bootstrap.min.js');
echo HTML::script('media/js/lodash/lodash-1.2.1.min.js');
} else {
echo HTML::script($meta->secure().'code.jquery.com/jquery-1.9.1.min.js');
echo HTML::script($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js');
echo HTML::script($meta->secure().'cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js');
echo HTML::script(Site::Protocol('code.jquery.com/jquery-1.9.1.min.js'));
echo HTML::script(Site::Protocol('netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js'));
echo HTML::script(Site::Protocol('cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js'));
}
echo HTML::script('media/theme/baseadmin/js/backtotop.js');

View File

@ -25,10 +25,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
protected $_display_filters = array(
'service_connect_date'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'service_contract_date'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);
@ -66,14 +66,14 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
* Calculate our contract start and end dates
*/
public function contract_date_start($format=FALSE) {
return $format ? Config::date($this->service_contract_date) : $this->service_contract_date;
return $format ? Site::Date($this->service_contract_date) : $this->service_contract_date;
}
public function contract_date_end($format=FALSE) {
// ADSL Contract Terms are held in the ADSL Plan
$x = strtotime(sprintf('+%s months',$this->service->plugin()->contract_term),$this->service_contract_date);
return $format ? Config::date($x) : $x;
return $format ? Site::Date($x) : $x;
}
/**
@ -248,7 +248,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
$google = GoogleChart::factory('Legacy')
->type('vertical_bar')
->title(sprintf('DSL traffic usage as at %s',Config::date($data['last'])));
->title(sprintf('DSL traffic usage as at %s',Site::Date($data['last'])));
foreach ($traffic_type as $k => $details)
$google->sdata(array('yl'=>($x=$this->traffic->friendly($k))),array($x=>$details));
@ -277,7 +277,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
case 'PEAK_AVERAGE_REMAIN': $value = ((isset($data['used']['base_down_peak']) AND ($data['allow']['base_down_peak'] > $data['used']['base_down_peak']) AND $daysleft) ? round(($data['allow']['base_down_peak']-$data['used']['base_down_peak'])/$daysleft,2).' MB' : '-'); break;
case 'SERVICE_NUMBER': $value = $this->service_number; break;
case 'USAGE_DATE': $value = Config::date($data['last']); break;
case 'USAGE_DATE': $value = Site::Date($data['last']); break;
case 'USER_NAME': $value = $this->service->account->name(); break;
default:
$value = '';

View File

@ -36,10 +36,10 @@ class Model_Charge extends ORM_OSB implements Invoicable {
array('Currency::display',array(':value')),
),
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_charge'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'processed'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),

View File

@ -17,10 +17,14 @@ class Model_Checkout_Notify extends ORM_OSB implements Invoicable {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);
protected $_compress_column = array(
'data',
);
public function invoice_item($item_type) {
return sprintf('Payment Fee: %s',$this->checkout->name);
}

View File

@ -23,13 +23,13 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
protected $_display_filters = array(
'domain_expire'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'domain_name'=>array(
array('strtoupper',array(':value')),
),
'registrar_lastsync'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);

View File

@ -24,18 +24,18 @@ class Email_Template {
throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template));
if (is_null($language_id))
$language_id = Config::language();
$language_id = Company::instance()->language();
$this->_etto = $eto->translate
->where_open()
->where('language_id','=',$language_id)
->or_where('language_id','=',Config::language())
->or_where('language_id','=',Company::instance()->language())
->where_close()
->find();
if (! $this->_etto->loaded())
throw new Kohana_Exception('No template (:template) found for user language (:language_id) or default language (:default_lang)',
array(':template'=>$eto->name,':language_id'=>$language_id,':default_lang'=>Config::language()));
array(':template'=>$eto->name,':language_id'=>$language_id,':default_lang'=>Company::instance()->language()));
}
public function __set($key,$value) {

View File

@ -22,9 +22,13 @@ class Model_Email_Log extends ORM_OSB {
'id'=>'DESC',
);
protected $_compress_column = array(
'data',
);
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);

View File

@ -88,7 +88,7 @@ class Controller_Reseller_Export extends Controller_Export {
->prepend(array(
'id'=>array('checkbox'=>'id[]'),
))->filters(array(
'exported'=>array(array('Config::date',array(':value'))),
'exported'=>array(array('Site::Date',array(':value'))),
));
$output .= '</div>';

View File

@ -16,6 +16,10 @@ class Model_Export_DataMap extends ORM_OSB {
'module' => array(),
);
protected $_compress_column = array(
'map_data',
);
public function list_itemsnoexport(Model $o,$emoid,$desc='title()') {
$result = array();

View File

@ -22,6 +22,10 @@ class Model_Export_Module extends ORM_OSB {
'export_item' => array('far_key'=>'id'),
);
protected $_compress_column = array(
'display',
);
protected $_nullifempty = array(
'display',
);

View File

@ -31,7 +31,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
array('strtoupper',array(':value')),
),
'host_expire'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);

View File

@ -28,10 +28,10 @@ class Model_Invoice extends ORM_OSB implements Cartable {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'due_date'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'status'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
@ -46,6 +46,10 @@ class Model_Invoice extends ORM_OSB implements Cartable {
'invoice_item'=>'service_id,item_type,date_start,date_stop',
);
protected $_compress_column = array(
'reminders',
);
private $_render = array();
// Our required Interface Methods

View File

@ -21,13 +21,13 @@ class Model_Invoice_Item extends ORM_OSB {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_start'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_stop'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);
@ -104,7 +104,7 @@ class Model_Invoice_Item extends ORM_OSB {
// Display the period that a transaction applies
public function period() {
return ($this->date_start == $this->date_stop) ? Config::date($this->date_start) : sprintf('%s -> %s',Config::date($this->date_start),Config::date($this->date_stop));
return ($this->date_start == $this->date_stop) ? Site::Date($this->date_start) : sprintf('%s -> %s',Site::Date($this->date_start),Site::Date($this->date_stop));
}
public function save(Validation $validation = NULL) {

View File

@ -23,8 +23,12 @@ class Model_Invoice_Memo extends ORM_OSB {
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);
protected $_compress_column = array(
'memo',
);
}
?>

View File

@ -10,6 +10,10 @@
* @license http://dev.osbill.net/license.html
*/
class Model_Account_Oauth extends ORM_OSB {
protected $_compress_column = array(
'oauth_data',
);
// Relationships
protected $_has_one = array(
'account' => array('foreign_key'=>'id'),

View File

@ -26,10 +26,10 @@ class Model_Payment extends ORM_OSB {
protected $_display_filters = array(
'date_orig'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_payment'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'fees_amt'=>array(
array('Currency::display',array(':value')),
@ -241,7 +241,7 @@ class Model_Payment extends ORM_OSB {
$sql .= ' GROUP BY A.id';
$sql .= ' HAVING round(A.total_amt-ALLOC,2) <> 0';
foreach ($db->query(Database::SELECT,__($sql,array(':prefix_'=>$db->table_prefix(),':site_id'=>Config::siteid()))) as $values)
foreach ($db->query(Database::SELECT,__($sql,array(':prefix_'=>$db->table_prefix(),':site_id'=>Site::ID()))) as $values)
array_push($pid,$values['id']);
return $this->where('id','IN',$pid)->order_by('account_id')->find_all();

View File

@ -37,6 +37,13 @@ class Model_Product extends ORM_OSB implements Invoicable {
protected $_form = array('id'=>'id','value'=>'description()');
protected $_compress_column = array(
'avail_category',
'group_avail',
'price_group',
'prod_plugin_data',
);
protected $_nullifempty = array(
'price_group',
);
@ -207,7 +214,7 @@ class Model_Product extends ORM_OSB implements Invoicable {
}
private function translate() {
return $this->translate->where('language_id','=',Config::language())->find();
return $this->translate->where('language_id','=',Company::instance()->language())->find();
}
/**

View File

@ -106,7 +106,7 @@ class Model_Product_Category extends ORM_OSB {
private function translate() {
return $this->translate->where('language_id','=',Config::language())->find();
return $this->translate->where('language_id','=',Company::instance()->language())->find();
}
}
?>

View File

@ -18,6 +18,10 @@ class Model_Product_Category_Translate extends ORM_OSB {
'language'=>array('foreign_key'=>'id'),
);
protected $_compress_column = array(
'description',
);
protected $_save_message = TRUE;
}
?>

View File

@ -21,6 +21,10 @@ class Model_Product_Translate extends ORM_OSB {
'language'=>array('foreign_key'=>'id'),
);
protected $_compress_column = array(
'description_full',
);
protected $_save_message = TRUE;
}
?>

View File

@ -267,18 +267,18 @@ $(document).ready(function() {
case 4:
case 5:
if ($iio->date_start != $pdata['start_time']) {
$doutput .= sprintf('%s: Set start_time: %s [%s]<br/>',$iio->id,Config::date($pdata['start_time']),$pdata['start_time']);
$doutput .= sprintf('%s: Set start_time: %s [%s]<br/>',$iio->id,Site::Date($pdata['start_time']),$pdata['start_time']);
$iio->date_start=$pdata['start_time'];
}
if (! $pr AND $iio->date_stop != $pdata['end_time']) {
$doutput .= sprintf('%s: Set end_time: %s [%s] <br/>',$iio->id,Config::date($pdata['end_time']),$pdata['end_time']);
$doutput .= sprintf('%s: Set end_time: %s [%s] <br/>',$iio->id,Site::Date($pdata['end_time']),$pdata['end_time']);
$iio->date_stop = $pdata['end_time'];
}
$bt = ($pr ? $iio->date_stop : $pdata['end_time'])+86400;
// $doutput .= sprintf('%s: BT now: %s (%s) [%s]<br/>',$iio->id,Config::date($bt),Config::date($pdata['end_time']),$bt);
// $doutput .= sprintf('%s: BT now: %s (%s) [%s]<br/>',$iio->id,Site::Date($bt),Site::Date($pdata['end_time']),$bt);
break;
default:

View File

@ -47,16 +47,16 @@ class Model_Service extends ORM_OSB {
*/
protected $_display_filters = array(
'date_start'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_end'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_last_invoice'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_next_invoice'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'external_billing'=>array(
array('StaticList_YesNo::get',array(':value',TRUE)),
@ -136,7 +136,7 @@ class Model_Service extends ORM_OSB {
// If $expire is NULL, we'll use the next invoice date
$expire = is_null($expire) ? $this->paid_to() : $expire;
return $format ? Config::date($expire) : $expire;
return $format ? Site::Date($expire) : $expire;
}
/**
@ -183,7 +183,7 @@ class Model_Service extends ORM_OSB {
$x = (! $iio->loaded() AND $this->date_next_invoice) ? $this->date_next_invoice-86400 : ($iio->total() < 0 ? $iio->date_start-86400 : $iio->date_stop);
return $format ? Config::date($x) : $x;
return $format ? Site::Date($x) : $x;
}
private function last_invoice_item() {
@ -217,7 +217,7 @@ class Model_Service extends ORM_OSB {
break;
}
return $format ? ($x ? Config::date($metric) : '&nbsp;') : ($x ? $metric : NULL);
return $format ? ($x ? Site::Date($metric) : '&nbsp;') : ($x ? $metric : NULL);
}
/**

View File

@ -23,10 +23,10 @@ class Model_Service_Change extends ORM_OSB {
*/
protected $_display_filters = array(
'date_ordered'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
'date_effective'=>array(
array('Config::date',array(':value')),
array('Site::Date',array(':value')),
),
);

View File

@ -18,12 +18,16 @@ class Model_Service_Memo extends ORM_OSB {
'account'=>array('foreign_key'=>'id'),
);
protected $_compress_column = array(
'memo',
);
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);
}

View File

@ -17,7 +17,7 @@
<div class="row">
<div class="input-append date" id="date_next_invoice_label">
<?php echo Form::input('date_next_invoice_label',Config::date(time()),array('class'=>'span2','label'=>'Date Next Invoice','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
<?php echo Form::input('date_next_invoice_label',Site::Date(time()),array('class'=>'span2','label'=>'Date Next Invoice','add-on'=>'<i class="icon-calendar"></i>','disabled')); ?>
</div>
<?php echo Form::hidden('date_next_invoice',time()); ?>

View File

@ -188,13 +188,13 @@ class SSL {
public function get_valid_to($format=FALSE) {
$k = $this->_details('validTo_time_t');
return $format ? Config::date($k) : $k;
return $format ? Site::Date($k) : $k;
}
public function get_valid_from($format=FALSE) {
$k = $this->_details('validFrom_time_t');
return $format ? Config::date($k) : $k;
return $format ? Site::Date($k) : $k;
}
public function get_version() {

View File

@ -12,7 +12,7 @@
class Model_Task extends ORM_OSB {
protected $_display_filters = array(
'date_run'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);
@ -26,7 +26,7 @@ class Model_Task extends ORM_OSB {
public function next_run($format=FALSE) {
$x = $this->_cron()->next($this->date_run);
return $format ? Config::datetime($x) : $x;
return $format ? Site::Datetime($x) : $x;
}
}
?>

View File

@ -18,9 +18,13 @@ class Model_Task_Log extends ORM_OSB {
'task'=>array(),
);
protected $_compress_column = array(
'message',
);
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
array('Site::Datetime',array(':value')),
),
);
}