File size: 3,450 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php

use ProcessMaker\Plugins\PluginRegistry;

if (! isset( $_REQUEST['action'] )) {
    $return['success'] = 'failure';
    $return['message'] = 'You may request an action';
    print G::json_encode( $return );
    die();
}
if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['action'])) {
    $return['success'] = 'failure';
    $return['message'] = 'The requested action doesn\'t exists';
    print G::json_encode( $return );
    die();
}

$functionName = $_REQUEST['action'];
//var_dump($functionName);
$functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
$functionName( $functionParams );

function searchSavedJob ($schUid)
{

}

function pluginsList ()
{
    $oPluginRegistry = PluginRegistry::loadSingleton();
    $activePluginsForCaseScheduler = $oPluginRegistry->getCaseSchedulerPlugins();
    $selectedPlugin = "";
    if ((isset( $_REQUEST['plg_uid'] )) && ($_REQUEST['plg_uid'] != "")) {
        $selectedPlugin = $_REQUEST['plg_uid'];
    }
    if (! empty( $activePluginsForCaseScheduler )) {
        echo '<select style="width: 300px;" name="form[CASE_SH_PLUGIN_UID]" id="form[CASE_SH_PLUGIN_UID]" class="module_app_input___gray" required="1" onChange="showPluginSelection(this.options[this.selectedIndex].value,getField(\'PRO_UID\').value)">';
        echo "<option value=\"\">- Select -</option>";
        foreach ($activePluginsForCaseScheduler as $key => $caseSchedulerPluginDetail) {
            $sActionId = $caseSchedulerPluginDetail->sActionId;
            $sNamespace = $caseSchedulerPluginDetail->sNamespace;
            $optionId = $sNamespace . "--" . $sActionId;
            $selectedOption = "";
            if ($selectedPlugin == $optionId) {
                $selectedOption = "selected";
            }
            echo "<option value=\"$optionId\" $selectedOption>" . $sActionId . "</option>";
        }
        echo '</select>';
        //G::pr($activePlugnsForCaseScheduler);
    }
}

function pluginCaseSchedulerForm ()
{
    if (! isset( $_REQUEST['selectedOption'] )) {
        die();
    }
    $G_PUBLISH = new Publisher();
    $params = explode( "--", $_REQUEST['selectedOption'] );
    $oPluginRegistry = PluginRegistry::loadSingleton();
    $activePluginsForCaseScheduler = $oPluginRegistry->getCaseSchedulerPlugins();
    /** @var \ProcessMaker\Plugins\Interfaces\CaseSchedulerPlugin $caseSchedulerPluginDetail */
    foreach ($activePluginsForCaseScheduler as $caseSchedulerPluginDetail) {
        if (($caseSchedulerPluginDetail->equalNamespaceTo($params[0])) &&
            ($caseSchedulerPluginDetail->equalActionIdTo($params[1]))) {
            $caseSchedulerSelected = $caseSchedulerPluginDetail;
        }
    }
    if ((isset( $caseSchedulerSelected )) && (is_object( $caseSchedulerSelected ))) {
        //Render the form
        if ((isset( $_REQUEST['sch_uid'] )) && ($_REQUEST['sch_uid'] != "")) {
            //$oData=$oPluginRegistry->executeMethod( $caseSchedulerPluginDetail->sNamespace, $caseSchedulerPluginDetail->sActionGetFields, array("SCH_UID"=>$_REQUEST['sch_uid']) );
            $oData = array ("SCH_UID" => $_REQUEST['sch_uid'],"PRO_UID" => $_REQUEST['pro_uid']
            );
        } else {
            $oData = array ("PRO_UID" => $_REQUEST['pro_uid']
            );
        }
        $oPluginRegistry->executeMethod($caseSchedulerPluginDetail->getNamespace(), $caseSchedulerPluginDetail->getActionForm(), $oData);
    }
}