<commit_before><?php

namespace InsaLan\InformationBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use InsaLan\InsaLanBundle\Entity;
use InsaLan\TournamentBundle\Entity\Participant;

class DefaultController extends Controller
{
    const OPENING_DATE = '2014/10/03 00:00:00';

    /**
     * @Route("/faq")
     * @Template()
     */
    public function faqAction()
    {
        $em = $this->getDoctrine()->getManager();

        // Get global variables
        $globalVars = array();
        $globalKeys = ['staffNumber', 'number', 'lettersNumber',
                      'playersNumber', 'openingDate', 'openingHour', 'closingDate', 'closingHour', 'price', 'webPrice', 'campanilePrice'];
        $globalVars = $em->getRepository('InsaLanBundle:GlobalVars')->getGlobalVars($globalKeys);

        // Get staff
        $staff = $em->getRepository('InsaLanBundle:Staff')->findAll();

        return array('globalVars' => $globalVars, 'staff' => $staff);
    }

    /**
     * @Route("/cosplay")
     * @Template()
     */
    public function cosplayAction()
    {
        $em = $this->getDoctrine()->getManager();

        // Get global variables
        $globalVars = array();
        $globalKeys = ['cosplayEdition', 'cosplayName', 'cosplayDate',
                      'cosplayEndRegistration'];

        $globalVars = $em->getRepository('InsaLanBundle:GlobalVars')->getGlobalVars($globalKeys);

        return array('globalVars' => $globalVars);
    }

    /**
     * @Route("/playersinfos")
     * @Template()
     */
    public function playersInfosAction()
    {
        return array();
    }

    /**
     * @Route("/salesterms")
     * @Template()
     */
    public function salesTermsAction()
    {
        return array();
    }

    /** 
     * @Route("/hardwareRental")
     * @Template()
     */
    public function hardwareRentalAction()
    {
        $em = $this->getDoctrine()->getManager();
        $usr = $this->get('security.token_storage')->getToken()->getUser();
        $participants = $em->getRepository('InsaLanTournamentBundle:Participant')->findByUser($usr);

        $validated = False;
        foreach($participants as $p) {
            if ($p->getValidated() == Participant::STATUS_VALIDATED) {
                $validated = True;
            }
        }
        return array('validated' => $validated);
    }
}<commit_msg>Add opening date for hardware rental page and safety valve<commit_after><?php

namespace InsaLan\InformationBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use InsaLan\InsaLanBundle\Entity;
use InsaLan\TournamentBundle\Entity\Participant;

class DefaultController extends Controller
{
    const OPENING_DATE = '2018/12/24 20:00:00';

    /**
     * @Route("/faq")
     * @Template()
     */
    public function faqAction()
    {
        $em = $this->getDoctrine()->getManager();

        // Get global variables
        $globalVars = array();
        $globalKeys = ['staffNumber', 'number', 'lettersNumber',
                      'playersNumber', 'openingDate', 'openingHour', 'closingDate', 'closingHour', 'price', 'webPrice', 'campanilePrice'];
        $globalVars = $em->getRepository('InsaLanBundle:GlobalVars')->getGlobalVars($globalKeys);

        // Get staff
        $staff = $em->getRepository('InsaLanBundle:Staff')->findAll();

        return array('globalVars' => $globalVars, 'staff' => $staff);
    }

    /**
     * @Route("/cosplay")
     * @Template()
     */
    public function cosplayAction()
    {
        $em = $this->getDoctrine()->getManager();

        // Get global variables
        $globalVars = array();
        $globalKeys = ['cosplayEdition', 'cosplayName', 'cosplayDate',
                      'cosplayEndRegistration'];

        $globalVars = $em->getRepository('InsaLanBundle:GlobalVars')->getGlobalVars($globalKeys);

        return array('globalVars' => $globalVars);
    }

    /**
     * @Route("/playersinfos")
     * @Template()
     */
    public function playersInfosAction()
    {
        return array();
    }

    /**
     * @Route("/salesterms")
     * @Template()
     */
    public function salesTermsAction()
    {
        return array();
    }

    /** 
     * @Route("/hardwareRental")
     * @Template()
     */
    public function hardwareRentalAction()
    {
        $em = $this->getDoctrine()->getManager();

        // Get global variables
        $globalVars = array();
        // Safety  valve
        $globalKeys = ['rentalPageEnabled'];

        $globalVars = $em->getRepository('InsaLanBundle:GlobalVars')->getGlobalVars($globalKeys);

        // Disallow access until date reached
        if(time() < strtotime(self::OPENING_DATE) || $globalVars['rentalPageEnabled'] != "True") {
            $this->get('session')->getFlashBag()->add('error', "Page indisponible pour le moment. Revenez plus tard !");
            return $this->redirect($this->generateUrl(
                'insalan_news_default_index'));
            }

        $usr = $this->get('security.token_storage')->getToken()->getUser();
        $participants = $em->getRepository('InsaLanTournamentBundle:Participant')->findByUser($usr);

        // Check if player's team / player / manager is validated
        $validated = False;
        foreach($participants as $p) {
            if ($p->getValidated() == Participant::STATUS_VALIDATED) {
                $validated = True;
            }
        }
        return array('validated' => $validated);
    }
}
{'fraction_non_alphanumeric': 0.152276295133438, 'fraction_numerical': 0.004884004884004884, 'mean_word_length': 2.6756410256410255, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2403089', 'n_tokens_mistral': 1706, 'n_tokens_neox': 1644, 'n_words': 281}