Пример #1
0
 public static function hasView($feedid, $uid)
 {
     $feed = Feed::model()->get($feedid);
     $feedUser = User::model()->fetchByUid($feed["uid"]);
     $user = User::model()->fetchByUid($uid);
     if ($feed && $feed["view"] !== WbConst::SELF_VIEW_SCOPE) {
         $fuDeptIds = StringUtil::filterStr($feedUser["alldeptid"] . "," . $feedUser["alldowndeptid"]);
         $deptIds = StringUtil::filterStr($user["alldeptid"] . "," . $user["allupdeptid"]);
         if ($feed["view"] == WbConst::ALL_VIEW_SCOPE) {
             return true;
         } elseif ($feed["view"] == WbConst::SELFDEPT_VIEW_SCOPE) {
             if (StringUtil::findIn($fuDeptIds, $deptIds)) {
                 return true;
             }
         } else {
             if (StringUtil::findIn($feed["userid"], $uid)) {
                 return true;
             }
             if (StringUtil::findIn($feed["positionid"], $user["allposid"])) {
                 return true;
             }
             if (StringUtil::findIn($fuDeptIds, $deptIds)) {
                 return true;
             }
         }
     }
     return false;
 }
Пример #2
0
 public function actionIndex()
 {
     $type = EnvUtil::getRequest("type");
     $catid = EnvUtil::getRequest("catid");
     $childCatIds = "";
     if (!empty($catid)) {
         if ($catid == "-1") {
             $type = "nosign";
         } elseif ($catid == "-2") {
             $type = "sign";
         } else {
             $childCatIds = OfficialdocCategory::model()->fetchCatidByPid($catid, true);
         }
     }
     if (EnvUtil::getRequest("search")) {
         $this->search();
     }
     $uid = Ibos::app()->user->uid;
     $docIdArr = OfficialdocReader::model()->fetchDocidsByUid($uid);
     $this->_condition = OfficialdocUtil::joinListCondition($type, $docIdArr, $childCatIds, $this->_condition);
     $datas = Officialdoc::model()->fetchAllAndPage($this->_condition);
     if (isset($datas["datas"])) {
         foreach ($datas["datas"] as $k => $v) {
             $datas["datas"][$k]["content"] = mb_substr(strip_tags($v["content"]), 0, 15, 'utf-8');
         }
     }
     $officialDocList = ICOfficialdoc::getListDatas($datas["datas"]);
     $dashboardConfig = Yii::app()->setting->get("setting/docconfig");
     $params = array("pages" => $datas["pages"], "datas" => $officialDocList, "isApprover" => StringUtil::findIn($uid, $dashboardConfig["docapprover"]));
     $this->ajaxReturn($params, "JSONP");
 }
Пример #3
0
 private function loadTodo($num = 4)
 {
     $uid = Ibos::app()->user->uid;
     $fields = array("frp.runid", "frp.processid", "frp.flowprocess", "ft.type", "frp.flag", "ft.flowid", "fr.name as runName", "fr.beginuser", "fr.focususer");
     $condition = array("and", "fr.delflag = 0", "frp.childrun = 0", sprintf("frp.uid = %d", $uid));
     $condition[] = array("in", "frp.flag", array(1, 2));
     $sort = "frp.createtime DESC";
     $group = "frp.id";
     $runProcess = Ibos::app()->db->createCommand()->select($fields)->from("{{flow_run_process}} frp")->leftJoin("{{flow_run}} fr", "frp.runid = fr.runid")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->where($condition)->order($sort)->group($group)->offset(0)->limit($num)->queryAll();
     $allProcess = FlowProcess::model()->fetchAllProcessSortByFlowId();
     foreach ($runProcess as &$run) {
         $run["user"] = User::model()->fetchByUid($run["beginuser"]);
         if ($run["type"] == 1) {
             if (isset($allProcess[$run["flowid"]][$run["flowprocess"]]["name"])) {
                 $run["stepname"] = $allProcess[$run["flowid"]][$run["flowprocess"]]["name"];
             } else {
                 $run["stepname"] = Ibos::lang("Process steps already deleted", "workflow.default");
             }
         } else {
             $run["stepname"] = Ibos::lang("Step", "", array("{step}" => $run["processid"]));
         }
         $run["focus"] = StringUtil::findIn($uid, $run["focususer"]);
         $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
         $run["key"] = WfCommonUtil::param($param);
     }
     return $runProcess;
 }
Пример #4
0
 public function fetchPermission($uid, $flowId, $type = array(0, 1, 2, 3))
 {
     $user = User::model()->fetchByUid($uid);
     $condition = sprintf("FIND_IN_SET(type,'%s') AND flowid = %d", implode(",", $type), $flowId);
     $per = false;
     $result = Ibos::app()->db->createCommand()->select("*")->from($this->tableName())->where($condition)->queryAll();
     foreach ($result as $rs) {
         if ($rs["deptid"] == "alldept" || StringUtil::findIn($user["uid"], $rs["uid"]) || StringUtil::findIn($user["alldeptid"], $rs["deptid"]) || StringUtil::findIn($user["allposid"], $rs["positionid"])) {
             $per = $rs["type"];
         }
     }
     return $per !== false ? intval($per) : false;
 }
