summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-02-03 11:38:03 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-02-03 11:38:03 +0100
commita788fe55713e7c44068ee2dd8377b98037d9375f (patch)
treede44dd8802d8e7c05fdf0a8bfaa395094419087d /application/controllers/file.php
parentd9c895ce4f53b180fc11c3b5a172c4cf787b1279 (diff)
api: implement file/delete
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php51
1 files changed, 4 insertions, 47 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 63f6a71b5..1b45c1ba3 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -683,55 +683,12 @@ class File extends MY_Controller {
$this->muser->require_access("apikey");
$ids = $this->input->post("ids");
- $userid = $this->muser->get_userid();
- $errors = array();
- $deleted = array();
- $deleted_count = 0;
- $total_count = 0;
-
- if (!$ids || !is_array($ids)) {
- show_error("No IDs specified");
- }
- foreach ($ids as $id) {
- $total_count++;
- $next = false;
-
- foreach (array($this->mfile, $this->mmultipaste) as $model) {
- if ($model->id_exists($id)) {
- if ($model->get_owner($id) !== $userid) {
- $errors[] = array(
- "id" => $id,
- "reason" => "wrong owner",
- );
- continue;
- }
- if ($model->delete_id($id)) {
- $deleted[] = $id;
- $deleted_count++;
- $next = true;
- } else {
- $errors[] = array(
- "id" => $id,
- "reason" => "unknown error",
- );
- }
- }
- }
-
- if ($next) {
- continue;
- }
-
- $errors[] = array(
- "id" => $id,
- "reason" => "doesn't exist",
- );
- }
+ $ret = \service\files::delete($ids);
- $this->data["errors"] = $errors;
- $this->data["deleted_count"] = $deleted_count;
- $this->data["total_count"] = $total_count;
+ $this->data["errors"] = $ret["errors"];
+ $this->data["deleted_count"] = $ret["deleted_count"];
+ $this->data["total_count"] = $ret["total_count"];
$this->load->view('header', $this->data);
$this->load->view($this->var->view_dir.'/deleted', $this->data);