[fix] Synchronize the error reporting and user feedback between photo and version import
:
This commit is contained in:
parent
6f38b732fa
commit
2c258cdddf
2 changed files with 35 additions and 9 deletions
|
|
@ -36,6 +36,21 @@ $database = site_prolog(PO_USER_TYPE_USER);
|
|||
|
||||
$default_folder_id = pg_escape_string($database, $_REQUEST['folder']);
|
||||
|
||||
if (!isset($_FILES['file_name']['error'][0])) {
|
||||
throw new RuntimeException('Invalid parameters.');
|
||||
}
|
||||
switch ($_FILES['file_name']['error'][0]) {
|
||||
case UPLOAD_ERR_OK:
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new RuntimeException('No file sent.');
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new RuntimeException('Exceeded filesize limit.');
|
||||
default:
|
||||
throw new RuntimeException('Unknown errors.');
|
||||
}
|
||||
|
||||
$file_name = $_FILES['file_name']['name'][0];
|
||||
$file_size = $_FILES['file_name']['size'][0];
|
||||
$file_name_tmp = $_FILES['file_name']['tmp_name'][0];
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ switch($action) {
|
|||
$photo_id = pg_escape_string($database, $_REQUEST['photo']);
|
||||
$version_id = pg_escape_string($database, $_REQUEST['version']);
|
||||
$sql_selector = "photo_version.identifier = '$version_id' and photo.identifier = '$photo_id'";
|
||||
|
||||
|
||||
$photo_version = pg_fetch_row(pg_query($database, "select identifier, key, date_of_creation, comment, master, colorspace from photo_version where identifier='$version_id'"));
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$photo_data = pg_fetch_assoc(pg_query($database, "
|
||||
select caption, '' as preview_path,
|
||||
select caption, '' as preview_path,
|
||||
users, title, folder, photo_version.identifier, original_image_name
|
||||
from photo, photo_version
|
||||
where photo.identifier = photo_version.photo
|
||||
|
|
@ -104,9 +104,16 @@ if ($go) {
|
|||
$index = 0;
|
||||
$image_data['num_of_files'] = 0;
|
||||
$tempnam = tempnam($tmp_volume_path, "po.import.");
|
||||
|
||||
print $strings['import_moving_file_to_tmp'] . " ... ";
|
||||
|
||||
if (move_uploaded_file($file_name_tmp, $tempnam) === FALSE) {
|
||||
site_push_error("'$file_name_tmp' -> '$tempnam' failed!");
|
||||
print "<font color=\"red\">".$strings['generic_failed']."</font>";
|
||||
print "<pre>mv $file_name_tmp $tempnam</pre><br/>";
|
||||
} else {
|
||||
print $strings['generic_done'].".<br/>";
|
||||
}
|
||||
|
||||
$image_data['file'][$index]['name'] = $file_name;
|
||||
$image_data['file'][$index]['name_tmp'] = $tempnam;
|
||||
$image_data['file'][$index]['type'] = $original_file_type;
|
||||
|
|
@ -120,8 +127,12 @@ if ($go) {
|
|||
$image_data['photo_id'] = $photo_id;
|
||||
photo_import_all($database, $image_data);
|
||||
|
||||
if (!$external_workers)
|
||||
if (!$external_workers) {
|
||||
photo_import_worker($database, $po_user['id'], FALSE);
|
||||
print "<p>".$strings['import_all_complete']."</p>";
|
||||
} else {
|
||||
print "<p>$count ".$strings['import_all_queued']."</p>";
|
||||
}
|
||||
|
||||
print "<br/>".$strings['import_complete']."<br/>";
|
||||
site_footer($database);
|
||||
|
|
@ -237,7 +248,7 @@ switch($action) {
|
|||
// print "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".ini_get_size('upload_max_filesize')."\" />";
|
||||
print "<input type=\"file\" name=\"file_name[]\" alt=\"....\"/>";
|
||||
print "</td></tr>";
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
print "<div align=\"center\">\n";
|
||||
print $thm_elem['button.add'];
|
||||
|
|
@ -281,7 +292,7 @@ switch($action) {
|
|||
print "<td>";
|
||||
print emit_yes_no_combo("replace_existing", "f");
|
||||
}
|
||||
|
||||
|
||||
print "<td>";
|
||||
print "<input type=\"text\" name=\"comment\" value=\"$photo_version[3]\"/>\n";
|
||||
print "</td>";
|
||||
|
|
@ -289,7 +300,7 @@ switch($action) {
|
|||
print emit_colorspace_combo("colorspace", $photo_version[5]);
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
print "<center>";
|
||||
print $thm_elem['button.save.changes'];
|
||||
|
|
@ -321,7 +332,7 @@ switch($action) {
|
|||
print emit_td(emit_yes_no_text($photo_version[4]));
|
||||
print "<td>$photo_version[3]</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print "</table>\n";
|
||||
print "<center>";
|
||||
if ($photo_version[4] == 't') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue