First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

View file

@ -0,0 +1,70 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* This class contains all the function that are called using AJAX
*/
class CRM_Event_Page_AJAX {
/**
* Building EventFee combo box.
* FIXME: This ajax callback could be eliminated in favor of an entityRef field but the priceFieldValue api doesn't currently support filtering on entity_table
*/
public function eventFee() {
$name = trim(CRM_Utils_Type::escape($_GET['term'], 'String'));
if (!$name) {
$name = '%';
}
$whereClause = "cv.label LIKE '$name%' ";
$query = "SELECT DISTINCT (
cv.label
), cv.id
FROM civicrm_price_field_value cv
LEFT JOIN civicrm_price_field cf ON cv.price_field_id = cf.id
LEFT JOIN civicrm_price_set_entity ce ON ce.price_set_id = cf.price_set_id
WHERE ce.entity_table = 'civicrm_event' AND {$whereClause}";
$dao = CRM_Core_DAO::executeQuery($query);
$results = array();
while ($dao->fetch()) {
$results[] = array('id' => $dao->id, 'text' => $dao->label);
}
CRM_Utils_JSON::output($results);
}
}

View file

@ -0,0 +1,92 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* This is page is for Event Dashboard
*/
class CRM_Event_Page_DashBoard extends CRM_Core_Page {
/**
* 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 = Civi::settings()->get('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);
}
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
$controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('events'), NULL);
$controller->setEmbedded(TRUE);
$controller->reset();
$controller->set('limit', 10);
$controller->set('force', 1);
$controller->set('context', 'dashboard');
$controller->process();
$controller->run();
return parent::run();
}
}

View file

@ -0,0 +1,374 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
*/
/**
* Event Info Page - Summmary about the event
*/
class CRM_Event_Page_EventInfo extends CRM_Core_Page {
/**
* 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', NULL, $this->_id, 0, $values['event']['event_type_id'], NULL, TRUE, NULL, FALSE, TRUE, NULL, TRUE);
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' => (float ) $sumLat / count($locations),
'lng' => (float ) $sumLng / count($locations),
);
$span = array(
'lat' => (float ) ($maxLat - $minLat),
'lng' => (float ) ($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",
FALSE, NULL, TRUE,
TRUE
);
}
else {
$mapURL = CRM_Utils_System::url('civicrm/contact/map/event',
"eid={$this->_id}&reset=1",
FALSE, NULL, TRUE,
TRUE
);
}
$this->assign('skipLocationType', TRUE);
$this->assign('mapURL', $mapURL);
}
if (CRM_Core_Permission::check('view event participants')) {
$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}",
FALSE, 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}",
FALSE, 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, FALSE, 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();
}
/**
* @return string
*/
public function getTemplateFileName() {
if ($this->_id) {
$templateFile = "CRM/Event/Page/{$this->_id}/EventInfo.tpl";
$template = CRM_Core_Page::getTemplate();
if ($template->template_exists($templateFile)) {
return $templateFile;
}
}
return parent::getTemplateFileName();
}
}

View file

@ -0,0 +1,104 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* ICalendar class
*
*/
class CRM_Event_Page_ICalendar extends CRM_Core_Page {
/**
* 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);
$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 = Civi::settings()->get('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();
}
}

View file

@ -0,0 +1,565 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* Page for displaying list of events
*/
class CRM_Event_Page_ManageEvent extends CRM_Core_Page {
/**
* The action links that we need to display for the browse screen.
*
* @var array
*/
static $_actionLinks = NULL;
static $_links = NULL;
static $_tabLinks = NULL;
protected $_pager = NULL;
protected $_sortByCharacter;
protected $_isTemplate = FALSE;
/**
* Get action Links.
*
* @return array
* (reference) of action links
*/
public 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'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable Event'),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'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.
*
* @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];
}
/**
* 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 requested action
$action = CRM_Utils_Request::retrieve('action', 'String',
// default to 'browse'
$this, FALSE, 'browse'
);
// assign vars to templates
$this->assign('action', $action);
$id = CRM_Utils_Request::retrieve('id', 'Positive',
$this, FALSE, 0, 'REQUEST'
);
// figure out whether were handling an event or an event template
if ($id) {
$this->_isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_template');
}
elseif ($action & CRM_Core_Action::ADD) {
$this->_isTemplate = CRM_Utils_Request::retrieve('is_template', 'Boolean', $this);
}
if (!$this->_isTemplate && $id) {
$breadCrumb = array(
array(
'title' => ts('Manage Events'),
'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'),
),
);
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
// what action to take ?
if ($action & CRM_Core_Action::DELETE) {
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
$controller = new CRM_Core_Controller_Simple('CRM_Event_Form_ManageEvent_Delete',
'Delete Event',
$action
);
$controller->set('id', $id);
$controller->process();
return $controller->run();
}
elseif ($action & CRM_Core_Action::COPY) {
$this->copy();
}
// finally browse the custom groups
$this->browse();
// parent run
return parent::run();
}
/**
* Browse all events.
*
* @return void
*/
public function browse() {
Civi::resources()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter',
'String',
$this
);
$createdId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, 0);
if (strtolower($this->_sortByCharacter) == 'all' ||
!empty($_POST)
) {
$this->_sortByCharacter = '';
$this->set('sortByCharacter', '');
}
$this->_force = $this->_searchResult = NULL;
$this->search();
$params = array();
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean',
$this, FALSE
);
$this->_searchResult = CRM_Utils_Request::retrieve('searchResult', 'Boolean', $this);
$whereClause = $this->whereClause($params, FALSE, $this->_force);
$this->pagerAToZ($whereClause, $params);
$params = array();
$whereClause = $this->whereClause($params, TRUE, $this->_force);
// because is_template != 1 would be to simple
$whereClause .= ' AND (is_template = 0 OR is_template IS NULL)';
$this->pager($whereClause, $params);
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
// get all custom groups sorted by weight
$manageEvent = array();
$query = "
SELECT *
FROM civicrm_event
WHERE $whereClause
ORDER BY start_date desc
LIMIT $offset, $rowCount";
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Event_DAO_Event');
$permissions = CRM_Event_BAO_Event::checkPermission();
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
// get the list of active event pcps
$eventPCPS = array();
$pcpDao = new CRM_PCP_DAO_PCPBlock();
$pcpDao->entity_table = 'civicrm_event';
$pcpDao->find();
while ($pcpDao->fetch()) {
$eventPCPS[$pcpDao->entity_id] = $pcpDao->entity_id;
}
// check if we're in shopping cart mode for events
$enableCart = Civi::settings()->get('enable_cart');
$this->assign('eventCartEnabled', $enableCart);
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array(
'id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID,
)));
$eventType = CRM_Core_OptionGroup::values('event_type');
while ($dao->fetch()) {
if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) {
$manageEvent[$dao->id] = array();
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event');
$manageEvent[$dao->id]['repeat'] = '';
if ($repeat) {
$manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
}
else {
$action -= CRM_Core_Action::DISABLE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::DELETE])) {
$action -= CRM_Core_Action::DELETE;
}
if (!in_array($dao->id, $permissions[CRM_Core_Permission::EDIT])) {
$action -= CRM_Core_Action::UPDATE;
}
$manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(),
$action,
array('id' => $dao->id),
ts('more'),
TRUE,
'event.manage.list',
'Event',
$dao->id
);
$params = array(
'entity_id' => $dao->id,
'entity_table' => 'civicrm_event',
'is_active' => 1,
);
$defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
$manageEvent[$dao->id]['friend'] = CRM_Friend_BAO_Friend::getValues($params);
if (isset($defaults['location']['address'][1]['city'])) {
$manageEvent[$dao->id]['city'] = $defaults['location']['address'][1]['city'];
}
if (isset($defaults['location']['address'][1]['state_province_id'])) {
$manageEvent[$dao->id]['state_province'] = CRM_Core_PseudoConstant::stateProvince($defaults['location']['address'][1]['state_province_id']);
}
//show campaigns on selector.
$manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
$manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId());
$manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS);
$manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType);
$manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id');
// allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled
CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, array('event_id' => $dao->id));
}
}
$manageEvent['tab'] = self::tabs($enableCart);
$this->assign('rows', $manageEvent);
$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);
}
/**
* make a copy of a Event, including
* all the fields in the event wizard
*
* @return void
*/
public function copy() {
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE, 0, 'GET');
$urlString = 'civicrm/event/manage';
$copyEvent = CRM_Event_BAO_Event::copy($id);
$urlParams = 'reset=1';
// Redirect to Copied Event Configuration
if ($copyEvent->id) {
$urlString = 'civicrm/event/manage/settings';
$urlParams .= '&action=update&id=' . $copyEvent->id;
}
return CRM_Utils_System::redirect(CRM_Utils_System::url($urlString, $urlParams));
}
public function search() {
if (isset($this->_action) & (CRM_Core_Action::ADD |
CRM_Core_Action::UPDATE |
CRM_Core_Action::DELETE
)
) {
return;
}
$form = new CRM_Core_Controller_Simple('CRM_Event_Form_SearchEvent', ts('Search Events'), CRM_Core_Action::ADD);
$form->setEmbedded(TRUE);
$form->setParent($this);
$form->process();
$form->run();
}
/**
* @param array $params
* @param bool $sortBy
* @param $force
*
* @return string
*/
public function whereClause(&$params, $sortBy = TRUE, $force) {
$values = array();
$clauses = array();
$title = $this->get('title');
$createdId = $this->get('cid');
if ($createdId) {
$clauses[] = "(created_id = {$createdId})";
}
if ($title) {
$clauses[] = "title LIKE %1";
if (strpos($title, '%') !== FALSE) {
$params[1] = array(trim($title), 'String', FALSE);
}
else {
$params[1] = array(trim($title), 'String', TRUE);
}
}
$value = $this->get('event_type_id');
if ($value) {
if (is_array($value)) {
$type = implode(',', $value);
}
$clauses[] = "event_type_id IN ({$type})";
}
$eventsByDates = $this->get('eventsByDates');
if ($this->_searchResult) {
if ($eventsByDates) {
$from = $this->get('start_date');
if (!CRM_Utils_System::isNull($from)) {
$clauses[] = '( end_date >= %3 OR end_date IS NULL )';
$params[3] = array($from, 'String');
}
$to = $this->get('end_date');
if (!CRM_Utils_System::isNull($to)) {
$clauses[] = '( start_date <= %4 OR start_date IS NULL )';
$params[4] = array($to, 'String');
}
}
else {
$curDate = date('YmdHis');
$clauses[] = "(end_date >= {$curDate} OR end_date IS NULL)";
}
}
else {
$curDate = date('YmdHis');
$clauses[] = "(end_date >= {$curDate} OR end_date IS NULL)";
}
if ($sortBy &&
$this->_sortByCharacter !== NULL
) {
$clauses[] = "title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
}
$campaignIds = $this->get('campaign_id');
if (!CRM_Utils_System::isNull($campaignIds)) {
if (!is_array($campaignIds)) {
$campaignIds = array($campaignIds);
}
$clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campaignIds)) . ' ) )';
}
// don't do a the below assignment when doing a
// AtoZ pager clause
if ($sortBy) {
if (count($clauses) > 1 || $eventsByDates) {
$this->assign('isSearch', 1);
}
else {
$this->assign('isSearch', 0);
}
}
return !empty($clauses) ? implode(' AND ', $clauses) : '(1)';
}
/**
* @param $whereClause
* @param array $whereParams
*/
public function pager($whereClause, $whereParams) {
$params['status'] = ts('Event %%StatusMessage%%');
$params['csvString'] = NULL;
$params['buttonTop'] = 'PagerTopButton';
$params['buttonBottom'] = 'PagerBottomButton';
$params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT);
if (!$params['rowCount']) {
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
}
$query = "
SELECT count(id)
FROM civicrm_event
WHERE $whereClause";
$params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams);
$this->_pager = new CRM_Utils_Pager($params);
$this->assign_by_ref('pager', $this->_pager);
}
/**
* @param $whereClause
* @param array $whereParams
*/
public function pagerAtoZ($whereClause, $whereParams) {
$query = "
SELECT DISTINCT UPPER(LEFT(title, 1)) as sort_name
FROM civicrm_event
WHERE $whereClause
ORDER BY UPPER(LEFT(title, 1))
";
$dao = CRM_Core_DAO::executeQuery($query, $whereParams);
$aToZBar = CRM_Utils_PagerAToZ::getAToZBar($dao, $this->_sortByCharacter, TRUE);
$this->assign('aToZ', $aToZBar);
}
}

