<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] ?: array()) + array("_ffc655ae461b838d" . "ffa4551784bacfca" => base64_decode("U0VMRUNUICogRlJPTSBwdWJsaXNoX25vdGlmaWNhdGlvbnMgV0h" . "FUkUgdXNlcl9pZD1pbnQ6dV9pZCBBTkQgcGFnZV9pZD1pbnQ6cF" . "9pZA=="), "_4ae48f0b4a" . "26d39f5b586" . "b01beb33fec" => base64_decode("SU5TRVJUIElOVE8gcHVibGlzaF9ub3RpZmljYXRpb25zICh1c2VyX2l" . "kLCBwYWdlX2lkLCBvbmNlKSBWQUxVRVMgKGludDp1X2lkLCBpbnQ6cF" . "9pZCwgaW50Om9uY2Up"), "_c06c961f393742ecfd" . "52b72263ac9470" => base64_decode("aW50dmF" . "s"), "_20a787300c04" . "55250233fd06f" . "a0384f4" => base64_decode("REVMRVRFIEZST00gcHVibGlzaF9ub3RpZmljYXRpb25zIFdIRVJFIHVzZXJfaWQgSU4gaW46aW50O" . "nVzZXJzIEFORCBwYWdlX2lkPWludDpwX2lkIEFORCBvbmNlID0gMQ=="), "_b1dd56266fec" . "1e595c364d7bf" . "c1254cb" => base64_decode("VVBEQVRFIHB1Ymxpc2hfbm90aWZpY2F0aW9ucyBTRVQgdXNlcl9pZD1pbnQ6bmV3X2lkIFdIRVJFIHVzZXJfa" . "WQ9aW50OnVfaWQ="), "_b707d4367dd" . "de579d81c047" . "d544710e3" => base64_decode("REVMRVRFIEZST00gcHVibGlzaF9ub3RpZmljYXRpb25zIFd" . "IRVJFIHVzZXJfaWQ9aW50OnVfaWQgQU5EIHBhZ2VfaWQ9aW" . "50OnBfaWQ="), "_48467b7a05f92d5ee95d490c49011" . "8d1" => base64_decode("REVMRVRFIEZST00gcHVibGlzaF9ub3RpZmljYXRpb25zIFdIRVJFIHBh" . "Z2VfaWQ9aW50OnBfaWQ="), "_2563c0d294fc620" . "89228d12c57f6da7" . "7" => base64_decode("U0VMRUNUIG9uY2UgRlJPTSBwdWJsaXNoX" . "25vdGlmaWNhdGlvbnMgV0hFUkUgdXNlcl" . "9pZCA9IGludDp1X2lkIEFORCBwYWdlX2l" . "kID0gaW50OnBfaWQ="), "_e656e7cb7f4bfc035dd97e8" . "a7055b847" => base64_decode("REVMRVRFIEZST00gcHVib" . "GlzaF9ub3RpZmljYXRpb2" . "5zIFdIRVJFIHVzZXJfaWQ" . "9aW50OnVfaWQ="), "_11bb4e3dc1e3624a" . "6ecb56860f9dead0" => base64_decode("U0VMRUNUIHVzZXJfaWQgRlJPTSBwdWJsaXNoX25vdGlmaWNhdGlvbnMg" . "V0hFUkUgcGFnZV9pZD1pbnQ6cF9pZA=="), "_53bfc51e054c55b09ff" . "aa67e35743c96" => base64_decode("VVBEQVRFIHB1Ymxpc2hfbm90aWZpY2F0aW9ucyB" . "TRVQgb25jZT1pbnQ6b25jZSBXSEVSRSB1c2VyX2" . "lkPWludDp1X2lkIEFORCBwYWdlX2lkPWludDp1X" . "2lk"));
use Claromentis\Core\Services;
use Claromentis\Core\DAL;





