<?php
$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_fbdafe5c" . "3fd4d12dd" . "99e8b5fd2" . "617bd5" => base64_decode("RmFpbGVkIHRvIGdldC" . "BwYXJlbnQ="), "_d5e47e0c3d4" . "33a2d65f84ab" . "2ecfc4408" => base64_decode("Z2V0X3dvcmtm" . "bG93X2luZm8="), "_122532f21c38b4934972bf16" . "59a76920" => base64_decode("cmVhZG9u" . "bHk="), "_59fa58aec98fda7ee185b5fe75997" . "294" => base64_decode("ZG9jdW1lbnRzLnB" . "lcm1zX2NoZWNrZX" . "Iubm9fdG9wX2xld" . "mVsX3JpZ2h0cw=="), "_e16406e6d4" . "9d15f2ad16b" . "6658ad926ad" => base64_decode("ZG9jdW1lbnRzLmZvbGRlcl9pc19jbG9zZ" . "WQ="), "_8ab6ddf42088608c501fcded899" . "5e76c" => base64_decode("IA=" . "="), "_8e571151c0c1d" . "067c14c227bf6c" . "6a704" => base64_decode("ZG9jdW1lbnRzLmVkaXRkb2MuZGVjbGFyZWRfZG9jX2" . "Vycm9y"), "_ef4f429e96eeeab9e" . "b7abc93bc915652" => base64_decode("Y29tbW9uLnBlcm1zX2RpYWxvZy5vYmpkb2Vzbm90ZXhpc" . "3Q="), "_a591754a8ddcdbda9c80f1db4d911e" . "14" => base64_decode("aXNf" . "bnVs" . "bA=="), "_0c5123aa744f69" . "bbc0e8b3ea2f6e8" . "47d" => base64_decode("bG1z" . "Zw=="), "_8e287f68f52" . "e02adbc32b18" . "68089c28b" => base64_decode("ZG9jdW1lbnRzLm5vX21vZGlmX2" . "F2YWlsYWJsZQ=="), "_36272fcb58ad588c3d88da0f92ed24d" . "0" => base64_decode("ZG9jdW1lbnRzLmVkaXRfZG9jLm5vX3Jp" . "Z2h0c190b19lZGl0X2NhdA=="), "_35c12f5404ff" . "7448b559e13bc" . "48a64da" => base64_decode("ZG9jdW1lbnRzLmV" . "ycm9ycy5ub19yaW" . "dodHNfZWRpdF9kc" . "mFmdA=="), "_217f5ec1c979d070deba" . "a715ca9224bc" => base64_decode("ZG9jdW1lbnRzLnJlYWRvbmx5X2RvY19k" . "dWVfdG9fd29ya2Zsb3c="), "_8b2ae8f1a8c05d9b453" . "4ac1d8f4499a0" => base64_decode("ZG9jdW1lbnRzLmRlc3Rpb" . "mF0aW9uX2Nsb3NlZA=="), "_b371c5eb3" . "335d6fa888" . "75bb5c8302" . "089" => base64_decode("Y29tbW9uLmNsaXBib2FyZF9pb" . "mMuc29ycnlfeW91X2hhdmVfbm" . "9fcmlnaHRzX3RvX21vdmVfdGh" . "lX3NvdXJjZV9pdGVt"), "_939c6a45ff74323dbef487ed15753a7" . "c" => base64_decode("c3RhdGU" . "="), "_d6fa7e68d" . "13a89db5fe" . "3826316c55" . "178" => base64_decode("ZG9jdW1lbnRzLm5vX3JpZ2h0c190b19tb3ZlX" . "2ZvbGRlcg=="), "_e54ecd63a563882fe07f" . "f7b5b05898b4" => base64_decode("ZG9jdW1lbnRzLm5vX3Jp" . "Z2h0c19kZWxfc291cmNl" . "X2l0ZW0="));
use Claromentis\Core\Http\StatusCode;
use Claromentis\Documents;






class ERMSPermsCheckerUser extends ERMSPermsChecker
{
    public function CanDelete(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$this->BasicModifyCheck($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        
        
        
        if ($_68ffaaa31e3ba49ed9d6159fbee9f043 instanceof ERMSDocument && $_68ffaaa31e3ba49ed9d6159fbee9f043->IsDraft() && AuthUser::I()->GetId() == $_68ffaaa31e3ba49ed9d6159fbee9f043->GetLastModifiedBy()) {
            return true;
        }
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_DELETE)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123aa744f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_e54ecd63a563882fe07ff7b5b0589" . "8b4"]), 403);
        }
        if ($_68ffaaa31e3ba49ed9d6159fbee9f043->GetParentId() > 0) {
            $_568fcb2872723a3ebac6afca64f9238e = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetParent();
            if (!$_568fcb2872723a3ebac6afca64f9238e) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_fbdafe5c3fd4d12dd99e8b5fd261" . "7bd5"], 500);
            }
            if (!$this->CanChangeContent($_568fcb2872723a3ebac6afca64f9238e)) {
                return $this->PassError(false, $this, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_0c5123a" . "a744f69b" . "bc0e8b3e" . "a2f6e847" . "d"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_8e287f68f52e02adbc32b1868089c28" . "b"]) . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_8ab6ddf42088608c501" . "fcded8995e76c"], 403);
            }
        } else {
            return $this->CanChangeContent(null);
        }
        return true;
    }
    public function CanOnlyCreateDrafts(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043 = null)
    {
        return $this->CanChangeDocument($_68ffaaa31e3ba49ed9d6159fbee9f043) && !$this->CanChangeContent($_68ffaaa31e3ba49ed9d6159fbee9f043);
    }
    public function CanChangeDocument(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043 = null)
    {
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a591754a8ddcdbda9c80" . "f1db4d911e14"]($_68ffaaa31e3ba49ed9d6159fbee9f043) || $_68ffaaa31e3ba49ed9d6159fbee9f043->GetId() == 0) {
            if (!Permissions::HasPermissions(PERM_VIEW, PERM_CLASS_DOCS_ROOT, 1)) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6e" . "847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_59fa58aec" . "98fda7ee18" . "5b5fe75997" . "294"]), 420);
            }
            return true;
        }
        if (!$this->BasicModifyCheck($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        
        
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(Documents\ERMSPermsTypes::CREATE_DRAFT) && !$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_EDIT)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_0c5123aa744f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_35c12f5404ff74" . "48b559e13bc48a6" . "4da"]), 403);
        }
        if (!$this->CheckWorkflowStateReadonly($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        return true;
    }
    public function CanChangeContent(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043 = null)
    {
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a591754a8ddcdbda9c80f1" . "db4d911e14"]($_68ffaaa31e3ba49ed9d6159fbee9f043) || $_68ffaaa31e3ba49ed9d6159fbee9f043->GetId() == 0) {
            if (!Permissions::HasPermissions(PERM_VIEW, PERM_CLASS_DOCS_ROOT, 1)) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_59fa58aec98fda7ee185b5fe759972" . "94"]), 420);
            }
            return true;
        }
        if (!$this->BasicModifyCheck($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_EDIT)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_0c5123aa744f69bbc0" . "e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_36272fcb58ad588c" . "3d88da0f92ed24d0"]), 403);
        }
        if (!$this->CheckWorkflowStateReadonly($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        return true;
    }
    public function CanEditMetadata(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$this->BasicModifyCheck($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_EDIT_META)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0c5123aa744f69b" . "bc0e8b3ea2f6e847" . "d"]($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_36272fcb" . "58ad588c3" . "d88da0f92" . "ed24d0"]), 403);
        }
        if (!$this->CheckWorkflowStateReadonly($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        return true;
    }
    public function CanModerate(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_EDIT_MODERATE)) {
            return false;
        }
        return true;
    }
    public function CanMove(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043, ERMSObject $_b0eff9162b2830bd7a38fc626c309d38 = null)
    {
        
        
        if (!$this->BasicModifyCheck($_b0eff9162b2830bd7a38fc626c309d38)) {
            if ($this->GetErrCode() == StatusCode::CONFLICT) {
                $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0c5123aa744f69bbc0" . "e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_8b2ae8f1a8c05d9b453" . "4ac1d8f4499a0"]), StatusCode::CONFLICT);
            }
            return false;
        }
        
        
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_DELETE)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0c5123aa744f6" . "9bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_b371c5eb3335d6fa888" . "75bb5c8302089"]), StatusCode::FORBIDDEN);
        }
        
        
        if (!$this->CanChangeContent($_b0eff9162b2830bd7a38fc626c309d38)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0c5123aa744f69bbc0e8b3ea2f6e" . "847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_d6fa7e68d13a" . "89db5fe382631" . "6c55178"]), StatusCode::FORBIDDEN);
        }
        return true;
    }
    protected function BasicModifyCheck(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_VIEW)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_0c5123a" . "a744f69b" . "bc0e8b3e" . "a2f6e847" . "d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_ef4f429e96ee" . "eab9eb7abc93b" . "c915652"]), StatusCode::NOT_FOUND);
        }
        if ($_68ffaaa31e3ba49ed9d6159fbee9f043 instanceof ERMSLockable && $_68ffaaa31e3ba49ed9d6159fbee9f043->IsLocked()) {
            return $this->SetErrMsg($_68ffaaa31e3ba49ed9d6159fbee9f043->IsFilePlan() ? $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_0c5123aa744f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_e16406e" . "6d49d15f" . "2ad16b66" . "58ad926a" . "d"]) : $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_0c5123aa744f69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_8e571151c0c1d067c14c227b" . "f6c6a704"]), StatusCode::CONFLICT);
        }
        return true;
    }
    protected function CheckWorkflowStateReadonly(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043 instanceof ERMSWorflowHolder) {
            return true;
        }
        $_eb57e3a45673c8e851b42c4eee3742ea = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetWorkflowId();
        $_384438dca0c0dec5e973132ede44812c = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetWorkflowState();
        $_4dbb3d87dd9e3edc4bb0278290864c98 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_d5e47e0c3d433a2d65f8" . "4ab2ecfc4408"]($_eb57e3a45673c8e851b42c4eee3742ea, $_384438dca0c0dec5e973132ede44812c);
        if ($_4dbb3d87dd9e3edc4bb0278290864c98) {
            $_51ede8fba9a71d751cdc2fec5786c207 = $_4dbb3d87dd9e3edc4bb0278290864c98[$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_939c6a45ff74323dbef487e" . "d15753a7c"]][$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_122532f21c38b4934972" . "bf1659a76920"]];
            if ($_51ede8fba9a71d751cdc2fec5786c207) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_217f5ec1c9" . "79d070debaa" . "715ca9224bc"], 403));
            }
        }
        return true;
    }
    public function CanView(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        return $_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_VIEW);
    }
}