Ejemplo n.º 1
0
 public function init()
 {
     $key = $this->getKey();
     $flow = new ICFlowType(intval($key["flowid"]), true);
     $this->_var = array_merge($key, array("lang" => Ibos::getLangSources(), "flow" => $flow, "key" => $this->makeKey($key), "flowName" => $flow->name, "freePreset" => $flow->freepreset, "runName" => FlowRun::model()->fetchNameByRunID($key["runid"])));
     parent::init();
 }
Ejemplo n.º 2
0
 public function actionRestore()
 {
     $id = EnvUtil::getRequest("id");
     $runID = StringUtil::filterStr(StringUtil::filterCleanHtml($id));
     FlowRun::model()->updateAll(array("delflag" => 0), sprintf("FIND_IN_SET(runid,'%s')", $runID));
     $this->ajaxReturn(array("isSuccess" => true));
 }
Ejemplo n.º 3
0
 public static function getRunPermission($runId, $uid, $processId = 0)
 {
     $user = User::model()->fetchByUid($uid);
     $per = array();
     $flowId = FlowRun::model()->fetchFlowIdByRunId($runId);
     if (!$flowId) {
         return "";
     }
     if ($user["isadministrator"]) {
         $per[] = 1;
     }
     if (FlowRunProcess::model()->getIsOp($uid, $runId, $processId)) {
         $per[] = 2;
     }
     $permissions = FlowPermission::model()->fetchPermission($uid, $flowId);
     if (in_array($permissions, array(0, 1, 2), true)) {
         $per[] = 3;
     } elseif ($permissions == 3) {
         $per[] = 5;
     }
     if (FlowRunProcess::model()->getIsAgent($uid, $runId, $processId)) {
         $per[] = 4;
     }
     return implode(",", $per);
 }
Ejemplo n.º 4
0
 public function actionRestore()
 {
     $verID = intval(EnvUtil::getRequest("verid"));
     $ver = FlowFormVersion::model()->fetchByPk($verID);
     $formID = $ver["formid"];
     foreach (FlowType::model()->fetchAllAssociatedFlowIDByFormID($formID) as $flowID) {
         $hasRun = FlowRun::model()->countAllByFlowId($flowID);
         if ($hasRun) {
             $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Formversion Still has run")));
         } else {
             continue;
         }
     }
     unset($ver["formid"]);
     unset($ver["id"]);
     unset($ver["time"]);
     unset($ver["mark"]);
     FlowFormType::model()->modify($formID, $ver);
     $form = new ICFlowForm($formID);
     $form->getParser()->parse(true);
     $this->ajaxReturn(array("isSuccess" => true));
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 protected function countRecycle()
 {
     return FlowRun::model()->countByAttributes(array("beginuser" => $this->uid, "delflag" => 1));
 }
Ejemplo n.º 7
0
 public static function getFlowSearch($flowId, $searchType, $uid, $toId = "")
 {
     $condition = array();
     $flowIds = WfQueryUtil::getMyFlowIDs($uid);
     $myRuns = FlowRun::model()->fetchAllMyRunID($uid, $flowId);
     if ($searchType == "all" && Ibos::app()->user->isadministrator != 1) {
         $condition[] = sprintf("(fr.runid IN (%s) OR FIND_IN_SET('%s',ft.flowid))", implode(",", $myRuns), implode(",", $flowIds));
     } elseif ($searchType == "1") {
         $beginUser = $uid;
     } elseif ($searchType == "2") {
         $condition[] = sprintf("fr.runid IN (%s)", implode(",", $myRuns));
     } else {
         if ($searchType == "3" && Ibos::app()->user->isadministrator != 1) {
             $condition[] = sprintf("(FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds));
         } elseif (Ibos::app()->user->isadministrator != 1) {
             EnvUtil::iExit(Ibos::lang("Parameters error", "error"));
         }
     }
     if (!empty($toId) && $searchType !== "1") {
         $beginUser = $toId;
     }
     if (isset($beginUser)) {
         $condition[] = "fr.beginuser = {$beginUser}";
     }
     return $condition;
 }
Ejemplo n.º 8
0
 protected function makeUserSelect($runId, $index, $process, $name, $flowId, $processId)
 {
     $lang = Ibos::getLangSource("workflow.default");
     $tablestr = "";
     if ($index) {
         $display = "none;";
     } else {
         $display = "";
     }
     if ($process["childflow"] != 0) {
         $flow = FlowType::model()->fetchByPk($process["childflow"]);
         if ($flow) {
             $type = $flow["type"];
         }
         if ($type == 2) {
             $process["prcs_id_next"] = "";
         }
         $subfp = FlowProcess::model()->fetchProcess($process["childflow"], 1);
         if ($subfp) {
             $prcsuser = WfHandleUtil::getPrcsUser($process["childflow"], $processId);
         } else {
             $prcsuser = "";
         }
         $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : "");
         if (empty($subfp["uid"]) && empty($subfp["deptid"]) && empty($subfp["positionid"])) {
             $nopriv = $lang["Not set step permissions"];
         }
         $tablestr = "            <div style='display:{$display};' id='user_select_{$index}'>\r\n                <div class=\"control-group first-group\">\r\n                    <label class=\"control-label\">{$lang["Host"]}</label>\r\n                    <div class=\"controls\">\r\n                        <strong>{$name} {$nopriv}</strong>\r\n                        <input type=\"hidden\" name=\"topflag{$index}\" value=\"0\">\r\n                        <input id=\"prcs_user_op{$index}\" name=\"prcs_user_op{$index}\" type=\"text\" />\r\n                    </div>\r\n                </div>\r\n                <div class=\"control-group\">\r\n                    <label class=\"control-label\">{$lang["Agent"]}</label>\r\n                    <div class=\"controls\">\r\n                        <input id=\"prcs_user{$index}\" name=\"prcs_user{$index}\" type=\"text\" />\r\n                    </div>\r\n                </div>\r\n            </div>\r\n            <script>\r\n\t\t\t\t\$(function(){\r\n\t\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n\t\t\t\t\t\$('#prcs_user_op{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user',\r\n\t\t\t\t\t\tmaximumSelectionSize:'1'\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\$('#prcs_user{$index}').userSelect({\r\n\t\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n\t\t\t\t\t\tdata:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\t\ttype:'user'\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t</script>";
     } else {
         if (empty($process["uid"]) && empty($process["deptid"]) && empty($process["positionid"])) {
             $nopriv = $lang["Not set step permissions"];
         }
         $prcsOpUser = $prcsUserAuto = "";
         $deptArr = DepartmentUtil::loadDepartment();
         if ($process["autotype"] == 1) {
             $uid = FlowRun::model()->fetchBeginUserByRunID($runId);
             $prcsuser = User::model()->fetchByUid($uid);
             if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $prcsuser["uid"]) || StringUtil::findIn($process["deptid"], $prcsuser["alldeptid"]) || StringUtil::findIn($process["positionid"], $prcsuser["allposid"])) {
                 $prcsOpUser = $prcsuser["uid"];
                 $prcsUserAuto = $prcsuser["uid"] . ",";
             }
         } elseif (in_array($process["autotype"], array(2, 4, 5, 6))) {
             if ($process["autobaseuser"] != 0) {
                 $baseUid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autobaseuser"]);
                 $baseuser = User::model()->fetchByUid($baseUid);
                 $autodept = $baseuser["deptid"];
             } else {
                 $autodept = Ibos::app()->user->deptid;
             }
             if (0 < intval($autodept)) {
                 if ($process["autotype"] == 2) {
                     $tmpdept = $autodept;
                 } else {
                     if ($process["autotype"] == 4 || $process["autotype"] == 6) {
                         $tmpdept = $deptArr[$autodept]["pid"] == 0 ? $autodept : $deptArr[$autodept]["pid"];
                     } elseif ($process["autotype"] == 5) {
                         $deptStr = Department::model()->queryDept($autodept, true);
                         $temp = explode(",", $deptStr);
                         $count = count($temp);
                         $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $autodept;
                         if ($deptArr[$dept]["pid"] != 0) {
                             $tmpdept = $deptArr[$dept]["deptid"];
                         } else {
                             $tmpdept = $autodept;
                         }
                     }
                 }
                 $manager = $deptArr[$tmpdept]["manager"];
                 if ($process["autotype"] == 4 || $process["autotype"] == 6) {
                     $leader = $deptArr[$autodept]["leader"];
                     $subleader = $deptArr[$autodept]["subleader"];
                     if ($leader != "0" && $process["autotype"] == 4) {
                         $manager = $leader;
                     }
                     if ($subleader != "0" && $process["autotype"] == 6) {
                         $manager = $subleader;
                     }
                 }
                 if (!empty($manager)) {
                     $muser = User::model()->fetchByUid($manager);
                     if (!empty($muser)) {
                         if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $muser["uid"]) || StringUtil::findIn($process["deptid"], $muser["alldeptid"]) || StringUtil::findIn($process["positionid"], $muser["allposid"])) {
                             $prcsUserAuto = $muser["uid"] . ",";
                         }
                         if ($prcsUserAuto != "") {
                             $prcsOpUser = strtok($prcsUserAuto, ",");
                         }
                     }
                 } else {
                     $userPerMax = "";
                     foreach (User::model()->fetchAllOtherManager($tmpdept) as $user) {
                         $user = User::model()->fetchByUid($user["uid"]);
                         $uid = $user["uid"];
                         $position = $user["allposid"];
                         if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $uid) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $position)) {
                             if ($userPerMax == "") {
                                 $prcsOpUser = $uid;
                                 $prcsUserAuto .= $uid . ",";
                                 $userPerMax = $position;
                             } elseif ($position == $userPerMax) {
                                 $prcsUserAuto .= $uid . ",";
                             }
                         }
                     }
                 }
             }
         } elseif ($process["autotype"] == 3) {
             $autouserop = User::model()->fetchByUid($process["autouserop"]);
             if (!empty($autouserop)) {
                 if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $autouserop["uid"]) || StringUtil::findIn($process["deptid"], $autouserop["alldeptid"]) || StringUtil::findIn($process["positionid"], $autouserop["allposid"])) {
                     $prcsOpUser = $autouserop["uid"];
                 }
             }
             if (!empty($process["autouser"])) {
                 foreach (User::model()->fetchAllByUids(explode(",", trim($process["autouser"], ","))) as $user) {
                     if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $user["uid"]) || StringUtil::findIn($process["deptid"], $user["alldeptid"]) || StringUtil::findIn($process["positionid"], $user["allposid"])) {
                         $prcsUserAuto .= $user["uid"] . ",";
                     }
                 }
             }
         } elseif ($process["autotype"] == 7) {
             if (is_numeric($process["autouser"])) {
                 $itemData = FlowDataN::model()->fetchItem($process["autouser"], $process["flowid"], $runId);
                 $tmp = strtok($itemData, ",");
                 $userarr = array();
                 while ($tmp) {
                     $userarr[$tmp] = array();
                     $tmp = strtok(",");
                 }
                 $tempArray = explode(",", trim($itemData, ","));
                 foreach ($tempArray as $key => $value) {
                     if (is_numeric($value)) {
                         $value = User::model()->fetchRealnameByUid($value, "");
                         $tempArray[$key] = $value;
                     }
                 }
                 foreach (User::model()->fetchAllByRealnames($tempArray) as $k => $v) {
                     $dept = Department::model()->queryDept($v["alldeptid"]);
                     if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $dept) || StringUtil::findIn($process["positionid"], $v["allposid"])) {
                         $prcsUserAuto .= $v["uid"] . ",";
                     }
                 }
                 if ($prcsUserAuto != "") {
                     $prcsOpUser = strtok($prcsUserAuto, ",");
                 }
             }
         } else {
             if ($process["autotype"] == 8 && is_numeric($process["autouser"])) {
                 $uid = FlowRunProcess::model()->fetchBaseUid($runId, $process["autouser"]);
                 if ($uid) {
                     $temp = User::model()->fetchByUid($uid);
                     if ($temp) {
                         if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $temp["uid"]) || StringUtil::findIn($process["deptid"], $temp["alldeptid"]) || StringUtil::findIn($process["positionid"], $temp["allposid"])) {
                             $prcsOpUser = $prcsUserAuto = $temp["uid"];
                             $prcsUserAuto .= ",";
                         }
                     }
                 }
             } elseif ($process["autotype"] == 9) {
                 $main = Ibos::app()->user->deptid;
                 foreach (User::model()->fetchAllFitDeptUser($main) as $k => $v) {
                     if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) {
                         $prcsUserAuto .= $v["uid"] . ",";
                     }
                 }
                 if (!empty($prcsUserAuto)) {
                     $prcsOpUser = strtok($prcsUserAuto, ",");
                 }
             } elseif ($process["autotype"] == 10) {
                 $main = Ibos::app()->user->deptid;
                 $deptStr = Department::model()->queryDept($main, true);
                 $temp = explode(",", $deptStr);
                 $count = count($temp);
                 $dept = isset($temp[$count - 2]) ? $temp[$count - 2] : $main;
                 if ($deptArr[$dept]["pid"] != 0) {
                     $tmpdept = $deptArr[$dept]["deptid"];
                 } else {
                     $tmpdept = $main;
                 }
                 foreach (User::model()->fetchAllFitDeptUser($tmpdept) as $k => $v) {
                     if ($process["deptid"] == "alldept" || StringUtil::findIn($process["uid"], $v["uid"]) || StringUtil::findIn($process["deptid"], $v["alldeptid"]) || StringUtil::findIn($process["positionid"], $v["allposid"])) {
                         $prcsUserAuto .= $v["uid"] . ",";
                     }
                 }
                 if (!empty($prcsUserAuto)) {
                     $prcsOpUser = strtok($prcsUserAuto, ",");
                 }
             } else {
                 if ($process["uid"] != "" && $process["deptid"] == "" && $process["positionid"] == "") {
                     $prcsUserArr = explode(",", $process["uid"]);
                     $prcsUserCount = count($prcsUserArr) - 1;
                     if ($prcsUserCount == 1) {
                         $prcsUserAuto = $process["uid"];
                         $prcsOpUser = $prcsUserAuto;
                     }
                 }
             }
         }
         $prcsuser = WfHandleUtil::getPrcsUser($flowId, $process["processid"]);
         $prcsuser = sprintf("[%s]", !empty($prcsuser) ? StringUtil::iImplode($prcsuser) : "");
         if ($process["userlock"] != 1) {
             $attr = 'islock="1"';
         } else {
             $attr = '';
         }
         if (!empty($prcsOpUser)) {
             $prcsOpUser = StringUtil::wrapId($prcsOpUser);
         }
         if (!empty($prcsUserAuto)) {
             $prcsUserAuto = StringUtil::wrapId(StringUtil::filterStr($prcsUserAuto));
         }
         $tablestr = "        <div class=\"control-group\" style=\"display:{$display};\" id='user_select_{$index}'>\r\n            <div class=\"control-group first-group\">\r\n                <label class=\"control-label\">{$lang["Host"]}</label>\r\n                <div class=\"controls\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"topflag{$index}\" value=\"{$process["topdefault"]}\">\r\n\t\t\t\t\t<input id=\"prcs_user_op{$index}\" {$attr} name=\"prcs_user_op{$index}\"  value=\"{$prcsOpUser}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n            </div>\r\n            <div class=\"control-group\">\r\n                <label class=\"control-label\">{$lang["Agent"]}</label>\r\n                <div class=\"controls\">\r\n\t\t\t\t\t<input id=\"prcs_user{$index}\" {$attr} name=\"prcs_user{$index}\" value=\"{$prcsUserAuto}\" type=\"text\" />\r\n\t\t\t\t</div>\r\n            </div>\r\n        </div>\r\n        <script>\r\n            \$(function(){\r\n\t\t\t\tvar prcsData{$index} = {$prcsuser};\r\n                var puo = \$('#prcs_user_op{$index}');\r\n                var pu = \$('#prcs_user{$index}');\r\n\t\t\t\tvar topdef = '{$process["topdefault"]}';\r\n                puo.userSelect({\r\n                    box:\$('<div id=\"prcs_user_op_box{$index}\"></div>').appendTo(document.body),\r\n                    data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user',\r\n                    maximumSelectionSize:'1'\r\n                });\r\n                if(puo.attr('islock')==1 || topdef != 0){\r\n                    puo.userSelect('setReadOnly');\r\n                }     \r\n                pu.userSelect({\r\n\t\t\t\t\tbox:\$('<div id=\"prcs_user_box{$index}\"></div>').appendTo(document.body),\r\n                    data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user'\r\n                });\r\n                if(pu.attr('islock')==1){\r\n                    pu.userSelect('setReadOnly');\r\n                }\r\n            });\r\n        </script>";
     }
     return $tablestr;
 }
Ejemplo n.º 9
0
 public function actionTrans()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $data =& $_POST;
         $conArr = array("begin" => !empty($data["begin"]) ? strtotime($data["begin"]) : "", "end" => !empty($data["end"]) ? strtotime($data["end"]) : "", "runbegin" => !empty($data["runbegin"]) ? intval($data["runbegin"]) : "", "runend" => !empty($data["runend"]) ? intval($data["runend"]) : "");
         $flowStr = StringUtil::filterStr($data["flowid"]);
         $uid = implode(",", StringUtil::getId($data["uid"]));
         $toid = implode(",", StringUtil::getId($data["toid"]));
         $fitRunIds = FlowRun::model()->fetchAllRunIdByFlowIdFeatCondition($flowStr, $conArr);
         if (!empty($fitRunIds)) {
             FlowRunProcess::model()->updateTransRun($uid, $toid, $fitRunIds);
         }
         $this->ajaxReturn(array("isSuccess" => true));
     } else {
         $data = array("flows" => FlowType::model()->fetchAllOnOptlist($this->uid), "lang" => Ibos::getLangSources());
         $this->renderPartial("trans", $data);
     }
 }
Ejemplo n.º 10
0
 public function clearFlow($flowIds)
 {
     $ids = is_array($flowIds) ? $flowIds : explode(",", $flowIds);
     $count = 0;
     foreach ($ids as $id) {
         $flow = $this->fetchByPk($id);
         if (!empty($flow)) {
             $runs = FlowRun::model()->fetchAllByFlowId($id);
             if (!empty($runs)) {
                 $runIds = ConvertUtil::getSubByKey($runs, "runid");
                 WfHandleUtil::destroy($runIds);
                 $table = sprintf("{{flow_data_%d}}", $id);
                 if (WfCommonUtil::tableExists($table)) {
                     Ibos::app()->db->createCommand()->dropTable($table);
                 }
                 FlowRun::model()->deleteAllByAttributes(array("flowid" => $id));
                 $content = Ibos::lang("Clear flow", "workflow.default", array("{flowName}" => $flow["name"]));
                 FlowManageLog::model()->log($id, $flow["name"], Ibos::app()->user->uid, 3, $content);
                 $count++;
             }
         }
     }
     return $count;
 }
Ejemplo n.º 11
0
 protected function checkRunDel()
 {
     $isDel = FlowRun::model()->countByAttributes(array("delflag" => 1, "runid" => $this->runid));
     if ($isDel) {
         $this->error(Ibos::lang("Form run has been deleted"), $this->createUrl("list/index"));
     }
 }
Ejemplo n.º 12
0
 public function actionFlow()
 {
     $key = EnvUtil::getRequest("key");
     if ($key) {
         $param = WfCommonUtil::param($key, "DECODE");
     }
     $runId = intval($param["runid"]);
     $flowId = intval($param["flowid"]);
     $this->checkRunAccess($runId);
     $run = FlowRun::model()->fetchByPk($runId);
     $remindUid = array();
     $sidebar = WfPreviewUtil::getViewFlowData($runId, $flowId, $this->uid, $remindUid);
     $data = array("fl" => $sidebar, "remindUid" => $remindUid, "run" => $run, "key" => $key, "flowID" => $flowId);
     $this->render("flow", $data);
 }
Ejemplo n.º 13
0
 protected function setRun($runId)
 {
     $attr = FlowRun::model()->fetchByPk(intval($runId));
     $this->setAttributes($attr);
 }
Ejemplo n.º 14
0
 public function restoreDelay($runId, $processId, $flowProcess, $uid = "")
 {
     $set = array("flag" => 2, "activetime" => 0);
     $result = $this->updateAll($set, sprintf("runid = %d AND processid = %d AND flowprocess = %d", $runId, $processId, $flowProcess));
     if (!empty($uid)) {
         $runName = FlowRun::model()->fetchNameByRunID($runId);
         Notify::model()->sendNotify($uid, "workflow_restore_delay_notice", array("{runname}" => $runName));
     }
     return $result;
 }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
0
 protected function checkRunDel($runId)
 {
     $isDel = FlowRun::model()->countByAttributes(array("delflag" => 1, "runid" => $runId));
     if ($isDel) {
         exit(Ibos::lang("Run instance has been deleted"));
     }
 }
Ejemplo n.º 17
0
 protected function getListData()
 {
     $param = $this->getListFilterParam();
     $field = "fr.runid,fr.name as runName,fr.begintime,fr.endtime,ft.name as typeName,fr.attachmentid,fr.focususer,fr.beginuser,ft.flowid,ft.type,ft.freeother";
     $condition = array("and", "fr.delflag = 0");
     if ($param["flowid"]) {
         $condition[] = "ft.flowid = " . $param["flowid"];
         $isManager = FlowPermission::model()->fetchPermission($this->uid, $param["flowid"], array(0, 1));
     } else {
         $isManager = false;
     }
     if ($param["start"]) {
         $condition[] = "fr.begintime >= " . $param["start"];
     }
     if ($param["end"]) {
         $condition[] = "fr.endtime <= " . $param["end"];
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     $myRuns = FlowRun::model()->fetchAllMyRunID($this->uid, $param["flowid"]);
     if ($param["scope"] == "none" && Ibos::app()->user->isadministrator != 1) {
         $condition[] = sprintf("(FIND_IN_SET(fr.runid,'%s') OR FIND_IN_SET(ft.flowid,'%s'))", implode(",", $myRuns), implode(",", $flowIds));
     } elseif ($param["scope"] == "start") {
         $beginUser = $this->uid;
     } elseif ($param["scope"] == "handle") {
         $condition[] = array("in", "fr.runid", $myRuns);
     } else {
         if ($param["scope"] == "manage" && Ibos::app()->user->isadministrator != 1) {
             $condition[] = sprintf("FIND_IN_SET('%s',ft.flowid)", implode(",", $flowIds));
         } elseif ($param["scope"] == "focus") {
             $implodeStr = WfCommonUtil::implodeSql($this->uid, "fr.focususer");
             $condition[] = sprintf("fr.focususer = %d%s", $this->uid, $implodeStr);
         } elseif ($param["scope"] == "custom") {
             if (Ibos::app()->user->isadministrator != 1) {
                 $condition[] = sprintf("FIND_IN_SET(ft.flowid,'%s')", implode(",", $flowIds));
             }
             $beginUser = implode(",", StringUtil::getId($param["beginuser"]));
         } elseif (Ibos::app()->user->isadministrator != 1) {
             $this->error(Ibos::lang("Parameters error", "error"));
         }
     }
     if ($param["type"] !== "all") {
         if ($param["type"] == "perform") {
             $condition[] = "fr.endtime = 0";
         } else {
             $condition[] = "fr.endtime != 0";
         }
     }
     if (isset($beginUser)) {
         $condition[] = "fr.beginuser = "******"count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->queryScalar();
     $pages = PageUtil::create($count, $this->getListPageSize());
     $list = Ibos::app()->db->createCommand()->select($field)->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order("fr.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as &$rec) {
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["beginuser"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"]));
         $rec["begin"] = ConvertUtil::formatDate($rec["begintime"], "n月j日 H:i");
     }
     return array("list" => $list, "pages" => $pages, "advanceOpt" => $isManager || Ibos::app()->user->isadministrator == 1);
 }