Commit 0fd5fea3 authored by pprasath's avatar pprasath
Browse files

Removed filter, calender and search function from being visible to anon users

parent cfdd4d2c
......@@ -512,160 +512,163 @@ function uw_ct_event_block_view($delta = '') {
global $language;
global $theme_key;
$block = array();
switch ($delta) {
case 'front_page':
// If the user doesn't have permission to access content,
// don't display this block.
if (!user_access('access content')) {
return;
}
$events = db_select('node', 'n');
$events->leftJoin('field_data_field_event_date', 'events', 'events.entity_id = n.nid');
$events->fields('events', array('field_event_date_value', 'field_event_date_value2'));
$events->fields('n', array('nid', 'title', 'sticky'));
$events->condition('n.type', 'uw_event', '=');
$events->condition('n.status', 1, '=');
$events->condition('n.promote', 1, '=');
$events->havingCondition('field_event_date_value2', date('Y-m-d'), '>=');
$events->orderBy('n.sticky', 'DESC');
$events->orderBy('events.field_event_date_value', 'ASC');
$events->orderBy('n.title');
$events->range(0, 3);
$result = $events->execute();
$items = array();
$count = 0;
foreach ($result as $record) {
$date_start = strtotime($record->field_event_date_value);
$date_end = strtotime($record->field_event_date_value2);
// Start and end on same date. "Nov. 24, 2005".
if (date('Y-m-d', $date_start) === date('Y-m-d', $date_end)) {
if ($language->language === 'en') {
$date_formatted = uw_month_name_short(date('n', $date_start)) . ' ' . date('j, Y', $date_start);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M j, Y', array(), array('context' => 'php date format')));
}
}
elseif (date('Y', $date_start) === date('Y', $date_end)) {
// Same month and year, different day. "Nov. 24-26, 2005".
if (date('m', $date_start) === date('m', $date_end)) {
// If the user doesn't have permission to access content,
// don't display this block.
if (!user_access('access content')) {
return NULL;
}
else {
switch ($delta) {
case 'front_page':
$events = db_select('node', 'n');
$events->leftJoin('field_data_field_event_date', 'events', 'events.entity_id = n.nid');
$events->fields('events', [
'field_event_date_value',
'field_event_date_value2'
]);
$events->fields('n', ['nid', 'title', 'sticky']);
$events->condition('n.type', 'uw_event', '=');
$events->condition('n.status', 1, '=');
$events->condition('n.promote', 1, '=');
$events->havingCondition('field_event_date_value2', date('Y-m-d'), '>=');
$events->orderBy('n.sticky', 'DESC');
$events->orderBy('events.field_event_date_value', 'ASC');
$events->orderBy('n.title');
$events->range(0, 3);
$result = $events->execute();
$items = [];
$count = 0;
foreach ($result as $record) {
$date_start = strtotime($record->field_event_date_value);
$date_end = strtotime($record->field_event_date_value2);
// Start and end on same date. "Nov. 24, 2005".
if (date('Y-m-d', $date_start) === date('Y-m-d', $date_end)) {
if ($language->language === 'en') {
$date_formatted = t(uw_month_name_short(date('n', $date_start))) . ' ' . date('j', $date_start) . ' to ' . date('j, Y', $date_end);
$date_formatted = uw_month_name_short(date('n', $date_start)) . ' ' . date('j, Y', $date_start);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M j, Y', [], ['context' => 'php date format']));
}
}
elseif (date('Y', $date_start) === date('Y', $date_end)) {
// Same month and year, different day. "Nov. 24-26, 2005".
if (date('m', $date_start) === date('m', $date_end)) {
if ($language->language === 'en') {
$date_formatted = t(uw_month_name_short(date('n', $date_start))) . ' ' . date('j', $date_start) . ' to ' . date('j, Y', $date_end);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M', [], ['context' => 'php date format']))
. ' '
. format_date($date_start, 'custom', t('j', [], ['context' => 'php date format']))
. ' ' . t('to') . ' '
. format_date($date_end, 'custom', t('j, Y', [], ['context' => 'php date format']));
}
}
// Same year. "Nov. 24 to Dec. 2, 2005".
else {
$date_formatted = format_date($date_start, 'custom', t('M', array(), array('context' => 'php date format')))
. ' '
. format_date($date_start, 'custom', t('j', array(), array('context' => 'php date format')))
. ' ' . t('to') . ' '
. format_date($date_end, 'custom', t('j, Y', array(), array('context' => 'php date format')));
if ($language->language === 'en') {
$date_formatted = t('@start_month @start_day to @end_month @end_day',
[
'@start_month' => uw_month_name_short(date('n', $date_start)),
'@start_day' => date('j', $date_start),
'@end_month' => uw_month_name_short(date('n', $date_end)),
'@end_day' => date('j, Y', $date_end),
]);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M', [], ['context' => 'php date format']))
. ' '
. format_date($date_start, 'custom', t('j', [], ['context' => 'php date format']))
. ' ' . t('to') . ' '
. format_date($date_end, 'custom', t('M j, Y', [], ['context' => 'php date format']));
}
}
}
// Same year. "Nov. 24 to Dec. 2, 2005".
// Fully different dates."Nov. 24, 2005 to Jan. 2, 2006".
else {
if ($language->language === 'en') {
$date_formatted = t('@start_month @start_day to @end_month @end_day',
array(
'@start_month' => uw_month_name_short(date('n', $date_start)),
'@start_day' => date('j', $date_start),
'@end_month' => uw_month_name_short(date('n', $date_end)),
'@end_day' => date('j, Y', $date_end),
));
$date_formatted = t(uw_month_name_short(date('n', $date_start))) . ' ' . date('j, Y', $date_start) . ' to ' . t(uw_month_name_short(date('n', $date_end))) . ' ' . date('j, Y', $date_end);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M', array(), array('context' => 'php date format')))
. ' '
. format_date($date_start, 'custom', t('j', array(), array('context' => 'php date format')))
$date_formatted = format_date($date_start, 'custom', t('M j, Y', [], ['context' => 'php date format']))
. ' ' . t('to') . ' '
. format_date($date_end, 'custom', t('M j, Y', array(), array('context' => 'php date format')));
. format_date($date_end, 'custom', t('M j, Y', [], ['context' => 'php date format']));
}
}
}
// Fully different dates."Nov. 24, 2005 to Jan. 2, 2006".
else {
if ($language->language === 'en') {
$date_formatted = t(uw_month_name_short(date('n', $date_start))) . ' ' . date('j, Y', $date_start) . ' to ' . t(uw_month_name_short(date('n', $date_end))) . ' ' . date('j, Y', $date_end);
}
else {
$date_formatted = format_date($date_start, 'custom', t('M j, Y', array(), array('context' => 'php date format')))
. ' ' . t('to') . ' '
. format_date($date_end, 'custom', t('M j, Y', array(), array('context' => 'php date format')));
}
}
$items[$count] = "";
$items[$count] .= '<span class="home-listing-block-date' . (($record->sticky) ? ' sticky' : '') . '">' . $date_formatted . '</span>';
$items[$count] .= '<span class="home-listing-block-link">' . l($record->title, 'node/' . $record->nid) . '</span>';
$items[$count] = "";
$items[$count] .= '<span class="home-listing-block-date' . (($record->sticky) ? ' sticky' : '') . '">' . $date_formatted . '</span>';
$items[$count] .= '<span class="home-listing-block-link">' . l($record->title, 'node/' . $record->nid) . '</span>';
if ($theme_key == 'uw_fdsu_theme_resp') {
$node = node_load($record->nid);
if ($theme_key == 'uw_fdsu_theme_resp') {
$node = node_load($record->nid);
if (!empty($node->body['en'][0]['summary'])) {
$summary = $node->body['en'][0]['summary'];
}
elseif (!empty($node->body['en'][0]['value'])) {
$summary = text_summary($node->body['en'][0]['value']);
}
else {
$summary = '';
}
if (!empty($node->body['en'][0]['summary'])) {
$summary = $node->body['en'][0]['summary'];
}
elseif (!empty($node->body['en'][0]['value'])) {
$summary = text_summary($node->body['en'][0]['value']);
}
else {
$summary = '';
}
$summary = check_markup(preg_replace(',<(/?)h\d,', '<$1p', $summary), 'uw_tf_basic');
$summary = _filter_htmlcorrector($summary);
$summary = preg_replace("/<img[^>]+\>/i", "", $summary);
$items[$count] .= '<span class="home-listing-block-summary">';
if (!empty($node->field_event_image[LANGUAGE_NONE][0]['uri'])) {
$listing_image = $node->field_event_image[LANGUAGE_NONE][0]['uri'];
$themed_image = '<img alt="' . $node->field_event_image[LANGUAGE_NONE][0]['alt'] . '" src="' . file_create_url($listing_image) . '" typeof="foaf:Image">';
$items[$count] .= $themed_image;
$summary = check_markup(preg_replace(',<(/?)h\d,', '<$1p', $summary), 'uw_tf_basic');
$summary = _filter_htmlcorrector($summary);
$summary = preg_replace("/<img[^>]+\>/i", "", $summary);
$items[$count] .= '<span class="home-listing-block-summary">';
if (!empty($node->field_event_image[LANGUAGE_NONE][0]['uri'])) {
$listing_image = $node->field_event_image[LANGUAGE_NONE][0]['uri'];
$themed_image = '<img alt="' . $node->field_event_image[LANGUAGE_NONE][0]['alt'] . '" src="' . file_create_url($listing_image) . '" typeof="foaf:Image">';
$items[$count] .= $themed_image;
}
$items[$count] .= $summary . '</span>';
}
$items[$count] .= $summary . '</span>';
}
$count++;
}
$count++;
}
if (!empty($items)) {
$block['subject'] = t('Events');
// Setup array to be used by theme_item_list.
$content = array(
'items' => $items,
'title' => '',
'type' => 'ol',
'attributes' => array(),
);
$block['content'] = theme('item_list', $content) . '<span class="home-listing-block-more-link">' . l(t("All upcoming events"), 'events') . '</span>';
}
break;
if (!empty($items)) {
$block['subject'] = t('Events');
// Setup array to be used by theme_item_list.
$content = [
'items' => $items,
'title' => '',
'type' => 'ol',
'attributes' => [],
];
$block['content'] = theme('item_list', $content) . '<span class="home-listing-block-more-link">' . l(t("All upcoming events"), 'events') . '</span>';
}
break;
// Create a link to the rss feed for news.
case 'events_public_feed':
$block['content'] = events_public_feed_link();
break;
// Create a link to the rss feed for news.
case 'events_public_feed':
$block['content'] = events_public_feed_link();
break;
// Create a link to expose event calendar.
case 'event-calendar-block-id':
$block['content'] = uw_ct_event_calendar_contents();
break;
// Create a link to expose event calendar.
case 'event-calendar-block-id':
$block['content'] = uw_ct_event_calendar_contents();
break;
case 'events_by_audience':
case 'events_by_audience':
$audience_tree = uw_ct_event_audience_taxonomy_tree(0);
$html = '<div class="item-list">';
$html .= $audience_tree;
$html .= '</div>';
$audience_tree = uw_ct_event_audience_taxonomy_tree(0);
$html = '<div class="item-list">';
$html .= $audience_tree;
$html .= '</div>';
if ($audience_tree) {
$block['subject'] = '<button>' . t('Events by audience') . '</button>';
}
else {
$block['subject'] = ' ';
}
$block['content'] = $html;
break;
if ($audience_tree) {
$block['subject'] = '<button>' . t('Events by audience') . '</button>';
}
else {
$block['subject'] = ' ';
}
$block['content'] = $html;
break;
}
}
return $block;
}
......@@ -679,6 +682,9 @@ function uw_ct_event_block_view_alter(&$data, $block) {
$event_exist = db_query("SELECT count(nid) FROM {node} node WHERE type = 'uw_event'")->fetchField();
if ($block->delta == 'events_with_calendar-block_1') {
if (!user_access('access content')) {
return NULL;
};
if ($event_exist) {
$by_date = uw_ct_event_by_date();
$header = '<h2><button>' . t('Events by date') . '</button></h2>';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment