当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Member_BAO_Membership::buildOptions方法代码示例

本文整理汇总了PHP中CRM_Member_BAO_Membership::buildOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::buildOptions方法的具体用法?PHP CRM_Member_BAO_Membership::buildOptions怎么用?PHP CRM_Member_BAO_Membership::buildOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Member_BAO_Membership的用法示例。


在下文中一共展示了CRM_Member_BAO_Membership::buildOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * Takes an associative array and creates a membership object.
  *
  * the function extracts all the params it needs to initialize the created
  * membership object. The params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  *
  * @return CRM_Member_BAO_Membership
  */
 public static function add(&$params, $ids = array())
 {
     $oldStatus = $oldType = NULL;
     $params['id'] = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membership', $ids));
     if ($params['id']) {
         CRM_Utils_Hook::pre('edit', 'Membership', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Membership', NULL, $params);
     }
     $id = $params['id'];
     // we do this after the hooks are called in case it has been altered
     if ($id) {
         $membershipObj = new CRM_Member_DAO_Membership();
         $membershipObj->id = $id;
         $membershipObj->find();
         while ($membershipObj->fetch()) {
             $oldStatus = $membershipObj->status_id;
             $oldType = $membershipObj->membership_type_id;
         }
     }
     if (array_key_exists('is_override', $params) && !$params['is_override']) {
         $params['is_override'] = 'null';
     }
     $membership = new CRM_Member_BAO_Membership();
     $membership->copyValues($params);
     $membership->id = $id;
     $membership->save();
     $membership->free();
     if (empty($membership->contact_id) || empty($membership->status_id)) {
         // this means we are in renewal mode and are just updating the membership
         // record or this is an API update call and all fields are not present in the update record
         // however the hooks don't care and want all data CRM-7784
         $tempMembership = new CRM_Member_DAO_Membership();
         $tempMembership->id = $membership->id;
         $tempMembership->find(TRUE);
         $membership = $tempMembership;
     }
     //get the log start date.
     //it is set during renewal of membership.
     $logStartDate = CRM_Utils_Array::value('log_start_date', $params);
     $logStartDate = $logStartDate ? CRM_Utils_Date::isoToMysql($logStartDate) : CRM_Utils_Date::isoToMysql($membership->start_date);
     $values = self::getStatusANDTypeValues($membership->id);
     $membershipLog = array('membership_id' => $membership->id, 'status_id' => $membership->status_id, 'start_date' => $logStartDate, 'end_date' => CRM_Utils_Date::isoToMysql($membership->end_date), 'modified_date' => date('Ymd'), 'membership_type_id' => $values[$membership->id]['membership_type_id'], 'max_related' => $membership->max_related);
     $session = CRM_Core_Session::singleton();
     // If we have an authenticated session, set modified_id to that user's contact_id, else set to membership.contact_id
     if ($session->get('userID')) {
         $membershipLog['modified_id'] = $session->get('userID');
     } elseif (!empty($ids['userId'])) {
         $membershipLog['modified_id'] = $ids['userId'];
     } else {
         $membershipLog['modified_id'] = $membership->contact_id;
     }
     CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
     // reset the group contact cache since smart groups might be affected due to this
     CRM_Contact_BAO_GroupContactCache::remove();
     if ($id) {
         if ($membership->status_id != $oldStatus) {
             $allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get');
             $activityParam = array('subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$membership->status_id]}", 'source_contact_id' => $membershipLog['modified_id'], 'target_contact_id' => $membership->contact_id, 'source_record_id' => $membership->id, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Membership Status'), 'status_id' => 2, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'));
             civicrm_api3('activity', 'create', $activityParam);
         }
         if (isset($membership->membership_type_id) && $membership->membership_type_id != $oldType) {
             $membershipTypes = CRM_Member_BAO_Membership::buildOptions('membership_type_id', 'get');
             $activityParam = array('subject' => "Type changed from {$membershipTypes[$oldType]} to {$membershipTypes[$membership->membership_type_id]}", 'source_contact_id' => $membershipLog['modified_id'], 'target_contact_id' => $membership->contact_id, 'source_record_id' => $membership->id, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Membership Type'), 'status_id' => 2, 'priority_id' => 2, 'activity_date_time' => date('Y-m-d H:i:s'));
             civicrm_api3('activity', 'create', $activityParam);
         }
         CRM_Utils_Hook::post('edit', 'Membership', $membership->id, $membership);
     } else {
         CRM_Utils_Hook::post('create', 'Membership', $membership->id, $membership);
     }
     return $membership;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:86,代码来源:Membership.php

示例2: getMembershipTokenReplacement

 /**
  * Get replacement strings for any membership tokens (only a small number of tokens are implemnted in the first instance
  * - this is used by the pdfLetter task from membership search
  * @param string $token
  * @param array $membership
  *   An api result array for a single membership.
  * @param bool $escapeSmarty
  * @return string
  *   token replacement
  */
 public static function getMembershipTokenReplacement($token, $membership, $escapeSmarty = FALSE)
 {
     $entity = 'membership';
     self::_buildMembershipTokens();
     switch ($token) {
         case 'type':
             $value = $membership['membership_name'];
             break;
         case 'status':
             $statuses = CRM_Member_BAO_Membership::buildOptions('status_id');
             $value = $statuses[$membership['status_id']];
             break;
         case 'fee':
             try {
                 $value = civicrm_api3('membership_type', 'getvalue', array('id' => $membership['membership_type_id'], 'return' => 'minimum_fee'));
             } catch (CiviCRM_API3_Exception $e) {
                 // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the
                 // api handles NULL (4.4)
                 $value = 0;
             }
             break;
         default:
             if (in_array($token, self::$_tokens[$entity])) {
                 $value = $membership[$token];
             } else {
                 // ie unchanged
                 $value = "{$entity}.{$token}";
             }
             break;
     }
     if ($escapeSmarty) {
         $value = self::tokenEscapeSmarty($value);
     }
     return $value;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:45,代码来源:Token.php


注:本文中的CRM_Member_BAO_Membership::buildOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。