Пример #5
0
 public static function getAllItemName($structure, $exceptType = array(), $exceptTitle = "")
 {
     $temp = array();
     foreach ($structure as $config) {
         if (!in_array($config["data-type"], $exceptType) && $config["data-type"] !== "label") {
             $temp[] = $config["data-title"];
         }
     }
     if (!StringUtil::findIn($exceptTitle, "[A@]")) {
         $temp[] = "[A@]";
     }
     if (!StringUtil::findIn($exceptTitle, "[B@]")) {
         $temp[] = "[B@]";
     }
     $allItemName = str_replace(array("+", "#"), array("+", "#"), $temp);
     return $allItemName;
 }
Пример #6
0
 public function checkProcessCirculatingByFlowId($flowId)
 {
     $processInfo = $errorInfo = array();
     $tempId = $errorStr = "";
     $maxProcessId = 0;
     $criteria = array("select" => "processid,name,processto", "condition" => "flowid = " . intval($flowId), "order" => "processid");
     $steps = $this->fetchAll($criteria);
     foreach ($steps as $step) {
         $temp = array();
         $temp["id"] = $step["processid"];
         $temp["name"] = $step["name"];
         $temp["to"] = $step["processto"];
         if ($maxProcessId < $step["processid"]) {
             $maxProcessId = $step["processid"];
         }
         array_push($processInfo, $temp);
         $tempId .= $step["processid"] . ",";
     }
     foreach ($processInfo as $process) {
         $id = $process["id"];
         $name = $process["name"];
         $to = $process["to"];
         if (empty($to)) {
             if ($maxProcessId !== $id) {
                 $nextId = $id + 1;
                 if (StringUtil::findIn($tempId, $nextId)) {
                     continue;
                 }
                 $errorStr .= "{$nextId}";
             }
         } else {
             $processArr = explode(",", $to);
             foreach ($processArr as $toStep) {
                 if (!StringUtil::findIn($tempId, $toStep)) {
                     $errorStr .= $toStep . ",";
                 }
             }
         }
         $errorInfo[$id]["name"] = $name;
         $errorInfo[$id]["error"] = trim($errorStr, ",");
         $errorStr = "";
     }
     return $errorInfo;
 }
Пример #7
0
 public static function getFixedPrcs($flowId, $runId)
 {
     $return = $temp = array();
     foreach (FlowRunProcess::model()->fetchAllByRunID($runId) as $rp) {
         $fp = $rp["flowprocess"];
         $temp[$fp]["flag"] = $rp["flag"];
         if ($rp["childrun"] !== "0") {
             $temp[$fp]["flag"] = "7";
         }
     }
     $process = WfCommonUtil::loadProcessCache($flowId);
     arsort($process);
     $isEnd = false;
     foreach ($process as $processId => $val) {
         if (isset($temp[$processId])) {
             $val = $val + $temp[$processId];
             $val["type"] = self::$typeMapping[$val["flag"]];
             if (StringUtil::findIn($val["processto"], 0)) {
                 if ($val["type"] == "finish") {
                     $isEnd = true;
                 }
             }
         } else {
             $val["flag"] = 1;
             $val["childrun"] = 0;
             $val["type"] = "inactive";
             if ($processId == 0 && $isEnd) {
                 $val["type"] = "finish";
             }
         }
         $val["to"] = $val["processto"];
         $val["left"] = intval($val["setleft"]);
         $val["top"] = intval($val["settop"]);
         $val["processid"] = intval($val["processid"]);
         $return[] = $val;
     }
     return $return;
 }
Пример #8
0
 private function setOtherInfo(&$run)
 {
     if ($this->type !== "done") {
         $run["focus"] = StringUtil::findIn($this->uid, $run["focususer"]);
     } elseif (!empty($run["endtime"])) {
         $usedTime = $run["endtime"] - $run["begintime"];
         $run["usedtime"] = WfCommonUtil::getTime($usedTime);
     }
     $param = array("runid" => $run["runid"], "flowid" => $run["flowid"], "processid" => $run["processid"], "flowprocess" => $run["flowprocess"]);
     $run["key"] = WfCommonUtil::param($param);
 }
Пример #9
0
 protected function isEnabledInFreeItem(ICFlowType $flow, ICFlowRunProcess $rp)
 {
     return $flow->isFree() && $rp->freeitem == "" || StringUtil::findIn($rp->freeitem, "[A@]");
 }
Пример #10
0
 public static function checkShowPurview($uid, $author)
 {
     $flag = false;
     if ($uid == $author) {
         return true;
     }
     $subUidArr = UserUtil::getAllSubs($uid, "", true);
     if (StringUtil::findIn($author, implode(",", $subUidArr))) {
         $flag = true;
     }
     return $flag;
 }
