@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | 'from' => $domain, |
| 134 | 134 | 'action' => 'add', |
| 135 | 135 | ]; |
| 136 | - if ($alias) { |
|
| 136 | + if($alias) { |
|
| 137 | 137 | $parameters['alias'] = 'yes'; |
| 138 | 138 | $list = &$this->aliases; |
| 139 | 139 | } else { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public function getDomainNames() |
| 226 | 226 | { |
| 227 | - return $this->getCache('domainNames', function () { |
|
| 227 | + return $this->getCache('domainNames', function() { |
|
| 228 | 228 | $list = array_merge($this->aliases, $this->pointers, [$this->getDomainName()]); |
| 229 | 229 | sort($list); |
| 230 | 230 | return $list; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function getForwarders() |
| 238 | 238 | { |
| 239 | - return $this->getCache(self::CACHE_FORWARDERS, function () { |
|
| 239 | + return $this->getCache(self::CACHE_FORWARDERS, function() { |
|
| 240 | 240 | $forwarders = $this->getContext()->invokeApiGet('EMAIL_FORWARDERS', [ |
| 241 | 241 | 'domain' => $this->getDomainName(), |
| 242 | 242 | ]); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | public function getMailboxes() |
| 251 | 251 | { |
| 252 | - return $this->getCache(self::CACHE_MAILBOXES, function () { |
|
| 252 | + return $this->getCache(self::CACHE_MAILBOXES, function() { |
|
| 253 | 253 | $boxes = $this->getContext()->invokeApiGet('POP', [ |
| 254 | 254 | 'domain' => $this->getDomainName(), |
| 255 | 255 | 'action' => 'full_list', |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function getSubdomains() |
| 281 | 281 | { |
| 282 | - return $this->getCache(self::CACHE_SUBDOMAINS, function () { |
|
| 282 | + return $this->getCache(self::CACHE_SUBDOMAINS, function() { |
|
| 283 | 283 | $subs = $this->getContext()->invokeApiGet('SUBDOMAINS', ['domain' => $this->getDomainName()]); |
| 284 | 284 | $subs = array_combine($subs, $subs); |
| 285 | 285 | return DomainObject::toDomainObjectArray($subs, Subdomain::class, $this); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | 'action' => $action, |
| 302 | 302 | 'domain' => $this->domainName, |
| 303 | 303 | ], $parameters)); |
| 304 | - if ($clearCache) { |
|
| 304 | + if($clearCache) { |
|
| 305 | 305 | $this->clearCache(); |
| 306 | 306 | } |
| 307 | 307 | return $response; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $this->domainName = $config['domain']; |
| 339 | 339 | |
| 340 | 340 | // Determine owner |
| 341 | - if ($config['username'] === $context->getUsername()) { |
|
| 341 | + if($config['username'] === $context->getUsername()) { |
|
| 342 | 342 | $this->owner = $context->getContextUser(); |
| 343 | 343 | } else { |
| 344 | 344 | throw new DirectAdminException('Could not determine relationship between context user and domain'); |
@@ -133,10 +133,13 @@ discard block |
||
| 133 | 133 | 'from' => $domain, |
| 134 | 134 | 'action' => 'add', |
| 135 | 135 | ]; |
| 136 | - if ($alias) { |
|
| 136 | + if ($alias) |
|
| 137 | + { |
|
| 137 | 138 | $parameters['alias'] = 'yes'; |
| 138 | 139 | $list = &$this->aliases; |
| 139 | - } else { |
|
| 140 | + } |
|
| 141 | + else |
|
| 142 | + { |
|
| 140 | 143 | $list = &$this->pointers; |
| 141 | 144 | } |
| 142 | 145 | $this->getContext()->invokeApiPost('DOMAIN_POINTER', $parameters); |
@@ -301,7 +304,8 @@ discard block |
||
| 301 | 304 | 'action' => $action, |
| 302 | 305 | 'domain' => $this->domainName, |
| 303 | 306 | ], $parameters)); |
| 304 | - if ($clearCache) { |
|
| 307 | + if ($clearCache) |
|
| 308 | + { |
|
| 305 | 309 | $this->clearCache(); |
| 306 | 310 | } |
| 307 | 311 | return $response; |
@@ -338,9 +342,12 @@ discard block |
||
| 338 | 342 | $this->domainName = $config['domain']; |
| 339 | 343 | |
| 340 | 344 | // Determine owner |
| 341 | - if ($config['username'] === $context->getUsername()) { |
|
| 345 | + if ($config['username'] === $context->getUsername()) |
|
| 346 | + { |
|
| 342 | 347 | $this->owner = $context->getContextUser(); |
| 343 | - } else { |
|
| 348 | + } |
|
| 349 | + else |
|
| 350 | + { |
|
| 344 | 351 | throw new DirectAdminException('Could not determine relationship between context user and domain'); |
| 345 | 352 | } |
| 346 | 353 | |
@@ -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()->invokeApiGet('DATABASES') as $fullName) { |
|
| 209 | + foreach($this->getSelfManagedContext()->invokeApiGet('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 = BaseObject::toRichObjectArray($this->getContext()->invokeApiGet('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()->invokeApiGet('SHOW_USER_USAGE', ['user' => $this->getUsername()]); |
| 386 | 386 | }); |
| 387 | 387 | } |
@@ -43,7 +43,8 @@ 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 | 48 | $this->setCache(self::CACHE_CONFIG, $config); |
| 48 | 49 | } |
| 49 | 50 | } |
@@ -163,7 +164,8 @@ discard block |
||
| 163 | 164 | */ |
| 164 | 165 | public function getDefaultDomain() |
| 165 | 166 | { |
| 166 | - if (empty($name = $this->getConfig('domain'))) { |
|
| 167 | + if (empty($name = $this->getConfig('domain'))) |
|
| 168 | + { |
|
| 167 | 169 | return null; |
| 168 | 170 | } |
| 169 | 171 | return $this->getDomain($name); |
@@ -206,9 +208,11 @@ discard block |
||
| 206 | 208 | { |
| 207 | 209 | return $this->getCache(self::CACHE_DATABASES, function () { |
| 208 | 210 | $databases = []; |
| 209 | - foreach ($this->getSelfManagedContext()->invokeApiGet('DATABASES') as $fullName) { |
|
| 211 | + foreach ($this->getSelfManagedContext()->invokeApiGet('DATABASES') as $fullName) |
|
| 212 | + { |
|
| 210 | 213 | list($user, $db) = explode('_', $fullName, 2); |
| 211 | - if ($this->getUsername() != $user) { |
|
| 214 | + if ($this->getUsername() != $user) |
|
| 215 | + { |
|
| 212 | 216 | throw new DirectAdminException('Username incorrect on database ' . $fullName); |
| 213 | 217 | } |
| 214 | 218 | $databases[$db] = new Database($db, $this, $this->getSelfManagedContext()); |
@@ -223,7 +227,8 @@ discard block |
||
| 223 | 227 | */ |
| 224 | 228 | public function getDomain($domainName) |
| 225 | 229 | { |
| 226 | - if (!isset($this->domains)) { |
|
| 230 | + if (!isset($this->domains)) |
|
| 231 | + { |
|
| 227 | 232 | $this->getDomains(); |
| 228 | 233 | } |
| 229 | 234 | return isset($this->domains[$domainName]) ? $this->domains[$domainName] : null; |
@@ -234,10 +239,14 @@ discard block |
||
| 234 | 239 | */ |
| 235 | 240 | public function getDomains() |
| 236 | 241 | { |
| 237 | - if (!isset($this->domains)) { |
|
| 238 | - if (!$this->isSelfManaged()) { |
|
| 242 | + if (!isset($this->domains)) |
|
| 243 | + { |
|
| 244 | + if (!$this->isSelfManaged()) |
|
| 245 | + { |
|
| 239 | 246 | $this->domains = $this->impersonate()->getDomains(); |
| 240 | - } else { |
|
| 247 | + } |
|
| 248 | + else |
|
| 249 | + { |
|
| 241 | 250 | $this->domains = BaseObject::toRichObjectArray($this->getContext()->invokeApiGet('ADDITIONAL_DOMAINS'), Domain::class, $this->getContext()); |
| 242 | 251 | } |
| 243 | 252 | } |
@@ -282,7 +291,8 @@ discard block |
||
| 282 | 291 | public function impersonate() |
| 283 | 292 | { |
| 284 | 293 | /** @var ResellerContext $context */ |
| 285 | - if (!($context = $this->getContext()) instanceof ResellerContext) { |
|
| 294 | + if (!($context = $this->getContext()) instanceof ResellerContext) |
|
| 295 | + { |
|
| 286 | 296 | throw new DirectAdminException('You need to be at least a reseller to impersonate'); |
| 287 | 297 | } |
| 288 | 298 | return $context->impersonateUser($this->getUsername()); |
@@ -348,7 +358,8 @@ discard block |
||
| 348 | 358 | public static function fromConfig($config, UserContext $context) |
| 349 | 359 | { |
| 350 | 360 | $name = $config['username']; |
| 351 | - switch ($config['usertype']) { |
|
| 361 | + switch ($config['usertype']) |
|
| 362 | + { |
|
| 352 | 363 | case DirectAdmin::ACCOUNT_TYPE_USER: |
| 353 | 364 | return new self($name, $context, $config); |
| 354 | 365 | case DirectAdmin::ACCOUNT_TYPE_RESELLER: |