Fixes to OSB to work with KH 3.3

This commit is contained in:
Deon George
2012-11-10 10:13:57 +11:00
parent ea36639638
commit 6db02ae77d
238 changed files with 813 additions and 938 deletions

View File

@@ -33,7 +33,7 @@ class ADSL {
if (preg_match('/^a:/',$data))
throw new Kohana_Exception('Data shouldnt be a serialized array');
$ao = ORM::factory('adsl_plan',$data);
$ao = ORM::factory('ADSL_Plan',$data);
$output = View::factory('adsl/contract_view')
->set('record',$ao)
->set('price_base',$price_base)

View File

@@ -13,7 +13,7 @@
class Model_ADSL_Supplier extends ORM_OSB {
// Relationships
protected $_has_many = array(
'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
'ADSL_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
);
protected $_updated_column = FALSE;
@@ -22,7 +22,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
* Return a list of plans that this supplier makes available
*/
public function plans($active=TRUE) {
$a = $this->adsl_supplier_plan;
$a = $this->ADSL_supplier_plan;
if ($active)
$a->where_active();
@@ -37,7 +37,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
$return = array();
foreach ($this->plans($active)->find_all() as $po)
foreach ($po->adsl_plan->find_all() as $apo)
foreach ($po->ADSL_plan->find_all() as $apo)
$return[$apo->id] = $apo;
return $return;
@@ -55,14 +55,14 @@ class Model_ADSL_Supplier extends ORM_OSB {
$plans = array_keys($this->adsl_plans(FALSE));
// Start with all our ADSL Plans
foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so)
foreach (ORM::factory('Service')->list_bylistgroup('ADSL') as $so)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);
// @todo poor cludge, we should find them without using list_bylistgroup()
if (! $services)
foreach (ORM::factory('service')->list_bylistgroup('HSPA') as $so)
foreach (ORM::factory('Service')->list_bylistgroup('HSPA') as $so)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);

View File

@@ -13,10 +13,10 @@
class Model_ADSL_Supplier_Plan extends ORM_OSB {
// Relationships
protected $_has_many = array(
'adsl_plan'=>array('far_key'=>'id'),
'ADSL_plan'=>array('far_key'=>'id'),
);
protected $_belongs_to = array(
'adsl_supplier'=>array('foreign_key'=>'supplier_id'),
'ADSL_supplier'=>array('foreign_key'=>'supplier_id'),
);
/**

View File

@@ -132,7 +132,7 @@ class Model_Service_Plugin_ADSL extends Model_Service_Plugin {
if (is_null($period))
$period = strtotime('yesterday');
$t = ORM::factory('service_plugin_adsl_traffic')
$t = ORM::factory('Service_Plugin_ADSL_Traffic')
->where('service','=',$this->service_username)
->and_where('date','>=',date('Y-m-d',mktime(0,0,0,date('m',$period),1,date('Y',$period))))
->and_where('date','<=',date('Y-m-d',strtotime('last day of '.date('M Y',$period))))
@@ -160,7 +160,7 @@ class Model_Service_Plugin_ADSL extends Model_Service_Plugin {
if (is_null($period))
$period = strtotime('yesterday');
$t = ORM::factory('service_plugin_adsl_traffic')
$t = ORM::factory('Service_Plugin_ADSL_Traffic')
->select(
array('date_format(date,\'%y-%m\')','month'),
array('sum(up_peak)','up_peak'),

View File

@@ -34,7 +34,7 @@ class Service_Traffic_ADSL {
// Our DB record must be the suffix of this class name
$supplier = preg_replace('/^'.get_parent_class($this).'_/','',get_class($this));
$so = ORM::factory('adsl_supplier')
$so = ORM::factory('Adsl_Supplier')
->where('name','=',$supplier)
->find();
@@ -70,7 +70,7 @@ class Service_Traffic_ADSL {
* Traffic data from supplier
*/
public function update_traffic() {
if (CLI::options('verbose'))
if (Minion_CLI::options('verbose'))
echo ' - Last: '.date('Y-m-d',strtotime($this->last_update().'+1 day'))."\n";
$alreadyrun = FALSE;
@@ -78,7 +78,7 @@ class Service_Traffic_ADSL {
$querydate<=$this->today;
$querydate=date('Y-m-d',strtotime($querydate.'+1 day'))) {
if (CLI::options('verbose'))
if (Minion_CLI::options('verbose'))
echo " - Date: $querydate\n";
$goodfetch = false;
@@ -88,7 +88,7 @@ class Service_Traffic_ADSL {
// Data returned should be in MB's
$data = $this->getdata($querydate);
if (CLI::options('verbose'))
if (Minion_CLI::options('verbose'))
print_r($data);
if (! $this->fetchresult) {
@@ -96,7 +96,7 @@ class Service_Traffic_ADSL {
break;
}
$traffic = ORM::factory('service_plugin_adsl_traffic');
$traffic = ORM::factory('Service_Plugin_Adsl_Traffic');
foreach ($data as $item) {
$traffic->values($item,array_keys($item));
$traffic->supplier_id = $this->so->id;
@@ -122,7 +122,7 @@ class Service_Traffic_ADSL {
foreach ($this->so->services() as $so) {
if ($charge = $so->plugin()->traffic_lastmonth_exceed(FALSE,$date)) {
foreach ($charge as $metric => $details) {
$co = ORM::factory('charge');
$co = ORM::factory('Charge');
$co->status = 0;
$co->sweep_type = 6;

View File

@@ -39,7 +39,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
$update = array();
foreach ($this->so->services() as $so) {
if (CLI::options('verbose'))
if (Minion_CLI::options('verbose'))
echo " = Service: ".$so->name()."\n";
if ($so->plugin()->service_stats_collect AND $so->plugin()->service_stats_lastupdate < $date) {
@@ -51,7 +51,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
->post('doLogin',1)
->post('submit','Login');
$request->get_client()->options($this->curlopts+array(
$request->client()->options($this->curlopts+array(
CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
));
@@ -87,7 +87,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
->post('end_day_search_key',date('d',strtotime($lastday)))
->post('do_usage_search',1);
$request->get_client()->options($this->curlopts+array(
$request->client()->options($this->curlopts+array(
CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
));

View File

@@ -48,7 +48,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
->post('doLogin',1)
->post('submit','Login');
$request->get_client()->options($this->curlopts+array(
$request->client()->options($this->curlopts+array(
CURLOPT_COOKIEJAR=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
));
@@ -83,7 +83,7 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
->post('end_day_search_key',date('d',strtotime($lastday)))
->post('do_usage_search',1);
$request->get_client()->options($this->curlopts+array(
$request->client()->options($this->curlopts+array(
CURLOPT_COOKIEFILE=>sprintf('/tmp/usage.cookies.%s.txt',$so->plugin()->service_number),
));

View File

@@ -27,7 +27,7 @@ class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL {
->post($this->login_pass_field,$this->so->stats_password)
->post($this->date_field,$date);
$request->get_client()->options($this->curlopts+array(
$request->client()->options($this->curlopts+array(
CURLOPT_POST => TRUE,
));

View File

@@ -19,7 +19,7 @@ class Cart {
* Return a list of items in the cart
*/
public function contents() {
return ORM::factory('cart')
return ORM::factory('Cart')
->where('session_id','=',Session::instance()->id());
}

View File

@@ -83,7 +83,7 @@ class Controller_Cart extends Controller_TemplateDefault {
* Add an item to the cart
*/
public function action_add() {
$cart = ORM::factory('cart');
$cart = ORM::factory('Cart');
$cart->session_id = Session::instance()->id();
@@ -96,13 +96,13 @@ class Controller_Cart extends Controller_TemplateDefault {
echo Kohana::debug($cart->validate()->errors());
if ($cart->saved())
Request::current()->redirect('cart/index');
HTTP::redirect('cart/index');
else
throw new Kohana_Exception(_('There was a problem adding the item to the cart.'));
}
public function action_empty() {
$cart = ORM::factory('cart')
$cart = ORM::factory('Cart')
->where('session_id','=',session_id());
$cart->delete_all();

View File

@@ -24,7 +24,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Customer Charges'),
'body'=>Table::display(
ORM::factory('charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(),
ORM::factory('Charge')->where('sweep_type','>=',0)->order_by('date_orig DESC')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/charge/view/'),
@@ -50,7 +50,7 @@ class Controller_Admin_Charge extends Controller_TemplateDefault_Admin {
public function action_add() {
$output = '';
$co = ORM::factory('charge');
$co = ORM::factory('Charge');
if ($_POST) {
// Trim down our attributes

View File

@@ -62,7 +62,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
'body'=>$output,
));
$po = ORM::factory('checkout')
$po = ORM::factory('Checkout')
->payment_options_cart();
// @todo Country value should come from somewhere?
@@ -104,7 +104,7 @@ class Controller_Checkout extends Controller_TemplateDefault {
* Process checkout
*/
private function checkout() {
$invoice = ORM::factory('invoice');
$invoice = ORM::factory('Invoice');
// Add our individual items to the invoice
foreach (Cart::instance()->contents()->find_all() as $item) {

View File

@@ -10,7 +10,7 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Domain_TLD extends ORM_OSB {
class Model_Domain_Tld extends ORM_OSB {
protected $_display_filters = array(
'name'=>array(
array('strtoupper',array(':value')),

View File

@@ -10,7 +10,7 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Domain extends Model_Product_Plugin {
class Model_Product_Plugin_DOMAIN extends Model_Product_Plugin {
// This model doesnt have a database table
public function __construct() {
}
@@ -22,7 +22,7 @@ class Model_Product_Plugin_Domain extends Model_Product_Plugin {
// @todo This is not used, but should be.
public function order_features() {
$output = '';
$t = ORM::factory('domain_tld');
$t = ORM::factory('Domain_TLD');
// @todo Change this to a view.
$output = sprintf('<table class="box-full"><tr class="head"><td>%s</td></tr><tr><td>',_('Domains are available with the following suffixes'));

View File

@@ -10,15 +10,15 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Plugin_Domain extends Model_Service_Plugin {
class Model_Service_Plugin_DOMAIN extends Model_Service_Plugin {
protected $_table_name = 'service__domain';
protected $_updated_column = FALSE;
// Relationships
protected $_has_one = array(
'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'domain_registrar'=>array('foreign_key'=>'id','far_key'=>'domain_registrar_id'),
'service_plugin_host'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'),
'service_plugin_HOST'=>array('through'=>'service','far_key'=>'service_id','foreign_key'=>'service_id'),
);
protected $_belongs_to = array(
'service'=>array(),
@@ -49,7 +49,7 @@ class Model_Service_Plugin_Domain extends Model_Service_Plugin {
}
public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name'));
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
}
public function service_name() {

View File

@@ -31,7 +31,7 @@ abstract class Service_Domain {
* Setup this class. We need to get our supplier details out of the database.
*/
public function __construct($sid) {
$this->so = ORM::factory('domain_registrar',$sid);
$this->so = ORM::factory('Domain_Registrar',$sid);
}
/**

View File

@@ -16,7 +16,7 @@ class Service_Domain_Manual extends Service_Domain {
private $login_pass_field = '';
// Our required abstract classes
public function manage_button($u,$p,$d) {
public function manage_button(Model_Service_Plugin_Domain $spdo,$t) {
return _('Please contact us');
}
}

View File

@@ -16,18 +16,18 @@ class Service_Domain_PlanetDomain extends Service_Domain {
private $login_pass_field = 'login.password';
// Our required abstract classes
public function manage_button($u,$p,$d) {
public function manage_button(Model_Service_Plugin_Domain $spdo,$t) {
$output = '';
$output .= Form::open(
sprintf('%s/%s',$this->so->whitelabel_url,'newdnr/action/user/login.jsp'),
array('target'=>'pd','method'=>'post')
array('target'=>'pd','method'=>'post','id'=>sprintf('id_%s_%s',$spdo->service_id,$t))
);
$output .= Form::input($this->login_user_field,$u,array('type'=>'hidden'));
$output .= Form::input($this->login_pass_field,$p,array('type'=>'hidden'));
$output .= Form::input($this->login_user_field,$spdo->username_value(),array('type'=>'hidden','id'=>sprintf('u_%s_%s',$spdo->service_id,$t)));
$output .= Form::input($this->login_pass_field,substr(md5($spdo->password_value()),0,8),array('type'=>'hidden','id'=>sprintf('p_%s_%s',$spdo->service_id,$t)));
$output .= Form::input('page.next',sprintf('/newdnr/action/dns/getDNSDetails.jsp?domain.name=%s',$d),array('type'=>'hidden'));
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button'));
$output .= Form::close();
$output .= Form::button('submit',_('Manage'),array('class'=>'form_button','value'=>sprintf('%s:%s',$spdo->service_id,$t)));
return $output;
}

View File

@@ -25,7 +25,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('System Emails Sent'),
'body'=>Table::display(
ORM::factory('email_log')->find_all(),
ORM::factory('Email_Log')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/email/view/'),
@@ -47,7 +47,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
* List our defined email templates
*/
public function action_templatelist() {
$eto = ORM::factory('email_template');
$eto = ORM::factory('Email_Template');
$output = '';
// @todo Change this to use Table::
@@ -68,7 +68,7 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
* Add a template
*/
public function action_templateadd() {
$eto = ORM::factory('email_template');
$eto = ORM::factory('Email_Template');
$output = '';
if ($_POST AND $eto->values($_POST)->check()) {
@@ -102,11 +102,13 @@ class Controller_Admin_Email extends Controller_TemplateDefault_Admin {
* Edit Template Definition
* @todo Change this into an add_view function like payment()
*/
public function action_templateedit($id) {
$eto = ORM::factory('email_template',$id);
public function action_templateedit() {
$id = $this->request->param('id');
$eto = ORM::factory('Email_Template',$id);
if (! $eto->loaded())
Request::current()->redirect('email/admin/template/list');
HTTP::redirect('email/admin/template/list');
$output = '';

View File

@@ -41,7 +41,7 @@ class Controller_User_Email extends Controller_TemplateDefault_User {
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$elo = ORM::factory('email_log',$id);
$elo = ORM::factory('Email_Log',$id);
if (! $elo->loaded() OR ! Auth::instance()->authorised($elo->account_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';

View File

@@ -20,7 +20,7 @@ class Email_Template {
private $components = array('subject','message_text','message_html');
public function __construct($template,$language_id=NULL) {
$this->template = ORM::factory('email_template',array('name'=>$template));
$this->template = ORM::factory('Email_Template',array('name'=>$template));
if (! $this->template->loaded())
throw new Kohana_Exception('Email template :template not defined in DB',array(':template'=>$template));
@@ -75,7 +75,7 @@ class Email_Template {
$list = array();
foreach ($this->email_data[$key]['account'] as $id) {
$ao = ORM::factory('account',$id);
$ao = ORM::factory('Account',$id);
if ($ao->loaded())
$list[$ao->email] = $ao->name();
}
@@ -111,7 +111,7 @@ class Email_Template {
public function send(array $admin=array()) {
$e = Email::connect();
$sm = Swift_Message::newInstance()
->setFrom(Kohana::config('config.email_from'));
->setFrom(Kohana::$config->load('config')->email_from);
foreach ($this->components as $component) {
if ($this->etto->loaded()) {
@@ -154,7 +154,7 @@ class Email_Template {
if ($result) {
// Store our email log.
$elo = ORM::factory('email_log');
$elo = ORM::factory('Email_Log');
foreach ($sa as $id) {
$elo->clear();

View File

@@ -21,11 +21,11 @@ class Controller_Admin_Export extends Controller_TemplateDefault_Admin {
* Add Export Maping items
*/
public function action_add() {
$eo = ORM::factory('export');
$eo = ORM::factory('Export');
$output = '';
if ($_POST AND $eo->values($_POST)->check()) {
$eo->module_id = ORM::factory('module',array('name'=>'product'))->id; // @todo This probably should be in the form.
$eo->module_id = ORM::factory('Module',array('name'=>'product'))->id; // @todo This probably should be in the form.
$eo->plugin_name = 'quicken'; // @todo This should be in the form.
// Entry updated
if (! $eo->save())

View File

@@ -24,7 +24,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate {
if (empty($_POST['plugin']))
$this->request->redirect('affiliate/export/index');
$sc = sprintf('Export_%s',$_POST['plugin']);
$sc = sprintf('Export_%s',ucfirst($_POST['plugin']));
if (! class_exists($sc))
throw new Kohana_Exception('Export Class doesnt exist for :plugin',array(':plugin'=>$_POST['plugin']));
else
@@ -43,7 +43,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate {
$TBRexportplugins = array('quicken'=>'Export to Quicken');
// @todo: Need to limit this to affiliate acounts
$p = ORM::factory('payment');
$p = ORM::factory('Payment');
if ($p->find_all()->count()) {
Block::add(array(
@@ -80,7 +80,7 @@ class Controller_Affiliate_Export extends Controller_TemplateDefault_Affiliate {
'title'=>_('No payments to export'),
'type'=>'info',
'body'=>sprintf(_('There are no payments within the last %s days (since %s) to show.'),
$daysago,date(Kohana::config('osb')->get('date_format'),$daysago*86400+time())),
$daysago,date(Kohana::$config->load('osb')->date_format,$daysago*86400+time())),
));
}
}

View File

@@ -16,7 +16,7 @@ class Export_Quicken extends Export {
$qo = new Quicken;
foreach ($_POST['id'] as $pid) {
$po = ORM::factory('payment',$pid);
$po = ORM::factory('Payment',$pid);
if ($po->loaded()) {
$invoice_ids = array();
@@ -85,9 +85,9 @@ class Export_Quicken extends Export {
$daterange = '';
if ($iio->product_id) {
$mo = ORM::factory('module',array('name'=>'product'));
$eo = ORM::factory('export')
->where('plugin_name','=',$this->plugin)
$mo = ORM::factory('Module',array('name'=>'product'));
$eo = ORM::factory('Export')
->where('plugin_name','=',strtolower($this->plugin))
->and_where('module_id','=',$mo->id)
->and_where('item_id','=',$iio->product_id)
->find();

View File

@@ -18,12 +18,12 @@ class Model_Export extends ORM_OSB {
public function list_itemsnoexport() {
$result = array();
$mo = ORM::factory('module',array('name'=>'product'));
$p = ORM::factory('product')
$mo = ORM::factory('Module',array('name'=>'product'));
$p = ORM::factory('Product')
->order_by('id');
foreach ($p->find_all() as $po)
if (! ORM::factory('export')->where('module_id','=',$mo->id)->where('item_id','=',$po->id)->find()->loaded())
if (! ORM::factory('Export')->where('module_id','=',$mo->id)->where('item_id','=',$po->id)->find()->loaded())
$result[$po->id] = $po;
return $result;

View File

@@ -19,7 +19,7 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
public function action_ajaxmanage() {
$this->auto_render = FALSE;
$hso = ORM::factory('host_server',$this->request->param('id'));
$hso = ORM::factory('Host_Server',$this->request->param('id'));
$k = Session::instance()->get_once('manage_button');
$o = array(
@@ -38,7 +38,7 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
ORM::factory('host_server')->find_all(),
ORM::factory('Host_Server')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/host/update/'),
@@ -53,11 +53,11 @@ class Controller_Admin_Host extends Controller_TemplateDefault_Admin {
}
public function action_update() {
$hso = ORM::factory('host_server',$this->request->param('id'));
$hso = ORM::factory('Host_Server',$this->request->param('id'));
$output = '';
if (! $hso->loaded())
Request::current()->redirect('welcome/index');
HTTP::redirect('welcome/index');
if ($_POST) {
$hso->values($_POST);

View File

@@ -29,7 +29,7 @@ class Controller_Task_Host extends Controller_Task {
case 'setdisablemail':
case 'setexpire':
case 'setpasswd':
$this->so = ORM::factory('service',$this->request->param('id'));
$this->so = ORM::factory('Service',$this->request->param('id'));
if (! $this->so->loaded())
throw new Kohana_Exception('Unknown service :sid',array(':sid'=>$this->request->param('id')));
@@ -138,7 +138,7 @@ class Controller_Task_Host extends Controller_Task {
list($sid,$svrs) = preg_split('/:/',$ids,2);
list($fsid,$tsid) = preg_split('/-/',$svrs,2);
$so = ORM::factory('service',$sid);
$so = ORM::factory('Service',$sid);
if (! $so->loaded())
throw new Kohana_Exception('Service :sid doesnt exist?',array(':sid'=>$sid));
@@ -154,7 +154,7 @@ class Controller_Task_Host extends Controller_Task {
throw new Kohana_Exception('Service :sid is not on server :tsid?',array(':sid'=>$sid,':tsid'=>$tsid));
// Temporarily set our host_server_id to $fsid
$hpo = ORM::factory('host_server',$fsid);
$hpo = ORM::factory('Host_Server',$fsid);
if (! $hpo->loaded())
throw new Kohana_Exception('Host server :fsid not defined?',array(':fsid'=>$fsid));
@@ -230,7 +230,7 @@ class Controller_Task_Host extends Controller_Task {
$cats = array();
if ($mode)
$cats = ORM::factory('product_category')->list_bylistgroup($mode);
$cats = ORM::factory('Product_Category')->list_bylistgroup($mode);
foreach (ORM::Factory('service')->list_provision()->find_all() as $so) {
$pc = array();

View File

@@ -88,7 +88,7 @@ abstract class Host_Plugin_Plesk extends Host_Plugin {
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
->method('POST');
$request->get_client()->options(Arr::merge($this->curlopts,array(
$request->client()->options(Arr::merge($this->curlopts,array(
CURLOPT_HTTPHEADER => array(
'HTTP_AUTH_LOGIN: '.$this->hso->manage_username,
'HTTP_AUTH_PASSWD: '.$this->hso->manage_password,

View File

@@ -110,7 +110,7 @@ class Host_Plugin_Plesk_10 extends Host_Plugin_Plesk {
$this->init();
$items = array_keys($this->_template['reseller']);
$hsao = ORM::factory('host_server_affiliate',array('affiliate_id'=>$so->affiliate_id,'host_server_id'=>$so->plugin()->host_server_id))->find();
$hsao = ORM::factory('Host_Server_Affiliate',array('affiliate_id'=>$so->affiliate_id,'host_server_id'=>$so->plugin()->host_server_id))->find();
if (! $hsao->loaded())
return NULL;

View File

@@ -10,7 +10,7 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Host extends Model_Product_Plugin {
class Model_Product_Plugin_HOST extends Model_Product_Plugin {
// @todo This model doesnt have a database table
public function __construct() {
}

View File

@@ -20,7 +20,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
// Relationships
protected $_has_one = array(
'domain_tld'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'domain_TLD'=>array('foreign_key'=>'id','far_key'=>'domain_tld_id'),
'host_server'=>array('far_key'=>'host_server_id','foreign_key'=>'id'),
);
protected $_belongs_to = array(
@@ -46,7 +46,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
}
public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_tld->display('name'));
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
}
public function service_view() {

View File

@@ -43,7 +43,7 @@ class Controller_Admin_Invoice extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('System Customer Invoices'),
'body'=>Table::display(
ORM::factory('invoice')->find_all(),
ORM::factory('Invoice')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/invoice/view/'),

View File

@@ -20,7 +20,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_list() {
$mode = $this->request->param('id');
$i = ORM::factory('invoice');
$i = ORM::factory('Invoice');
$tm = 'list_'.$mode;
if (! method_exists($i,$tm))
@@ -59,9 +59,9 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_remind_due() {
$action = array();
$key = 'remind_due';
$days = ORM::factory('invoice')->config('REMIND_DUE');
$days = ORM::factory('Invoice')->config('REMIND_DUE');
foreach (ORM::factory('invoice')->list_due(time()+86400*$days) as $io) {
foreach (ORM::factory('Invoice')->list_due(time()+86400*$days) as $io) {
// @todo Use another option to supress reminders
// If we have already sent a reminder, we'll skip to the next one.
if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1))
@@ -105,7 +105,7 @@ class Controller_Task_Invoice extends Controller_Task {
case 1:
case 2:
case 3:
$days = ORM::factory('invoice')->config('REMIND_OVERDUE_'.$notice);
$days = ORM::factory('Invoice')->config('REMIND_OVERDUE_'.$notice);
break;
default:
@@ -115,7 +115,7 @@ class Controller_Task_Invoice extends Controller_Task {
$key = 'remind_overdue_'.$notice;
foreach (ORM::factory('invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) {
foreach (ORM::factory('Invoice')->list_overdue_billing(time()-86400*$days,FALSE) as $io) {
// @todo Use another option to supress reminders
// If we have already sent a reminder, we'll skip to the next one.
if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1))
@@ -154,7 +154,7 @@ class Controller_Task_Invoice extends Controller_Task {
*/
public function action_services() {
// Used to only process X invoices in a row.
$max = ORM::factory('invoice')->config('GEN_INV_MAX');
$max = ($x=Kohana::$config->load('debug')->invoice) ? $x : ORM::factory('Invoice')->config('GEN_INV_MAX');
// Our service next billing dates that need to be updated if this is successful.
$snd = array();
// Our charges that need to be updated if this is successful.
@@ -162,7 +162,7 @@ class Controller_Task_Invoice extends Controller_Task {
// If we are invoicing a specific service
$sid = is_null($this->request->param('id')) ? NULL : explode(':',$this->request->param('id'));
// Sort our service by account_id, then we can generate 1 invoice.
$svs = ORM::factory('service')->list_invoicesoon()->as_array();
$svs = ORM::factory('Service')->list_invoicesoon()->as_array();
Sort::MAsort($svs,'account_id,date_next_invoice');
$aid = $due = $io = NULL;
@@ -186,7 +186,7 @@ class Controller_Task_Invoice extends Controller_Task {
break;
// Start a new invoice.
$io = ORM::factory('invoice');
$io = ORM::factory('Invoice');
$io->due_date = $due = $io->min_due($so->date_next_invoice);
$io->account_id = $aid = $so->account_id;
$io->status = TRUE;
@@ -210,7 +210,7 @@ class Controller_Task_Invoice extends Controller_Task {
$snd[$so->id] = $pdata['end_time']+86400;
// Check if there are any charges
$c = ORM::factory('charge')
$c = ORM::factory('Charge')
->where('service_id','=',$so->id)
->where('status','=',0)
->where('sweep_type','=',6); // @todo This needs to be dynamic, not "6"
@@ -244,7 +244,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Update our service next billing dates.
// @todo Catch any update errors
foreach ($snd as $sid=>$date) {
$so = ORM::factory('service',$sid);
$so = ORM::factory('Service',$sid);
$so->date_next_invoice = $date;
$so->save();
}
@@ -252,7 +252,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Update any processed charges as such
// @todo Catch any update errors
foreach ($chgs as $cid) {
$co = ORM::factory('charge',$cid);
$co = ORM::factory('Charge',$cid);
$co->status=1;
$co->save();
}
@@ -262,7 +262,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_send() {
// Used to only process X invoices in a row.
$max = ORM::factory('invoice')->config('EMAIL_INV_MAX');
$max = ORM::factory('Invoice')->config('EMAIL_INV_MAX');
$action = array();
$iid = $this->request->param('id');
@@ -272,7 +272,7 @@ class Controller_Task_Invoice extends Controller_Task {
list($iid,$x) = explode(':',$iid);
// Get our list of invoices to send
$i = $iid ? ORM::factory('invoice')->where('id','=',$iid) : ORM::factory('invoice')->list_tosend();
$i = $iid ? ORM::factory('Invoice')->where('id','=',$iid) : ORM::factory('Invoice')->list_tosend();
$key = 'send';
@@ -288,7 +288,7 @@ class Controller_Task_Invoice extends Controller_Task {
// Send our email
$et = Email_Template::instance('task_invoice_'.$key);
$token = ORM::factory('module_method_token')
$token = ORM::factory('Module_Method_Token')
->method(array('invoice','user_download'))
->account($io->account)
->expire(time()+86400*21)
@@ -324,7 +324,7 @@ class Controller_Task_Invoice extends Controller_Task {
public function action_audit_invoice_items() {
$output = '';
foreach (ORM::factory('invoice_item')->find_all() as $iio) {
foreach (ORM::factory('Invoice_Item')->find_all() as $iio) {
if ($iio->product_name AND $iio->product_id) {
if (md5(strtoupper($iio->product_name)) == md5(strtoupper($iio->product->name()))) {
$iio->product_name = NULL;

View File

@@ -49,7 +49,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$io = ORM::factory('invoice',$id);
$io = ORM::factory('Invoice',$id);
if (! $io->loaded() OR (! Auth::instance()->authorised($io->account_id,$io->affiliate_id) AND ! in_array($this->ao->affiliate->id,$io->service_affiliates()))) {
$this->template->content = 'Unauthorised or doesnt exist?';
@@ -123,7 +123,7 @@ class Controller_User_Invoice extends Controller_TemplateDefault_User {
* Download an invoice
*/
public function action_download() {
$io = ORM::factory('invoice',$this->request->param('id'));
$io = ORM::factory('Invoice',$this->request->param('id'));
$this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
$this->response->headers(array('Content-Type' => 'application/pdf'));

View File

@@ -87,14 +87,14 @@ SELECT i.id AS iid,i.due_date AS due FROM ab_invoice i,ab_invoice_item ii WHERE
// @todo Function Not Used
public static function balance($id) {
return ORM::factory('invoice',$id)->due();
return ORM::factory('Invoice',$id)->due();
}
/**
* Generate a PDF invoice
*/
public function pdf() {
$invoice_class = sprintf('invoice_tcpdf_%s',Kohana::config('invoice.driver'));
$invoice_class = sprintf('Invoice_TCPDF_%s',ucfirst(Kohana::$config->load('invoice')->driver));
$pdf = new $invoice_class($this->io);

View File

@@ -357,9 +357,9 @@ class Invoice_TCPDF_Default extends Invoice_TCPDF {
// Calculate our rounding error
// @todo This shouldnt be required.
$subtotal = round($subtotal-$this->io->discount_amt,Kohana::config('config.currency_format'));
$subtotal = Currency::round($subtotal-$this->io->discount_amt);
if (round($this->io->subtotal(),Kohana::config('config.currency_format')) != $subtotal) {
if (Currency::round($this->io->subtotal()) != $subtotal) {
$this->SetFont('helvetica','',9);
$this->SetX($x);
$this->Cell(0,0,'Other');

View File

@@ -377,13 +377,13 @@ class Model_Invoice extends ORM_OSB {
$c = count($this->invoice_items);
$this->invoice_items[$c] = ORM::factory('invoice_item');
$this->invoice_items[$c] = ORM::factory('Invoice_Item');
return $this->invoice_items[$c];
}
public function min_due($date) {
return strtotime(date('Y-M-d',($date < time()) ? time()+ORM::factory('invoice')->config('DUE_DAYS_MIN')*86400 : $date));
return strtotime(date('Y-M-d',($date < time()) ? time()+ORM::factory('Invoice')->config('DUE_DAYS_MIN')*86400 : $date));
}
public function save(Validation $validation = NULL) {
@@ -577,7 +577,7 @@ class Model_Invoice extends ORM_OSB {
* @todo This should be optimised a little to return only invoices to send, instead of looking for them.
*/
public function list_tosend() {
return ORM::factory('invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close();
return ORM::factory('Invoice')->where_active()->where_open()->where('print_status','is',NULL)->or_where('print_status','!=',1)->where_close();
}
public function html() {

View File

@@ -169,7 +169,7 @@ class Model_Invoice_Item extends ORM_OSB {
// Need to save the discounts associated with the invoice_item
if ($this->saved()) {
$iito = ORM::factory('invoice_item_tax');
$iito = ORM::factory('Invoice_Item_Tax');
if ($this->subitems_loaded) {
foreach (array('tax') as $i)

View File

@@ -64,7 +64,7 @@
<table class="box-full" border="0">
<?php if ($items) { ?>
<?php foreach ($io->items_services($items) as $sid => $ito) { ?>
<?php $so = ORM::factory('service',$sid); ?>
<?php $so = ORM::factory('Service',$sid); ?>
<!-- Product Information -->
<tr class="head">
<td><?php echo $so->id(); ?></td>
@@ -122,7 +122,7 @@
</tr>
<?php
foreach ($io->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid);
$m = ORM::factory('Tax',$tid);
?>
<tr>
<td>&nbsp;</td>

View File

@@ -189,7 +189,7 @@
<td class="head" colspan="4">Taxes Included:</td>
</tr>
<?php foreach ($io->tax_summary() as $tid => $amount) {
$m = ORM::factory('tax',$tid); ?>
$m = ORM::factory('Tax',$tid); ?>
<tr>
<td>&nbsp;</td>
<td><?php echo $m->description; ?></td>

View File

@@ -24,8 +24,8 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
$return = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$return += ORM::factory('account')->list_autocomplete($_REQUEST['term']);
$return += ORM::factory('invoice')->list_autocomplete($_REQUEST['term'],'account_id');
$return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
$return += ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'account_id');
}
$this->auto_render = FALSE;
@@ -44,7 +44,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
$i = 0;
$list = array();
if (isset($_REQUEST['pid']))
foreach (ORM::factory('payment',$_REQUEST['pid'])->items() as $pio) {
foreach (ORM::factory('Payment',$_REQUEST['pid'])->items() as $pio) {
$output .= View::factory($this->viewpath().'/body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',$pio)
@@ -54,12 +54,12 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
array_push($list,$pio->invoice_id);
}
foreach (ORM::factory('account',$_REQUEST['key'])->invoices_due() as $io)
foreach (ORM::factory('Account',$_REQUEST['key'])->invoices_due() as $io)
// Only list invoices not yet listed
if (! in_array($io->id,$list))
$output .= View::factory($this->viewpath().'/body')
->set('trc',$i++%2 ? 'odd' : 'even')
->set('pio',ORM::factory('payment_item'))
->set('pio',ORM::factory('Payment_Item'))
->set('io',$io);
// @todo Need the JS to add up the payment allocation before submission
@@ -76,7 +76,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Customer Payments'),
'body'=>Table::display(
ORM::factory('payment')->find_all(),
ORM::factory('Payment')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/payment/view/'),
@@ -97,7 +97,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
}
private function add_view($id=NULL,$output='') {
$po = ORM::factory('payment',$id);
$po = ORM::factory('Payment',$id);
if ($_POST) {
// Update our invoice payment items
@@ -210,7 +210,7 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
$output = '';
if ($_POST AND isset($_POST['payer'])) {
$c = sprintf('payment_bulk_%s',$_POST['payer']);
$c = sprintf('Payment_Bulk_%s',ucfirst($_POST['payer']));
$o = new $c();
if (! $_FILES) {

View File

@@ -64,7 +64,7 @@ class Model_Payment extends ORM_OSB {
// New Item
$c = count($this->payment_items);
$this->payment_items[$c] = ORM::factory('payment_item');
$this->payment_items[$c] = ORM::factory('Payment_Item');
$this->payment_items[$c]->invoice_id = $iid;
return $this->payment_items[$c];
@@ -76,7 +76,7 @@ class Model_Payment extends ORM_OSB {
* @param int $start List payments that were modified this many days ago
*/
public function export($start) {
return ORM::factory('payment')
return ORM::factory('Payment')
->where('date_payment','>=',time()-$start*86400)
->find_all();
}
@@ -165,9 +165,9 @@ class Model_Payment extends ORM_OSB {
foreach ($items as $pio) {
// Only need to check items that ave actually changed.
if ($pio->changed()) {
$old_pio = ORM::factory('payment_item',$pio->id);
$old_pio = ORM::factory('Payment_Item',$pio->id);
if (($it = $pio->invoice->due()+ORM::factory('payment_item',$pio->id)->alloc_amt-$pio->alloc_amt) < 0)
if (($it = $pio->invoice->due()+ORM::factory('Payment_Item',$pio->id)->alloc_amt-$pio->alloc_amt) < 0)
$msg .= ($msg ? ' ' : '').sprintf('Invoice %s over allocated by %3.2f.',$pio->invoice_id,$it);
}

View File

@@ -44,7 +44,7 @@ class Payment_Bulk_Ezypay {
if (preg_match('/^'.Config::siteid(TRUE).'-/',$array[4]) AND $array[10] == 'Cleared') {
$aid = preg_replace('/^'.Config::siteid(TRUE).'-/','',$array[4]);
$po = ORM::factory('payment');
$po = ORM::factory('Payment');
$po->account_id = $aid;
$po->total_amt = $array[7];
$po->notes = $array[2].':'.$array[3];
@@ -85,7 +85,7 @@ class Payment_Bulk_Ezypay {
}
$return = '';
$return .= View::Factory('payment/admin/addbulk/ezypay/head');
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/head');
$total = $fees = 0;
foreach ($payments as $po) {
@@ -94,11 +94,11 @@ class Payment_Bulk_Ezypay {
$total += $po->total_amt;
$fees += $po->fees_amt;
$return .= View::Factory('payment/admin/addbulk/ezypay/body')
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/body')
->set('o',$po);
}
$return .= View::Factory('payment/admin/addbulk/ezypay/foot')
$return .= View::Factory('Payment/Admin/Addbulk/Ezypay/foot')
->set('total',$total)
->set('fees',$fees);;

View File

@@ -21,7 +21,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
public function action_ajaxtranslateform() {
$this->auto_render = FALSE;
$po = ORM::factory('product',$this->request->param('id'));
$po = ORM::factory('Product',$this->request->param('id'));
if (! $this->request->is_ajax() OR ! $po->loaded() OR ! isset($_REQUEST['key']))
$this->response->body(_('Unable to find translate data'));
@@ -39,9 +39,9 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
*/
public function action_list() {
if ($this->request->param('id'))
$prods = ORM::factory('product')->list_category($this->request->param('id'),FALSE);
$prods = ORM::factory('Product')->list_category($this->request->param('id'),FALSE);
else
$prods = ORM::factory('product')->order_by('status DESC,prod_plugin_file')->find_all();
$prods = ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();
Block::add(array(
'title'=>_('Customer Products'),
@@ -72,13 +72,13 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
* Edit a product configuration
*/
public function action_update() {
$po = ORM::factory('product',$this->request->param('id'));
$po = ORM::factory('Product',$this->request->param('id'));
if (! $po->loaded())
Request::current()->redirect('welcome/index');
HTTP::redirect('welcome/index');
if ($_POST) {
if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('product_translate',$_POST['product_translate']['id'])) AND $pto->loaded())
if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('Product_Translate',$_POST['product_translate']['id'])) AND $pto->loaded())
if (! $pto->values($_POST['product_translate'])->save())
throw new Kohana_Exception('Failed to save updates to product_translate data for record :record',array(':record'=>$po->id()));
@@ -118,12 +118,12 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
}
public function action_view() {
$po = ORM::factory('product',$this->request->param('id'));
$po = ORM::factory('Product',$this->request->param('id'));
Block::add(array(
'title'=>sprintf('%s: %s',_('Current Services Using this Product'),$po->name()),
'body'=>Table::display(
ORM::factory('service')->where('product_id','=',$po->id)->find_all(),
ORM::factory('Service')->where('product_id','=',$po->id)->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),

View File

@@ -15,7 +15,7 @@ class Controller_Product extends Controller_TemplateDefault {
$output = '<div id="category">';
$output .= '<ul>';
foreach (ORM::factory('product_category')->list_active() as $pco) {
foreach (ORM::factory('Product_Category')->list_active() as $pco) {
$a = '<h3>'.$pco->display('name').'</h3>';
$a .= '<p>'.$pco->description().'</p>';
@@ -35,15 +35,17 @@ class Controller_Product extends Controller_TemplateDefault {
* @todo Only show categories according to their validity dates
* @todo Obey sort order
*/
public function action_category($id) {
$cat = ORM::factory('product_category',$id);
public function action_category() {
$id = $this->request->param('id');
$cat = ORM::factory('Product_Category',$id);
if (! $cat->loaded())
Request::current()->redirect('welcome/index');
HTTP::redirect('welcome/index');
Breadcrumb::name($this->request->uri(),$cat->name);
Breadcrumb::url('product','product/categorys');
Breadcrumb::url('product/category','product/categorys');
BreadCrumb::name($this->request->uri(),$cat->name);
BreadCrumb::url('product','product/categorys');
BreadCrumb::url('product/category','product/categorys');
Block::add(array(
'title'=>sprintf('%s: %s',_('Category'),$cat->name),
@@ -57,31 +59,33 @@ class Controller_Product extends Controller_TemplateDefault {
* Obtain a list of pages in a category
*/
private function _get_category($id) {
return ORM::factory('product')->list_category($id);
return ORM::factory('Product')->list_category($id);
}
/**
* Show a product
*/
public function action_view($id) {
$po = ORM::factory('product',$id);
public function action_view() {
$id = $this->request->param('id');
$po = ORM::factory('Product',$id);
if (! $po->loaded())
Request::current()->redirect('product_category/index');
HTTP::redirect('Product_Category/index');
Breadcrumb::name($this->request->uri(),$po->product_translate->find()->name);
Breadcrumb::url('product','product/categorys');
BreadCrumb::name($this->request->uri(),$po->product_translate->find()->name);
BreadCrumb::url('product','product/categorys');
// Work out our category id for the control line
if (! empty($_GET['cid'])) {
$co = ORM::factory('product_category',$_GET['cid']);
$co = ORM::factory('Product_Category',$_GET['cid']);
// If the product category doesnt exist, or doesnt match the product
if (! $co->loaded() OR ! in_array($co->id,unserialize($po->avail_category)))
Request::current()->redirect('product_category/index');
HTTP::redirect('Product_Category/index');
Breadcrumb::name('product/view',$co->name);
Breadcrumb::url('product/view','product/category/'.$co->id);
BreadCrumb::name('product/view',$co->name);
BreadCrumb::url('product/view','product/category/'.$co->id);
}
Block::add(array(

View File

@@ -15,7 +15,7 @@ class Controller_Product_Category extends Controller_TemplateDefault {
* By default show a menu of available categories
*/
public function action_index() {
Request::current()->redirect('product_category/list');
HTTP::redirect('product_category/list');
}
public function action_list() {
@@ -33,7 +33,7 @@ class Controller_Product_Category extends Controller_TemplateDefault {
* @todo Move this to the model
*/
private function _get_categories() {
return ORM::factory('product_category')
return ORM::factory('Product_Category')
->list_active();
}
}

View File

@@ -56,7 +56,7 @@ class Model_Product extends ORM_OSB {
if (! is_numeric($this->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file));
return ORM::factory(sprintf('product_plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
return ORM::factory(sprintf('Product_Plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
}
/**

View File

@@ -27,7 +27,7 @@
<?php foreach ($po->availPriceGroups() as $g) { ?>
<?php foreach ($po->availPriceOptions() as $o) { ?>
<tr>
<td><?php echo ORM::factory('group',$g)->name; ?></td>
<td><?php echo ORM::factory('Group',$g)->name; ?></td>
<td><?php echo $o; ?></td>
<?php foreach (StaticList_RecurSchedule::keys() as $k) { ?>
<td colspan="2"><?php echo Form::input("price_group[$k][$g][$o]",$po->price($g,$k,$o),array('size'=>5)); ?></td>
@@ -48,7 +48,7 @@
</tr>
<tr>
<td>Product Descriptions</td>
<td><?php echo Form::select('language_id',ORM_OSB::form('language',TRUE)); ?></td>
<td><?php echo Form::select('language_id',ORM_OSB::form('Language',TRUE)); ?></td>
</tr>
<tr>
<td>&nbsp;</td>

View File

@@ -36,7 +36,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_ajaxlist() {
$return = array();
$return += ORM::factory('service')->list_autocomplete(
$return += ORM::factory('Service')->list_autocomplete(
isset($_REQUEST['term']) ? $_REQUEST['term'] : '',
'id',
isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array());
@@ -48,7 +48,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_ajaxjson_traffic() {
$return = array();
$svs = ORM::factory('service')->list_bylistgroup('ADSL');
$svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('ComboChart');
@@ -70,7 +70,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
ORM::factory('service')->find_all(),
ORM::factory('Service')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
@@ -95,9 +95,9 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_listbycheckout() {
$svs = array();
// @todo This needs to be configurable
$go = ORM::factory('group',array('name'=>'Personal'));
$go = ORM::factory('Group',array('name'=>'Personal'));
foreach (ORM::factory('account')->list_active() as $ao)
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($ao->service->list_active() as $so)
if (! $so->service_billing->checkout_plugin_id)
@@ -127,7 +127,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
)),
));
foreach (ORM::factory('checkout')->list_active() as $co) {
foreach (ORM::factory('Checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
@@ -194,7 +194,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listadslservices() {
$svs = ORM::factory('service')->list_bylistgroup('ADSL');
$svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('ComboChart')
@@ -238,7 +238,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
* Show a list of services that are expiring or have expired
*/
public function action_listexpiring() {
$svs = ORM::factory('service')->list_expiring();
$svs = ORM::factory('Service')->list_expiring();
Sort::MAsort($svs,'expire()');
@@ -261,7 +261,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listhspaservices() {
$svs = ORM::factory('service')->list_bylistgroup('HSPA');
$svs = ORM::factory('Service')->list_bylistgroup('HSPA');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
@@ -302,7 +302,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listdomainservices() {
$svs = ORM::factory('service')->list_bylistgroup('DOMAIN');
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'name()');
Block::add(array(
@@ -329,7 +329,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listdomainservicesbysupplier() {
$svs = ORM::factory('service')->list_bylistgroup('DOMAIN');
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->domain_registrar_id,name()');
$list = array();
@@ -362,13 +362,13 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listdomainservicesbydnshost() {
$svs = ORM::factory('service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->service_plugin_host,name()');
$svs = ORM::factory('Service')->list_bylistgroup('DOMAIN');
Sort::MAsort($svs,'plugin()->service_plugin_HOST,name()');
$list = array();
foreach ($svs as $so)
$list[$so->plugin()->service_plugin_host->host_server_id][] = $so;
$list[$so->plugin()->service_plugin_HOST->host_server_id][] = $so;
foreach (array_keys($list) as $sid)
Block::add(array(
@@ -392,7 +392,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listhostservices() {
$svs = ORM::factory('service')->list_bylistgroup('HOST');
$svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'name()');
Block::add(array(
@@ -419,7 +419,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listhostservicesbysupplier() {
$svs = ORM::factory('service')->list_bylistgroup('HOST');
$svs = ORM::factory('Service')->list_bylistgroup('HOST');
Sort::MAsort($svs,'plugin()->host_server,name()');
$list = array();
@@ -452,7 +452,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
public function action_listwebservices() {
$svs = ORM::factory('service')->list_bylistgroup('WEB');
$svs = ORM::factory('Service')->list_bylistgroup('WEB');
Sort::MAsort($svs,'name()');
Block::add(array(
@@ -482,8 +482,10 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
*
* @todo this should really be in a different class, since adsl wont be part of the main app
*/
public function action_listadslbilling($id) {
$aso = ORM::factory('adsl_supplier',$id);
public function action_listadslbilling() {
$id = $this->request->param('id');
$aso = ORM::factory('ADSL_Supplier',$id);
// Process upload
// @todo This should be separated out by supplier in case each supplier has a different format
@@ -646,7 +648,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('Services to Invoice'),
'body'=>Table::display(
ORM::factory('service')->list_invoicesoon(ORM::factory('invoice')->config('GEN_SOON_DAYS')),
ORM::factory('Service')->list_invoicesoon(ORM::factory('Invoice')->config('GEN_SOON_DAYS')),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
@@ -669,10 +671,10 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_update() {
$id = $this->request->param('id');
$so = ORM::factory('service',$id);
$so = ORM::factory('Service',$id);
if (! $so->loaded())
Request::current()->redirect('welcome/index');
HTTP::redirect('welcome/index');
if ($_POST) {
if (isset($_POST['plugin']) AND $_POST['plugin'])
@@ -717,7 +719,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$so = ORM::factory('service',$id);
$so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';
@@ -781,7 +783,8 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
}
if (isset($_REQUEST['go']))
$this->request->redirect('admin/service/view/'.$so->id);
HTTP::redirect('admin/service/view/'.$so->id);
Block::add(array(
'title'=>sprintf('Transaction History for %s: %s',$so->id(),$so->name()),
'body'=>$loutput,
@@ -803,7 +806,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
public function action_adslstat() {
$output = '';
$svs = ORM::factory('service')->list_bylistgroup('ADSL');
$svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$stats = array();
// @todo This needs to be configurable.
$traffic = array(1000,2000,5000,10000,25000,50000,75000,100000);

View File

@@ -27,7 +27,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Customer Services'),
'body'=>Table::display(
$this->filter(ORM::factory('service')->list_active(),$this->ao->affiliate->id),
$this->filter(ORM::factory('Service')->list_active(),$this->ao->affiliate->id),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
@@ -52,9 +52,9 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
public function action_listbycheckout() {
$svs = array();
// @todo This needs to be configurable
$go = ORM::factory('group',array('name'=>'Personal'));
$go = ORM::factory('Group',array('name'=>'Personal'));
foreach (ORM::factory('account')->list_active() as $ao)
foreach (ORM::factory('Account')->list_active() as $ao)
if ($ao->has_any('group',array($go)))
foreach ($this->filter($ao->service->list_active(),$this->ao->affiliate->id,'name()') as $so)
if (! $so->service_billing->checkout_plugin_id)
@@ -89,7 +89,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
'body'=>_('None found'),
));
foreach (ORM::factory('checkout')->list_active() as $co) {
foreach (ORM::factory('Checkout')->list_active() as $co) {
$svs = array();
foreach ($co->account->find_all() as $ao)
@@ -156,7 +156,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
}
public function action_listadslservices() {
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()');
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('ADSL'),$this->ao->affiliate->id,'name()');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
@@ -197,7 +197,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
}
public function action_listhspaservices() {
$svs = $this->filter(ORM::factory('service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()');
$svs = $this->filter(ORM::factory('Service')->list_bylistgroup('HSPA'),$this->ao->affiliate->id,'name()');
$data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('Legacy')
@@ -241,7 +241,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Domain Names'),
'body'=>Table::display(
$this->filter(ORM::factory('service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'),
$this->filter(ORM::factory('Service')->list_bylistgroup('DOMAIN'),$this->ao->affiliate->id,'name()'),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),
@@ -265,7 +265,7 @@ class Controller_Affiliate_Service extends Controller_TemplateDefault_Affiliate
Block::add(array(
'title'=>_('Hosting Services'),
'body'=>Table::display(
$this->filter(ORM::factory('service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'),
$this->filter(ORM::factory('Service')->list_bylistgroup('HOST'),$this->ao->affiliate->id,'name()'),
25,
array(
'id'=>array('label'=>'ID','url'=>'user/service/view/'),

View File

@@ -12,7 +12,7 @@
*/
class Controller_Task_Service extends Controller_Task {
private function _traffic_suppliers($active=FALSE) {
$suppliers = ORM::factory('adsl_supplier');
$suppliers = ORM::factory('Adsl_Supplier');
return $active ? $suppliers->list_active() : $suppliers->find_all();
}
@@ -22,7 +22,7 @@ class Controller_Task_Service extends Controller_Task {
*/
public function action_gettraffic() {
foreach ($this->_traffic_suppliers(TRUE) as $aso) {
if (CLI::options('verbose'))
if (Minion_CLI::options('verbose'))
echo $aso->name."\n";
$traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic();

View File

@@ -20,7 +20,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
public function action_ajaxmanage() {
$this->auto_render = FALSE;
$so = ORM::factory('service',$this->request->param('id'));
$so = ORM::factory('Service',$this->request->param('id'));
$k = Session::instance()->get_once('manage_button');
$amo = $so->plugin(isset($_REQUEST['t']) ? $_REQUEST['t'] : '');
@@ -60,7 +60,7 @@ class Controller_User_Service extends Controller_TemplateDefault_User {
public function action_view() {
list($id,$output) = Table::page(__METHOD__);
$so = ORM::factory('service',$id);
$so = ORM::factory('Service',$id);
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
$this->template->content = 'Unauthorised or doesnt exist?';

View File

@@ -56,7 +56,7 @@ class Model_Service extends ORM_OSB {
if (! is_numeric($this->product->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->product->id,':type'=>$this->product->prod_plugin_file));
$o = ORM::factory(sprintf('service_plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id));
$o = ORM::factory(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id));
return $type ? $o->$type : $o;
}
@@ -208,7 +208,7 @@ class Model_Service extends ORM_OSB {
public function list_bylistgroup($cat) {
$result = array();
$cats = ORM::factory('product_category')->list_bylistgroup($cat);
$cats = ORM::factory('Product_Category')->list_bylistgroup($cat);
foreach ($this->list_active() as $so) {
if (! $so->product->avail_category OR ! preg_match('/^a:/',$so->product->avail_category))
@@ -256,7 +256,7 @@ class Model_Service extends ORM_OSB {
public function list_invoicesoon($days=0) {
return $this->_where_active()
->where_open()->where('suspend_billing','IS',NULL)->or_where('suspend_billing','=','0')->where_close()
->where('date_next_invoice','<',time()+(ORM::factory('invoice')->config('GEN_DAYS')+$days)*86400)
->where('date_next_invoice','<',time()+(ORM::factory('Invoice')->config('GEN_DAYS')+$days)*86400)
->find_all();
}

View File

@@ -21,7 +21,7 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
Block::add(array(
'title'=>_('SSL CA Certificates'),
'body'=>Table::display(
ORM::factory('ssl_ca')->find_all(),
ORM::factory('SSL_CA')->find_all(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/ssl/view/'),
@@ -38,7 +38,7 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
}
private function add_view($id=NULL,$output='') {
$so = ORM::factory('ssl_ca',$id);
$so = ORM::factory('SSL_CA',$id);
if ($_POST) {
if ($so->values($_POST)->changed()) {
@@ -84,14 +84,14 @@ class Controller_Admin_SSL extends Controller_TemplateDefault_Admin {
list($id,$output) = Table::page(__METHOD__);
Block::add(array(
'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('ssl_ca',$id)->display('sign_cert')),
'title'=>sprintf('%s: %s (%s)',_('View SSL CA Certificate'),$id,ORM::factory('SSL_CA',$id)->display('sign_cert')),
'body'=>$this->add_view($id,$output),
));
Block::add(array(
'title'=>_('Services using this Certificate'),
'body'=>Table::display(
ORM::factory('ssl_ca',$id)->list_issued(),
ORM::factory('SSL_CA',$id)->list_issued(),
25,
array(
'id'=>array('label'=>'ID','url'=>'admin/service/view/'),

View File

@@ -17,20 +17,20 @@ class Controller_User_SSL extends Controller_TemplateDefault_User {
public function action_download() {
$id = $_POST['sid'];
$so = ORM::factory('service',$id);
$so = ORM::factory('Service',$id);
if (! $so->loaded())
Request::current()->redirect('welcome/index');
HTTP::redirect('welcome/index');
$passwd = $_POST['passwd'];
if (strlen($passwd) < Kohana::config('ssl.minpass_length')) {
if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
SystemMessage::add(array(
'title'=>_('Validation failed'),
'type'=>'error',
'body'=>_('Your requested password is too short.'),
));
Request::current()->redirect('user/service/view/'.$so->id);
HTTP::redirect('user/service/view/'.$so->id);
}
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id,$so->affiliate_id)) {
@@ -38,7 +38,7 @@ class Controller_User_SSL extends Controller_TemplateDefault_User {
return FALSE;
}
$file = Kohana::config('config.tmpdir').'/'.$so->name().'.pkcs12';
$file = sprintf('%s/%s.pkcs12',Kohana::$config->load('config')->tmpdir,$so->name());
openssl_pkcs12_export_to_file($so->plugin()->cert,$file,$so->plugin()->pk,$passwd,array('extracerts'=>$so->plugin()->cacerts()));
$x = file_get_contents($file);
unlink($file);

View File

@@ -19,7 +19,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
'service'=>array(),
);
protected $_has_one = array(
'ssl_ca'=>array('far_key'=>'ssl_ca_id','foreign_key'=>'id'),
'SSL_CA'=>array('far_key'=>'ssl_ca_id','foreign_key'=>'id'),
);
protected $_display_filters = array(
@@ -74,7 +74,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
}
public function name() {
return ($this->cert) ? sprintf('%s:%s',$this->ssl_ca->subject(),$this->display('cert')) : $this->display('csr');
return ($this->cert AND $this->SSL_CA->loaded()) ? sprintf('%s:%s',$this->SSL_CA->subject(),$this->display('cert')) : $this->display('csr');
}
public function service_view() {
@@ -124,7 +124,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
$x = $this->ssl_ca_id;
while ($x) {
$sco = ORM::factory('ssl_ca',$x);
$sco = ORM::factory('SSL_CA',$x);
array_push($return,$sco->sign_cert);
$x = $sco->parent_ssl_ca_id;
}
@@ -134,7 +134,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
public function renew() {
$d = SSL::details($this->cert);
$ssl_conf = Kohana::config('ssl');
$ssl_conf = Kohana::$config->load('ssl');
// @todo change this so an admin can force this.
$force = TRUE;
@@ -142,7 +142,7 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
if ($d['validTo_time_t'] > time()+$ssl_conf['min_renew_days']*86400 AND ! $force)
return FALSE;
$res = openssl_csr_sign($this->csr,$this->ssl_ca->sign_cert,$this->ssl_ca->sign_pk,$this->service->product->plugin()->days,array(
$res = openssl_csr_sign($this->csr,$this->SSL_CA->sign_cert,$this->SSL_CA->sign_pk,$this->service->product->plugin()->days,array(
'config'=>$ssl_conf['config'],
'x509_extensions'=>$this->service->product->plugin()->extensions,
'digest_alg'=>'sha1',
@@ -156,8 +156,8 @@ class Model_Service_Plugin_SSL extends Model_Service_Plugin {
} else {
print_r(array(
'csr'=>$this->csr,
'ca'=>$this->ssl_ca->sign_cert,
'capk'=>$this->ssl_ca->sign_pk,
'ca'=>$this->SSL_CA->sign_cert,
'capk'=>$this->SSL_CA->sign_pk,
'days'=>$this->service->product->plugin()->days,
'ssl'=>$ssl_conf,
'x509e'=>$this->service->product->plugin()->extensions

View File

@@ -202,10 +202,6 @@ class SSL {
return $this->_details('version');
}
public static function xdn($cert) {
return static::instance($cert)->get_dn();
}
public static function xexpire($cert,$format=FALSE) {
return static::instance($cert)->get_expire($format);
}

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