function getlocations_settings_validate in Get Locations 6
Same name and namespace in other branches
- 6.2 getlocations.admin.inc \getlocations_settings_validate()
- 7.2 getlocations.admin.inc \getlocations_settings_validate()
- 7 getlocations.admin.inc \getlocations_settings_validate()
1 string reference to 'getlocations_settings_validate'
- getlocations_settings_form in ./
getlocations.admin.inc - Function to display the getlocations admin settings form
File
- ./
getlocations.admin.inc, line 335 - getlocations module administration functions. using version 3 googlemaps API
Code
function getlocations_settings_validate($form, &$form_state) {
if (!getlocations_latlon_check($form_state['values']['getlocations_default']['latlong'])) {
form_set_error('getlocations_default][latlong', t('Map coordinates must be expressed as a decimal latitude and longitude, separated by a comma.'));
}
$found = FALSE;
foreach ($form_state['values']['getlocations_default']['baselayers'] as $l) {
if ($l) {
$found = TRUE;
break;
}
}
if (!$found) {
form_set_error('getlocations_default][baselayers', t('You must select at least one baselayer!'));
}
// Check that the default map type is sane.
# if (!$form_state['values']['getlocations_default']['baselayers'][$form_state['values']['getlocations_default']['maptype']]) {
# form_set_error($form['getlocations_default']['baselayers']['maptype'], t('The default map type must be an enabled baselayer!'));
# }
if ($form_state['values']['getlocations_default']['returnlink_page_enable'] && empty($form_state['values']['getlocations_default']['returnlink_page_link'])) {
form_set_error('getlocations_default][returnlink_page_link', t('Page return link must be filled in'));
}
if (module_exists('location_user')) {
if ($form_state['values']['getlocations_default']['returnlink_user_enable'] && empty($form_state['values']['getlocations_default']['returnlink_user_link'])) {
form_set_error('getlocations_default][returnlink_user_link', t('User return link must be filled in'));
}
}
if (!$form_state['values']['getlocations_default']['markermanagertype']) {
$form_state['values']['getlocations_default']['usemarkermanager'] = 0;
$form_state['values']['getlocations_default']['useclustermanager'] = 0;
}
elseif ($form_state['values']['getlocations_default']['markermanagertype'] == 1) {
$form_state['values']['getlocations_default']['useclustermanager'] = 0;
}
elseif ($form_state['values']['getlocations_default']['markermanagertype'] == 2) {
$form_state['values']['getlocations_default']['usemarkermanager'] = 0;
}
if (module_exists('colorbox') && isset($form_state['values']['getlocations_colorbox']['enable']) && $form_state['values']['getlocations_colorbox']['enable']) {
if (empty($form_state['values']['getlocations_colorbox']['width']) || !is_numeric($form_state['values']['getlocations_colorbox']['width']) || $form_state['values']['getlocations_colorbox']['width'] < 1) {
form_set_error('getlocations_colorbox][width', t('Colorbox width must be a number'));
}
if (empty($form_state['values']['getlocations_colorbox']['height']) || !is_numeric($form_state['values']['getlocations_colorbox']['height']) || $form_state['values']['getlocations_colorbox']['height'] < 1) {
form_set_error('getlocations_colorbox][height', t('Colorbox height must be a number'));
}
}
$list = array(
'Map',
'Satellite',
'Hybrid',
'Physical',
);
$found = FALSE;
foreach ($list as $maptype) {
if ($form_state['values']['getlocations_default']['maptype'] == $maptype && $form_state['values']['getlocations_default']['baselayers'][$maptype]) {
$found = TRUE;
break;
}
}
if (!$found) {
// force a setting
$form_state['values']['getlocations_default']['maptype'] = 'Map';
$form_state['values']['getlocations_default']['baselayers']['Map'] = 1;
}
}