From 19f0aab3221dd7760387cbec745c1eca9b215af7 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 9 Sep 2017 16:08:00 +0200 Subject: WIP: CI3 migration 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/Multipaste.php') diff --git a/application/controllers/file/Multipaste.php b/application/controllers/file/Multipaste.php new file mode 100644 index 000000000..50367697c --- /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_array("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_array('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_array('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 4388f9080ded6d4e4db9a333e94a005ba072a8cd Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 18 Sep 2017 12:45:31 +0200 Subject: Migrate return code checks for CI3 Signed-off-by: Florian Pritz --- application/controllers/file/Multipaste.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'application/controllers/file/Multipaste.php') diff --git a/application/controllers/file/Multipaste.php b/application/controllers/file/Multipaste.php index 50367697c..cc8ab8819 100644 --- a/application/controllers/file/Multipaste.php +++ b/application/controllers/file/Multipaste.php @@ -20,7 +20,7 @@ class Multipaste extends MY_Controller { $this->muser->require_access("basic"); $ids = $this->input->post_array("ids"); - if ($ids === false) { + if ($ids === null) { $ids = []; } @@ -58,7 +58,7 @@ class Multipaste extends MY_Controller { $ids = $this->input->post_array('ids'); $process = $this->input->post('process'); - if ($ids === false) { + if ($ids === null) { $ids = []; } @@ -89,7 +89,7 @@ class Multipaste extends MY_Controller { $this->muser->require_access("basic"); $ids = $this->input->post_array('ids'); - if ($ids === false) { + if ($ids === null) { $ids = []; } -- cgit v1.2.3-24-g4f1b