public function checkFlowAccess($flowId, $processId, $jump = "")
 {
     $per = WfNewUtil::checkProcessPermission($flowId, $processId, $this->getUid());
     if (!$per) {
         $errMsg = Ibos::lang("Permission denied");
         if (!empty($jump)) {
             $this->error($errMsg, $jump);
         } else {
             exit($errMsg);
         }
     }
 }
Example #2
0
 public function actionAdvanced()
 {
     $flowList = $sort = array();
     $enabledFlowIds = WfNewUtil::getEnabledFlowIdByUid($this->uid);
     foreach (FlowType::model()->fetchAll() as $flow) {
         $catId = $flow["catid"];
         $flowId = $flow["flowid"];
         if (!isset($flowList[$catId])) {
             $sort[$catId] = array();
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 $sort[$catId] = $cat;
             }
         }
         if ($flow["usestatus"] == 3) {
             continue;
         }
         $enabled = in_array($flowId, $enabledFlowIds);
         if (!$enabled && $flow["usestatus"] == 2) {
             continue;
         }
         $per = FlowPermission::model()->fetchPermission($this->uid, $flowId);
         if ($flow["type"] == 1 && Ibos::app()->user->isadministrator != "1" && !$per) {
             if (!WfNewUtil::checkProcessPermission($flowId, 0, $this->uid)) {
                 continue;
             }
         }
         $handle = $done = 0;
         foreach (FlowRun::model()->fetchAllEndByFlowID($flowId) as $run) {
             if ($run["endtime"] == 0) {
                 $handle++;
             } else {
                 $done++;
             }
         }
         $flow["handle"] = $handle;
         $flow["done"] = $done;
         $flow["enabled"] = $enabled;
         $flowList[$catId][$flowId] = $flow;
     }
     ksort($flowList, SORT_NUMERIC);
     $this->setPageTitle(Ibos::lang("Select process"));
     $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("Work query"), "url" => $this->createUrl("query/index")), array("name" => Ibos::lang("Advanced query"), "url" => $this->createUrl("query/advanced")), array("name" => Ibos::lang("Select process"))));
     $data = array("flows" => $flowList, "sort" => $sort);
     $this->render("advanced", $data);
 }
Example #3
0
 protected function handleStartFlowList(&$data)
 {
     $flowList = $commonlyFlowList = $sort = array();
     $enabledFlowIds = WfNewUtil::getEnabledFlowIdByUid($this->uid);
     $commonlyFlowIds = FlowRun::model()->fetchCommonlyUsedFlowId($this->uid);
     foreach (FlowType::model()->fetchAll(array("order" => "sort,flowid")) as $flow) {
         $catId = $flow["catid"];
         $flowId = $flow["flowid"];
         if (!isset($flowList[$catId])) {
             $sort[$catId] = array();
             $cat = FlowCategory::model()->fetchByPk($catId);
             if ($cat) {
                 $sort[$catId] = $cat;
             }
         }
         if ($flow["usestatus"] == 3) {
             continue;
         }
         $enabled = in_array($flowId, $enabledFlowIds);
         if (!$enabled && $flow["usestatus"] == 2) {
             continue;
         }
         $flow["enabled"] = $enabled;
         if (in_array($flowId, $commonlyFlowIds)) {
             $commonlyFlowList[] = $flow;
         }
         $flowList[$catId][$flowId] = $flow;
     }
     ksort($flowList, SORT_NUMERIC);
     $data["flows"] = $flowList;
     $data["sort"] = $sort;
     $data["commonlyFlows"] = $commonlyFlowList;
 }
Example #4
0
 public static function hasAccess($user, $compareArr)
 {
     $deptAccess = WfNewUtil::compareIds($user["alldeptid"], $compareArr["deptid"], "d");
     $userAccess = WfNewUtil::compareIds($user["uid"], $compareArr["uid"], "u");
     $posAccess = WfNewUtil::compareIds($user["allposid"], $compareArr["positionid"], "p");
     if ($deptAccess || $userAccess || $posAccess) {
         return true;
     } else {
         return false;
     }
 }
Example #5
0
 public function actionTurnNextPost()
 {
     $runId = $_GET["runid"];
     $flowId = $_GET["flowid"];
     $processId = $_GET["processid"];
     $flowProcess = $_GET["flowprocess"];
     $topflag = isset($_GET["topflag"]) ? $_GET["topflag"] : null;
     $this->nextAccessCheck($topflag, $runId, $processId);
     $plugin = FlowProcess::model()->fetchTurnPlugin($flowId, $flowProcess);
     if ($plugin) {
         $pluginFile = "./system/modules/workflow/plugins/turn/" . $plugin;
         if (file_exists($pluginFile)) {
             include_once $pluginFile;
         }
     }
     $prcsTo = $_GET["processto"];
     $prcsToArr = explode(",", trim($prcsTo, ","));
     $prcsChooseArr = $_GET["prcs_choose"];
     $prcsChoose = implode($prcsChooseArr, ",");
     $message = $_GET["message"];
     $toId = $nextId = $beginUserId = $toallId = "";
     $ext = array("{url}" => Ibos::app()->urlManager->createUrl("workflow/list/index", array("op" => "category")), "{message}" => $message);
     if (isset($_GET["remind"][1])) {
         $nextId = "";
         if (isset($_GET["prcs_user_op"])) {
             $nextId = intval($_GET["prcs_user_op"]);
         } else {
             foreach ($prcsChooseArr as $k => $v) {
                 if (isset($_GET["prcs_user_op" . $k])) {
                     $nextId .= $_GET["prcs_user_op" . $k] . ",";
                 }
             }
             $nextId = trim($nextId, ",");
         }
     }
     if (isset($_GET["remind"][2])) {
         $beginuser = FlowRunProcess::model()->fetchAllOPUid($runId, 1, true);
         if ($beginuser) {
             $beginUserId = StringUtil::wrapId($beginuser[0]["uid"]);
         }
     }
     if (isset($_GET["remind"]["3"])) {
         $toallId = "";
         if (isset($_GET["prcs_user"])) {
             $toallId = filter_input(INPUT_POST, "prcs_user", FILTER_SANITIZE_STRING);
         } else {
             foreach ($prcsChooseArr as $k => $v) {
                 if (isset($_GET["prcs_user" . $k])) {
                     $toallId .= filter_input(INPUT_POST, "prcs_user" . $k, FILTER_SANITIZE_STRING);
                 }
             }
         }
     }
     $idstr = $nextId . "," . $beginUserId . "," . $toallId;
     $toId = StringUtil::filterStr($idstr);
     if ($toId) {
         Notify::model()->sendNotify($toId, "workflow_turn_notice", $ext);
     }
     if ($prcsChoose == "") {
         $prcsUserOp = isset($_GET["prcs_user_op"]) ? intval($_GET["prcs_user_op"]) : "";
         $prcsUser = isset($_GET["prcs_user"]) ? $_GET["prcs_user"] : "";
         $run = FlowRun::model()->fetchByPk($runId);
         if ($run) {
             $pId = $run["parentrun"];
             $runName = $run["name"];
         }
         FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND processid = %d AND flowprocess = %d", $runId, $processId, $flowProcess));
         FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND flag = 3", $runId));
         FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND flowprocess = %d AND uid = %d", $runId, $processId, $flowProcess, $this->uid));
         $isUnique = FlowRunProcess::model()->getIsUnique($runId);
         if (!$isUnique) {
             FlowRun::model()->modify($runId, array("endtime" => TIMESTAMP));
         }
         if ($pId != 0) {
             $parentflowId = FlowRun::model()->fetchFlowIdByRunId($pId);
             $parentFormId = FlowType::model()->fetchFormIDByFlowID($parentflowId);
             $parentPrcs = FlowRunProcess::model()->fetchIDByChild($pId, $runId);
             if ($parentPrcs) {
                 $parentPrcsId = $parentPrcs["processid"];
                 $parentFlowProcess = $parentPrcs["flowprocess"];
             }
             $parentProcess = FlowProcess::model()->fetchProcess($parentflowId, $parentPrcsId);
             if ($parentProcess["relationout"] !== "") {
                 $relationArr = explode(",", trim($parentProcess["relationout"], ","));
                 $src = $des = $set = array();
                 foreach ($relationArr as $field) {
                     $src[] = substr($field, 0, strpos($field, "=>"));
                     $des[] = substr($field, strpos($field, "=>") + strlen("=>"));
                 }
                 $runData = WfHandleUtil::getRunData($runId);
                 $form = new ICFlowForm($parentFormId);
                 $structure = $form->parser->structure;
                 foreach ($structure as $k => $v) {
                     if ($v["data-type"] !== "label" && in_array($v["data-title"], $des)) {
                         $i = array_search($v["data-title"], $des);
                         $ptitle = $src[$i];
                         $itemData = $runData[$ptitle];
                         if (is_array($itemData) && $v["data-type"] == "listview") {
                             $itemDataStr = "";
                             $newDataStr = "";
                             for ($j = 1; $j < count($itemData); ++$j) {
                                 foreach ($itemData[$i] as $val) {
                                     $newDataStr .= $val . "`";
                                 }
                                 $itemDataStr .= $newDataStr . "\r\n";
                                 $newDataStr = "";
                             }
                             $itemData = $itemDataStr;
                         }
                         $field = "data_" . $v["itemid"];
                         $set[$field] = $itemData;
                     }
                 }
                 if (!empty($set)) {
                     FlowDataN::model()->update($parentflowId, $pId, $set);
                 }
             }
             WfHandleUtil::updateParentOver($runId, $pId);
             $prcsBack = $_GET["prcsback"] . "";
             if ($prcsBack != "") {
                 $parentPrcsIdNew = $parentPrcsId + 1;
                 $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $prcsUserOp, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 1, "topflag" => 0, "parent" => $parentFlowProcess);
                 FlowRunProcess::model()->add($data);
                 foreach (explode(",", trim($prcsUser, ",")) as $k => $v) {
                     if ($v != $prcsUserOp && !empty($v)) {
                         $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $v, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 0, "topflag" => 0, "parent" => $parentFlowProcess);
                         FlowRunProcess::model()->add($data);
                     }
                 }
                 $parentRunName = FlowRun::model()->fetchNameByRunID($pId);
                 $content = "[{$runName}]" . Ibos::lang("Log return the parent process") . ":[{$parentRunName}]";
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
                 FlowRun::model()->modify($pId, array("endtime" => null));
             }
         }
         $content = Ibos::lang("Form endflow");
         WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
     } else {
         $freeother = FlowType::model()->fetchFreeOtherByFlowID($flowId);
         $prcsChooseArrCount = count($prcsChooseArr);
         for ($i = 0; $i < $prcsChooseArrCount; $i++) {
             $flowPrcsNext = $prcsToArr[$prcsChooseArr[$i]];
             $prcsIdNew = $processId + 1;
             $str = "prcs_user_op" . $prcsChooseArr[$i];
             $prcsUserOp = $_GET[$str];
             if (empty($prcsUserOp)) {
                 $this->ajaxReturn(array("isSuccess" => false, "msg" => "必须选择主办人"), "JSONP");
                 exit;
             }
             if ($freeother == 2) {
                 $prcsUserOp = WfHandleUtil::turnOther($prcsUserOp, $flowId, $runId, $processId, $flowProcess);
             }
             $str = "prcs_user" . $prcsChooseArr[$i];
             $prcsUser = explode(",", $_GET[$str]);
             array_push($prcsUser, $prcsUserOp);
             $prcsUser = implode(",", array_unique($prcsUser));
             if ($freeother == 2) {
                 $prcsUser = WfHandleUtil::turnOther($prcsUser, $flowId, $runId, $processId, $flowProcess, $prcsUserOp);
             }
             $str = "topflag" . $prcsChooseArr[$i];
             $topflag = intval($_GET[$str]);
             $fp = FlowProcess::model()->fetchProcess($flowId, $flowPrcsNext);
             if ($fp["childflow"] == 0) {
                 $_topflag = FlowRunProcess::model()->fetchTopflag($runId, $prcsIdNew, $flowPrcsNext);
                 if ($_topflag) {
                     $topflag = $_topflag;
                 }
                 $isOpHandle = FlowRunProcess::model()->getIsOpOnTurn($runId, $prcsIdNew, $flowPrcsNext);
                 if ($isOpHandle) {
                     $prcsUserOp = "";
                     $t_flag = 1;
                 } else {
                     $t_flag = 0;
                 }
                 foreach (explode(",", trim($prcsUser)) as $k => $v) {
                     if ($v == $prcsUserOp || $topflag == 1) {
                         $opflag = 1;
                     } else {
                         $opflag = 0;
                     }
                     if ($topflag == 2) {
                         $opflag = 0;
                     }
                     $workedId = FlowRunProcess::model()->fetchProcessIDOnTurn($runId, $prcsIdNew, $flowPrcsNext, $v, $fp["gathernode"]);
                     if (!$workedId) {
                         $wrp = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $this->uid);
                         if ($wrp) {
                             $otherUser = $wrp["otheruser"] != "" ? $wrp["otheruser"] : "";
                         } else {
                             $otherUser = "";
                         }
                         $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $v, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => $opflag, "topflag" => $topflag, "parent" => $flowProcess, "createtime" => TIMESTAMP, "otheruser" => $otherUser);
                         FlowRunProcess::model()->add($data);
                     } else {
                         if ($prcsIdNew < $workedId) {
                             $prcsIdNew = $workedId;
                         }
                         $lastPrcsId = $workedId;
                         FlowRunProcess::model()->updateTurn($flowProcess, $prcsIdNew, $runId, $lastPrcsId, $flowPrcsNext, $v);
                     }
                 }
                 if ($t_flag == 1) {
                     FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess);
                 } else {
                     FlowRunProcess::model()->updateToTrans($runId, $processId, $flowProcess);
                 }
                 $userNameStr = User::model()->fetchRealnamesByUids($prcsUser);
                 $content = Ibos::lang("To the steps") . $prcsIdNew . "," . Ibos::lang("Transactor") . ":" . $userNameStr;
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
             } else {
                 $runidNew = WfNewUtil::createNewRun($fp["childflow"], $prcsUserOp, $prcsUser, $runId);
                 $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $prcsUserOp, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => 1, "topflag" => 0, "parent" => $flowProcess, "childrun" => $runidNew, "createtime" => TIMESTAMP);
                 FlowRunProcess::model()->add($data);
                 FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess);
                 $content = Ibos::lang("Log new subflow") . $runidNew;
                 WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content);
             }
         }
     }
     $this->ajaxReturn(array("isSuccess" => true), "JSONP");
 }
Example #6
0
 public static function getFlowList($uid, $filterUseStatus = true)
 {
     $temp = array();
     foreach (FlowType::model()->fetchAllFlow() as $flow) {
         if (!WfNewUtil::checkProcessPermission($flow["flowid"], 0, $uid)) {
             continue;
         }
         if ($filterUseStatus && $flow["usestatus"] == 3) {
             continue;
         }
         $data = array("id" => $flow["flowid"], "text" => $flow["name"]);
         if (!isset($temp[$flow["catid"]])) {
             $temp[$flow["catid"]]["text"] = $flow["catname"];
             $temp[$flow["catid"]]["children"] = array();
         }
         $temp[$flow["catid"]]["children"][] = $data;
     }
     $result = array_merge(array(), $temp);
     return $result;
 }