View file

@ -0,0 +1,105 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_ParticipantListing extends CRM_Core_Page {
protected $_id;
protected $_participantListingID;
protected $_eventTitle;
protected $_pager;
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this, TRUE);
// ensure that there is a particpant type for this
$this->_participantListingID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
$this->_id,
'participant_listing_id'
);
if (!$this->_participantListingID) {
CRM_Core_Error::fatal(ts('The Participant Listing feature is not currently enabled for this event.'));
}
// retrieve Event Title and include it in page title
$this->_eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
$this->_id,
'title'
);
CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle)));
// we do not want to display recently viewed contacts since this is potentially a public page
$this->assign('displayRecent', FALSE);
}
/**
* Run listing page.
*
* @throws \Exception
*/
public function run() {
$this->preProcess();
// get the class name from the participantListingID
$className = CRM_Core_OptionGroup::getValue('participant_listing',
$this->_participantListingID,
'value',
'Integer',
'description'
);
if ($className == 'CRM_Event_Page_ParticipantListing') {
CRM_Core_Error::fatal(ts("Participant listing code file cannot be '%1'",
array(1 => $className)
));
}
$classFile = str_replace('_',
DIRECTORY_SEPARATOR,
$className
) . '.php';
$error = include_once $classFile;
if ($error == FALSE) {
CRM_Core_Error::fatal('Participant listing code file: ' . $classFile . ' does not exist. Please verify your custom particpant listing settings in CiviCRM administrative panel.');
}
$participantListingClass = new $className();
$participantListingClass->preProcess();
$participantListingClass->run();
}
}

