Exemple #1
0
 public function onBeforeMain($tpl = null)
 {
     // Prevent phpStorm's whining...
     if ($tpl) {
     }
     // Load the model
     /** @var Categories $model */
     $model = $this->getModel('Categories');
     // Assign data to the view, part 1 (we need this later on)
     $this->categories = $model->get(true)->filter(function ($item) {
         return Filter::filterItem($item, true);
     });
     $this->vgroups = Filter::getCategoriesPerVisualGroup($this->categories);
     /** @var Releases $releasesModel */
     $releasesModel = $this->getModel();
     $releases = $releasesModel->get(true);
     $this->releases = [];
     if ($releases->count()) {
         /** @var Releases $release */
         foreach ($releases as $release) {
             $this->releases[$release->category_id] = $release;
         }
     }
     // Add RSS links
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     // Pass page params
     $this->params = $app->getParams();
     $this->cparams = \JComponentHelper::getParams('com_ars');
     $this->Itemid = $this->input->getInt('Itemid', 0);
     $this->menu = $app->getMenu()->getActive();
     return true;
 }
Exemple #2
0
 public function onBeforeBrowse($tpl = null)
 {
     // Prevent phpStorm's whining...
     if ($tpl) {
     }
     // Load the model
     /** @var Categories $model */
     $model = $this->getModel();
     // Assign data to the view, part 1 (we need this later on)
     $this->items = $model->get(true)->filter(function ($item) {
         return Filter::filterItem($item, true);
     });
     $visualGroups = Filter::getCategoriesPerVisualGroup($this->items);
     // Add RSS links
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     /** @var \JRegistry $params */
     $params = $app->getParams('com_ars');
     // Get the ordering
     $this->order = $model->getState('filter_order', 'id', 'cmd');
     $this->order_Dir = $model->getState('filter_order_Dir', 'DESC', 'cmd');
     // Assign data to the view
     $this->pagination = new \JPagination($model->count(), $model->limitstart, $model->limit);
     $this->vgroups = $visualGroups;
     // Pass page params
     $this->params = $app->getParams();
     $this->Itemid = $this->input->getInt('Itemid', 0);
     $this->menu = $app->getMenu()->getActive();
     return true;
 }
Exemple #3
0
 public function getItems($streams)
 {
     $arsContainer = \FOF30\Container\Container::getInstance('com_ars');
     $items = array();
     /** @var \Akeeba\ReleaseSystem\Site\Model\Update $model */
     $model = $arsContainer->factory->model('Update');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Items $dlModel */
     $dlModel = $arsContainer->factory->model('Items');
     foreach ($streams as $stream_id) {
         $items = $model->getItems($stream_id);
         if (empty($items)) {
             continue;
         }
         $i = array_shift($items);
         // Is the user authorized to download this item?
         $iFull = $dlModel->find($i->item_id);
         if (!\Akeeba\ReleaseSystem\Site\Helper\Filter::filterItem($iFull)) {
             continue;
         }
         // Add this item
         $newItem = array('id' => $i->item_id, 'release_id' => $i->release_id, 'name' => $i->name, 'version' => $i->version, 'maturity' => $i->maturity);
         $items[] = (object) $newItem;
     }
     return $items;
 }
Exemple #4
0
 public function onBeforeBrowse($tpl = null)
 {
     // Prevent phpStorm's whining...
     if ($tpl) {
     }
     // Load the model
     /** @var Releases $model */
     $model = $this->getModel();
     // Assign data to the view, part 1 (we need this later on)
     $this->items = $model->get()->filter(function ($item) {
         return Filter::filterItem($item, true);
     });
     // Add breadcrumbs
     $repoType = $this->items->first()->category->type;
     Breadcrumbs::addRepositoryRoot($repoType);
     Breadcrumbs::addCategory($this->items->first()->category->id, $this->items->first()->category->title);
     // Add RSS links
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     /** @var \JRegistry $params */
     $params = $app->getParams('com_ars');
     // Get the ordering
     $this->order = $model->getState('filter_order', 'id', 'cmd');
     $this->order_Dir = $model->getState('filter_order_Dir', 'DESC', 'cmd');
     // Assign data to the view
     $this->pagination = new \JPagination($model->count(), $model->limitstart, $model->limit);
     $this->category = $this->getModel('Categories');
     // Pass page params
     $this->params = $app->getParams();
     $this->Itemid = $this->input->getInt('Itemid', 0);
     $this->menu = $app->getMenu()->getActive();
     return true;
 }
