Loading src/UnicaenZimbra/Processus/BoiteGenerique.php +125 −1 Changes for src/UnicaenZimbra/Processus/BoiteGenerique.php: 125 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -122,6 +122,57 @@ class BoiteGenerique extends Processus return $this; } /** * Renomme une adresse fonctionnelle * * @param string $mail Adresse mail de la boite générique * @param string $adresseFonctionnelle adresse mail de l'adresse fonctionnelle * @param string $newName nouveau nom * @return self */ public function renameAdresseFonctionnelle($mail, $adresseFonctionnelle, $newName) { $afName = $this->getMailName($adresseFonctionnelle); $afNewName = $this->getMailName($newName); // récupération des services $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $distribListService = $this->getServiceManager()->get('zimbraServiceDistributionList'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); // Travail sur la boite générique $bg = $accountService->get($mail); $folderService->setAccount($bg); $filterService->setAccount($bg); // Liste de distribution // la suppression de la liste de distribution permet de supprimer les droits (ACE) sur celle-ci $distribListService->delete($distribListService->get($adresseFonctionnelle)); $distribList = $distribListService->create($newName); $distribListService->addMembers($distribList, $mail); // Répertoires $folderService->rename($folderService->get($afName.' | Réception'), $afNewName.' | Réception'); $folderService->rename($folderService->get($afName.' | Envoi'), $afNewName.' | Envoi'); // Filtre entrant $filter = $filterService->getInput()[$afName.' | Réception']; $filter->setName($afNewName.' | Réception'); $test1 = new FilterTestAddress(); $test1->setHeader('to,cc')->setStringComparison('contains')->setPart('all') ->setValue($newName); $test2 = new FilterTestHeader(); $test2->setHeader('X-Zimbra-DL')->setStringComparison('contains') ->setValue($newName); $filter->setTests(array($test1, $test2)); $filterService->deleteInput($afName.' | Réception'); $filterService->createInput($filter); return $this; } /** * Supprime une adresse fonctionnelle par rapport à la boite générique (paramètre $mail) * Loading Loading @@ -223,7 +274,7 @@ class BoiteGenerique extends Processus $identity->setName($afName); $identity->zimbraPrefFromAddress = $adresseFonctionnelle; $identity->zimbraPrefFromAddressType = 'sendAs'; $identity->zimbraPrefFromDisplay = $adresseFonctionnelle; $identity->zimbraPrefFromDisplay = $afName; $identity->zimbraPrefWhenInFolderIds = $folderService->get($afName.' | Réception')->getId(); $identity->zimbraPrefWhenInFoldersEnabled = true; $identity->zimbraPrefReplyToAddress = $adresseFonctionnelle; Loading @@ -250,6 +301,7 @@ class BoiteGenerique extends Processus $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); $rightService = $this->getServiceManager()->get('zimbraServiceRight'); $identityService = $this->getServiceManager()->get('zimbraServiceIdentity'); // Travail sur la boite générique Loading @@ -271,11 +323,83 @@ class BoiteGenerique extends Processus // Filtres $filterService->deleteOutput($afName.' | Envoi'); // ACE $ace = new Right; $ace->setTarget($distribListService->get($adresseFonctionnelle)) ->setGrantee($userAccount) ->setRightByRightName('sendAsDistList'); $rightService->revokeRight($ace); // Avatar $identityService->delete( $identityService->get($afName) ); return $this; } /** * * @param string $adresseFonctionnelle adresse mail de l'adresse fonctionnelle * @param type $userMail adresse mail de l'utilisateur * @param type $newName nouveau nom * @return self */ public function renameAdresseFonctionnelleToUser($adresseFonctionnelle, $userMail, $newName) { $afName = $this->getMailName($adresseFonctionnelle); $afNewName = $this->getMailName($newName); $distribListService = $this->getServiceManager()->get('zimbraServiceDistributionList'); $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); $rightService = $this->getServiceManager()->get('zimbraServiceRight'); $identityService = $this->getServiceManager()->get('zimbraServiceIdentity'); // Travail sur la boite utilisateur $userAccount = $accountService->get($userMail); $folderService->setAccount($userAccount); $filterService->setAccount($userAccount); $identityService->setAccount($userAccount); // Répertoires $folderService->rename($folderService->get($afName.' | Réception'), $afNewName.' | Réception'); $folderService->rename($folderService->get($afName.' | Envoi'), $afNewName.' | Envoi'); // Filtre sortant $filter = $filterService->getOutput()[$afName.' | Envoi']; $filter->setName($afNewName.' | Envoi'); $test = new FilterTestAddress(); $test->setHeader('from')->setStringComparison('contains')->setPart('all') ->setValue($newName); $filter->setTests(array($test)); $filterService->deleteOutput($afName.' | Envoi'); $filterService->createOutput($filter); // ACE $newAce = new Right(); $newAce->setTarget($distribListService->get($newName)) ->setGrantee($userAccount) ->setRightByRightName('sendAsDistList'); $rightService->grantRight($newAce); // Avatar $identityService->delete($identityService->get($afName)); // suppression ancienne identité $identity = new Identity(); $identity->setName($afNewName); $identity->zimbraPrefFromAddress = $newName; $identity->zimbraPrefFromAddressType = 'sendAs'; $identity->zimbraPrefFromDisplay = $afNewName; $identity->zimbraPrefWhenInFolderIds = $folderService->get($afNewName.' | Réception')->getId(); $identity->zimbraPrefWhenInFoldersEnabled = true; $identity->zimbraPrefReplyToAddress = $newName; $identity->zimbraPrefReplyToEnabled = true; $identity->zimbraPrefWhenSentToAddresses = $newName; $identity->zimbraPrefWhenSentToEnabled = true; $identityService->create($identity); return $this; } /** * Retourne la partie locale d'une adresse mail (tout ce qu'il y a avant le dernier @) * Loading src/UnicaenZimbra/Service/Right.php +6 −0 Changes for src/UnicaenZimbra/Service/Right.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,12 @@ class Right extends Service return true; } /** * Revoke a right on a target to an individual or group grantee. * * @param \UnicaenZimbra\Entity\Right $right * @return boolean */ public function revokeRight(RightEntity $right) { $params = $right->getConvertedToXml(); Loading Loading
src/UnicaenZimbra/Processus/BoiteGenerique.php +125 −1 Changes for src/UnicaenZimbra/Processus/BoiteGenerique.php: 125 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -122,6 +122,57 @@ class BoiteGenerique extends Processus return $this; } /** * Renomme une adresse fonctionnelle * * @param string $mail Adresse mail de la boite générique * @param string $adresseFonctionnelle adresse mail de l'adresse fonctionnelle * @param string $newName nouveau nom * @return self */ public function renameAdresseFonctionnelle($mail, $adresseFonctionnelle, $newName) { $afName = $this->getMailName($adresseFonctionnelle); $afNewName = $this->getMailName($newName); // récupération des services $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $distribListService = $this->getServiceManager()->get('zimbraServiceDistributionList'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); // Travail sur la boite générique $bg = $accountService->get($mail); $folderService->setAccount($bg); $filterService->setAccount($bg); // Liste de distribution // la suppression de la liste de distribution permet de supprimer les droits (ACE) sur celle-ci $distribListService->delete($distribListService->get($adresseFonctionnelle)); $distribList = $distribListService->create($newName); $distribListService->addMembers($distribList, $mail); // Répertoires $folderService->rename($folderService->get($afName.' | Réception'), $afNewName.' | Réception'); $folderService->rename($folderService->get($afName.' | Envoi'), $afNewName.' | Envoi'); // Filtre entrant $filter = $filterService->getInput()[$afName.' | Réception']; $filter->setName($afNewName.' | Réception'); $test1 = new FilterTestAddress(); $test1->setHeader('to,cc')->setStringComparison('contains')->setPart('all') ->setValue($newName); $test2 = new FilterTestHeader(); $test2->setHeader('X-Zimbra-DL')->setStringComparison('contains') ->setValue($newName); $filter->setTests(array($test1, $test2)); $filterService->deleteInput($afName.' | Réception'); $filterService->createInput($filter); return $this; } /** * Supprime une adresse fonctionnelle par rapport à la boite générique (paramètre $mail) * Loading Loading @@ -223,7 +274,7 @@ class BoiteGenerique extends Processus $identity->setName($afName); $identity->zimbraPrefFromAddress = $adresseFonctionnelle; $identity->zimbraPrefFromAddressType = 'sendAs'; $identity->zimbraPrefFromDisplay = $adresseFonctionnelle; $identity->zimbraPrefFromDisplay = $afName; $identity->zimbraPrefWhenInFolderIds = $folderService->get($afName.' | Réception')->getId(); $identity->zimbraPrefWhenInFoldersEnabled = true; $identity->zimbraPrefReplyToAddress = $adresseFonctionnelle; Loading @@ -250,6 +301,7 @@ class BoiteGenerique extends Processus $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); $rightService = $this->getServiceManager()->get('zimbraServiceRight'); $identityService = $this->getServiceManager()->get('zimbraServiceIdentity'); // Travail sur la boite générique Loading @@ -271,11 +323,83 @@ class BoiteGenerique extends Processus // Filtres $filterService->deleteOutput($afName.' | Envoi'); // ACE $ace = new Right; $ace->setTarget($distribListService->get($adresseFonctionnelle)) ->setGrantee($userAccount) ->setRightByRightName('sendAsDistList'); $rightService->revokeRight($ace); // Avatar $identityService->delete( $identityService->get($afName) ); return $this; } /** * * @param string $adresseFonctionnelle adresse mail de l'adresse fonctionnelle * @param type $userMail adresse mail de l'utilisateur * @param type $newName nouveau nom * @return self */ public function renameAdresseFonctionnelleToUser($adresseFonctionnelle, $userMail, $newName) { $afName = $this->getMailName($adresseFonctionnelle); $afNewName = $this->getMailName($newName); $distribListService = $this->getServiceManager()->get('zimbraServiceDistributionList'); $accountService = $this->getServiceManager()->get('zimbraServiceAccount'); $folderService = $this->getServiceManager()->get('zimbraServiceFolder'); $filterService = $this->getServiceManager()->get('zimbraServiceFilter'); $rightService = $this->getServiceManager()->get('zimbraServiceRight'); $identityService = $this->getServiceManager()->get('zimbraServiceIdentity'); // Travail sur la boite utilisateur $userAccount = $accountService->get($userMail); $folderService->setAccount($userAccount); $filterService->setAccount($userAccount); $identityService->setAccount($userAccount); // Répertoires $folderService->rename($folderService->get($afName.' | Réception'), $afNewName.' | Réception'); $folderService->rename($folderService->get($afName.' | Envoi'), $afNewName.' | Envoi'); // Filtre sortant $filter = $filterService->getOutput()[$afName.' | Envoi']; $filter->setName($afNewName.' | Envoi'); $test = new FilterTestAddress(); $test->setHeader('from')->setStringComparison('contains')->setPart('all') ->setValue($newName); $filter->setTests(array($test)); $filterService->deleteOutput($afName.' | Envoi'); $filterService->createOutput($filter); // ACE $newAce = new Right(); $newAce->setTarget($distribListService->get($newName)) ->setGrantee($userAccount) ->setRightByRightName('sendAsDistList'); $rightService->grantRight($newAce); // Avatar $identityService->delete($identityService->get($afName)); // suppression ancienne identité $identity = new Identity(); $identity->setName($afNewName); $identity->zimbraPrefFromAddress = $newName; $identity->zimbraPrefFromAddressType = 'sendAs'; $identity->zimbraPrefFromDisplay = $afNewName; $identity->zimbraPrefWhenInFolderIds = $folderService->get($afNewName.' | Réception')->getId(); $identity->zimbraPrefWhenInFoldersEnabled = true; $identity->zimbraPrefReplyToAddress = $newName; $identity->zimbraPrefReplyToEnabled = true; $identity->zimbraPrefWhenSentToAddresses = $newName; $identity->zimbraPrefWhenSentToEnabled = true; $identityService->create($identity); return $this; } /** * Retourne la partie locale d'une adresse mail (tout ce qu'il y a avant le dernier @) * Loading
src/UnicaenZimbra/Service/Right.php +6 −0 Changes for src/UnicaenZimbra/Service/Right.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -28,6 +28,12 @@ class Right extends Service return true; } /** * Revoke a right on a target to an individual or group grantee. * * @param \UnicaenZimbra\Entity\Right $right * @return boolean */ public function revokeRight(RightEntity $right) { $params = $right->getConvertedToXml(); Loading