Ejemplo n.º 1
0
 /**
  * Gets a product's files list
  * formatted for display
  *
  * @param int $address_id
  * @return string html
  */
 function getFiles($product_id)
 {
     $html = '';
     // get the product's files
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductFiles', 'TiendaModel');
     $model->setState('filter_product', $product_id);
     $model->setState('filter_enabled', 1);
     //$model->setState( 'filter_purchaserequired', 1 );
     $items = $model->getList();
     // get the user's active subscriptions to this product, if possible
     $submodel = JModel::getInstance('Subscriptions', 'TiendaModel');
     $submodel->setState('filter_userid', JFactory::getUser()->id);
     $submodel->setState('filter_productid', $product_id);
     $subs = $submodel->getList();
     if (!empty($items)) {
         // reconcile the list of files to the date the sub's files were last checked
         Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
         $subhelper = new TiendaHelperSubscription();
         $subhelper->reconcileFiles($subs);
         Tienda::load('TiendaHelperBase', 'helpers._base');
         $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
         $filtered_items = $helper->filterRestricted($items, JFactory::getUser()->id);
         $view = $this->getView('products', 'html');
         $view->set('_controller', 'products');
         $view->set('_view', 'products');
         $view->set('_doTask', true);
         $view->set('hidemenu', true);
         $view->setModel($model, true);
         $view->setLayout('product_files');
         $view->set('downloadItems', $filtered_items[0]);
         $view->set('nondownloadItems', $filtered_items[1]);
         $view->set('product_id', $product_id);
         ob_start();
         $view->display();
         $html = ob_get_contents();
         ob_end_clean();
     }
     return $html;
 }
Ejemplo n.º 2
0
 /**
  * Gets a product's files list
  * formatted for display
  *
  * @param int $address_id
  * @return string html
  */
 function getFiles($view, $product_id)
 {
     $html = '';
     // get the product's files
     JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
     $model = JModel::getInstance('ProductFiles', 'TiendaModel');
     $model->setState('filter_product', $product_id);
     $model->setState('filter_enabled', 1);
     //$model->setState( 'filter_purchaserequired', 1 );
     $items = $model->getList();
     // get the user's active subscriptions to this product, if possible
     $submodel = JModel::getInstance('Subscriptions', 'TiendaModel');
     $submodel->setState('filter_userid', JFactory::getUser()->id);
     $submodel->setState('filter_productid', $product_id);
     $subs = $submodel->getList();
     if (!empty($items)) {
         // reconcile the list of files to the date the sub's files were last checked
         Tienda::load('TiendaHelperSubscription', 'helpers.subscription');
         $subhelper = new TiendaHelperSubscription();
         $subhelper->reconcileFiles($subs);
         Tienda::load('TiendaHelperBase', 'helpers._base');
         $helper = TiendaHelperBase::getInstance('ProductDownload', 'TiendaHelper');
         $filtered_items = $helper->filterRestricted($items, JFactory::getUser()->id);
         $view->setModel($model, true);
         $product_file_data = new stdClass();
         $product_file_data->downloadItems = $filtered_items[0];
         $product_file_data->nondownloadItems = $filtered_items[1];
         $product_file_data->product_id = $product_id;
         $lyt = $view->getLayout();
         $view->setLayout('product_files');
         $view->product_file_data = $product_file_data;
         ob_start();
         echo $view->loadTemplate(null);
         $html = ob_get_contents();
         ob_end_clean();
         $view->setLayout($lyt);
         unset($view->product_file_data);
     }
     return $html;
 }