Added merged indicator to DataUploadEvent and ImageAddEvent

Changed merge process so that the ID of the merged image can make it back through the event chanin
This commit is contained in:
Matthew Barbour
2019-06-19 19:40:25 -05:00
committed by matthew
parent 5a30ce1c83
commit 5eb4a66ab7
6 changed files with 13 additions and 9 deletions

View File

@@ -88,7 +88,7 @@ class ImageIO extends Extension
public function onImageAddition(ImageAdditionEvent $event)
{
try {
$this->add_image($event->image);
$this->add_image($event);
} catch (ImageAdditionException $e) {
throw new UploadException($e->error);
}
@@ -175,10 +175,12 @@ class ImageIO extends Extension
// add image {{{
private function add_image(Image $image)
private function add_image(ImageAdditionEvent $event)
{
global $user, $database, $config;
$image = $event->image;
/*
* Validate things
*/
@@ -201,7 +203,9 @@ class ImageIO extends Extension
if (isset($_GET['source']) && isset($_GET['update'])) {
send_event(new SourceSetEvent($existing, $_GET['source']));
}
return null;
$event->merged = true;
$event->image = Image::by_id($existing->id);
return;
} else {
$error = "Image <a href='".make_link("post/view/{$existing->id}")."'>{$existing->id}</a> ".
"already has hash {$image->hash}:<p>".$this->theme->build_thumb_html($existing);