Commit f4e44454 authored by Liam Morland's avatar Liam Morland
Browse files

Coding standards: Remove unnecessary use of $base_url

parent 6ab395ad
......@@ -694,13 +694,12 @@ function uw_ct_event_block_view_alter(&$data, $block) {
* Redirect invalid term ids and dates on above paths to events.
*/
function uw_ct_event_init() {
global $base_url;
$path = current_path();
// Redirect events/archive, events/audience,
// events/type pages to events.
if ($path == 'events/archive' || $path == 'events/audience' || $path == 'events/type') {
drupal_goto($base_url . '/events', array(), 301);
drupal_goto('events', array(), 301);
}
$path = explode("/", $path);
......@@ -718,7 +717,7 @@ function uw_ct_event_init() {
// -- e.g. https://uwaterloo.ca/environment/events/category/1
if ($path[0] == 'events' && isset($path[1]) && ($path[1] == 'category') && isset($path[2])) {
if (is_numeric($path[2]) && in_array($path[2], $uw_ct_event_audience_tids)) {
drupal_goto($base_url . '/events/audience/' . $path[2], array(), 301);
drupal_goto('events/audience/' . $path[2], array(), 301);
}
}
......@@ -727,7 +726,7 @@ function uw_ct_event_init() {
if ($path[0] == 'events' && isset($path[1]) && ($path[1] == 'audience') && isset($path[2])) {
if (!is_numeric($path[2]) || !in_array($path[2], $uw_ct_event_audience_tids)) {
drupal_set_message(t('Invalid event audience URL. You have been redirected to the main "events" page.'), 'warning');
drupal_goto($base_url . '/events', array(), 301);
drupal_goto('events', array(), 301);
}
}
......@@ -736,7 +735,7 @@ function uw_ct_event_init() {
if ($path[0] == 'events' && isset($path[1]) && ($path[1] == 'type') && isset($path[2])) {
if (!is_numeric($path[2]) || !in_array($path[2], $uw_ct_event_type_tids)) {
drupal_set_message(t('Invalid event type URL. You have been redirected to the main "events" page.'), 'warning');
drupal_goto($base_url . '/events', array(), 301);
drupal_goto('events', array(), 301);
}
}
......@@ -745,7 +744,7 @@ function uw_ct_event_init() {
if ($path[0] == 'events' && isset($path[1]) && ($path[1] == 'archive') && isset($path[2])) {
if (!preg_match('/^\d{4}(?:-(?:[123456789]|1[012]))?$/', $path[2])) {
drupal_set_message(t('Invalid event date URL. You have been redirected to the main "events" page.'), 'warning');
drupal_goto($base_url . '/events', array(), 301);
drupal_goto('events', array(), 301);
}
}
......@@ -755,7 +754,7 @@ function uw_ct_event_init() {
// because taxonomy/term/xx/edit breaks otherwise.
if ($path[0] == 'taxonomy' && $path[1] == 'term' && isset($path[2]) && !isset($path[3])) {
if (in_array($path[2], $uw_ct_event_tag_tids)) {
drupal_goto($base_url . '/events/tag/' . $path[2], array(), 301);
drupal_goto('events/tag/' . $path[2], array(), 301);
}
}
......@@ -764,20 +763,20 @@ function uw_ct_event_init() {
if ($path[0] == 'events' && isset($path[1]) && ($path[1] == 'tag') && isset($path[2])) {
if (!is_numeric($path[2]) || !in_array($path[2], $uw_ct_event_tag_tids)) {
drupal_set_message(t('Invalid event tag URL. You have been redirected to the main "events" page.'), 'warning');
drupal_goto($base_url . '/events', array(), 301);
drupal_goto('events', array(), 301);
}
}
// Redirect events/calendar/NOTADATE.
if ($path[0] == 'events' && isset($path[1]) && $path[1] == 'calendar' && isset($path[2]) && !preg_match('/^[0-9]{4}-(0?[1-9]|1[0-2])$/', $path[2])) {
drupal_set_message(t('Invalid calendar URL. You have been redirected to the main "calendar" page.'), 'warning');
drupal_goto($base_url . '/events/calendar', array(), 301);
drupal_goto('events/calendar', array(), 301);
}
// Redirect events/day/NOTADATE.
if ($path[0] == 'events' && isset($path[1]) && $path[1] == 'day' && isset($path[2]) && !preg_match('/^[0-9]{4}-(0?[1-9]|1[0-2])(-[0-9]{1,2})$/', $path[2])) {
drupal_set_message(t('Invalid day URL. You have been redirected to today\'s "day" page.'), 'warning');
drupal_goto($base_url . '/events/day', array(), 301);
drupal_goto('events/day', array(), 301);
}
}
......
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