<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("_f1e6d6ccdd" . "8b8b79d2406" . "bc0c00e8ba8" => base64_decode("Li4vY29tbW" . "9uL21ldGFk" . "YXRhX3BrZy" . "5waHA="), "_4d707fab93b" . "ebb00bbe69e8" . "159697c90" => base64_decode(""), "_5e9a99dc0dd49b907abf1b3" . "5e96965f8" => base64_decode("dHJpbQ=" . "="), "_128dbe01" . "c1bad9f48" . "615c68bec" . "445794" => base64_decode("cHVibGlzaC5" . "lZGl0X2NhdC" . "52YWxpZF9uY" . "W1l"), "_c5100d6" . "2369ce6c" . "930c7c27" . "4c3ad1b3" . "1" => base64_decode("Li4vY29tbW9uL3B1Ymxpc2hfZnVuY3Rpb25zL" . "nBocA=="), "_a591754a8ddcdbda9c80f1db4d911e1" . "4" => base64_decode("aXNfb" . "nVsbA" . "=="), "_c118dec84d7ff3999fcc614bdda08" . "110" => base64_decode("L15bYS16QS1aMC05X" . "C1cX1wuXSskLw=="), "_f61ce5d1f564e87e3f720c" . "376acc6718" => base64_decode("cHVibGlzaC5hZGRfY2F0" . "LmVudGVyX25hbWU="), "_ef1b393a04a102d6" . "59860236a7ee04ab" => base64_decode("cHVibGlzaC51bm" . "FibGVfdG9fc2F2" . "ZV9tZXRhZGF0YQ" . "=="), "_c06c961f393742" . "ecfd52b72263ac9" . "470" => base64_decode("aW" . "50" . "dm" . "Fs"), "_d155d43a39de93f" . "858123c6b6ce31d8" . "a" => base64_decode("cHJlZ19tYXRja" . "A=="), "_0c5123aa744f69bbc0e8b3ea2f6" . "e847d" => base64_decode("bG1zZw=" . "="));
require_once $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_f1e6d6ccdd8b8b79" . "d2406bc0c00e8ba8"];
require_once $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_c5100d62369ce6c930c7c274c3ad1" . "b31"];






class PublishObject extends ErrorHandler
{
    protected $id = 0;
    protected $title = '';
    protected $creator = 0;
    protected $description = '';
    protected $perm_id;
    
    
    
    
    
    
    public $metadata;
    
    
    
    
    
    
    protected $perms;
    
    
    
    
    protected $save_perms, $perms_loaded;
    
    
    
    
    protected $pub_location = null;
    protected $acl_loaded;
    
    
    
    
    protected $acl;
    
    
    
    
    
    
    public function __construct($aggregation)
    {
        $this->metadata = new MetaDataSimple($aggregation);
        $this->perms = new UnifiedPermissions();
        $this->acl = new Claromentis\Core\Acl\Acl(PERM_CLASS_UNIFIED);
        $this->perms_loaded = false;
        $this->save_perms = false;
        $this->perm_id = 0;
        $this->pub_location = null;
    }
    
    
    
    
    
    public function __destruct()
    {
        unset($this->perms);
        unset($this->metadata);
        unset($this->pub_location);
    }
    public function __clone()
    {
        $this->metadata = clone $this->metadata;
        
        
        
    }
    
    
    
    
    
    
    
    public function LoadPerms()
    {
        if ($this->perms->Load($this->perm_id)) {
            $this->perms_loaded = true;
            return true;
        } else {
            $this->perms_loaded = false;
            return false;
        }
    }
    
    
    
    
    
    
    
