/** * Delete image */ public function removeImage() { // Check for request forgeries. JSession::checkToken("get") or jexit(JText::_('JINVALID_TOKEN')); // Get item id $itemId = $this->input->get->getInt("id"); $redirectOptions = array("view" => "reward", "layout" => "edit", "id" => $itemId); // Create an reward object. $reward = new Crowdfunding\Reward(JFactory::getDbo()); $reward->load($itemId); // Check for registered user if (!$reward->getId()) { $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_IMAGE'), $redirectOptions); return; } $imagesFolder = CrowdfundingHelper::getImagesFolder($reward->getUserId(), JPATH_ROOT); try { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.path'); $model = $this->getModel(); $model->removeImage($itemId, $imagesFolder); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_CROWDFUNDING_IMAGE_DELETED'), $redirectOptions); }
/** * Delete image */ public function removeImage() { // Check for request forgeries. JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN')); // Get item id $itemId = $this->input->get->getInt('id'); $redirectOptions = array('view' => 'reward', 'layout' => 'edit', 'id' => $itemId); // Create an reward object. $reward = new Crowdfunding\Reward(JFactory::getDbo()); $reward->load($itemId); // Check for registered user if (!$reward->getId()) { $this->displayNotice(JText::_('COM_CROWDFUNDING_ERROR_INVALID_IMAGE'), $redirectOptions); return; } $imagesFolder = CrowdfundingHelper::getImagesFolder($reward->getUserId(), JPATH_ROOT); try { $model = $this->getModel(); $model->removeImage($itemId, $imagesFolder); } catch (Exception $e) { JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding'); throw new Exception(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM')); } $this->displayMessage(JText::_('COM_CROWDFUNDING_IMAGE_DELETED'), $redirectOptions); }