CRM-14024 - Get rid of redundant fn
authorColeman Watts <coleman@civicrm.org>
Fri, 3 Jan 2014 22:37:50 +0000 (14:37 -0800)
committerColeman Watts <coleman@civicrm.org>
Fri, 3 Jan 2014 22:37:50 +0000 (14:37 -0800)
CRM/Campaign/Page/Petition/Confirm.php
CRM/Contact/BAO/GroupContact.php
CRM/Mailing/Event/BAO/Confirm.php
api/v3/GroupContact.php

index b31f2b1a239fc3379f9ab6152de67d2817f0a190..e7d8829f4348df5a03f151081611bd68b2df7723 100644 (file)
@@ -106,9 +106,12 @@ class CRM_Campaign_Page_Petition_Confirm extends CRM_Core_Page {
     $ce->time_stamp = date('YmdHis');
     $ce->save();
 
-
-    CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus($contact_id, $se->group_id,
-      'Email', $ce->id
+    CRM_Contact_BAO_GroupContact::addContactsToGroup(
+      array($contact_id),
+      $se->group_id,
+      'Email',
+      'Added',
+      $ce->id
     );
 
     $bao = new CRM_Campaign_BAO_Petition();
index 9d23870dd3d3d7719dc59a2c87fba4a009c9a0be..77975561468af11724bae694ee2fe3e1e17c8651 100644 (file)
@@ -120,15 +120,18 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
   /**
    * Given an array of contact ids, add all the contacts to the group
    *
-   * @param array  $contactIds (reference ) the array of contact ids to be added
-   * @param int    $groupId    the id of the group
+   * @param array $contactIds the array of contact ids to be added
+   * @param int $groupId the id of the group
+   * @param string $method
+   * @param string $status
+   * @param int $tracking
    *
    * @return array             (total, added, notAdded) count of contacts added to group
    * @access public
    * @static
    */
   static function addContactsToGroup(
-    &$contactIds,
+    $contactIds,
     $groupId,
     $method   = 'Admin',
     $status   = 'Added',
@@ -466,48 +469,6 @@ SELECT    *
     return $dao;
   }
 
-  /**
-   * Method to update the Status of Group member form 'Pending' to 'Added'
-   *
-   * @param  int  $contactId id of the contact
-   *
-   * @param  int  $groupID   Id of a perticuler group
-   *
-   * @param mixed $tracking   tracking information for history
-   *
-   * @return null If success
-   * @access public
-   * @static
-   */
-  static function updateGroupMembershipStatus($contactId, $groupID, $method = 'Email', $tracking = NULL) {
-    if (!isset($contactId) && !isset($groupID)) {
-      return CRM_Core_Error::fatal("$contactId or $groupID should not empty");
-    }
-
-    $query = "
-UPDATE civicrm_group_contact
-  SET civicrm_group_contact.status = 'Added'
-  WHERE civicrm_group_contact.contact_id = %1
-  AND civicrm_group_contact.group_id = %2";
-    $params = array(
-      1 => array($contactId, 'Integer'),
-      2 => array($groupID, 'Integer'),
-    );
-
-    $dao = CRM_Core_DAO::executeQuery($query, $params);
-
-    $params = array(
-      'contact_id' => $contactId,
-      'group_id' => $groupID,
-      'status' => 'Added',
-      'method' => $method,
-      'tracking' => $tracking,
-    );
-
-    CRM_Contact_BAO_SubscriptionHistory::create($params);
-    return NULL;
-  }
-
   /**
    * Method to get Group Id
    *
index 427216996af26d2ecc3284cc968b448bdc8ccbcf..9b4ce911e791d997cef2e2c9ba261f64d53624e8 100644 (file)
@@ -86,10 +86,11 @@ class CRM_Mailing_Event_BAO_Confirm extends CRM_Mailing_Event_DAO_Confirm {
     $ce->time_stamp = date('YmdHis');
     $ce->save();
 
-    CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus(
-      $contact_id,
+    CRM_Contact_BAO_GroupContact::addContactsToGroup(
+      array($contact_id),
       $se->group_id,
       'Email',
+      'Added',
       $ce->id
     );
 
index 7223ed2c9f53b59b0f261ce26aff4b34482a6bf6..85bfa5494161e65f92198011d82c0a87d3402199 100644 (file)
@@ -228,10 +228,13 @@ function civicrm_api3_group_contact_update_status($params) {
 
   civicrm_api3_verify_mandatory($params, NULL, array('contact_id', 'group_id'));
 
-  $method = CRM_Utils_Array::value('method', $params, 'API');
-  $tracking = CRM_Utils_Array::value('tracking', $params);
-
-  CRM_Contact_BAO_GroupContact::updateGroupMembershipStatus($params['contact_id'], $params['group_id'], $method, $tracking);
+  CRM_Contact_BAO_GroupContact::addContactsToGroup(
+    array($params['contact_id']),
+    $params['group_id'],
+    CRM_Utils_Array::value('method', $params, 'API'),
+    'Added',
+    CRM_Utils_Array::value('tracking', $params)
+  );
 
   return TRUE;
 }