Пример #11
0
 public static function compareIds($userIds, $flowIds, $type)
 {
     $access = false;
     if ($type == "u" || $type == "p") {
         $access = StringUtil::findIn($userIds, $flowIds);
     } elseif ($type == "d") {
         static $parentDeptId = "";
         if ($flowIds == "alldept") {
             return true;
         }
         if (empty($parentDeptId)) {
             $parentDeptId = Department::model()->queryDept($userIds);
         }
         $access = StringUtil::findIn($userIds, $flowIds) || StringUtil::findIn($parentDeptId, $flowIds);
     }
     return $access;
 }
Пример #12
0
 public static function getExportData($list, $param)
 {
     $lang = Ibos::getLangSources(array("workflow.default"));
     $data = $titles = $sum = array();
     $group = "";
     $flow = new ICFlowType($param["flowid"]);
     $structure = $flow->form->parser->structure;
     foreach ($list as $index => $row) {
         if (!empty($param["condition"])) {
             $formData = WfHandleUtil::getFormData($row["flowid"], $row["runid"]);
             $notPass = WfHandleUtil::checkCondition($formData, $param["condition"], "");
             if ($notPass !== "") {
                 continue;
             }
         }
         $queryHidden = Ibos::app()->db->createCommand()->select("hiddenitem")->from("{{flow_process}} fp")->leftJoin("{{flow_run_process}} frp", "fp.processid = frp.flowprocess")->where(sprintf("fp.flowid = %d AND frp.runid = %d AND frp.uid = %d", $param["flowid"], $row["runid"], $param["uid"]))->queryAll();
         $hidden = ConvertUtil::getSubByKey($queryHidden, "hiddenitem");
         $itemData = FlowDataN::model()->fetch($param["flowid"], $row["runid"]);
         $processor = new ICPrintViewProcessor(array("itemData" => $itemData));
         foreach (explode(",", $param["viewextfields"]) as $key => $field) {
             if (strpos($field, ".") !== false) {
                 list(, $itemID) = explode(".", $field);
                 $item = isset($structure[$itemID]) ? $structure[$itemID] : array();
                 if (empty($item)) {
                     continue;
                 }
                 if ($item["data-type"] == "sign" || $item["data-type"] == "label") {
                     continue;
                 }
                 if (in_array($item["data-title"], $hidden)) {
                     $value = "";
                 } else {
                     $itemValue = $itemData[$itemID];
                     switch ($item["data-type"]) {
                         case "checkbox":
                             if ($itemValue == "on") {
                                 $value = $lang["Yes"];
                             } else {
                                 $value = $lang["No"];
                             }
                             break;
                         case "user":
                         case "auto":
                             $method = $item["data-type"] . "Processor";
                             if (method_exists($processor, $method)) {
                                 $value = $processor->{$method}($item, true);
                             }
                             break;
                         case "listview":
                             $sumflag = 0;
                             $lv_subject = $item["data-lv-title"];
                             $lv_sum = $item["data-lv-sum"];
                             $lv_sum_array = explode("`", $lv_sum);
                             if (strstr($lv_sum, "1")) {
                                 $sumflag = 1;
                             }
                             $lv_value = $itemValue;
                             $item_value = "<table class='commonTable2' ><tr>\n";
                             $my_array = explode("`", $lv_subject);
                             $array_count_title = sizeof($my_array);
                             if ($my_array[$array_count_title - 1] == "") {
                                 $array_count_title--;
                             }
                             for ($i = 0; $i < $array_count_title; $i++) {
                                 $item_value .= "<td>" . $my_array[$i] . "</td>\n";
                             }
                             $item_value .= "</tr>\n";
                             $my_array = explode("\r\n", $lv_value);
                             $array_count = sizeof($my_array);
                             if ($my_array[$array_count - 1] == "") {
                                 $array_count--;
                             }
                             $sum_data = array();
                             for ($i = 0; $i < $array_count; $i++) {
                                 $item_value .= "<tr>\n";
                                 $tr_data = $my_array[$i];
                                 $my_array1 = explode("`", $tr_data);
                                 for ($j = 0; $j < $array_count_title; $j++) {
                                     if ($lv_sum_array[$j] == 1) {
                                         $sum_data[$j] += $my_array1[$j];
                                     }
                                     $td_data = $my_array1[$j];
                                     if ($td_data == "") {
                                         $td_data = "&nbsp;";
                                     }
                                     $item_value .= "<td>" . $td_data . "</td>\n";
                                 }
                                 $item_value .= "</tr>\n";
                             }
                             if ($sumflag == 1 && 0 < $array_count) {
                                 $item_value .= "<tr style='font-weight:bold;'>\n";
                                 for ($j = 0; $j < $array_count_title; $j++) {
                                     if ($sum_data[$j] == "") {
                                         $sumvalue = "&nbsp;";
                                     } else {
                                         $sumvalue = "合计:" . $sum_data[$j];
                                     }
                                     $item_value .= "<td align=right>" . $sumvalue . "</td>\n";
                                 }
                                 $item_value .= "</tr>\n";
                             }
                             $item_value .= "</table>\n";
                             break;
                         default:
                             $value = isset($itemData[$itemID]) ? $itemData[$itemID] : "";
                             break;
                     }
                 }
                 $title = $item["data-title"];
             } else {
                 switch ($field) {
                     case "runid":
                         $value = $row["runid"];
                         $title = $lang["Flow no"];
                         break;
                     case "runname":
                         $value = $row["runName"];
                         $title = $lang["Flow subject/num"];
                         break;
                     case "runstatus":
                         if ($param["flowconditions"]["flowstatus"] == "all") {
                             if ($row["endtime"] == 0) {
                                 $status = "<span class=\"red\">{$lang["Perform"]}</span>";
                             } else {
                                 $status = $lang["Has ended"];
                             }
                         } elseif ($param["flowconditions"]["flowstatus"] == "0") {
                             $status = "<span class=\"red\">{$lang["Perform"]}</span>";
                         } else {
                             $status = $lang["Has ended"];
                         }
                         $value = $status;
                         $title = $lang["Flow status"];
                         break;
                     case "rundate":
                         $value = date("Y-m-d", $row["begintime"]);
                         $title = $lang["Flow begin date"];
                         break;
                     case "runtime":
                         $value = ConvertUtil::formatDate($row["begintime"]);
                         $title = $lang["Flow begin time"];
                         break;
                     default:
                         break;
                 }
             }
             if (StringUtil::findIn($param["sumfields"], $field)) {
                 $sum[] = $key;
             }
             $data[$index][$key] = $value;
             if ($index == 0) {
                 if (strcmp($param["groupbyfields"]["field"], $field) == 0) {
                     $group = $key;
                 }
                 $titles[$key] = $title;
             }
         }
     }
     return array("title" => $titles, "data" => $data, "sum" => $sum, "group" => $group, "sum_data" => isset($sum_data) ? $sum_data : array());
 }
