<?php
namespace Claromentis\Quiz\Permissions;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_38f12d8b8c719a8ce0fc2faefc225f3" . "5" => base64_decode("YXJyYXlfbW" . "Fw"), "_3f6d7d23d9" . "702fbd8e06b" . "755c2e7b3e0" => base64_decode("cXVpei5wZXJtaXNzaW9ucy" . "52aWV3X2FsbF9zdGF0aXN0" . "aWNz"), "_ce97e83d" . "884f0f0c4" . "3662999ff" . "ef59ed" => base64_decode("cXVpei5wZXJtaXNzaW9ucy5tYW5h" . "Z2VfYWxs"), "_aa46d3ae56040972fac37aa9bc" . "87d803" => base64_decode("L3F1a" . "Xo="), "_62df08b6ed8667f8174a96d5" . "8970883d" => base64_decode("aW50dm" . "Fs"), "_261fbffc46a1394" . "955b10c01bdd96d0" . "3" => base64_decode("cXVpei5yZXBvc2l0b3J5LnF1a" . "Xo="), "_0c5123aa744f69bbc0e8b3ea2f6e" . "847d" => base64_decode("bG1zZw" . "=="), "_30deb384d" . "bcd913f062" . "8cb00c05ed" . "68b" => base64_decode("cXVpei5hZG1pbi5ub19jcmVhdGV" . "fcGVybXM="), "_97f0dd166c" . "14320c43b6f" . "c77c283e27e" => base64_decode("cXVpei5wZXJtaXNzaW9ucy5tYW" . "5hZ2Vfb3du"), "_74c5ab0" . "7fa21483" . "70c1d2c5" . "5ebdaf3a" . "b" => base64_decode("cXVpei5hZG1pbi5ub19wZX" . "Jtcw=="), "_ada909094c3f2b48f2ba66bec3334aa" . "b" => base64_decode("cXVpei5" . "mYWNhZG" . "UucXVpe" . "g=="), "quiz" . "_id" => base64_decode("cXVp" . "el9p" . "ZA=="));
use Claromentis\Core\Application;
use Claromentis\Core\Acl;
use Claromentis\Core\Http\SymfonyRequest;
use Claromentis\Core\Http\RedirectResponse;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Quiz\Model;






class QuizAdminPermissions
{
    
    
    const CLASS_QUIZ_ADMIN = 130;
    
    
    const PERM_VIEW_ALL_STATISTICS = 0x100;
    const PERM_MANAGE_OWN = 0x10;
    const PERM_MANAGE_ALL = 0x111;
    
    
    
    
    
    
    
