@@ -79,31 +79,31 @@ discard block |
||
| 79 | 79 | 'api.chunk.start' => $page * $limit |
| 80 | 80 | ]; |
| 81 | 81 | |
| 82 | - if ( ! empty($options['limit'])) { |
|
| 82 | + if (!empty($options['limit'])) { |
|
| 83 | 83 | $params['api.chunk.size'] = intval($options['limit']); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( ! empty($options['page'])) { |
|
| 86 | + if (!empty($options['page'])) { |
|
| 87 | 87 | $params['api.chunk.start'] = intval($options['page']) * $params['api.chunk.size']; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( ! empty($searchType) && ! in_array($searchType, ["domain", "owner", "user", "ip", "package"])) { |
|
| 90 | + if (!empty($searchType) && !in_array($searchType, ["domain", "owner", "user", "ip", "package"])) { |
|
| 91 | 91 | throw new \InvalidArgumentException("`searchType` must be one of these - domain, owner, user, ip, package"); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( ! empty($options['searchmethod']) && ! in_array($options['searchmethod'], ["exact", "regex"])) { |
|
| 94 | + if (!empty($options['searchmethod']) && !in_array($options['searchmethod'], ["exact", "regex"])) { |
|
| 95 | 95 | throw new \InvalidArgumentException("options[searchmethod] must be either `regex` or `exact`"); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( ! empty($options['want'])) { |
|
| 98 | + if (!empty($options['want'])) { |
|
| 99 | 99 | $params['want'] = $options['want']; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( ! empty($searchType)) { |
|
| 102 | + if (!empty($searchType)) { |
|
| 103 | 103 | $params['searchtype'] = $searchType; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( ! empty($keyword)) { |
|
| 106 | + if (!empty($keyword)) { |
|
| 107 | 107 | $params['search'] = $keyword; |
| 108 | 108 | empty($searchType) ? $params['searchtype'] = "user" : null; |
| 109 | 109 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | throw ClientExceptions::invalidArgument("You must provide either a username or a domain or both"); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ( ! empty($user) && ! empty($domain)) { |
|
| 148 | + if (!empty($user) && !empty($domain)) { |
|
| 149 | 149 | throw ClientExceptions::invalidArgument( |
| 150 | 150 | "You must provide only one argument either user OR domain (not both)" |
| 151 | 151 | ); |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $params = []; |
| 155 | 155 | |
| 156 | - if ( ! empty($user)) { |
|
| 156 | + if (!empty($user)) { |
|
| 157 | 157 | $params['user'] = $user; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if ( ! empty($domain)) { |
|
| 160 | + if (!empty($domain)) { |
|
| 161 | 161 | $params['domain'] = $domain; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | if ($result['metadata']['reason'] != "OK") { |
| 171 | 171 | throw ClientExceptions::recordNotFound( |
| 172 | - ! empty($result['metadata']['reason']) ? $result['metadata']['reason'] : "Record not found" |
|
| 172 | + !empty($result['metadata']['reason']) ? $result['metadata']['reason'] : "Record not found" |
|
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( ! empty($result['data']) && is_array($result['data']) && !empty($result['data']['acct'])) { |
|
| 176 | + if (!empty($result['data']) && is_array($result['data']) && !empty($result['data']['acct'])) { |
|
| 177 | 177 | return Account::buildFromArray($result['data']['acct'][0]); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $result = $this->client->sendRequest("/json-api/applist", 'GET', []); |
| 201 | 201 | |
| 202 | - if ( ! empty($result['app']) && sizeof($result['app']) > 0) { |
|
| 202 | + if (!empty($result['app']) && sizeof($result['app']) > 0) { |
|
| 203 | 203 | return $result['app']; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -234,18 +234,18 @@ discard block |
||
| 234 | 234 | $params = []; |
| 235 | 235 | $params['username'] = $account->getUser(); |
| 236 | 236 | $params['domain'] = $account->getDomain(); |
| 237 | - ! empty($account->getPlanName()) ? $params['plan'] = $account->getPlanName() : null; |
|
| 238 | - ! empty($options['pkgname']) ? $params['pkgname'] = $options['pkgname'] : null; |
|
| 239 | - if ( ! empty($options['savepkg'])) { |
|
| 240 | - if ( ! in_array(intval($options['savepkg']), [0, 1])) { |
|
| 237 | + !empty($account->getPlanName()) ? $params['plan'] = $account->getPlanName() : null; |
|
| 238 | + !empty($options['pkgname']) ? $params['pkgname'] = $options['pkgname'] : null; |
|
| 239 | + if (!empty($options['savepkg'])) { |
|
| 240 | + if (!in_array(intval($options['savepkg']), [0, 1])) { |
|
| 241 | 241 | throw new ClientExceptions("`savepkg` must be either 0 or 1"); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | $params['savepkg'] = $options['savepkg']; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - ! empty($options['featurelist']) ? $params['featurelist'] = $options['featurelist'] : null; |
|
| 248 | - if ( ! empty($account->getDiskLimit())) { |
|
| 247 | + !empty($options['featurelist']) ? $params['featurelist'] = $options['featurelist'] : null; |
|
| 248 | + if (!empty($account->getDiskLimit())) { |
|
| 249 | 249 | if ($account->getDiskLimit() === -1) { |
| 250 | 250 | $params['quota'] = 0; |
| 251 | 251 | } else { |
@@ -253,16 +253,16 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - ! empty($account->getPassword()) ? $params['password'] = $account->getPassword() : null; |
|
| 257 | - ! empty($account->getIpAddress()) ? $params['ip'] = $account->getIpAddress() : null; |
|
| 258 | - ! empty($account->isCgiEnable()) ? $params['cgi'] = (int)$account->isCgiEnable() : null; |
|
| 259 | - ! empty($account->isSpamAssassinEnable()) ? |
|
| 256 | + !empty($account->getPassword()) ? $params['password'] = $account->getPassword() : null; |
|
| 257 | + !empty($account->getIpAddress()) ? $params['ip'] = $account->getIpAddress() : null; |
|
| 258 | + !empty($account->isCgiEnable()) ? $params['cgi'] = (int)$account->isCgiEnable() : null; |
|
| 259 | + !empty($account->isSpamAssassinEnable()) ? |
|
| 260 | 260 | $params['spamassassin'] = (int)$account->isSpamAssassinEnable() |
| 261 | 261 | : null; |
| 262 | - ! empty($account->isFrontPageEnable()) ? $params['frontpage'] = (int)$account->isFrontPageEnable() : null; |
|
| 263 | - ! empty($account->getShell()) ? $params['hasshell'] = 1 : null; |
|
| 264 | - ! empty($account->getEmail()) ? $params['contactemail'] = $account->getEmail() : null; |
|
| 265 | - ! empty($account->getTheme()) ? $params['cpmod'] = 1 : null; |
|
| 262 | + !empty($account->isFrontPageEnable()) ? $params['frontpage'] = (int)$account->isFrontPageEnable() : null; |
|
| 263 | + !empty($account->getShell()) ? $params['hasshell'] = 1 : null; |
|
| 264 | + !empty($account->getEmail()) ? $params['contactemail'] = $account->getEmail() : null; |
|
| 265 | + !empty($account->getTheme()) ? $params['cpmod'] = 1 : null; |
|
| 266 | 266 | |
| 267 | 267 | if ($account->getMaxFTP() === -1) { |
| 268 | 268 | $params['maxftp'] = "unlimited"; |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | $params['bwlimit'] = intval($account->getBandwidthLimit()); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - ! empty($options['customip']) ? $params['customip'] = $options['customip'] : null; |
|
| 315 | + !empty($options['customip']) ? $params['customip'] = $options['customip'] : null; |
|
| 316 | 316 | |
| 317 | - ! empty($account->getLanguagePreference()) ? $params['language'] = $account->getLanguagePreference() : null; |
|
| 317 | + !empty($account->getLanguagePreference()) ? $params['language'] = $account->getLanguagePreference() : null; |
|
| 318 | 318 | |
| 319 | - ! empty($options['useregns']) ? $params['useregns'] = $options['useregns'] : null; |
|
| 320 | - ! empty($options['reseller']) ? $params['reseller'] = (int)$options['reseller'] : null; |
|
| 321 | - ! empty($options['forcedns']) ? $params['forcedns'] = (int)$options['forcedns'] : null; |
|
| 319 | + !empty($options['useregns']) ? $params['useregns'] = $options['useregns'] : null; |
|
| 320 | + !empty($options['reseller']) ? $params['reseller'] = (int)$options['reseller'] : null; |
|
| 321 | + !empty($options['forcedns']) ? $params['forcedns'] = (int)$options['forcedns'] : null; |
|
| 322 | 322 | |
| 323 | - ! empty($account->getMailboxFormat()) ? $params['mailbox_format'] = $account->getMailboxFormat() : null; |
|
| 323 | + !empty($account->getMailboxFormat()) ? $params['mailbox_format'] = $account->getMailboxFormat() : null; |
|
| 324 | 324 | |
| 325 | - if ( ! empty($options['mxcheck'])) { |
|
| 326 | - if ( ! in_array($options['mxcheck'], ['local', 'secondary', 'remote', 'auto'])) { |
|
| 325 | + if (!empty($options['mxcheck'])) { |
|
| 326 | + if (!in_array($options['mxcheck'], ['local', 'secondary', 'remote', 'auto'])) { |
|
| 327 | 327 | throw new ClientExceptions("options[mxcheck] parameters must be one of local, secondary, remote, auto"); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -348,27 +348,27 @@ discard block |
||
| 348 | 348 | $params['max_defer_fail_percentage'] = intval($account->getMaxDeferFailMailPercentage()); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - ! empty($account->getUid()) ? $params['uid'] = $account->getUid() : null; |
|
| 352 | - ! empty($account->getPartition()) ? $params['homedir'] = $account->getPartition() : null; |
|
| 353 | - ! empty($options['dkim']) ? $params['dkim'] = intval($options['dkim']) : null; |
|
| 354 | - ! empty($options['spf']) ? $params['spf'] = intval($options['spf']) : null; |
|
| 355 | - ! empty($account->getOwner()) ? $params['owner'] = $account->getOwner() : null; |
|
| 351 | + !empty($account->getUid()) ? $params['uid'] = $account->getUid() : null; |
|
| 352 | + !empty($account->getPartition()) ? $params['homedir'] = $account->getPartition() : null; |
|
| 353 | + !empty($options['dkim']) ? $params['dkim'] = intval($options['dkim']) : null; |
|
| 354 | + !empty($options['spf']) ? $params['spf'] = intval($options['spf']) : null; |
|
| 355 | + !empty($account->getOwner()) ? $params['owner'] = $account->getOwner() : null; |
|
| 356 | 356 | |
| 357 | 357 | $result = $this->client->sendRequest("/json-api/createacct", "GET", $params); |
| 358 | 358 | |
| 359 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 359 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 360 | 360 | throw new ClientExceptions($result['metadata']['reason']); |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( ! empty($result) && ! empty($result['result'][0]) && $result['result'][0]['status'] === 0) { |
|
| 363 | + if (!empty($result) && !empty($result['result'][0]) && $result['result'][0]['status'] === 0) { |
|
| 364 | 364 | throw new ClientExceptions($result['result'][0]['statusmsg']); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( ! empty($result) && ! empty($result['result'][0]) && $result['result'][0]['status'] === 1) { |
|
| 367 | + if (!empty($result) && !empty($result['result'][0]) && $result['result'][0]['status'] === 1) { |
|
| 368 | 368 | return ['result' => $result['result'][0]['options'], 'raw_output' => $result['result'][0]['rawout']]; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 371 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 372 | 372 | return ['result' => $result['data'], 'raw_output' => $result['metadata']['output']['raw']]; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | throw new ClientExceptions($result['metadata']['reason']); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if ( ! empty($result['data'])) { |
|
| 484 | + if (!empty($result['data'])) { |
|
| 485 | 485 | return $result['updated']; |
| 486 | 486 | } |
| 487 | 487 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | return null; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 510 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 511 | 511 | $domains = $result['data']['domains']; |
| 512 | 512 | |
| 513 | 513 | $domainList = []; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | { |
| 556 | 556 | $params = ['user' => $user]; |
| 557 | 557 | $result = $this->client->sendRequest("/json-api/has_digest_auth", "GET", $params); |
| 558 | - if ( ! empty($result['data'])) { |
|
| 558 | + if (!empty($result['data'])) { |
|
| 559 | 559 | return $result['data']['digestauth'] === 1 ? true : false; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -581,14 +581,14 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | public function setDigestAuth($user, $password, $enableDigestAuth = true) |
| 583 | 583 | { |
| 584 | - $params = ['user' => $user, 'password' => $password, 'digestauth' => (int) $enableDigestAuth]; |
|
| 584 | + $params = ['user' => $user, 'password' => $password, 'digestauth' => (int)$enableDigestAuth]; |
|
| 585 | 585 | $result = $this->client->sendRequest("/json-api/set_digest_auth", "GET", $params); |
| 586 | 586 | |
| 587 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 587 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 588 | 588 | throw new ClientExceptions($result['metadata']['reason']); |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 591 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 592 | 592 | return true; |
| 593 | 593 | } |
| 594 | 594 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | { |
| 611 | 611 | $params = ['user' => $user]; |
| 612 | 612 | $result = $this->client->sendRequest("/json-api/has_mycnf_for_cpuser", "GET", $params); |
| 613 | - if ( ! empty($result['data'])) { |
|
| 613 | + if (!empty($result['data'])) { |
|
| 614 | 614 | return $result['data']['has_mycnf_for_cpuser'] === 1 ? true : false; |
| 615 | 615 | } |
| 616 | 616 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | { |
| 634 | 634 | $params = ['user' => $user, 'bwlimit' => intval($bwlimit)]; |
| 635 | 635 | $result = $this->client->sendRequest("/json-api/limitbw", "GET", $params); |
| 636 | - if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 636 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 637 | 637 | return $result['data']['bwlimits'][0]; |
| 638 | 638 | } |
| 639 | 639 | |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | public function getUsers() |
| 654 | 654 | { |
| 655 | 655 | $result = $this->client->sendRequest("/json-api/list_users", "GET", []); |
| 656 | - if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 656 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 657 | 657 | return $result['data']['users']; |
| 658 | 658 | } |
| 659 | 659 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | public function getLockedAccounts() |
| 675 | 675 | { |
| 676 | 676 | $result = $this->client->sendRequest("/json-api/listlockedaccounts", "GET", []); |
| 677 | - if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 677 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 678 | 678 | return $result['data']['account']; |
| 679 | 679 | } |
| 680 | 680 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | public function getSuspendedAccounts() |
| 695 | 695 | { |
| 696 | 696 | $result = $this->client->sendRequest("/json-api/listsuspended", "GET", []); |
| 697 | - if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 697 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 698 | 698 | $suspendList = $result['data']['account']; |
| 699 | 699 | |
| 700 | 700 | $lists = []; |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | */ |
| 732 | 732 | public function modifyAccount(Account $account) |
| 733 | 733 | { |
| 734 | - if(empty($account->getUser())){ |
|
| 734 | + if (empty($account->getUser())) { |
|
| 735 | 735 | throw ClientExceptions::invalidArgument("You must provide username to modify account"); |
| 736 | 736 | } |
| 737 | 737 | |
@@ -739,103 +739,103 @@ discard block |
||
| 739 | 739 | 'user' => $account->getUser() |
| 740 | 740 | ]; |
| 741 | 741 | |
| 742 | - if($account->isBackupEnabled()){ |
|
| 742 | + if ($account->isBackupEnabled()) { |
|
| 743 | 743 | $params['BACKUP'] = 1; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if($account->getBandwidthLimit() === -1){ |
|
| 746 | + if ($account->getBandwidthLimit() === -1) { |
|
| 747 | 747 | $params['BWLIMIT'] = "unlimited"; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - if(!empty($account->getDomain())){ |
|
| 750 | + if (!empty($account->getDomain())) { |
|
| 751 | 751 | $params['DNS'] = $account->getDomain(); |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if(!empty($account->isCgiEnable())){ |
|
| 755 | - $params['HASCGI'] = (int) $account->isCgiEnable(); |
|
| 754 | + if (!empty($account->isCgiEnable())) { |
|
| 755 | + $params['HASCGI'] = (int)$account->isCgiEnable(); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - if(!empty($account->getMaxAddonDomains())){ |
|
| 758 | + if (!empty($account->getMaxAddonDomains())) { |
|
| 759 | 759 | $params['MAXADDON'] = $account->getMaxAddonDomains() === -1 ? "unlimited" : intval($account->getMaxAddonDomains()); |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - if(!empty($account->getMaxFTP())){ |
|
| 762 | + if (!empty($account->getMaxFTP())) { |
|
| 763 | 763 | $params['MAXFTP'] = $account->getMaxFTP() === -1 ? "unlimited" : intval($account->getMaxFTP()); |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if(!empty($account->getMaxMailingList())){ |
|
| 766 | + if (!empty($account->getMaxMailingList())) { |
|
| 767 | 767 | $params['MAXLST'] = $account->getMaxMailingList() === -1 ? "unlimited" : intval($account->getMaxMailingList()); |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - if(!empty($account->getMaxParkedDomains())){ |
|
| 770 | + if (!empty($account->getMaxParkedDomains())) { |
|
| 771 | 771 | $params['MAXPARK'] = $account->getMaxParkedDomains() === -1 ? "unlimited" : intval($account->getMaxParkedDomains()); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if(!empty($account->getMaxPOP())){ |
|
| 774 | + if (!empty($account->getMaxPOP())) { |
|
| 775 | 775 | $params['MAXPOP'] = $account->getMaxPOP() === -1 ? "unlimited" : null; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | - if(!empty($account->getMaxSQL())){ |
|
| 778 | + if (!empty($account->getMaxSQL())) { |
|
| 779 | 779 | $params['MAXSQL'] = $account->getMaxSQL() === -1 ? "unlimited" : intval($account->getMaxSQL()); |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - if(!empty($account->getMaxSubDomain())){ |
|
| 782 | + if (!empty($account->getMaxSubDomain())) { |
|
| 783 | 783 | $params['MAXSUB'] = $account->getMaxSubDomain() === -1 ? "unlimited" : intval($account->getMaxSubDomain()); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - if(!empty($account->getMaxEmailPerHour())){ |
|
| 786 | + if (!empty($account->getMaxEmailPerHour())) { |
|
| 787 | 787 | $params['MAX_EMAIL_PER_HOUR'] = $account->getMaxEmailPerHour() === -1 ? "unlimited" : intval($account->getMaxEmailPerHour()); |
| 788 | 788 | } |
| 789 | - if(!empty($account->getMaxEmailAccountQuota())){ |
|
| 789 | + if (!empty($account->getMaxEmailAccountQuota())) { |
|
| 790 | 790 | $params['MAX_EMAILACCT_QUOTA'] = $account->getMaxEmailAccountQuota() === -1 ? "unlimited" : intval($account->getMaxDeferFailMailPercentage()); |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - if(!empty($account->getMaxDeferFailMailPercentage())){ |
|
| 793 | + if (!empty($account->getMaxDeferFailMailPercentage())) { |
|
| 794 | 794 | $params['MAX_DEFER_FAIL_PERCENTAGE'] = $account->getMaxDeferFailMailPercentage() === -1 ? "unlimited" : intval($account->getMaxDeferFailMailPercentage()); |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - if(!empty($account->getOwner())){ |
|
| 797 | + if (!empty($account->getOwner())) { |
|
| 798 | 798 | $params['owner'] = $account->getOwner(); |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - if(!empty($account->getDiskLimit())){ |
|
| 801 | + if (!empty($account->getDiskLimit())) { |
|
| 802 | 802 | $params['QUOTA'] = $account->getDiskLimit() === -1 ? "unlimited" : intval($account->getDiskLimit()); |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if($account->isSpamAssassinEnable()){ |
|
| 806 | - $params['spamassassin'] = (int) $account->isSpamAssassinEnable(); |
|
| 805 | + if ($account->isSpamAssassinEnable()) { |
|
| 806 | + $params['spamassassin'] = (int)$account->isSpamAssassinEnable(); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - if($account->isFrontPageEnable()){ |
|
| 810 | - $params['frontpage'] = (int) $account->isFrontPageEnable(); |
|
| 809 | + if ($account->isFrontPageEnable()) { |
|
| 810 | + $params['frontpage'] = (int)$account->isFrontPageEnable(); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - if(!empty($account->getTheme())){ |
|
| 813 | + if (!empty($account->getTheme())) { |
|
| 814 | 814 | $params['RS'] = $account->getTheme(); |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - if(!empty($account->getIpAddress())){ |
|
| 817 | + if (!empty($account->getIpAddress())) { |
|
| 818 | 818 | $params['IP'] = $account->getIpAddress(); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - if(!empty($account->getLanguagePreference())){ |
|
| 821 | + if (!empty($account->getLanguagePreference())) { |
|
| 822 | 822 | $params['LANG'] = $account->getLanguagePreference(); |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if(!empty($account->getMailboxFormat())){ |
|
| 825 | + if (!empty($account->getMailboxFormat())) { |
|
| 826 | 826 | $params['MAILBOX_FORMAT'] = $account->getMailboxFormat(); |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - if(is_bool($account->isOutgoingMailSuspended())){ |
|
| 830 | - $params['OUTGOING_EMAIL_SUSPENDED'] = (int) $account->isOutgoingMailSuspended(); |
|
| 829 | + if (is_bool($account->isOutgoingMailSuspended())) { |
|
| 830 | + $params['OUTGOING_EMAIL_SUSPENDED'] = (int)$account->isOutgoingMailSuspended(); |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $result = $this->client->sendRequest("/json-api/modifyacct", "GET", $params); |
| 834 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 834 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 835 | 835 | return true; |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 838 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 839 | 839 | throw new ClientExceptions($result['metadata']['reason']); |
| 840 | 840 | } |
| 841 | 841 | |
@@ -862,21 +862,21 @@ discard block |
||
| 862 | 862 | 'password' => $newPassword |
| 863 | 863 | ]; |
| 864 | 864 | |
| 865 | - if(isset($digestAuth)){ |
|
| 866 | - $params['digestauth'] = (int) $digestAuth; |
|
| 865 | + if (isset($digestAuth)) { |
|
| 866 | + $params['digestauth'] = (int)$digestAuth; |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | - if(isset($dbPassUpdate)){ |
|
| 870 | - $params['db_pass_update'] = (int) $dbPassUpdate; |
|
| 869 | + if (isset($dbPassUpdate)) { |
|
| 870 | + $params['db_pass_update'] = (int)$dbPassUpdate; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | $result = $this->client->sendRequest("/json-api/passwd", "GET", $params); |
| 874 | 874 | |
| 875 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 875 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 876 | 876 | throw new ClientExceptions($result['metadata']['reason']); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 879 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 880 | 880 | return $result['data']['app']; |
| 881 | 881 | } |
| 882 | 882 | |
@@ -897,14 +897,14 @@ discard block |
||
| 897 | 897 | */ |
| 898 | 898 | public function remove($username, $keepDNS = false) |
| 899 | 899 | { |
| 900 | - $params = ['user' => $username, 'keepdns' => (int) $keepDNS]; |
|
| 900 | + $params = ['user' => $username, 'keepdns' => (int)$keepDNS]; |
|
| 901 | 901 | $result = $this->client->sendRequest("/json-api/removeacct", "GET", $params); |
| 902 | 902 | |
| 903 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 903 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 904 | 904 | throw new ClientExceptions($result['metadata']['reason']); |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 907 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 908 | 908 | return true; |
| 909 | 909 | } |
| 910 | 910 | |
@@ -929,44 +929,44 @@ discard block |
||
| 929 | 929 | public function getBandwidthInfo($month = null, $year = null, $resellerUsername = null, $searchKeyword = null, $searchType = null) |
| 930 | 930 | { |
| 931 | 931 | $params = []; |
| 932 | - if(!empty($searchKeyword)){ |
|
| 932 | + if (!empty($searchKeyword)) { |
|
| 933 | 933 | $params['search'] = $searchKeyword; |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | - if(!empty($searchType) && !in_array($searchType, ["domain", "user", "owner", "ip", "package"])){ |
|
| 936 | + if (!empty($searchType) && !in_array($searchType, ["domain", "user", "owner", "ip", "package"])) { |
|
| 937 | 937 | throw new ClientExceptions("searchType must be one of domain, user, owner, ip and package"); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - if(!empty($searchType)){ |
|
| 940 | + if (!empty($searchType)) { |
|
| 941 | 941 | $params['searchtype'] = $searchType; |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - if(!empty($month) && !is_int($month)){ |
|
| 944 | + if (!empty($month) && !is_int($month)) { |
|
| 945 | 945 | throw new ClientExceptions("month must be an integer"); |
| 946 | 946 | } |
| 947 | - if(!empty($month)){ |
|
| 947 | + if (!empty($month)) { |
|
| 948 | 948 | $params['month'] = intval($month); |
| 949 | 949 | } |
| 950 | 950 | |
| 951 | - if(!empty($year) && !is_int($year)){ |
|
| 951 | + if (!empty($year) && !is_int($year)) { |
|
| 952 | 952 | throw new ClientExceptions("year must be an integer"); |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - if(!empty($year)){ |
|
| 955 | + if (!empty($year)) { |
|
| 956 | 956 | $params['year'] = intval($year); |
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - if(!empty($resellerUsername)){ |
|
| 959 | + if (!empty($resellerUsername)) { |
|
| 960 | 960 | $params['showres'] = $resellerUsername; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | $result = $this->client->sendRequest("/json-api/showbw", "GET", $params); |
| 964 | 964 | |
| 965 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 965 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 966 | 966 | throw new ClientExceptions($result['metadata']['reason']); |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 969 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 970 | 970 | return $result['data']['acct']; |
| 971 | 971 | } |
| 972 | 972 | |
@@ -988,14 +988,14 @@ discard block |
||
| 988 | 988 | */ |
| 989 | 989 | public function suspend($user, $reason, $disallowUnsuspension = true) |
| 990 | 990 | { |
| 991 | - $params = ['user' => $user, 'reason' => $reason, 'disallowun' => (int) $disallowUnsuspension]; |
|
| 991 | + $params = ['user' => $user, 'reason' => $reason, 'disallowun' => (int)$disallowUnsuspension]; |
|
| 992 | 992 | $result = $this->client->sendRequest("/json-api/suspendacct", "GET", $params); |
| 993 | 993 | |
| 994 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 994 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 995 | 995 | throw new ClientExceptions($result['metadata']['reason']); |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 998 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 999 | 999 | return true; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
@@ -1018,11 +1018,11 @@ discard block |
||
| 1018 | 1018 | $params = ['user' => $user]; |
| 1019 | 1019 | $result = $this->client->sendRequest("/json-api/unsuspendacct", "GET", $params); |
| 1020 | 1020 | |
| 1021 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 1021 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 1022 | 1022 | throw new ClientExceptions($result['metadata']['reason']); |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 1025 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 1026 | 1026 | return true; |
| 1027 | 1027 | } |
| 1028 | 1028 | |
@@ -1045,11 +1045,11 @@ discard block |
||
| 1045 | 1045 | $params = ['user' => $username]; |
| 1046 | 1046 | $result = $this->client->sendRequest("/json-api/verify_new_username", "GET", $params); |
| 1047 | 1047 | |
| 1048 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 1048 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 1049 | 1049 | throw new ClientExceptions($result['metadata']['reason']); |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 1){ |
|
| 1052 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 1) { |
|
| 1053 | 1053 | return true; |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | $result = $this->client->sendRequest('/json-api/create_user_session', 'GET', $params); |
| 1079 | 1079 | |
| 1080 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 1080 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 1081 | 1081 | throw new ClientExceptions($result['metadata']['reason']); |
| 1082 | 1082 | } |
| 1083 | 1083 | |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | |
| 1105 | 1105 | $result = $this->client->sendRequest('/json-api/changepackage', 'GET', $params); |
| 1106 | 1106 | |
| 1107 | - if(!empty($result['metadata']) && $result['metadata']['result'] === 0){ |
|
| 1107 | + if (!empty($result['metadata']) && $result['metadata']['result'] === 0) { |
|
| 1108 | 1108 | throw new ClientExceptions($result['metadata']['reason']); |
| 1109 | 1109 | } |
| 1110 | 1110 | |
@@ -1257,7 +1257,7 @@ |
||
| 1257 | 1257 | |
| 1258 | 1258 | $ac->setInodeUsed(intval($account['inodesused'])); |
| 1259 | 1259 | |
| 1260 | - if (! empty($account['has_backup'])) { |
|
| 1260 | + if (!empty($account['has_backup'])) { |
|
| 1261 | 1261 | $ac->setBackup((bool)$account['has_backup']); |
| 1262 | 1262 | } |
| 1263 | 1263 | |