/** * Get tab Links for events. * * @param $enableCart * * @return array * (reference) of tab links */ public static function &tabs($enableCart) { $cacheKey = $enableCart ? 1 : 0; if (!self::$_tabLinks) { self::$_tabLinks = array(); } if (!isset(self::$_tabLinks[$cacheKey])) { self::$_tabLinks[$cacheKey]['settings'] = array('title' => ts('Info and Settings'), 'url' => 'civicrm/event/manage/settings', 'field' => 'id'); self::$_tabLinks[$cacheKey]['location'] = array('title' => ts('Location'), 'url' => 'civicrm/event/manage/location', 'field' => 'loc_block_id'); self::$_tabLinks[$cacheKey]['fee'] = array('title' => ts('Fees'), 'url' => 'civicrm/event/manage/fee', 'field' => 'is_monetary'); self::$_tabLinks[$cacheKey]['registration'] = array('title' => ts('Online Registration'), 'url' => 'civicrm/event/manage/registration', 'field' => 'is_online_registration'); if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) { self::$_tabLinks[$cacheKey]['reminder'] = array('title' => ts('Schedule Reminders'), 'url' => 'civicrm/event/manage/reminder', 'field' => 'reminder'); } self::$_tabLinks[$cacheKey]['conference'] = array('title' => ts('Conference Slots'), 'url' => 'civicrm/event/manage/conference', 'field' => 'slot_label_id'); self::$_tabLinks[$cacheKey]['friend'] = array('title' => ts('Tell a Friend'), 'url' => 'civicrm/event/manage/friend', 'field' => 'friend'); self::$_tabLinks[$cacheKey]['pcp'] = array('title' => ts('Personal Campaign Pages'), 'url' => 'civicrm/event/manage/pcp', 'field' => 'is_pcp_enabled'); self::$_tabLinks[$cacheKey]['repeat'] = array('title' => ts('Repeat'), 'url' => 'civicrm/event/manage/repeat', 'field' => 'is_repeating_event'); } if (!$enableCart) { unset(self::$_tabLinks[$cacheKey]['conference']); } CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], array()); return self::$_tabLinks[$cacheKey]; }
/** * Basic page run function. */ public function run() { // Get link options for managing events. $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); $tabs = CRM_Event_Page_ManageEvent::tabs($enableCart); foreach ($tabs as $tab => $tabInfo) { $tabs[$tab]['name'] = $tabInfo['title']; $tabs[$tab]['qs'] = $tab == 'reminder' ? 'reset=1&action=browse&setTab=1&id=%%id%%' : 'reset=1&action=update&id=%%id%%'; } // Get link options for participant listings. $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $participantLinks = array(); if (1 || !empty($statusTypes)) { $participantLinks[2] = array('name' => implode(', ', array_values($statusTypes)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=true&event=%%id%%', 'title' => ts('Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } if (!empty($statusTypesPending)) { $participantLinks[3] = array('name' => implode(', ', array_values($statusTypesPending)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=false&event=%%id%%', 'title' => ts('Not Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } $participantLinks[4] = array('name' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/participant', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions'))); // Get link options for event links. $eventLinks = array(array('name' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/participant/add', 'qs' => 'reset=1&action=add&context=standalone&eid=%%id%%', 'title' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&action=preview&id=%%id%%', 'title' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')))); $utils = new CRM_Eventpermissions_Utils(); $events = array(); foreach ($utils->myUpcomingEvents() as $id => $event) { $events[] = array('title' => CRM_Utils_System::href($event['title'], 'civicrm/event/info', "id={$id}&reset=1"), 'links' => CRM_Core_Action::formLink($tabs, NULL, array('id' => $id), ts('Configure', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.configure', 'Event', $id), 'participantLinks' => CRM_Core_Action::formLink($participantLinks, $event['participant_listing_id'] ? 6 : 3, array('id' => $id), ts('Participants', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.participants', 'Event', $id), 'eventLinks' => CRM_Core_Action::formLink($eventLinks, NULL, array('id' => $id), ts('Event Links', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.links', 'Event', $id)); } $this->assign('events', $events); parent::run(); }
/** * Get action Links * * @return array (reference) of action links */ function &links() { if (!self::$_actionLinks) { // helper variable for nicer formatting $copyExtra = ts('Are you sure you want to make a copy of this Event?'); $deleteExtra = ts('Are you sure you want to delete this Event?'); self::$_actionLinks = array(CRM_Core_Action::UPDATE => array('name' => ts('Configure'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Configure Event')), CRM_Core_Action::PREVIEW => array('name' => ts('Test-drive'), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&action=preview&id=%%id%%', 'title' => ts('Preview')), CRM_Core_Action::FOLLOWUP => array('name' => ts('Live Page'), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('FollowUp')), CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Event_BAO_Event' . '\',\'' . 'enable-disable' . '\' );"', 'ref' => 'disable-action', 'title' => ts('Disable Event')), CRM_Core_Action::ENABLE => array('name' => ts('Enable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Event_BAO_Event' . '\',\'' . 'disable-enable' . '\' );"', 'ref' => 'enable-action', 'title' => ts('Enable Event')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete Event')), CRM_Core_Action::COPY => array('name' => ts('Copy Event'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'reset=1&action=copy&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"', 'title' => ts('Copy Event'))); } return self::$_actionLinks; }
/** * Get action Links * * @return array (reference) of action links */ function &links() { if (!self::$_actionLinks) { // helper variable for nicer formatting $copyExtra = ts('Are you sure you want to make a copy of this Event?'); $deleteExtra = ts('Are you sure you want to delete this Event?'); self::$_actionLinks = array(CRM_Core_Action::DISABLE => array('name' => ts('Disable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Event_BAO_Event' . '\',\'' . 'enable-disable' . '\' );"', 'ref' => 'disable-action', 'title' => ts('Disable Event')), CRM_Core_Action::ENABLE => array('name' => ts('Enable'), 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Event_BAO_Event' . '\',\'' . 'disable-enable' . '\' );"', 'ref' => 'enable-action', 'title' => ts('Enable Event')), CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete Event')), CRM_Core_Action::COPY => array('name' => ts('Copy'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'reset=1&action=copy&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"', 'title' => ts('Copy Event'))); } return self::$_actionLinks; }
/** * Get tab Links for events * * @return array (reference) of tab links */ static function &tabs($enableCart) { $cacheKey = $enableCart ? 1 : 0; if (!self::$_tabLinks) { self::$_tabLinks = array(); } if (!isset(self::$_tabLinks[$cacheKey])) { self::$_tabLinks[$cacheKey] = array('settings' => array('title' => ts('Info and Settings'), 'url' => 'civicrm/event/manage/settings', 'field' => 'id'), 'location' => array('title' => ts('Location'), 'url' => 'civicrm/event/manage/location', 'field' => 'loc_block_id'), 'fee' => array('title' => ts('Fees'), 'url' => 'civicrm/event/manage/fee', 'field' => 'is_monetary'), 'registration' => array('title' => ts('Online Registration'), 'url' => 'civicrm/event/manage/registration', 'field' => 'is_online_registration'), 'reminder' => array('title' => ts('Schedule Reminders'), 'url' => 'civicrm/event/manage/reminder', 'field' => 'reminder'), 'conference' => array('title' => ts('Conference Slots'), 'url' => 'civicrm/event/manage/conference', 'field' => 'slot_label_id'), 'friend' => array('title' => ts('Tell a Friend'), 'url' => 'civicrm/event/manage/friend', 'field' => 'friend'), 'pcp' => array('title' => ts('Personal Campaign Pages'), 'url' => 'civicrm/event/manage/pcp', 'field' => 'is_pcp_enabled')); } if (!$enableCart) { unset(self::$_tabLinks[$cacheKey]['conference']); } CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], array()); return self::$_tabLinks[$cacheKey]; }
/** * 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); }
/** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * Finally it calls the parent's run method. * * @return void */ public function run() { //get the event id. $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $config = CRM_Core_Config::singleton(); // ensure that the user has permission to see this page if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'view event info')) { CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event')); return CRM_Utils_System::permissionDenied(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'register'); $this->assign('context', $context); // Sometimes we want to suppress the Event Full msg $noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false'); // set breadcrumb to append to 2nd layer pages $breadCrumbPath = CRM_Utils_System::url('civicrm/event/info', "id={$this->_id}&reset=1"); //retrieve event information $params = array('id' => $this->_id); CRM_Event_BAO_Event::retrieve($params, $values['event']); if (!$values['event']['is_active']) { // form is inactive, die a fatal death CRM_Utils_System::setUFMessage(ts('The event you requested is currently unavailable (contact the site administrator for assistance).')); return CRM_Utils_System::permissionDenied(); } if (!empty($values['event']['is_template'])) { // form is an Event Template CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.')); } // Add Event Type to $values in case folks want to display it $values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType()); $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event'])); // show event fees. if ($this->_id && !empty($values['event']['is_monetary'])) { //CRM-6907 $config = CRM_Core_Config::singleton(); $config->defaultCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency); //CRM-10434 $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event'); if ($discountId) { $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'price_set_id'); } else { $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_id); } // get price set options, - CRM-5209 if ($priceSetId) { $setDetails = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, TRUE); $priceSetFields = $setDetails[$priceSetId]['fields']; if (is_array($priceSetFields)) { $fieldCnt = 1; $visibility = CRM_Core_PseudoConstant::visibility('name'); // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions $adminFieldVisible = FALSE; if (CRM_Core_Permission::check('administer CiviCRM')) { $adminFieldVisible = TRUE; } foreach ($priceSetFields as $fid => $fieldValues) { if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == FALSE) { continue; } if (count($fieldValues['options']) > 1) { $values['feeBlock']['value'][$fieldCnt] = ''; $values['feeBlock']['label'][$fieldCnt] = $fieldValues['label']; $values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label'; $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues); $fieldCnt++; $labelClass = 'price_set_option-label'; } else { $labelClass = 'price_set_field-label'; } // show tax rate with amount $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); foreach ($fieldValues['options'] as $optionId => $optionVal) { $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues); if ($invoicing && isset($optionVal['tax_amount'])) { $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm); $values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount']; } else { $values['feeBlock']['value'][$fieldCnt] = $optionVal['amount']; } $values['feeBlock']['label'][$fieldCnt] = $optionVal['label']; $values['feeBlock']['lClass'][$fieldCnt] = $labelClass; $fieldCnt++; } } } // Tell tpl we have price set fee data and whether it's a quick_config price set $this->assign('isPriceSet', 1); $this->assign('isQuickConfig', $setDetails[$priceSetId]['is_quick_config']); } } $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'); $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); // fix phone type labels if (!empty($values['location']['phone'])) { $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); foreach ($values['location']['phone'] as &$val) { if (!empty($val['phone_type_id'])) { $val['phone_type_display'] = $phoneTypes[$val['phone_type_id']]; } } } //retrieve custom field information $groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id']); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id); $this->assign('action', CRM_Core_Action::VIEW); //To show the event location on maps directly on event info page $locations = CRM_Event_BAO_Event::getMapInfo($this->_id); if (!empty($locations) && !empty($values['event']['is_map'])) { $this->assign('locations', $locations); $this->assign('mapProvider', $config->mapProvider); $this->assign('mapKey', $config->mapAPIKey); $sumLat = $sumLng = 0; $maxLat = $maxLng = -400; $minLat = $minLng = 400; foreach ($locations as $location) { $sumLat += $location['lat']; $sumLng += $location['lng']; if ($location['lat'] > $maxLat) { $maxLat = $location['lat']; } if ($location['lat'] < $minLat) { $minLat = $location['lat']; } if ($location['lng'] > $maxLng) { $maxLng = $location['lng']; } if ($location['lng'] < $minLng) { $minLng = $location['lng']; } } $center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations)); $span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng)); $this->assign_by_ref('center', $center); $this->assign_by_ref('span', $span); if ($action == CRM_Core_Action::PREVIEW) { $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE); } else { $mapURL = CRM_Utils_System::url('civicrm/contact/map/event', "eid={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE); } $this->assign('skipLocationType', TRUE); $this->assign('mapURL', $mapURL); } if (CRM_Core_Permission::check('view event participants') && CRM_Core_Permission::check('view all contacts')) { $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1', 'label'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0', 'label'); $findParticipants['statusCounted'] = implode(', ', array_values($statusTypes)); $findParticipants['statusNotCounted'] = implode(', ', array_values($statusTypesPending)); $this->assign('findParticipants', $findParticipants); } $participantListingID = CRM_Utils_Array::value('participant_listing_id', $values['event']); if ($participantListingID) { $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', "reset=1&id={$this->_id}", TRUE, NULL, TRUE, TRUE); $this->assign('participantListingURL', $participantListingURL); } $hasWaitingList = CRM_Utils_Array::value('has_waitlist', $values['event']); $eventFullMessage = CRM_Event_BAO_Participant::eventFull($this->_id, FALSE, $hasWaitingList); $allowRegistration = FALSE; if (!empty($values['event']['is_online_registration'])) { if (CRM_Event_BAO_Event::validRegistrationRequest($values['event'], $this->_id)) { // we always generate urls for the front end in joomla $action_query = $action === CRM_Core_Action::PREVIEW ? "&action={$action}" : ''; $url = CRM_Utils_System::url('civicrm/event/register', "id={$this->_id}&reset=1{$action_query}", TRUE, NULL, TRUE, TRUE); if (!$eventFullMessage || $hasWaitingList) { $registerText = ts('Register Now'); if (!empty($values['event']['registration_link_text'])) { $registerText = $values['event']['registration_link_text']; } // check if we're in shopping cart mode for events $enable_cart = Civi::settings()->get('enable_cart'); if ($enable_cart) { $link = CRM_Event_Cart_BAO_EventInCart::get_registration_link($this->_id); $registerText = $link['label']; $url = CRM_Utils_System::url($link['path'], $link['query'] . $action_query, TRUE, NULL, TRUE, TRUE); } //Fixed for CRM-4855 $allowRegistration = CRM_Event_BAO_Event::showHideRegistrationLink($values); $this->assign('registerText', $registerText); $this->assign('registerURL', $url); $this->assign('eventCartEnabled', $enable_cart); } } elseif (CRM_Core_Permission::check('register for events')) { $this->assign('registerClosed', TRUE); } } $this->assign('allowRegistration', $allowRegistration); $session = CRM_Core_Session::singleton(); $params = array('contact_id' => $session->get('userID'), 'event_id' => CRM_Utils_Array::value('id', $values['event']), 'role_id' => CRM_Utils_Array::value('default_role_id', $values['event'])); if ($eventFullMessage && $noFullMsg == 'false' || CRM_Event_BAO_Event::checkRegistration($params)) { $statusMessage = $eventFullMessage; if (CRM_Event_BAO_Event::checkRegistration($params)) { if ($noFullMsg == 'false') { if ($values['event']['allow_same_participant_emails']) { $statusMessage = ts('It looks like you are already registered for this event. You may proceed if you want to create an additional registration.'); } else { $registerUrl = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$values['event']['id']}&cid=0"); $statusMessage = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also <a href="%1">register another participant</a>.', array(1 => $registerUrl)); } } } elseif ($hasWaitingList) { $statusMessage = CRM_Utils_Array::value('waitlist_text', $values['event']); if (!$statusMessage) { $statusMessage = ts('Event is currently full, but you can register and be a part of waiting list.'); } } CRM_Core_Session::setStatus($statusMessage); } // we do not want to display recently viewed items, so turn off $this->assign('displayRecent', FALSE); // set page title = event title CRM_Utils_System::setTitle($values['event']['title']); $this->assign('event', $values['event']); if (isset($values['feeBlock'])) { $this->assign('feeBlock', $values['feeBlock']); } $this->assign('location', $values['location']); if (CRM_Core_Permission::check('access CiviEvent')) { $enableCart = Civi::settings()->get('enable_cart'); $this->assign('manageEventLinks', CRM_Event_Page_ManageEvent::tabs($enableCart)); } return parent::run(); }