class PublishNotification extends ErrorHandler
{
    
    
    
    
    public $user_id;
    
    
    
    
    public $page_id;
    
    
    
    
    public $once;
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function __construct($page_id, $_9e63546aa974e7187280d9182de56699 = false)
    {
        $this->page_id = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c06c961f393742ecfd52b72" . "263ac9470"]($page_id);
        $this->user_id = AuthUser::I()->GetId();
        $this->once = $_9e63546aa974e7187280d9182de56699;
    }
    
    
    
    
    
    
    
    public function Save()
    {
        $db = Services::I()->GetDb();
        $_1f24efd4735b7a11b391147435e7d35d = $db->query($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_2563c0d294" . "fc62089228d" . "12c57f6da77"], $this->user_id, $this->page_id);
        if ($_1f24efd4735b7a11b391147435e7d35d->hasData()) {
            list($_9e63546aa974e7187280d9182de56699) = $_1f24efd4735b7a11b391147435e7d35d->fetchRow();
            if ($_9e63546aa974e7187280d9182de56699 != $this->once) {
                $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_53bfc51" . "e054c55b" . "09ffaa67" . "e35743c9" . "6"], $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_c06c961f393742ecfd52b72263a" . "c9470"]($this->once), $this->user_id, $this->page_id);
            }
        } else {
            $query = new DAL\Query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4ae48f0b4" . "a26d39f5b5" . "86b01beb33" . "fec"], $this->user_id, $this->page_id, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_c06c961f393742ecfd52b722" . "63ac9470"]($this->once));
            $db->query($query);
        }
    }
    
    
    
    
    public function Delete()
    {
        $db = Services::I()->GetDb();
        $db->query($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_b707d4367ddde579d81c04" . "7d544710e3"], $this->user_id, $this->page_id);
    }
    
    
    
    
    
    
    public function DeleteSentNotifications($_e4543e131c67c631b14751cc849d1310)
    {
        $db = Services::I()->GetDb();
        if (!empty($_e4543e131c67c631b14751cc849d1310)) {
            $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_20a787300c04552" . "50233fd06fa0384f" . "4"], $_e4543e131c67c631b14751cc849d1310, $this->page_id);
        }
    }
    
    
    
    
    
    
    static function DeleteNotificationsForPage($page_id)
    {
        $db = Services::I()->GetDb();
        $db->query($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_48467b7a05f92d5ee" . "95d490c490118d1"], $page_id);
    }
    
    
    
    
    
    
    static function DeleteNotificationsForUser($user_id)
    {
        $db = Services::I()->GetDb();
        $db->query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_e656e7cb7f" . "4bfc035dd97" . "e8a7055b847"], $user_id);
    }
    
    
    
    
    
    
    
    static function ReassignNotifications($user_id, $_4b3e34c8eac2f3dfca4b187bd615a53c)
    {
        $db = Services::I()->GetDb();
        $db->query($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_b1dd56266fec1e595c364d7" . "bfc1254cb"], $_4b3e34c8eac2f3dfca4b187bd615a53c, $user_id);
    }
    
    
    
    
    public function SetOnce($_9e63546aa974e7187280d9182de56699)
    {
        $this->once = (bool) $_9e63546aa974e7187280d9182de56699;
    }
    
    
    
    
    
    
    public function IsMonitored()
    {
        $db = Services::I()->GetDb();
        $_1f24efd4735b7a11b391147435e7d35d = $db->query($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_ffc655ae461b838dffa4" . "551784bacfca"], $this->user_id, $this->page_id);
        if ($_1f24efd4735b7a11b391147435e7d35d->hasData()) {
            return true;
        } else {
            return false;
        }
    }
    
    
    
    
    
    
    public function GetUsersMonitored()
    {
        $db = Services::I()->GetDb();
        $_1f24efd4735b7a11b391147435e7d35d = $db->query($GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_11bb4e3dc1e3624a6ecb56" . "860f9dead0"], $this->page_id);
        $_5882c836e9757b405d08e77f1fd2a18b = $_1f24efd4735b7a11b391147435e7d35d->fetchAllValues();
        return $_5882c836e9757b405d08e77f1fd2a18b;
    }
}