Просмотр исходного кода

Merge branch 'forward' of andre/whmcsZimbraEmail into thurdata

andre 1 год назад
Родитель
Сommit
21b9f229e2

+ 1 - 1
app/Enums/Zimbra.php

@@ -94,7 +94,7 @@ class Zimbra
         'zimbraFeatureSavedSearchesEnabled',
         'zimbraFeaturePeopleSearchEnabled',
         'zimbraFeatureSMIMEEnabled',
-        'zimbraFeatureEwsEnabled'
+        'zimbraFeatureEwsEnabled',
     ];
 
 }

+ 3 - 0
app/Libs/Migrations/Drivers/Version1To2/Settings.php

@@ -104,6 +104,9 @@ class Settings
             'zimbraFeatureWebClientOfflineAccessEnabled',
             'zimbraImapEnabled',
             'zimbraPop3Enabled',
+            'zimbraPrefMailForwardingAddress',
+            'zimbraPrefMailLocalDeliveryDisabled',
+            'zimbraFeatureMailForwardingEnabled',    
         ];
     }
 

+ 1 - 1
app/Libs/Zimbra/Components/Api/Soap/Actions/Account.php

@@ -105,8 +105,8 @@ class Account extends AbstractAction
         {
             $params[] = new SoapVar('<ns1:a n="' . $key . '">' . $value . '</ns1:a>', XSD_ANYXML);
         }
-
         $result = $this->connection->request("ModifyAccountRequest", $params);
+
         $this->setLastResult($result);
 
         if($accountData = $result->getResponseBody()['MODIFYACCOUNTRESPONSE']['ACCOUNT'])

+ 3 - 0
app/Libs/Zimbra/Components/Api/Soap/Models/Account.php

@@ -36,6 +36,9 @@ class Account extends AbstractModel
     const ATTR_DISPLAY_NAME     = 'displayName';
     const ATTR_MAIL_QUOTA       = 'zimbraMailQuota';
     const ATTR_ALIAS            = 'zimbraMailAlias';
+    const ATTR_MAIL_FORWARD     = 'zimbraPrefMailForwardingAddress';
+    const ATTR_DISABLE_LOCAL    = 'zimbraPrefMailLocalDeliveryDisabled';
+    const ATTR_ENABLE_FORWARD   = 'zimbraFeatureMailForwardingEnabled';
     const ATTR_CLASS_OF_SERVICE_ID = 'zimbraCOSId';
 
     protected $id;

+ 1 - 1
app/Libs/Zimbra/Components/Api/Soap/MySoapClient.php

@@ -54,7 +54,7 @@ class MySoapClient extends SoapClient
             $exception = $e;
         
         }
-        
+
         if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) {
         
             //this is where the exception from __doRequest is stored

+ 9 - 0
app/Libs/Zimbra/Components/Api/Soap/Services/Update/UpdateAccount.php

@@ -70,6 +70,15 @@ class UpdateAccount extends CreateAccount
         $account->setAttr(Account::ATTR_COMPANY, $this->formData['company']);
         $account->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);
         $account->setAttr(Account::ATTR_DISPLAY_NAME, $this->formData['display_name']);
+        if ($this->formData['forward'] == 'on') {
+            $account->setAttr(Account::ATTR_MAIL_FORWARD, $this->formData['zimbraPrefMailForwardingAddress']);
+            $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'TRUE');
+            $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'TRUE');
+        } else {
+            $account->setAttr(Account::ATTR_MAIL_FORWARD, NULL);
+            $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'FALSE');
+            $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'FALSE');
+        }
 
         return $account;
 

+ 9 - 0
app/Libs/Zimbra/Components/Api/Soap/Services/Update/UpdateAccountCosQuota.php

@@ -74,6 +74,15 @@ class UpdateAccountCosQuota extends CreateAccountCosQuota
         $account->setAttr(Account::ATTR_COMPANY, $this->formData['company']);
         $account->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);
         $account->setAttr(Account::ATTR_DISPLAY_NAME, $this->formData['display_name']);
