X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FMember%2FBAO%2FMembershipStatus.php;h=3ecd8ab164ff020fa9f14e6b65c6d242469b6b99;hb=9d4d481e3d8bbf5f5655f257bc11f74eb1ae5808;hp=c2e197e95c1dd78cc7bd356f8b9c897b524aab92;hpb=00be918220e9ac8f6d25d12ed3c9c49fddd07ff7;p=civicrm-core.git diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index c2e197e95c..3ecd8ab164 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -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. | | | @@ -23,38 +23,38 @@ | 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 - * @param array $defaults (reference ) an assoc array to hold the flattened values + * @param array $params + * (reference ) an assoc array of name/value pairs. + * @param array $defaults + * (reference ) an assoc array to hold the flattened values. * - * @return CRM_Member_BAO_MembershipStatus object - * @access public - * @static + * @return CRM_Member_BAO_MembershipStatus */ public static function retrieve(&$params, &$defaults) { $membershipStatus = new CRM_Member_DAO_MembershipStatus(); @@ -67,35 +67,36 @@ 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 - * @param boolean $is_active value we want to set the is_active field + * @param int $id + * Id of the database record. + * @param bool $is_active + * Value we want to set the is_active field. * - * @return Object DAO object on sucess, null otherwise - * @static + * @return Object + * DAO object on sucess, null otherwise */ public static function setIsActive($id, $is_active) { return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipStatus', $id, 'is_active', $is_active); } /** - * 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 (reference ) an assoc array of name/value pairs + * @param array $params + * (reference ) an assoc array of name/value pairs. * * @throws Exception - * @return CRM_Member_BAO_MembershipStatus object - * @access public - * @static + * @return CRM_Member_BAO_MembershipStatus */ - public static function create($params){ + public static function create($params) { $ids = array(); - if(!empty($params['id'])){ - $ids['membershipStatus'] = $params['id']; + if (!empty($params['id'])) { + $ids['membershipStatus'] = $params['id']; } - else{ + else { //don't allow duplicate names - if id not set $status = new CRM_Member_DAO_MembershipStatus(); $status->name = $params['name']; @@ -106,14 +107,15 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { $membershipStatusBAO = CRM_Member_BAO_MembershipStatus::add($params, $ids); return $membershipStatusBAO; } + /** - * Add the membership types + * Add the membership types. * - * @param array $params reference array contains the values submitted by the form - * @param array $ids array contains the id - this param is deprecated + * @param array $params + * Reference array contains the values submitted by the form. + * @param array $ids + * Array contains the id - this param is deprecated. * - * @access public - * @static * * @return object */ @@ -139,8 +141,6 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { ); } - - // action is taken depending upon the mode $membershipStatus = new CRM_Member_DAO_MembershipStatus(); $membershipStatus->copyValues($params); @@ -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,12 +166,11 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { } /** - * Get membership status + * Get membership status. * * @param int $membershipStatusId * * @return array - * @static */ public static function getMembershipStatus($membershipStatusId) { $statusDetails = array(); @@ -183,12 +183,11 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { } /** - * Delete membership Types + * Delete membership Types. * * @param int $membershipStatusId * * @throws CRM_Core_Exception - * @static */ public static function del($membershipStatusId) { //check dependencies @@ -209,30 +208,36 @@ 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(); } /** * Find the membership status based on start date, end date, join date & status date. * - * @param string $startDate start date of the member whose membership status is to be calculated. - * @param string $endDate end date of the member whose membership status is to be calculated. - * @param string $joinDate join date of the member whose membership status is to be calculated. + * @param string $startDate + * Start date of the member whose membership status is to be calculated. + * @param string $endDate + * End date of the member whose membership status is to be calculated. + * @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 boolean $excludeIsAdmin exclude 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 membership params as available to calling function - passed to the hook + * @param array $membership + * Membership params as available to calling function - passed to the hook. * * @return array - @static */ - static function getMembershipStatusByDate($startDate, $endDate, $joinDate, + public static function getMembershipStatusByDate( + $startDate, $endDate, $joinDate, $statusDate = 'today', $excludeIsAdmin = FALSE, $membershipTypeID, $membership = array() ) { $membershipDetails = array(); if (!$statusDate || $statusDate == 'today') { - $statusDate = getDate(); + $statusDate = getdate(); $statusDate = date('Ymd', mktime($statusDate['hours'], $statusDate['minutes'], @@ -296,26 +301,26 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { // add in months if ($membershipStatus->{$eve . '_event_adjust_unit'} == 'month') { ${$eve . 'Event'} = date('Ymd', mktime($hour, $minute, $second, - ${$dat . 'Month'} + $membershipStatus->{$eve . '_event_adjust_interval'}, - ${$dat . 'Day'}, - ${$dat . 'Year'} - )); + ${$dat . 'Month'} + $membershipStatus->{$eve . '_event_adjust_interval'}, + ${$dat . 'Day'}, + ${$dat . 'Year'} + )); } // add in days if ($membershipStatus->{$eve . '_event_adjust_unit'} == 'day') { ${$eve . 'Event'} = date('Ymd', mktime($hour, $minute, $second, - ${$dat . 'Month'}, - ${$dat . 'Day'} + $membershipStatus->{$eve . '_event_adjust_interval'}, - ${$dat . 'Year'} - )); + ${$dat . 'Month'}, + ${$dat . 'Day'} + $membershipStatus->{$eve . '_event_adjust_interval'}, + ${$dat . 'Year'} + )); } // add in years if ($membershipStatus->{$eve . '_event_adjust_unit'} == 'year') { ${$eve . 'Event'} = date('Ymd', mktime($hour, $minute, $second, - ${$dat . 'Month'}, - ${$dat . 'Day'}, - ${$dat . 'Year'} + $membershipStatus->{$eve . '_event_adjust_interval'} - )); + ${$dat . 'Month'}, + ${$dat . 'Day'}, + ${$dat . 'Year'} + $membershipStatus->{$eve . '_event_adjust_interval'} + )); } // if no interval and unit, present } @@ -372,10 +377,9 @@ 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 - @static */ public static function getMembershipStatusCurrent() { $statusIds = array(); @@ -390,5 +394,5 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { $membershipStatus->free(); return $statusIds; } -} +}