Working on HOST SERVER and improvements to ORMOSB
This commit is contained in:
@@ -14,21 +14,59 @@ class Model_Host_Server extends ORMOSB {
|
||||
// Host Server doesnt use the update column
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
public function manage_button(Model_Service_Plugin_Host $spho,$t) {
|
||||
$c = sprintf('Service_Host_%s',$this->provision_plugin);
|
||||
if (! class_exists($c))
|
||||
return '';
|
||||
protected $_serialize_column = array(
|
||||
'provision_plugin_data',
|
||||
);
|
||||
|
||||
$po = new $c($this->id);
|
||||
/**
|
||||
* Return the object of the product plugin
|
||||
*/
|
||||
public function plugin($type='') {
|
||||
$c = sprintf('Host_Plugin_%s',$this->provision_plugin);
|
||||
|
||||
return $po->manage_button($spho,$t);
|
||||
if (! $this->provision_plugin OR ! class_exists($c))
|
||||
return NULL;
|
||||
|
||||
$o = new $c($this);
|
||||
|
||||
return $type ? $o->$type : $o;
|
||||
}
|
||||
|
||||
public function prov_plugin_data() {
|
||||
if (! $this->provision_plugin_data)
|
||||
throw new Kohana_Exception('No plugin configuration data');
|
||||
/**
|
||||
* Enable the plugin to update
|
||||
*/
|
||||
public function admin_update() {
|
||||
if (is_null($plugin = $this->plugin()))
|
||||
return NULL;
|
||||
else
|
||||
return $plugin->admin_update();
|
||||
}
|
||||
|
||||
return unserialize($this->provision_plugin_data);
|
||||
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::site('admin/host/ajaxmanage/'.$this->id).'", { 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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -36,14 +36,6 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
),
|
||||
);
|
||||
|
||||
public function rules() {
|
||||
return array_merge(parent::rules(),array(
|
||||
'server_data_date'=>array(
|
||||
array('ORMOSB::serialize_array',array(':model',':field',':value')),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
// Required abstract functions
|
||||
public function admin_update() {
|
||||
return '';
|
||||
@@ -77,7 +69,7 @@ class Model_Service_Plugin_Host extends Model_Service_Plugin {
|
||||
if ($this->service->queue == 'PROVISION')
|
||||
return _('To Be Provisioned');
|
||||
|
||||
return ($this->username_value() AND $this->password_value()) ? $this->host_server->manage_button($this,$t) : '';
|
||||
return ($this->username_value() AND $this->password_value()) ? $this->host_server->plugin()->manage_button($this,$t) : '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user