diff --git a/examples/DNS/delete_dns_records.php b/examples/DNS/delete_dns_records.php new file mode 100644 index 0000000..f6f3911 --- /dev/null +++ b/examples/DNS/delete_dns_records.php @@ -0,0 +1,13 @@ +1, + //'domain'=>'example.com' +); + +$request = new \pmill\Plesk\DeleteDNSRecords($config, $params); +$info = $request->process(); + +var_dump($info); diff --git a/examples/Users/get_user.php b/examples/Users/get_user.php new file mode 100644 index 0000000..ae4d628 --- /dev/null +++ b/examples/Users/get_user.php @@ -0,0 +1,13 @@ +'', + //'username'=>'', +); + +$request = new \pmill\Plesk\GetUser($config, $params); +$info = $request->process(); + +var_dump($info); diff --git a/examples/Users/list_users.php b/examples/Users/list_users.php new file mode 100644 index 0000000..4add519 --- /dev/null +++ b/examples/Users/list_users.php @@ -0,0 +1,8 @@ +process(); + +var_dump($info); diff --git a/src/pmill/Plesk/ApiRequestException.php b/src/pmill/Plesk/ApiRequestException.php index 9c870e8..e12037a 100644 --- a/src/pmill/Plesk/ApiRequestException.php +++ b/src/pmill/Plesk/ApiRequestException.php @@ -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); } } diff --git a/src/pmill/Plesk/BaseRequest.php b/src/pmill/Plesk/BaseRequest.php index 0aa049a..8781523 100644 --- a/src/pmill/Plesk/BaseRequest.php +++ b/src/pmill/Plesk/BaseRequest.php @@ -172,11 +172,12 @@ public function process() return $this->processResponse($responseXml); } + return false; + } catch (ApiRequestException $e) { $this->error = $e; + throw new ApiRequestException($e->getMessage(), $e->getCode()); } - - return false; } /** diff --git a/src/pmill/Plesk/CreateDatabase.php b/src/pmill/Plesk/CreateDatabase.php index 6b6678c..05320d8 100644 --- a/src/pmill/Plesk/CreateDatabase.php +++ b/src/pmill/Plesk/CreateDatabase.php @@ -49,4 +49,4 @@ protected function processResponse($xml) $this->id = (int)$xml->database->{'add-db'}->result->id; return true; } -} \ No newline at end of file +} diff --git a/src/pmill/Plesk/DeleteDNSRecords.php b/src/pmill/Plesk/DeleteDNSRecords.php new file mode 100644 index 0000000..bab331d --- /dev/null +++ b/src/pmill/Plesk/DeleteDNSRecords.php @@ -0,0 +1,63 @@ + + + + + + {ID} + {ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + 'site_id' => null, + ]; + + /** + * @param array $config + * @param array $params + * @throws ApiRequestException + */ + public function __construct($config, $params) + { + if (isset($params['domain'])) { + $request = new GetSite($config, ['domain' => $params['domain']]); + $info = $request->process(); + + $params['site_id'] = $info['id']; + } + + parent::__construct($config, $params); + } + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + $result = $xml->dns->{'del-rec'}->result; + + if ($result->status == 'error') { + throw new ApiRequestException($result); + } + + return true; + } +} diff --git a/src/pmill/Plesk/DeleteDatabaseUser.php b/src/pmill/Plesk/DeleteDatabaseUser.php new file mode 100644 index 0000000..1c49e7e --- /dev/null +++ b/src/pmill/Plesk/DeleteDatabaseUser.php @@ -0,0 +1,60 @@ + + + + + + {FILTER} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + '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 + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + $result = $xml->database->{'del-db-user'}->result; + + if ($result->status == 'error') { + throw new ApiRequestException($result); + } + + return true; + } +} diff --git a/src/pmill/Plesk/GetDatabase.php b/src/pmill/Plesk/GetDatabase.php new file mode 100644 index 0000000..8a59536 --- /dev/null +++ b/src/pmill/Plesk/GetDatabase.php @@ -0,0 +1,54 @@ + + + + + + {SUBSCRIPTION_ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'id' => null, + ]; + + /** + * @param $xml + * @return array + */ + protected function processResponse($xml) + { + + $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'}, + ]; + + } +} diff --git a/src/pmill/Plesk/GetDatabaseServer.php b/src/pmill/Plesk/GetDatabaseServer.php new file mode 100644 index 0000000..054bf45 --- /dev/null +++ b/src/pmill/Plesk/GetDatabaseServer.php @@ -0,0 +1,64 @@ + + + + + + {FILTER} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'filter' => null, + ]; + + /** + * GetDatabaseServer constructor. + * @param array $config + * @param array $params + */ + public function __construct(array $config, $params = []) + { + if (isset($params['type'])) { + $params['filter'] = new Node('type', $params['type']); + } + if (isset($params['id'])) { + $params['filter'] = new Node('id', $params['id']); + } + parent::__construct($config, $params); + } + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ($xml->db_server->{'get-local'}->result->status == 'error') { + throw new ApiRequestException($xml->db_server->{'get-local'}->result); + } + + $db_server = $xml->db_server->{'get-local'}->result; + return [ + 'id' => (int)$db_server->id, + 'status' => (string)$db_server->status, + 'type' => (string)$db_server->type, + ]; + } + +} diff --git a/src/pmill/Plesk/GetDatabaseUser.php b/src/pmill/Plesk/GetDatabaseUser.php index 920ddd7..8dbb43d 100644 --- a/src/pmill/Plesk/GetDatabaseUser.php +++ b/src/pmill/Plesk/GetDatabaseUser.php @@ -8,27 +8,22 @@ class GetDatabaseUser extends BaseRequest */ public $xml_packet = << - + - + - {DATABASE_ID} + {ID} - + EOT; - /** - * @var int - */ - public $id; - /** * @var array */ protected $default_params = [ - 'database_id' => null, + 'id' => null, ]; /** @@ -38,12 +33,20 @@ class GetDatabaseUser extends BaseRequest */ protected function processResponse($xml) { - if ($xml->database->{'get-default-user'}->result->status == 'error') { + if ($xml->database->{'get-db-users'}->result->status == 'error') { throw new ApiRequestException($xml->database->{'get-default-user'}->result); } - $this->id = (int)$xml->database->{'get-default-user'}->result->id; - return true; + $user = $xml->database->{'get-db-users'}->result; + return [ + 'status' => (string)$user->status, + 'filter-id' => (int)$user->{'filter-id'}, + 'id' => (int)$user->id, + 'db-id' => (int)$user->{'db-id'}, + 'login' => (string)$user->login, + 'acl-host' => (string)$user->acl->host, + 'allow-access-from-ip' => (string)$user->{'allow-access-from'}->{'ip-address'}, + ]; } -} \ No newline at end of file +} diff --git a/src/pmill/Plesk/GetDefaultDatabaseUser.php b/src/pmill/Plesk/GetDefaultDatabaseUser.php new file mode 100644 index 0000000..4ee7727 --- /dev/null +++ b/src/pmill/Plesk/GetDefaultDatabaseUser.php @@ -0,0 +1,44 @@ + + + + + + {DATABASE_ID} + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'database_id' => null, + ]; + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ($xml->database->{'get-default-user'}->result->status == 'error') { + throw new ApiRequestException($xml->database->{'get-default-user'}->result); + } + + $this->id = (int)$xml->database->{'get-default-user'}->result->id; + return true; + } + +} diff --git a/src/pmill/Plesk/GetSite.php b/src/pmill/Plesk/GetSite.php index a36ca23..99503b1 100644 --- a/src/pmill/Plesk/GetSite.php +++ b/src/pmill/Plesk/GetSite.php @@ -8,17 +8,17 @@ class GetSite extends BaseRequest */ public $xml_packet = << - - + + - {DOMAIN} + {DOMAIN} - + EOT; diff --git a/src/pmill/Plesk/GetSubscription.php b/src/pmill/Plesk/GetSubscription.php index 23f3009..c8ff627 100644 --- a/src/pmill/Plesk/GetSubscription.php +++ b/src/pmill/Plesk/GetSubscription.php @@ -39,10 +39,22 @@ public function __construct($config, $params = []) { $this->default_params['filter'] = new Node('filter'); - if (isset($params['subscription_id'])) { - $ownerIdNode = new Node('id', $params['subscription_id']); + if (isset($params['client_id'])) { + $ownerIdNode = new Node('owner-id', $params['client_id']); $params['filter'] = new Node('filter', $ownerIdNode); - } + } + if (isset($params['username'])) { + $ownerLoginNode = new Node('owner-login', $params['username']); + $params['filter'] = new Node('filter', $ownerLoginNode); + } + if (isset($params['name'])) { + $nameNode = new Node('name', $params['name']); + $params['filter'] = new Node('filter', $nameNode); + } + if (isset($params['subscription_id'])) { + $idNode = new Node('id', $params['subscription_id']); + $params['filter'] = new Node('filter', $idNode); + } parent::__construct($config, $params); } @@ -57,6 +69,10 @@ protected function processResponse($xml) for ($i = 0; $i < count($xml->webspace->get->result); $i++) { $webspace = $xml->webspace->get->result[$i]; + if ($webspace->status == 'error') { + throw new ApiRequestException($webspace); + } + $hosting = []; foreach ($webspace->data->hosting->children() as $host) { $hosting[$host->getName()] = Xml::getProperties($host); diff --git a/src/pmill/Plesk/GetUser.php b/src/pmill/Plesk/GetUser.php new file mode 100644 index 0000000..b94cce0 --- /dev/null +++ b/src/pmill/Plesk/GetUser.php @@ -0,0 +1,96 @@ + + + + + + {GUID} + + + + + + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'guid' => null, + ]; + + /** + * GetClient constructor. + * @param array $config + * @param array $params + */ + public function __construct(array $config, $params) + { + if (isset($params['username'])) { + $request = new ListUsers($config); + $users = $request->process(); + foreach($users as $user){ + if ($user['login'] == $params['username']) + $params['guid'] = $user['guid']; + } + } + + parent::__construct($config, $params); + } + + /** + * @param $xml + * @return array + */ + protected function processResponse($xml) + { + $user = $xml->user->get->result; + + if ((string)$user->status == 'error') { + throw new ApiRequestException($user); + } + + if ((string)$user->result->status == 'error') { + throw new ApiRequestException($user->result); + } + return [ + 'id' => (int)$user->id, + 'filter-id' => (int)$user->{'filter-id'}, + 'status' => (string)$user->status, + 'login' => (string)$user->data->{'gen-info'}->login, + 'name' => (string)$user->data->{'gen-info'}->name, + 'owner-guid' => (string)$user->data->{'gen-info'}->{'owner-guid'}, + 'status' => (string)$user->data->{'gen-info'}->status, + 'guid' => (string)$user->data->{'gen-info'}->guid, + 'is-built-in' => (int)$user->data->{'gen-info'}->{'is-built-in'}, + 'subcription-domain-id' => (int)$user->data->{'gen-info'}->{'subcription-domain-id'}, + 'email' => (string)$user->data->{'gen-info'}->email, + 'contact-info' => [ + 'company' => (string)$user->data->{'gen-info'}->{'contact-info'}->company, + 'phone' => (string)$user->data->{'gen-info'}->{'contact-info'}->phone, + 'fax' => (string)$user->data->{'gen-info'}->{'contact-info'}->fax, + 'address' => (string)$user->data->{'gen-info'}->{'contact-info'}->address, + 'city' => (string)$user->data->{'gen-info'}->{'contact-info'}->city, + 'state' => (string)$user->data->{'gen-info'}->{'contact-info'}->state, + 'zip' => (string)$user->data->{'gen-info'}->{'contact-info'}->zip, + 'country' => (string)$user->data->{'gen-info'}->{'contact-info'}->country, + 'im' => (string)$user->data->{'gen-info'}->{'contact-info'}->im, + 'imtype' => (string)$user->data->{'gen-info'}->{'contact-info'}->imtype, + 'comment' => (string)$user->data->{'gen-info'}->{'contact-info'}->comment, + 'locale' => (string)$user->data->{'gen-info'}->{'contact-info'}->locale, + ], + 'role' => (string)$user->data->roles->name, + ]; + } +} diff --git a/src/pmill/Plesk/ListDatabaseUsers.php b/src/pmill/Plesk/ListDatabaseUsers.php new file mode 100644 index 0000000..bc315cd --- /dev/null +++ b/src/pmill/Plesk/ListDatabaseUsers.php @@ -0,0 +1,65 @@ + + + + + + {DATABASE_ID} + + + + +EOT; + + /** + * @var int + */ + public $id; + + /** + * @var array + */ + protected $default_params = [ + 'database_id' => null, + ]; + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + $result = []; + + if ($xml->database->{'get-db-users'}->result->status == 'error') { + throw new ApiRequestException($xml->database->{'get-default-user'}->result); + } + + $users = $xml->database->{'get-db-users'}->result; + foreach ($users as $user){ + if (isset($user->id)){ + $result[] = [ + 'status'=> (string)$user->status, + 'filter-id'=> (int)$user->{'filter-id'}, + 'id'=> (int)$user->id, + 'db-id'=> (int)$user->{'db-id'}, + 'login'=> (string)$user->login, + 'acl-host'=> (string)$user->acl->host, + 'allow-access-from-ip'=> (string)$user->{'allow-access-from'}->{'ip-address'}, + ]; + } + } + + return $result; + } + +} diff --git a/src/pmill/Plesk/ListDatabases.php b/src/pmill/Plesk/ListDatabases.php index 0ada2c6..310096c 100644 --- a/src/pmill/Plesk/ListDatabases.php +++ b/src/pmill/Plesk/ListDatabases.php @@ -11,9 +11,7 @@ class ListDatabases extends BaseRequest - - {SUBSCRIPTION_ID} - + {FILTER} @@ -23,9 +21,28 @@ class ListDatabases extends BaseRequest * @var array */ protected $default_params = [ - 'subscription_id' => null, + 'filter' => '', ]; + /** + * @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); + } + /** * @param $xml * @return array @@ -33,16 +50,17 @@ class ListDatabases extends BaseRequest protected function processResponse($xml) { $result = []; - foreach ($xml->database->{'get-db'}->children() as $node) { - $result[] = [ - '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'}, - ]; + if (isset($node->id)){ + $result[] = [ + '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'}, + ]; + } } return $result; diff --git a/src/pmill/Plesk/ListSites.php b/src/pmill/Plesk/ListSites.php index 551beab..d12266f 100644 --- a/src/pmill/Plesk/ListSites.php +++ b/src/pmill/Plesk/ListSites.php @@ -56,20 +56,22 @@ protected function processResponse($xml) for ($i = 0; $i < $itemCount; $i++) { $site = $xml->site->get->result[$i]; - $hosting_type = (string)$site->data->gen_info->htype; + if (isset($site->id)){ + $hosting_type = (string)$site->data->gen_info->htype; - $result[] = [ - 'id' => (string)$site->id, - 'status' => (string)$site->status, - 'created' => (string)$site->data->gen_info->cr_date, - 'name' => (string)$site->data->gen_info->name, - 'ip' => (string)$site->data->gen_info->dns_ip_address, - 'hosting_type' => $hosting_type, - 'ip_address' => (string)$site->data->hosting->{$hosting_type}->ip_address, - 'www_root' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'www_root'), - 'ftp_username' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'ftp_login'), - 'ftp_password' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'ftp_password'), - ]; + $result[] = [ + 'id' => (string)$site->id, + 'status' => (string)$site->status, + 'created' => (string)$site->data->gen_info->cr_date, + 'name' => (string)$site->data->gen_info->name, + 'ip' => (string)$site->data->gen_info->dns_ip_address, + 'hosting_type' => $hosting_type, + 'ip_address' => (string)$site->data->hosting->{$hosting_type}->ip_address, + 'www_root' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'www_root'), + 'ftp_username' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'ftp_login'), + 'ftp_password' => $this->findHostingProperty($site->data->hosting->{$hosting_type}, 'ftp_password'), + ]; + } } return $result; diff --git a/src/pmill/Plesk/ListSubdomains.php b/src/pmill/Plesk/ListSubdomains.php index 51faef4..263a3eb 100644 --- a/src/pmill/Plesk/ListSubdomains.php +++ b/src/pmill/Plesk/ListSubdomains.php @@ -57,6 +57,7 @@ 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, @@ -66,6 +67,7 @@ protected function processResponse($xml) 'php_handler_type' => (string)Xml::findProperty($node->data, 'php_handler_type'), 'www_root' => (string)Xml::findProperty($node->data, 'www_root'), ]; + } } return $result; diff --git a/src/pmill/Plesk/ListSubscriptions.php b/src/pmill/Plesk/ListSubscriptions.php index a64e67e..fcf020d 100644 --- a/src/pmill/Plesk/ListSubscriptions.php +++ b/src/pmill/Plesk/ListSubscriptions.php @@ -13,7 +13,7 @@ class ListSubscriptions extends BaseRequest - {FILTER} + @@ -23,30 +23,6 @@ class ListSubscriptions extends BaseRequest EOT; - /** - * @var array - */ - protected $default_params = [ - 'filter' => null, - ]; - - /** - * @param array $config - * @param array $params - * @throws ApiRequestException - */ - public function __construct($config, $params = []) - { - $this->default_params['filter'] = new Node('filter'); - - if (isset($params['client_id'])) { - $ownerIdNode = new Node('owner-id', $params['client_id']); - $params['filter'] = new Node('filter', $ownerIdNode); - } - - parent::__construct($config, $params); - } - /** * @param $xml * @return array @@ -57,34 +33,36 @@ protected function processResponse($xml) for ($i = 0; $i < count($xml->webspace->get->result); $i++) { $webspace = $xml->webspace->get->result[$i]; + if (isset($webspace->id)){ - $hosting = []; - foreach ($webspace->data->hosting->children() as $host) { - $hosting[$host->getName()] = Xml::getProperties($host); - } + $hosting = []; + foreach ($webspace->data->hosting->children() as $host) { + $hosting[$host->getName()] = Xml::getProperties($host); + } + + $subscriptions = []; + foreach ($webspace->data->subscriptions->children() as $subscription) { + $subscriptions[] = [ + 'locked' => (bool)$subscription->locked, + 'synchronized' => (bool)$subscription->synchronized, + 'plan-guid' => (string)$subscription->plan->{"plan-guid"}, + ]; + } - $subscriptions = []; - foreach ($webspace->data->subscriptions->children() as $subscription) { - $subscriptions[] = [ - 'locked' => (bool)$subscription->locked, - 'synchronized' => (bool)$subscription->synchronized, - 'plan-guid' => (string)$subscription->plan->{"plan-guid"}, + $result[] = [ + 'id' => (string)$webspace->id, + 'status' => (string)$webspace->status, + 'subscription_status' => (int)$webspace->data->gen_info->status, + 'created' => (string)$webspace->data->gen_info->cr_date, + 'name' => (string)$webspace->data->gen_info->name, + 'owner_id' => (string)$webspace->data->gen_info->{"owner-id"}, + 'hosting' => $hosting, + 'real_size' => (int)$webspace->data->gen_info->real_size, + 'dns_ip_address' => (string)$webspace->data->gen_info->dns_ip_address, + 'htype' => (string)$webspace->data->gen_info->htype, + 'subscriptions' => $subscriptions, ]; } - - $result[] = [ - 'id' => (string)$webspace->id, - 'status' => (string)$webspace->status, - 'subscription_status' => (int)$webspace->data->gen_info->status, - 'created' => (string)$webspace->data->gen_info->cr_date, - 'name' => (string)$webspace->data->gen_info->name, - 'owner_id' => (string)$webspace->data->gen_info->{"owner-id"}, - 'hosting' => $hosting, - 'real_size' => (int)$webspace->data->gen_info->real_size, - 'dns_ip_address' => (string)$webspace->data->gen_info->dns_ip_address, - 'htype' => (string)$webspace->data->gen_info->htype, - 'subscriptions' => $subscriptions, - ]; } return $result; diff --git a/src/pmill/Plesk/ListUsers.php b/src/pmill/Plesk/ListUsers.php new file mode 100644 index 0000000..40eecdd --- /dev/null +++ b/src/pmill/Plesk/ListUsers.php @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + +EOT; + + /** + * @param $xml + * @return array + */ + protected function processResponse($xml) + { + $result = []; + + for ($i = 0; $i < count($xml->user->get->result); $i++) { + $user = $xml->user->get->result[$i]; + + $result[] = [ + 'id' => (int)$user->id, + 'filter-id' => (int)$user->{'filter-id'}, + 'status' => (string)$user->status, + 'login' => (string)$user->data->{'gen-info'}->login, + 'name' => (string)$user->data->{'gen-info'}->name, + 'owner-guid' => (string)$user->data->{'gen-info'}->{'owner-guid'}, + 'status' => (string)$user->data->{'gen-info'}->status, + 'guid' => (string)$user->data->{'gen-info'}->guid, + 'is-built-in' => (int)$user->data->{'gen-info'}->{'is-built-in'}, + 'subcription-domain-id' => (int)$user->data->{'gen-info'}->{'subcription-domain-id'}, + 'email' => (string)$user->data->{'gen-info'}->email, + 'contact-info' => [ + 'company' => (string)$user->data->{'gen-info'}->{'contact-info'}->company, + 'phone' => (string)$user->data->{'gen-info'}->{'contact-info'}->phone, + 'fax' => (string)$user->data->{'gen-info'}->{'contact-info'}->fax, + 'address' => (string)$user->data->{'gen-info'}->{'contact-info'}->address, + 'city' => (string)$user->data->{'gen-info'}->{'contact-info'}->city, + 'state' => (string)$user->data->{'gen-info'}->{'contact-info'}->state, + 'zip' => (string)$user->data->{'gen-info'}->{'contact-info'}->zip, + 'country' => (string)$user->data->{'gen-info'}->{'contact-info'}->country, + 'im' => (string)$user->data->{'gen-info'}->{'contact-info'}->im, + 'imtype' => (string)$user->data->{'gen-info'}->{'contact-info'}->imtype, + 'comment' => (string)$user->data->{'gen-info'}->{'contact-info'}->comment, + 'locale' => (string)$user->data->{'gen-info'}->{'contact-info'}->locale, + ], + 'role' => (string)$user->data->roles->name, + ]; + } + + return $result; + } +} diff --git a/src/pmill/Plesk/SetDefaultDatabaseUser.php b/src/pmill/Plesk/SetDefaultDatabaseUser.php new file mode 100644 index 0000000..bf92b5a --- /dev/null +++ b/src/pmill/Plesk/SetDefaultDatabaseUser.php @@ -0,0 +1,44 @@ + + + + + {DATABASE_ID} + {ID} + + + +EOT; + + /** + * @var array + */ + protected $default_params = [ + 'database_id' => null, + 'id' => null, + ]; + + /** + * @param $xml + * @return bool + * @throws ApiRequestException + */ + protected function processResponse($xml) + { + if ($xml->database->{'set-default-user'}->result->status == 'error') { + throw new ApiRequestException($xml->database->{'set-default-user'}->result); + } + + return true; + + } + +}