maxEmailAccountCount

This commit is contained in:
yuri
2015-02-26 11:16:57 +02:00
parent 6876bd9a6d
commit fb8a4b90ca
3 changed files with 11 additions and 0 deletions
@@ -96,6 +96,7 @@ return array (
'emailMessageMaxSize' => 10,
'notificationsCheckInterval' => 10,
'disabledCountQueryEntityList' => array('Email'),
'maxEmailAccountCount' => 2,
'isInstalled' => false,
);
@@ -115,6 +115,7 @@ return array (
'ldapTryUsernameSplit',
'ldapOptReferrals',
'ldapCreateEspoUser',
'maxEmailAccountCount'
),
'isInstalled' => false,
);
@@ -94,6 +94,15 @@ class EmailAccount extends Record
public function createEntity($data)
{
if (!$this->getUser()->isAdmin()) {
$count = $this->getEntityManager()->getRepository('EmailAccount')->where(array(
'assignedUserId' => $this->getUser()->id
))->count();
if ($count >= $this->getConfig()->get('maxEmailAccountCount', \PHP_INT_MAX)) {
throw new Forbidden();
}
}
$entity = parent::createEntity($data);
if ($entity) {
if (!$this->getUser()->isAdmin()) {