From a08a411df91947b32d8e603b450548321e90c57e Mon Sep 17 00:00:00 2001 From: Alexey Ch Date: Sat, 26 Mar 2016 17:46:29 +0500 Subject: [PATCH 1/3] Add to AJAX script action.php link to method Add to AJAX script action.php link to method "ticket/file/desc" than can edit description on image. --- assets/components/tickets/action.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/components/tickets/action.php b/assets/components/tickets/action.php index 98108e3..49d100d 100644 --- a/assets/components/tickets/action.php +++ b/assets/components/tickets/action.php @@ -72,6 +72,7 @@ case 'ticket/file/upload': $response = $Tickets->fileUpload($_POST, 'Ticket'); break; case 'ticket/file/delete': $response = $Tickets->fileDelete($_POST['id']); break; + case 'ticket/file/desc': $response = $Tickets->fileDesc($_POST['id'], $_POST['desc']); break; default: $message = $_REQUEST['action'] != $action ? 'tickets_err_register_globals' : 'tickets_err_unknown'; $response = $modx->toJSON(array('success' => false, 'message' => $modx->lexicon($message))); @@ -82,4 +83,4 @@ } @session_write_close(); -exit($response); \ No newline at end of file +exit($response); From 02e9e070d0e14aabedf139af01d21f93ef9cd8ae Mon Sep 17 00:00:00 2001 From: Alexey Ch Date: Sat, 26 Mar 2016 17:48:43 +0500 Subject: [PATCH 2/3] Processor for edit description images --- .../processors/web/file/desc.class.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 core/components/tickets/processors/web/file/desc.class.php diff --git a/core/components/tickets/processors/web/file/desc.class.php b/core/components/tickets/processors/web/file/desc.class.php new file mode 100644 index 0000000..a823387 --- /dev/null +++ b/core/components/tickets/processors/web/file/desc.class.php @@ -0,0 +1,40 @@ +modx->hasPermission($this->permission)) { + return $this->modx->lexicon('access_denied'); + } + return true; + } + + + /** + * @return array|string + */ + public function process() { + $id = $this->getProperty('id'); + $description = $this->getProperty('description'); + /** @var TicketFile $file */ + if (!$file = $this->modx->getObject($this->classKey, $id)) { + return $this->failure($this->modx->lexicon('ticket_err_file_ns')); + } + elseif ($file->createdby != $this->modx->user->id && !$this->modx->user->isMember('Administrator')) { + return $this->failure($this->modx->lexicon('ticket_err_file_owner')); + } + $file->set('description', $description); + $file->save(); + + return $this->success(); + } + +} + +return 'TicketFileDescProcessor'; From 1874268344d7e66845faaba159a37feed444e20a Mon Sep 17 00:00:00 2001 From: Alexey Ch Date: Sat, 26 Mar 2016 17:51:06 +0500 Subject: [PATCH 3/3] Add call processor that can make change descriptio Add call processor that can make change description on image file --- .../tickets/model/tickets/tickets.class.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/components/tickets/model/tickets/tickets.class.php b/core/components/tickets/model/tickets/tickets.class.php index c10e3c8..86cfe5e 100644 --- a/core/components/tickets/model/tickets/tickets.class.php +++ b/core/components/tickets/model/tickets/tickets.class.php @@ -1431,6 +1431,26 @@ public function fileUpload($data, $class = 'Ticket') { } + /** + * Edit description in uploaded file + * + * @param $id,$description + * + * @return array|string + */ + public function fileDesc($id,$description) { + if (!$this->authenticated || empty($this->config['allowFiles'])) { + return $this->error('ticket_err_access_denied'); + } + /** @var modProcessorResponse $response */ + $response = $this->runProcessor('web/file/desc', array('id' => $id, 'description' => $description)); + if ($response->isError()) { + return $this->error($response->getMessage()); + } + + return $this->success(); + } + /** * Delete or restore uploaded file *