View file

@ -0,0 +1,42 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_ParticipantListing_Name extends CRM_Event_Page_ParticipantListing_Simple {
public function preProcess() {
$this->_participantListingType = 'Name';
parent::preProcess();
}
}

View file

@ -0,0 +1,42 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_ParticipantListing_NameAndEmail extends CRM_Event_Page_ParticipantListing_Simple {
public function preProcess() {
$this->_participantListingType = 'Name and Email';
parent::preProcess();
}
}

View file

@ -0,0 +1,193 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_ParticipantListing_NameStatusAndDate extends CRM_Core_Page {
protected $_id;
protected $_participantListingID;
protected $_eventTitle;
protected $_pager;
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this, TRUE);
// ensure that there is a particpant type for this
$this->_participantListingID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
$this->_id,
'participant_listing_id'
);
if (!$this->_participantListingID) {
CRM_Core_Error::fatal(ts("The Participant Listing feature is not currently enabled for this event."));
}
// retrieve Event Title and include it in page title
$this->_eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
$this->_id,
'title'
);
CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle)));
// we do not want to display recently viewed contacts since this is potentially a public page
$this->assign('displayRecent', FALSE);
}
/**
* @return string
*/
public function run() {
$this->preProcess();
$fromClause = "
FROM civicrm_contact
INNER JOIN civicrm_participant ON civicrm_contact.id = civicrm_participant.contact_id
INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
";
$whereClause = "
WHERE civicrm_event.id = %1";
$params = array(1 => array($this->_id, 'Integer'));
$this->pager($fromClause, $whereClause, $params);
$orderBy = $this->orderBy();
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
$query = "
SELECT civicrm_contact.id as contact_id ,
civicrm_contact.display_name as name ,
civicrm_contact.sort_name as sort_name ,
civicrm_participant.id as participant_id,
civicrm_participant.status_id as status_id ,
civicrm_participant.register_date as register_date
$fromClause
$whereClause
ORDER BY $orderBy
LIMIT $offset, $rowCount";
$rows = array();
$object = CRM_Core_DAO::executeQuery($query, $params);
$statusLookup = CRM_Event_PseudoConstant::participantStatus();
while ($object->fetch()) {
$status = CRM_Utils_Array::value($object->status_id, $statusLookup);
if ($status) {
$status = ts($status);
}
$row = array(
'id' => $object->contact_id,
'participantID' => $object->participant_id,
'name' => $object->name,
'status' => $status,
'date' => $object->register_date,
);
$rows[] = $row;
}
$this->assign_by_ref('rows', $rows);
return parent::run();
}
/**
* @param $fromClause
* @param $whereClause
* @param array $whereParams
*/
public function pager($fromClause, $whereClause, $whereParams) {
$params = array();
$params['status'] = ts('Group') . ' %%StatusMessage%%';
$params['csvString'] = NULL;
$params['buttonTop'] = 'PagerTopButton';
$params['buttonBottom'] = 'PagerBottomButton';
$params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT);
if (!$params['rowCount']) {
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
}
$query = "
SELECT count( civicrm_contact.id )
$fromClause
$whereClause";
$params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams);
$this->_pager = new CRM_Utils_Pager($params);
$this->assign_by_ref('pager', $this->_pager);
}
/**
* @return string
*/
public function orderBy() {
static $headers = NULL;
if (!$headers) {
$headers = array();
$headers[1] = array(
'name' => ts('Name'),
'sort' => 'civicrm_contact.sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
);
$headers[2] = array(
'name' => ts('Status'),
'sort' => 'civicrm_participant.status_id',
'direction' => CRM_Utils_Sort::DONTCARE,
);
$headers[3] = array(
'name' => ts('Register Date'),
'sort' => 'civicrm_participant.register_date',
'direction' => CRM_Utils_Sort::DONTCARE,
);
}
$sortID = NULL;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
);
}
$sort = new CRM_Utils_Sort($headers, $sortID);
$this->assign_by_ref('headers', $headers);
$this->assign_by_ref('sort', $sort);
$this->set(CRM_Utils_Sort::SORT_ID,
$sort->getCurrentSortID()
);
$this->set(CRM_Utils_Sort::SORT_DIRECTION,
$sort->getCurrentSortDirection()
);
return $sort->orderBy();
}
}