+        if ($this->formData['forward'] == 'on') {
+            $account->setAttr(Account::ATTR_MAIL_FORWARD, $this->formData['zimbraPrefMailForwardingAddress']);
+            $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'TRUE');
+            $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'TRUE');
+        } else {
+            $account->setAttr(Account::ATTR_MAIL_FORWARD, NULL);
+            $account->setAttr(Account::ATTR_DISABLE_LOCAL, 'FALSE');
+            $account->setAttr(Account::ATTR_ENABLE_FORWARD, 'FALSE');
+        }
 
         /* @var $cos ClassOfService*/
         $cos = $this->cosModels[$this->formData['cosId']];

+ 6 - 0
app/UI/Admin/ProductConfiguration/Pages/Sections/GeneralFeatures.php

@@ -61,6 +61,9 @@ class GeneralFeatures extends BoxSectionExtended implements AdminArea
         $field = new Switcher('zimbraDumpsterEnabled');
         $left->addField($field);
 
+        $field = new Switcher('zimbraPrefMailLocalDeliveryDisabled');
+        $left->addField($field);
+
         return $left;
 
     }
@@ -96,6 +99,9 @@ class GeneralFeatures extends BoxSectionExtended implements AdminArea
         $field = new Switcher('zimbraDumpsterPurgeEnabled');
         $right->addField($field);
 
+        $field = new Switcher('zimbraFeatureMailForwardingEnabled');
+        $right->addField($field);
+
         return $right;
     }
 

+ 3 - 0
app/UI/Client/EmailAccount/Forms/EditAccountForm.php

@@ -12,6 +12,7 @@ use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Providers\Accou
 use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Providers\EditAccountDataProvider;
 use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Sections\EditAdditionalSection;
 use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Sections\EditGeneralSection;
+use ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Sections\EditForwardSection;
 use ModulesGarden\Servers\ZimbraEmail\Core\UI\Interfaces\ClientArea;
 use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Hidden;
 use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Select;
@@ -51,5 +52,7 @@ class EditAccountForm extends SortedFieldForm implements ClientArea
         $this->addSection(new EditGeneralSection());
 
         $this->addSection(new EditAdditionalSection());
+
+        $this->addSection(new EditForwardSection());
     }
 }

+ 5 - 2
app/UI/Client/EmailAccount/Pages/Accounts.php

@@ -78,6 +78,9 @@ class Accounts extends DataTable implements ClientArea
             ->addColumn((new Column('quota'))
                 ->setOrderable()
                 ->setSearchable(true, Column::TYPE_INT))
+            ->addColumn((new Column('forward'))
+                ->setOrderable()
+                ->setSearchable(true, Column::TYPE_STRING))
             ->addColumn((new Column('status'))
                 ->setOrderable()
                 ->setSearchable(true));
@@ -188,8 +191,8 @@ class Accounts extends DataTable implements ClientArea
                 'date_created' => AccountHelper::getFormattedData($account->getDataResourceA('zimbraCreateTimestamp')),
                 'last_login'   => AccountHelper::getFormattedData($account->getDataResourceA('zimbraLastLogonTimestamp'), 'd/m/Y H:i'),
                 'quota'        => AccountHelper::getQuotaAsMb($account->getDataResourceA('zimbraMailQuota')),
-                'status'       => $account->getDataResourceA('zimbraAccountStatus'),
-
+                'forward'      => $account->getDataResourceA('zimbraPrefMailForwardingAddress'),
+                'status'       => $account->getDataResourceA('zimbraAccountStatus')
             ];
 
             $data[] = $accountArray;

+ 6 - 3
app/UI/Client/EmailAccount/Providers/EditAccountDataProvider.php

@@ -56,7 +56,6 @@ class EditAccountDataProvider extends BaseDataProvider
         {
             throw new \Exception($result->getLastError());
         }
-
         $mailBoxParams              = explode('@', $result->getName());
         $this->data['id']           = $result->getId();
         $this->data['username']     = $mailBoxParams[0];
@@ -79,7 +78,12 @@ class EditAccountDataProvider extends BaseDataProvider
         $this->data['currentCosId'] = $result->getDataResourceA(Account::ATTR_CLASS_OF_SERVICE_ID);
         $this->data['cosId']        = $result->getDataResourceA(Account::ATTR_CLASS_OF_SERVICE_ID);
         $this->data['state']        = $result->getDataResourceA(Account::ATTR_STATE);