Exemple #5
0
 public function onBeforeBrowse($tpl = null)
 {
     // Prevent phpStorm's whining...
     if ($tpl) {
     }
     // Load the model
     /** @var Items $model */
     $model = $this->getModel();
     // Assign data to the view, part 1 (we need this later on)
     $this->items = $model->get(true)->filter(function ($item) {
         return Filter::filterItem($item, true);
     });
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     $user = $this->container->platform->getUser();
     $params = $app->getParams();
     // Add Breadcrumbs
     /** @var Releases $release */
     $release = $this->getModel('Releases');
     /** @var Categories $category */
     $category = $release->category;
     Breadcrumbs::addRepositoryRoot($category->type);
     Breadcrumbs::addCategory($category->id, $category->title);
     Breadcrumbs::addRelease($release->id, $release->version);
     // DirectLink setup
     $this->downloadId = Filter::myDownloadID();
     $directlink = $params->get('show_directlink', 1) && !$user->guest;
     $this->directlink = $directlink;
     // Pass on Direct Link-related stuff
     if ($directlink) {
         $directlink_extensions = explode(',', $params->get('directlink_extensions', 'zip,tar,tar.gz,tgz,tbz,tar.bz2'));
         if (empty($directlink_extensions)) {
             $directlink_extensions = array();
         } else {
             $temp = array();
             foreach ($directlink_extensions as $ext) {
                 $temp[] = '.' . trim($ext);
             }
             $directlink_extensions = $temp;
         }
         $this->directlink_extensions = $directlink_extensions;
         $this->directlink_description = $params->get('directlink_description', \JText::_('COM_ARS_CONFIG_DIRECTLINKDESCRIPTION_DEFAULT'));
     }
     // Get the ordering
     $this->order = $model->getState('filter_order', 'id', 'cmd');
     $this->order_Dir = $model->getState('filter_order_Dir', 'DESC', 'cmd');
     // Assign data to the view
     $this->pagination = new \JPagination($model->count(), $model->limitstart, $model->limit);
     $this->release = $this->getModel('Releases');
     // Pass page params
     $this->params = $params;
     $this->Itemid = $this->input->getInt('Itemid', 0);
     $this->menu = $app->getMenu()->getActive();
     return true;
 }