Пример #13
0
 public function actionShow()
 {
     $id = is_null($_GET["id"]) ? 0 : intval($_GET["id"]);
     if ($id) {
         $data = array();
         $email = Email::model()->fetchById($id, $this->archiveId);
         if (!$email) {
             $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("list/index"));
         }
         $isReceiver = $email["toid"] == $this->uid || $email["fromid"] == $this->uid || StringUtil::findIn($email["copytoids"], $this->uid) || StringUtil::findIn($email["toids"], $this->uid);
         if (!$isReceiver) {
             $this->error(Ibos::lang("View access invalid"), $this->createUrl("list/index"));
         }
         if (EnvUtil::getRequest("op") == "showframe") {
             echo $email["content"];
             exit;
         }
         if (($email["toid"] == $this->uid || StringUtil::findIn($email["toids"], $this->uid)) && $email["isread"] == 0) {
             Email::model()->setRead($id, $this->uid);
         }
         $email["dateTime"] = ConvertUtil::formatDate($email["sendtime"]);
         if ($this->uid == $email["fromid"]) {
             $email["fromName"] = Ibos::lang("Me");
         } elseif (!empty($email["fromid"])) {
             $email["fromName"] = User::model()->fetchRealnameByUid($email["fromid"]);
         } else {
             $email["fromName"] = $email["fromwebmail"];
         }
         $allIds = StringUtil::filterStr($email["toids"] . "," . $email["copytoids"]);
         $copyToId = explode(",", $email["copytoids"]);
         $toId = explode(",", $email["toids"]);
         $allUsers = $copyToUsers = $toUsers = array();
         foreach (explode(",", $allIds) as $key => $uid) {
             if (!empty($uid)) {
                 $tempUid = strpos($uid, "@");
                 if (!$tempUid) {
                     if ($this->uid == $uid) {
                         $name = Ibos::lang("Self");
                     } else {
                         $name = User::model()->fetchRealnameByUid($uid);
                     }
                 } else {
                     $name = $uid;
                 }
                 if (in_array($uid, $copyToId)) {
                     $copyToUsers[$key] = $allUsers[$key] = $name;
                 } elseif (in_array($uid, $toId)) {
                     $allUsers[$key] = $toUsers[$uid] = $name;
                 } else {
                     $allUsers[$key] = $name;
                 }
             }
         }
         if (!empty($email["towebmail"])) {
             $towebmails = explode(";", $email["towebmail"]);
             while (!empty($towebmails)) {
                 $toUsers[] = $allUsers[] = array_pop($towebmails);
             }
             $toUsers = array_unique($toUsers);
             $allUsers = array_unique($allUsers);
         }
         $data["allUsers"] = $allUsers;
         $data["toUsers"] = $toUsers;
         $data["copyToUsers"] = $copyToUsers;
         $data["isSecretUser"] = StringUtil::findIn($this->uid, $email["secrettoids"]);
         !empty($email["attachmentid"]) && ($data["attach"] = AttachUtil::getAttach($email["attachmentid"]));
         $data["next"] = Email::model()->fetchNext($id, $this->uid, $email["fid"], $this->archiveId);
         $data["prev"] = Email::model()->fetchPrev($id, $this->uid, $email["fid"], $this->archiveId);
         $data["email"] = $email;
         $data["weekDay"] = DateTimeUtil::getWeekDay($email["sendtime"]);
         $this->setPageTitle(Ibos::lang("Show email"));
         $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Personal Office")), array("name" => Ibos::lang("Email center"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Show email"))));
         $this->render("show", $data);
     } else {
         $this->error(Ibos::lang("Parameters error"), $this->createUrl("list/index"));
     }
 }
