From c553bb64715f40d1755bb84c277442df88e3a925 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 6 Sep 2016 14:02:31 +0200 Subject: Add multipaste queue Signed-off-by: Florian Pritz --- application/controllers/file/multipaste.php | 113 ++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 application/controllers/file/multipaste.php (limited to 'application/controllers/file') diff --git a/application/controllers/file/multipaste.php b/application/controllers/file/multipaste.php new file mode 100644 index 000000000..00efb2403 --- /dev/null +++ b/application/controllers/file/multipaste.php @@ -0,0 +1,113 @@ + + * + * Licensed under AGPLv3 + * (see COPYING for full license text) + * + */ + +class Multipaste extends MY_Controller { + + function __construct() { + parent::__construct(); + + $this->load->model('mfile'); + $this->load->model('mmultipaste'); + } + + public function append_multipaste_queue() { + $this->muser->require_access("basic"); + + $ids = $this->input->post("ids"); + if ($ids === false) { + $ids = []; + } + + $m = new \service\multipaste_queue(); + $m->append($ids); + + redirect("file/multipaste/queue"); + } + + public function review_multipaste() { + $this->muser->require_access("basic"); + + $this->load->view('header', $this->data); + $this->load->view('file/review_multipaste', $this->data); + $this->load->view('footer', $this->data); + } + + public function queue() { + $this->muser->require_access("basic"); + + $m = new \service\multipaste_queue(); + $ids = $m->get(); + + $this->data['ids'] = $ids; + $this->data['items'] = array_map(function($id) {return $this->_get_multipaste_item($id);}, $ids); + + $this->load->view('header', $this->data); + $this->load->view('file/multipaste/queue', $this->data); + $this->load->view('footer', $this->data); + } + + public function form_submit() { + $this->muser->require_access("basic"); + + $ids = $this->input->post('ids'); + $process = $this->input->post('process'); + + if ($ids === false) { + $ids = []; + } + + $m = new \service\multipaste_queue(); + $m->set($ids); + + $dispatcher = [ + 'save' => function() use ($ids, $m) { + redirect("file/multipaste/queue"); + }, + 'create' => function() use ($ids, $m) { + $userid = $this->muser->get_userid(); + $limits = $this->muser->get_upload_id_limits(); + $ret = \service\files::create_multipaste($ids, $userid, $limits); + $m->set([]); + redirect($ret['url_id']); + }, + ]; + + if (isset($dispatcher[$process])) { + $dispatcher[$process](); + } else { + throw new \exceptions\UserInputException("file/multipaste/form_submit/invalid-process-value", "Value in process field not found in dispatch table"); + } + } + + public function ajax_submit() { + $this->muser->require_access("basic"); + $ids = $this->input->post('ids'); + + if ($ids === false) { + $ids = []; + } + + $m = new \service\multipaste_queue(); + $m->set($ids); + } + + private function _get_multipaste_item($id) { + $filedata = $this->mfile->get_filedata($id); + $item = []; + $item['id'] = $filedata['id']; + $item['tooltip'] = \service\files::tooltip($filedata); + $item['title'] = $filedata['filename']; + if (\libraries\Image::type_supported($filedata["mimetype"])) { + $item['thumbnail'] = site_url("file/thumbnail/".$filedata['id']); + } + + return $item; + } + +} -- cgit v1.2.3-24-g4f1b From c9fa3ed37fd1371ef24f6c3330995025295d7baf Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 6 Sep 2016 14:11:39 +0200 Subject: Allow creation of multipastes from upload history Signed-off-by: Florian Pritz --- application/controllers/file/file_default.php | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'application/controllers/file') diff --git a/application/controllers/file/file_default.php b/application/controllers/file/file_default.php index 2b77866a0..3b5eb0ee4 100644 --- a/application/controllers/file/file_default.php +++ b/application/controllers/file/file_default.php @@ -683,6 +683,40 @@ class File_default extends MY_Controller { $this->load->view('footer', $this->data); } + public function handle_history_submit() + { + $this->muser->require_access("apikey"); + + $process = $this->input->post("process"); + + $dispatcher = [ + "delete" => function() { + return $this->do_delete(); + }, + "multipaste" => function() { + return $this->_append_multipaste_queue(); + }, + ]; + + if (isset($dispatcher[$process])) { + $dispatcher[$process](); + } else { + throw new \exceptions\UserInputException("file/handle_history_submit/invalid-process-value", "Value in process field not found in dispatch table"); + } + } + + private function _append_multipaste_queue() + { + $ids = $this->input->post("ids"); + if ($ids === false) { + $ids = []; + } + + $m = new \service\multipaste_queue(); + $m->append($ids); + redirect("file/multipaste/queue"); + } + function upload_history() { $this->muser->require_access("apikey"); -- cgit v1.2.3-24-g4f1b From eeed107aebabb3cb4829a9daedf88f139ee703ee Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 10 Sep 2016 16:27:50 +0200 Subject: Fix missing / in redirect after creating multipaste via webui Signed-off-by: Florian Pritz --- application/controllers/file/multipaste.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/controllers/file') diff --git a/application/controllers/file/multipaste.php b/application/controllers/file/multipaste.php index 00efb2403..759a781f0 100644 --- a/application/controllers/file/multipaste.php +++ b/application/controllers/file/multipaste.php @@ -74,7 +74,7 @@ class Multipaste extends MY_Controller { $limits = $this->muser->get_upload_id_limits(); $ret = \service\files::create_multipaste($ids, $userid, $limits); $m->set([]); - redirect($ret['url_id']); + redirect($ret['url_id'].'/'); }, ]; -- cgit v1.2.3-24-g4f1b