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


PHP CRM_Price_BAO_PriceSet::copyPriceSet方法代码示例

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


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

示例1: copy

 /**
  * This function is to make a copy of a Event, including
  * all the fields in the event Wizard
  *
  * @param int $id the event id to copy
  *        obj     $newEvent    object of CRM_Event_DAO_Event
  *        boolean $afterCreate call to copy after the create function
  * @param null $newEvent
  * @param bool $afterCreate
  *
  * @return void
  * @access public
  */
 static function copy($id, $newEvent = NULL, $afterCreate = FALSE)
 {
     $defaults = $eventValues = array();
     //get the require event values.
     $eventParams = array('id' => $id);
     $returnProperties = array('loc_block_id', 'is_show_location', 'default_fee_id', 'default_discount_fee_id', 'is_template');
     CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $eventParams, $eventValues, $returnProperties);
     // since the location is sharable, lets use the same loc_block_id.
     $locBlockId = CRM_Utils_Array::value('loc_block_id', $eventValues);
     $fieldsFix = $afterCreate ? array() : array('prefix' => array('title' => ts('Copy of') . ' '));
     if (empty($eventValues['is_show_location'])) {
         $fieldsFix['prefix']['is_show_location'] = 0;
     }
     if ($newEvent && is_a($newEvent, 'CRM_Event_DAO_Event')) {
         $copyEvent = $newEvent;
     }
     if (!isset($copyEvent)) {
         $copyEvent =& CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', array('id' => $id), array('loc_block_id' => $locBlockId ? $locBlockId : NULL), $fieldsFix);
     }
     CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id);
     $copyUF =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id));
     $copyTellFriend =& CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id));
     $copyPCP =& CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array('entity_id' => $id, 'entity_table' => 'civicrm_event'), array('entity_id' => $copyEvent->id), array('replace' => array('target_entity_id' => $copyEvent->id)));
     if ($eventValues['is_template']) {
         $field = 'event_template';
     } else {
         $field = 'civicrm_event';
     }
     $mappingId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', $field, 'id', 'entity_value');
     $oldData = array('entity_value' => $id, 'mapping_id' => $mappingId);
     if ($copyEvent->is_template == 1) {
         $field = 'event_template';
     } else {
         $field = 'civicrm_event';
     }
     $copyMappingId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', $field, 'id', 'entity_value');
     $newData = array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMappingId);
     $copyReminder =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', $oldData, $newData);
     if (!$afterCreate) {
         //copy custom data
         $extends = array('event');
         $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
         if ($groupTree) {
             foreach ($groupTree as $groupID => $group) {
                 $table[$groupTree[$groupID]['table_name']] = array('entity_id');
                 foreach ($group['fields'] as $fieldID => $field) {
                     $table[$groupTree[$groupID]['table_name']][] = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
                 }
             }
             foreach ($table as $tableName => $tableColumns) {
                 $insert = 'INSERT INTO ' . $tableName . ' (' . implode(', ', $tableColumns) . ') ';
                 $tableColumns[0] = $copyEvent->id;
                 $select = 'SELECT ' . implode(', ', $tableColumns);
                 $from = ' FROM ' . $tableName;
                 $where = " WHERE {$tableName}.entity_id = {$id}";
                 $query = $insert . $select . $from . $where;
                 $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
             }
         }
     }
     $copyEvent->save();
     CRM_Utils_System::flushCache();
     if (!$afterCreate) {
         CRM_Utils_Hook::copy('Event', $copyEvent);
     }
     return $copyEvent;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:80,代码来源:Event.php

示例2: copy

 /**
  * make a copy of a contribution page, including
  * all the blocks in the page
  *
  * @param int $id
  *   The contribution page id to copy.
  *
  * @return CRM_Contribute_DAO_ContributionPage
  */
 public static function copy($id)
 {
     $fieldsFix = array('prefix' => array('title' => ts('Copy of') . ' '));
     $copy =& CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_ContributionPage', array('id' => $id), NULL, $fieldsFix);
     //copying all the blocks pertaining to the contribution page
     $copyPledgeBlock =& CRM_Core_DAO::copyGeneric('CRM_Pledge_DAO_PledgeBlock', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id));
     $copyMembershipBlock =& CRM_Core_DAO::copyGeneric('CRM_Member_DAO_MembershipBlock', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id));
     $copyUFJoin =& CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id));
     $copyWidget =& CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Widget', array('contribution_page_id' => $id), array('contribution_page_id' => $copy->id));
     //copy price sets
     CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_contribution_page', $id, $copy->id);
     $copyTellFriend =& CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id));
     $copyPersonalCampaignPages =& CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id, 'target_entity_id' => $copy->id));
     $copyPremium =& CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Premium', array('entity_id' => $id, 'entity_table' => 'civicrm_contribution_page'), array('entity_id' => $copy->id));
     $premiumQuery = "\nSELECT id\nFROM civicrm_premiums\nWHERE entity_table = 'civicrm_contribution_page'\n      AND entity_id ={$id}";
     $premiumDao = CRM_Core_DAO::executeQuery($premiumQuery, CRM_Core_DAO::$_nullArray);
     while ($premiumDao->fetch()) {
         if ($premiumDao->id) {
             $copyPremiumProduct =& CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_PremiumsProduct', array('premiums_id' => $premiumDao->id), array('premiums_id' => $copyPremium->id));
         }
     }
     $copy->save();
     CRM_Utils_Hook::copy('ContributionPage', $copy);
     return $copy;
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:34,代码来源:ContributionPage.php


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