Пример #14
0
 public function autoProcessor($item, $readOnly)
 {
     $field = $item["data-field"];
     $width = isset($item["data-width"]) ? $item["data-width"] : "200";
     $autoValue = "";
     $value = $this->getValue($item);
     $hourTime = date("H:i:s", TIMESTAMP);
     $date = date("Y-m-d");
     $time = $date . " " . $hourTime;
     $isTextAuto = substr($field, 0, 8) !== "sys_list";
     $lang = Ibos::getLangSource("workflow.default");
     if ($isTextAuto) {
         switch ($field) {
             case "sys_date":
                 $autoValue = $date;
                 break;
             case "sys_date_cn":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short1":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"] . "m" . $lang["month"]);
                 break;
             case "sys_date_cn_short2":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "m" . $lang["Month"] . "d" . $lang["Chinese day"]);
                 break;
             case "sys_date_cn_short3":
                 $autoValue = ConvertUtil::formatDate(TIMESTAMP, "Y" . $lang["Year"]);
                 break;
             case "sys_date_cn_short4":
                 $autoValue = date("Y", TIMESTAMP);
                 break;
             case "sys_time":
                 $autoValue = $hourTime;
                 break;
             case "sys_datetime":
                 $autoValue = $time;
                 break;
             case "sys_week":
                 $autoValue = WfCommonUtil::getWeek();
                 break;
             case "sys_userid":
                 $autoValue = Ibos::app()->user->uid;
                 break;
             case "sys_realname":
                 $autoValue = Ibos::app()->user->realname;
                 break;
             case "sys_userpos":
                 $autoValue = Ibos::app()->user->posname;
                 break;
             case "sys_realname_date":
                 $autoValue = Ibos::app()->user->realname . " " . $date;
                 break;
             case "sys_realname_datetime":
                 $autoValue = Ibos::app()->user->realname . " " . $time;
                 break;
             case "sys_deptname":
                 $autoValue = Department::model()->fetchDeptNameByDeptId(Ibos::app()->user->alldeptid);
                 break;
             case "sys_deptname_short":
                 $autoValue = Ibos::app()->user->deptname;
                 break;
             case "sys_formname":
                 $autoValue = $this->form->formname;
                 break;
             case "sys_runname":
                 $autoValue = $this->inDebug ? "" : $this->run->name;
                 break;
             case "sys_rundate":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime, "d");
                 break;
             case "sys_rundatetime":
                 $autoValue = $this->inDebug ? "" : ConvertUtil::formatDate($this->run->begintime);
                 break;
             case "sys_runid":
                 $autoValue = $this->inDebug ? "" : $this->run->runid;
                 break;
             case "sys_autonum":
                 $autoValue = $this->inApp ? $this->flow->autonum : "";
                 break;
             case "sys_ip":
                 $autoValue = EnvUtil::getClientIp();
                 break;
             case "sys_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt, false);
                 break;
             case "sys_manager1":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $managerID = $deptCache[$main]["manager"];
                 if ($managerID != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($managerID);
                 }
                 break;
             case "sys_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     if ($deptCache[$upid]["manager"] != 0) {
                         $autoValue = User::model()->fetchRealnameByUid($deptCache[$upid]["manager"]);
                     }
                 }
                 break;
             case "sys_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 if ($deptCache[$dept]["manager"] != 0) {
                     $autoValue = User::model()->fetchRealnameByUid($deptCache[$dept]["manager"]);
                 }
                 break;
             default:
                 break;
         }
         if ($value == "" && !$readOnly || $this->flow->isFixed() && $readOnly && StringUtil::findIn($this->process->processitemauto, $item["data-title"]) && $this->rp->opflag) {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$autoValue}\" title=\"{$item["data-title"]}\" />";
         } else {
             $eleout = "\t\t\t\t<input type=\"text\" style=\"width:{$width} px;\" name=\"data_{$item["itemid"]}\" value=\"{$value}\" title=\"{$item["data-title"]}\" />";
         }
         $hidden = isset($item["data-hide"]) ? $item["data-hide"] : "0";
         if ($hidden == "1") {
             $eleout = str_ireplace("type=\"text\"", "type=\"hidden\"", $eleout);
         }
         if (!$readOnly) {
             if ($this->inApp && $this->flow->isFixed() && StringUtil::findIn($this->process->processitemauto, $item["data-title"])) {
                 $readOnly = true;
             } else {
                 $eleout = str_ireplace("<input", "<input data-orig-value=\"{$autoValue}\" data-focus=\"restore\"", $eleout);
             }
         }
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "input");
         }
     } else {
         $autoValue = "<option value=\"\"";
         if ($value == "") {
             $autoValue .= " selected";
         }
         $autoValue .= "></option>\n";
         switch ($field) {
             case "sys_list_dept":
                 $cache = DepartmentUtil::loadDepartment();
                 $str = StringUtil::getTree($cache, "<option value='\$deptid' \$selected>\$spacer\$deptname</option>", $value);
                 $autoValue .= $str;
                 break;
             case "sys_list_user":
                 foreach (UserUtil::loadUser() as $user) {
                     $selected = $value == $user["uid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $user["uid"] . "'>" . $user["realname"] . "</option>";
                 }
                 break;
             case "sys_list_pos":
                 foreach (PositionUtil::loadPosition() as $pos) {
                     $selected = $value == $pos["positionid"] ? "selected" : "";
                     $autoValue .= "<option {$selected} value='" . $pos["positionid"] . "'>" . $pos["posname"] . "</option>";
                 }
                 break;
             case "sys_list_prcsuser1":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, 0, $value);
                 break;
             case "sys_list_prcsuser2":
                 $autoValue .= $this->getProcessUserList($this->flow->flowid, $this->process->processid, $value, true);
                 break;
             case "sys_list_sql":
                 $sql = $item["data-src"];
                 $tempopt = array("uid" => Ibos::app()->user->uid, "deptid" => Ibos::app()->user->deptid, "positionid" => Ibos::app()->user->positionid, "runid" => $this->inDebug ? "" : $this->run->runid);
                 $autoValue = $this->execSysSql($sql, $tempopt);
                 $autoValue .= $this->arrayTolist($autoValue, $value);
                 break;
             case "sys_list_manager1":
                 $main = Ibos::app()->user->deptid;
                 $autoValue .= $this->getManagerList($main, $value);
                 break;
             case "sys_list_manager2":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $upid = $deptCache[$main]["upid"];
                 if ($upid != 0) {
                     $autoValue .= $this->getManagerList($main, $value);
                 }
                 break;
             case "sys_list_manager3":
                 $main = Ibos::app()->user->deptid;
                 $deptCache = DepartmentUtil::loadDepartment();
                 $dept_str = Department::model()->queryDept($main);
                 $temp = explode(",", $dept_str);
                 $count = count($temp);
                 $dept = $temp[$count - 2];
                 $autoValue .= $this->getManagerList($dept, $value);
                 break;
         }
         $eleout = "\t\t\t\t\t<select title=\"{$item["data-title"]}\" name=\"data_{$item["itemid"]}\">\r\n\t\t\t\t\t{$autoValue}\r\n\t\t\t\t\t</select>";
         if ($readOnly) {
             $this->setCommonReadOnly($item, $eleout, "select");
         }
     }
     return $eleout;
 }
