[replace] if replace gets a POST with no replacement, show the ask-for-a-replacement page, see #1034
This commit is contained in:
parent
4e362d816f
commit
f033efd456
1 changed files with 7 additions and 0 deletions
|
@ -22,6 +22,7 @@ class ReplaceFile extends Extension
|
||||||
|
|
||||||
$this->theme->display_replace_page($page, $image_id);
|
$this->theme->display_replace_page($page, $image_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($event->page_matches("replace/{image_id}", method: "POST", permission: Permissions::REPLACE_IMAGE)) {
|
if ($event->page_matches("replace/{image_id}", method: "POST", permission: Permissions::REPLACE_IMAGE)) {
|
||||||
$image_id = $event->get_iarg('image_id');
|
$image_id = $event->get_iarg('image_id');
|
||||||
$image = Image::by_id($image_id);
|
$image = Image::by_id($image_id);
|
||||||
|
@ -29,6 +30,12 @@ class ReplaceFile extends Extension
|
||||||
throw new UploadException("Can not replace Post: No post with ID $image_id");
|
throw new UploadException("Can not replace Post: No post with ID $image_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(empty($event->get_POST("url")) && count($_FILES) == 0) {
|
||||||
|
$page->set_mode(PageMode::REDIRECT);
|
||||||
|
$page->set_redirect(make_link("replace/$image_id"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($event->get_POST("url"))) {
|
if (!empty($event->get_POST("url"))) {
|
||||||
$tmp_filename = shm_tempnam("transload");
|
$tmp_filename = shm_tempnam("transload");
|
||||||
fetch_url($event->req_POST("url"), $tmp_filename);
|
fetch_url($event->req_POST("url"), $tmp_filename);
|
||||||
|
|
Reference in a new issue