<?php
$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] ?: array()) + array("_d4683aaab5aae7f" . "c03f50a78f8bc5fe" . "9" => base64_decode("L153" . "X2Zf" . "Lw=="), "_fc4ffcaec4dff1" . "9ed04cc1c922922" . "2d1" => base64_decode("ZG9jd" . "W1lbn" . "Q="), "_707babebf195e6b331b04212a1c17" . "391" => base64_decode("YWN0aW9uX29iamVjdF9kYXR" . "h"), "_d447517cc97224c" . "765e9183163fe504" . "0" => base64_decode("L" . "Q" . "=" . "="), "_b96dd7974a94d4d16722f81b4658a" . "0d6" => base64_decode("ZG9jdW1lbnRzLndvcmtmbG93cy5ub3RpZnl" . "fYWN0aW9uX2V4ZWN1dGVk"), "_f8c5ae64cf005e10" . "48f67b7be3a51951" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBh" . "Y3Rpb25fZGF0YSwgc3RhdGVf" . "aWQgRlJPTSB3Zl9hY3Rpb24g" . "V0hFUkUgaWQ9aW50Omlk"), "t" . "y" . "p" . "e" => base64_decode("dHlwZQ=" . "="), "_c244a470df52d1d5a7085138ec94" . "e393" => base64_decode("dW5zZX" . "JpYWxp" . "emU="), "_5e433b1c8" . "d5bde08b25" . "5f7e27c183" . "b04" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24gV0hFUkUgdHlwZT1pbnQ6dH" . "lwZSBBTkQgc3RhdGVfaWQ9aW50OnN0YXRlX2lk"), "_dcd48c94b8c6e6387e4d3a774" . "bd0ce44" => base64_decode("Li4vY29tbW9uL3" . "RlbXBsYXRlci5w" . "aHA="), "i" . "d" => base64_decode("aW" . "Q="), "_c5ead5401bce0c8360cb329b48e164" . "8a" => base64_decode("YWN0aW9uX2Rh" . "dGE="), "_e3033efc13162755da51142f9e" . "6eb022" => base64_decode("cHJlZ19yZXBsYW" . "Nl"), "_531602f7210ea5e2d40" . "14444ce4a0dde" => base64_decode("d2ZfYWN0" . "aW9ucw=="), "_96be32a6f44" . "bf54e635e173" . "6acf7a96c" => base64_decode("c2VyaW" . "FsaXpl"), "_10fe3af8a3115caf353c825b9408" . "bfea" => base64_decode("YWN0aW9uX" . "3R5cGU="), "per" . "ms" => base64_decode("cGVybXM" . "="), "_4d707fab93bebb00bbe6" . "9e8159697c90" => base64_decode(""), "_963704c" . "97829cbb" . "6c0d426c" . "bb665145" . "2" => base64_decode("cHJvY2Vzc" . "19jbGFfdG" . "VtcGxhdGU" . "="), "_a389b62c7877ab37d041f77b69a7456" . "1" => base64_decode("QWN0aW9uIG9iamVjdCBpcyBub" . "3Qgc2F2ZWQgeWV0"));
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["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_531602f7210ea5e2d4014444ce4a0dd" . "e"];
        $this->id = -1;
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $this->state_id = $_226b051490848e9e1835697931696225;
        $this->action_type = 0;
        $this->action_object_data = null;
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e8159697c" . "90"];
        $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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c244a470df52d1d5a7" . "085138ec94e393"]($this->action_data);
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_96be32a6f44b" . "f54e635e1736a" . "cf7a96c"]($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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["pe" . "rm" . "s"] || $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_707babebf195e6b331b" . "04212a1c17391"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    
    public function SaveTargetUsers($_5f53bb9a0317b2cff1248a5d6f951ce0 = false)
    {
        if ($_5f53bb9a0317b2cff1248a5d6f951ce0) {
            if ($this->id <= 0) {
                return $this->SetErrMsg($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_a389b62c7877ab37d041f77b" . "69a74561"]);
            }
            $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["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4d707fab93bebb00bbe69e81" . "59697c90"];
    }
    
    
    
    
    
    
    
    public function ProcessUserInput(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return true;
    }
    
    
    
    
    
    
    public function ShowAdminFormFields()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_4d707fab93bebb00bbe69e8159697c9" . "0"];
    }
    
    
    
    
    
    
    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["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_f8c5ae64cf005e104" . "8f67b7be3a51951"], $id);
            $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
            if (!$_a606a2dcd236a549db0574a9c1675927->hasData()) {
                return false;
            }
            $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
            if ($type && $type != $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["t" . "y" . "p" . "e"]]) {
                $_7f5aa4e96d4b415a86ed72ebff677cbe = new Query($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_5e433b1c" . "8d5bde08b" . "255f7e27c" . "183b04"], $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["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["ty" . "pe"]];
        }
        $action = self::GetEmptyActionObjectByType($type);
        $action->id = $id;
        if (isset($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_c5ead5401bce0c" . "8360cb329b48e16" . "48a"]])) {
            $action->RestoreActionData($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_c5ead5401bce0c8360cb32" . "9b48e1648a"]]);
        }
        $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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_e3033efc13162755d" . "a51142f9e6eb022"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_d4683aaab5aae7fc" . "03f50a78f8bc5fe9"], $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d707fab93be" . "bb00bbe69e815" . "9697c90"], $_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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_d447517cc97224c765e9183163fe5" . "040"]);
        $_e3be37b466da96cb55bbca1e9a810ff0->Save();
    }
    public abstract function Execute(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_c5ead5401bce0c8360cb329b48e1648a, $comment);
    protected function CallTemplater($template)
    {
        global $args, $datasources;
        require_once $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_dcd48c94" . "b8c6e6387" . "e4d3a774b" . "d0ce44"];
        $_f274035cf280fb57c0c9ef54d849a83d = $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_963704c97829cbb6c0" . "d426cbb6651452"]($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["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_fc4ffcaec4" . "dff19ed04cc" . "1c9229222d1"] => $_fc4ffcaec4dff19ed04cc1c9229222d1->GetTitle(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_10fe3af8a31" . "15caf353c825" . "b9408bfea"] => $_e6256553b6994263cbac2f560d68f04a[$this->GetType()]);
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_b96dd7974a94d4d16722f81b4658a" . "0d6"], $_c29af76a164c7b22864dd0a9282e8234, $_e4bf1e70e6d9b11e2cf0fe9ce843e56b);
    }
}