public function actionDel() { $id = intval(EnvUtil::getRequest("id")); if ($id && EnvUtil::submitCheck("formhash")) { $flowId = intval(EnvUtil::getRequest("flowid")); $status = FlowPermission::model()->deleteAllByAttributes(array("id" => $id, "flowid" => $flowId)); $this->ajaxReturn(array("isSuccess" => !!$status)); } }
public static function getMyFlowIDs($uid) { $flowIDs = $orgIDs = array(); $user = User::model()->fetchByUid($uid); $allDeptStr = Department::model()->queryDept($user["alldeptid"], true); $deptArr = DepartmentUtil::loadDepartment(); foreach ($deptArr as $id => $dept) { if ($dept["pid"] == 0) { $orgIDs[] = $id; } } $orgIDs = implode(",", $orgIDs); foreach (FlowPermission::model()->fetchAllByPer() as $val) { switch ($val["scope"]) { case "selfdeptall": case "selfdept": $deptid = FlowType::model()->fetchDeptIDByFlowID($val["flowid"]); if ($deptid !== 0 && $user["isadministrator"] != 1) { if ($val["scope"] == "selfdept") { $deptAccess = StringUtil::findIn($user["alldeptid"], $val["deptid"]); $userAccess = WfNewUtil::compareIds($user["uid"], $val["uid"], "u"); $posAccess = WfNewUtil::compareIds($user["allposid"], $val["positionid"], "p"); if ($deptAccess || $userAccess || $posAccess) { $flowIDs[] = $val["flowid"]; } } elseif (self::hasAccess($user, $val)) { $flowIDs[] = $val["flowid"]; } } else { $flowIDs[] = $val["flowid"]; } break; case "selforg": if (StringUtil::findIn($allDeptStr, $orgIDs)) { if (self::hasAccess($user, $val)) { $flowIDs[] = $val["flowid"]; } } break; case "alldept": if (self::hasAccess($user, $val)) { $flowIDs[] = $val["flowid"]; } break; default: if (StringUtil::findIn($allDeptStr, $val["scope"])) { if (self::hasAccess($user, $val)) { $flowIDs[] = $val["flowid"]; } } break; } } return $flowIDs; }
public static function checkProcessPermission($flowId, $processId, $uid) { $user = User::model()->fetchByUid(intval($uid)); $flow = new ICFlowType(intval($flowId), false); $criteria = array("select" => "processid,uid,deptid,positionid", "condition" => sprintf("processid > 0 AND flowid = %d%s", $flowId, $processId ? " AND processid = {$processId}" : "")); foreach (FlowProcess::model()->fetchAll($criteria) as $process) { $deptAccess = self::compareIds($user["alldeptid"], $process["deptid"], "d"); $userAccess = self::compareIds($uid, $process["uid"], "u"); $posAccess = self::compareIds($user["allposid"], $process["positionid"], "p"); if ($deptAccess || $userAccess || $posAccess) { return true; } } if (empty($processId)) { $hasPermission = FlowPermission::model()->fetchPermission($uid, $flowId); if ($hasPermission) { return true; } } if ($flow->isFree()) { if ($processId != 1) { return true; } else { $ids = $flow->newuser; if (!empty($ids)) { $deptAccess = self::compareMixedIds($user["alldeptid"], $ids, "d"); $userAccess = self::compareMixedIds($uid, $ids, "u"); $posAccess = self::compareMixedIds($user["allposid"], $ids, "p"); if ($deptAccess || $userAccess || $posAccess) { return true; } else { return false; } } } } unset($flow); return false; }
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); }
public function delFlow($flowIds) { $ids = is_array($flowIds) ? $flowIds : explode(",", $flowIds); $sqlCondition = sprintf("FIND_IN_SET(flowid,'%s')", implode(",", $ids)); $this->clearFlow($ids); $uid = Ibos::app()->user->uid; foreach ($ids as $id) { $flow = $this->fetchByPk($id); $content = Ibos::lang("Del flow", "workflow.default", array("{flowName}" => $flow["name"])); FlowManageLog::model()->log($id, $flow["name"], $uid, 3, $content); } $delFlow = $this->deleteByPk($ids); FlowProcess::model()->deleteAll($sqlCondition); FlowRule::model()->deleteAll($sqlCondition); FlowPermission::model()->deleteAll($sqlCondition); if ($delFlow) { return true; } else { return false; } }
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); }