<?php
namespace Claromentis\Orgchart\UseCase;

$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_0c5123aa744f69b" . "bc0e8b3ea2f6e847" . "d" => base64_decode("bG1zZw" . "=="), "_a591754a" . "8ddcdbda9" . "c80f1db4d" . "911e14" => base64_decode("aXNf" . "bnVs" . "bA=="), "_3b8514d" . "999b7620" . "5b06729f" . "a5ea2cde" . "6" => base64_decode("U0VMRUNUIERJU1RJTkNUIG9yZ19jaGFydF9kZXBhcnRtZW50LiogRlJPTSBvcmdf" . "Y2hhcnRfZGVwYXJ0bWVudCBPUkRFUiBCWSBvcmdfY2hhcnRfZGVwYXJ0bWVudC50" . "aXRsZSBBU0M="), "_5f9ae35e13f8d2a2ed571fa92068b7" . "20" => base64_decode("b3JnY2hhcnQuZXJyb3Iubm9fY3JlY" . "XRlX2VkaXRfcmlnaHRz"));
use Claromentis\Core\DAL;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Orgchart\Exception\AccessDeniedException;
use Claromentis\Orgchart\OrgchartAcl;
use Claromentis\Orgchart\OrgchartRepository;
use Claromentis\Orgchart\Perm;




class GetOrgchart
{
    protected $orgchart_repo;
    protected $acl;
    public function __construct(OrgchartRepository $_0bb8bac53757cffec6387614650ed2d8, OrgchartAcl $acl)
    {
        $this->orgchart_repo = $_0bb8bac53757cffec6387614650ed2d8;
        $this->acl = $acl;
    }
    
    
    
    
    
    
    
    
    
    
    public function GetForEdit(SecurityContext $security, $id, $_8059e2bace3311190b0a85f8709f7a6a = false)
    {
        if (!$this->acl->CanCreateEditOrgchart($security) && !$_8059e2bace3311190b0a85f8709f7a6a) {
            throw new AccessDeniedException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_0c5123aa744f69" . "bbc0e8b3ea2f6e8" . "47d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_5f9ae35e13f" . "8d2a2ed571fa" . "92068b720"]));
        }
        if (!$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_a591754a8ddcd" . "bda9c80f1db4d9" . "11e14"]($id)) {
            $_08328d03bde61c25f3f3ac2f0b278b96 = $this->orgchart_repo->LoadById($id);
        } else {
            $_08328d03bde61c25f3f3ac2f0b278b96 = $this->orgchart_repo->GetNewOrgchart();
            $_08328d03bde61c25f3f3ac2f0b278b96->id = 0;
        }
        return $_08328d03bde61c25f3f3ac2f0b278b96;
    }
    public function GetOrgchartsWithPermission(SecurityContext $context)
    {
        $_4c8189237e0d0b5cd82c06d69613c88e = new DAL\QueryBuilder($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_3b8514d999b76205b06729fa5ea2" . "cde6"]);
        $this->acl->ApplySitesPermissions($context, $_4c8189237e0d0b5cd82c06d69613c88e, Perm::PERM_VIEW);
        return $this->orgchart_repo->GetOrgchartsFilter($_4c8189237e0d0b5cd82c06d69613c88e);
    }
}