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


PHP CRM_Event_BAO_Event::find方法代码示例

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


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

示例1: loadRelatedObjects

 /**
  * Load objects relations to contribution object.
  * Objects are stored in the $_relatedObjects property
  * In the first instance we are just moving functionality from BASEIpn -
  * @see http://issues.civicrm.org/jira/browse/CRM-9996
  *
  * Note that the unit test for the BaseIPN class tests this function
  *
  * @param array $input
  *   Input as delivered from Payment Processor.
  * @param array $ids
  *   Ids as Loaded by Payment Processor.
  * @param bool $loadAll
  *   Load all related objects - even where id not passed in? (allows API to call this).
  *
  * @return bool
  * @throws Exception
  */
 public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE)
 {
     if ($loadAll) {
         $ids = array_merge($this->getComponentDetails($this->id), $ids);
         if (empty($ids['contact']) && isset($this->contact_id)) {
             $ids['contact'] = $this->contact_id;
         }
     }
     if (empty($this->_component)) {
         if (!empty($ids['event'])) {
             $this->_component = 'event';
         } else {
             $this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
         }
     }
     // If the object is not fully populated then make sure it is - this is a more about legacy paths & cautious
     // refactoring than anything else, and has unit test coverage.
     if (empty($this->financial_type_id)) {
         $this->find(TRUE);
     }
     $paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $input, CRM_Utils_Array::value('paymentProcessor', $ids));
     if (!$paymentProcessorID && $this->contribution_page_id) {
         $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->contribution_page_id, 'payment_processor');
         if ($paymentProcessorID) {
             $intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage;
         }
     }
     $ids['contributionType'] = $this->financial_type_id;
     $ids['financialType'] = $this->financial_type_id;
     $entities = array('contact' => 'CRM_Contact_BAO_Contact', 'contributionRecur' => 'CRM_Contribute_BAO_ContributionRecur', 'contributionType' => 'CRM_Financial_BAO_FinancialType', 'financialType' => 'CRM_Financial_BAO_FinancialType');
     foreach ($entities as $entity => $bao) {
         if (!empty($ids[$entity])) {
             $this->_relatedObjects[$entity] = new $bao();
             $this->_relatedObjects[$entity]->id = $ids[$entity];
             if (!$this->_relatedObjects[$entity]->find(TRUE)) {
                 throw new CRM_Core_Exception($entity . ' could not be loaded');
             }
         }
     }
     if (!empty($ids['contributionRecur']) && !$paymentProcessorID) {
         $paymentProcessorID = $this->_relatedObjects['contributionRecur']->payment_processor_id;
     }
     if (!empty($ids['pledge_payment'])) {
         foreach ($ids['pledge_payment'] as $key => $paymentID) {
             if (empty($paymentID)) {
                 continue;
             }
             $payment = new CRM_Pledge_BAO_PledgePayment();
             $payment->id = $paymentID;
             if (!$payment->find(TRUE)) {
                 throw new Exception("Could not find pledge payment record: " . $paymentID);
             }
             $this->_relatedObjects['pledge_payment'][] = $payment;
         }
     }
     if ($this->_component == 'contribute') {
         // retrieve the other optional objects first so
         // stuff down the line can use this info and do things
         // CRM-6056
         //in any case get the memberships associated with the contribution
         //because we now support multiple memberships w/ price set
         // see if there are any other memberships to be considered for same contribution.
         $query = "\n            SELECT membership_id\n            FROM   civicrm_membership_payment\nWHERE  contribution_id = %1 ";
         $params = array(1 => array($this->id, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         while ($dao->fetch()) {
             if ($dao->membership_id) {
                 if (!is_array($ids['membership'])) {
                     $ids['membership'] = array();
                 }
                 $ids['membership'][] = $dao->membership_id;
             }
         }
         if (array_key_exists('membership', $ids) && is_array($ids['membership'])) {
             foreach ($ids['membership'] as $id) {
                 if (!empty($id)) {
                     $membership = new CRM_Member_BAO_Membership();
                     $membership->id = $id;
                     if (!$membership->find(TRUE)) {
                         throw new Exception("Could not find membership record: {$id}");
                     }
                     $membership->join_date = CRM_Utils_Date::isoToMysql($membership->join_date);
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例2: loadRelatedObjects

 /**
  * Load objects relations to contribution object.
  * Objects are stored in the $_relatedObjects property
  * In the first instance we are just moving functionality from BASEIpn -
  * @see http://issues.civicrm.org/jira/browse/CRM-9996
  *
  * Note that the unit test for the BaseIPN class tests this function
  *
  * @param array $input
  *   Input as delivered from Payment Processor.
  * @param array $ids
  *   Ids as Loaded by Payment Processor.
  * @param bool $required
  *   Is Payment processor / contribution page required.
  * @param bool $loadAll
  *   Load all related objects - even where id not passed in? (allows API to call this).
  *
  * @return bool
  * @throws Exception
  */
 public function loadRelatedObjects(&$input, &$ids, $required = FALSE, $loadAll = FALSE)
 {
     if ($loadAll) {
         $ids = array_merge($this->getComponentDetails($this->id), $ids);
         if (empty($ids['contact']) && isset($this->contact_id)) {
             $ids['contact'] = $this->contact_id;
         }
     }
     if (empty($this->_component)) {
         if (!empty($ids['event'])) {
             $this->_component = 'event';
         } else {
             $this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
         }
     }
     $paymentProcessorID = CRM_Utils_Array::value('paymentProcessor', $ids);
     $contributionType = new CRM_Financial_BAO_FinancialType();
     $contributionType->id = $this->financial_type_id;
     $contributionType->find(TRUE);
     if (!empty($ids['contact'])) {
         $this->_relatedObjects['contact'] = new CRM_Contact_BAO_Contact();
         $this->_relatedObjects['contact']->id = $ids['contact'];
         $this->_relatedObjects['contact']->find(TRUE);
     }
     $this->_relatedObjects['contributionType'] = $contributionType;
     if ($this->_component == 'contribute') {
         // retrieve the other optional objects first so
         // stuff down the line can use this info and do things
         // CRM-6056
         //in any case get the memberships associated with the contribution
         //because we now support multiple memberships w/ price set
         // see if there are any other memberships to be considered for same contribution.
         $query = "\n            SELECT membership_id\n            FROM   civicrm_membership_payment\nWHERE  contribution_id = %1 ";
         $params = array(1 => array($this->id, 'Integer'));
         $dao = CRM_Core_DAO::executeQuery($query, $params);
         while ($dao->fetch()) {
             if ($dao->membership_id) {
                 if (!is_array($ids['membership'])) {
                     $ids['membership'] = array();
                 }
                 $ids['membership'][] = $dao->membership_id;
             }
         }
         if (array_key_exists('membership', $ids) && is_array($ids['membership'])) {
             foreach ($ids['membership'] as $id) {
                 if (!empty($id)) {
                     $membership = new CRM_Member_BAO_Membership();
                     $membership->id = $id;
                     if (!$membership->find(TRUE)) {
                         throw new Exception("Could not find membership record: {$id}");
                     }
                     $membership->join_date = CRM_Utils_Date::isoToMysql($membership->join_date);
                     $membership->start_date = CRM_Utils_Date::isoToMysql($membership->start_date);
                     $membership->end_date = CRM_Utils_Date::isoToMysql($membership->end_date);
                     $this->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
                     $membership->free();
                 }
             }
         }
         if (!empty($ids['pledge_payment'])) {
             foreach ($ids['pledge_payment'] as $key => $paymentID) {
                 if (empty($paymentID)) {
                     continue;
                 }
                 $payment = new CRM_Pledge_BAO_PledgePayment();
                 $payment->id = $paymentID;
                 if (!$payment->find(TRUE)) {
                     throw new Exception("Could not find pledge payment record: " . $paymentID);
                 }
                 $this->_relatedObjects['pledge_payment'][] = $payment;
             }
         }
         if (!empty($ids['contributionRecur'])) {
             $recur = new CRM_Contribute_BAO_ContributionRecur();
             $recur->id = $ids['contributionRecur'];
             if (!$recur->find(TRUE)) {
                 throw new Exception("Could not find recur record: " . $ids['contributionRecur']);
             }
             $this->_relatedObjects['contributionRecur'] =& $recur;
             //get payment processor id from recur object.
//.........这里部分代码省略.........
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例3: loadRelatedObjects

 /**
  * Load objects relations to contribution object.
  * Objects are stored in the $_relatedObjects property
  * In the first instance we are just moving functionality from BASEIpn -
  * @see http://issues.civicrm.org/jira/browse/CRM-9996
  *
  * Note that the unit test for the BaseIPN class tests this function
  *
  * @param array $input
  *   Input as delivered from Payment Processor.
  * @param array $ids
  *   Ids as Loaded by Payment Processor.
  * @param bool $loadAll
  *   Load all related objects - even where id not passed in? (allows API to call this).
  *
  * @return bool
  * @throws Exception
  */
 public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE)
 {
     if ($loadAll) {
         $ids = array_merge($this->getComponentDetails($this->id), $ids);
         if (empty($ids['contact']) && isset($this->contact_id)) {
             $ids['contact'] = $this->contact_id;
         }
     }
     if (empty($this->_component)) {
         if (!empty($ids['event'])) {
             $this->_component = 'event';
         } else {
             $this->_component = strtolower(CRM_Utils_Array::value('component', $input, 'contribute'));
         }
     }
     // If the object is not fully populated then make sure it is - this is a more about legacy paths & cautious
     // refactoring than anything else, and has unit test coverage.
     if (empty($this->financial_type_id)) {
         $this->find(TRUE);
     }
     $paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $input, CRM_Utils_Array::value('paymentProcessor', $ids));
     if (!$paymentProcessorID && $this->contribution_page_id) {
         $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->contribution_page_id, 'payment_processor');
         if ($paymentProcessorID) {
             $intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage;
         }
     }
     $ids['contributionType'] = $this->financial_type_id;
     $ids['financialType'] = $this->financial_type_id;
     $entities = array('contact' => 'CRM_Contact_BAO_Contact', 'contributionRecur' => 'CRM_Contribute_BAO_ContributionRecur', 'contributionType' => 'CRM_Financial_BAO_FinancialType', 'financialType' => 'CRM_Financial_BAO_FinancialType');
     foreach ($entities as $entity => $bao) {
         if (!empty($ids[$entity])) {
             $this->_relatedObjects[$entity] = new $bao();
             $this->_relatedObjects[$entity]->id = $ids[$entity];
             if (!$this->_relatedObjects[$entity]->find(TRUE)) {
                 throw new CRM_Core_Exception($entity . ' could not be loaded');
             }
         }
     }
     if (!empty($ids['contributionRecur']) && !$paymentProcessorID) {
         $paymentProcessorID = $this->_relatedObjects['contributionRecur']->payment_processor_id;
     }
     if (!empty($ids['pledge_payment'])) {
         foreach ($ids['pledge_payment'] as $key => $paymentID) {
             if (empty($paymentID)) {
                 continue;
             }
             $payment = new CRM_Pledge_BAO_PledgePayment();
             $payment->id = $paymentID;
             if (!$payment->find(TRUE)) {
                 throw new Exception("Could not find pledge payment record: " . $paymentID);
             }
             $this->_relatedObjects['pledge_payment'][] = $payment;
         }
     }
     $this->loadRelatedMembershipObjects($ids);
     if ($this->_component != 'contribute') {
         // we are in event mode
         // make sure event exists and is valid
         $event = new CRM_Event_BAO_Event();
         $event->id = $ids['event'];
         if ($ids['event'] && !$event->find(TRUE)) {
             throw new Exception("Could not find event: " . $ids['event']);
         }
         $this->_relatedObjects['event'] =& $event;
         $participant = new CRM_Event_BAO_Participant();
         $participant->id = $ids['participant'];
         if ($ids['participant'] && !$participant->find(TRUE)) {
             throw new Exception("Could not find participant: " . $ids['participant']);
         }
         $participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date);
         $this->_relatedObjects['participant'] =& $participant;
         // get the payment processor id from event - this is inaccurate see CRM-16923
         // in future we should look at throwing an exception here rather than an dubious guess.
         if (!$paymentProcessorID) {
             $paymentProcessorID = $this->_relatedObjects['event']->payment_processor;
             if ($paymentProcessorID) {
                 $intentionalEnotice = $CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromEvent;
             }
         }
     }
     if ($paymentProcessorID) {
//.........这里部分代码省略.........
开发者ID:joshgowans,项目名称:civicrm-core,代码行数:101,代码来源:Contribution.php

示例4: crm_get_event

/**
 * Get an Event.
 * 
 * This api is used to retrieve all data for an existing Event.
 * Required parameters : id of event
 * 
 * @param  array $params  an associative array of title/value property values of civicrm_event
 * 
 * @return  If successful array of event data; otherwise object of CRM_Core_Error.
 * @access public
 */
function crm_get_event($params)
{
    _crm_initialize();
    if (!is_array($params)) {
        return _crm_error('Params is not an array.');
    }
    if (!isset($params['id'])) {
        return _crm_error('Required id (event ID) parameter is missing.');
    }
    $event = array();
    require_once 'CRM/Event/BAO/Event.php';
    $eventBAO = new CRM_Event_BAO_Event();
    $eventBAO->copyValues($params);
    $eventBAO->find();
    while ($eventBAO->fetch()) {
        $event = array();
        _crm_object_to_array(clone $eventBAO, $event);
        $event[$eventBAO->id] = $event;
    }
    return $event;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:32,代码来源:Event.php

示例5: civicrm_event_search

/**
 * Get Event record.
 * 
 *
 * @param  array  $params     an associative array of name/value property values of civicrm_event
 *
 * @return  Array of all found event property values.
 * @access public
 */
function civicrm_event_search(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array.'));
    }
    $inputParams = array();
    $returnProperties = array();
    $returnCustomProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount');
    $sort = false;
    // don't check if empty, more meaningful error for API user instead of siletn defaults
    $offset = array_key_exists('return.offset', $params) ? $params['return.offset'] : 0;
    $rowCount = array_key_exists('return.max_results', $params) ? $params['return.max_results'] : 25;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            if (substr($n, 0, 14) == 'return.custom_') {
                //take custom return properties separate
                $returnCustomProperties[] = substr($n, 7);
            } elseif (!in_array(substr($n, 7), array('offset', 'max_results'))) {
                $returnProperties[] = substr($n, 7);
            }
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (!empty($returnProperties)) {
        $returnProperties[] = 'id';
        $returnProperties[] = 'event_type_id';
    }
    $returnProperties[] = 'is_template';
    require_once 'CRM/Core/BAO/CustomGroup.php';
    require_once 'CRM/Event/BAO/Event.php';
    $eventDAO = new CRM_Event_BAO_Event();
    $eventDAO->copyValues($inputParams);
    $event = array();
    if (!empty($returnProperties)) {
        $eventDAO->selectAdd();
        $eventDAO->selectAdd(implode(',', $returnProperties));
    }
    $eventDAO->orderBy($sort);
    $eventDAO->limit((int) $offset, (int) $rowCount);
    $eventDAO->find();
    while ($eventDAO->fetch()) {
        // ignore event templates
        // ideally need to put this in the query, but not sure how to do this with the below
        // ( ( is_template IS NULL ) OR ( is_template = 0 ) )
        // hence doing this here for now, please fix on a future rewrite
        if ($eventDAO->is_template) {
            continue;
        }
        $event[$eventDAO->id] = array();
        CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]);
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Event', CRM_Core_DAO::$_nullObject, $eventDAO->id, false, $eventDAO->event_type_id);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                if (!empty($returnCustomProperties)) {
                    $customKey = explode('_', $key);
                    //show only return properties
                    if (in_array('custom_' . $customKey['1'], $returnCustomProperties)) {
                        $event[$eventDAO->id][$key] = $val;
                    }
                } else {
                    $event[$eventDAO->id][$key] = $val;
                }
            }
        }
    }
    //end of the loop
    $eventDAO->free();
    return $event;
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:85,代码来源:Event.php

示例6: civicrm_event_search

/**
 * Get Event record.
 *
 *
 * @param  array  $params     an associative array of name/value property values of civicrm_event
 *
 * @return  Array of all found event property values.
 * @access public
 */
function civicrm_event_search(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array.'));
    }
    $inputParams = array();
    $returnProperties = array();
    $returnCustomProperties = array();
    $otherVars = array('sort', 'offset', 'rowCount', 'isCurrent');
    $sort = array_key_exists('return.sort', $params) ? $params['return.sort'] : FALSE;
    // don't check if empty, more meaningful error for API user instead of silent defaults
    $offset = array_key_exists('return.offset', $params) ? $params['return.offset'] : 0;
    $rowCount = array_key_exists('return.max_results', $params) ? $params['return.max_results'] : 25;
    $isCurrent = array_key_exists('isCurrent', $params) ? $params['isCurrent'] : 0;
    foreach ($params as $n => $v) {
        if (substr($n, 0, 7) == 'return.') {
            if (substr($n, 0, 14) == 'return.custom_') {
                //take custom return properties separate
                $returnCustomProperties[] = substr($n, 7);
            } elseif (!in_array(substr($n, 7), array('sort', 'offset', 'max_results'))) {
                $returnProperties[] = substr($n, 7);
            }
        } elseif (in_array($n, $otherVars)) {
            ${$n} = $v;
        } else {
            $inputParams[$n] = $v;
        }
    }
    if (!empty($returnProperties)) {
        $returnProperties[] = 'id';
        $returnProperties[] = 'event_type_id';
    }
    require_once 'CRM/Core/BAO/CustomGroup.php';
    require_once 'CRM/Event/BAO/Event.php';
    $eventDAO = new CRM_Event_BAO_Event();
    $eventDAO->copyValues($inputParams);
    $event = array();
    if (!empty($returnProperties)) {
        $eventDAO->selectAdd();
        $eventDAO->selectAdd(implode(',', $returnProperties));
    }
    $eventDAO->whereAdd('( is_template IS NULL ) OR ( is_template = 0 )');
    if ($isCurrent) {
        $eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
    }
    $eventDAO->orderBy($sort);
    $eventDAO->limit((int) $offset, (int) $rowCount);
    $eventDAO->find();
    while ($eventDAO->fetch()) {
        $event[$eventDAO->id] = array();
        CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]);
        $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Event', CRM_Core_DAO::$_nullObject, $eventDAO->id, FALSE, $eventDAO->event_type_id);
        $groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, CRM_Core_DAO::$_nullObject);
        $defaults = array();
        CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
        if (!empty($defaults)) {
            foreach ($defaults as $key => $val) {
                if (!empty($returnCustomProperties)) {
                    $customKey = explode('_', $key);
                    //show only return properties
                    if (in_array('custom_' . $customKey['1'], $returnCustomProperties)) {
                        $event[$eventDAO->id][$key] = $val;
                    }
                } else {
                    $event[$eventDAO->id][$key] = $val;
                }
            }
        }
    }
    //end of the loop
    $eventDAO->free();
    return $event;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:82,代码来源:Event.php


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