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


PHP CRM_Core_BAO_CustomOption::retrieve方法代码示例

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


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

示例1: setDefaultValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  * 
  * @param null
  * 
  * @return array   array of default values
  * @access public
  */
 function setDefaultValues()
 {
     $defaults = array();
     $fieldDefaults = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_CustomOption::retrieve($params, $defaults);
         //$this->_fid = $defaults['custom_field_id'];
         $this->_fid = $defaults['entity_id'];
         $paramsField = array('id' => $this->_fid);
         CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
         if ($fieldDefaults['html_type'] == 'CheckBox' || $fieldDefaults['html_type'] == 'Multi-Select') {
             $defaultCheckValues = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $fieldDefaults['default_value']);
             if (in_array($defaults['value'], $defaultCheckValues)) {
                 $defaults['default_value'] = 1;
             }
         } else {
             if ($fieldDefaults['default_value'] == $defaults['value']) {
                 $defaults['default_value'] = 1;
             }
         }
     } else {
         $defaults['is_active'] = 1;
     }
     require_once 'CRM/Core/DAO.php';
     if ($this->_action & CRM_CORE_ACTION_ADD) {
         $cf =& new CRM_Core_DAO();
         $sql = "SELECT max(weight) as weight\n                    FROM civicrm_custom_option\n                    WHERE entity_table='civicrm_custom_field' AND entity_id=" . $this->_fid . "\n                    ORDER BY weight";
         $cf->query($sql);
         while ($cf->fetch()) {
             $defaults['weight'] = $cf->weight + 1;
         }
         if (empty($defaults['weight'])) {
             $defaults['weight'] = 1;
         }
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:47,代码来源:Option.php

示例2: setDefaultValues

 /**
  * This function sets the default values for the form. Note that in edit/view mode
  * the default values are retrieved from the database
  * 
  * @param null
  * 
  * @return array   array of default values
  * @access public
  */
 function setDefaultValues()
 {
     $defaults = array();
     $fieldDefaults = array();
     if (isset($this->_id)) {
         $params = array('id' => $this->_id);
         CRM_Core_BAO_CustomOption::retrieve($params, $defaults);
         $paramsField = array('id' => $this->_fid);
         CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
         if ($fieldDefaults['html_type'] == 'CheckBox' || $fieldDefaults['html_type'] == 'Multi-Select' || $fieldDefaults['html_type'] == 'AdvMulti-Select') {
             $defaultCheckValues = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($fieldDefaults['default_value'], 1, -1));
             if (in_array($defaults['value'], $defaultCheckValues)) {
                 $defaults['default_value'] = 1;
             }
         } else {
             if (CRM_Utils_Array::value('default_value', $fieldDefaults) == CRM_Utils_Array::value('value', $defaults)) {
                 $defaults['default_value'] = 1;
             }
         }
     } else {
         $defaults['is_active'] = 1;
     }
     require_once 'CRM/Core/DAO.php';
     if ($this->_action & CRM_Core_Action::ADD) {
         $fieldValues = array('option_group_id' => $this->_optionGroupID);
         $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
     }
     return $defaults;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:38,代码来源:Option.php

示例3: setDefaultValues


//.........这里部分代码省略.........
                         }
                     }
                 }
             }
         }
         $form->assign('totalAmount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
         if ($form->_action == CRM_Core_Action::UPDATE) {
             $fee_level = $defaults[$form->_pId]['fee_level'];
             CRM_Event_BAO_Participant::fixEventLevel($fee_level);
             $form->assign("fee_level", $fee_level);
             $form->assign('fee_amount', CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]));
         }
     } else {
         $optionGroupId = null;
         // if user has selected discount use that to set default
         if (isset($form->_discountId)) {
             $defaults[$form->_pId]['discount_id'] = $form->_discountId;
             //hack to set defaults for already selected discount value
             if ($form->_action == CRM_Core_Action::UPDATE && !$form->_originalDiscountId) {
                 $form->_originalDiscountId = $defaults[$form->_pId]['discount_id'];
                 if ($form->_originalDiscountId) {
                     $optionGroupId = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_Discount", $form->_originalDiscountId, 'option_group_id');
                     $defaults[$form->_pId]['discount_id'] = $form->_originalDiscountId;
                 }
             }
         }
         if ($form->_action == CRM_Core_Action::ADD) {
             // this case is for add mode, where we show discount automatically
             if (!isset($form->_discountId)) {
                 require_once 'CRM/Core/BAO/Discount.php';
                 $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event');
             } else {
                 $discountId = $form->_discountId;
             }
             if ($form->_eventId && $discountId) {
                 $defaultDiscountId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $form->_eventId, 'default_discount_fee_id');
                 if ($defaultDiscountId) {
                     $discountKey = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $defaultDiscountId, 'weight');
                 }
                 $defaults[$form->_pId]['discount_id'] = $discountId;
                 $defaults[$form->_pId]['amount'] = key(array_slice($form->_values['discount'][$discountId], $discountKey - 1, $discountKey, true));
                 $optionGroupId = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_Discount", $discountId, 'option_group_id');
             } else {
                 if ($form->_eventId) {
                     $defaults[$form->_pId]['amount'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $form->_eventId, 'default_fee_id');
                 }
             }
         }
         if (CRM_Utils_Array::value('event_id', $defaults[$form->_pId]) && ($form->_action == CRM_Core_Action::UPDATE || $form->_allowConfirmation)) {
             if (!empty($form->_feeBlock)) {
                 $feeLevel = CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]);
                 $feeAmount = CRM_Utils_Array::value('fee_amount', $defaults[$form->_pId]);
                 foreach ($form->_feeBlock as $amountId => $amountInfo) {
                     if ($amountInfo['label'] == $feeLevel && $amountInfo['value'] == $feeAmount) {
                         $defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
                     }
                     // if amount is not set do fuzzy matching
                     if (!isset($defaults[$form->_pId]['amount'])) {
                         // if only level use that
                         if ($amountInfo['label'] == $feeLevel) {
                             $defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
                         } else {
                             if (strpos($feeLevel, $amountInfo['label']) !== false) {
                                 $defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
                             } else {
                                 if ($amountInfo['value'] == $feeAmount) {
                                     // if amount matches use that
                                     $defaults[$form->_pId]['amount'] = $amountInfo['amount_id'];
                                 }
                             }
                         }
                     }
                 }
             }
             if (!isset($defaults[$form->_pId]['amount'])) {
                 // keeping the old code too
                 if (!$optionGroupId) {
                     $optionGroupId = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionGroup", 'civicrm_event.amount.' . $defaults[$form->_pId]['event_id'], 'id', 'name');
                 }
                 $optionParams = array('option_group_id' => $optionGroupId, 'label' => CRM_Utils_Array::value('fee_level', $defaults[$form->_pId]));
                 CRM_Core_BAO_CustomOption::retrieve($optionParams, $params);
                 $defaults[$form->_pId]['amount'] = $params['id'];
             }
         }
         $form->assign("amountId", $defaults[$form->_pId]['amount']);
     }
     //CRM-4453
     $form->assign('fee_currency', $defaults[$form->_pId]['participant_fee_currency']);
     // CRM-4395
     if ($contriId = $form->get('onlinePendingContributionId')) {
         require_once 'CRM/Contribute/DAO/Contribution.php';
         $contribution =& new CRM_Contribute_DAO_Contribution();
         $contribution->id = $contriId;
         $contribution->find(true);
         foreach (array('contribution_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date') as $f) {
             $defaults[$form->_pId][$f] = $contribution->{$f};
         }
     }
     return $defaults[$form->_pId];
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:101,代码来源:EventFees.php


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