<?php
$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] ?: array()) + array("_d447517cc97224c7" . "65e9183163fe5040" => base64_decode("LQ" . "=="), "i" . "d" => base64_decode("aW" . "Q="), "_dcd48c94b8c6e6387" . "e4d3a774bd0ce44" => base64_decode("Li4vY29tbW9uL3RlbXBsYXR" . "lci5waHA="), "_d4683aaab5aae7fc03f50a78f8bc5fe" . "9" => base64_decode("L153X2Zf" . "Lw=="), "_963704c97829cbb6c0d426" . "cbb6651452" => base64_decode("cHJvY2Vzc" . "19jbGFfdG" . "VtcGxhdGU" . "="), "_f8c5ae6" . "4cf005e1" . "048f67b7" . "be3a5195" . "1" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZG" . "F0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rp" . "b24gV0hFUkUgaWQ9aW50Omlk"), "_b96dd7974a94d4d16722f81b46" . "58a0d6" => base64_decode("ZG9jdW1lbnRzLndv" . "cmtmbG93cy5ub3Rp" . "ZnlfYWN0aW9uX2V4" . "ZWN1dGVk"), "_e3033efc13162755da51" . "142f9e6eb022" => base64_decode("cHJlZ19yZXBsYWN" . "l"), "_531602f7210ea5" . "e2d4014444ce4a0" . "dde" => base64_decode("d2ZfYWN0aW9ucw" . "=="), "_4d707fab93bebb00bbe6" . "9e8159697c90" => base64_decode(""), "_707babeb" . "f195e6b33" . "1b04212a1" . "c17391" => base64_decode("YWN0aW9uX29iamVjdF9kYXR" . "h"), "_fc4ffcaec4dff" . "19ed04cc1c9229" . "222d1" => base64_decode("ZG9jdW" . "1lbnQ="), "_c244a470df52d1d5a" . "7085138ec94e393" => base64_decode("dW5zZXJpYWxpem" . "U="), "_a389b62" . "c7877ab3" . "7d041f77" . "b69a7456" . "1" => base64_decode("QWN0aW9uIG9i" . "amVjdCBpcyBu" . "b3Qgc2F2ZWQg" . "eWV0"), "typ" . "e" => base64_decode("dHl" . "wZQ" . "=="), "_5e433b1c8d5bde08b255f7e27c1" . "83b04" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24gV0hFUkUgdHlwZT1pbnQ6dHlwZSBBTkQgc3RhdGVfaWQ9aW50OnN0YXRlX2" . "lk"), "_96be32a6f44bf54e635e173" . "6acf7a96c" => base64_decode("c2Vy" . "aWFs" . "aXpl"), "per" . "ms" => base64_decode("cGVybX" . "M="), "_c5ead5401bce0" . "c8360cb329b48e" . "1648a" => base64_decode("YWN0a" . "W9uX2" . "RhdGE" . "="), "_10fe3af8a31" . "15caf353c825" . "b9408bfea" => base64_decode("YWN0aW9" . "uX3R5cG" . "U="));
abstract class WFAction extends DBObject
{
    
    
    
    
    protected $id;
    protected $wf_id;
    protected $state_id;
    protected $action_type;
    protected $action_data;
    
    
    
    
    
    
    
    protected $perms;
    protected $action_object_data;
    
    
    
    
    public function __construct($_eb57e3a45673c8e851b42c4eee3742ea = 0, $_226b051490848e9e1835697931696225 = 0)
    {
        $this->TABLE_NAME = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_531602f7210ea" . "5e2d4014444ce4" . "a0dde"];
        $this->id = -1;
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $this->state_id = $_226b051490848e9e1835697931696225;
        $this->action_type = 0;
        $this->action_object_data = null;
        $this->action_data = $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e815" . "9697c90"];
        $this->perms = null;
    }
    
    
    
    
    
    
    
