### Eclipse Workspace Patch 1.0 #P cck_gmapaddress Index: cck_gmapaddress.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck_gmapaddress/cck_gmapaddress.module,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 cck_gmapaddress.module --- cck_gmapaddress.module 22 Jun 2009 11:34:18 -0000 1.1.2.2 +++ cck_gmapaddress.module 22 Jun 2009 14:57:05 -0000 @@ -38,10 +38,12 @@ '#default_value' => $field['accuracy'], '#options' => _cck_gmapaddress_accuracy(), ); - $form['validation_not_mandatory'] = array( - '#type' => 'checkbox', - '#title' => t('Validation is not mandatory'), - '#default_value' => $field['validation_not_mandatory'], + $form['validation_mode'] = array( + '#type' => 'select', + '#title' => t('Validation mode'), + '#description' => t('Select the way validation errors shall be processed. Only %seterror forces the user to type in a valid geocodeable address.', array('%seterror' => t('Set error'))), + '#default_value' => ($field['validation_mode']) ? $field['validation_mode'] : 'error', + '#options' => array('error' => t('Set error'), 'warning' => t('Show warning.'), 'status' => t('Show status'), 'no' => t('Don\'t show a message.')) ); //GMAP SIMPLE $form['gmap_simple'] = array( @@ -227,7 +229,7 @@ case 'validate': break; case 'save': - return array('tld', 'validation_not_mandatory', 'accuracy', 'gmap_all', 'gmap_simple', 'route_single', 'route_all'); + return array('tld', 'validation_mode', 'accuracy', 'gmap_all', 'gmap_simple', 'route_single', 'route_all'); case 'database columns': $columns = array( 'longitude' => array('type' => 'decimal', 'length' => '18,15', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0), @@ -275,11 +277,23 @@ if ($item['status'] == 610) { form_set_error($field['field_name'] .']['. $key .'][address', t('No valid Google Map Key! Set correct key in !link', array('!link' => l('GMap Admin', base_path() .'admin/settings/gmap')))); } - elseif($field['validation_not_mandatory'] && $item['status']!= 200) { - drupal_set_message(t('The address %address in %field could not be validated as correct address! Look at !link to check your address.', array('%address' => $item['address'], '%field' => $field['field_name'] ."[$key]", '!link' => l('Maps.Google.'. $field['tld'], "http://maps.google.{$field['tld']}/maps", array(), "q={$item['address']}"))), 'warning'); - } elseif ($item['status']!= 200) { - form_set_error($field['field_name'] .']['. $key .'][address', t('The address %address in %field could not be validated as correct address! Look at !link to check your address.', array('%address' => $item['address'], '%field' => $field['field_name'] ."[$key]", '!link' => l('Maps.Google.'. $field['tld'], "http://maps.google.{$field['tld']}/maps", array(), "q={$item['address']}")))); + $message = t('The address %address in %field could not be validated as correct address! Look at !link to check your address.', array('%address' => $item['address'], '%field' => $field['field_name'] ."[$key]", '!link' => l('Maps.Google.'. $field['tld'], "http://maps.google.{$field['tld']}/maps", array(), "q={$item['address']}"))); + switch ($field['validation_mode']) { + case 'no': + //do nothing + break; + case 'status': + drupal_set_message($message,'status'); + break; + case 'warning': + drupal_set_message($message,'warning'); + break; + case 'error': + default: + form_set_error($field['field_name'] .']['. $key .'][address', $message); + break; + } } elseif ($item['accuracy'] < $field['accuracy']) { form_set_error($field['field_name'] .']['. $key .'][address', t('The address in %field does not have satisfying accuracy!', array('%field' => $field['field_name'] ."[$key]")));