correct validation errors, if no file selected or file could not be attached

This commit is contained in:
Ralf Becker 2010-06-14 20:17:55 +00:00
parent 2d35aa7af8
commit 8c913bb95a
3 changed files with 19 additions and 10 deletions

View File

@ -473,7 +473,7 @@ class link_widget
* @param mixed &$value the extension returns here it's input, if there's any * @param mixed &$value the extension returns here it's input, if there's any
* @param mixed &$extension_data persistent storage between calls or pre- and post-process * @param mixed &$extension_data persistent storage between calls or pre- and post-process
* @param boolean &$loop can be set to true to request a re-submision of the form/dialog * @param boolean &$loop can be set to true to request a re-submision of the form/dialog
* @param object &$tmpl the eTemplate the widget belongs too * @param etemplate &$tmpl the eTemplate the widget belongs too
* @param mixed &value_in the posted values (already striped of magic-quotes) * @param mixed &value_in the posted values (already striped of magic-quotes)
* @return boolean true if $value has valid content, on false no content will be returned! * @return boolean true if $value has valid content, on false no content will be returned!
*/ */
@ -554,6 +554,7 @@ class link_widget
break; break;
case 'attach': case 'attach':
$name = preg_replace('/^exec\[([^]]+)\](.*)$/','\\1\\2',$name); // remove exec prefix
if (is_array($value['file']) && $value['to_app'] && if (is_array($value['file']) && $value['to_app'] &&
!empty($value['file']['tmp_name']) && $value['file']['tmp_name'] != 'none') !empty($value['file']['tmp_name']) && $value['file']['tmp_name'] != 'none')
{ {
@ -570,8 +571,13 @@ class link_widget
move_uploaded_file($value['file']['tmp_name'],$new_file); move_uploaded_file($value['file']['tmp_name'],$new_file);
$value['file']['tmp_name'] = $new_file; $value['file']['tmp_name'] = $new_file;
} }
$link_id = egw_link::link($value['to_app'],$value['to_id'], if (!($link_id = egw_link::link($value['to_app'],$value['to_id'],
egw_link::VFS_APPNAME,$value['file'],$value['remark']); egw_link::VFS_APPNAME,$value['file'],$value['remark'])))
{
etemplate::set_validation_error($name.'[file]',lang('Error copying uploaded file to vfs!'));
}
else
{
$value['remark'] = ''; $value['remark'] = '';
if (isset($value['primary']) && !$value['anz_links'] ) if (isset($value['primary']) && !$value['anz_links'] )
@ -581,9 +587,10 @@ class link_widget
unset($value['comment']); unset($value['comment']);
unset($value['file']); unset($value['file']);
} }
}
else else
{ {
$value['msg'] = 'You need to select a file first!'; etemplate::set_validation_error($name.'[file]',lang('You need to select a file first!'));
} }
$extension_data = $value; $extension_data = $value;
$loop = True; $loop = True;

View File

@ -430,4 +430,5 @@ xslt template etemplate de XSLT Template
year etemplate de Jahr year etemplate de Jahr
you are not allowed to export more then %1 entries! etemplate de Sie sind nicht berechtigt mehr als %1 Datensätze zu exportieren! you are not allowed to export more then %1 entries! etemplate de Sie sind nicht berechtigt mehr als %1 Datensätze zu exportieren!
you can respond by visiting: etemplate de Sie können unter dem folgenden Verweis antworten: you can respond by visiting: etemplate de Sie können unter dem folgenden Verweis antworten:
you need to select a file first! etemplate de Sie müssen zuerst eine Datei auswählen!
your code is incorrect !!! etemplate de Ihr Code ist nicht richtig!!! your code is incorrect !!! etemplate de Ihr Code ist nicht richtig!!!

View File

@ -430,4 +430,5 @@ xslt template etemplate en XSLT Template
year etemplate en Year year etemplate en Year
you are not allowed to export more then %1 entries! etemplate en You are not allowed to export more then %1 entries! you are not allowed to export more then %1 entries! etemplate en You are not allowed to export more then %1 entries!
you can respond by visiting: etemplate en You can respond by visiting: you can respond by visiting: etemplate en You can respond by visiting:
you need to select a file first! etemplate en You need to select a file first!
your code is incorrect !!! etemplate en Your code is incorrect !!! your code is incorrect !!! etemplate en Your code is incorrect !!!