    public static function GetDialog(Acl\AclRepository $acl)
    {
        $acl = $acl->Get(static::CLASS_QUIZ_ADMIN, 1);
        $_199355a18b7f1825de748a3bdea73bdb = new Acl\CommonPermsDialog($acl);
        $_199355a18b7f1825de748a3bdea73bdb->SetAllPermValues(static::GetDialogValues());
        return $_199355a18b7f1825de748a3bdea73bdb;
    }
    
    
    
    
    
    
    public static function GetDialogValues()
    {
        return array(static::PERM_VIEW_ALL_STATISTICS => array($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0c5123a" . "a744f69b" . "bc0e8b3e" . "a2f6e847" . "d"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_3f6d7d23d9702fbd8e06b75" . "5c2e7b3e0"]), 1), static::PERM_MANAGE_OWN => array($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_97f0dd1" . "66c14320" . "c43b6fc7" . "7c283e27" . "e"]), 1), static::PERM_MANAGE_ALL => array($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123aa744f69bbc0e8" . "b3ea2f6e847d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_ce97e83d88" . "4f0f0c43662" . "999ffef59ed"]), 1));
    }
    
    
    
    
    
    
    
    
    public static function GetUsersWhoCan(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, $_a48eb1db4f6ab2c82fb9db687c5f4a32)
    {
        $acl = $_8652ba33e6ffeba02459fa9cbb320851->Get(static::CLASS_QUIZ_ADMIN, 1);
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_38f12d8b8c719a8ce0fc" . "2faefc225f35"]($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_62df08b6ed866" . "7f8174a96d5897" . "0883d"], $acl->GetIndividualsList($_a48eb1db4f6ab2c82fb9db687c5f4a32));
    }
    
    
    
    
    
    
    
    
    public static function CanCreate(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        $acl = $_8652ba33e6ffeba02459fa9cbb320851->Get(static::CLASS_QUIZ_ADMIN, 1);
        
        
        return $acl->Permits($context, static::PERM_MANAGE_OWN) || $acl->Permits($context, static::PERM_MANAGE_ALL);
    }
    
    
    
    
    
    
    
    
    public static function CanManageOwn(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        $acl = $_8652ba33e6ffeba02459fa9cbb320851->Get(static::CLASS_QUIZ_ADMIN, 1);
        return $acl->Permits($context, static::PERM_MANAGE_OWN);
    }
    
    
    
    
    
    
    
    
    public static function CanManageAll(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        $acl = $_8652ba33e6ffeba02459fa9cbb320851->Get(static::CLASS_QUIZ_ADMIN, 1);
        return $acl->Permits($context, static::PERM_MANAGE_ALL);
    }
    
    
    
    
    
    
    
    
    public static function CanViewAllStatistics(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        
        
        if (static::CanManageAll($_8652ba33e6ffeba02459fa9cbb320851, $context)) {
            return true;
        }
        $acl = $_8652ba33e6ffeba02459fa9cbb320851->Get(static::CLASS_QUIZ_ADMIN, 1);
        return $acl->Permits($context, static::PERM_VIEW_ALL_STATISTICS);
    }
    
    
    
    
    
    
    
    
    public static function CanViewAll(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        return static::CanManageAll($_8652ba33e6ffeba02459fa9cbb320851, $context) || static::CanViewAllStatistics($_8652ba33e6ffeba02459fa9cbb320851, $context);
    }
    
    
    
    
    
    
    
    
    public static function CanAttemptAll(Acl\AclRepository $_8652ba33e6ffeba02459fa9cbb320851, SecurityContext $context)
    {
        return static::CanManageAll($_8652ba33e6ffeba02459fa9cbb320851, $context);
    }
    
    
    
    
    
    
    
    public static function BeforeHook(SymfonyRequest $request, Application $_6eb6fcb92c942851e079f8ec5fb80324)
    {
        
        
        if (static::CanManageAll($_6eb6fcb92c942851e079f8ec5fb80324->acl, $_6eb6fcb92c942851e079f8ec5fb80324->security)) {
            return null;
        }
        $quiz_id = 0;
        
        
        if ($request->attributes->has($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["qu" . "iz" . "_i" . "d"])) {
            $quiz_id = $request->attributes->get($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["quiz_" . "id"]);
        }
        
        
        if (!$quiz_id) {
            
            
            if (static::CanCreate($_6eb6fcb92c942851e079f8ec5fb80324->acl, $_6eb6fcb92c942851e079f8ec5fb80324->security)) {
                return null;
            } else {
                return RedirectResponse::httpRedirect($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_aa46d3ae5604" . "0972fac37aa9b" . "c87d803"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123aa744f69bbc0e8b3ea2f6e" . "847d"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_30deb384dbcd913f0628cb00c05ed6" . "8b"]));
            }
        }
        
        
        
        
        
        $_864ec8f1fa467c206b6bb2b9c0f308bf = $_6eb6fcb92c942851e079f8ec5fb80324[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_261fbffc46a1394955b10c01bdd96d" . "03"]];
        $_876ca2097b275e704d71e00d36b3e7c5 = $_6eb6fcb92c942851e079f8ec5fb80324[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_ada9090" . "94c3f2b4" . "8f2ba66b" . "ec3334aa" . "b"]];
        $quiz = $_864ec8f1fa467c206b6bb2b9c0f308bf->GetOrNew($quiz_id);
        $quiz->SetQuestions($_876ca2097b275e704d71e00d36b3e7c5->GetQuestionsForQuiz($quiz));
        $_238d2e692acf9c393aea4c12eda04a3d = QuizPermissions::CanManage($_6eb6fcb92c942851e079f8ec5fb80324->acl, $_6eb6fcb92c942851e079f8ec5fb80324->security, $quiz);
        
        
        if ($_238d2e692acf9c393aea4c12eda04a3d) {
            return null;
        }
        return RedirectResponse::httpRedirect($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_aa46d3ae56040972fac37aa" . "9bc87d803"], $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0c5123aa744f69bb" . "c0e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_74c5ab07f" . "a2148370c1" . "d2c55ebdaf" . "3ab"]), true);
    }
}