<?php
$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] ?: array()) + array("_96be32a6f44bf54e63" . "5e1736acf7a96c" => base64_decode("c2VyaWFs" . "aXpl"), "_5e433b1c8d5bde08b255f7e27c183b0" . "4" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb2" . "4gV0hFUkUgdHlwZT1pbnQ6dHlwZSBBTkQgc3RhdGVfaWQ9aW50OnN0YXRlX2lk"), "_fc4ffca" . "ec4dff19" . "ed04cc1c" . "9229222d" . "1" => base64_decode("ZG9j" . "dW1l" . "bnQ="), "_707babebf195e6" . "b331b04212a1c17" . "391" => base64_decode("YWN0aW9uX29iamV" . "jdF9kYXRh"), "_e3033efc13162755da51142f9e" . "6eb022" => base64_decode("cHJlZ19yZXBsYWN" . "l"), "_d4683aaab5aae7fc03f50a" . "78f8bc5fe9" => base64_decode("L153X" . "2ZfLw" . "=="), "_c5ead5401bce0" . "c8360cb329b48e" . "1648a" => base64_decode("YWN0aW9uX2Rh" . "dGE="), "_c244a470d" . "f52d1d5a70" . "85138ec94e" . "393" => base64_decode("dW5zZXJpYWxpem" . "U="), "_531602f7210ea5e" . "2d4014444ce4a0dd" . "e" => base64_decode("d2ZfYWN0" . "aW9ucw=="), "_4d707fab93bebb00bb" . "e69e8159697c90" => base64_decode(""), "_d447517" . "cc97224c" . "765e9183" . "163fe504" . "0" => base64_decode("LQ" . "=="), "_f8c5ae64cf005e1048f67b7b" . "e3a51951" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24g" . "V0hFUkUgaWQ9aW50Omlk"), "_10fe3af8a3115caf353c82" . "5b9408bfea" => base64_decode("YWN0a" . "W9uX3" . "R5cGU" . "="), "ty" . "pe" => base64_decode("dHlw" . "ZQ=="), "_a389b62c7877ab37d041f" . "77b69a74561" => base64_decode("QWN0aW9uIG9iamVjdCBpcyBub3Qgc2F" . "2ZWQgeWV0"), "_b96dd7974a9" . "4d4d16722f81" . "b4658a0d6" => base64_decode("ZG9jdW1lbnRzLndvcmtmbG93cy5ub3RpZnl" . "fYWN0aW9uX2V4ZWN1dGVk"), "perm" . "s" => base64_decode("cGV" . "ybX" . "M="), "_dcd48c94b8c6e6387e4d3a774bd0c" . "e44" => base64_decode("Li4vY29tbW9uL3Rl" . "bXBsYXRlci5waHA="), "_963704c97829cbb6c0d426cb" . "b6651452" => base64_decode("cHJvY2Vzc19jbGFfdGVt" . "cGxhdGU="), "i" . "d" => base64_decode("aWQ" . "="));
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["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_531602f7210ea5e2d4014444ce4a" . "0dde"];
        $this->id = -1;
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $this->state_id = $_226b051490848e9e1835697931696225;
        $this->action_type = 0;
        $this->action_object_data = null;
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_4d707fab93bebb00bbe69e8" . "159697c90"];
        $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["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c244a470df52d1d5a7085138ec94e39" . "3"]($this->action_data);
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_96be32a6f4" . "4bf54e635e1" . "736acf7a96c"]($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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["p" . "e" . "r" . "m" . "s"] || $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_707babebf195e" . "6b331b04212a1c" . "17391"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    
    public function SaveTargetUsers($_5f53bb9a0317b2cff1248a5d6f951ce0 = false)
    {
        if ($_5f53bb9a0317b2cff1248a5d6f951ce0) {
            if ($this->id <= 0) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_a389b62c7877ab37d041f7" . "7b69a74561"]);
            }
            $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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_4d707fab93bebb0" . "0bbe69e8159697c9" . "0"];
    }
    
    
    
    
    
    
    
    public function ProcessUserInput(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return true;
    }
    
    
    
    
    
    
    public function ShowAdminFormFields()
    {
        return $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_4d707fab93bebb00bbe69" . "e8159697c90"];
    }
    
    
    
    
    
    
    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"]["_f8c5ae64cf005e1048f67" . "b7be3a51951"], $id);
            $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
            if (!$_a606a2dcd236a549db0574a9c1675927->hasData()) {
                return false;
            }
            $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
            if ($type && $type != $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["typ" . "e"]]) {
                $_7f5aa4e96d4b415a86ed72ebff677cbe = new Query($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5e433b1c8d5bde08b25" . "5f7e27c183b04"], $type, $_226b051490848e9e1835697931696225);
                $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
                if ($_a606a2dcd236a549db0574a9c1675927->hasData()) {
                    $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
                    $id = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["i" . "d"]];
                } else {
                    $id = 0;
                }
            }
            $type = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["ty" . "pe"]];
        }
        $action = self::GetEmptyActionObjectByType($type);
        $action->id = $id;
        if (isset($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_c5ead5401bce0c8360cb" . "329b48e1648a"]])) {
            $action->RestoreActionData($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_c5ead5401bce0c8" . "360cb329b48e1648" . "a"]]);
        }
        $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["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_e3033efc13162755da51142f9e" . "6eb022"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_d4683aaab5aae7fc03f50a7" . "8f8bc5fe9"], $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_4d707fab93bebb00bbe69e81" . "59697c90"], $_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["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_d447517" . "cc97224c" . "765e9183" . "163fe504" . "0"]);
        $_e3be37b466da96cb55bbca1e9a810ff0->Save();
    }
    public abstract function Execute(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_c5ead5401bce0c8360cb329b48e1648a, $comment);
    protected function CallTemplater($template)
    {
        global $args, $datasources;
        require_once $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_dcd48c94b8c" . "6e6387e4d3a7" . "74bd0ce44"];
        $_f274035cf280fb57c0c9ef54d849a83d = $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_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["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_fc4ffcaec" . "4dff19ed04" . "cc1c922922" . "2d1"] => $_fc4ffcaec4dff19ed04cc1c9229222d1->GetTitle(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_10fe3af" . "8a3115ca" . "f353c825" . "b9408bfe" . "a"] => $_e6256553b6994263cbac2f560d68f04a[$this->GetType()]);
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_b96dd7974a94d4d1672" . "2f81b4658a0d6"], $_c29af76a164c7b22864dd0a9282e8234, $_e4bf1e70e6d9b11e2cf0fe9ce843e56b);
    }
}