<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] ?: array()) + array("_ef4f429e96eeeab9eb7abc93bc91565" . "2" => base64_decode("Y29tbW9uLnBlcm1zX2RpYWxvZy5vYmpkb" . "2Vzbm90ZXhpc3Q="), "_a591754a8ddcdbda9c8" . "0f1db4d911e14" => base64_decode("aXNfbn" . "VsbA=="), "_36272fcb5" . "8ad588c3d8" . "8da0f92ed2" . "4d0" => base64_decode("ZG9jdW1lbnRzLmVkaXRfZG9jLm5vX3JpZ2h0c190b19lZG" . "l0X2NhdA=="), "_d6fa7e68d13a89db5fe382" . "6316c55178" => base64_decode("ZG9jdW1lbnRzLm5vX3" . "JpZ2h0c190b19tb3Zl" . "X2ZvbGRlcg=="), "_217f5ec1c979d070debaa715ca92" . "24bc" => base64_decode("ZG9jdW1lbnRzLnJlY" . "WRvbmx5X2RvY19kdW" . "VfdG9fd29ya2Zsb3c" . "="), "_e54ecd63a563882fe07ff7b5" . "b05898b4" => base64_decode("ZG9jdW1lbnRzLm5vX3JpZ2h0c19kZWxfc291" . "cmNlX2l0ZW0="), "_0c5123aa744f69bbc0e8b3" . "ea2f6e847d" => base64_decode("bG1zZw=" . "="), "_b371c5eb3335d" . "6fa88875bb5c83" . "02089" => base64_decode("Y29tbW9uLmNsaXBib2FyZF9pbmMuc29ycnlf" . "eW91X2hhdmVfbm9fcmlnaHRzX3RvX21vdmVf" . "dGhlX3NvdXJjZV9pdGVt"), "_fbdafe5c3fd4d12dd9" . "9e8b5fd2617bd5" => base64_decode("RmFpbGVkIHRvIGd" . "ldCBwYXJlbnQ="), "_8e571151c0c1d067c14c22" . "7bf6c6a704" => base64_decode("ZG9jdW1lbnRzLmVkaXRkb2MuZGVjbGFyZWRfZG9j" . "X2Vycm9y"), "_d5e47e0c3d433a2d65f84ab2ecfc" . "4408" => base64_decode("Z2V0X3dvcmtmbG93" . "X2luZm8="), "_8b2ae8f1a8c05d9b4534ac1" . "d8f4499a0" => base64_decode("ZG9jdW1lbnRzLmRlc3RpbmF0aW9uX2Nsb3NlZA" . "=="), "_939c6a45ff74323dbef487ed157" . "53a7c" => base64_decode("c3Rh" . "dGU="), "_e16406e6d49d15f2ad16b6658ad" . "926ad" => base64_decode("ZG9jdW1lbnRzLmZvbGRlcl9pc19" . "jbG9zZWQ="), "_59fa58aec98" . "fda7ee185b5f" . "e75997294" => base64_decode("ZG9jdW1lbnRzLnBlcm1zX2NoZWNrZXIubm9fdG9wX2xldmVsX3JpZ2h0cw=" . "="), "_8e287f68f52e02a" . "dbc32b1868089c28" . "b" => base64_decode("ZG9jdW1lbnRzLm5vX21vZGlmX2F2YWl" . "sYWJsZQ=="), "_8ab6ddf42088608c501fcded8995" . "e76c" => base64_decode("I" . "A" . "=" . "="), "_122532f21c38b4" . "934972bf1659a76" . "920" => base64_decode("cmVhZG9ubHk" . "="), "_35c12f5404f" . "f7448b559e13" . "bc48a64da" => base64_decode("ZG9jdW1lbnRzLmVycm9ycy5ub19yaW" . "dodHNfZWRpdF9kcmFmdA=="));
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["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_0c5123aa74" . "4f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_e54ecd63a563882fe07ff7b5b" . "05898b4"]), 403);
        }
        if ($_68ffaaa31e3ba49ed9d6159fbee9f043->GetParentId() > 0) {
            $_568fcb2872723a3ebac6afca64f9238e = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetParent();
            if (!$_568fcb2872723a3ebac6afca64f9238e) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_fbdafe5c3fd4d12dd99e8b5fd2617bd" . "5"], 500);
            }
            if (!$this->CanChangeContent($_568fcb2872723a3ebac6afca64f9238e)) {
                return $this->PassError(false, $this, $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_0c5123aa744f69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_8e287f68f52e02adbc32b1868089c" . "28b"]) . $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_8ab6ddf4208" . "8608c501fcde" . "d8995e76c"], 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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_a591754a8ddcdbda9" . "c80f1db4d911e14"]($_68ffaaa31e3ba49ed9d6159fbee9f043) || $_68ffaaa31e3ba49ed9d6159fbee9f043->GetId() == 0) {
            if (!Permissions::HasPermissions(PERM_VIEW, PERM_CLASS_DOCS_ROOT, 1)) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0c5123aa744f" . "69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_35c12f5404ff7448b559e13bc48a64" . "da"]), 403);
        }
        if (!$this->CheckWorkflowStateReadonly($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        return true;
    }
    public function CanChangeContent(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043 = null)
    {
        if ($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_a591754a8ddcdbda9c80f1db4d9" . "11e14"]($_68ffaaa31e3ba49ed9d6159fbee9f043) || $_68ffaaa31e3ba49ed9d6159fbee9f043->GetId() == 0) {
            if (!Permissions::HasPermissions(PERM_VIEW, PERM_CLASS_DOCS_ROOT, 1)) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_0c5123aa744f69bbc0e8b3" . "ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_59fa58aec98fda7ee185b5fe7599" . "7294"]), 420);
            }
            return true;
        }
        if (!$this->BasicModifyCheck($_68ffaaa31e3ba49ed9d6159fbee9f043)) {
            return false;
        }
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_EDIT)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0c5123aa744f69bbc0" . "e8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_36272fcb58ad588c3d88da0f" . "92ed24d0"]), 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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0c5123aa744" . "f69bbc0e8b3e" . "a2f6e847d"]($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_36272fcb58ad588c3d88da0f9" . "2ed24d0"]), 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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0c5123aa744f6" . "9bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_8b2ae8f1a8c05d9b4534ac1d8f" . "4499a0"]), StatusCode::CONFLICT);
            }
            return false;
        }
        
        
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_DELETE)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0c5123aa744f69bbc0e8b3ea2f6e" . "847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_b371c5eb3335d6fa88875b" . "b5c8302089"]), StatusCode::FORBIDDEN);
        }
        
        
        if (!$this->CanChangeContent($_b0eff9162b2830bd7a38fc626c309d38)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0c5123aa744f" . "69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_d6fa7e68d13a8" . "9db5fe3826316c" . "55178"]), StatusCode::FORBIDDEN);
        }
        return true;
    }
    protected function BasicModifyCheck(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_VIEW)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123aa744f69bbc0e8b3ea2f" . "6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_ef4f429e96eeea" . "b9eb7abc93bc915" . "652"]), StatusCode::NOT_FOUND);
        }
        if ($_68ffaaa31e3ba49ed9d6159fbee9f043 instanceof ERMSLockable && $_68ffaaa31e3ba49ed9d6159fbee9f043->IsLocked()) {
            return $this->SetErrMsg($_68ffaaa31e3ba49ed9d6159fbee9f043->IsFilePlan() ? $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_0c5123aa744f69b" . "bc0e8b3ea2f6e847" . "d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_e16406e6d49d15f2ad16b66" . "58ad926ad"]) : $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_0c5123aa744f69bbc0e8b3ea" . "2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_8e57115" . "1c0c1d06" . "7c14c227" . "bf6c6a70" . "4"]), StatusCode::CONFLICT);
        }
        return true;
    }
    protected function CheckWorkflowStateReadonly(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        if (!$_68ffaaa31e3ba49ed9d6159fbee9f043 instanceof ERMSWorflowHolder) {
            return true;
        }
        $_eb57e3a45673c8e851b42c4eee3742ea = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetWorkflowId();
        $_384438dca0c0dec5e973132ede44812c = $_68ffaaa31e3ba49ed9d6159fbee9f043->GetWorkflowState();
        $_4dbb3d87dd9e3edc4bb0278290864c98 = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_d5e47e0c3d433a2d65f84ab2ecfc" . "4408"]($_eb57e3a45673c8e851b42c4eee3742ea, $_384438dca0c0dec5e973132ede44812c);
        if ($_4dbb3d87dd9e3edc4bb0278290864c98) {
            $_51ede8fba9a71d751cdc2fec5786c207 = $_4dbb3d87dd9e3edc4bb0278290864c98[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_939c6a45ff74323dbef" . "487ed15753a7c"]][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_122532f21c38" . "b4934972bf165" . "9a76920"]];
            if ($_51ede8fba9a71d751cdc2fec5786c207) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_217f5ec1" . "c979d070d" . "ebaa715ca" . "9224bc"], 403));
            }
        }
        return true;
    }
    public function CanView(ERMSObject $_68ffaaa31e3ba49ed9d6159fbee9f043)
    {
        return $_68ffaaa31e3ba49ed9d6159fbee9f043->UserHasPermission(PERM_VIEW);
    }
}