    public function Load($id = -1)
    {
        if (!parent::Load($id)) {
            return false;
        }
        $this->perms = new Permissions(PERM_CLASS_WF_ACTION, $this->id);
        if ($this->id > 0) {
            $this->perms->Load();
        }
        if ($this->perms->IsError()) {
            
            
            $this->perms = false;
        }
        $this->action_object_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c244a470df" . "52d1d5a7085" . "138ec94e393"]($this->action_data);
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_96be32a6f44bf54e635e17" . "36acf7a96c"]($this->action_object_data);
        unset($this->action_object_data);
        parent::Save();
        $this->SaveTargetUsers();
        return true;
    }
    
    
    
    
    
    
    public function Delete()
    {
        $this->DeleteTargetUsers();
        $_a78352abcf4b66b494494393046a07e7 = new WFActionRecord(0, $this->id);
        $_c456c6b3886ed2803349248752fedd14 = $_a78352abcf4b66b494494393046a07e7->GetSameBySender();
        foreach ($_c456c6b3886ed2803349248752fedd14 as $_a8ad7274b4f01a10bf5b3782145f9691) {
            
            
            $_a8ad7274b4f01a10bf5b3782145f9691->Delete();
        }
        parent::Delete();
        return true;
    }
    
    
    
    
    
    
    
    public function DeleteActionRecords($_fc4ffcaec4dff19ed04cc1c9229222d1, $_c122cf02b563ba442340c5715f54e1c6)
    {
        $_34992e657f81fd07e3eabd87c8701d75 = $this->GetActionRecords($_fc4ffcaec4dff19ed04cc1c9229222d1, $_c122cf02b563ba442340c5715f54e1c6);
        foreach ($_34992e657f81fd07e3eabd87c8701d75 as $_a8ad7274b4f01a10bf5b3782145f9691) {
            
            
            $_a8ad7274b4f01a10bf5b3782145f9691->Delete();
        }
        return true;
    }
    
    
    
    
    
    
    
    public function Cancel($_fc4ffcaec4dff19ed04cc1c9229222d1, $_c122cf02b563ba442340c5715f54e1c6)
    {
        return $this->DeleteActionRecords($_fc4ffcaec4dff19ed04cc1c9229222d1, $_c122cf02b563ba442340c5715f54e1c6);
    }
    
    
    
    
    
    
    
