/** * Creates a new database under the specified user. * * @param User $user Owner of the database * @param string $name Database name, without <user>_ prefix * @param string $username Username to access the database with, without <user>_ prefix * @param string|null $password Password, or null if database user already exists * @return Database Newly created database */ public static function create(User $user, $name, $username, $password) { $options = ['action' => 'create', 'name' => $name]; if (!empty($password)) { $options += ['user' => $username, 'passwd' => $password, 'passwd2' => $password]; } else { $options += ['userlist' => $username]; } $user->getContext()->invokePost('DATABASES', $options); return new self($name, $user, $user->getContext()); }
/** * Returns the actual user object behind the context. * * @return User The user object behind the context */ public function getContextUser() { if (!isset($this->user)) { $this->user = User::fromConfig($this->invokeGet('SHOW_USER_CONFIG'), $this); } return $this->user; }
/** * @depends testDefaultDomain */ public function testCatchall(Domain $domain) { self::$user->setAllowCatchall(true); $domain->setCatchall('*****@*****.**'); $this->assertEquals('*****@*****.**', $domain->getCatchall()); $domain->setCatchall(Domain::CATCHALL_BLACKHOLE); $this->assertEquals(Domain::CATCHALL_BLACKHOLE, $domain->getCatchall()); $domain->setCatchall(Domain::CATCHALL_FAIL); $this->assertEquals(Domain::CATCHALL_FAIL, $domain->getCatchall()); }
/** * {@inheritdoc} */ public function __construct($name, UserContext $context, $config = null) { parent::__construct($name, $context, $config); }
/** * Deletes this domain from the user. */ public function delete() { $this->getContext()->invokePost('DOMAIN', ['delete' => true, 'confirmed' => true, 'select0' => $this->domainName]); $this->owner->clearCache(); }