<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] ?: array()) + array("_f47e852715cd4370a1238d0f512cbc7" . "6" => base64_decode("Y29tbW9uLnRhZ3MuY2FudF9sb2FkX25vX2l" . "k"), "_31767d7ad58e706dbf47" . "b7a51a0fe6c4" => base64_decode("Y29" . "1bn" . "Q="), "_0c0700a8bebefae934a0cf" . "9847852077" => base64_decode("U0VMRUNUIHRhZyBGUk9NIHRhZ3MgV0hFUkUgYWdncmVnYXRpb249aW50OmFnZ3IgQU5EIG9iamVj" . "dF9pZD1pbnQ6aWQ="), "_70e6654ead5d137ecec170e44267" . "bd6c" => base64_decode("REVMRVRFIEZST00gdGFncyBXSEVSRSBhZ2dyZWdhdGlvbj1pbnQ6YWdnciBBTkQgb2JqZWN0X2lkPWludD" . "ppZCBBTkQgdGFnIE5PVCBJTiBpbjpzdHI6dGFncw=="), "_a591754a8ddcdbda9c8" . "0f1db4d911e14" => base64_decode("aXNf" . "bnVs" . "bA=="), "_b66252d7bbf361012a65" . "31a8e3a73230" => base64_decode("YXJyYXlfZG" . "lmZg=="), "_293864c3" . "3833a46ea" . "d899b6226" . "2cd91c" => base64_decode("SU5TRVJUIElOVE8gdGFncyAob2JqZWN0X2lkLCBhZ2dyZWdhdGlvbiwgdGFnKSBWQUxVRVMgKGludDpvYmosIGludDphZ2dyLCBzdHIoMTAwKT" . "p0YWcp"), "_7f628626dd1d55c71" . "b1fc0932ffd1d2c" => base64_decode("aXNfYXJy" . "YXk="), "_f85fae321548578d2a" . "3ac0b2bf86c7a5" => base64_decode("Y29tbW9uLnRhZ3MuY2FudF9zYXZlX2" . "5vX2lk"), "_30972a27daea182778883f07743a" . "0108" => base64_decode("Y29tbW9uLnRhZ3MuY2FudF9zZXRfbm" . "90X2FycmF5"), "_cf43775e21fc8124623875731f" . "16f207" => base64_decode("REVMRVRFIEZST00gdGFncyBXSEVSRSBhZ" . "2dyZWdhdGlvbj1pbnQ6YWdnciBBTkQgb2" . "JqZWN0X2lkPWludDppZA=="), "_0c5123aa7" . "44f69bbc0e" . "8b3ea2f6e8" . "47d" => base64_decode("bG1z" . "Zw=="), "_075c6c4172eaf58cfa84828" . "a3582d19a" => base64_decode("YXJyYXl" . "fdW5pcX" . "Vl"));





class Tags extends ErrorHandler
{
    protected $aggregation;
    protected $object_id;
    protected $tags;
    
    
    
    
    
    
    
    public function __construct($aggregation, $object_id = 0)
    {
        $this->aggregation = $aggregation;
        $this->object_id = $object_id;
        $this->tags = null;
        
        
        if (!$object_id) {
            $this->tags = array();
        }
    }
    
    
    
    
    
    
    public function Load()
    {
        $db = \Claromentis\Core\Services::I()->GetDb();
        if (!$this->object_id) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea" . "2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_f47e852715cd4370a1238d0f512" . "cbc76"]));
        }
        $_189840d11056515e52402d1412a0b6e4 = $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0c0700a8bebefae934a0cf9847852" . "077"], $this->aggregation, $this->object_id);
        $this->tags = $_189840d11056515e52402d1412a0b6e4->fetchAllValues();
        $this->tags = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_075c6c4172eaf58cfa84828a358" . "2d19a"]($this->tags);
        return true;
    }
    
    
    
    
    
    
    
    public function Save()
    {
        $db = \Claromentis\Core\Services::I()->GetDb();
        if (!$this->object_id) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_0c5123aa744f69bbc0e8b3" . "ea2f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_f85fae32154" . "8578d2a3ac0b" . "2bf86c7a5"]));
        }
        if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_a591754a8ddcdbda9c80f1db4d91" . "1e14"]($this->tags)) {
            return true;
        }
        
        
        if ($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_31767d7ad58e" . "706dbf47b7a51" . "a0fe6c4"]($this->tags) == 0) {
            return $this->Delete();
        }
        $this->tags = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_075c6c4172eaf58" . "cfa84828a3582d19" . "a"]($this->tags);
        $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_70e6654ead5d137ecec170e44267bd6" . "c"], $this->aggregation, $this->object_id, $this->tags);
        $_8bb2c70b5bbd66c0507f7bb361542675 = $this->tags;
        $this->Load();
        $_750da62bcf9c85aedec630ff28bf651f = $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_b66252d7bbf361012a6531a8e3a7323" . "0"]($_8bb2c70b5bbd66c0507f7bb361542675, $this->tags);
        foreach ($_750da62bcf9c85aedec630ff28bf651f as $_402209aba575baaba313d7e099faee2a) {
            $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_293864c33833a46ead899b622" . "62cd91c"], $this->object_id, $this->aggregation, $_402209aba575baaba313d7e099faee2a);
        }
        $this->tags = $_8bb2c70b5bbd66c0507f7bb361542675;
        return true;
    }
    
    
    
    
    
    
    public function Delete()
    {
        $db = \Claromentis\Core\Services::I()->GetDb();
        if (!$this->object_id) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_0c5123aa744f69bbc0e" . "8b3ea2f6e847d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f85fae321548578d2a3ac0b2bf86" . "c7a5"]));
        }
        $db->query($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_cf43775e21fc8124623875731f" . "16f207"], $this->aggregation, $this->object_id);
        $this->tags = array();
        return true;
    }
    
    
    
    
    
    
    
    public function SetAll($_3689368f38447c0c39632dfa66ffc5ea)
    {
        if (!$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_7f628626dd1d55" . "c71b1fc0932ffd1" . "d2c"]($_3689368f38447c0c39632dfa66ffc5ea)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_30972a27daea182778883f0774" . "3a0108"]));
        }
        $this->tags = $_3689368f38447c0c39632dfa66ffc5ea;
        return true;
    }
    
    
    
    
    
    
    
    public function AddTag($_402209aba575baaba313d7e099faee2a)
    {
        if ($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_a591754a8ddcdbda9c80f1db4" . "d911e14"]($this->tags) && $this->object_id) {
            $this->Load();
        }
        if ($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a591754a8ddcdbda9c80f1db4d9" . "11e14"]($this->tags)) {
            $this->tags = array();
        }
        $this->tags[] = $_402209aba575baaba313d7e099faee2a;
        return true;
    }
    
    
    
    
    
    
    public function GetTags()
    {
        if ($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_a591754a8ddcdbda" . "9c80f1db4d911e14"]($this->tags) && $this->object_id) {
            $this->Load();
        }
        if ($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_a591754a8ddcdbda9c80f1db4d91" . "1e14"]($this->tags)) {
            $this->tags = array();
        }
        return $this->tags;
    }
    public function GetAggregation()
    {
        return $this->aggregation;
    }
    public function GetObjectId()
    {
        return $this->object_id;
    }
    public function SetObjectId($_fef39b4481c361a14ccd7333056d1c32)
    {
        return $this->object_id = $_fef39b4481c361a14ccd7333056d1c32;
    }
}