<?php
namespace Claromentis\Quiz\Permissions;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("_647aa6e0ba68d8b41499" . "7085ce1a3082" => base64_decode("cXVpei5zdXJ2ZXkucGVybWlzc2lvbi5jYW50X2NyZWF0ZQ" . "=="), "survey" . "_id" => base64_decode("c3VydmV5X" . "2lk"), "_29e1a79fbc23ef1ab54dba1c57" . "bce0e8" => base64_decode("L3BvbGxzLXN1cnZleX" . "M="));
use Claromentis\Core\Application;
use Claromentis\Core\Http\RedirectResponse;
use Claromentis\Core\Http\SymfonyRequest;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Core\Acl;
class PollAdminPermissions
{
    
    
    
    
    protected $lmsg;
    
    
    
    
    protected $acl;
    public function __construct(Lmsg $lmsg, Acl\AclRepository $acl)
    {
        $this->lmsg = $lmsg;
        $this->acl = $acl;
    }
    public function BeforeHook(SymfonyRequest $request, Application $_6eb6fcb92c942851e079f8ec5fb80324)
    {
        
        
        if ($this->CanManageAll($_6eb6fcb92c942851e079f8ec5fb80324->security)) {
            return null;
        }
        $survey_id = 0;
        
        
        if ($request->attributes->has($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["su" . "rv" . "ey" . "_i" . "d"])) {
            $survey_id = $request->attributes->get($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["sur" . "vey" . "_id"]);
        }
        
        
        if (!$survey_id) {
            
            
            if ($this->CanCreate($_6eb6fcb92c942851e079f8ec5fb80324->security)) {
                return null;
            } else {
                return RedirectResponse::httpRedirect($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_29e1a79f" . "bc23ef1ab" . "54dba1c57" . "bce0e8"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_647aa6e0ba" . "68d8b414997" . "085ce1a3082"]), true);
            }
        }
    }
    
    
    
    
    
    
    
    public function CanManageAll(SecurityContext $context)
    {
        $acl = $this->acl->Get(self::CLASS_SURVEY_ADMIN, 1);
        return $acl->Permits($context, self::PERM_MANAGE_ALL);
    }
}