2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports OSB Web Hosting
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Host
|
2010-11-29 22:41:08 +00:00
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2010-11-29 22:41:08 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2012-12-10 21:48:30 +00:00
|
|
|
class Model_Host_Server extends ORM_OSB {
|
2011-12-16 23:31:35 +00:00
|
|
|
// Host Server doesnt use the update column
|
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
protected $_serialize_column = array(
|
|
|
|
'provision_plugin_data',
|
|
|
|
);
|
2011-09-28 06:46:22 +00:00
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
/**
|
|
|
|
* Return the object of the product plugin
|
|
|
|
*/
|
|
|
|
public function plugin($type='') {
|
2013-03-22 20:37:04 +00:00
|
|
|
$c = Kohana::classname('Host_Plugin_'.$this->provision_plugin);
|
2011-09-28 06:46:22 +00:00
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
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();
|
2011-09-28 06:46:22 +00:00
|
|
|
}
|
2011-12-16 23:31:35 +00:00
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
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; }
|
2013-02-12 11:14:59 +00:00
|
|
|
$.getJSON("'.URL::link('admin','host/ajaxmanage/'.$this->id,TRUE).'", { k: "'.$k.'",t: t[1] }, function(data) {
|
2012-06-26 14:28:18 +00:00
|
|
|
$.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(); });
|
|
|
|
});
|
|
|
|
});'
|
|
|
|
));
|
|
|
|
}
|
2011-12-16 23:31:35 +00:00
|
|
|
|
2012-06-26 14:28:18 +00:00
|
|
|
return is_null($this->plugin()) ? '' : $this->plugin()->admin_manage_button($this,$t);
|
2011-12-16 23:31:35 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|