Exemple #6
0
 public function onBeforeBrowse()
 {
     // Only apply on HTML views
     if (!in_array($this->input->getCmd('format', 'html'), ['html', 'feed'])) {
         return;
     }
     // Get the page parameters
     /** @var \JApplicationSite $app */
     $app = \JFactory::getApplication();
     $params = $app->getParams('com_ars');
     // Push the page params to the Releases model
     /** @var Categories $categoryModel */
     $categoryModel = $this->getModel('Categories')->orderby_filter($params->get('orderby', 'order'))->access_user($this->container->platform->getUser()->id);
     /** @var Releases $releasesModel */
     $releasesModel = $this->getModel()->orderby_filter($params->get('rel_orderby', 'order'))->access_user($this->container->platform->getUser()->id);
     // Get the category ID
     $id = $this->input->getInt('category_id', 0);
     if (empty($id)) {
         $id = $params->get('catid', 0);
     }
     try {
         // Try to find the category
         $categoryModel->find($id);
         // Make sure subscription level filtering allows access
         if (!Filter::filterItem($categoryModel) || !$categoryModel->published) {
             throw new \Exception('Filtering failed');
         }
     } catch (\Exception $e) {
         $noAccessURL = \JComponentHelper::getParams('com_ars')->get('no_access_url', '');
         if ($categoryModel->id && $categoryModel->redirect_unauth && $categoryModel->show_unauth_links) {
             $noAccessURL = $categoryModel->redirect_unauth;
         }
         if (!empty($noAccessURL)) {
             \JFactory::getApplication()->redirect($noAccessURL);
             return;
         }
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     // Filter the releases by this category
     $releasesModel->category($categoryModel->id)->published(1);
     /** @var BleedingEdge $bleedingEdgeModel */
     $bleedingEdgeModel = $this->container->factory->model('BleedingEdge');
     $bleedingEdgeModel->scanCategory($categoryModel);
     // Push the models to the view
     $this->getView()->setDefaultModel($releasesModel);
     $this->getView()->setModel('Categories', $categoryModel);
 }
Exemple #7
0
<?php

defined('_JEXEC') or die;
/** @var  \Akeeba\ReleaseSystem\Site\View\Releases\Html $this */
use Akeeba\ReleaseSystem\Site\Helper\Filter;
use Akeeba\ReleaseSystem\Site\Helper\Router;
use Akeeba\ReleaseSystem\Admin\Helper\Format;
$released = JFactory::getDate($item->created);
$release_url = Router::_('index.php?option=com_ars&view=Items&release_id=' . $item->id . '&Itemid=' . $Itemid);
$authorisedViewLevels = $this->getContainer()->platform->getUser()->getAuthorisedViewLevels();
if (!Filter::filterItem($item, false, $authorisedViewLevels) && !empty($item->redirect_unauth)) {
    $release_url = $item->redirect_unauth;
}
switch ($item->maturity) {
    case 'stable':
        $maturityClass = 'label-success';
        break;
    case 'rc':
        $maturityClass = 'label-info';
        break;
    case 'beta':
        $maturityClass = 'label-warning';
        break;
    case 'alpha':
        $maturityClass = 'label-important';
        break;
    default:
        $maturityClass = 'label-inverse';
        break;
}
?>
Exemple #8
0
<?php

defined('_JEXEC') or die;
/** @var  \Akeeba\ReleaseSystem\Site\View\Latest\Html $this */
use Akeeba\ReleaseSystem\Site\Helper\Filter;
use Akeeba\ReleaseSystem\Site\Helper\Router;
use Akeeba\ReleaseSystem\Admin\Helper\Format;
use Akeeba\ReleaseSystem\Admin\Helper\Select;
$download_url = Router::_('index.php?option=com_ars&view=Item&task=download&format=raw&id=' . $item->id . '&Itemid=' . $this->Itemid);
if (!Filter::filterItem($item, false, $this->getContainer()->platform->getUser()->getAuthorisedViewLevels()) && !empty($item->redirect_unauth)) {
    $download_url = $item->redirect_unauth;
}
?>


<tr>
	<td>
		<a href="{{ htmlentities($download_url) }}" rel="nofollow">
			{{{ $item->title }}}
		</a>
	</td>
	<td width="25%">
		<a href="{{ htmlentities($download_url) }}" rel="nofollow" class="btn btn-small">
			<span class="icon icon-download"></span>
			@lang('LBL_ITEM_DOWNLOAD')
		</a>
	</td>
	<td width="20%" class="small">
		@unless(!$this->cparams->get('show_downloads', 1))
			@lang('LBL_ITEMS_HITS')
			@sprintf(($item->hits == 1 ? 'LBL_RELEASES_TIME' : 'LBL_RELEASES_TIMES'), $item->hits)
 /**
  * Inisialises the arrays.
  */
 private function initialise()
 {
     // Make sure our auto-loader is set up and ready
     $container = \FOF30\Container\Container::getInstance('com_ars');
     /** @var \Akeeba\ReleaseSystem\Admin\Model\Releases $model */
     $model = $container->factory->model('Releases');
     $model->reset(true)->published(1)->latest(true)->access_user($container->platform->getUser()->id)->with(['items', 'category']);
     /** @var \FOF30\Model\DataModel\Collection $releases */
     $releases = $model->get(true)->filter(function ($item) {
         return \Akeeba\ReleaseSystem\Site\Helper\Filter::filterItem($item, true);
     });
     $cats = [];
     if ($releases->count()) {
         /** @var \Akeeba\ReleaseSystem\Admin\Model\Releases $release */
         foreach ($releases as $release) {
             $cat = $release->category;
             $cat->title = trim(strtoupper($cat->title));
             $cats[] = $cat;
             $this->categoryTitles[$cat->title] = $cat->id;
             $this->categoryLatest[$cat->id] = $release;
         }
     }
     $this->prepared = true;
 }
Exemple #10
0
 /**
  * Downloads the latest version of a software given its update stream ID
  *
  * @throws \RuntimeException
  */
 public function download()
 {
     $id = $this->input->getInt('id', 0);
     if ($id == 0) {
         // Do we have a menu item parameter?
         /** @var \JApplicationSite $app */
         $app = JFactory::getApplication();
         $params = $app->getParams('com_ars');
         $id = $params->get('streamid', 0);
     }
     /** @var UpdateModel $model */
     $model = $this->getModel();
     $view = $this->getView();
     $view->items = $model->getItems($id);
     $view->published = $model->getPublished($id);
     $items = $view->items;
     if (!$view->published) {
         // This stream isn't published. Go away! GO. AWAY.
         die;
     }
     if (empty($items)) {
         // No items to display. What are you doing here? Are you lost? Go away!
         die;
     }
     // Get the download item
     $downloadItem = array_shift($items);
     // Get the download model
     /** @var Download $downloadModel */
     $downloadModel = $this->container->factory->model('Download')->tmpInstance();
     /** @var Items $item */
     $item = $this->container->factory->model('Items')->tmpInstance();
     try {
         if ($downloadItem->item_id <= 0) {
             throw new \Exception('No item');
         }
         $item->find($downloadItem->item_id);
     } catch (\Exception $e) {
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     // Log in a user if I have to
     $downloadModel->loginUser();
     // Get the log table
     /** @var Logs $log */
     $log = $this->container->factory->model('Logs')->tmpInstance();
     if (!Filter::filterItem($item)) {
         $log->create(['authorized' => 0, 'item_id' => $downloadItem->item_id]);
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     $item->save(['hits' => ++$item->hits]);
     $log->create(['item_id' => $downloadItem->item_id, 'authorized' => 1]);
     $downloadModel->doDownload($item);
     JFactory::getApplication()->close();
 }
Exemple #11
0
 public function download()
 {
     $id = $this->input->getInt('id', null);
     // Get the page parameters
     $app = \JFactory::getApplication();
     $params = \JComponentHelper::getParams('com_ars');
     /** @var Download $model */
     $model = $this->getModel('Download');
     // Log in a user if I have to
     $model->loginUser();
     // Get the log table
     /** @var Logs $log */
     $log = $this->getModel('Logs');
     /** @var Items $item */
     $item = $this->getModel();
     // The item must exist and be accessible
     try {
         // Try to find the item
         $item->find($id);
         // Make sure subscription level filtering allows access
         if (!Filter::filterItem($item, false, $this->container->platform->getUser()->getAuthorisedViewLevels())) {
             throw new \Exception('Filtering failed');
         }
     } catch (\Exception $e) {
         $this->logFailedDownloadAttempt($item->id ? $id : 0);
         $noAccessURL = \JComponentHelper::getParams('com_ars')->get('no_access_url', '');
         if ($item->id && $item->redirect_unauth && $item->show_unauth_links) {
             $noAccessURL = $item->redirect_unauth;
         }
         if (!empty($noAccessURL)) {
             \JFactory::getApplication()->redirect($noAccessURL);
             return;
         }
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     try {
         // The release must be accessible
         $release = $item->release;
         // Make sure subscription level filtering allows access
         if (!$release->id || !Filter::filterItem($release, false, $this->container->platform->getUser()->getAuthorisedViewLevels())) {
             throw new \Exception('Filtering failed');
         }
     } catch (\Exception $e) {
         $this->logFailedDownloadAttempt($id);
         $noAccessURL = \JComponentHelper::getParams('com_ars')->get('no_access_url', '');
         if (isset($release) && $release->id && $release->redirect_unauth && $release->show_unauth_links) {
             $noAccessURL = $release->redirect_unauth;
         }
         if (!empty($noAccessURL)) {
             \JFactory::getApplication()->redirect($noAccessURL);
             return;
         }
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     // The category must be accessible
     try {
         $category = $release->category;
         // Make sure subscription level filtering allows access
         if (!$category->id || !Filter::filterItem($category, false, $this->container->platform->getUser()->getAuthorisedViewLevels())) {
             throw new \Exception('Filtering failed');
         }
     } catch (\Exception $e) {
         $this->logFailedDownloadAttempt($id);
         $noAccessURL = \JComponentHelper::getParams('com_ars')->get('no_access_url', '');
         if (isset($category) && $category->id && $category->redirect_unauth && $category->show_unauth_links) {
             $noAccessURL = $category->redirect_unauth;
         }
         if (!empty($noAccessURL)) {
             \JFactory::getApplication()->redirect($noAccessURL);
             return;
         }
         throw new \RuntimeException(\JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
     }
     // Hit the item
     $item->save(['hits' => ++$item->hits]);
     // Log the download
     $log->create(array('item_id' => $id, 'authorized' => 1));
     // Download the item
     $model->doDownload($item);
     $app->close();
 }