    public function IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425)
    {
        return $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["pe" . "rm" . "s"] || $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_707babebf195" . "e6b331b04212a" . "1c17391"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    
    public function SaveTargetUsers($_5f53bb9a0317b2cff1248a5d6f951ce0 = false)
    {
        if ($_5f53bb9a0317b2cff1248a5d6f951ce0) {
            if ($this->id <= 0) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_a389b62c7877ab37d0" . "41f77b69a74561"]);
            }
            $this->perms = $_5f53bb9a0317b2cff1248a5d6f951ce0;
            $this->perms->id = $this->id;
            $this->perms->class_id = PERM_CLASS_WF_ACTION;
            return $this->PassError($this->perms->Save(), $this->perms);
        }
        return true;
    }
    
    
    
    
    
    
    public function DeleteTargetUsers()
    {
        return $this->PassError($this->perms ? $this->perms->DeleteAll() : true, $this->perms);
    }
    
    
    
    
    
    
    public function GetId()
    {
        return $this->id;
    }
    
    
    
    
    
    
    
    
    
    public function GetParentState()
    {
        $_939c6a45ff74323dbef487ed15753a7c = new WFState();
        $_939c6a45ff74323dbef487ed15753a7c->Load($this->state_id);
        return $_939c6a45ff74323dbef487ed15753a7c;
    }
    
    
    
    
    
    public function HasTargetUsers()
    {
        if ($this->perms && $this->perms instanceof Permissions) {
            return true;
        }
        return false;
    }
    
    
    
    
    
    
    public function GetTargetUsers()
    {
        return $this->perms;
    }
    
    
    
    
    
    
    
    public function GetActionRecords($_fc4ffcaec4dff19ed04cc1c9229222d1, $_c122cf02b563ba442340c5715f54e1c6)
    {
        $_e3be37b466da96cb55bbca1e9a810ff0 = new WFActionRecord($_c122cf02b563ba442340c5715f54e1c6, $this->id, $this->action_type, $_fc4ffcaec4dff19ed04cc1c9229222d1->GetDocID());
        return $_e3be37b466da96cb55bbca1e9a810ff0->GetSameByStateRecord();
    }
    
    
    
    
    
    
    
    public abstract function GetType();
    
    
    
    
    
    
    
    public abstract function InitAction(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1);
    
    
    
    
    
    
    
    public function ShowUserFormFields(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab93bebb00bbe6" . "9e8159697c90"];
    }
    
    
    
    
    
    
    
    public function ProcessUserInput(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return true;
    }
    
    
    
    
    
    
    public function ShowAdminFormFields()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_4d707fab93bebb00bbe69e815969" . "7c90"];
    }
    
    
    
    
    
    
    public function ProcessAdminInput()
    {
        return true;
    }
    public function SetActionObjectData($data)
    {
        $this->action_object_data = $data;
    }
    
    
    
    
    
    public abstract function NeedTargetUsers();
    public static function GetActionObject($id, $_226b051490848e9e1835697931696225, $_eb57e3a45673c8e851b42c4eee3742ea, $type)
    {
        global $db;
        if ($id) {
            $_7f5aa4e96d4b415a86ed72ebff677cbe = new Query($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_f8c5ae64cf005e1048f67b7be3a519" . "51"], $id);
            $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
            if (!$_a606a2dcd236a549db0574a9c1675927->hasData()) {
                return false;
            }
            $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
            if ($type && $type != $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["ty" . "pe"]]) {
                $_7f5aa4e96d4b415a86ed72ebff677cbe = new Query($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_5e433b1c8d5bde08b255f7e27c18" . "3b04"], $type, $_226b051490848e9e1835697931696225);
                $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
                if ($_a606a2dcd236a549db0574a9c1675927->hasData()) {
                    $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
                    $id = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["i" . "d"]];
                } else {
                    $id = 0;
                }
            }
            $type = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["t" . "y" . "p" . "e"]];
        }
        $action = self::GetEmptyActionObjectByType($type);
        $action->id = $id;
        if (isset($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_c5ead5401bce0c83" . "60cb329b48e1648a"]])) {
            $action->RestoreActionData($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_c5ead5401bce0c8360" . "cb329b48e1648a"]]);
        }
        $action->state_id = $_226b051490848e9e1835697931696225;
        $action->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $action->action_type = $type;
        if ($action->NeedTargetUsers()) {
            $action->LoadTargetUsers();
        }
        return $action;
    }
    public static function GetEmptyActionObjectByType($_10fe3af8a3115caf353c825b9408bfea)
    {
        switch ($_10fe3af8a3115caf353c825b9408bfea) {
            case WF_ACTION_FEEDBACK_REQUEST:
                $action = new WFActionFeedbackRequest();
                break;
            case WF_ACTION_MOVE_TO_FOLDER:
                $action = new WFActionMoveToFolder();
                break;
            case WF_ACTION_SEND_EMAIL:
                $action = new WFActionSendEmail();
                break;
            case WF_ACTION_NONE:
                $action = new WFActionNone();
                break;
            default:
                return false;
                break;
        }
        $action->action_type = $_10fe3af8a3115caf353c825b9408bfea;
        return $action;
    }
    
    
    
    
    
    
    
    public function GetActionType()
    {
        return $this->GetType();
    }
    public abstract function ShowActorsForm(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1);
    public function LoadTargetUsers()
    {
        $this->perms = new Permissions(PERM_CLASS_WF_ACTION, $this->id);
        if ($this->id > 0) {
            $this->perms->Load();
        }
    }
    protected function TryToGuessField($_13d133c615714d50832f54e91fea8fb0)
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e3033efc13162755da51142f9e6e" . "b022"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_d4683aaab5aae7fc03f50a78f8bc5fe" . "9"], $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab" . "93bebb00b" . "be69e8159" . "697c90"], $_13d133c615714d50832f54e91fea8fb0);
    }
    public function GetActionObjectData()
    {
        return $this->action_object_data;
    }
    protected function SendNotification(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_820ad9a07366edd8676179c752241db4)
    {
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $_820ad9a07366edd8676179c752241db4, $this->GetTargetUsers()->GetIndividualsList(PERM_VIEW));
    }
    protected function SaveActionRecord(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $comment, $_590accd9bf5cabf9360e50157b7f12e8 = "")
    {
        $_e3be37b466da96cb55bbca1e9a810ff0 = new WFActionRecord($_fc4ffcaec4dff19ed04cc1c9229222d1->GetWorkflowStateObj()->GetCurrentStateRecord($_fc4ffcaec4dff19ed04cc1c9229222d1)->GetId(), $this->id, $this->action_type, $_fc4ffcaec4dff19ed04cc1c9229222d1->GetDocID(), AuthUser::I()->GetId() ? AuthUser::I()->GetId() : 0);
        $_e3be37b466da96cb55bbca1e9a810ff0->SetComment($comment);
        $_e3be37b466da96cb55bbca1e9a810ff0->SetEventData($_590accd9bf5cabf9360e50157b7f12e8 ? $_590accd9bf5cabf9360e50157b7f12e8 : $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_d447517cc97224c" . "765e9183163fe504" . "0"]);
        $_e3be37b466da96cb55bbca1e9a810ff0->Save();
    }
    public abstract function Execute(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_c5ead5401bce0c8360cb329b48e1648a, $comment);
    protected function CallTemplater($template)
    {
        global $args, $datasources;
        require_once $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_dcd48c9" . "4b8c6e63" . "87e4d3a7" . "74bd0ce4" . "4"];
        $_f274035cf280fb57c0c9ef54d849a83d = $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_963704c97829cbb6c0d426cbb665145" . "2"]($template, $args, $datasources);
        
        
        return $_f274035cf280fb57c0c9ef54d849a83d;
    }
    public function SetWorkflowId($_eb57e3a45673c8e851b42c4eee3742ea)
    {
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
    }
    public function SetParentStateId($_226b051490848e9e1835697931696225)
    {
        $this->state_id = $_226b051490848e9e1835697931696225;
    }
    public function UserHasPermission($perms, $user_id = false)
    {
        return $this->HasTargetUsers() ? $this->GetTargetUsers()->UserHasPermission($perms, $user_id) : false;
    }
    public function NotifyResponsible(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $comment)
    {
        if ($_fc4ffcaec4dff19ed04cc1c9229222d1->GetWorkflowResponsibleObj()) {
            $_c29af76a164c7b22864dd0a9282e8234 = array($_fc4ffcaec4dff19ed04cc1c9229222d1->GetWorkflowResponsible());
        } else {
            $_c29af76a164c7b22864dd0a9282e8234 = $_fc4ffcaec4dff19ed04cc1c9229222d1->GetWorkflowObj()->GetPermissions()->GetIndividualsList(PERM_APPROVE);
        }
        $_e6256553b6994263cbac2f560d68f04a = WFWorkflow::GetActionList();
        $_e4bf1e70e6d9b11e2cf0fe9ce843e56b = array($GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_fc4ffcaec4dff19e" . "d04cc1c9229222d1"] => $_fc4ffcaec4dff19ed04cc1c9229222d1->GetTitle(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_10fe3af8a3" . "115caf353c8" . "25b9408bfea"] => $_e6256553b6994263cbac2f560d68f04a[$this->GetType()]);
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_b96dd7974a94d4d16722f" . "81b4658a0d6"], $_c29af76a164c7b22864dd0a9282e8234, $_e4bf1e70e6d9b11e2cf0fe9ce843e56b);
    }
}