Keep all submitted data if contact form validation fails (#1487865)

release-0.6
thomascube 14 years ago
parent 12dac4911b
commit 3d8b54edf7

@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Keep all submitted data if contact form validation fails (#1487865)
- Handle uncode strings in rcube_addressbook::normalize_string() (#1487866)
- Fix bug where template name without plugin prefix was used in render_page hook - Fix bug where template name without plugin prefix was used in render_page hook
- Fix handling of debug_level=4 in ajax requests (#1487831) - Fix handling of debug_level=4 in ajax requests (#1487831)
- Support 'abort' and 'result' response in 'preferences_save' hook, add error handling - Support 'abort' and 'result' response in 'preferences_save' hook, add error handling

@ -31,18 +31,28 @@ if ($CONTACTS->readonly) {
} }
function rcmail_contact_edithead($attrib) function rcmail_get_edit_record()
{ {
global $RCMAIL, $CONTACTS; global $RCMAIL, $CONTACTS;
// check if we have a valid result
if ($GLOBALS['EDIT_RECORD']) {
$record = $GLOBALS['EDIT_RECORD'];
}
else if ($RCMAIL->action != 'add'
&& !(($result = $CONTACTS->get_result()) && ($record = $result->first()))
) {
$RCMAIL->output->show_message('contactnotfound');
return false;
}
return $record;
}
function rcmail_contact_edithead($attrib)
{
// check if we have a valid result // check if we have a valid result
if ($RCMAIL->action != 'add' $record = rcmail_get_edit_record();
&& !(($result = $CONTACTS->get_result()) && ($record = $result->first()))
) {
$RCMAIL->output->show_message('contactnotfound');
return false;
}
$i_size = !empty($attrib['size']) ? $attrib['size'] : 20; $i_size = !empty($attrib['size']) ? $attrib['size'] : 20;
$form = array( $form = array(
@ -74,15 +84,9 @@ function rcmail_contact_edithead($attrib)
function rcmail_contact_editform($attrib) function rcmail_contact_editform($attrib)
{ {
global $RCMAIL, $CONTACTS, $CONTACT_COLTYPES; global $RCMAIL, $CONTACT_COLTYPES;
// check if we have a valid result $record = rcmail_get_edit_record();
if ($RCMAIL->action != 'add'
&& !(($result = $CONTACTS->get_result()) && ($record = $result->first()))
) {
$RCMAIL->output->show_message('contactnotfound');
return false;
}
// add some labels to client // add some labels to client
$RCMAIL->output->add_label('noemailwarning', 'nonamewarning'); $RCMAIL->output->add_label('noemailwarning', 'nonamewarning');

@ -139,6 +139,7 @@ if (empty($a_record['name'])) {
if (!$CONTACTS->validate($a_record)) { if (!$CONTACTS->validate($a_record)) {
$err = (array)$CONTACTS->get_error() + array('message' => 'formincomplete', 'type' => 'warning'); $err = (array)$CONTACTS->get_error() + array('message' => 'formincomplete', 'type' => 'warning');
$OUTPUT->show_message($err['message'], $err['type']); $OUTPUT->show_message($err['message'], $err['type']);
$GLOBALS['EDIT_RECORD'] = $a_record; // store submitted data to be used in edit form
rcmail_overwrite_action($return_action); rcmail_overwrite_action($return_action);
return; return;
} }

Loading…
Cancel
Save