Merge pull request #5210 from eileenmcnaughton/CRM-15996
[civicrm-core.git] / CRM / Contribute / BAO / ContributionRecur.php
index 5b57460bdef6348893ea8e0335633010163d5bdc..ee81af0b638291f1e2a1deaa213a141f0cbd3e74 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
 class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_ContributionRecur {
 
   /**
-   * Create recurring contribution
+   * Create recurring contribution.
    *
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
    *
-   * @return object activity contact object
-   *
+   * @return object
+   *   activity contact object
    */
   public static function create(&$params) {
     return self::add($params);
   }
 
   /**
-   * Takes an associative array and creates a contribution object
+   * Takes an associative array and creates a contribution object.
    *
    * the function extract all the params it needs to initialize the create a
    * contribution object. the params array could contain additional unused name/value
@@ -57,8 +57,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
    *
-   * @return CRM_Contribute_BAO_Contribution object
-   * @static
+   * @return CRM_Contribute_BAO_Contribution
    * @todo move hook calls / extended logic to create - requires changing calls to call create not add
    */
   public static function add(&$params) {
@@ -105,19 +104,19 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
   }
 
   /**
-   * Check if there is a recurring contribution with the same trxn_id or invoice_id
+   * Check if there is a recurring contribution with the same trxn_id or invoice_id.
    *
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
    * @param array $duplicates
    *   (reference ) store ids of duplicate contribs.
    *
-   * @return boolean true if duplicate, false otherwise
-   * static
+   * @return bool
+   *   true if duplicate, false otherwise
    */
   public static function checkDuplicate($params, &$duplicates) {
-    $id         = CRM_Utils_Array::value('id', $params);
-    $trxn_id    = CRM_Utils_Array::value('trxn_id', $params);
+    $id = CRM_Utils_Array::value('id', $params);
+    $trxn_id = CRM_Utils_Array::value('trxn_id', $params);
     $invoice_id = CRM_Utils_Array::value('invoice_id', $params);
 
     $clause = array();
@@ -143,8 +142,8 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
       $params[3] = array($id, 'Integer');
     }
 
-    $query  = "SELECT id FROM civicrm_contribution_recur WHERE $clause";
-    $dao    = CRM_Core_DAO::executeQuery($query, $params);
+    $query = "SELECT id FROM civicrm_contribution_recur WHERE $clause";
+    $dao = CRM_Core_DAO::executeQuery($query, $params);
     $result = FALSE;
     while ($dao->fetch()) {
       $duplicates[] = $dao->id;
@@ -182,8 +181,8 @@ SELECT r.payment_processor_id
    * @param array $ids
    *   (reference ) an array of recurring contribution ids.
    *
-   * @return array $totalCount an array of recurring ids count
-   * static
+   * @return array
+   *   an array of recurring ids count
    */
   public static function getCount(&$ids) {
     $recurID = implode(',', $ids);
@@ -209,7 +208,6 @@ SELECT r.payment_processor_id
    * @param int $recurId
    *
    * @return bool
-   * @static
    */
   public static function deleteRecurContribution($recurId) {
     $result = FALSE;
@@ -217,9 +215,9 @@ SELECT r.payment_processor_id
       return $result;
     }
 
-    $recur     = new CRM_Contribute_DAO_ContributionRecur();
+    $recur = new CRM_Contribute_DAO_ContributionRecur();
     $recur->id = $recurId;
-    $result    = $recur->delete();
+    $result = $recur->delete();
 
     return $result;
   }
@@ -236,7 +234,6 @@ SELECT r.payment_processor_id
    * @param array $activityParams
    *
    * @return bool
-   * @static
    */
   public static function cancelRecurContribution($recurId, $objects, $activityParams = array()) {
     if (!$recurId) {
@@ -244,9 +241,9 @@ SELECT r.payment_processor_id
     }
 
     $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-    $canceledId         = array_search('Cancelled', $contributionStatus);
-    $recur              = new CRM_Contribute_DAO_ContributionRecur();
-    $recur->id          = $recurId;
+    $canceledId = array_search('Cancelled', $contributionStatus);
+    $recur = new CRM_Contribute_DAO_ContributionRecur();
+    $recur->id = $recurId;
     $recur->whereAdd("contribution_status_id != $canceledId");
 
     if ($recur->find(TRUE)) {
@@ -264,15 +261,15 @@ SELECT r.payment_processor_id
         if ($dao->auto_renew && $dao->membership_id) {
           // its auto-renewal membership mode
           $membershipTypes = CRM_Member_PseudoConstant::membershipType();
-          $membershipType  = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id');
-          $membershipType  = CRM_Utils_Array::value($membershipType, $membershipTypes);
+          $membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id');
+          $membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes);
           $details .= '
 <br/>' . ts('Automatic renewal of %1 membership cancelled.', array(1 => $membershipType));
         }
         else {
           $details .= '
 <br/>' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(
-          1 => $dao->amount,
+              1 => $dao->amount,
               2 => $dao->frequency_interval,
               3 => $dao->frequency_unit,
             ));
@@ -324,14 +321,14 @@ SELECT r.payment_processor_id
   }
 
   /**
-   * Get list of recurring contribution of contact Ids
+   * Get list of recurring contribution of contact Ids.
    *
    * @param int $contactId
    *   Contact ID.
    *
-   * @return array list of recurring contribution fields
+   * @return array
+   *   list of recurring contribution fields
    *
-   * @static
    */
   public static function getRecurContributions($contactId) {
     $params = array();
@@ -459,4 +456,5 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
       }
     }
   }
+
 }