function vtDeleteWorkflow($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("deltetask");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $wm = new VTTaskManager($adb);
    $wm->deleteTask($request['task_id']);
    if (isset($request["return_url"])) {
        $returnUrl = vtlib_purify($request["return_url"]);
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Example #2
0
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    $request = vtlib_purify($request);
    // this cleans all values of the array
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = $request["module_name"];
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = $request["save_type"];
    $executionCondition = $request['execution_condition'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset($request["return_url"])) {
        $returnUrl = $request["return_url"];
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
Example #3
0
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    $request = vtlib_purify($request);
    // this cleans all values of the array
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = $request["module_name"];
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = $request["save_type"];
    $executionCondition = $request['execution_condition'];
    $schdayofweek = array();
    if (isset($request['sun_flag']) && $_REQUEST['sun_flag'] != null) {
        $schdayofweek[] = 1;
    }
    if (isset($request['mon_flag']) && $_REQUEST['mon_flag'] != null) {
        $schdayofweek[] = 2;
    }
    if (isset($request['tue_flag']) && $_REQUEST['tue_flag'] != null) {
        $schdayofweek[] = 3;
    }
    if (isset($request['wed_flag']) && $_REQUEST['wed_flag'] != null) {
        $schdayofweek[] = 4;
    }
    if (isset($request['thu_flag']) && $_REQUEST['thu_flag'] != null) {
        $schdayofweek[] = 5;
    }
    if (isset($request['fri_flag']) && $_REQUEST['fri_flag'] != null) {
        $schdayofweek[] = 6;
    }
    if (isset($request['sat_flag']) && $_REQUEST['sat_flag'] != null) {
        $schdayofweek[] = 7;
    }
    // internally the code is prepared to launch the same workflow on many dates
    // but the interface only sends one in
    // TODO: change interface to send in many dates for annual scheduling
    $schannualdates = DateTimeField::convertToDBFormat($request['schdate']);
    $schannualdates = json_encode(array($schannualdates));
    $schminuteinterval = $request['schminuteinterval'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wf->schtypeid = $request['schtypeid'];
        $wf->schtime = VTCreateEventTask::conv12to24hour($request['schtime']);
        $wf->schdayofmonth = json_encode($request['schdayofmonth']);
        $wf->schdayofweek = json_encode($schdayofweek);
        $wf->schannualdates = $schannualdates;
        $wf->schminuteinterval = $schminuteinterval;
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wf->schtypeid = $request['schtypeid'];
            $wf->schtime = VTCreateEventTask::conv12to24hour($request['schtime']);
            $wf->schdayofmonth = json_encode($request['schdayofmonth']);
            $wf->schdayofweek = json_encode($schdayofweek);
            $wf->schannualdates = $schannualdates;
            $wf->schminuteinterval = $schminuteinterval;
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset($request["return_url"])) {
        $returnUrl = $request["return_url"];
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}
function vtWorkflowSave($adb, $request)
{
    $util = new VTWorkflowUtils();
    $module = new VTWorkflowApplication("saveworkflow");
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $description = from_html($request["description"]);
    $moduleName = vtlib_purify($request["module_name"]);
    $conditions = $request["conditions"];
    $taskId = $request["task_id"];
    $saveType = vtlib_purify($request["save_type"]);
    //OnDemand Specific Starts
    $schtypeid = $request["schtypeid"];
    $schtime = $request["s_time"];
    if (!preg_match('/^[0-2]\\d(:[0-5]\\d){1,2}$/', $schtime) or substr($schtime, 0, 2) > 23) {
        // invalid time format
        $schtime = '00:00';
    }
    $schdayofmonth = $request["s_dayofmonth"];
    $schdayofweek = $request["s_dayofweek"];
    $schmonth = $request["s_month"];
    //OnDemand Specific Ends
    $executionCondition = $request['execution_condition'];
    $wm = new VTWorkflowManager($adb);
    if ($saveType == 'new') {
        $wf = $wm->newWorkflow($moduleName);
        $wf->description = $description;
        $wf->test = $conditions;
        $wf->taskId = $taskId;
        $wf->executionConditionAsLabel($executionCondition);
        $wf->filtersavedinnew = 5;
        //OnDemand Specific Starts
        $wf->schtypeid = $schtypeid;
        $wf->schtime = $schtime;
        $wf->schdayofmonth = $schdayofmonth;
        $wf->schdayofweek = $schdayofweek;
        $wf->schmonth = $schmonth;
        //OnDemand Specific Ends
        $wm->save($wf);
    } else {
        if ($saveType == 'edit') {
            $wf = $wm->retrieve($request["workflow_id"]);
            $wf->description = $description;
            $wf->test = $conditions;
            $wf->taskId = $taskId;
            $wf->executionConditionAsLabel($executionCondition);
            $wf->filtersavedinnew = 5;
            //OnDemand Specific Starts
            $wf->schtypeid = $schtypeid;
            $wf->schtime = $schtime;
            $wf->schdayofmonth = $schdayofmonth;
            $wf->schdayofweek = $schdayofweek;
            $wf->schmonth = $schmonth;
            //OnDemand Specific Ends
            $wm->save($wf);
        } else {
            throw new Exception();
        }
    }
    if (isset(vtlib_purify($request["return_url"]))) {
        $returnUrl = vtlib_purify($request["return_url"]);
    } else {
        $returnUrl = $module->editWorkflowUrl($wf->id);
    }
    ?>
		<script type="text/javascript" charset="utf-8">
			window.location="<?php 
    echo $returnUrl;
    ?>
";
		</script>
		<a href="<?php 
    echo $returnUrl;
    ?>
">Return</a>
		<?php 
}