本文整理汇总了PHP中CRM_Event_PseudoConstant::eventType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_PseudoConstant::eventType方法的具体用法?PHP CRM_Event_PseudoConstant::eventType怎么用?PHP CRM_Event_PseudoConstant::eventType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Event_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Event_PseudoConstant::eventType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browse
/**
* Browse all event templates.
*/
public function browse()
{
//get all event templates.
$allEventTemplates = array();
$eventTemplate = new CRM_Event_DAO_Event();
$eventTypes = CRM_Event_PseudoConstant::eventType();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$participantListings = CRM_Event_PseudoConstant::participantListing();
//find all event templates.
$eventTemplate->is_template = TRUE;
$eventTemplate->find();
while ($eventTemplate->fetch()) {
CRM_Core_DAO::storeValues($eventTemplate, $allEventTemplates[$eventTemplate->id]);
//get listing types.
if ($eventTemplate->participant_listing_id) {
$allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id];
}
//get participant role
if ($eventTemplate->default_role_id) {
$allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id];
}
//get event type.
if (isset($eventTypes[$eventTemplate->event_type_id])) {
$allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id];
}
//form all action links
$action = array_sum(array_keys($this->links()));
//add action links.
$allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $eventTemplate->id), ts('more'), FALSE, 'eventTemplate.manage.action', 'Event', $eventTemplate->id);
}
$this->assign('rows', $allEventTemplates);
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
}
示例2: alterEventType
function alterEventType($value, &$row)
{
return CRM_Event_PseudoConstant::eventType($value);
}
示例3: extractGroupTypes
static function extractGroupTypes($groupType)
{
$returnGroupTypes = array();
if (!$groupType) {
return $returnGroupTypes;
}
$groupTypeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $groupType);
foreach (explode(',', $groupTypeParts[0]) as $type) {
$returnGroupTypes[$type] = $type;
}
if (CRM_Utils_Array::value(1, $groupTypeParts)) {
foreach (explode(',', $groupTypeParts[1]) as $typeValue) {
$groupTypeValues = $valueLabels = array();
$valueParts = explode(':', $typeValue);
$typeName = NULL;
switch ($valueParts[0]) {
case 'ContributionType':
$typeName = 'Contribution';
$valueLabels = CRM_Contribute_PseudoConstant::financialType();
break;
case 'ParticipantRole':
$typeName = 'Participant';
$valueLabels = CRM_Event_PseudoConstant::participantRole();
break;
case 'ParticipantEventName':
$typeName = 'Participant';
$valueLabels = CRM_Event_PseudoConstant::event();
break;
case 'ParticipantEventType':
$typeName = 'Participant';
$valueLabels = CRM_Event_PseudoConstant::eventType();
break;
case 'MembershipType':
$typeName = 'Membership';
$valueLabels = CRM_Member_PseudoConstant::membershipType();
break;
case 'ActivityType':
$typeName = 'Activity';
$valueLabels = CRM_Core_PseudoConstant::ActivityType(TRUE, TRUE, FALSE, 'label', TRUE);
break;
}
foreach ($valueParts as $val) {
if (CRM_Utils_Rule::integer($val)) {
$groupTypeValues[$val] = CRM_Utils_Array::value($val, $valueLabels);
}
}
if (!is_array($returnGroupTypes[$typeName])) {
$returnGroupTypes[$typeName] = array();
}
$returnGroupTypes[$typeName][$valueParts[0]] = $groupTypeValues;
}
}
return $returnGroupTypes;
}
示例4: array
/**
* Retrieve list of Scheduled Reminders
*
* @param bool $namesOnly return simple list of names
*
* @param null $entityValue
* @param null $id
*
* @return array (reference) reminder list
* @static
* @access public
*/
static function &getList($namesOnly = FALSE, $entityValue = NULL, $id = NULL)
{
$activity_type = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$activity_status = CRM_Core_PseudoConstant::activityStatus();
$event_type = CRM_Event_PseudoConstant::eventType();
$civicrm_event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
$civicrm_participant_status_type = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$event_template = CRM_Event_PseudoConstant::eventTemplates();
$civicrm_contact = self::getDateFields();
$auto_renew_options = CRM_Core_OptionGroup::values('auto_renew_options');
$contact_date_reminder_options = CRM_Core_OptionGroup::values('contact_date_reminder_options');
$civicrm_membership_type = CRM_Member_PseudoConstant::membershipType();
$entity = array('civicrm_activity' => 'Activity', 'civicrm_participant' => 'Event', 'civicrm_membership' => 'Member', 'civicrm_contact' => 'Contact');
$query = "\nSELECT\n title,\n cam.entity,\n cas.id as id,\n cam.entity_value as entityValue,\n cas.entity_value as entityValueIds,\n cam.entity_status as entityStatus,\n cas.entity_status as entityStatusIds,\n cas.start_action_date as entityDate,\n cas.start_action_offset,\n cas.start_action_unit,\n cas.start_action_condition,\n cas.absolute_date,\n is_repeat,\n is_active\n\nFROM civicrm_action_schedule cas\nLEFT JOIN civicrm_action_mapping cam ON (cam.id = cas.mapping_id)\n";
$params = CRM_Core_DAO::$_nullArray;
if ($entityValue and $id) {
$where = "\nWHERE cas.entity_value = {$id} AND\n cam.entity_value = '{$entityValue}'";
$query .= $where;
$params = array(1 => array($id, 'Integer'), 2 => array($entityValue, 'String'));
}
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$list[$dao->id]['id'] = $dao->id;
$list[$dao->id]['title'] = $dao->title;
$list[$dao->id]['start_action_offset'] = $dao->start_action_offset;
$list[$dao->id]['start_action_unit'] = $dao->start_action_unit;
$list[$dao->id]['start_action_condition'] = $dao->start_action_condition;
$list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate));
$list[$dao->id]['absolute_date'] = $dao->absolute_date;
$status = $dao->entityStatus;
$statusArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityStatusIds);
foreach ($statusArray as &$s) {
$s = CRM_Utils_Array::value($s, ${$status});
}
$statusIds = implode(', ', $statusArray);
$value = $dao->entityValue;
$valueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds);
foreach ($valueArray as &$v) {
$v = CRM_Utils_Array::value($v, ${$value});
}
$valueIds = implode(', ', $valueArray);
$list[$dao->id]['entity'] = $entity[$dao->entity];
$list[$dao->id]['value'] = $valueIds;
$list[$dao->id]['status'] = $statusIds;
$list[$dao->id]['is_repeat'] = $dao->is_repeat;
$list[$dao->id]['is_active'] = $dao->is_active;
}
return $list;
}
示例5: alterEventType
/**
* @param int|null $value
* @param array $row
*
* @return string
* Event label.
*/
function alterEventType($value, &$row) {
if (empty($value)) {
return '';
}
return CRM_Event_PseudoConstant::eventType($value);
}
示例6: array
/**
* Get all event types.
*
* @access public
*
* @return array - array reference of all event types.
* @static
*/
public static function &eventType($id = NULL)
{
if (!self::$eventType) {
self::$eventType = array();
self::$eventType = CRM_Core_OptionGroup::values('event_type');
}
if ($id) {
return self::$eventType[$id];
}
return self::$eventType;
}
示例7: array
/**
* Get all event types.
*
* @access public
* @return array - array reference of all event types.
* @static
*/
public static function &eventType($id = null)
{
if (!self::$eventType) {
self::$eventType = array();
require_once "CRM/Core/OptionGroup.php";
self::$eventType = CRM_Core_OptionGroup::values("event_type");
}
if ($id) {
return self::$eventType[$id];
}
return self::$eventType;
}
示例8: run
/**
* 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);
//.........这里部分代码省略.........
示例9: getValueLabelMap
protected static function getValueLabelMap($name)
{
static $valueLabelMap = NULL;
if ($valueLabelMap === NULL) {
$valueLabelMap['activity_type'] = \CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
asort($valueLabelMap['activity_type']);
$valueLabelMap['activity_status'] = \CRM_Core_PseudoConstant::activityStatus();
$valueLabelMap['event_type'] = \CRM_Event_PseudoConstant::eventType();
$valueLabelMap['civicrm_event'] = \CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
$valueLabelMap['civicrm_participant_status_type'] = \CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
$valueLabelMap['event_template'] = \CRM_Event_PseudoConstant::eventTemplates();
$valueLabelMap['auto_renew_options'] = \CRM_Core_OptionGroup::values('auto_renew_options');
$valueLabelMap['contact_date_reminder_options'] = \CRM_Core_OptionGroup::values('contact_date_reminder_options');
$valueLabelMap['civicrm_membership_type'] = \CRM_Member_PseudoConstant::membershipType();
$allCustomFields = \CRM_Core_BAO_CustomField::getFields('');
$dateFields = array('birth_date' => ts('Birth Date'), 'created_date' => ts('Created Date'), 'modified_date' => ts('Modified Date'));
foreach ($allCustomFields as $fieldID => $field) {
if ($field['data_type'] == 'Date') {
$dateFields["custom_{$fieldID}"] = $field['label'];
}
}
$valueLabelMap['civicrm_contact'] = $dateFields;
}
return $valueLabelMap[$name];
}
示例10: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$config = CRM_Core_Config::singleton();
$configParams = array();
require_once 'CRM/Event/PseudoConstant.php';
$event_type = CRM_Event_PseudoConstant::eventType();
$colorevents = $event_type;
foreach ($event_type as $k => $v) {
$v = str_replace(" ", "_", $v);
$evnt_color = 'eventcolor_' . $k;
$eventname = 'eventtype_' . $k;
if (!empty($params[$evnt_color]) && !empty($params[$eventname])) {
$configParams[$v] = $params[$evnt_color];
$configParams[$eventname] = $params[$eventname];
} else {
$configParams[$v] = '3366CC';
$configParams[$eventname] = 0;
}
$event_type[$k] = $v;
}
foreach ($event_type as $k => $v) {
$evnt_key = 'eventtype_' . $k;
if (!array_key_exists($evnt_key, $params)) {
unset($event_type[$k]);
}
}
$configParams['civicrm_events_event_types'] = $event_type;
if (isset($params['event_calendar_title'])) {
$configParams['civicrm_event_calendar_title'] = $params['event_calendar_title'];
} else {
$configParams['civicrm_event_calendar_title'] = 'Event Calendar';
}
if (isset($params['show_past_event']) && $params['show_past_event'] == 1) {
$configParams['civicrm_events_event_past'] = $params['show_past_event'];
} else {
$configParams['civicrm_events_event_past'] = 0;
}
if (isset($params['show_end_date']) && $params['show_end_date'] == 1) {
$configParams['civicrm_events_event_end_date'] = $params['show_end_date'];
} else {
$configParams['civicrm_events_event_end_date'] = 0;
}
if (isset($params['event_is_public']) && $params['event_is_public'] == 1) {
$configParams['civicrm_events_event_is_public'] = $params['event_is_public'];
} else {
$configParams['civicrm_events_event_is_public'] = 0;
}
if (isset($params['events_event_month']) && $params['events_event_month'] == 1) {
$configParams['civicrm_events_event_months'] = $params['show_event_from_month'];
} else {
$configParams['civicrm_events_event_months'] = 0;
}
if (isset($params['show_event_from_month'])) {
$configParams['show_event_from_month'] = $params['show_event_from_month'];
} else {
$configParams['show_event_from_month'] = '';
}
CRM_Core_BAO_ConfigSetting::create($configParams);
CRM_Core_Session::setStatus(" ", ts('The value has been saved.'), "success");
}
示例11: run
function run()
{
// Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
$config = CRM_Core_Config::singleton();
if (isset($config->civicrm_event_calendar_title) && !empty($config->civicrm_event_calendar_title)) {
CRM_Utils_System::setTitle(ts($config->civicrm_event_calendar_title));
} else {
CRM_Utils_System::setTitle(ts('Event Calendar'));
}
$whereCondition = '';
$eventTypes = array();
$colorevents = array();
if (isset($config->civicrm_events_event_types)) {
$eventTypes = $config->civicrm_events_event_types;
$eventTypes = array_flip($eventTypes);
} else {
require_once 'CRM/Event/PseudoConstant.php';
$all_events = CRM_Event_PseudoConstant::eventType();
$eventTypes = array_flip($all_events);
}
$colorevents = array_flip($eventTypes);
if (!empty($eventTypes)) {
$whereCondition .= ' AND civicrm_event.event_type_id in (' . implode(",", $eventTypes) . ')';
} else {
$whereCondition .= ' AND civicrm_event.event_type_id in (0)';
}
//Show/Hide Past Events.
$pastEvents = '';
$currentDate = date("Y-m-d h:i:s", time());
if (isset($config->civicrm_events_event_past)) {
$pastEvents = $config->civicrm_events_event_past;
}
if (empty($pastEvents)) {
$whereCondition .= " AND civicrm_event.start_date > '" . $currentDate . "'";
}
// Show events according to number of next months.
$monthEvents = '';
if (isset($config->civicrm_events_event_months)) {
$monthEvents = $config->civicrm_events_event_months;
}
if (!empty($monthEvents)) {
$monthEventsDate = date("Y-m-d h:i:s", strtotime(date("Y-m-d h:i:s", strtotime($currentDate)) . "+" . $monthEvents . " month"));
$whereCondition .= " AND civicrm_event.start_date < '" . $monthEventsDate . "'";
}
//Sho/Hide Public Events.
$ispublicEvents = '';
if (isset($config->civicrm_events_event_is_public)) {
$ispublicEvents = $config->civicrm_events_event_is_public;
}
if (!empty($ispublicEvents)) {
$whereCondition .= " AND civicrm_event.is_public = " . $ispublicEvents . "";
}
$query = "SELECT `id`, `title`, `start_date` as start, `end_date` as end ,`event_type_id` as event_type FROM `civicrm_event` WHERE civicrm_event.is_active = 1 AND civicrm_event.is_template = 0";
$query .= $whereCondition;
$events['events'] = array();
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
$eventCalendarParams = array('title' => 'title', 'start' => 'start', 'url' => 'url');
if (isset($config->civicrm_events_event_end_date) && !empty($config->civicrm_events_event_end_date)) {
$eventCalendarParams['end'] = 'end';
}
while ($dao->fetch()) {
if ($dao->title) {
if (isset($startDate)) {
$startDate = date("Y,n,j", strtotime($dao->start_date));
}
if (isset($endDate)) {
$endDate = date("Y,n,j", strtotime($dao->end_date));
}
$dao->url = CRM_Utils_System::url('civicrm/event/info', 'id=' . $dao->id);
}
$eventData = array();
foreach ($eventCalendarParams as $k) {
$eventData[$k] = $dao->{$k};
if (!empty($colorevents) && isset($config->{$colorevents}[$dao->event_type])) {
$eventData['backgroundColor'] = '#' . $config->{$colorevents}[$dao->event_type] . '';
}
}
$eventData['url'] = html_entity_decode($eventData['url']);
$events['events'][] = $eventData;
}
$events['header']['left'] = 'prev,next today';
$events['header']['center'] = 'title';
$events['header']['right'] = 'month,basicWeek,basicDay';
//send Events array to calendar.
$this->assign('civicrm_events', json_encode($events));
parent::run();
}
示例12: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$config = CRM_Core_BAO_Setting::getItem('Eventcalendar', 'events_event_types', null, new stdClass());
$this->add('text', 'show_event_from_month', ts('Show Events from how many months from current month '), array('size' => 50));
$this->add('text', 'event_calendar_title', ts('Calendar title'), array('size' => 50));
$this->addElement('checkbox', 'show_end_date', ts('Show End Date'));
$this->addElement('checkbox', 'event_is_public', ts('Is Public'));
$this->addElement('checkbox', 'events_event_month', ts('Events By Month'));
$this->addElement('checkbox', 'show_past_event', ts('Show Past Events'));
require_once 'CRM/Event/PseudoConstant.php';
$event_type = CRM_Event_PseudoConstant::eventType();
foreach ($event_type as $key => $val) {
$eventname = 'eventtype_' . $key;
$colortextbox = 'eventcolor_' . $key;
$this->addElement('checkbox', $eventname, ts($val), NULL, array('onclick' => "showhidecolorbox('{$key}')"));
$this->addElement('text', $colortextbox, '', array('onchange' => "updatecolor('{$colortextbox}',this.value);", 'class' => 'color'));
}
$this->assign('event_type', $event_type);
$this->assign('fullcalendarviews', EventCalendarDefines::$fullcalendarviews);
foreach (EventCalendarDefines::$fullcalendarviews as $view => $viewName) {
$this->addElement('checkbox', 'calendar_views_' . $view, ts($viewName));
}
}
示例13: run
function run()
{
if (!CRM_Core_Permission::check('access CiviEvent')) {
return;
}
$config = (array) CRM_Core_BAO_Setting::getItem('Eventcalendar', 'events_event_types', null, array());
if (isset($config['event_calendar_title']) && !empty($config['event_calendar_title'])) {
CRM_Utils_System::setTitle(ts($config['event_calendar_title']));
} else {
CRM_Utils_System::setTitle(ts('Event Calendar'));
}
// add assets
CRM_Core_Resources::singleton()->addScriptFile('com.osseed.eventcalendar', 'js/fullcalendar.js', 10);
CRM_Core_Resources::singleton()->addScriptFile('com.osseed.eventcalendar', 'js/civicrm_events.js', 11);
CRM_Core_Resources::singleton()->addStyleFile('com.osseed.eventcalendar', 'css/fullcalendar.css');
CRM_Core_Resources::singleton()->addStyleFile('com.osseed.eventcalendar', 'css/civicrm_events.css');
$whereCondition = '';
require_once 'CRM/Event/PseudoConstant.php';
$eventTypes = CRM_Event_PseudoConstant::eventType();
$eventTypesColors = array();
$eventIds = array();
if (!empty($eventTypes)) {
foreach ($eventTypes as $key => $eventType) {
$eventname = 'eventtype_' . $key;
if (empty($config[$eventname])) {
continue;
}
$eventIds[] = $key;
$colortextbox = 'eventcolor_' . $key;
$eventTypesColors[$key] = array('id' => $key, 'color' => empty($config[$colortextbox]) ? '#3366CC' : '#' . $config[$colortextbox], 'name' => $eventType);
}
}
//~ print_r($eventTypesColors);
$this->assign('eventTypesColors', $eventTypesColors);
if (!empty($eventIds)) {
$whereCondition .= ' AND civicrm_event.event_type_id in (' . implode(",", $eventIds) . ')';
} else {
$whereCondition .= ' AND civicrm_event.event_type_id in (0)';
}
$currentDate = date("Y-m-d h:i:s", time());
//Show/Hide Past Events.
if (empty($config['show_past_event'])) {
$whereCondition .= " AND civicrm_event.start_date > '" . $currentDate . "'";
}
// Show events according to number of next months.
if (!empty($defaults['events_event_month'])) {
$monthEventsDate = date("Y-m-d h:i:s", strtotime(date("Y-m-d h:i:s", strtotime($defaults['show_event_from_month'])) . "+" . $defaults['show_event_from_month'] . " month"));
$whereCondition .= " AND civicrm_event.start_date < '" . $monthEventsDate . "'";
}
//Sho/Hide Public Events.
if (!empty($defaults['event_is_public'])) {
$whereCondition .= " AND civicrm_event.is_public = 1";
}
// only show events for department
if (class_exists('CRM_Lalgbtseniors_Acl') && !CRM_Core_Permission::check('administer CiviCRM')) {
$deptq = CRM_Lalgbtseniors_Acl::getEventDepartmentQuery();
//~ die($deptq);
$whereCondition .= " AND civicrm_event.id IN (" . $deptq . ")";
}
$query = "SELECT `id`, `title`, `start_date` as start, `end_date` as end ,`event_type_id` as event_type FROM `civicrm_event` WHERE civicrm_event.is_active = 1 AND civicrm_event.is_template = 0";
$query .= $whereCondition;
$events['events'] = array();
//~ echo $query;
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
$eventCalendarParams = array('title' => 'title', 'start' => 'start', 'url' => 'url');
if (!empty($defaults['show_end_date'])) {
$eventCalendarParams['end'] = 'end';
}
while ($dao->fetch()) {
if (!$dao->title) {
continue;
}
$eventData = array('allDay' => true);
if (isset($dao->start)) {
$dao->start = date("Y-m-d\\TH:i:s", strtotime($dao->start));
}
if (isset($dao->end)) {
$dao->end = date("Y-m-d\\TH:i:s", strtotime($dao->end));
}
if (isset($dao->start) && isset($dao->end)) {
$eventData['allDay'] = false;
}
$eventData['event_id'] = $dao->id;
$dao->url = CRM_Utils_System::url('civicrm/event/info', 'id=' . $dao->id);
if (!empty($eventTypesColors[$dao->event_type])) {
$eventData['backgroundColor'] = $eventTypesColors[$dao->event_type]['color'] . '';
}
foreach ($eventCalendarParams as $k) {
$eventData[$k] = $dao->{$k};
}
$eventData['url'] = html_entity_decode($eventData['url']);
$events['events'][] = $eventData;
}
$events['header']['left'] = 'prev,next today';
$events['header']['center'] = 'title';
$views = array_intersect(array_keys(EventCalendarDefines::$fullcalendarviews), empty($_REQUEST['calendar_views']) ? array() : $_REQUEST['calendar_views']);
if (empty($views)) {
foreach (EventCalendarDefines::$fullcalendarviews as $view => $viewName) {
if (empty($config['calendar_views_' . $view])) {
continue;
//.........这里部分代码省略.........