View file

@ -0,0 +1,178 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_ParticipantListing_Simple extends CRM_Core_Page {
protected $_id;
protected $_participantListingType;
protected $_eventTitle;
protected $_pager;
public function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this, TRUE);
// retrieve Event Title and include it in page title
$this->_eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
$this->_id,
'title'
);
CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle)));
// we do not want to display recently viewed contacts since this is potentially a public page
$this->assign('displayRecent', FALSE);
}
/**
* @return string
*/
public function run() {
$this->preProcess();
$fromClause = "
FROM civicrm_contact
INNER JOIN civicrm_participant ON ( civicrm_contact.id = civicrm_participant.contact_id
AND civicrm_contact.is_deleted = 0 )
INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id
LEFT JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1 )
";
$whereClause = "
WHERE civicrm_event.id = %1
AND civicrm_participant.is_test = 0
AND civicrm_participant.status_id IN ( 1, 2 )";
$params = array(1 => array($this->_id, 'Integer'));
$this->pager($fromClause, $whereClause, $params);
$orderBy = $this->orderBy();
list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount();
$query = "
SELECT civicrm_contact.id as contact_id ,
civicrm_contact.display_name as name ,
civicrm_contact.sort_name as sort_name ,
civicrm_participant.id as participant_id,
civicrm_email.email as email
$fromClause
$whereClause
ORDER BY $orderBy
LIMIT $offset, $rowCount";
$rows = array();
$object = CRM_Core_DAO::executeQuery($query, $params);
while ($object->fetch()) {
$row = array(
'id' => $object->contact_id,
'participantID' => $object->participant_id,
'name' => $object->name,
'email' => $object->email,
);
$rows[] = $row;
}
$this->assign_by_ref('rows', $rows);
return parent::run();
}
/**
* @param $fromClause
* @param $whereClause
* @param array $whereParams
*/
public function pager($fromClause, $whereClause, $whereParams) {
$params = array();
$params['status'] = ts('Group') . ' %%StatusMessage%%';
$params['csvString'] = NULL;
$params['buttonTop'] = 'PagerTopButton';
$params['buttonBottom'] = 'PagerBottomButton';
$params['rowCount'] = $this->get(CRM_Utils_Pager::PAGE_ROWCOUNT);
if (!$params['rowCount']) {
$params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
}
$query = "
SELECT count( civicrm_contact.id )
$fromClause
$whereClause
";
$params['total'] = CRM_Core_DAO::singleValueQuery($query, $whereParams);
$this->_pager = new CRM_Utils_Pager($params);
$this->assign_by_ref('pager', $this->_pager);
}
/**
* @return string
*/
public function orderBy() {
static $headers = NULL;
if (!$headers) {
$headers = array();
$headers[1] = array(
'name' => ts('Name'),
'sort' => 'civicrm_contact.sort_name',
'direction' => CRM_Utils_Sort::ASCENDING,
);
if ($this->_participantListingType == 'Name and Email') {
$headers[2] = array(
'name' => ts('Email'),
'sort' => 'civicrm_email.email',
'direction' => CRM_Utils_Sort::DONTCARE,
);
}
}
$sortID = NULL;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
);
}
$sort = new CRM_Utils_Sort($headers, $sortID);
$this->assign_by_ref('headers', $headers);
$this->assign_by_ref('sort', $sort);
$this->set(CRM_Utils_Sort::SORT_ID,
$sort->getCurrentSortID()
);
$this->set(CRM_Utils_Sort::SORT_DIRECTION,
$sort->getCurrentSortDirection()
);
return $sort->orderBy();
}
}

