CRM - 17471 Fix Issue where updated status labels aren't displayed in search
[civicrm-core.git] / CRM / Member / BAO / MembershipStatus.php
index 8d1521c7c50adb16ec288b7b62ed2e67c942994d..3ecd8ab164ff020fa9f14e6b65c6d242469b6b99 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
 class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
 
   /**
-   * Static holder for the default LT
+   * Static holder for the default LT.
    */
   static $_defaultMembershipStatus = NULL;
 
   /**
-   * Class constructor
+   * Class constructor.
    */
   public function __construct() {
     parent::__construct();
   }
 
   /**
-   * Fetch object based on array of properties
+   * Fetch object based on array of properties.
    *
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
@@ -67,7 +67,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Update the is_active flag in the db
+   * Update the is_active flag in the db.
    *
    * @param int $id
    *   Id of the database record.
@@ -82,7 +82,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Takes an associative array and creates a membership Status object
+   * Takes an associative array and creates a membership Status object.
    * See http://wiki.civicrm.org/confluence/display/CRM/Database+layer
    *
    * @param array $params
@@ -109,7 +109,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Add the membership types
+   * Add the membership types.
    *
    * @param array $params
    *   Reference array contains the values submitted by the form.
@@ -148,11 +148,12 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     $membershipStatus->id = $id;
 
     $membershipStatus->save();
+    CRM_Member_PseudoConstant::flush('membershipStatus');
     return $membershipStatus;
   }
 
   /**
-   * Get defaults for new entity
+   * Get defaults for new entity.
    * @return array
    */
   public static function getDefaults() {
@@ -165,7 +166,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Get  membership status
+   * Get  membership status.
    *
    * @param int $membershipStatusId
    *
@@ -182,7 +183,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Delete membership Types
+   * Delete membership Types.
    *
    * @param int $membershipStatusId
    *
@@ -207,6 +208,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     $membershipStatus = new CRM_Member_DAO_MembershipStatus();
     $membershipStatus->id = $membershipStatusId;
     $membershipStatus->delete();
+    CRM_Member_PseudoConstant::flush('membershipStatus');
     $membershipStatus->free();
   }
 
@@ -220,7 +222,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
    * @param string $joinDate
    *   Join date of the member whose membership status is to be calculated.
    * @param \date|string $statusDate status date of the member whose membership status is to be calculated.
-   * @param bool $excludeIsAdminExclude the statuses those having is_admin = 1.
+   * @param bool $excludeIsAdmin the statuses those having is_admin = 1.
    *   Exclude the statuses those having is_admin = 1.
    * @param int $membershipTypeID
    * @param array $membership
@@ -228,7 +230,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
    *
    * @return array
    */
-  static function getMembershipStatusByDate(
+  public static function getMembershipStatusByDate(
     $startDate, $endDate, $joinDate,
     $statusDate = 'today', $excludeIsAdmin = FALSE, $membershipTypeID, $membership = array()
   ) {
@@ -375,7 +377,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
   }
 
   /**
-   * Function that return the status ids whose is_current_member is set
+   * Function that return the status ids whose is_current_member is set.
    *
    * @return array
    */
@@ -392,4 +394,5 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     $membershipStatus->free();
     return $statusIds;
   }
+
 }