<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] ?: array()) + array("_e970414571a994439cfa" . "1219524a6174" => base64_decode("ZXZlbnQgPSBpbnQ6" . "ZXZlbnQ="), "_0c5123aa744f69bbc0e8b" . "3ea2f6e847d" => base64_decode("bG1zZw" . "=="), "_560de4db" . "b7ada3343" . "3ab8eb203" . "ea7594" => base64_decode("YWdncmVnYXRpb24gPSBpbnQ6YWdncmVnYXRpb2" . "4="), "_1dacd987c8" . "4cc280826c9" . "780df66c92f" => base64_decode("aXNfYWN0aXZ" . "lX3N1YnNjcm" . "lwdGlvbg=="), "_a591754a8ddcdbda9c80f1db4d911e" . "14" => base64_decode("aXNfbnVsbA=" . "="), "_685d6aaf0e3" . "89384c72a2bd" . "5eba74865" => base64_decode("dXNlcl9pZCA9IG" . "ludDp1c2VyX2lk"), "_23c2134692e18" . "d57a51fbf51ee6" . "dd02a" => base64_decode("b2JqZWN0X2lkID0" . "gaW50Om9iamVjdF" . "9pZA=="), "_a5b8a957b6" . "bb889a65d01" . "10f7df85ff0" => base64_decode("REVTQ" . "w=="), "_aad69d2" . "8db3e41b" . "eebdea2f" . "379f70b8" . "5" => base64_decode("bm90aWZpY2F0aW9u" . "Lm5vdF9mb3VuZA=="), "_c4f7cd6333dbdf9cd2345b781a" . "02f4f9" => base64_decode("b25jZSA9IGludDpv" . "bmNl"), "_aa7e860da1acd4e767e0df9d7d40738" . "0" => base64_decode("ZGF0ZV9jcm" . "VhdGVk"), "_ba1baa4a3de03b5" . "800b6b1fe8373eff" . "8" => base64_decode("V3Jvbmcgb2JqZWN0IHR5cGUgZm9" . "yIHN1YnNjcmlwdGlvbg=="), "_565d34054550d362" . "c80f48727de09d24" => base64_decode("bm90aWZpY2F0aW9uX3N1YnNjcmlwdGlvb" . "nM="));






