Ejemplo n.º 1
0
 /**
  * Add the membership types.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Array contains the id (deprecated).
  *
  *
  * @return object
  */
 public static function add(&$params, $ids = array())
 {
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membershipType', $ids));
     if (!$id) {
         if (!isset($params['is_active'])) {
             // do we need this?
             $params['is_active'] = FALSE;
         }
         if (!isset($params['domain_id'])) {
             $params['domain_id'] = CRM_Core_Config::domainID();
         }
     }
     // action is taken depending upon the mode
     $membershipType = new CRM_Member_DAO_MembershipType();
     $membershipType->copyValues($params);
     $membershipType->id = $id;
     // $previousID is the old organization id for membership type i.e 'member_of_contact_id'. This is used when an organization is changed.
     $previousID = NULL;
     if ($id) {
         $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $id, 'member_of_contact_id');
     }
     $membershipType->save();
     if ($id) {
         // on update we may need to retrieve some details for the price field function - otherwise we get e-notices on attempts to retrieve
         // name etc - the presence of previous id tells us this is an update
         $params = array_merge(civicrm_api3('membership_type', 'getsingle', array('id' => $membershipType->id)), $params);
     }
     self::createMembershipPriceField($params, $previousID, $membershipType->id);
     // update all price field value for quick config when membership type is set CRM-11718
     if ($id) {
         self::updateAllPriceFieldValue($id, $params);
     }
     self::flush();
     return $membershipType;
 }
 /**
  * function to add the membership types
  *
  * @param array $params reference array contains the values submitted by the form
  * @param array $ids    reference array contains the id
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function add(&$params, &$ids)
 {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     // action is taken depending upon the mode
     $membershipType = new CRM_Member_DAO_MembershipType();
     $membershipType->copyValues($params);
     $membershipType->domain_id = CRM_Core_Config::domainID();
     $membershipType->id = CRM_Utils_Array::value('membershipType', $ids);
     $membershipType->member_of_contact_id = CRM_Utils_Array::value('memberOfContact', $ids);
     // $previousID is the old organization id for memberhip type i.e 'member_of_contact_id'. This is used when an oganization is changed.
     $previousID = NULL;
     if ($membershipType->id) {
         $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipType->id, 'member_of_contact_id');
     }
     $membershipType->save();
     self::createMembershipPriceField($params, $ids, $previousID, $membershipType->id);
     return $membershipType;
 }
Ejemplo n.º 3
0
 /**
  * function to add the membership types
  *
  * @param array $params reference array contains the values submitted by the form
  * @param array $ids array contains the id (deprecated)
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function add(&$params, $ids = array())
 {
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membershipType', $ids));
     if (!$id) {
         if (!isset($params['is_active'])) {
             // do we need this?
             $params['is_active'] = FALSE;
         }
         if (!isset($params['domain_id'])) {
             $params['domain_id'] = CRM_Core_Config::domainID();
         }
     }
     // action is taken depending upon the mode
     $membershipType = new CRM_Member_DAO_MembershipType();
     $membershipType->copyValues($params);
     $membershipType->id = $id;
     // $previousID is the old organization id for membership type i.e 'member_of_contact_id'. This is used when an oganization is changed.
     $previousID = NULL;
     if ($membershipType->id) {
         $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipType->id, 'member_of_contact_id');
     }
     $membershipType->save();
     self::createMembershipPriceField($params, $ids, $previousID, $membershipType->id);
     // update all price field value for quick config when membership type is set CRM-11718
     if ($id) {
         self::updateAllPriceFieldValue($id, $params);
     }
     return $membershipType;
 }
Ejemplo n.º 4
0
 /**
  * function to add the membership types
  *
  * @param array $params reference array contains the values submitted by the form
  * @param array $ids    reference array contains the id
  * 
  * @access public
  * @static 
  * @return object
  */
 static function add(&$params, &$ids)
 {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
     // action is taken depending upon the mode
     $membershipType = new CRM_Member_DAO_MembershipType();
     $membershipType->copyValues($params);
     $membershipType->domain_id = CRM_Core_Config::domainID();
     $membershipType->id = CRM_Utils_Array::value('membershipType', $ids);
     $membershipType->member_of_contact_id = CRM_Utils_Array::value('memberOfContact', $ids);
     $membershipType->save();
     return $membershipType;
 }