'. t('Calendar') .'';
$node = menu_get_object();
if ($path == 'node/add/event' || $node->type == 'event') {
$help .= '
'. t('Tips for adding and editing events:') .'
';
$help .= '';
$help .= '- '. t('Fill in a title and description for your event.') .'
';
$help .= '- '. t('Choose a start date and an end date for your event. If your event doesn\'t last longer than a day, leave out the end date.') .'
';
$help .= '
';
}
else if ($path == 'node/add/feed-ical' || $node->type == 'feed_ical') {
$help .= ''. t('Tips for adding and editing iCal feeds:') .'
';
$help .= '';
$help .= '- '. t('Add a title for your feed so you can identify it quickly later.') .'
';
$help .= '- '. t('Enter the URL of an iCal feed. Feed URLs often begin with webcal:// and often end with a filename like my_calendar.ics.') .'
';
$help .= '
';
}
return $help;
case 'help#atrium_calendar':
default:
$help = '';
$help .= ''. t('Calendar') .'
';
$help .= ''. t('The calendar displays events and calendar feeds submitted by your group.') .'
';
$help .= '';
$help .= '- '. t('!add_events to the calendar to let others know about what\'s coming up.', array('!add_events' => l(t('Add events'), 'node/add/event'))) .'
';
$help .= '- '. t('!add_feeds to automatically populate your calendar with events from external sources.', array('!add_feeds' => l(t('Add iCal feeds'), 'node/add/feed-ical'))) .'
';
$help .= '
';
return $help;
}
}
}
/**
* Implementation of hook_context_links_alter().
* Removes ical event items from node links.
*/
function atrium_calendar_context_links_alter(&$links) {
if (!empty($links['feed_ical_item'])) {
unset($links['feed_ical_item']);
}
}
/**
* Implementation of hook_block().
*/
function atrium_calendar_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks['mini'] = array('info' => t('Mini calendar'));
$blocks['filters'] = array('info' => t('Atrium: Calendar Event Type filter'));
return $blocks;
default:
$function = "_atrium_calendar_block_{$delta}";
if (function_exists($function)) {
return $function($op, $edit);
}
}
}
/**
* Implementation of hook_menu_alter().
*/
function atrium_calendar_menu_alter(&$items) {
// Remove ical item node add page.
if (isset($items['node/add/feed-ical-item'])) {
unset($items['node/add/feed-ical-item']);
}
}
/**
* Implementation of hook_nodeapi().
*/
function atrium_calendar_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
// Custom code for forcing inheritance of OG groups from feed node to
// iCal items. See: http://drupal.org/node/632920.
case 'insert':
case 'update':
if ($node->type == 'feed_ical_item' && !empty($node->feeds_node_item->feed_nid)) {
$feed_node = node_load($node->feeds_node_item->feed_nid);
if (!empty($feed_node->og_groups)) {
$node->og_groups = $feed_node->og_groups;
}
}
break;
case 'view':
// Confirm we are actually on a page of relevance
if (menu_get_object() === $node && !empty($node->field_date)) {
$from = date_convert($node->field_date[0]['value'], DATE_ISO, DATE_OBJECT);
context_set('node', 'field_date', $from);
}
break;
}
}
function atrium_calendar_views_default_views_alter(&$views) {
if($views['calendar_listing']) {
$event_type_vid = variable_get('atrium_calendar_vocab', 1);
$event_type_array = array(
$event_type_vid => $event_type_vid,
);
$views['calendar_listing']->display['default']->display_options['relationships'] = array(
'term_node_tid' => array(
'label' => 'Event Type terms',
'required' => 0,
'vids' => $event_type_array,
'id' => 'term_node_tid',
'table' => 'node',
'field' => 'term_node_tid',
'relationship' => 'none',
),
);
$views['calendar_listing']->display['default']->display_options['fields']['tid']['relationship'] = 'term_node_tid';
}
}
/**
* Block: contextual mini calendar block
*/
function _atrium_calendar_block_mini($op, $edit) {
if ($op == 'view') {
$block = array();
if ($date = context_get('node', 'field_date')) {
$args = date_format($date, 'Y') . '-' . date_format($date, 'm');
}
else {
$args = format_date(time(), 'custom', 'Y') . '-' . format_date(time(), 'custom', 'm');
}
$block['content'] = views_embed_view('calendar_listing', 'block_1', $args);
}
return $block;
}
/**
* Preprocessor for theme('views_view').
*/
function atrium_calendar_preprocess_views_view(&$vars) {
$view = $vars['view'];
if ($view->name == 'calendar_listing' || $view->name == 'calendar_upcoming') {
// Whisk away exposed filter for display in a block
_atrium_calendar_block_filters(NULL, $vars['exposed']);
$vars['exposed'] = '';
}
}
/**
* Filter block.
*/
function _atrium_calendar_block_filters($op = NULL, $set = '') {
static $filters;
if (!empty($set)) {
$filters = $set;
return;
}
if (!empty($filters)) {
return array('subject' => t('Event Types'), 'content' => $filters);
}
return array();
}
function atrium_calendar_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_exposed_form' && ($form['#id'] == 'views-exposed-form-calendar-listing-page-1' || $form['#id'] == 'views-exposed-form-calendar-upcoming-page-1')) {
$form['tid']['#default_value'] = implode(array_keys($form['tid']['#options']));
$form['#theme'] = 'atrium_calendar_event_type_form';
$output = '';
// Render each of the user selector options
if ($form['tid']['#options']) {
$options = '';
foreach ($form['tid']['#options'] as $tid => $term) {
$options .= "". check_plain($term) ."
";
}
$form['options'] = array(
'#type' => 'markup',
'#value' => '',
'#weight' => -1,
'#value' => ''. $options .'
',
);
}
}
}
/**
* Theme function for rendering the js-enabled team notifications widget.
*/
function theme_atrium_calendar_event_type_form($form) {
// Add javascript
drupal_add_css(drupal_get_path('module', 'crayon') .'/crayon.css');
drupal_add_js(drupal_get_path('module', 'atrium_calendar') .'/atrium_calendar.js', 'module');
drupal_add_css(drupal_get_path('module', 'atrium_calendar') .'/atrium_calendar.css');
$output .= "". drupal_render($form) ."
";
return $output;
}
/**
* Implementation of hook_theme()
*/
function atrium_calendar_theme() {
return array(
'atrium_calendar_event_type_form' => array(),
);
}