Code for cmd_workflow.php

<?php
/*
 * filename: cmd_workflow.php 
 */


function getValue($prop_name, $cmd_list)
{
	$prop_value = NULL;

	for ($k=0; $k < count($cmd_list); $k++) 
	{
		if ($cmd_list[$k] == $prop_name) {
			if ($k+1 < count($cmd_list)) {
				$prop_value = $cmd_list[$k+1];		
			}

		}
	}
	return $prop_value;
}


//	foreach $cmd_list as $t {
//
//
// }

/*
 * This function dispatches a command and its parameters to the corresponding function 
 */
function dispatchWorkflowCmd($cmd, $cmd_list) 
{
	global $gResult;
	$status = cCmdStatus_NOT_FOUND;
	
	$cmd = $cmd_list[0];
	if ($cmd != "workflow") {
		$status = cCmdStatus_NOT_FOUND; 
		return $status;
	}

	$arg1 = "";
	if (count($cmd_list) > 1) {
		$arg1 = $cmd_list[1];
	}
	
	if ($arg1 == "create") {
		$status = wf_create($cmd_list);
	}
	elseif ($arg1 == "delete") {
		$status = wf_delete($cmd_list);
	}
	elseif ($arg1 == "list") {
		$status = wf_list($cmd_list);
	}
	else {
		$status = cCmdStatus_NOT_FOUND; 
	}
	
	return $status;
}

/*
 * create -- Creates a workflow
 */
function wf_create($cmd_list) {
	global $gResult;

	$n = getValue("-n",$cmd_list);
	if ($n == NULL) {
		return cCmdStatus_ERROR; 
	}

	$i = getValue("-i",$cmd_list); 
	if ($i == NULL) {
		return cCmdStatus_ERROR; 
	}


	$t = "Stub to implement workflow create (name: $n) (info: $i) \n"; 
	$gResult = $t . print_r($cmd_list,true);
	return cCmdStatus_OK; 
}

/*
 * create -- Deletes a workflow
 */
function wf_delete($cmd_list) {
	global $gResult;
	$t = "Stub to implement workflow delete \n"; 
	$gResult = $t . print_r($cmd_list,true);
	return cCmdStatus_OK; 
}

/*
 * create -- List all workflows
 */
function wf_list($cmd_list) {
	global $gResult;
	$t = "Stub to implement workflow list \n"; 
	$gResult = $t . print_r($cmd_list,true);
	return cCmdStatus_OK; 
}

/*
 *     
 */