فهرست منبع

add mailinglists

andre 2 سال پیش
والد
کامیت
4b3fdd2ba7
2فایلهای تغییر یافته به همراه34 افزوده شده و 1 حذف شده
  1. 19 0
      api/KerioWhmcs.php
  2. 15 1
      app/UI/Client/DistributionList/Providers/AddListDataProvider.php

+ 19 - 0
api/KerioWhmcs.php

@@ -338,6 +338,25 @@ class KerioWhmcs extends KerioConnectApi {
 		return $result['list'];
 		return $result['list'];
 	}
 	}
 
 
+	/**
+	 * Add users to mailing list
+	 *
+	 * @param   array   List of fields of users to ba added
+	 * @param	string  Mailing list Id
+	 *
+	 * @return	array	List of mailing lists
+	 */
+	public function addMlUserList($members, $mlId) {
+		$method = 'MailingLists.addMlUserList';
+
+		$params['mebers'] = array($members);
+		$params['mlId'] = $mlId;
+
+		$result = $this->sendRequest($method, $params);
+
+		return $result;
+	}
+
 	/**
 	/**
 	 * Get list of resources from a domain
 	 * Get list of resources from a domain
 	 *
 	 *

+ 15 - 1
app/UI/Client/DistributionList/Providers/AddListDataProvider.php

@@ -219,6 +219,20 @@ class AddListDataProvider extends BaseDataProvider
         }
         }
 
 
         $listID = $result[0]['id'];
         $listID = $result[0]['id'];
+
+        try {
+            $result = $api->addMlUserList($paramsAddMembers, $listID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }
+
         $api->logout();
         $api->logout();
 
 
         logModuleCall(
         logModuleCall(
@@ -226,7 +240,7 @@ class AddListDataProvider extends BaseDataProvider
             __FUNCTION__,
             __FUNCTION__,
             $paramsCreate,
             $paramsCreate,
             'Debug add ML',
             'Debug add ML',
-            $listID
+            $paramsAddMembers
         );
         );
 
 
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenAdded')->setStatusSuccess();
         return (new HtmlDataJsonResponse())->setMessageAndTranslate('distributionListHasBeenAdded')->setStatusSuccess();