Add unit tests to cover date field imports
[civicrm-core.git] / api / v3 / MailingEventSubscribe.php
index 92a8795bdb20f3fd0ef60257ce411faa3466d17b..8e64faa365335488c923ba85c60046679bad88ce 100644 (file)
@@ -38,6 +38,10 @@ function civicrm_api3_mailing_event_subscribe_create($params) {
     throw new API_Exception('Invalid Group id');
   }
 
+  if (substr($group->visibility, 0, 6) != 'Public') {
+    throw new API_Exception('Group is not Public. Contact cannot be subscribed to this Group.');
+  }
+
   $subscribe = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $email, $contact_id);
 
   if ($subscribe !== NULL) {
@@ -66,12 +70,12 @@ function civicrm_api3_mailing_event_subscribe_create($params) {
 function _civicrm_api3_mailing_event_subscribe_create_spec(&$params) {
   $params['email'] = [
     'api.required' => 1,
-    'title' => 'Unsubscribe Email',
+    'title' => 'Subscribe Email',
     'type' => CRM_Utils_Type::T_STRING,
   ];
   $params['group_id'] = [
     'api.required' => 1,
-    'title' => 'Unsubscribe From Group',
+    'title' => 'Subscribe To Group',
     'type' => CRM_Utils_Type::T_INT,
   ];
 }