Пример #15
0
 protected function parseMarcroAttach($runID, $attachmentID, $showImg = true)
 {
     $attachDir = Ibos::app()->setting->get("setting/attachdir");
     $attach = AttachmentN::model()->fetch("rid:" . $runID, $attachmentID);
     if ($attach["isimage"] && $showImg) {
         $imgAttr = FileUtil::imageSize($attachDir . $attach["attachment"]);
         $attachLink = "<img src=\"{$attachDir}" . $attach["attachment"] . "\" {$imgAttr['3']} alt=\"{$attach["filename"]}\">";
         return $attachLink;
     }
     if ($this->flow->isFixed() && (StringUtil::findIn($this->process->attachpriv, "4") || !$this->process->attachpriv)) {
         $down = 1;
     } else {
         $down = 0;
     }
     if ($down) {
         $attachstr = AttachUtil::getAttachStr($attachmentID);
         $url = Ibos::app()->urlManager->createUrl("main/attach/download", array("id" => $attachstr));
         $link = "<a target=\"_blank\" class=\"xi2\" href=\"{$url}\">{$attach["filename"]}</a>";
     } else {
         $link = "<a class=\"xi2\" href=\"#\">{$attach["filename"]}</a>";
     }
     $type = StringUtil::getFileExt($attach["attach"]);
     $path = AttachUtil::attachType($type);
     $attachLink = "<span><img src=\"{$path}\">{$link}</span>";
     return $attachLink;
 }
