adding code to create accounts with quotas (default being 200m)

This commit is contained in:
Alexander Vassilevski 2021-01-23 23:40:17 -08:00
parent 9044313269
commit 68e6718375
2 changed files with 13 additions and 2 deletions

View File

@ -6,6 +6,8 @@ class Config {
const CONFIG_KEY = 'ct_auto_mail_hooks'; const CONFIG_KEY = 'ct_auto_mail_hooks';
const CONFIG_KEY_GLESYS_KEYS="glesys_keys"; const CONFIG_KEY_GLESYS_KEYS="glesys_keys";
const CONFIG_KEY_EMAIL_ADDR_SUFFIX="email_suffix"; const CONFIG_KEY_EMAIL_ADDR_SUFFIX="email_suffix";
const CONFIG_KEY_EMAIL_ADDR_QUOTA_MB="quota";
const DEFAULT_EMAIL_ADDR_QUOTA_MB="200";
private $logger; private $logger;
private $appConfiguration; private $appConfiguration;
private $logContext = ['app' => 'ct_auto_mail_hooks']; private $logContext = ['app' => 'ct_auto_mail_hooks'];
@ -19,7 +21,14 @@ class Config {
public function getEmailAddressSuffix() { public function getEmailAddressSuffix() {
return $this->getConfValue(self::CONFIG_KEY_EMAIL_ADDR_SUFFIX); return $this->getConfValue(self::CONFIG_KEY_EMAIL_ADDR_SUFFIX);
} }
public function getEmailQuotaMB() {
$quota = $this->getConfValue(self::CONFIG_KEY_EMAIL_ADDR_QUOTA_MB);
return is_null($quota) ? self::DEFAULT_EMAIL_ADDR_QUOTA_MB : $quota;
}
private function getConfValue($configKey) { private function getConfValue($configKey) {
if(array_key_exists($configKey, $this->appConfiguration)){
return $this->appConfiguration[$configKey]; return $this->appConfiguration[$configKey];
} }
return NULL;
}
} }

View File

@ -25,11 +25,13 @@ class UserHooks {
$uid = $user->getUID(); $uid = $user->getUID();
$name = $user->getDisplayName(); $name = $user->getDisplayName();
$email_suffix = $this->config->getEmailAddressSuffix(); $email_suffix = $this->config->getEmailAddressSuffix();
$quota = $this->config->getEmailQuotaMB();
$newuser = array( $newuser = array(
'userid' => $uid, 'userid' => $uid,
'password' => $password, 'password' => $password,
'name' => $name, 'name' => $name,
'email' => $uid . $email_suffix 'email' => $uid . $email_suffix,
'quota' => $quota // in MB
); );
$this->logger->warning("newuser:". print_r($newuser,1)); $this->logger->warning("newuser:". print_r($newuser,1));
if($this->createEmailAccount($newuser)) { if($this->createEmailAccount($newuser)) {