class NotificationSubscription extends DBObject
{
    protected $id;
    protected $user_id;
    protected $aggregation;
    protected $object_id;
    protected $event;
    protected $once;
    protected $date_created;
    protected $is_active_subscription;
    
    
    
    
    
    
    
    
    public function __construct($_b15aac3aa29c10ea6d1228f58cb9a7e8 = 0, $event = 0, $_d430feef04e2081c6a19d73f26e855dc = false, $_3877cdf57a61e49b56aeab7af930ee82 = null)
    {
        $this->TABLE_NAME = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_565d3405" . "4550d362c" . "80f48727d" . "e09d24"];
        $this->DATE_FIELDS = array($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_aa7e860da1acd" . "4e767e0df9d7d4" . "07380"]);
        $this->SetOrderFields(array($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_aa7e860d" . "a1acd4e76" . "7e0df9d7d" . "407380"] => $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_a5b8a957b6bb8" . "89a65d0110f7df" . "85ff0"]));
        $_50eb88f32296e9d31eb6e8c8f50e9ea0 = new Date();
        $this->date_created = $_50eb88f32296e9d31eb6e8c8f50e9ea0->getDate();
        $this->id = -1;
        $this->is_active_subscription = false;
        $this->event = $event;
        $this->once = $_d430feef04e2081c6a19d73f26e855dc ? 1 : 0;
        if (!$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a591754a8ddcdbda9c80f1db4d" . "911e14"]($_3877cdf57a61e49b56aeab7af930ee82)) {
            $this->user_id = $_3877cdf57a61e49b56aeab7af930ee82;
        } else {
            $this->user_id = AuthUser::I()->GetId();
        }
        if ($_b15aac3aa29c10ea6d1228f58cb9a7e8) {
            $this->SetObject($_b15aac3aa29c10ea6d1228f58cb9a7e8);
        }
        if ($this->object_id && $this->aggregation && $event) {
            $this->is_active_subscription = false;
            $_03e9164d0a343b742df4793268b80767 = $this->GenerateSelect();
            $_03e9164d0a343b742df4793268b80767->AddWhereAndClause($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_685d6aaf0e389" . "384c72a2bd5eba" . "74865"], $this->user_id);
            $_03e9164d0a343b742df4793268b80767->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_560de4dbb7ada3" . "3433ab8eb203ea7" . "594"], $this->aggregation);
            $_03e9164d0a343b742df4793268b80767->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_23c2134692e18d57a51fb" . "f51ee6dd02a"], $this->object_id);
            $_03e9164d0a343b742df4793268b80767->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_e970414571a994439cfa1219524a6" . "174"], $this->event);
            $_03e9164d0a343b742df4793268b80767->AddWhereAndClause($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c4f7cd6333dbdf9c" . "d2345b781a02f4f9"], $this->once);
            $_189840d11056515e52402d1412a0b6e4 = $this->GetAll($_03e9164d0a343b742df4793268b80767, 1);
            if (!empty($_189840d11056515e52402d1412a0b6e4)) {
                $_0caa59d0ba19dc22905e706434b2362d = $_189840d11056515e52402d1412a0b6e4[0];
                $this->id = $_0caa59d0ba19dc22905e706434b2362d->id;
                $this->date_created = $_0caa59d0ba19dc22905e706434b2362d->date_created;
                $this->is_active_subscription = true;
            }
        }
    }
    
    
    
    
    
    
    
    public function IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425)
    {
        return $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_1dacd987c84cc280826c9780df6" . "6c92f"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    public function Load($id = -1)
    {
        try {
            parent::Load($id);
        } catch (Exception $_6359ab1a9c56f5f77a02e3082a95a38c) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_0c5123aa744" . "f69bbc0e8b3e" . "a2f6e847d"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_aad69d28db3e41beebdea2f379f70b" . "85"]));
        }
        $this->is_active_subscription = true;
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        if ($this->is_active_subscription) {
            parent::Save();
        } else {
            if ($this->id > 0) {
                parent::Delete();
            }
        }
        return true;
    }
    
    
    
    
    
    
    public function GetId()
    {
        return $this->id;
    }
    
    
    
    
    
    
    public function GetSubscriberId()
    {
        return $this->user_id;
    }
    
    
    
    
    
    
    
    protected function SetSubscriberId($_3877cdf57a61e49b56aeab7af930ee82)
    {
        $this->user_id = $_3877cdf57a61e49b56aeab7af930ee82;
        return true;
    }
    
    
    
    
    
    
    public function GetAggregation()
    {
        return $this->aggregation;
    }
    
    
    
    
    
    
    public function GetObjectId()
    {
        return $this->object_id;
    }
    
    
    
    
    
    
    
    protected function SetObject($_b15aac3aa29c10ea6d1228f58cb9a7e8)
    {
        if (!$_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof ClaAggregation) {
            throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_ba1baa4a3de03b5800b6b1fe8373ef" . "f8"]);
        }
        $this->aggregation = $_b15aac3aa29c10ea6d1228f58cb9a7e8->GetAggregation();
        if ($_b15aac3aa29c10ea6d1228f58cb9a7e8 instanceof ERMSDocument) {
            
            
            $this->object_id = $_b15aac3aa29c10ea6d1228f58cb9a7e8->GetDocID();
        } else {
            $this->object_id = $_b15aac3aa29c10ea6d1228f58cb9a7e8->GetId();
        }
        return true;
    }
    
    
    
    
    
    
    public function GetEvent()
    {
        return $this->event;
    }
    
    
    
    
    
    
    
    protected function SetEvent($event)
    {
        $this->event = $event;
        return true;
    }
    
    
    
    
    
    
    public function IsOnce()
    {
        return $this->once ? true : false;
    }
    
    
    
    
    
    
    
    protected function SetOnce($_d430feef04e2081c6a19d73f26e855dc)
    {
        $this->once = $_d430feef04e2081c6a19d73f26e855dc ? 1 : 0;
        return true;
    }
    
    
    
    
    
    
    public function IsActive()
    {
        return $this->is_active_subscription;
    }
    
    
    
    
    
    
    
    public function SetActive($_1dacd987c84cc280826c9780df66c92f)
    {
        $this->is_active_subscription = $_1dacd987c84cc280826c9780df66c92f;
        return true;
    }
}