本文整理汇总了PHP中CRM_Event_BAO_Event类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_BAO_Event类的具体用法?PHP CRM_Event_BAO_Event怎么用?PHP CRM_Event_BAO_Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Event_BAO_Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieveEvent
protected function retrieveEvent($eventID)
{
$bao = new CRM_Event_BAO_Event();
if ($bao->get('id', $eventID)) {
return $bao;
}
return NULL;
}
示例2: buildForm
/**
* @param CRM_Core_Form $form
*/
public function buildForm(&$form)
{
/**
* You can define a custom title for the search form
*/
$this->setTitle('Find Totals for Events');
/**
* Define the search form fields here
*/
$form->addElement('checkbox', 'paid_online', ts('Only show Credit Card Payments'));
$form->addElement('checkbox', 'show_payees', ts('Show payees'));
$event_type = CRM_Core_OptionGroup::values('event_type', FALSE);
foreach ($event_type as $eventId => $eventName) {
$form->addElement('checkbox', "event_type_id[{$eventId}]", 'Event Type', $eventName);
}
$events = CRM_Event_BAO_Event::getEvents(1);
$form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events);
$form->addDate('start_date', ts('Payments Date From'), FALSE, array('formatType' => 'custom'));
$form->addDate('end_date', ts('...through'), FALSE, array('formatType' => 'custom'));
/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id'));
}
示例3: postProcess
public function postProcess()
{
$params = $this->exportValues();
$params['id'] = $this->_id;
CRM_Event_BAO_Event::add($params);
parent::endPostProcess();
}
示例4: registerParticipant
/**
* @param array $params
* @param $participant
* @param $event
*
* @return mixed
*/
public function registerParticipant($params, &$participant, $event)
{
$transaction = new CRM_Core_Transaction();
// handle register date CRM-4320
$registerDate = date('YmdHis');
$participantParams = array('id' => $participant->id, 'event_id' => $event->id, 'register_date' => $registerDate, 'source' => CRM_Utils_Array::value('participant_source', $params, $this->description), 'is_pay_later' => $this->is_pay_later, 'fee_amount' => CRM_Utils_Array::value('amount', $params, 0), 'fee_currency' => CRM_Utils_Array::value('currencyID', $params));
if ($participant->must_wait) {
$participant_status = 'On waitlist';
} elseif (CRM_Utils_Array::value('is_pay_later', $params, FALSE)) {
$participant_status = 'Pending from pay later';
} else {
$participant_status = 'Registered';
}
$participant_statuses = CRM_Event_PseudoConstant::participantStatus();
$participantParams['status_id'] = array_search($participant_status, $participant_statuses);
$participant_status_label = CRM_Utils_Array::value($participantParams['status_id'], CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'));
$participantParams['participant_status'] = $participant_status_label;
$this->assign('isOnWaitlist', $participant->must_wait);
if ($this->_action & CRM_Core_Action::PREVIEW || CRM_Utils_Array::value('mode', $params) == 'test') {
$participantParams['is_test'] = 1;
} else {
$participantParams['is_test'] = 0;
}
if (self::is_administrator()) {
if (!empty($params['note'])) {
$note_params = array('participant_id' => $participant->id, 'contact_id' => self::getContactID(), 'note' => $params['note']);
CRM_Event_BAO_Participant::update_note($note_params);
}
}
$participant->copyValues($participantParams);
$participant->save();
if (!empty($params['contributionID'])) {
$payment_params = array('participant_id' => $participant->id, 'contribution_id' => $params['contributionID']);
$ids = array();
$paymentParticpant = CRM_Event_BAO_ParticipantPayment::create($payment_params, $ids);
}
$transaction->commit();
$event_values = array();
CRM_Core_DAO::storeValues($event, $event_values);
$location = array();
if (CRM_Utils_Array::value('is_show_location', $event_values) == 1) {
$locationParams = array('entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event');
$location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
CRM_Core_BAO_Address::fixAddress($location['address'][1]);
}
list($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id);
$payer_values = array('email' => '', 'name' => '');
if ($this->payer_contact_id) {
$payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
$payer_values = array('email' => $payer_contact_details[1], 'name' => $payer_contact_details[0]);
}
$values = array('params' => array($participant->id => $participantParams), 'event' => $event_values, 'location' => $location, 'custom_pre_id' => $pre_id, 'custom_post_id' => $post_id, 'payer' => $payer_values);
CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id);
return $participant;
}
示例5: validate
function validate()
{
parent::validate();
if ($this->_errors) {
return FALSE;
}
$this->cart->load_associations();
$fields = $this->_submitValues;
foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) {
$price_set_id = CRM_Event_BAO_Event::usesPriceSet($event_in_cart->event_id);
if ($price_set_id) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $price_set_id;
$priceField->find();
$check = array();
while ($priceField->fetch()) {
if (!empty($fields["event_{$event_in_cart->event_id}_price_{$priceField->id}"])) {
$check[] = $priceField->id;
}
}
//XXX
if (empty($check)) {
$this->_errors['_qf_default'] = ts("Select at least one option from Price Levels.");
}
$lineItem = array();
if (is_array($this->_values['fee']['fields'])) {
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee']['fields'], $fields, $lineItem);
//XXX total...
if ($fields['amount'] < 0) {
$this->_errors['_qf_default'] = ts("Price Levels can not be less than zero. Please select the options accordingly");
}
}
}
foreach ($event_in_cart->participants as $mer_participant) {
$participant_fields = $fields['event'][$event_in_cart->event_id]['participant'][$mer_participant->id];
//TODO what to do when profile responses differ for the same contact?
$contact_id = self::find_contact($participant_fields);
if ($contact_id) {
$participant = new CRM_Event_BAO_Participant();
$participant->event_id = $event_in_cart->event_id;
$participant->contact_id = $contact_id;
$statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
$participant->find();
while ($participant->fetch()) {
if (array_key_exists($participant->status_id, $statusTypes)) {
$form = $mer_participant->get_form();
$this->_errors[$form->html_field_name('email')] = ts("The participant %1 is already registered for %2 (%3).", array(1 => $participant_fields['email'], 2 => $event_in_cart->event->title, 3 => $event_in_cart->event->start_date));
}
}
}
}
}
return empty($this->_errors);
}
示例6: preProcess
function preProcess()
{
parent::preProcess();
$matches = array();
preg_match("/.*_(\\d+)_(\\d+)/", $this->getAttribute('name'), $matches);
$event_id = $matches[1];
$participant_id = $matches[2];
$event_in_cart = $this->cart->get_event_in_cart_by_event_id($event_id);
$this->conference_event = $event_in_cart->event;
$this->main_participant = $event_in_cart->get_participant_by_id($participant_id);
$this->contact_id = $this->main_participant->contact_id;
$this->main_participant->display_name = CRM_Contact_BAO_Contact::displayName($this->contact_id);
$events = new CRM_Event_BAO_Event();
$query = <<<EOS
\t SELECT
civicrm_event.*,
slot.label AS slot_label
FROM
civicrm_event
JOIN
civicrm_option_value slot ON civicrm_event.slot_label_id = slot.value
JOIN
civicrm_option_group og ON slot.option_group_id = og.id
\t WHERE
\t\tparent_event_id = {$this->conference_event->id}
AND civicrm_event.is_active = 1
AND COALESCE(civicrm_event.is_template, 0) = 0
AND og.name = 'conference_slot'
\t ORDER BY
\t\tslot.weight, start_date
EOS;
$events->query($query);
while ($events->fetch()) {
if (!array_key_exists($events->slot_label, $this->events_by_slot)) {
$this->events_by_slot[$events->slot_label] = array();
}
$this->events_by_slot[$events->slot_label][] = clone $events;
}
}
示例7: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
CRM_Utils_System::setTitle(ts('CiviEvent'));
$eventSummary = CRM_Event_BAO_Event::getEventSummary();
$actionColumn = FALSE;
if (!empty($eventSummary) && isset($eventSummary['events']) && is_array($eventSummary['events'])) {
foreach ($eventSummary['events'] as $e) {
if (isset($e['isMap']) || isset($e['configure'])) {
$actionColumn = TRUE;
break;
}
}
}
$this->assign('actionColumn', $actionColumn);
$this->assign('eventSummary', $eventSummary);
}
示例8: postProcess
/**
* Process the form when submitted.
*/
public function postProcess()
{
$participant = new CRM_Event_DAO_Participant();
$participant->event_id = $this->_id;
if ($participant->find()) {
$searchURL = CRM_Utils_System::url('civicrm/event/search', 'reset=1');
CRM_Core_Session::setStatus(ts('This event cannot be deleted because there are participant records linked to it. If you want to delete this event, you must first find the participants linked to this event and delete them. You can use use <a href=\'%1\'> CiviEvent >> Find Participants page </a>.', array(1 => $searchURL)), ts('Deletion Error'), 'error');
return;
}
CRM_Event_BAO_Event::del($this->_id);
if ($this->_isTemplate) {
CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Template Deleted'), 'success');
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'));
} else {
CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Event Deleted'), 'success');
}
}
示例9: run
/**
* Heart of the iCalendar data assignment process. The runner gets all the meta
* data for the event and calls the method to output the iCalendar
* to the user. If gData param is passed on the URL, outputs gData XML format.
* Else outputs iCalendar format per IETF RFC2445. Page param true means send
* to browser as inline content. Else, we send .ics file as attachment.
*
* @return void
*/
function run()
{
require_once "CRM/Utils/Request.php";
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, null, 'GET');
$type = CRM_Utils_Request::retrieve('type', 'Positive', $this, false, 0);
$start = CRM_Utils_Request::retrieve('start', 'Positive', $this, false, 0);
$end = CRM_Utils_Request::retrieve('end', 'Positive', $this, false, 0);
$iCalPage = CRM_Utils_Request::retrieve('page', 'Positive', $this, false, 0);
$gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, false, 0);
$html = CRM_Utils_Request::retrieve('html', 'Positive', $this, false, 0);
$rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, false, 0);
require_once "CRM/Event/BAO/Event.php";
$info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end);
$this->assign('events', $info);
// Send data to the correct template for formatting (iCal vs. gData)
$template = CRM_Core_Smarty::singleton();
$config = CRM_Core_Config::singleton();
if ($rss) {
// rss 2.0 requires lower case dash delimited locale
$this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages)));
$calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl');
} else {
if ($gData) {
$calendar = $template->fetch('CRM/Core/Calendar/GData.tpl');
} else {
if ($html) {
return parent::run();
} else {
$calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl');
}
}
}
// Push output for feed or download
require_once "CRM/Utils/ICalendar.php";
if ($iCalPage == 1) {
if ($gData || $rss) {
CRM_Utils_ICalendar::send($calendar, 'text/xml', 'utf-8');
} else {
CRM_Utils_ICalendar::send($calendar, 'text/plain', 'utf-8');
}
} else {
CRM_Utils_ICalendar::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment');
}
CRM_Utils_System::civiExit();
}
示例10: run
/**
* Heart of the iCalendar data assignment process. The runner gets all the meta
* data for the event and calls the method to output the iCalendar
* to the user. If gData param is passed on the URL, outputs gData XML format.
* Else outputs iCalendar format per IETF RFC2445. Page param true means send
* to browser as inline content. Else, we send .ics file as attachment.
*
* @return void
*/
public function run()
{
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
$type = CRM_Utils_Request::retrieve('type', 'Positive', $this, FALSE, 0);
$start = CRM_Utils_Request::retrieve('start', 'Positive', $this, FALSE, 0);
$end = CRM_Utils_Request::retrieve('end', 'Positive', $this, FALSE, 0);
$iCalPage = CRM_Utils_Request::retrieve('list', 'Positive', $this, FALSE, 0);
$gData = CRM_Utils_Request::retrieve('gData', 'Positive', $this, FALSE, 0);
$html = CRM_Utils_Request::retrieve('html', 'Positive', $this, FALSE, 0);
$rss = CRM_Utils_Request::retrieve('rss', 'Positive', $this, FALSE, 0);
$info = CRM_Event_BAO_Event::getCompleteInfo($start, $type, $id, $end, false);
$this->assign('events', $info);
$this->assign('timezone', @date_default_timezone_get());
// Send data to the correct template for formatting (iCal vs. gData)
$template = CRM_Core_Smarty::singleton();
$config = CRM_Core_Config::singleton();
if ($rss) {
// rss 2.0 requires lower case dash delimited locale
$this->assign('rssLang', str_replace('_', '-', strtolower($config->lcMessages)));
$calendar = $template->fetch('CRM/Core/Calendar/Rss.tpl');
} elseif ($gData) {
$calendar = $template->fetch('CRM/Core/Calendar/GData.tpl');
} elseif ($html) {
// check if we're in shopping cart mode for events
$enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
if ($enable_cart) {
$this->assign('registration_links', TRUE);
}
return parent::run();
} else {
$calendar = $template->fetch('CRM/Core/Calendar/ICal.tpl');
$calendar = preg_replace('/(?<!\\r)\\n/', "\r\n", $calendar);
}
// Push output for feed or download
if ($iCalPage == 1) {
if ($gData || $rss) {
CRM_Utils_ICalendar::send($calendar, 'text/xml', 'utf-8');
} else {
CRM_Utils_ICalendar::send($calendar, 'text/plain', 'utf-8');
}
} else {
CRM_Utils_ICalendar::send($calendar, 'text/calendar', 'utf-8', 'civicrm_ical.ics', 'attachment');
}
CRM_Utils_System::civiExit();
}
示例11: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
*/
public function preProcess()
{
CRM_Utils_System::setTitle(ts('CiviEvent'));
$eventSummary = CRM_Event_BAO_Event::getEventSummary();
$enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
$eventSummary['tab'] = CRM_Event_Page_ManageEvent::tabs($enableCart);
$actionColumn = FALSE;
if (!empty($eventSummary) && isset($eventSummary['events']) && is_array($eventSummary['events'])) {
foreach ($eventSummary['events'] as $e) {
if (isset($e['isMap']) || isset($e['configure'])) {
$actionColumn = TRUE;
break;
}
}
}
$this->assign('actionColumn', $actionColumn);
$this->assign('eventSummary', $eventSummary);
}
示例12: init
/**
* The initializer code, called before the processing.
*/
public function init()
{
$fields = CRM_Event_BAO_Participant::importableFields($this->_contactType, FALSE);
$fields['event_id']['title'] = 'Event ID';
$eventfields =& CRM_Event_BAO_Event::fields();
$fields['event_title'] = $eventfields['event_title'];
foreach ($fields as $name => $field) {
$field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT);
$field['dataPattern'] = CRM_Utils_Array::value('dataPattern', $field, '//');
$field['headerPattern'] = CRM_Utils_Array::value('headerPattern', $field, '//');
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
}
$this->_newParticipants = array();
$this->setActiveFields($this->_mapperKeys);
// FIXME: we should do this in one place together with Form/MapField.php
$this->_contactIdIndex = -1;
$this->_eventIndex = -1;
$this->_participantStatusIndex = -1;
$this->_participantRoleIndex = -1;
$this->_eventTitleIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
switch ($key) {
case 'participant_contact_id':
$this->_contactIdIndex = $index;
break;
case 'event_id':
$this->_eventIndex = $index;
break;
case 'participant_status':
case 'participant_status_id':
$this->_participantStatusIndex = $index;
break;
case 'participant_role_id':
$this->_participantRoleIndex = $index;
break;
case 'event_title':
$this->_eventTitleIndex = $index;
break;
}
$index++;
}
}
示例13: init
/**
* the initializer code, called before the processing
*
* @return void
* @access public
*/
function init()
{
require_once 'CRM/Event/BAO/Participant.php';
$fields =& CRM_Event_BAO_Participant::importableFields($this->_contactType, false);
$fields['event_id']['title'] = "Event ID";
require_once 'CRM/Event/BAO/Event.php';
$eventfields =& CRM_Event_BAO_Event::fields();
$fields['event_title'] = $eventfields['event_title'];
foreach ($fields as $name => $field) {
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
}
$this->_newParticipants = array();
$this->setActiveFields($this->_mapperKeys);
// FIXME: we should do this in one place together with Form/MapField.php
$this->_contactIdIndex = -1;
$this->_eventIndex = -1;
$this->_participantStatusIndex = -1;
$this->_participantRoleIndex = -1;
$this->_eventTitleIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
switch ($key) {
case 'participant_contact_id':
$this->_contactIdIndex = $index;
break;
case 'event_id':
$this->_eventIndex = $index;
break;
case 'participant_status':
case 'participant_status_id':
$this->_participantStatusIndex = $index;
break;
case 'participant_role_id':
$this->_participantRoleIndex = $index;
break;
case 'event_title':
$this->_eventTitleIndex = $index;
break;
}
$index++;
}
}
示例14: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
CRM_Utils_System::setTitle(ts('CiviEvent'));
$admin = false;
if (CRM_Core_Permission::check('access CiviEvent') && CRM_Core_Permission::check('administer CiviCRM')) {
$admin = true;
}
require_once 'CRM/Event/BAO/Event.php';
$eventSummary = CRM_Event_BAO_Event::getEventSummary($admin);
$eventMap = false;
if (!empty($eventSummary) && isset($eventSummary['events']) && is_array($eventSummary['events'])) {
foreach ($eventSummary['events'] as $e) {
if (isset($e['isMap'])) {
$eventMap = true;
}
}
}
$this->assign('eventAdmin', $admin);
$this->assign('eventMap', $eventMap);
$this->assign('eventSummary', $eventSummary);
}
示例15: preProcess
public function preProcess()
{
parent::preProcess();
$this->assign('currentEventId', $this->_id);
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
//If this ID has parent, send parent id
if ($checkParentExistsForThisId) {
/**
* Get connected event information list
*/
//Get all connected event ids
$allEventIdsArray = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($checkParentExistsForThisId, 'civicrm_event');
$allEventIds = array();
if (!empty($allEventIdsArray)) {
foreach ($allEventIdsArray as $key => $val) {
$allEventIds[] = $val['id'];
}
if (!empty($allEventIds)) {
$params = array();
$query = "\n SELECT *\n FROM civicrm_event\n WHERE id IN (" . implode(",", $allEventIds) . ")\n ORDER BY start_date asc\n ";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
}
}
}
$this->assign('rows', $manageEvent);
}
}
$parentEventParams = array('id' => $this->_id);
$parentEventValues = array();
$parentEventReturnProperties = array('start_date', 'end_date');
$parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
$this->_parentEventStartDate = $parentEventAttributes->start_date;
$this->_parentEventEndDate = $parentEventAttributes->end_date;
}