Пример #16
0
 protected function getListData()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $runid = intval(EnvUtil::getRequest("runid"));
         $flowid = intval(EnvUtil::getRequest("flowid"));
         $userType = EnvUtil::getRequest("usertype");
         $runName = StringUtil::filterCleanHtml(EnvUtil::getRequest("runname"));
         $toid = !empty($_POST["toid"]) ? implode(",", StringUtil::getId($_POST["toid"])) : "";
     } else {
         $runid = 0;
         $userType = $runName = $toid = "";
         $flowid = "all";
     }
     $flowIds = WfQueryUtil::getMyFlowIDs($this->uid);
     if (empty($flowIds)) {
         $flowIds = array(0);
     }
     $condition = array("and", "fr.delflag = 0", array("in", "fr.flowid", $flowIds), array("in", "frp.flag", array(1, 2)), "(frp.opflag = 1 OR frp.topflag = 2)");
     $field = "frp.runid,frp.processid,frp.uid,frp.flag,frp.processtime,frp.flowprocess,fr.attachmentid,fr.focususer,ft.freeother";
     if ($flowid !== "all") {
         $condition[] = "ft.flowid = " . $flowid;
     }
     if (!empty($runid)) {
         $condition[] = "fr.runid = " . $runid;
     }
     if (!empty($runName)) {
         $condition[] = " fr.name LIKE '%{$runName}%'";
     }
     if ($toid != "") {
         if ($userType == "opuser") {
             $condition[] = "frp.uid = {$toid}";
         } else {
             $condition[] = "fr.beginuser = {$toid}";
         }
     }
     $lang = Ibos::getLangSource("workflow.default");
     $count = Ibos::app()->db->createCommand()->select("count(fr.runid)")->from("{{flow_run}} fr")->leftJoin("{{flow_type}} ft", "fr.flowid = ft.flowid")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->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")->leftJoin("{{flow_run_process}} frp", "fr.runid = frp.runid")->where($condition)->group("frp.runid")->order("frp.runid DESC")->limit($pages->getLimit())->offset($pages->getOffset())->queryAll();
     foreach ($list as $k => &$rec) {
         $temp = Ibos::app()->db->createCommand()->select("ft.flowid,ft.freeother,fr.name as runName,ft.name as typeName,ft.type,ft.sort")->from("{{flow_type}} ft")->leftJoin("{{flow_run}} fr", "fr.flowid = ft.flowid")->where("fr.runid = " . $rec["runid"])->queryRow();
         if ($temp) {
             $rec = array_merge($rec, $temp);
         } else {
             continue;
         }
         if ($temp["type"] == 1) {
             $fp = FlowProcess::model()->fetchProcess($temp["flowid"], $rec["flowprocess"]);
             if ($fp) {
                 $rec["stepname"] = $fp["name"];
             } else {
                 $rec["stepname"] = $lang["Process steps already deleted"];
             }
         } else {
             $rec["stepname"] = Ibos::lang("Step", "", array("{step}" => $rec["processid"]));
         }
         if ($rec["flag"] == FlowConst::PRCS_UN_RECEIVE) {
             $deliverTime = FlowRunProcess::model()->fetchDeliverTime($rec["runid"], $rec["flowprocess"]);
             if ($deliverTime) {
                 $prcsBeginTime = $deliverTime;
             }
         } else {
             $prcsBeginTime = $rec["processtime"];
         }
         if (!isset($prcsBeginTime) || $prcsBeginTime == 0) {
             $prcsBeginTime = TIMESTAMP;
         }
         $usedTime = TIMESTAMP - $prcsBeginTime;
         $rec["timestr"] = WfCommonUtil::getTime($usedTime, "dhi");
         if (!empty($rec["attachmentid"])) {
             $rec["attachdata"] = AttachUtil::getAttachData($rec["attachmentid"]);
         }
         $rec["focus"] = StringUtil::findIn($this->uid, $rec["focususer"]);
         $rec["user"] = User::model()->fetchByUid($rec["uid"]);
         $rec["key"] = WfCommonUtil::param(array("flowid" => $rec["flowid"], "runid" => $rec["runid"], "processid" => $rec["processid"], "flowprocess" => $rec["flowprocess"]));
         if (empty($rec["user"])) {
             unset($list[$k]);
         }
     }
     return array("list" => $list, "pages" => $pages);
 }
Пример #17
0
 protected function nextAccessCheck($topflag, $runId, $processId)
 {
     $per = WfCommonUtil::getRunPermission($runId, $this->uid, $processId);
     if ($topflag != 2) {
         if (!StringUtil::findIn($per, 1) && !StringUtil::findIn($per, 2) && !StringUtil::findIn($per, 3)) {
             EnvUtil::iExit("必须是系统管理员,主办人,管理或监控人才能进行操作");
         }
     } elseif (!StringUtil::findIn($per, 4)) {
         EnvUtil::iExit("您不是经办人,没有权限进行操作。");
     }
 }
