Changeset View
Changeset View
Standalone View
Standalone View
src/app/Domain.php
Show First 20 Lines • Show All 375 Lines • ▼ Show 20 Lines | public function hash($mod = null): string | ||||
} | } | ||||
$hash = \md5('hkccp-verify-' . $this->namespace); | $hash = \md5('hkccp-verify-' . $this->namespace); | ||||
return $mod === self::HASH_TEXT ? "$cname=$hash" : $hash; | return $mod === self::HASH_TEXT ? "$cname=$hash" : $hash; | ||||
} | } | ||||
/** | /** | ||||
* Checks if there are any objects (users/aliases/groups) in a domain. | |||||
* Note: Public domains are always reported not empty. | |||||
* | |||||
* @return bool True if there are no objects assigned, False otherwise | |||||
*/ | |||||
public function isEmpty(): bool | |||||
{ | |||||
if ($this->isPublic()) { | |||||
return false; | |||||
} | |||||
// FIXME: These queries will not use indexes, so maybe we should consider | |||||
// wallet/entitlements to search in objects that belong to this domain account? | |||||
$suffix = '@' . $this->namespace; | |||||
$suffixLen = strlen($suffix); | |||||
return !( | |||||
\App\User::whereRaw('substr(email, ?) = ?', [-$suffixLen, $suffix])->exists() | |||||
|| \App\UserAlias::whereRaw('substr(alias, ?) = ?', [-$suffixLen, $suffix])->exists() | |||||
|| \App\Group::whereRaw('substr(email, ?) = ?', [-$suffixLen, $suffix])->exists() | |||||
); | |||||
} | |||||
/** | |||||
* Any (additional) properties of this domain. | * Any (additional) properties of this domain. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function settings() | public function settings() | ||||
{ | { | ||||
return $this->hasMany('App\DomainSetting', 'domain_id'); | return $this->hasMany('App\DomainSetting', 'domain_id'); | ||||
} | } | ||||
Show All 39 Lines | public function unsuspend(): void | ||||
$this->status |= Domain::STATUS_ACTIVE; | $this->status |= Domain::STATUS_ACTIVE; | ||||
} | } | ||||
$this->save(); | $this->save(); | ||||
} | } | ||||
/** | /** | ||||
* List the users of a domain, so long as the domain is not a public registration domain. | * List the users of a domain, so long as the domain is not a public registration domain. | ||||
* Note: It returns only users with a mailbox. | |||||
* | * | ||||
* @return array | * @return \App\User[] A list of users | ||||
*/ | */ | ||||
public function users(): array | public function users(): array | ||||
{ | { | ||||
if ($this->isPublic()) { | if ($this->isPublic()) { | ||||
return []; | return []; | ||||
} | } | ||||
$wallet = $this->wallet(); | $wallet = $this->wallet(); | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |