summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-02-03 12:11:28 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-02-03 12:16:38 +0100
commit5816cbcad0e9c4cda4dc10b730a5a1ea2c4e419a (patch)
tree6724a88a7bcc3b97d6277550125bac91b4a72597 /application/controllers/file.php
parenta788fe55713e7c44068ee2dd8377b98037d9375f (diff)
api: implement file/create_multipaste
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php49
1 files changed, 3 insertions, 46 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 1b45c1ba3..c60831cba 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -700,55 +700,12 @@ class File extends MY_Controller {
$this->muser->require_access("apikey");
$ids = $this->input->post("ids");
- $errors = array();
-
- if (!$ids || !is_array($ids)) {
- show_error("No IDs specified");
- }
-
- if (count(array_unique($ids)) != count($ids)) {
- show_error("Duplicate IDs are not supported");
- }
-
- foreach ($ids as $id) {
- if (!$this->mfile->id_exists($id)) {
- $errors[] = array(
- "id" => $id,
- "reason" => "doesn't exist",
- );
- }
-
- $filedata = $this->mfile->get_filedata($id);
- if ($filedata["user"] != $this->muser->get_userid()) {
- $errors[] = array(
- "id" => $id,
- "reason" => "not owned by you",
- );
- }
- }
-
- if (!empty($errors)) {
- $errorstring = "";
- foreach ($errors as $error) {
- $errorstring .= $error["id"]." ".$error["reason"]."<br>\n";
- }
- show_error($errorstring);
- }
-
+ $userid = $this->muser->get_userid();
$limits = $this->muser->get_upload_id_limits();
- $url_id = $this->mmultipaste->new_id($limits[0], $limits[1]);
-
- $multipaste_id = $this->mmultipaste->get_multipaste_id($url_id);
- assert($multipaste_id !== false);
- foreach ($ids as $id) {
- $this->db->insert("multipaste_file_map", array(
- "file_url_id" => $id,
- "multipaste_id" => $multipaste_id,
- ));
- }
+ $ret = \service\files::create_multipaste($ids, $userid, $limits);
- return $this->_show_url(array($url_id), false);
+ return $this->_show_url(array($ret["url_id"]), false);
}
function delete()