<commit_before><?php
/**
 * @package     Mautic
 * @copyright   2014 Mautic, NP. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.com
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

namespace Mautic\PageBundle\Controller;

use Mautic\CoreBundle\Controller\FormController as CommonFormController;
use Mautic\PageBundle\Event\PageEvent;
use Mautic\PageBundle\PageEvents;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

class PublicController extends CommonFormController
{
    public function indexAction($slug1, $slug2 = '')
    {
        //find the page
        $factory    = $this->get('mautic.factory');
        $model      = $factory->getModel('page.page');
        $translator = $this->get('translator');
        $entity     = $model->getEntityBySlugs($slug1, $slug2);
        $user       = $factory->getUser();

        if (!empty($entity)) {
            $published = $entity->isPublished();
            //make sure the page is published or deny access if not
            if (!$published && ($user && !$this->get('mautic.security')->hasEntityAccess(
                'page:pages:viewown', 'page:pages:viewother', $entity->getCreatedBy()))) {
                $model->hitPage($entity, $this->request, 401);
                throw new AccessDeniedHttpException($translator->trans('mautic.core.url.error.401'));
            }

            $category = $entity->getCategory();

            $pageSlug = $entity->getId() . ':' . $entity->getAlias();
            $catSlug  = (!empty($category)) ? $category->getId() . ':' . $category->getTitle() :
                $translator->trans('mautic.core.url.uncategorized');

            //Check to make sure slugs match up and do a redirect if they don't
            $catInUrl = $this->get('mautic.factory')->getParameter('cat_in_page_url');

            if (
                //slugs don't match up<commit_msg>Fixed where published pages for unpublished categories were still visible to the public<commit_after><?php
/**
 * @package     Mautic
 * @copyright   2014 Mautic, NP. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.com
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */

namespace Mautic\PageBundle\Controller;

use Mautic\CoreBundle\Controller\FormController as CommonFormController;
use Mautic\PageBundle\Event\PageEvent;
use Mautic\PageBundle\PageEvents;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

class PublicController extends CommonFormController
{
    public function indexAction($slug1, $slug2 = '')
    {
        //find the page
        $factory    = $this->get('mautic.factory');
        $model      = $factory->getModel('page.page');
        $translator = $this->get('translator');
        $entity     = $model->getEntityBySlugs($slug1, $slug2);
        $user       = $factory->getUser();

        if (!empty($entity)) {
            $category     = $entity->getCategory();
            $catPublished = (!empty($category)) ? $category->isPublished() : true;
            $published    = $entity->isPublished();

            //make sure the page is published or deny access if not
            if ((!$catPublished || !$published) && (!$this->get('mautic.security')->hasEntityAccess(
                'page:pages:viewown', 'page:pages:viewother', $entity->getCreatedBy()))) {
                $model->hitPage($entity, $this->request, 401);
                throw new AccessDeniedHttpException($translator->trans('mautic.core.url.error.401'));
            }

            $pageSlug = $entity->getId() . ':' . $entity->getAlias();
            $catSlug  = (!empty($category)) ? $category->getId() . ':' . $category->getTitle() :
                $translator->trans('mautic.core.url.uncategorized');

            //Check to make sure slugs match up and do a redirect if they don't
            $catInUrl = $this->get('mautic.factory')->getParameter('cat_in_page_url');

            if (
                //slugs don't match up
{'fraction_non_alphanumeric': 0.1477964450937424, 'fraction_numerical': 0.008278548819089359, 'mean_word_length': 2.6548042704626336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5042691', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1187, 'n_words': 239}