<?php
$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_a389b62c7877ab37d041f77b69a7" . "4561" => base64_decode("QWN0aW9uIG9iamVjdCBpcyBub3Qgc2F" . "2ZWQgeWV0"), "i" . "d" => base64_decode("aWQ" . "="), "_707babebf195e6b331b" . "04212a1c17391" => base64_decode("YWN0aW9uX29ia" . "mVjdF9kYXRh"), "_c244a470df52d1d5a70" . "85138ec94e393" => base64_decode("dW5zZXJpYWxp" . "emU="), "_d4683aa" . "ab5aae7f" . "c03f50a7" . "8f8bc5fe" . "9" => base64_decode("L153X2Z" . "fLw=="), "_d447517cc97224c76" . "5e9183163fe5040" => base64_decode("LQ" . "=="), "_963704c97829cbb6c0d42" . "6cbb6651452" => base64_decode("cHJvY2Vzc19jbGFfdGV" . "tcGxhdGU="), "p" . "e" . "r" . "m" . "s" => base64_decode("cGVybX" . "M="), "_b96dd7974a94d4d1" . "6722f81b4658a0d6" => base64_decode("ZG9jdW1lbnRzLndvcmtmbG93cy5ub3RpZn" . "lfYWN0aW9uX2V4ZWN1dGVk"), "_5e433b1c8d5bde08b255" . "f7e27c183b04" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24gV0hFUkUgdHlwZT" . "1pbnQ6dHlwZSBBTkQgc3RhdGVfaWQ9aW50OnN0YXRlX2lk"), "_531602f7210ea5e2d4014444ce4a" . "0dde" => base64_decode("d2ZfYWN0aW" . "9ucw=="), "_dcd48c94b8c6e6387e" . "4d3a774bd0ce44" => base64_decode("Li4vY29tbW9uL3RlbXBsYXRl" . "ci5waHA="), "_c5ead5401bce0c" . "8360cb329b48e16" . "48a" => base64_decode("YWN0aW9uX2Rhd" . "GE="), "_96be32a6f44bf5" . "4e635e1736acf7a" . "96c" => base64_decode("c2VyaWFsaX" . "pl"), "typ" . "e" => base64_decode("dHlw" . "ZQ=="), "_4d707fab93bebb00bbe69e" . "8159697c90" => base64_decode(""), "_e3033efc13162755da5114" . "2f9e6eb022" => base64_decode("cHJlZ19yZXBsYWN" . "l"), "_10fe3af8a3115caf3" . "53c825b9408bfea" => base64_decode("YWN0aW9" . "uX3R5cG" . "U="), "_fc4ffcaec4d" . "ff19ed04cc1c" . "9229222d1" => base64_decode("ZG9j" . "dW1l" . "bnQ="), "_f8c5ae64cf005e1048f67b7be3a519" . "51" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaW" . "QgRlJPTSB3Zl9hY3Rpb24gV0hFUkUgaWQ9aW50Omlk"));
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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_531602f7210ea5e2d4014" . "444ce4a0dde"];
        $this->id = -1;
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $this->state_id = $_226b051490848e9e1835697931696225;
        $this->action_type = 0;
        $this->action_object_data = null;
        $this->action_data = $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4d707fab93bebb00bbe69e8159697" . "c90"];
        $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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_c244a470df52d1d5a7085138ec94" . "e393"]($this->action_data);
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_96be32a6f44bf54e635e1736acf" . "7a96c"]($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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["p" . "e" . "r" . "m" . "s"] || $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_707babebf195e6b331b" . "04212a1c17391"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    
    public function SaveTargetUsers($_5f53bb9a0317b2cff1248a5d6f951ce0 = false)
    {
        if ($_5f53bb9a0317b2cff1248a5d6f951ce0) {
            if ($this->id <= 0) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_a389b62c7877ab37d041" . "f77b69a74561"]);
            }
            $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["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e815969" . "7c90"];
    }
    
    
    
    
    
    
    
    public function ProcessUserInput(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return true;
    }
    
    
    
    
    
    
    public function ShowAdminFormFields()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_4d707fab93be" . "bb00bbe69e815" . "9697c90"];
    }
    
    
    
    
    
    
    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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_f8c5ae64cf005e1048" . "f67b7be3a51951"], $id);
            $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
            if (!$_a606a2dcd236a549db0574a9c1675927->hasData()) {
                return false;
            }
            $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
            if ($type && $type != $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["t" . "y" . "p" . "e"]]) {
                $_7f5aa4e96d4b415a86ed72ebff677cbe = new Query($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_5e433b1c8d5bde08b255f7e" . "27c183b04"], $type, $_226b051490848e9e1835697931696225);
                $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
                if ($_a606a2dcd236a549db0574a9c1675927->hasData()) {
                    $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
                    $id = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_c5ead540" . "1bce0c836" . "0cb329b48" . "e1648a"]])) {
            $action->RestoreActionData($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_c5ead5401bce0c8360cb329b48e" . "1648a"]]);
        }
        $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["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_e3033efc13162755da51142f" . "9e6eb022"]($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d4683aaab" . "5aae7fc03f" . "50a78f8bc5" . "fe9"], $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_4d707fab93bebb" . "00bbe69e8159697" . "c90"], $_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["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_d447517cc97224c" . "765e9183163fe504" . "0"]);
        $_e3be37b466da96cb55bbca1e9a810ff0->Save();
    }
    public abstract function Execute(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_c5ead5401bce0c8360cb329b48e1648a, $comment);
    protected function CallTemplater($template)
    {
        global $args, $datasources;
        require_once $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_dcd48c94b8c6e63" . "87e4d3a774bd0ce4" . "4"];
        $_f274035cf280fb57c0c9ef54d849a83d = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_963704c97829cb" . "b6c0d426cbb6651" . "452"]($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"]["_fc4ffcaec4dff19ed04cc1" . "c9229222d1"] => $_fc4ffcaec4dff19ed04cc1c9229222d1->GetTitle(), $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_10fe3af8a" . "3115caf353" . "c825b9408b" . "fea"] => $_e6256553b6994263cbac2f560d68f04a[$this->GetType()]);
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_b96dd7974a94d4" . "d16722f81b4658a" . "0d6"], $_c29af76a164c7b22864dd0a9282e8234, $_e4bf1e70e6d9b11e2cf0fe9ce843e56b);
    }
}