Browse Source

Updated download page to not download offline pages

Jeroen De Meerleer 8 months ago
parent
commit
184cdbe78c
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/JeroenED/PortfolioBundle/Controller/PortfolioController.php

+ 5 - 2
src/JeroenED/PortfolioBundle/Controller/PortfolioController.php

@@ -129,10 +129,13 @@ class PortfolioController extends Controller
      */
     public function pageDownloadAction($slug) {
         if($slug == 'none') throw new NotFoundHttpException('Page not found');
-                
+        $loggedin = null !== $user ? true : false;
+        
+        $whereclause = "p.slug LIKE :slug";
+        $whereclause .= (!$loggedin) ? " AND p.online = 1": "";
         $page = $this->getDoctrine()->getRepository('JeroenEDPortfolioBundle:Page')
             ->createQueryBuilder('p')
-            ->where("p.slug LIKE :slug")
+            ->where($whereclause)
             ->setParameter('slug', '%;'.$slug.';%')
             ->getQuery()->getResult();
         if ($page == null || $page[0]->getDownload() == null) throw new NotFoundHttpException('Page not found');