Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-07-15-32-51
[civicrm-core.git] / CRM / Contact / BAO / GroupContact.php
index 9d23870dd3d3d7719dc59a2c87fba4a009c9a0be..23bceb8009ea0c1b001185446fbc1c3d9a10d84e 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -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',
@@ -435,7 +438,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact {
    * @access public
    * @static
    */
-  function &getMembershipDetail($contactId, $groupID, $method = 'Email') {
+  static function getMembershipDetail($contactId, $groupID, $method = 'Email') {
     $leftJoin = $where = $orderBy = null;
 
     if ($method) {
@@ -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
    *
@@ -533,7 +494,7 @@ UPDATE civicrm_group_contact
    * @param array $params (reference ) an assoc array of name/value pairs
    * @param array $contactId    contact id
    *
-   * @return none
+   * @return void
    * @access public
    * @static
    */
@@ -574,11 +535,11 @@ UPDATE civicrm_group_contact
 
     // check which values has to be add/remove contact from group
     foreach ($allGroup as $key => $varValue) {
-      if (CRM_Utils_Array::value($key, $params) && !array_key_exists($key, $contactGroup)) {
+      if (!empty($params[$key]) && !array_key_exists($key, $contactGroup)) {
         // add contact to group
         CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $key, $method);
       }
-      elseif (!CRM_Utils_Array::value($key, $params) && array_key_exists($key, $contactGroup)) {
+      elseif (empty($params[$key]) && array_key_exists($key, $contactGroup)) {
         // remove contact from group
         CRM_Contact_BAO_GroupContact::removeContactsFromGroup($contactIds, $key, $method);
       }