<?php
namespace Claromentis\Quiz\Permissions;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] ?: array()) + array("_29e1a79fbc23ef" . "1ab54dba1c57bce" . "0e8" => base64_decode("L3BvbGxzLXN1" . "cnZleXM="), "su" . "rv" . "ey" . "_i" . "d" => base64_decode("c3V" . "ydm" . "V5X" . "2lk"), "_647aa6e0ba68d8b414" . "997085ce1a3082" => base64_decode("cXVpei5zdXJ2Z" . "XkucGVybWlzc2" . "lvbi5jYW50X2N" . "yZWF0ZQ=="));
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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["survey" . "_id"])) {
            $survey_id = $request->attributes->get($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["surv" . "ey_i" . "d"]);
        }
        
        
        if (!$survey_id) {
            
            
            if ($this->CanCreate($_6eb6fcb92c942851e079f8ec5fb80324->security)) {
                return null;
            } else {
                return RedirectResponse::httpRedirect($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_29e1a79fbc23ef1ab54dba1c57b" . "ce0e8"], ($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_647aa6e0" . "ba68d8b41" . "4997085ce" . "1a3082"]), true);
            }
        }
    }
    
    
    
    
    
    
    
    public function CanManageAll(SecurityContext $context)
    {
        $acl = $this->acl->Get(self::CLASS_SURVEY_ADMIN, 1);
        return $acl->Permits($context, self::PERM_MANAGE_ALL);
    }
}