protected function handleRunData(ICFlowType $type, &$runData) { $structure = $type->form->structure; foreach ($structure as $k => $v) { if ($v["data-type"] == "checkbox" && stristr($v["content"], "checkbox")) { if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) { $itemData = "on"; } else { $itemData = ""; } } elseif (!in_array($v["data-type"], array("select", "listview"))) { if (isset($v["data-value"])) { $itemData = str_replace("\"", "", $v["data-value"]); if ($itemData == "{macro}") { $itemData = ""; } } else { $itemData = ""; } } else { $itemData = ""; } $runData[strtolower($k)] = $itemData; } WfCommonUtil::addRunData($type->getID(), $runData, $structure); }
public static function createNewRun($flowId, $uid, $uidstr, $pid = 0, $remind = 0, $startTime = "") { if (!$startTime) { $startTime = TIMESTAMP; } $flow = new ICFlowType(intval($flowId)); $runName = self::replaceAutoName($flow, $uid, !!$pid); $maxRunId = FlowRun::model()->getMaxRunId(); if ($maxRunId) { $runId = $maxRunId + 1; } $data = array("runid" => $runId, "name" => $runName, "flowid" => $flowId, "beginuser" => $uid, "begintime" => $startTime, "parentrun" => $pid); FlowRun::model()->add($data); if (strstr($runName, "{RUN}") !== false) { $runName = str_replace("{RUN}", $runId, $runName); FlowRun::model()->modify($runId, array("name" => $runName)); } foreach (explode(",", trim($uidstr, ",")) as $k => $v) { if ($v == $uid) { $opflag = 1; } else { $opflag = 0; } $wrpdata = array("runid" => $runId, "processid" => 1, "uid" => $v, "flag" => 1, "flowprocess" => 1, "opflag" => $opflag, "createtime" => $startTime); FlowRunProcess::model()->add($wrpdata); } if ($remind) { $remindUrl = Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param(array("runid" => $runId, "flowid" => $flowId, "processid" => 1, "flowprocess" => 1)))); $config = array("{url}" => $remindUrl, "{runname}" => $runName, "{runid}" => $runId); Notify::model()->sendNotify($uid, "workflow_new_notice", $config); } if ($pid != 0) { $pflowId = FlowRun::model()->fetchFlowIdByRunId($pid); $pRundata = WfHandleUtil::getRunData($pid); $pfield = $subFlow = array(); $relation = FlowProcess::model()->fetchRelationOut($pflowId, $flowId); if ($relation) { $relationArr = explode(",", trim($relation, ",")); foreach ($relationArr as $field) { $pfield[] = substr($field, 0, strpos($field, "=>")); $subFlow[] = substr($field, strpos($field, "=>") + strlen("=>")); } } $runData = array("runid" => $runId, "name" => $runName, "begin" => $startTime, "beginuser" => $uid); } $structure = $flow->form->parser->structure; if (is_array($structure) && 0 < count($structure)) { foreach ($structure as $k => $v) { if ($v["data-type"] !== "label") { if ($v["data-type"] == "checkbox") { if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) { $itemData = "on"; } else { $itemData = ""; } } if ($v["data-type"] != "select" && $v["data-type"] != "listview") { $itemData = isset($v["data-value"]) ? $v["data-value"] : ""; $itemData = str_replace("\"", "", $itemData); if ($v["data-type"] == "auto") { $itemData = ""; } } if ($pid != 0 && in_array($v["data-title"], $subFlow)) { $i = array_search($v["data-title"], $subFlow); $ptitle = $pfield[$i]; $itemData = $pRundata["{$ptitle}"]; if (is_array($itemData) && $v["data-type"] == "listview") { $itemDataStr = ""; $newDataStr = ""; for ($j = 1; $j < count($itemData); ++$j) { foreach ($itemData[$j] as $val) { $newDataStr .= $val . "`"; } $itemDataStr .= $newDataStr . "\r\n"; $newDataStr = ""; } $itemData = $itemDataStr; } } $runData[$k] = $itemData; } } } WfCommonUtil::addRunData($flowId, $runData, $structure); return $runId; }