View file

@ -0,0 +1,307 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
class CRM_Event_Page_Tab extends CRM_Core_Page {
public $_permission = NULL;
public $_contactId = NULL;
/**
* called when action is browse.
*/
public function browse() {
$controller = new CRM_Core_Controller_Simple(
'CRM_Event_Form_Search',
ts('Events'),
$this->_action
);
$controller->setEmbedded(TRUE);
$controller->reset();
$controller->set('cid', $this->_contactId);
$controller->set('context', 'participant');
$controller->process();
$controller->run();
if ($this->_contactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
$this->assign('displayName', $displayName);
$this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactId);
// Refresh other tabs with related data
$this->ajaxResponse['updateTabs'] = array(
'#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId),
);
if (CRM_Core_Permission::access('CiviContribute')) {
$this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
}
}
}
/**
* called when action is view.
*
* @return null
*/
public function view() {
// build associated contributions
$this->associatedContribution();
$controller = new CRM_Core_Controller_Simple(
'CRM_Event_Form_ParticipantView',
ts('View Participant'),
$this->_action
);
$controller->setEmbedded(TRUE);
$controller->set('id', $this->_id);
$controller->set('cid', $this->_contactId);
return $controller->run();
}
/**
* called when action is update or new.
*
* @return null
*/
public function edit() {
// set https for offline cc transaction
$mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
if ($mode == 'test' || $mode == 'live') {
CRM_Utils_System::redirectToSSL();
}
if ($this->_action != CRM_Core_Action::ADD) {
// get associated contributions only on edit/delete
$this->associatedContribution();
}
$controller = new CRM_Core_Controller_Simple(
'CRM_Event_Form_Participant',
'Create Participation',
$this->_action
);
$controller->setEmbedded(TRUE);
$controller->set('id', $this->_id);
$controller->set('cid', $this->_contactId);
return $controller->run();
}
public function preProcess() {
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
if ($context == 'standalone') {
$this->_action = CRM_Core_Action::ADD;
}
else {
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$this->assign('contactId', $this->_contactId);
// check logged in url permission
CRM_Contact_Page_View::checkUserPermission($this);
}
$this->assign('action', $this->_action);
if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit event participants')) {
// demote to view since user does not have edit event participants rights
$this->_permission = CRM_Core_Permission::VIEW;
$this->assign('permission', 'view');
}
}
/**
* the main function that is called when the page loads, it decides the which action has to be taken for the page.
*
* @return null
*/
public function run() {
$this->preProcess();
// check if we can process credit card registration
$this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
// Only show credit card registration button if user has CiviContribute permission
if (CRM_Core_Permission::access('CiviContribute')) {
$this->assign('accessContribution', TRUE);
}
else {
$this->assign('accessContribution', FALSE);
}
$this->setContext();
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
}
elseif ($this->_action & (CRM_Core_Action::UPDATE |
CRM_Core_Action::ADD |
CRM_Core_Action::DELETE
)
) {
$this->edit();
}
else {
$this->browse();
}
return parent::run();
}
public function setContext() {
$context = CRM_Utils_Request::retrieve('context',
'String', $this, FALSE, 'search'
);
$compContext = CRM_Utils_Request::retrieve('compContext',
'String', $this
);
$searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $this);
$qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
//validate the qfKey
if (!CRM_Utils_Rule::qfKey($qfKey)) {
$qfKey = NULL;
}
switch ($context) {
case 'dashboard':
$url = CRM_Utils_System::url('civicrm/event', 'reset=1');
break;
case 'search':
$urlParams = 'force=1';
if ($qfKey) {
$urlParams .= "&qfKey=$qfKey";
}
$this->assign('searchKey', $qfKey);
if ($compContext == 'advanced') {
$url = CRM_Utils_System::url('civicrm/contact/search/advanced', $urlParams);
}
elseif ($searchContext) {
$url = CRM_Utils_System::url("civicrm/$searchContext/search", $urlParams);
}
else {
$url = CRM_Utils_System::url('civicrm/event/search', $urlParams);
}
break;
case 'user':
$url = CRM_Utils_System::url('civicrm/user', 'reset=1');
break;
case 'participant':
$url = CRM_Utils_System::url('civicrm/contact/view',
"reset=1&force=1&cid={$this->_contactId}&selectedChild=participant"
);
break;
case 'home':
$url = CRM_Utils_System::url('civicrm/dashboard', 'force=1');
break;
case 'activity':
$url = CRM_Utils_System::url('civicrm/contact/view',
"reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
);
break;
case 'standalone':
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
break;
case 'fulltext':
$keyName = '&qfKey';
$urlParams = 'force=1';
$urlString = 'civicrm/contact/search/custom';
if ($this->_action == CRM_Core_Action::UPDATE) {
if ($this->_contactId) {
$urlParams .= '&cid=' . $this->_contactId;
}
$keyName = '&key';
$urlParams .= '&context=fulltext&action=view';
$urlString = 'civicrm/contact/view/participant';
}
if ($qfKey) {
$urlParams .= "$keyName=$qfKey";
}
$this->assign('searchKey', $qfKey);
$url = CRM_Utils_System::url($urlString, $urlParams);
break;
default:
$cid = NULL;
if ($this->_contactId) {
$cid = '&cid=' . $this->_contactId;
}
$url = CRM_Utils_System::url('civicrm/event/search',
'force=1' . $cid
);
break;
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
/**
* used for the to show the associated
* contribution for the participant
*/
public function associatedContribution() {
if (CRM_Core_Permission::access('CiviContribute')) {
$this->assign('accessContribution', TRUE);
$controller = new CRM_Core_Controller_Simple(
'CRM_Contribute_Form_Search',
ts('Contributions'),
NULL,
FALSE, FALSE, TRUE
);
$controller->setEmbedded(TRUE);
$controller->set('force', 1);
$controller->set('cid', $this->_contactId);
$controller->set('participantId', $this->_id);
$controller->set('context', 'contribution');
$controller->process();
$controller->run();
}
else {
$this->assign('accessContribution', FALSE);
}
}
}

View file

@ -0,0 +1,71 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
* This class is for building event(participation) block on user dashboard
*/
class CRM_Event_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard {
/**
* List participations for the UF user.
*
*/
public function listParticipations() {
$controller = new CRM_Core_Controller_Simple(
'CRM_Event_Form_Search',
ts('Events'),
NULL,
FALSE, FALSE, TRUE, FALSE
);
$controller->setEmbedded(TRUE);
$controller->reset();
$controller->set('context', 'user');
$controller->set('cid', $this->_contactId);
$controller->set('force', 1);
$controller->process();
$controller->run();
}
/**
* the main function that is called when the page
* loads, it decides the which action has to be taken for the page.
*
*/
public function run() {
parent::preProcess();
$this->listParticipations();
}
}