Exemplo n.º 1
0
 /**
  * Display the view
  */
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $this->form->title = jdownloadshelper::getUserGroupInfos($this->item->group_id);
     $this->addToolbar();
     parent::display($tpl);
 }
Exemplo n.º 2
0
 /**
  * Method to delete an assigned file from the download.
  *
  *
  * @return    Boolean    True if successful, false otherwise.
  */
 public function deletefile()
 {
     $jinput = JFactory::getApplication()->input;
     $type = $jinput->get('type', '');
     $id = $jinput->get('id', 0, 'int');
     // load the download data
     $data = $this->getModel()->getItem($id);
     // check permissions
     if ($data->params->get('access-edit') == true) {
         // Load the backend helper methodes
         require_once JPATH_ADMINISTRATOR . '/components/com_jdownloads/helpers/jdownloadshelper.php';
         if ($type == 'prev') {
             // delete the preview file
             $result = jdownloadshelper::deletePreviewFile($id);
         } else {
             // delete the main file
             $result = jdownloadshelper::deleteFile($id);
         }
     } else {
         // no permissions - do nothing
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     // Add a message to the message queue
     $application = JFactory::getApplication();
     if ($result) {
         $application->enqueueMessage(JText::_('COM_JDOWNLOADS_FILE_DELETED_MSG'), 'message');
     } else {
         $application->enqueueMessage(JText::_('COM_JDOWNLOADS_FILE_DELETED_MSG_ERROR'), 'error');
     }
     // Redirect to the download view page.
     $this->setRedirect(JRoute::_('index.php?option=com_jdownloads&view=download&id=' . $id, false));
     return $result;
 }