Пример #18
0
 public static function checkReadScope($uid, $data)
 {
     if ($data["deptid"] == "alldept") {
         return true;
     }
     if ($uid == $data["author"]) {
         return true;
     }
     if (empty($data["deptid"]) && empty($data["positionid"]) && empty($data["uid"])) {
         return true;
     }
     $user = User::model()->fetch(array("select" => array("deptid", "positionid"), "condition" => "uid=:uid", "params" => array(":uid" => $uid)));
     $childDeptid = Department::model()->fetchChildIdByDeptids($data["deptid"]);
     if (StringUtil::findIn($user["deptid"], $childDeptid . "," . $data["deptid"])) {
         return true;
     }
     $childCcDeptid = Department::model()->fetchChildIdByDeptids($data["ccdeptid"]);
     if (StringUtil::findIn($user["deptid"], $childCcDeptid . "," . $data["ccdeptid"])) {
         return true;
     }
     if (StringUtil::findIn($data["positionid"], $user["positionid"])) {
         return true;
     }
     if (StringUtil::findIn($data["uid"], $uid)) {
         return true;
     }
     if (StringUtil::findIn($data["ccpositionid"], $user["positionid"])) {
         return true;
     }
     if (StringUtil::findIn($data["ccuid"], $uid)) {
         return true;
     }
     return false;
 }
Пример #19
0
 public function actionRedo()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $key = EnvUtil::getRequest("key");
         if ($key) {
             $param = WfCommonUtil::param($key, "DECODE");
             $uid = intval(EnvUtil::getRequest("uid"));
             $per = WfCommonUtil::getRunPermission($param["runid"], $this->uid, $param["processid"]);
             if (!StringUtil::findIn($per, 2)) {
                 exit(Ibos::lang("Permission denied"));
             }
             if ($this->redo($param["runid"], $param["processid"], $uid, $param["flowprocess"])) {
                 $this->ajaxReturn(array("isSuccess" => true));
             } else {
                 $this->ajaxReturn(array("isSuccess" => false));
             }
         }
     }
 }
Пример #20
0
 public function actionManager()
 {
     $data = array();
     $type = EnvUtil::getRequest("type");
     $inSearch = false;
     if ($type == "search") {
         $inSearch = true;
         $condition = "1";
         $keyword = EnvUtil::getRequest("keyword");
         if (!empty($keyword)) {
             $keyword = StringUtil::filterCleanHtml($keyword);
             $condition .= " AND content LIKE '%{$keyword}%'";
         }
         $searchType = EnvUtil::getRequest("searchtype");
         if (!empty($searchType)) {
             $returnStatus = array();
             if (StringUtil::findIn($searchType, 1)) {
                 $returnStatus[] = 1;
             }
             if (StringUtil::findIn($searchType, 0)) {
                 $returnStatus[] = 0;
             }
             $condition .= sprintf(" AND return IN ('%s')", implode(",", $returnStatus));
         }
         $begin = EnvUtil::getRequest("begin");
         $end = EnvUtil::getRequest("end");
         if (!empty($begin) && !empty($end)) {
             $condition .= sprintf(" AND ctime BETWEEN %d AND %d", strtotime($begin), strtotime($end));
         } elseif (!empty($begin)) {
             $condition .= sprintf(" AND ctime > %d", strtotime($begin));
         } elseif (!empty($end)) {
             $condition .= sprintf(" AND ctime < %d", strtotime($end));
         }
         $sender = EnvUtil::getRequest("sender");
         if (!empty($sender)) {
             $realSender = implode(",", StringUtil::getId($sender));
             $condition .= sprintf(" AND uid = %d", intval($realSender));
         }
         $recNumber = EnvUtil::getRequest("recnumber");
         if (!empty($recNumber)) {
             $condition .= sprintf(" AND mobile = %d", sprintf("%d", $recNumber));
         }
         $content = EnvUtil::getRequest("content");
         if (!empty($content) && empty($keyword)) {
             $content = StringUtil::filterCleanHtml($content);
             $condition .= " AND content LIKE '%{$content}%'";
         }
         $type = "manager";
     } else {
         $condition = "";
     }
     $count = NotifySms::model()->count($condition);
     $pages = PageUtil::create($count, 20);
     if ($inSearch) {
         $pages->params = array("keyword" => $keyword, "searchtype" => $searchType, "begin" => $begin, "end" => $end, "sender" => $sender, "recnumber" => $recNumber, "content" => $content);
     }
     $data["list"] = NotifySms::model()->fetchAll(array("condition" => $condition, "order" => "ctime DESC"));
     $data["count"] = $count;
     $data["pages"] = $pages;
     $data["search"] = $inSearch;
     $this->render("manager", $data);
 }
Пример #21
0
 public function del($id, $uid)
 {
     $ids = is_array($id) ? $id : explode(",", $id);
     $count = 0;
     $logContent = Ibos::lang("Del run", "workflow.default");
     foreach ($ids as $runID) {
         $per = WfCommonUtil::getRunPermission($runID, $uid, 1);
         $isOnly = FlowRunProcess::model()->getIsOnlyOne($runID);
         if (!StringUtil::findIn($per, 2) && $isOnly && !StringUtil::findIn($per, 1) && !StringUtil::findIn($per, 3)) {
             continue;
         }
         if ($this->modify($runID, array("delflag" => 1))) {
             $count++;
             WfCommonUtil::runlog($runID, 0, 0, $uid, 3, $logContent);
         }
     }
     return $count;
 }
Пример #22
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);
 }