/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 12.1 * @throws LogicException * @throws RuntimeException */ public function execute() { if (!JFactory::getUser()->authorise('attachment.delete', 'com_monitor')) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $app = JFactory::getApplication(); $model = new MonitorModelAttachments($app); $id = $app->input->getInt('id'); if (!$id) { throw new Exception(JText::_('JERROR_NO_ITEMS_SELECTED'), 404); } $model->delete(array($id)); $app->enqueueMessage(JText::_('COM_MONITOR_ATTACHMENT_DELETED')); $return = base64_decode($this->app->input->get('return', '', 'BASE64')); if (!JUri::isInternal($return)) { $return = 'index.php?option=com_monitor&view=projects'; } $this->app->redirect(JRoute::_($return, false)); return true; }
/** * Retrieves the attachments for all comments of the given issue. * * @param int $issueId ID of the issue. * * @see MonitorModelAttachments::getAttachments * * @return mixed Null on failure, an array indexed by attachment IDs on success. */ public function getIssueCommentsAttachments($issueId) { $modelAttachments = new MonitorModelAttachments(); return $modelAttachments->attachmentsComments($issueId); }
/** * Retrieves the attachments for this issue. * * @see MonitorModelAttachments::getAttachments * * @return mixed Null on failure, an array indexed by attachment IDs on success. */ public function getAttachments() { $modelAttachments = new MonitorModelAttachments(); return $modelAttachments->attachmentsIssue($this->issueId); }
/** * Validates uploaded files from a form. * * @param array $files Array containing the files to validate. * @param array $data Other data from the form. * @param MonitorModelAttachments $modelAttachments Model to use. * * @return array|null A filtered array if all files are valid, null if not. */ public function validateFiles($files, $data, $modelAttachments = null) { if (!$modelAttachments) { $modelAttachments = new MonitorModelAttachments($this->app); } foreach ($files as $i => $file) { if ($file[0]['error'] === UPLOAD_ERR_NO_FILE) { unset($files[$i]); } } if (!$modelAttachments->canUpload($files)) { // Store data for redirects. if (!$this->form) { $this->loadForm(); } $this->app->setUserState($this->form->getName() . '.data', $data); return null; } return $files; }