@@ -83,7 +83,7 @@ |
||
83 | 83 | public function deleteAccounts(array $usernames) |
84 | 84 | { |
85 | 85 | $options = ['confirmed' => 'Confirm', 'delete' => 'yes']; |
86 | - foreach (array_values($usernames) as $idx => $username) { |
|
86 | + foreach(array_values($usernames) as $idx => $username) { |
|
87 | 87 | $options["select{$idx}"] = $username; |
88 | 88 | } |
89 | 89 | $this->invokePost('SELECT_USERS', $options); |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | public function __construct(DirectAdmin $connection, $validate = false) |
35 | 35 | { |
36 | 36 | parent::__construct($connection); |
37 | - if ($validate) { |
|
37 | + if($validate) { |
|
38 | 38 | $classMap = [ |
39 | 39 | DirectAdmin::ACCOUNT_TYPE_ADMIN => AdminContext::class, |
40 | 40 | DirectAdmin::ACCOUNT_TYPE_RESELLER => ResellerContext::class, |
41 | 41 | DirectAdmin::ACCOUNT_TYPE_USER => self::class, |
42 | 42 | ]; |
43 | - if ($classMap[$this->getType()] != get_class($this)) { |
|
43 | + if($classMap[$this->getType()] != get_class($this)) { |
|
44 | 44 | throw new DirectAdminException('Validation mismatch on context construction'); |
45 | 45 | } |
46 | 46 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getContextUser() |
65 | 65 | { |
66 | - if (!isset($this->user)) { |
|
66 | + if(!isset($this->user)) { |
|
67 | 67 | $this->user = User::fromConfig($this->invokeGet('SHOW_USER_CONFIG'), $this); |
68 | 68 | } |
69 | 69 | return $this->user; |
@@ -70,7 +70,7 @@ |
||
70 | 70 | */ |
71 | 71 | public static function toDomainObjectArray(array $items, $class, Domain $domain) |
72 | 72 | { |
73 | - array_walk($items, function (&$value, $name) use ($class, $domain) { |
|
73 | + array_walk($items, function(&$value, $name) use ($class, $domain) { |
|
74 | 74 | $value = new $class($name, $domain, $value); |
75 | 75 | }); |
76 | 76 | return $items; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function __construct($name, UserContext $context, $config = null) |
44 | 44 | { |
45 | 45 | parent::__construct($name, $context); |
46 | - if (isset($config)) { |
|
46 | + if(isset($config)) { |
|
47 | 47 | $this->setCache(self::CACHE_CONFIG, $config); |
48 | 48 | } |
49 | 49 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function getDefaultDomain() |
165 | 165 | { |
166 | - if (empty($name = $this->getConfig('domain'))) { |
|
166 | + if(empty($name = $this->getConfig('domain'))) { |
|
167 | 167 | return null; |
168 | 168 | } |
169 | 169 | return $this->getDomain($name); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function getDatabases() |
206 | 206 | { |
207 | - return $this->getCache(self::CACHE_DATABASES, function () { |
|
207 | + return $this->getCache(self::CACHE_DATABASES, function() { |
|
208 | 208 | $databases = []; |
209 | - foreach ($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName) { |
|
209 | + foreach($this->getSelfManagedContext()->invokeGet('DATABASES') as $fullName) { |
|
210 | 210 | list($user, $db) = explode('_', $fullName, 2); |
211 | - if ($this->getUsername() != $user) { |
|
211 | + if($this->getUsername() != $user) { |
|
212 | 212 | throw new DirectAdminException('Username incorrect on database ' . $fullName); |
213 | 213 | } |
214 | 214 | $databases[$db] = new Database($db, $this, $this->getSelfManagedContext()); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function getDomain($domainName) |
225 | 225 | { |
226 | - if (!isset($this->domains)) { |
|
226 | + if(!isset($this->domains)) { |
|
227 | 227 | $this->getDomains(); |
228 | 228 | } |
229 | 229 | return isset($this->domains[$domainName]) ? $this->domains[$domainName] : null; |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function getDomains() |
236 | 236 | { |
237 | - if (!isset($this->domains)) { |
|
238 | - if (!$this->isSelfManaged()) { |
|
237 | + if(!isset($this->domains)) { |
|
238 | + if(!$this->isSelfManaged()) { |
|
239 | 239 | $this->domains = $this->impersonate()->getDomains(); |
240 | 240 | } else { |
241 | 241 | $this->domains = Object::toRichObjectArray($this->getContext()->invokeGet('ADDITIONAL_DOMAINS'), Domain::class, $this->getContext()); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | public function impersonate() |
283 | 283 | { |
284 | 284 | /** @var ResellerContext $context */ |
285 | - if (!($context = $this->getContext()) instanceof ResellerContext) { |
|
285 | + if(!($context = $this->getContext()) instanceof ResellerContext) { |
|
286 | 286 | throw new DirectAdminException('You need to be at least a reseller to impersonate'); |
287 | 287 | } |
288 | 288 | return $context->impersonateUser($this->getUsername()); |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | public static function fromConfig($config, UserContext $context) |
349 | 349 | { |
350 | 350 | $name = $config['username']; |
351 | - switch ($config['usertype']) { |
|
351 | + switch($config['usertype']) { |
|
352 | 352 | case DirectAdmin::ACCOUNT_TYPE_USER: |
353 | 353 | return new self($name, $context, $config); |
354 | 354 | case DirectAdmin::ACCOUNT_TYPE_RESELLER: |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | private function getConfig($item) |
370 | 370 | { |
371 | - return $this->getCacheItem(self::CACHE_CONFIG, $item, function () { |
|
371 | + return $this->getCacheItem(self::CACHE_CONFIG, $item, function() { |
|
372 | 372 | return $this->loadConfig(); |
373 | 373 | }); |
374 | 374 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | private function getUsage($item) |
383 | 383 | { |
384 | - return $this->getCacheItem(self::CACHE_USAGE, $item, function () { |
|
384 | + return $this->getCacheItem(self::CACHE_USAGE, $item, function() { |
|
385 | 385 | return $this->getContext()->invokeGet('SHOW_USER_USAGE', ['user' => $this->getUsername()]); |
386 | 386 | }); |
387 | 387 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | public function impersonate() |
36 | 36 | { |
37 | 37 | /** @var AdminContext $context */ |
38 | - if (!($context = $this->getContext()) instanceof AdminContext) { |
|
38 | + if(!($context = $this->getContext()) instanceof AdminContext) { |
|
39 | 39 | throw new DirectAdminException('You need to be an admin to impersonate another admin'); |
40 | 40 | } |
41 | 41 | return $context->impersonateAdmin($this->getUsername()); |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->domainName = $data['domain']; |
70 | 70 | |
71 | 71 | // Determine owner |
72 | - if ($data['username'] === $context->getUsername()) { |
|
72 | + if($data['username'] === $context->getUsername()) { |
|
73 | 73 | $this->owner = $context->getContextUser(); |
74 | 74 | } else { |
75 | 75 | throw new DirectAdminException('Could not determine relationship between context user and domain'); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | public function getDomainNames() |
221 | 221 | { |
222 | - return $this->getCache('domainNames', function () { |
|
222 | + return $this->getCache('domainNames', function() { |
|
223 | 223 | $list = array_merge($this->aliases, $this->pointers, [$this->getDomainName()]); |
224 | 224 | sort($list); |
225 | 225 | return $list; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function getForwarders() |
233 | 233 | { |
234 | - return $this->getCache(self::CACHE_FORWARDERS, function () { |
|
234 | + return $this->getCache(self::CACHE_FORWARDERS, function() { |
|
235 | 235 | $forwarders = $this->getContext()->invokeGet('EMAIL_FORWARDERS', [ |
236 | 236 | 'domain' => $this->getDomainName(), |
237 | 237 | ]); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getMailboxes() |
246 | 246 | { |
247 | - return $this->getCache(self::CACHE_MAILBOXES, function () { |
|
247 | + return $this->getCache(self::CACHE_MAILBOXES, function() { |
|
248 | 248 | $boxes = $this->getContext()->invokeGet('POP', [ |
249 | 249 | 'domain' => $this->getDomainName(), |
250 | 250 | 'action' => 'full_list', |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function getSubdomains() |
276 | 276 | { |
277 | - return $this->getCache(self::CACHE_SUBDOMAINS, function () { |
|
277 | + return $this->getCache(self::CACHE_SUBDOMAINS, function() { |
|
278 | 278 | $subs = $this->getContext()->invokeGet('SUBDOMAINS', ['domain' => $this->getDomainName()]); |
279 | 279 | $subs = array_combine($subs, $subs); |
280 | 280 | return DomainObject::toDomainObjectArray($subs, Subdomain::class, $this); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | 'action' => $action, |
297 | 297 | 'domain' => $this->domainName, |
298 | 298 | ], $parameters)); |
299 | - if ($clearCache) { |
|
299 | + if($clearCache) { |
|
300 | 300 | $this->clearCache(); |
301 | 301 | } |
302 | 302 | return $response; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function __construct($prefix, Domain $domain, $config = null) |
32 | 32 | { |
33 | 33 | parent::__construct($prefix, $domain); |
34 | - if (isset($config)) { |
|
34 | + if(isset($config)) { |
|
35 | 35 | $this->setCache(self::CACHE_DATA, is_string($config) ? \GuzzleHttp\Psr7\parse_query($config) : $config); |
36 | 36 | } |
37 | 37 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function getData($key) |
120 | 120 | { |
121 | - return $this->getCacheItem(self::CACHE_DATA, $key, function () { |
|
121 | + return $this->getCacheItem(self::CACHE_DATA, $key, function() { |
|
122 | 122 | $result = $this->getContext()->invokeGet('POP', [ |
123 | 123 | 'domain' => $this->getDomainName(), |
124 | 124 | 'action' => 'full_list', |
@@ -77,7 +77,7 @@ |
||
77 | 77 | */ |
78 | 78 | public function getAliases() |
79 | 79 | { |
80 | - return array_map(function ($domain) { |
|
80 | + return array_map(function($domain) { |
|
81 | 81 | return $this->getPrefix() . '@' . $domain; |
82 | 82 | }, $this->getDomain()->getDomainNames()); |
83 | 83 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'action' => 'create', |
58 | 58 | 'name' => $name, |
59 | 59 | ]; |
60 | - if (!empty($password)) { |
|
60 | + if(!empty($password)) { |
|
61 | 61 | $options += ['user' => $username, 'passwd' => $password, 'passwd2' => $password]; |
62 | 62 | } else { |
63 | 63 | $options += ['userlist' => $username]; |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function getAccessHosts() |
85 | 85 | { |
86 | - return $this->getCache(self::CACHE_ACCESS_HOSTS, function () { |
|
86 | + return $this->getCache(self::CACHE_ACCESS_HOSTS, function() { |
|
87 | 87 | $accessHosts = $this->getContext()->invokeGet('DATABASES', [ |
88 | 88 | 'action' => 'accesshosts', |
89 | 89 | 'db' => $this->getDatabaseName(), |
90 | 90 | ]); |
91 | 91 | |
92 | - return array_map(function ($name) { |
|
92 | + return array_map(function($name) { |
|
93 | 93 | return new Database\AccessHost($name, $this); |
94 | 94 | }, $accessHosts); |
95 | 95 | }); |