    public function LoadAcl()
    {
        global $g_application;
        $_3436ad73cf80729d5a2e43d861c31e8b = $g_application->acl;
        $this->acl->SetObjectId($this->perm_id);
        try {
            $_3436ad73cf80729d5a2e43d861c31e8b->Load($this->acl);
        } catch (\Claromentis\Core\Acl\Exception\AclException $e) {
            $this->acl_loaded = false;
            return false;
        }
        $this->acl_loaded = true;
        return true;
    }
    
    
    
    
    
    
    public function SaveMetadata()
    {
        if (!$this->id) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_0c5123aa74" . "4f69bbc0e8b" . "3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_ef1b393a04a102d6598" . "60236a7ee04ab"]));
        }
        $this->metadata->Save($this->id);
        return true;
    }
    
    
    
    
    
    
    
    public function SetValue($name, $value)
    {
        $this->metadata->SetValue($name, $value);
    }
    
    
    
    
    
    
    
    
    
    public function GetValue($name)
    {
        return $this->metadata->GetValue($name);
    }
    
    
    
    
    
    
    
    public function DeleteValue($name)
    {
        $this->metadata->DeleteValue($name);
    }
    
    
    
    
    
    
    
    
    
    public function SetPerms($_5f53bb9a0317b2cff1248a5d6f951ce0, $_d518e3269f1db8e80d2ccd12b33ff3d0 = false)
    {
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a591754a8ddcdbda9c80f1db" . "4d911e14"]($_5f53bb9a0317b2cff1248a5d6f951ce0)) {
            $this->perm_id = 0;
            
            
            $this->perms->id = 0;
        } else {
            $this->perms = $_5f53bb9a0317b2cff1248a5d6f951ce0;
            $this->perm_id = $_5f53bb9a0317b2cff1248a5d6f951ce0->id;
            $this->save_perms = $_d518e3269f1db8e80d2ccd12b33ff3d0;
            $this->perms_loaded = true;
        }
        return true;
    }
    
    
    
    
    
    
    
    public function UserHasPermission($perms)
    {
        if (AuthUser::I()->IsReadonly() && $perms != PERM_VIEW) {
            return false;
        }
        
        
        
        
        
        $_1f24efd4735b7a11b391147435e7d35d = $this->GetAcl()->Permits(AuthUser::I()->GetContext(), $perms, $this->creator);
        return $_1f24efd4735b7a11b391147435e7d35d;
    }
    
    
    
    
    
    
    public function GetPerms()
    {
        if (!$this->perms_loaded) {
            $this->LoadPerms();
        }
        return $this->perms;
    }
    
    
    
    
    
    
    public function GetAcl()
    {
        if (!$this->acl_loaded) {
            $this->LoadAcl();
        }
        return $this->acl;
    }
    
    
    
    
    
    
    
    public function GetId()
    {
        return $this->id;
    }
    public function GetCreator()
    {
        return $this->creator;
    }
    public function SetCreator($_022eeb17ad2461a772886fe0f5575520)
    {
        $this->creator = $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_c06c961f393742" . "ecfd52b72263ac9" . "470"]($_022eeb17ad2461a772886fe0f5575520);
        return true;
    }
    public function GetTitle()
    {
        return $this->title;
    }
    public function SetTitle($title)
    {
        $this->title = $title;
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_5e9a99dc" . "0dd49b907" . "abf1b35e9" . "6965f8"]($title) == $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"]) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_f61ce5d1f564e87e3f720c376a" . "cc6718"]));
        }
        if (!$this->IsValidTitle($title)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_128dbe01c1bad" . "9f48615c68bec4" . "45794"]));
        }
        return true;
    }
    protected function IsValidTitle($title)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d155d43a3" . "9de93f8581" . "23c6b6ce31" . "d8a"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_c118dec8" . "4d7ff3999" . "fcc614bdd" . "a08110"], $title)) {
            return false;
        }
        return true;
    }
    public function GetDescription()
    {
        return $this->description;
    }
    public function SetDescription($_28fd57f750dbb5ffb3ffad3a888358a9)
    {
        $this->description = $_28fd57f750dbb5ffb3ffad3a888358a9;
        return true;
    }
    public function GetPermId()
    {
        return $this->perm_id;
    }
    public function _SetPermId($_bb1041b59872d5ae0f6b35aca6c14513)
    {
        $this->perm_id = $_bb1041b59872d5ae0f6b35aca6c14513;
    }
}