-
+        $this->data['zimbraPrefMailForwardingAddress']       = $result->getDataResourceA(Account::ATTR_MAIL_FORWARD);
+        if (empty($this->data['zimbraPrefMailForwardingAddress'])) {
+            $this->data['forward'] = 'off';
+        } else {
+            $this->data['forward'] = 'on';
+        }
         $lang = di('lang');
         $this->availableValues['status'] = [
             Zimbra::ACC_STATUS_ACTIVE        => $lang->absoluteT('zimbra','account','status','active'),
@@ -135,7 +139,6 @@ class EditAccountDataProvider extends BaseDataProvider
             ->setProductManager($productManager)
             ->setFormData($this->formData);
 
-
         /**
          * run service
          */

+ 29 - 0
app/UI/Client/EmailAccount/Sections/EditForwardSection.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace ModulesGarden\Servers\ZimbraEmail\App\UI\Client\EmailAccount\Sections;
+
+
+use ModulesGarden\Servers\ZimbraEmail\App\Traits\FormExtendedTrait;
+use ModulesGarden\Servers\ZimbraEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
+use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Text;
+use ModulesGarden\Servers\ZimbraEmail\Core\UI\Widget\Forms\Fields\Checkbox;
+use ModulesGarden\Servers\ZimbraEmail\App\Validators\EmailValidator;
+
+/**
+ * Class EditForwardSection
+ */
+class EditForwardSection extends FreeFieldsSection
+{
+    protected $id   = 'editForwardSection';
+    protected $name = 'editForwardSection';
+
+    use FormExtendedTrait;
+
+    public function initContent()
+    {
+        $field = new Text('zimbraPrefMailForwardingAddress');
+        $field->addValidator(new EmailValidator());
+        $this->generateDoubleSection([new Checkbox('forward'), $field]);
+    }
+
+}

+ 2 - 1
app/Validators/EmailValidator.php

@@ -23,6 +23,7 @@ class EmailValidator extends BaseValidator
      */
     protected function validate($data, $additionalData = null)
     {
+
         /**
          * if is empty
          */
@@ -34,7 +35,7 @@ class EmailValidator extends BaseValidator
         /**
          * check if correct email
          */
-        if (filter_var($data, FILTER_VALIDATE_EMAIL))
+        if (!filter_var($data, FILTER_VALIDATE_EMAIL))
         {
             $this->addValidationError('incorrectEmailAddress');
             return false;

+ 5 - 0
langs/english.php

@@ -282,6 +282,7 @@ $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['mailbox
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['date_created'] = 'Date Created';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['last_login'] = 'Last Login';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['quota'] = 'Quota (MB)';
+$_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['forward'] = 'Forward';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['status'] = 'Status';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['editAccountButton']['button']['editAccountButton'] = 'Edit';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['deleteAccountButton']['button']['deleteAccountButton'] = 'Delete';
@@ -306,6 +307,7 @@ $_LANG['addonCA']['ressource']['ressources']['actions']['Additional Actions'] =
 $_LANG['addonCA']['emailAccount']['addAccountModal']['modal']['addAccountModal'] = 'Add Email Account';
 $_LANG['addonCA']['emailAccount']['addAccountModal']['generalSection'] = 'General';
 $_LANG['addonCA']['emailAccount']['addAccountModal']['additionalSection'] = 'Additional Information';
+$_LANG['addonCA']['emailAccount']['addAccountModal']['forwardSection'] = 'Forwarding';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['generated_row_section_0']['generated_0_0']['firstname']['firstname'] = 'First Name';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['generated_row_section_0']['generated_0_1']['lastname']['lastname'] = 'Last Name';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['usernameGroup']['usernameGroup'] = 'Username *';
@@ -425,6 +427,7 @@ $_LANG['ressourceHasBeenDeleted'] = 'Resource has been deleted successfully';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['editGeneralSection'] = 'General';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['editAdditionalSection'] = 'Additional Information';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['modal']['editAccountModal'] = 'Edit Account';
+$_LANG['addonCA']['emailAccount']['editAccountModal']['editForwardSection'] = 'Forwarding';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editGeneralSection']['generated_row_section_0']['generated_0_0']['firstname']['firstname'] = 'First Name';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editGeneralSection']['generated_row_section_0']['generated_0_1']['lastname']['lastname'] = 'Last Name';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editGeneralSection']['usernameGroup']['usernameGroup'] = 'Username';
@@ -442,6 +445,8 @@ $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['g
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['generated_row_section_4']['generated_4_0']['city']['city'] = 'City';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['generated_row_section_4']['generated_4_1']['street']['street'] = 'Street';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['post_code']['post_code'] = 'Postal Code';
+$_LANG['addonCA']['emailAccount']['editAccountForm']['editForwardSection']['generated_row_section_0']['generated_0_0']['forward']['forward'] = 'Forwarding enabled';
+$_LANG['addonCA']['emailAccount']['editAccountForm']['editForwardSection']['generated_row_section_0']['generated_0_1']['zimbraPrefMailForwardingAddress']['zimbraPrefMailForwardingAddress'] = 'Target Address';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['baseAcceptButton']['title'] = 'Confirm';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['baseCancelButton']['title'] = 'Cancel';
 

+ 5 - 0
langs/german.php

@@ -282,6 +282,7 @@ $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['mailbox
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['date_created'] = 'Erstellungsdatum';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['last_login'] = 'Letztes Login';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['quota'] = 'Quota (MB)';
+$_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['forward'] = 'Weiterleitung';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['table']['status'] = 'Status';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['editAccountButton']['button']['editAccountButton'] = 'Editieren';
 $_LANG['addonCA']['emailAccount']['mainContainer']['accounts']['deleteAccountButton']['button']['deleteAccountButton'] = 'Löschen';
@@ -306,6 +307,7 @@ $_LANG['addonCA']['ressource']['ressources']['actions']['Additional Actions'] =
 $_LANG['addonCA']['emailAccount']['addAccountModal']['modal']['addAccountModal'] = 'Neuer Email Account hinzufügen';
 $_LANG['addonCA']['emailAccount']['addAccountModal']['generalSection'] = 'Allgemein';
 $_LANG['addonCA']['emailAccount']['addAccountModal']['additionalSection'] = 'Zusätzliche Informationen';
+$_LANG['addonCA']['emailAccount']['addAccountModal']['forwardSection'] = 'E-Mail Weiterleitung';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['generated_row_section_0']['generated_0_0']['firstname']['firstname'] = 'Vorname';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['generated_row_section_0']['generated_0_1']['lastname']['lastname'] = 'Nachname';
 $_LANG['addonCA']['emailAccount']['addAccountForm']['generalSection']['usernameGroup']['usernameGroup'] = 'Benutzername *';
@@ -424,6 +426,7 @@ $_LANG['ressourceHasBeenDeleted'] = 'Die Ressource wurde erfolgreich gelöscht';
 
 $_LANG['addonCA']['emailAccount']['editAccountModal']['editGeneralSection'] = 'Allgemein';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['editAdditionalSection'] = 'Zusätzliche Informationen';
+$_LANG['addonCA']['emailAccount']['editAccountModal']['editForwardSection'] = 'E-Mail Weiterleitung';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['modal']['editAccountModal'] = 'Account bearbeiten';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editGeneralSection']['generated_row_section_0']['generated_0_0']['firstname']['firstname'] = 'Vorname';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editGeneralSection']['generated_row_section_0']['generated_0_1']['lastname']['lastname'] = 'Nachname';
@@ -442,6 +445,8 @@ $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['g
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['generated_row_section_4']['generated_4_0']['city']['city'] = 'Stadt';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['generated_row_section_4']['generated_4_1']['street']['street'] = 'Strasse';
 $_LANG['addonCA']['emailAccount']['editAccountForm']['editAdditionalSection']['post_code']['post_code'] = 'PLZ';
+$_LANG['addonCA']['emailAccount']['editAccountForm']['editForwardSection']['generated_row_section_0']['generated_0_0']['forward']['forward'] = 'Weiterleitung aktivieren';
+$_LANG['addonCA']['emailAccount']['editAccountForm']['editForwardSection']['generated_row_section_0']['generated_0_1']['zimbraPrefMailForwardingAddress']['zimbraPrefMailForwardingAddress'] = 'Ziel E-Mail Adresse';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['baseAcceptButton']['title'] = 'Bestätigen';
 $_LANG['addonCA']['emailAccount']['editAccountModal']['baseCancelButton']['title'] = 'Abbrechen';