/** * Construct the object. * * @param string $name The domain name * @param UserContext $context The owning user context * @param string|array $config The basic config string as returned by CMD_API_ADDITIONAL_DOMAINS */ public function __construct($name, UserContext $context, $config) { parent::__construct($name, $context); // Unpack domain config $data = is_array($config) ? $config : \GuzzleHttp\Psr7\parse_query($config); $this->domainName = $data['domain']; // Determine owner if ($data['username'] === $context->getUsername()) { $this->owner = $context->getContextUser(); } else { throw new DirectAdminException('Could not determine relationship between context user and domain'); } // Parse plain options $bandwidths = array_map('trim', explode('/', $data['bandwidth'])); $this->bandwidthUsed = floatval($bandwidths[0]); $this->bandwidthLimit = ctype_alpha($bandwidths[1]) ? null : floatval($bandwidths[1]); $this->diskUsage = floatval($data['quota']); $this->aliases = array_filter(explode('|', $data['alias_pointers'])); $this->pointers = array_filter(explode('|', $data['pointers'])); }
/** * @return Domain[] */ public function getDomains() { if (!isset($this->domains)) { if (!$this->isSelfManaged()) { $this->domains = $this->impersonate()->getDomains(); } else { $this->domains = BaseObject::toRichObjectArray($this->getContext()->invokeGet('ADDITIONAL_DOMAINS'), Domain::class, $this->getContext()); } } return $this->domains; }
/** * @param string $host * @param Database $database */ public function __construct($host, Database $database) { parent::__construct($host, $database->getContext()); $this->database = $database; }
/** * @return User[] */ public function getUsers() { return BaseObject::toObjectArray($this->getContext()->invokeGet('SHOW_USERS', ['reseller' => $this->getUsername()]), User::class, $this->getContext()); }
/** * Returns the list of known resellers. * * @return Reseller[] */ public function getResellers() { return BaseObject::toObjectArray($this->invokeGet('SHOW_RESELLERS'), Reseller::class, $this); }
/** * Database constructor. * * @param string $name Name of the database * @param User $owner Database owner * @param UserContext $context Context within which the object is valid */ public function __construct($name, User $owner, UserContext $context) { parent::__construct($name, $context); $this->owner = $owner; $this->databaseName = $this->owner->getUsername() . '_' . $this->getName(); }
/** * Returns all users for this reseller. * * @return User[] Associative array of users */ public function getUsers() { return BaseObject::toObjectArray($this->invokeGet('SHOW_USERS'), User::class, $this); }