From 0443d0829ab7e2d30825fded2f172b74d26b5b3c Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 19 Feb 2015 22:36:29 +0100 Subject: Add claiming of multipastes Signed-off-by: Florian Pritz --- application/controllers/file.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'application/controllers/file.php') diff --git a/application/controllers/file.php b/application/controllers/file.php index fd7eb9962..6a14fceee 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -813,6 +813,7 @@ class File extends MY_Controller { } if ($multipaste !== false) { + $userid = $this->muser->get_userid(); $ids[] = \service\files::create_multipaste($ids, $userid, $limits)["url_id"]; } @@ -835,17 +836,17 @@ class File extends MY_Controller { assert(is_array($ids)); foreach ($ids as $key => $id) { - $filedata = $this->mfile->get_filedata($id); + $affected = 0; + $affected += $this->mfile->adopt($id); + $affected += $this->mmultipaste->adopt($id); - if ($filedata["user"] != 0) { + if ($affected == 0) { $errors[] = $id; } - - $this->mfile->adopt($id); } if (!empty($errors)) { - throw new \exceptions\PublicApiException("file/claim_id/already-owned", "Someone already owns '".implode(", ", $errors)."', can't reassign."); + throw new \exceptions\PublicApiException("file/claim_id/failed", "Failed to claim ".implode(", ", $errors).""); } $this->session->unset_userdata("last_upload"); -- cgit v1.2.3-24-g4f1b