<?php
$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"] ?: array()) + array("p" . "e" . "r" . "m" . "s" => base64_decode("cGVy" . "bXM="), "ty" . "pe" => base64_decode("dH" . "lw" . "ZQ" . "=="), "_a389b62c7877a" . "b37d041f77b69a" . "74561" => base64_decode("QWN0aW9uIG9iamVjdCBpcyBub3Qgc2F2ZWQgeW" . "V0"), "_d4683aaab5aae7f" . "c03f50a78f8bc5fe" . "9" => base64_decode("L15" . "3X2" . "ZfL" . "w=="), "_531602f7210e" . "a5e2d4014444c" . "e4a0dde" => base64_decode("d2ZfYWN0aW9ucw=" . "="), "_b96dd797" . "4a94d4d16" . "722f81b46" . "58a0d6" => base64_decode("ZG9jdW1lbnRzLnd" . "vcmtmbG93cy5ub3" . "RpZnlfYWN0aW9uX" . "2V4ZWN1dGVk"), "_c5ead5401bce0c8360cb" . "329b48e1648a" => base64_decode("YWN0" . "aW9u" . "X2Rh" . "dGE="), "_fc4ffcaec" . "4dff19ed04" . "cc1c922922" . "2d1" => base64_decode("ZG9jdW1lb" . "nQ="), "_707babebf195e6b331b0421" . "2a1c17391" => base64_decode("YWN0aW9uX29iamVjd" . "F9kYXRh"), "_dcd48c94b8c6e6387e4d3a774bd0" . "ce44" => base64_decode("Li4vY29t" . "bW9uL3Rl" . "bXBsYXRl" . "ci5waHA="), "_96be32a6f44bf54e635" . "e1736acf7a96c" => base64_decode("c2Vy" . "aWFs" . "aXpl"), "_10fe3af8a3115caf353c825b9408" . "bfea" => base64_decode("YWN0aW9uX3R5" . "cGU="), "_d447517cc9722" . "4c765e9183163f" . "e5040" => base64_decode("L" . "Q" . "=" . "="), "_4d707fab93bebb00bbe69e8159697" . "c90" => base64_decode(""), "_e3033efc13162755da51142" . "f9e6eb022" => base64_decode("cHJlZ19yZX" . "BsYWNl"), "_c244a470df52d1d5a70851" . "38ec94e393" => base64_decode("dW5zZXJpYWxp" . "emU="), "_5e433b1c8d5bde0" . "8b255f7e27c183b0" . "4" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24gV0hFUkUgdHlwZT1pbnQ6dHlwZSBB" . "TkQgc3RhdGVfaWQ9aW50OnN0YXRlX2lk"), "i" . "d" => base64_decode("aW" . "Q="), "_f8c5ae64cf005e1048f67b7be3" . "a51951" => base64_decode("U0VMRUNUIGlkLCB0eXBlLCBhY3Rpb25fZGF0YSwgc3RhdGVfaWQgRlJPTSB3Zl9hY3Rpb24gV0h" . "FUkUgaWQ9aW50Omlk"), "_963704c978" . "29cbb6c0d42" . "6cbb6651452" => base64_decode("cHJvY2Vzc" . "19jbGFfdG" . "VtcGxhdGU" . "="));
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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_531602f7210ea5e2d4014444c" . "e4a0dde"];
        $this->id = -1;
        $this->wf_id = $_eb57e3a45673c8e851b42c4eee3742ea;
        $this->state_id = $_226b051490848e9e1835697931696225;
        $this->action_type = 0;
        $this->action_object_data = null;
        $this->action_data = $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_4d707fab93bebb00" . "bbe69e8159697c90"];
        $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"]["_c244a470df52" . "d1d5a7085138e" . "c94e393"]($this->action_data);
        return true;
    }
    
    
    
    
    
    
    public function Save()
    {
        $this->action_data = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_96be32a6f44bf54e635e1" . "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["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["pe" . "rm" . "s"] || $_40421a4e75c2ba3c82b018e6b56f7425 == $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_707babebf195e6b331b04212a1c" . "17391"] || parent::IsSpecial($_40421a4e75c2ba3c82b018e6b56f7425);
    }
    
    
    
    
    
    
    
    
    public function SaveTargetUsers($_5f53bb9a0317b2cff1248a5d6f951ce0 = false)
    {
        if ($_5f53bb9a0317b2cff1248a5d6f951ce0) {
            if ($this->id <= 0) {
                return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_a389b62c7877ab37d041f77b69a745" . "61"]);
            }
            $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["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"];
    }
    
    
    
    
    
    
    
    public function ProcessUserInput(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1)
    {
        return true;
    }
    
    
    
    
    
    
    public function ShowAdminFormFields()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe6" . "9e8159697c90"];
    }
    
    
    
    
    
    
    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["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f8c5ae64" . "cf005e104" . "8f67b7be3" . "a51951"], $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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_5e433b1c8d5bde08b255f7e27c1" . "83b04"], $type, $_226b051490848e9e1835697931696225);
                $_a606a2dcd236a549db0574a9c1675927 = $db->query($_7f5aa4e96d4b415a86ed72ebff677cbe);
                if ($_a606a2dcd236a549db0574a9c1675927->hasData()) {
                    $_189840d11056515e52402d1412a0b6e4 = $_a606a2dcd236a549db0574a9c1675927->fetchArray();
                    $id = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["i" . "d"]];
                } else {
                    $id = 0;
                }
            }
            $type = $_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["typ" . "e"]];
        }
        $action = self::GetEmptyActionObjectByType($type);
        $action->id = $id;
        if (isset($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_c5ead540" . "1bce0c836" . "0cb329b48" . "e1648a"]])) {
            $action->RestoreActionData($_189840d11056515e52402d1412a0b6e4[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_c5ead5401bce0c8360c" . "b329b48e1648a"]]);
        }
        $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["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_e3033efc13162755da51142f9e6eb0" . "22"]($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_d4683aaab5aae7fc03f50a78f8bc" . "5fe9"], $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_4d707fab93bebb00b" . "be69e8159697c90"], $_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["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_d447517cc972" . "24c765e918316" . "3fe5040"]);
        $_e3be37b466da96cb55bbca1e9a810ff0->Save();
    }
    public abstract function Execute(ERMSDataObj $_fc4ffcaec4dff19ed04cc1c9229222d1, $_c5ead5401bce0c8360cb329b48e1648a, $comment);
    protected function CallTemplater($template)
    {
        global $args, $datasources;
        require_once $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_dcd48c94b8c6e6" . "387e4d3a774bd0c" . "e44"];
        $_f274035cf280fb57c0c9ef54d849a83d = $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_963704c97829" . "cbb6c0d426cbb" . "6651452"]($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["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_fc4ffcaec4" . "dff19ed04cc" . "1c9229222d1"] => $_fc4ffcaec4dff19ed04cc1c9229222d1->GetTitle(), $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_10fe3af8a3115caf353c825b9408bf" . "ea"] => $_e6256553b6994263cbac2f560d68f04a[$this->GetType()]);
        return WFWorkflow::SendNotification($_fc4ffcaec4dff19ed04cc1c9229222d1, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_b96dd7974a94d4d1672" . "2f81b4658a0d6"], $_c29af76a164c7b22864dd0a9282e8234, $_e4bf1e70e6d9b11e2cf0fe9ce843e56b);
    }
}