delete mailboxes and resources
This commit is contained in:
parent
c1f88ad2a6
commit
66c039df73
1 changed files with 23 additions and 8 deletions
|
@ -303,14 +303,29 @@ class Server_Manager_Mailcow extends Server_Manager
|
||||||
|
|
||||||
} */
|
} */
|
||||||
} else if (str_contains($result1, 'domain_not_empty')) {
|
} else if (str_contains($result1, 'domain_not_empty')) {
|
||||||
$mailboxes = array_column(json_decode($this->_makeRequest('GET', 'get/mailbox/all/' . $a->getDomain())), "username");
|
$mailboxes = json_decode($this->_makeRequest('GET', 'get/mailbox/all/' . $a->getDomain()), true);
|
||||||
$mailboxesData = [
|
if(count($mailboxes) > 0) {
|
||||||
'json' => $mailboxes
|
$mailboxesData = [
|
||||||
];
|
'json' => array_column(array_filter($mailboxes, function($item) use ($a) { return $item['domain'] == $a->getDomain(); }), 'username')
|
||||||
$result2 = $this->_makeRequest('POST', 'delete/mailbox', $mailboxesData);
|
];
|
||||||
if(!str_contains($result2, 'success')) {
|
$result2 = $this->_makeRequest('POST', 'delete/mailbox', $mailboxesData);
|
||||||
$placeholders = [':action:' => __trans('delete mailbox'), ':type:' => 'Mailcow'];
|
if(!str_contains($result2, 'success')) {
|
||||||
throw new Server_Exception('Failed to :action: on the :type: server, check the error logs for further details', $placeholders);
|
|
||||||
|
$placeholders = [':action:' => __trans('delete mailbox'), ':type:' => 'Mailcow'];
|
||||||
|
throw new Server_Exception('Failed to :action: on the :type: server, check the error logs for further details', $placeholders);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$resources = json_decode($this->_makeRequest('GET', 'get/resource/all'), true);
|
||||||
|
if(count($resources) > 0) {
|
||||||
|
$resourcesData = [
|
||||||
|
'json' => array_column(array_filter($resources, function($item) use ($a) { return $item['domain'] == $a->getDomain(); }), 'name')
|
||||||
|
];
|
||||||
|
$result3 = $this->_makeRequest('POST', 'delete/resource', $resourcesData);
|
||||||
|
if(!str_contains($result3, 'success')) {
|
||||||
|
$placeholders = [':action:' => __trans('delete domain'), ':type:' => 'Mailcow'];
|
||||||
|
throw new Server_Exception('Failed to :action: on the :type: server, check the error logs for further details', $placeholders);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $this->cancelAccount($a);
|
return $this->cancelAccount($a);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue