Commit 9fe0a4a0 authored by Eric Bremner's avatar Eric Bremner
Browse files

FDSU-1621: Ensured that we are on a node before editing the page.

parent deb1d4b4
......@@ -540,34 +540,34 @@ function uw_ct_event_page_alter(&$page) {
// Get nid of current node.
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
}
// If there is a location present, step through each one and ensure that it is completely empty.
// If it is empty unset the location.
if(isset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location[LANGUAGE_NONE])) {
foreach ($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location[LANGUAGE_NONE] as $key => $locations) {
$location_flag = false;
foreach ($locations as $location_key => $location) {
if ($location_key !== 'lid' && $location_key !== 'source' && $location_key !== 'is_primary') {
if ($location_key == 'latitude' || $location_key == "longitude") {
if ($location !== '0.000000') {
$location_flag = true;
break;
}
} else {
if ($location !== "") {
$location_flag = true;
break;
// If there is a location present, step through each one and ensure that it is completely empty.
// If it is empty unset the location.
if(isset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location[LANGUAGE_NONE])) {
foreach ($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location[LANGUAGE_NONE] as $key => $locations) {
$location_flag = false;
foreach ($locations as $location_key => $location) {
if ($location_key !== 'lid' && $location_key !== 'source' && $location_key !== 'is_primary') {
if ($location_key == 'latitude' || $location_key == "longitude") {
if ($location !== '0.000000') {
$location_flag = true;
break;
}
} else {
if ($location !== "") {
$location_flag = true;
break;
}
}
}
}
}
if ($location_flag == false) {
if (isset($page['content']['system_main']['nodes'][$nid]['field_event_location'])) {
unset($page['content']['system_main']['nodes'][$nid]['field_event_location']);
}
if (isset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location)) {
unset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location);
if ($location_flag == false) {
if (isset($page['content']['system_main']['nodes'][$nid]['field_event_location'])) {
unset($page['content']['system_main']['nodes'][$nid]['field_event_location']);
}
if (isset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location)) {
unset($page['content']['system_main']['nodes'][$nid]['body']['#object']->field_event_location);
}
}
}
}
......
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