ソースを参照

add mailinglists

andre 2 年 前
コミット
d3997736d2

+ 3 - 3
app/Enums/Kerio.php

@@ -34,9 +34,9 @@ class Kerio
     /**
      * Kerio statuses
      */
-    const STATUS_ACCEPT     = 'ACCEPT';
-    const STATUS_APPROVAL   = 'APPROVAL';
-    const STATUS_REJECT     = 'REJECT';
+    const STATUS_ACCEPT     = 'Allowed';
+    const STATUS_APPROVAL   = 'Moderated';
+    const STATUS_REJECT     = 'Denied';
 
     const ACC_STATUS_ACTIVE = 'active';
     const ACC_STATUS_LOCKED = 'locked';

+ 46 - 19
app/UI/Client/DistributionList/Providers/AddListDataProvider.php

@@ -89,15 +89,6 @@ class AddListDataProvider extends BaseDataProvider
             Kerio::STATUS_REJECT   => $lang->absoluteT('Automatically reject')
         ];
 
-        /**
-         * unsubscription requests
-         */
-        $this->availableValues['unsubscriptionRequest'] = [
-            Kerio::STATUS_ACCEPT   => $lang->absoluteT('Automatically accept'),
-            Kerio::STATUS_APPROVAL => $lang->absoluteT('Require moderator approval'),
-            Kerio::STATUS_REJECT   => $lang->absoluteT('Automatically reject')
-        ];
-
         $this->availableValues['lang'] = [ 'de' => $lang->absoluteT('german'), 'en' => $lang->absoluteT('english') ];
 
         if($this->formData)
@@ -122,25 +113,61 @@ class AddListDataProvider extends BaseDataProvider
     public function create()
     {
         
-        $myFormData = $this->formData;
-        /**
-         * custom members
-         */
-        $customMembers = explode(',',$this->formData['customMember']);
-
+        // add domain to members
         foreach($this->formData['memberList'] as $member) {
             $memberList[] = $member . '@' . $this->getWhmcsParamByKey('domain');
         }
-        $this->formData['memberList'] = $memberList;
 
+        /**
+         * custom members
+         */
+        $customMembers = explode(',',$this->formData['customMember']);
         foreach($customMembers as $customMember)
         {
             if($customMember !== '' && !in_array($customMember, $this->formData['memberList']))
             {
-                $this->formData['memberList'][]  = $customMember;
+                $customMemberList[] = $customMember;
             }
         }
 
+        $paramsCreate['name'] = $this->formData['listmail'];
+        $paramsCreate['description'] = $this->formData['description'];
+        $paramsCreate['languageId'] = $this->formData['lang'];
+        $paramsCreate['subscription']['type'] = $this->formData['subscriptionRequest'];
+        $paramsCreate['subscription']['moderatorNotification'] = $this->formData['subscriptionNotify'] === 'on' ? TRUE : FALSE;
+        $paramsCreate['replyTo'] = 'OtherAddress';
+        $paramsCreate['OtherAddress'] = $this->formData['replyEmailAddress'];
+        $paramsCreate['posting']['memberPosting'] = $this->formData['memberPosting'];
+        $paramsCreate['posting']['nonMemberPosting'] = $this->formData['nonMemberPosting'];
+        $paramsCreate['posting']['sendErrorsToModerator'] = $this->formData['sendErrorsToModerator'] === 'on' ? TRUE : FALSE;
+
+        if($this->formData['moderator'] != 'none') {
+            $moderator = array(
+                "hasId" => true,
+                "emailAddress" => $this->formData['moderator'],
+                "kind" => "Moderator"
+            );
+        }
+        $paramsAddMembers[] = $moderator;
+
+        foreach($memberList as $member) {
+            $intMembers = array(
+                "hasId" => true,
+                "emailAddress" => $member,
+                "kind" => "Member"
+            );
+        }
+        $paramsAddMembers[] = $intMembers;
+
+        foreach($customMemberList as $customMember) {
+            $extMembers = array(
+                "hasId" => false,
+                "emailAddress" => $customMember,
+                "kind" => "Member"
+            );
+        }
+        $paramsAddMembers[] = $extMembers;
+
         /**
          * hosting id
          */
@@ -149,9 +176,9 @@ class AddListDataProvider extends BaseDataProvider
         logModuleCall(
             'kerioEmail',
             __FUNCTION__,
-            $myFormData,
+            $paramsCreate,
             'Debug add ML',
-            $this->formData
+            $paramsAddMembers
         );
 
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenAdded')->setStatusSuccess();

+ 4 - 2
app/UI/Client/DistributionList/Sections/AddPreferencesDistribution.php

@@ -26,9 +26,11 @@ class AddPreferencesDistribution extends FreeFieldsSection
         /**
          *
          */
-        $this->addField(new Select('lang'));
+        $this->addField(new Select('memberPosting'));
 
-        $this->addField(new Switcher('replyEmail'));
+        $this->addField(new Select('nonMemberPosting'));
+
+        $this->addField(new Switcher('sendErrorsToModerator'));
 
         $this->addField(
             (new Text('replyEmailAddress'))

+ 2 - 2
app/UI/Client/DistributionList/Sections/AddPropertiesDistribution.php

@@ -18,12 +18,12 @@ class AddPropertiesDistribution extends FreeFieldsSection
 
     public function initContent()
     {
+        $this->addField(new Select('lang'));
+
         $this->addField(new Select('moderator'));
 
         $this->addField(new Select('subscriptionRequest'));
 
-        $this->addField(new Select('unsubscriptionRequest'));
-
         $this->addField(new Switcher('subscriptionNotify'));
 
     }