Open Source Billing

This commit is contained in:
Deon George
2013-10-10 13:44:53 +11:00
commit b02d70adf0
2344 changed files with 392978 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports OSB Web Hosting
*
* @package Host
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Host_Server extends ORM_OSB {
// Host Server doesnt use the update column
protected $_updated_column = FALSE;
protected $_serialize_column = array(
'provision_plugin_data',
);
/**
* Return the object of the product plugin
*/
public function plugin($type='') {
$c = Kohana::classname('Host_Plugin_'.$this->provision_plugin);
if (! $this->provision_plugin OR ! class_exists($c))
return NULL;
$o = new $c($this);
return $type ? $o->$type : $o;
}
/**
* Enable the plugin to update
*/
public function admin_update() {
if (is_null($plugin = $this->plugin()))
return NULL;
else
return $plugin->admin_update();
}
public function manage_button($t='') {
static $k = '';
// If $k is already set, we've rendered this JS
if (! $k) {
$k = Random::char();
Session::instance()->set('manage_button',$k);
Script::add(array('type'=>'stdin','data'=>'
$(document).ready(function() {
var x=0;
$("button[name=submit]").click(function() {
var t=$(this).val().split(":");
if (x++) { alert("Session expired, please refresh the page!"); return false; }
$.getJSON("'.URL::link('admin','host/ajaxmanage/'.$this->id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
$.each(data, function(key, val) { $("#"+key+"_"+t[0]+"_"+t[1]).val(val); });
})
.error(function() { alert("There was a problem with the request"); return false; })
.success(function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
});
});'
));
}
return is_null($this->plugin()) ? '' : $this->plugin()->admin_manage_button($this,$t);
}
}
?>

View File

@@ -0,0 +1,14 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports affiliates Host Server Configuration
*
* @package Host
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Host_Server_Affiliate extends ORM_OSB {
}
?>

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Host products
*
* @package Host
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Host extends Model_Product_Plugin {
// @todo This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods
public function admin_update() {}
public function feature_summary() {}
// @todo This is not used, but should be.
public function order_features() {
}
}
?>

View File

@@ -0,0 +1,79 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Services
*
* @package Host
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Plugin_Host extends Model_Service_Plugin {
protected $_table_name = 'service__hosting';
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
protected $_serialize_column = array(
'server_data_date',
);
// Relationships
protected $_has_one = array(
'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(
'service'=>array(),
);
protected $_display_filters = array(
'domain_name'=>array(
array('strtoupper',array(':value')),
),
'host_expire'=>array(
array('Config::date',array(':value')),
),
);
// Required abstract functions
public function admin_update() {
return '';
}
public function expire() {
return $this->host_expire;
}
public function name() {
return sprintf('%s.%s',$this->display('domain_name'),$this->domain_TLD->display('name'));
}
public function service_view() {
return View::factory('service/user/plugin/host/view')
->set('so',$this);
}
public function username_value() {
return $this->host_username;
}
public function password_value() {
return $this->host_password;
}
/**
* This provides us with a manage button to jump to the hosting server
* to manage the domain.
*/
public function manage_button($t='') {
if (! parent::manage_button($t))
return NULL;
// @todo Convert this to a Static_List display
if ($this->service->queue == 'PROVISION')
return _('To Be Provisioned');
return ($this->username_value() AND $this->password_value() AND $a=$this->host_server->plugin()) ? $a->manage_button($this,$t) : '';
}
}
?>