From bb64fc9350d9159ea23f415de7964b6a4b2123d4 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 19 Dec 2010 14:21:51 +0100 Subject: add deleteion support to the webui Signed-off-by: Florian Pritz --- system/application/controllers/file.php | 32 +++++++++++++++++++++++---- system/application/models/file_mod.php | 1 + system/application/views/file/delete_form.php | 9 ++++++++ system/application/views/file/deleted.php | 3 +++ system/application/views/file/html_header.php | 2 +- system/application/views/file/upload_form.php | 4 +++- 6 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 system/application/views/file/delete_form.php create mode 100644 system/application/views/file/deleted.php diff --git a/system/application/controllers/file.php b/system/application/controllers/file.php index 40a5c9016..e42d1d3db 100644 --- a/system/application/controllers/file.php +++ b/system/application/controllers/file.php @@ -86,14 +86,38 @@ class File extends Controller { // Allow users to delete IDs if their password matches the one used when uploading function delete() { + $data = array(); $id = $this->uri->segment(3); $password = $this->input->post('password'); - if ($this->file_mod->delete_id($id, $password)) { - echo $id." deleted\n"; + $data["title"] = "Delete"; + $data["id"] = $id; + if ($password) { + if ($this->file_mod->delete_id($id, $password)) { + if ($this->var->cli_client) { + echo $id." deleted\n"; + die(); + } else { + $this->load->view('file/header', $data); + $this->load->view('file/deleted', $data); + $this->load->view('file/footer', $data); + return; + } + } else { + if ($this->var->cli_client) { + echo 'Couldn\'t delete '.$id."\n"; + die(); + } else { + $data["msg"] = "Deletion failed. Is the password correct?"; + } + } + } + if ($this->var->cli_client) { + die(); } else { - echo 'Couldn\'t delete '.$id."\n"; + $this->load->view('file/header', $data); + $this->load->view('file/delete_form', $data); + $this->load->view('file/footer', $data); } - die(); } // Take the content from post instead of a file diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php index 83834f7f1..5a06a9801 100644 --- a/system/application/models/file_mod.php +++ b/system/application/models/file_mod.php @@ -215,6 +215,7 @@ class File_mod extends Model { $data['plain_link'] = site_url($id.'/plain'); $data['auto_link'] = site_url($id).'/'; $data['rmd_link'] = site_url($id.'/rmd'); + $data['delete_link'] = site_url("file/delete/".$id); header("Content-Type: text/html\n"); if ($mode) { diff --git a/system/application/views/file/delete_form.php b/system/application/views/file/delete_form.php new file mode 100644 index 000000000..7d4f2329f --- /dev/null +++ b/system/application/views/file/delete_form.php @@ -0,0 +1,9 @@ +
+ +

+ "; ?> + Password: + +

+ +
diff --git a/system/application/views/file/deleted.php b/system/application/views/file/deleted.php new file mode 100644 index 000000000..865b5304a --- /dev/null +++ b/system/application/views/file/deleted.php @@ -0,0 +1,3 @@ +
+

has been deleted.

+
diff --git a/system/application/views/file/html_header.php b/system/application/views/file/html_header.php index b7e27315d..52ffab007 100644 --- a/system/application/views/file/html_header.php +++ b/system/application/views/file/html_header.php @@ -11,7 +11,7 @@ Raw | Plain | Currently: | - Timeout: + Timeout:
Code | Render Markdown diff --git a/system/application/views/file/upload_form.php b/system/application/views/file/upload_form.php index ec7ab53de..fe3f5db5a 100644 --- a/system/application/views/file/upload_form.php +++ b/system/application/views/file/upload_form.php @@ -2,13 +2,15 @@

File: - +
+ Optional password (for deletion):

OR


+ Optional password (for deletion):

-- cgit v1.2.3-24-g4f1b