Example #1
0
 public function initContent()
 {
     parent::initContent();
     $user_id = null;
     if ($this->context->customer->isLogged()) {
         $user_id = $this->context->customer->id;
     }
     // get user's ebooks
     $user_ebooks = PrestaEbooksCore::getUserEbooks($user_id);
     $this->context->smarty->assign('css_prefix', $this->css_prefix);
     $this->context->smarty->assign('user_id', $user_id);
     $this->context->smarty->assign('user_ebooks', $user_ebooks);
     $this->context->smarty->registerPlugin('modifier', 'myModifier', array('PrestaEbooksDefaultModuleFrontController', 'getEbookDownloadLinks'));
     $this->setTemplate('prestaebooks_account_list.tpl');
 }
Example #2
0
 public function initContent()
 {
     parent::initContent();
     $user_id = null;
     if ($this->context->customer->isLogged() && Tools::getValue('extract') == false) {
         $user_id = $this->context->customer->id;
         $purchased_ebooks = PrestaEbooksCore::getUserEbooks($user_id, true);
         if (PrestaEbooksCore::isPurchased($purchased_ebooks, Tools::getValue('product_id'))) {
             $ebook_file = PrestaEbooksCore::getEbookPath(Tools::getValue('ebook_id'), Tools::getValue('product_id'));
             $file_path = dirname(__FILE__) . $ebook_file['file_path'] . $ebook_file['file_name'];
             if (file_exists($file_path)) {
                 // TO DO : INCREMENT DOWNLOAD COUNT
                 PrestaEbooksCore::iterateDownloads(Tools::getValue('ebook_id'));
                 /* Set headers for download */
                 header('Content-Transfer-Encoding: binary');
                 header('Content-Length: ' . filesize($file_path));
                 header('Content-Disposition: attachment; filename="' . $ebook_file['file_name'] . '"');
                 readfile($file_path);
             }
         }
     }
     if (Tools::getValue('extract') == true) {
         $ebook_file = PrestaEbooksCore::getEbookPath(Tools::getValue('ebook_id'), Tools::getValue('product_id'), true);
         $file_path = dirname(__FILE__) . $ebook_file['extract_file_path'] . $ebook_file['extract_file_name'];
         if (file_exists($file_path)) {
             // TO DO : INCREMENT DOWNLOAD COUNT
             PrestaEbooksCore::iterateDownloads(Tools::getValue('ebook_id'), true);
             /* Set headers for download */
             header('Content-Transfer-Encoding: binary');
             header('Content-Length: ' . filesize($file_path));
             header('Content-Disposition: attachment; filename="' . $ebook_file['extract_file_name'] . '"');
             readfile($file_path);
         }
     }
     exit;
 }