Changeset View
Changeset View
Standalone View
Standalone View
src/app/Handlers/Mailbox.php
<?php | <?php | ||||
namespace App\Handlers; | namespace App\Handlers; | ||||
class Mailbox extends \App\Handlers\Base | class Mailbox extends \App\Handlers\Base | ||||
{ | { | ||||
/** | |||||
* The entitleable class for this handler. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public static function entitleableClass(): string | public static function entitleableClass(): string | ||||
{ | { | ||||
return \App\User::class; | return \App\User::class; | ||||
} | } | ||||
public static function preReq($entitlement, $user): bool | /** | ||||
* SKU handler metadata. | |||||
* | |||||
* @param \App\Sku $sku The SKU object | |||||
* | |||||
* @return array | |||||
*/ | |||||
public static function metadata(\App\Sku $sku): array | |||||
{ | { | ||||
if (!$entitlement->sku->active) { | $data = parent::metadata($sku); | ||||
\Log::error("Sku not active"); | |||||
return false; | |||||
} | |||||
/* | |||||
FIXME: This code prevents from creating initial mailbox SKU | |||||
on signup of group account, because User::domains() | |||||
does not return the new domain. | |||||
Either we make sure to create domain entitlement before mailbox | |||||
entitlement or make the method here aware of that case or? | |||||
list($local, $domain) = explode('@', $user->email); | |||||
$domains = $user->domains(); | |||||
foreach ($domains as $_domain) { | |||||
if ($domain == $_domain->namespace) { | |||||
return true; | |||||
} | |||||
} | |||||
\Log::info("Domain not for user"); | // Mailbox is always enabled and cannot be unset | ||||
*/ | $data['readonly'] = true; | ||||
return true; | $data['enabled'] = true; | ||||
return $data; | |||||
} | } | ||||
/** | /** | ||||
* The priority that specifies the order of SKUs in UI. | * The priority that specifies the order of SKUs in UI. | ||||
* Higher number means higher on the list. | * Higher number means higher on the list. | ||||
* | * | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
public static function priority(): int | public static function priority(): int | ||||
{ | { | ||||
return 100; | return 100; | ||||
} | } | ||||
} | } |