From 064bd7fd017fc139f56d4ea8b61ecc1cbd327cb5 Mon Sep 17 00:00:00 2001 From: shish Date: Thu, 2 Aug 2007 20:49:25 +0000 Subject: [PATCH] Use the veto error message, not adding blocks from within main.php git-svn-id: file:///home/shish/svn/shimmie2/trunk@422 7f39781d-f577-437e-ae19-be835c7a54ca --- ext/image/main.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/ext/image/main.php b/ext/image/main.php index c7b278c3..e0c30ce3 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -34,8 +34,8 @@ class ImageIO extends Extension { } if(is_a($event, 'UploadingImageEvent')) { - $ok = $this->add_image($event->image); - if(!$ok) $event->veto(); + $error = $this->add_image($event->image); + if(!empty($error)) $event->veto($error); } if(is_a($event, 'ImageDeletionEvent')) { @@ -172,11 +172,9 @@ class ImageIO extends Extension { */ $existing = $database->get_image_by_hash($image->hash); if(!is_null($existing)) { - $page->add_block(new Block("Error uploading {$image->filename}", - "Image {$existing->id} ". - "already has hash {$image->hash}:

". - build_thumb_html($existing))); - return false; + $error = "Image {$existing->id} ". + "already has hash {$image->hash}:

".build_thumb_html($existing); + return $error; } // actually insert the info @@ -195,27 +193,25 @@ class ImageIO extends Extension { * insert the image info into the database */ if(!copy($image->temp_filename, $image->get_image_filename())) { - $page->add_block(new Block("Error uploading {$image->filename}", - "The image couldn't be moved from the temporary area to the - main data store -- is the web server allowed to write to '". - ($image->get_image_filename())."'?")); send_event(new ImageDeletionEvent($image->id)); - return false; + $error = "The image couldn't be moved from the temporary area to the + main data store -- is the web server allowed to write to '". + ($image->get_image_filename())."'?"; + return $error; } chmod($image->get_image_filename(), 0644); if(!$this->make_thumb($image->get_image_filename(), $image->get_thumb_filename())) { - $page->add_block(new Block("Error uploading {$image->filename}", - "The image thumbnail couldn't be generated -- is the web - server allowed to write to '".($image->get_thumb_filename())."'?")); send_event(new ImageDeletionEvent($image->id)); - return false; + $error="The image thumbnail couldn't be generated -- is the web + server allowed to write to '".($image->get_thumb_filename())."'?"; + return $error; } chmod($image->get_thumb_filename(), 0644); send_event(new TagSetEvent($image->id, $image->get_tag_array())); - return true; + return null; } // }}} // fetch image {{{