Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Some fixes
  • Loading branch information
Diego committed Nov 21, 2016
commit 115965d468f8c1d4e0442dc397a7fe01598a7a18
2 changes: 0 additions & 2 deletions examples/Subscriptions/get_subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/
$params = array(
'subscription_id'=>'1',
//'name'=>'example.com',
//'username'=>'',
);

$request = new \pmill\Plesk\GetSubscription($config, $params);
Expand Down
1 change: 0 additions & 1 deletion src/pmill/Plesk/ApiRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function __construct($errorNode, $code = 0)
$message = isset($errorNode->errtext) ? (string)$errorNode->errtext : '';
$code = isset($errorNode->errcode) ? (int)$errorNode->errcode : '';
}

parent::__construct($message, $code);
}
}
1 change: 0 additions & 1 deletion src/pmill/Plesk/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ public function process()
$this->error = $e;
throw new ApiRequestException($e->getMessage(), $e->getCode());
}

}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pmill/Plesk/CreateDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ protected function processResponse($xml)
$this->id = (int)$xml->database->{'add-db'}->result->id;
return true;
}
}
}
22 changes: 18 additions & 4 deletions src/pmill/Plesk/DeleteDatabaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class DeleteDatabaseUser extends BaseRequest
<database>
<del-db-user>
<filter>
<id>{ID}</id>
<db-id>{DATABASE_ID}</db-id>
{FILTER}
</filter>
</del-db-user>
</database>
Expand All @@ -24,10 +23,25 @@ class DeleteDatabaseUser extends BaseRequest
* @var array
*/
protected $default_params = [
'id' => null,
'database_id' => null,
'filter' => null,
];

/**
* @param array $config
* @param array $params
* @throws ApiRequestException
*/
public function __construct($config, $params = [])
{
if (isset($params['id'])) {
$params['filter'] = new Node('id', $params['id']);
}
else if (isset($params['database_id'])) {
$params['filter'] = new Node('db-id', $params['database_id']);
}
parent::__construct($config, $params);
}

/**
* @param $xml
* @return bool
Expand Down
21 changes: 12 additions & 9 deletions src/pmill/Plesk/GetDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GetDatabase extends BaseRequest
<database>
<get-db>
<filter>
<id>{ID}</id>
<webspace-id>{SUBSCRIPTION_ID}</webspace-id>
</filter>
</get-db>
</database>
Expand All @@ -32,20 +32,23 @@ class GetDatabase extends BaseRequest
*/
protected function processResponse($xml)
{
$db = $xml->db->{'get-db'}->result;
if ((string)$db->status == 'error') {
throw new ApiRequestException($db);
}
if ((string)$db->result->status == 'error') {
throw new ApiRequestException($db->result);
}
return [

$db = $xml->database->{'get-db'}->result;
if ((string)$db->status == 'error') {
throw new ApiRequestException($db);
}
if ((string)$db->result->status == 'error') {
throw new ApiRequestException($db->result);
}

return [
'status' => (string)$node->status,
'id' => (int)$node->id,
'name' => (string)$node->name,
'subscription_id' => (int)$node->{'webspace-id'},
'db_server_id' => (int)$node->{'db-server-id'},
'default_user_id' => (int)$node->{'default-user-id'},
];

}
}
6 changes: 3 additions & 3 deletions src/pmill/Plesk/GetDatabaseServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ protected function processResponse($xml)

$db_server = $xml->db_server->{'get-local'}->result;
return [
'id' => (int)$db_sever->id,
'status' => (string)$db_sever->status,
'type' => (string)$db_server->type,
'id' => (int)$db_server->id,
'status' => (string)$db_server->status,
'type' => (string)$db_server->type,
];
}

Expand Down
7 changes: 1 addition & 6 deletions src/pmill/Plesk/GetDatabaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GetDatabaseUser extends BaseRequest
*/
public $xml_packet = <<<EOT
<?xml version="1.0"?>
<packet version="1.4.2.0">
<packet version="1.6.7.0">
<database>
<get-db-users>
<filter>
Expand All @@ -19,11 +19,6 @@ class GetDatabaseUser extends BaseRequest
</packet>
EOT;

/**
* @var int
*/
public $id;

/**
* @var array
*/
Expand Down
5 changes: 0 additions & 5 deletions src/pmill/Plesk/GetDefaultDatabaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class GetDefaultDatabaseUser extends BaseRequest
</packet>
EOT;

/**
* @var int
*/
public $id;

/**
* @var array
*/
Expand Down
2 changes: 1 addition & 1 deletion src/pmill/Plesk/GetSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function processResponse($xml)
$webspace = $xml->webspace->get->result[$i];

if ($webspace->status == 'error') {
throw new ApiRequestException($webspace);
throw new ApiRequestException($webspace);
}

$hosting = [];
Expand Down
22 changes: 11 additions & 11 deletions src/pmill/Plesk/GetUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class GetUser extends BaseRequest
<?xml version="1.0"?>
<packet version="1.6.7.0">
<user>
<get>
<filter>
<guid>{GUID}</guid>
</filter>
<dataset>
<gen-info/>
<roles/>
</dataset>
</get>
</customer>
<get>
<filter>
<guid>{GUID}</guid>
</filter>
<dataset>
<gen-info/>
<roles/>
</dataset>
</get>
</user>
</packet>
EOT;

Expand All @@ -35,7 +35,7 @@ class GetUser extends BaseRequest
* @param array $config
* @param array $params
*/
public function __construct(array $config, $params = [])
public function __construct(array $config, $params)
{
if (isset($params['username'])) {
$request = new ListUsers($config);
Expand Down
29 changes: 14 additions & 15 deletions src/pmill/Plesk/ListDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ class ListDatabases extends BaseRequest
* @param array $config
* @param array $params
* @throws ApiRequestException
* */
public function __construct(array $config, $params = [])
{
$this->default_params['filter'] = new Node('filter');
if (isset($params['subscription_id'])) {
$webspaceIdNode = new Node('webspace-id', $params['subscription_id']);
$params['filter'] = new Node('filter', $webspaceIdNode);
}
if (isset($params['subscription_id'])) {
$webspaceNameNode = new Node('webspace-name', $params['subscription_name']);
$params['filter'] = new Node('filter', $webspaceNameNode);
}
parent::__construct($config, $params);
}
*/
public function __construct(array $config, $params = [])
{
$this->default_params['filter'] = new Node('filter');
if (isset($params['subscription_id'])) {
$webspaceIdNode = new Node('webspace-id', $params['subscription_id']);
$params['filter'] = new Node('filter', $webspaceIdNode);
}
if (isset($params['subscription_id'])) {
$webspaceNameNode = new Node('webspace-name', $params['subscription_name']);
$params['filter'] = new Node('filter', $webspaceNameNode);
}
parent::__construct($config, $params);
}

/**
* @param $xml
Expand All @@ -50,7 +50,6 @@ public function __construct(array $config, $params = [])
protected function processResponse($xml)
{
$result = [];

foreach ($xml->database->{'get-db'}->children() as $node) {
if (isset($node->id)){
$result[] = [
Expand Down
22 changes: 11 additions & 11 deletions src/pmill/Plesk/ListSubdomains.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ protected function processResponse($xml)
$result = [];

foreach ($xml->subdomain->get->result as $node) {
if (isset($node->id)){
$result[] = [
'id' => (int)$node->id,
'status' => (string)$node->status,
'parent' => (string)$node->data->parent,
'name' => (string)$node->data->name,
'php' => (string)Xml::findProperty($node->data, 'php'),
'php_handler_type' => (string)Xml::findProperty($node->data, 'php_handler_type'),
'www_root' => (string)Xml::findProperty($node->data, 'www_root'),
];
}
if (isset($node->id)){
$result[] = [
'id' => (int)$node->id,
'status' => (string)$node->status,
'parent' => (string)$node->data->parent,
'name' => (string)$node->data->name,
'php' => (string)Xml::findProperty($node->data, 'php'),
'php_handler_type' => (string)Xml::findProperty($node->data, 'php_handler_type'),
'www_root' => (string)Xml::findProperty($node->data, 'www_root'),
];
}
}

return $result;
Expand Down