summaryrefslogtreecommitdiffstats
path: root/application/controllers/file.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/file.php')
-rw-r--r--application/controllers/file.php65
1 files changed, 46 insertions, 19 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 079802dbc..2a56df96c 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -180,37 +180,64 @@ class File extends CI_Controller {
echo $cached;
}
- // Allow users to delete their own IDs
- function delete()
+ function do_delete()
{
$this->muser->require_access();
- $id = $this->uri->segment(3);
- $this->data["id"] = $id;
+ $ids = $this->input->post("ids");
+ $errors = array();
+ $msgs = array();
+ $deleted_count = 0;
+ $total_count = 0;
- $process = $this->input->post("process");
- if ($this->var->cli_client) {
- $process = true;
+ if (!$ids) {
+ show_error("No IDs specified");
}
- if ($id && !$this->file_mod->id_exists($id)) {
- $this->output->set_status_header(404);
- $this->data["msg"] = "Unknown ID.";
- } elseif ($process) {
+ foreach ($ids as $id) {
+ $total_count++;
+
+ if (!$this->file_mod->id_exists($id)) {
+ $errors[] = "'$id' didn't exist anymore.";
+ continue;
+ }
+
if ($this->file_mod->delete_id($id)) {
- $this->load->view($this->var->view_dir.'/header', $this->data);
- $this->load->view($this->var->view_dir.'/deleted', $this->data);
- $this->load->view($this->var->view_dir.'/footer', $this->data);
- return;
+ $msgs[] = "'$id' has been removed.";
+ $deleted_count++;
} else {
- $this->data["msg"] = "Deletion failed. Do you really own that file?";
+ $errors[] = "'$id' couldn't be deleted.";
}
}
- $this->data["filedata"] = $this->file_mod->get_filedata($id);
- $this->data["can_delete"] = $this->data["filedata"]["user"] == $this->muser->get_userid();
+ $this->data["errors"] = $errors;
+ $this->data["msgs"] = $msgs;
+ $this->data["deleted_count"] = $deleted_count;
+ $this->data["total_count"] = $total_count;
+
+ $this->load->view($this->var->view_dir.'/header', $this->data);
+ $this->load->view($this->var->view_dir.'/deleted', $this->data);
+ $this->load->view($this->var->view_dir.'/footer', $this->data);
+ }
+
+ function delete()
+ {
+ $this->muser->require_access();
+
+ $id = $this->uri->segment(3);
+ $this->data["id"] = $id;
+
+ if ($id && !$this->file_mod->id_exists($id)) {
+ $this->output->set_status_header(404);
+ echo "Unknown ID '$id'.\n";
+ return;
+ }
- $this->file_mod->display_info($id);
+ if ($this->file_mod->delete_id($id)) {
+ echo "$id has been deleted.\n";
+ } else {
+ echo "Deletion failed. Do you really own that file?\n";
+ }
}
// Handle pastes