Added service expiry to plesk
This commit is contained in:
parent
25c73e2819
commit
dabdad9179
@ -26,6 +26,7 @@ class Controller_Task_Host extends Controller_Task {
|
||||
case 'migrate':
|
||||
case 'provision':
|
||||
case 'resetpw':
|
||||
case 'setexpire':
|
||||
$this->so = ORM::factory('service',$this->request->param('id'));
|
||||
|
||||
if (! $this->so->loaded())
|
||||
@ -265,5 +266,14 @@ class Controller_Task_Host extends Controller_Task {
|
||||
|
||||
echo _('Password Reset Success');
|
||||
}
|
||||
|
||||
public function action_setexpire() {
|
||||
if (! ($result = $this->hpo->setexpire($this->so)) OR ! $result->loaded()) {
|
||||
echo ('Unable to set expire date.');
|
||||
echo (string)$result->_xml;
|
||||
echo (string)$result->_object;
|
||||
} else
|
||||
echo (string)$result->_object;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -41,11 +41,10 @@ abstract class Host_Plugin_Plesk extends Host_Plugin {
|
||||
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$this->xml));
|
||||
$get = array_shift($a);
|
||||
|
||||
if (! $this->_loaded OR $this->_object->$key->$get->result->status->value() != 'ok' )
|
||||
return $this->_object;
|
||||
|
||||
if ($index == '_object')
|
||||
return $this->_object->$key->$get;
|
||||
return (! $this->_loaded OR $this->_object->$key->$get->result->status->value() != 'ok' ) ? $this->_object : $this->_object->$key->$get;
|
||||
elseif ($index == '_xml')
|
||||
return $this->xml;
|
||||
else
|
||||
return is_object($this->_object->$key->$get->result->$index) ? $this->_object->$key->$get->result->$index : NULL;
|
||||
}
|
||||
@ -86,14 +85,6 @@ abstract class Host_Plugin_Plesk extends Host_Plugin {
|
||||
}
|
||||
|
||||
protected function server_command(XML $xml) {
|
||||
// We need to find out the command key, so we can get the status result.
|
||||
if (count($a=array_keys($xml->packet->as_array())) != 1)
|
||||
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$xml));
|
||||
$key = array_shift($a);
|
||||
if (count($a=array_keys($xml->packet->$key->as_array())) != 1)
|
||||
throw new Kohana_Exception('XML command malformed? :xml',array(':xml'=>(string)$xml));
|
||||
$get = array_shift($a);
|
||||
|
||||
$request = Request::factory(sprintf('%s/%s',$this->hso->manage_url,$this->path))
|
||||
->method('POST');
|
||||
|
||||
|
@ -230,6 +230,24 @@ class Host_Plugin_Plesk_10 extends Host_Plugin_Plesk {
|
||||
return $this->packet->add_node($type);
|
||||
}
|
||||
|
||||
public function setexpire(Model_Service $so,$date=NULL) {
|
||||
// @todo This should be a config item
|
||||
$expbuffer = 14;
|
||||
$this->init();
|
||||
|
||||
$site = $this->packet->add_node('webspace');
|
||||
$set = $site->add_node('set');
|
||||
$filter = $set->add_node('filter');
|
||||
$filter->add_node('name',strtolower($so->plugin()->name()));
|
||||
$values = $set->add_node('values');
|
||||
$limits = $values->add_node('limits');
|
||||
$limit = $limits->add_node('limit');
|
||||
$limit->add_node('name','expiration');
|
||||
$limit->add_node('value',(is_null($date) ? $so->plugin()->host_expire+$expbuffer*86400 : $date));
|
||||
|
||||
return $this->server_command($this->xml);
|
||||
}
|
||||
|
||||
public function setpasswd(Model_Service $so,$pw) {
|
||||
$this->init();
|
||||
|
||||
|
@ -304,6 +304,24 @@ class Host_Plugin_Plesk_9 extends Host_Plugin_Plesk {
|
||||
*/
|
||||
}
|
||||
|
||||
public function setexpire(Model_Service $so,$date=NULL) {
|
||||
// @todo This should be a config item
|
||||
$expbuffer = 14;
|
||||
$this->init();
|
||||
|
||||
$domain = $this->packet->add_node('domain');
|
||||
$set = $domain->add_node('set');
|
||||
$filter = $set->add_node('filter');
|
||||
$filter->add_node('domain-name',strtolower($so->plugin()->name()));
|
||||
$values = $set->add_node('values');
|
||||
$limits = $values->add_node('limits');
|
||||
$limit = $limits->add_node('limit');
|
||||
$limit->add_node('name','expiration');
|
||||
$limit->add_node('value',(is_null($date) ? $so->plugin()->host_expire+$expbuffer*86400 : $date));
|
||||
|
||||
return $this->server_command($this->xml);
|
||||
}
|
||||
|
||||
public function setpasswd(Model_Service $so,$pw) {
|
||||
$this->init();
|
||||
|
||||
|
Reference in New Issue
Block a user