Example #1
0
 public function actionEdit()
 {
     if (EnvUtil::submitCheck("emailSubmit")) {
         $setting = array();
         foreach ($this->_fields as $field) {
             if (array_key_exists($field, $_POST)) {
                 $setting[$field] = intval($_POST[$field]);
             } else {
                 $setting[$field] = 0;
             }
         }
         $roles = array();
         if (isset($_POST["role"])) {
             foreach ($_POST["role"] as $role) {
                 if (!empty($role["positionid"]) && !empty($role["size"])) {
                     $positionId = StringUtil::getId($role["positionid"]);
                     $roles[implode(",", $positionId)] = intval($role["size"]);
                 }
             }
         }
         $setting["emailroleallocation"] = serialize($roles);
         foreach ($setting as $key => $value) {
             Setting::model()->updateSettingValueByKey($key, $value);
         }
         CacheUtil::update("setting");
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("dashboard/index"));
     }
 }
Example #2
0
 public function actionSave()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $data =& $_POST;
         if (isset($data["type"])) {
             foreach ($data["type"] as $id => $type) {
                 if (empty($data["uid"][$id]) || empty($data["remindtime"][$id])) {
                     continue;
                 }
                 $type = intval($type);
                 $attr = array("type" => intval($type));
                 if (!in_array($type, array(1, 5))) {
                     $attr["reminddate"] = $data["reminddate"][$id];
                 }
                 $attr["remindtime"] = $data["remindtime"][$id];
                 if (substr($id, 0, 1) == "n") {
                     $uid = StringUtil::getId($data["uid"][$id]);
                     $attr["uid"] = implode(",", $uid);
                     $attr["flowid"] = $this->flowid;
                     FlowTimer::model()->add($attr);
                 } else {
                     FlowTimer::model()->modify($id, $attr);
                 }
             }
         }
         if (!empty($data["delid"])) {
             $id = StringUtil::filterStr($data["delid"]);
             FlowTimer::model()->deleteAll("FIND_IN_SET(tid,'{$id}')");
         }
         $this->ajaxReturn(array("isSuccess" => true));
     }
     exit;
 }
Example #3
0
 public function actionPostFeed()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $return = array("isSuccess" => true, "data" => "");
         $d["content"] = isset($_POST["content"]) ? StringUtil::filterDangerTag($_POST["content"]) : "";
         $d["body"] = $_POST["body"];
         $d["rowid"] = isset($_POST["rowid"]) ? intval($_POST["rowid"]) : 0;
         foreach ($_POST as $key => $val) {
             $_POST[$key] = StringUtil::filterCleanHtml($_POST[$key]);
         }
         $uid = Ibos::app()->user->uid;
         $user = User::model()->fetchByUid($uid);
         if (isset($_POST["view"])) {
             $_POST["view"] = $d["view"] = intval($_POST["view"]);
             if ($_POST["view"] == WbConst::SELFDEPT_VIEW_SCOPE) {
                 $d["deptid"] = $user["deptid"];
             }
             if ($_POST["view"] == WbConst::CUSTOM_VIEW_SCOPE) {
                 $scope = StringUtil::getId($_POST["viewid"], true);
                 if (isset($scope["u"])) {
                     $d["userid"] = implode(",", $scope["u"]);
                 }
                 if (isset($scope["d"])) {
                     $d["deptid"] = implode(",", $scope["d"]);
                 }
                 if (isset($scope["p"])) {
                     $d["positionid"] = implode(",", $scope["p"]);
                 }
             }
         }
         $d["source_url"] = isset($_POST["source_url"]) ? urldecode($_POST["source_url"]) : "";
         $d["body"] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", "#" . trim("\${1}") . "#", $d["body"]);
         if (isset($_POST["attachid"])) {
             $d["attach_id"] = trim(StringUtil::filterCleanHtml($_POST["attachid"]));
             if (!empty($d["attach_id"])) {
                 $d["attach_id"] = explode(",", $d["attach_id"]);
                 array_map("intval", $d["attach_id"]);
             }
         }
         $type = StringUtil::filterCleanHtml($_POST["type"]);
         $table = isset($_POST["table"]) ? StringUtil::filterCleanHtml($_POST["table"]) : "feed";
         $module = isset($_POST["module"]) ? StringUtil::filterCleanHtml($_POST["module"]) : "weibo";
         $data = Feed::model()->put(Ibos::app()->user->uid, $module, $type, $d, $d["rowid"], $table);
         if (!$data) {
             $return["isSuccess"] = false;
             $return["data"] = Feed::model()->getError("putFeed");
             $this->ajaxReturn($return);
         }
         UserUtil::updateCreditByAction("addweibo", Ibos::app()->user->uid);
         $data["from"] = EnvUtil::getFromClient($data["from"], $data["module"]);
         $lang = Ibos::getLangSources();
         $return["data"] = $this->renderPartial("feedlist", array("list" => array($data), "lang" => $lang), true);
         $return["feedid"] = $data["feedid"];
         FeedTopic::model()->addTopic(html_entity_decode($d["body"], ENT_QUOTES, "UTF-8"), $data["feedid"], $type);
         $this->ajaxReturn($return);
     }
 }
Example #4
0
 public static function processAddRequestData()
 {
     $fieldArr = array("avatarid" => "", "realname" => "", "gender" => 0, "birthday" => 0, "birthplace" => "", "workyears" => "", "education" => "", "residecity" => "", "zipcode" => "", "idcard" => "", "height" => "", "weight" => "", "maritalstatus" => 0, "mobile" => "", "email" => "", "telephone" => "", "qq" => "", "msn" => "", "beginworkday" => "", "positionid" => 0, "expectsalary" => "", "workplace" => "", "recchannel" => "", "workexperience" => "", "projectexperience" => "", "eduexperience" => "", "langskill" => "", "computerskill" => "", "professionskill" => "", "trainexperience" => "", "selfevaluation" => "", "relevantcertificates" => "", "socialpractice" => "", "status" => 0, "attachmentid" => "");
     foreach ($_POST as $key => $value) {
         if (in_array($key, array_keys($fieldArr))) {
             $fieldArr[$key] = $value;
         }
     }
     $fieldArr["positionid"] = implode(",", StringUtil::getId($fieldArr["positionid"]));
     return $fieldArr;
 }
Example #5
0
 protected function beforeSave()
 {
     $viewExtFields = StringUtil::filterStr($_POST["viewextfields"]);
     $sumFields = StringUtil::filterStr($_POST["sumfields"]);
     $flowConditions = array("flowquerytype" => $_POST["flow_query_type"], "beginuser" => StringUtil::getId($_POST["begin_user"]), "runname" => StringUtil::filterCleanHtml($_POST["run_name"]), "flowstatus" => $_POST["flow_status"], "time1" => $_POST["time1"], "time2" => $_POST["time2"], "time3" => $_POST["time3"], "time4" => $_POST["time4"], "attachname" => StringUtil::filterCleanHtml($_POST["attach_name"]));
     $groupbyFields = array("field" => $_POST["group_field"], "order" => $_POST["group_sort"]);
     $name = StringUtil::filterCleanHtml($_POST["tplname"]);
     $sid = intval(EnvUtil::getRequest("sid"));
     $data = array("flowid" => $this->flowid, "uid" => $this->uid, "tplname" => $this->tplNameExists($name, $sid) ? $name . StringUtil::random(3) : $name, "viewextfields" => $viewExtFields, "sumfields" => $sumFields, "flowconditions" => serialize($flowConditions), "groupbyfields" => serialize($groupbyFields), "condformula" => $_POST["condformula"]);
     return $data;
 }
Example #6
0
 public static function processAddOrEditData($data)
 {
     $inverviewArr = array("interviewtime" => 0, "interviewer" => 0, "method" => "", "type" => "", "process" => "");
     foreach ($data as $k => $v) {
         if (in_array($k, array_keys($inverviewArr))) {
             $inverviewArr[$k] = $v;
         }
     }
     $interviewer = implode(",", StringUtil::getId($inverviewArr["interviewer"]));
     $inverviewArr["interviewer"] = empty($interviewer) ? Ibos::app()->user->uid : $interviewer;
     if ($inverviewArr["interviewtime"] != 0) {
         $inverviewArr["interviewtime"] = strtotime($inverviewArr["interviewtime"]);
     } else {
         $inverviewArr["interviewtime"] = TIMESTAMP;
     }
     return $inverviewArr;
 }
Example #7
0
 public function actionConfirmPost()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $key = EnvUtil::getRequest("key");
         $param = WfCommonUtil::param($key, "DECODE");
         $runId = intval($param["runid"]);
         $processId = intval($param["processid"]);
         $flowId = intval($param["flowid"]);
         $flowProcess = intval($param["flowprocess"]);
         $opflag = intval($_POST["opflag"]);
         $oldUid = intval($_POST["oldUid"]);
         $this->checkRunAccess($runId);
         $this->checkEntrustType($flowId);
         $referer = EnvUtil::referer();
         $frp = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $oldUid);
         if ($frp) {
             $parent = $frp["parent"];
             $topflag = $frp["topflag"];
         }
         $toid = implode(",", StringUtil::getId($_POST["prcs_other"]));
         $tempFRP = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $toid);
         if (!$tempFRP) {
             $data = array("runid" => $runId, "processid" => $processId, "uid" => $toid, "flag" => 1, "flowprocess" => $flowProcess, "opflag" => $opflag, "topflag" => $topflag, "parent" => $parent, "createtime" => TIMESTAMP);
             FlowRunProcess::model()->add($data);
         } else {
             if ($tempFRP["opflag"] == 0 && $opflag == 1) {
                 FlowRunProcess::model()->updateAll(array("opflag" => 1, "flag" => 2), sprintf("runid = %d AND processid = %d AND flowprocess = %d AND uid = %d", $runId, $processId, $flowProcess, $toid));
             } else {
                 $name = User::model()->fetchRealnameByUid($toid);
                 $this->error(Ibos::lang("Already are opuser", "", array("{name}" => $name)), $referer);
             }
         }
         FlowRunProcess::model()->updateProcessTime($runId, $processId, $flowProcess, $oldUid);
         FlowRunProcess::model()->updateAll(array("flag" => 4, "opflag" => 0, "delivertime" => TIMESTAMP), "runid = :runid AND processid = :prcsid AND flowprocess = :fp AND uid = :uid", array(":runid" => $runId, ":prcsid" => $processId, ":fp" => $flowProcess, ":uid" => $oldUid));
         $toName = User::model()->fetchRealnameByUid($toid);
         $userName = User::model()->fetchRealnameByUid($oldUid);
         $content = Ibos::lang("Entrust to desc", "", array("{username}" => $userName, "{toname}" => $toName));
         WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 2, $content, $toid);
         $message = StringUtil::filterCleanHtml($_POST["message"]);
         if (!empty($message)) {
             Notify::model()->sendNotify($toid, "workflow_entrust_notice", array("{message}" => $message));
         }
         $this->redirect($referer);
     }
 }
Example #8
0
 public static function processAddOrEditData($data)
 {
     $contactArr = array("upuid" => 0, "inputtime" => 0, "contact" => "", "purpose" => "", "detail" => "");
     foreach ($data as $k => $v) {
         if (in_array($k, array_keys($contactArr))) {
             $contactArr[$k] = $v;
         }
     }
     $input = implode(",", StringUtil::getId($contactArr["upuid"]));
     $contactArr["input"] = empty($input) ? Ibos::app()->user->uid : $input;
     if ($contactArr["inputtime"] != 0) {
         $contactArr["inputtime"] = strtotime($contactArr["inputtime"]);
     } else {
         $contactArr["inputtime"] = TIMESTAMP;
     }
     unset($contactArr["upuid"]);
     return $contactArr;
 }
Example #9
0
 public function handleEmailBody($data)
 {
     $data["toids"] = implode(",", StringUtil::getId($data["toids"]));
     $data["sendtime"] = TIMESTAMP;
     $data["isneedreceipt"] = isset($data["isneedreceipt"]) ? 1 : 0;
     if (empty($data["isOtherRec"])) {
         $data["copytoids"] = $data["secrettoids"] = "";
     } else {
         $data["copytoids"] = implode(",", StringUtil::getId($data["copytoids"]));
         $data["secrettoids"] = implode(",", StringUtil::getId($data["secrettoids"]));
     }
     if (empty($data["isWebRec"])) {
         $data["towebmail"] = "";
     }
     if (!isset($data["fromwebmail"])) {
         $data["fromwebmail"] = "";
     }
     !empty($data["attachmentid"]) && ($data["attachmentid"] = StringUtil::filterStr($data["attachmentid"]));
     $data["size"] = EmailUtil::getEmailSize($data["content"], $data["attachmentid"]);
     return $data;
 }
Example #10
0
 public function actionCategory()
 {
     if (EnvUtil::submitCheck("formhash")) {
         if (isset($_POST["name"])) {
             foreach ($_POST["name"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["sort"][$id]), "deptid" => !empty($_POST["deptid"][$id]) ? implode(",", StringUtil::getId($_POST["deptid"][$id])) : "");
                     FlowCategory::model()->modify(intval($id), $data);
                 }
             }
         }
         if (isset($_POST["newname"])) {
             foreach ($_POST["newname"] as $id => $val) {
                 if (!empty($val)) {
                     $data = array("name" => StringUtil::filterCleanHtml($val), "sort" => intval($_POST["newsort"][$id]), "deptid" => !empty($_POST["newdeptid"][$id]) ? implode(",", StringUtil::getId($_POST["newdeptid"][$id])) : "");
                     FlowCategory::model()->add($data);
                 }
             }
         }
         if (!empty($_POST["delid"])) {
             $id = StringUtil::filterStr($_POST["delid"]);
             if (!FlowCategory::model()->del($id)) {
                 $this->error(Ibos::lang("Category delete require"));
             }
         }
         $this->success(Ibos::lang("Operation succeed", "message"));
     } else {
         $categorys = FlowCategory::model()->fetchAll(array("order" => "sort ASC"));
         foreach ($categorys as $key => &$cat) {
             if ($cat["deptid"] !== "") {
                 $cat["deptid"] = StringUtil::wrapId($cat["deptid"], "d");
             }
             $cat["flownums"] = FlowType::model()->countByAttributes(array("catid" => $cat["catid"]));
             $cat["formnums"] = FlowFormType::model()->countByAttributes(array("catid" => $cat["catid"]));
         }
         $this->render("category", array("list" => $categorys));
     }
 }
Example #11
0
 protected function beforeSave()
 {
     $users = $_POST["users"];
     $_POST["uid"] = $_POST["deptid"] = $_POST["positionid"] = "";
     $allIds = StringUtil::getId($users, true);
     foreach ($allIds as $prefix => $ids) {
         $id = implode(",", $ids);
         if ($prefix == "c") {
             $_POST["deptid"] = "alldept";
         }
         if ($prefix == "d") {
             $_POST["deptid"] = $id;
         }
         if ($prefix == "p") {
             $_POST["positionid"] = $id;
         }
         if ($prefix == "u") {
             $_POST["uid"] = $id;
         }
     }
     if ($_POST["scope"] === "custom") {
         $_POST["scope"] = implode(",", StringUtil::getId($_POST["scopedept"]));
     }
 }
Example #12
0
 protected function handleSaveData($post)
 {
     $ret = array("name" => $post["name"], "level" => $post["level"], "level1" => implode(",", StringUtil::getId($post["level1"])), "level2" => implode(",", StringUtil::getId($post["level2"])), "level3" => implode(",", StringUtil::getId($post["level3"])), "level4" => implode(",", StringUtil::getId($post["level4"])), "level5" => implode(",", StringUtil::getId($post["level5"])), "free" => implode(",", StringUtil::getId($post["free"])), "desc" => $post["desc"]);
     return $ret;
 }
Example #13
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);
 }
Example #14
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);
 }
Example #15
0
 public function actionSave()
 {
     $uid = Ibos::app()->user->uid;
     $originalPlan = $planOutside = "";
     if (array_key_exists("originalPlan", $_POST)) {
         $originalPlan = $_POST["originalPlan"];
     }
     if (array_key_exists("planOutside", $_POST)) {
         $planOutside = array_filter($_POST["planOutside"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
     }
     if (!empty($originalPlan)) {
         foreach ($originalPlan as $key => $value) {
             DiaryRecord::model()->modify($key, array("schedule" => $value));
         }
     }
     $shareUidArr = isset($_POST["shareuid"]) ? StringUtil::getId($_POST["shareuid"]) : array();
     $diary = array("uid" => $uid, "diarytime" => strtotime($_POST["todayDate"]), "nextdiarytime" => strtotime($_POST["plantime"]), "addtime" => TIMESTAMP, "content" => $_POST["diaryContent"], "shareuid" => implode(",", $shareUidArr), "readeruid" => "", "remark" => "", "attention" => "");
     $diaryId = Diary::model()->add($diary, true);
     if (!empty($planOutside)) {
         DiaryRecord::model()->addRecord($planOutside, $diaryId, strtotime($_POST["todayDate"]), $uid, "outside");
     }
     $plan = array_filter($_POST["plan"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
     DiaryRecord::model()->addRecord($plan, $diaryId, strtotime($_POST["plantime"]), $uid, "new");
     UserUtil::updateCreditByAction("adddiary", $uid);
     $this->ajaxReturn($diaryId, "JSONP");
 }
Example #16
0
 public function nextPost()
 {
     $var = $this->_var;
     $topflag = $this->getTopflag();
     $topflagOld = filter_input(INPUT_POST, "topflagOld", FILTER_SANITIZE_NUMBER_INT);
     $prcsUserOpNext = implode(",", StringUtil::getId(filter_input(INPUT_POST, "prcsUserOp", FILTER_SANITIZE_STRING)));
     $op = $this->getOp();
     $prcsUserNext = StringUtil::getId(filter_input(INPUT_POST, "prcsUser", FILTER_SANITIZE_STRING));
     array_push($prcsUserNext, $prcsUserOpNext);
     $prcsUserNext = implode(",", array_unique($prcsUserNext));
     $freeOther = $var["flow"]->freeother;
     $processIdNext = $var["processid"] + 1;
     $preset = filter_input(INPUT_POST, "preset", FILTER_SANITIZE_NUMBER_INT);
     if (is_null($preset)) {
         $lineCount = filter_input(INPUT_POST, "lineCount", FILTER_SANITIZE_NUMBER_INT);
         for ($i = 0; $i <= $lineCount; $i++) {
             $prcsIdSet = $processIdNext + $i;
             $tmp = $i == 0 ? "" : $i;
             $str = "prcsUserOp" . $tmp;
             $prcsUserOp = implode(",", StringUtil::getId(filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING)));
             $prcsUserOpOld = $prcsUserOp;
             if ($freeOther == 2) {
                 $prcsUserOp = WfHandleUtil::turnOther($prcsUserOp, $var["flowid"], $var["runid"], $var["processid"], $var["flowprocess"]);
             }
             $str = "prcsUser" . $tmp;
             $prcsUser = StringUtil::getId(filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING));
             array_push($prcsUser, $prcsUserOp);
             $prcsUser = implode(",", array_unique($prcsUser));
             if ($freeOther == 2) {
                 $prcsUser = WfHandleUtil::turnOther($prcsUser, $var["flowid"], $var["runid"], $var["processid"], $var["flowprocess"], $prcsUserOpOld);
             }
             $str = "topflag" . $tmp;
             $topflag = filter_input(INPUT_POST, $str, FILTER_SANITIZE_NUMBER_INT);
             $prcsFlag = $i == 0 ? 1 : 5;
             $str = "freeItem" . $tmp;
             $freeItem = filter_input(INPUT_POST, $str, FILTER_SANITIZE_STRING);
             if (is_null($freeItem) || empty($freeItem)) {
                 $freeItem = filter_input(INPUT_POST, "freeItemOld", FILTER_SANITIZE_STRING);
             }
             $tok = strtok($prcsUser, ",");
             while ($tok != "") {
                 if ($tok == $prcsUserOp || $topflag == 1) {
                     $opflag = 1;
                 } else {
                     $opflag = 0;
                 }
                 if ($topflag == 2) {
                     $opflag = 0;
                 }
                 if ($opflag == 0) {
                     $freeItem = "";
                 }
                 $data = array("runid" => $var["runid"], "processid" => $prcsIdSet, "flowprocess" => $prcsIdSet, "uid" => $tok, "flag" => $prcsFlag, "opflag" => $opflag, "topflag" => $topflag, "freeitem" => $freeItem);
                 FlowRunProcess::model()->add($data);
                 $tok = strtok(",");
             }
         }
     } else {
         FlowRunProcess::model()->updateAll(array("flag" => 1), sprintf("runid = %d AND processid = %d", $var["runid"], $processIdNext));
     }
     $presetDesc = !is_null($preset) ? $var["lang"]["Default step"] : "";
     $userNameStr = User::model()->fetchRealnamesByUids($prcsUserNext);
     $content = $var["lang"]["To the steps"] . $processIdNext . $presetDesc . "," . $var["lang"]["Transactor"] . ":" . $userNameStr;
     WfCommonUtil::runlog($var["runid"], $var["processid"], 0, Ibos::app()->user->uid, 1, $content);
     FlowRunProcess::model()->updateAll(array("flag" => 3), sprintf("runid = %d AND processid = %d", $var["runid"], $var["processid"]));
     FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND uid = %d", $var["runid"], $var["processid"], Ibos::app()->user->uid));
     $content = filter_input(INPUT_POST, "message", FILTER_SANITIZE_STRING);
     if (!is_null($content)) {
         $key = array("runid" => $var["runid"], "flowid" => $var["flowid"], "processid" => $processIdNext, "flowprocess" => $var["flowprocess"]);
         $ext = array("{url}" => Ibos::app()->createUrl("workflow/form/index", array("key" => WfCommonUtil::param($key))), "{message}" => $content);
         Notify::model()->sendNotify($prcsUserNext, "workflow_turn_notice", $ext);
     }
     if ($op == "manage") {
         $prcsFirst = $var["processid"] - 1;
         $prcsNext = $var["processid"] - 2;
         FlowRunProcess::model()->updateAll(array("flag" => 4), sprintf("runid = %d AND (processid = %d OR processid = %d)", $var["runid"], $prcsFirst, $prcsNext));
     }
     MainUtil::setCookie("flow_turn_flag", 1, 30);
     $url = Ibos::app()->createUrl("workflow/list/index", array("op" => "list", "type" => "trans", "sort" => "all"));
     $this->getController()->redirect($url);
 }
Example #17
0
 public static function compareMixedIds($userIds, $mixedIds, $type)
 {
     static $ids = array();
     if (empty($ids)) {
         $ids = StringUtil::getId($mixedIds, true);
     }
     $access = false;
     if (isset($ids[$type])) {
         $flowIds = implode(",", $ids[$type]);
         $access = self::compareIds($userIds, $flowIds, $type);
     }
     return $access;
 }
Example #18
0
 protected function beforeSave()
 {
     $_POST["catid"] = intval($_POST["catid"]);
     $_POST["sort"] = intval($_POST["sort"]);
     $_POST["autonum"] = intval($_POST["autonum"]);
     $_POST["autolen"] = intval($_POST["autolen"]);
     $_POST["deptid"] = !empty($_POST["deptid"]) ? StringUtil::getId($_POST["deptid"]) : "";
     if (is_array($_POST["deptid"])) {
         $_POST["deptid"] = implode(",", $_POST["deptid"]);
     }
     if (!isset($_POST["allowattachment"])) {
         $_POST["allowattachment"] = 0;
     }
     if (!isset($_POST["allowversion"])) {
         $_POST["allowversion"] = 0;
     }
     if (!isset($_POST["forcepreset"])) {
         $_POST["forcepreset"] = 0;
     }
     if (empty($_POST["formid"])) {
         if (empty($_POST["formname"])) {
             $this->error(Ibos::lang("Form name invalid"));
         } else {
             $_POST["formid"] = FlowFormType::model()->quickAdd($_POST["formname"], $_POST["catid"]);
         }
     }
 }
Example #19
0
 public function userProcessor($item, $readOnly)
 {
     $value = $this->getValue($item);
     if (!empty($value)) {
         $ids = StringUtil::getId($value, true);
         $values = "";
         foreach ($ids as $prefix => $id) {
             if ($prefix == "u") {
                 $values = User::model()->fetchRealnamesByUids($id);
             }
             if ($prefix == "d") {
                 $values = Department::model()->fetchDeptNameByDeptId($id);
             }
             if ($prefix == "p") {
                 $values = Position::model()->fetchPosNameByPosId($id);
             }
         }
         return $values;
     }
     return $value;
 }
Example #20
0
 protected function beforeSave()
 {
     if (!empty($_POST["deptid"])) {
         $deptId = StringUtil::getId($_POST["deptid"]);
         $_POST["deptid"] = implode(",", $deptId);
     } else {
         $_POST["deptid"] = 0;
     }
 }
Example #21
0
 private function update()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $docid = $_POST["docid"];
         $uid = Ibos::app()->user->uid;
         $data = $_POST;
         $publicScope = OfficialdocUtil::handleSelectBoxData(StringUtil::getId($data["publishScope"], true));
         $data["uid"] = $publicScope["uid"];
         $data["positionid"] = $publicScope["positionid"];
         $data["deptid"] = $publicScope["deptid"];
         $ccScope = OfficialdocUtil::handleSelectBoxData(StringUtil::getId($data["ccScope"], true), false);
         $data["ccuid"] = $ccScope["uid"];
         $data["ccpositionid"] = $ccScope["positionid"];
         $data["ccdeptid"] = $ccScope["deptid"];
         $data["approver"] = $uid;
         $data["docno"] = $_POST["docNo"];
         $data["commentstatus"] = isset($data["commentstatus"]) ? $data["commentstatus"] : 0;
         $data["uptime"] = TIMESTAMP;
         $data["version"] = $data["version"] + 1;
         $version = Officialdoc::model()->fetchByPk($_POST["docid"]);
         $version["editor"] = $uid;
         $version["reason"] = $data["reason"];
         $version["uptime"] = TIMESTAMP;
         OfficialdocVersion::model()->add($version);
         if ($data["status"] == 2) {
             $catid = intval($data["catid"]);
             $category = OfficialdocCategory::model()->fetchByPk($catid);
             $data["status"] = empty($category["aid"]) ? 1 : 2;
             $data["approver"] = !empty($category["aid"]) ? 0 : $uid;
         }
         $attachmentid = trim($_POST["attachmentid"], ",");
         if (!empty($attachmentid)) {
             AttachUtil::updateAttach($attachmentid);
             Officialdoc::model()->modify($docid, array("attachmentid" => $attachmentid));
         }
         $attributes = Officialdoc::model()->create($data);
         Officialdoc::model()->updateByPk($data["docid"], $attributes);
         $doc = Officialdoc::model()->fetchByPk($data["docid"]);
         $this->sendPending($doc, $uid);
         OfficialdocBack::model()->deleteAll("docid = {$docid}");
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("officialdoc/index"));
     }
 }
Example #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);
 }
Example #23
0
 protected function dealWithSpecialParams()
 {
     $_POST["upuid"] = implode(",", StringUtil::getUid($_POST["upuid"]));
     $_POST["deptid"] = implode(",", StringUtil::getId($_POST["deptid"]));
     $_POST["positionid"] = implode(",", StringUtil::getId($_POST["positionid"]));
 }
Example #24
0
 private function beforeSave()
 {
     $data =& $_POST;
     $process = array("processid" => intval($data["processid"]), "type" => intval($data["type"]));
     if (isset($data["attachpriv"]) && is_array($data["attachpriv"])) {
         $process["attachpriv"] = implode(",", $data["attachpriv"]);
     } else {
         $process["attachpriv"] = "";
     }
     if (!empty($data["prcsuser"])) {
         $users = StringUtil::getId($data["prcsuser"], true);
         if (isset($users["c"])) {
             $process["deptid"] = "alldept";
         } else {
             if (isset($users["d"])) {
                 $process["deptid"] = implode(",", $users["d"]);
             } else {
                 $process["deptid"] = "";
             }
             if (isset($users["p"])) {
                 $process["positionid"] = implode(",", $users["p"]);
             } else {
                 $process["positionid"] = "";
             }
             if (isset($users["u"])) {
                 $process["uid"] = implode(",", $users["u"]);
             } else {
                 $process["uid"] = "";
             }
         }
     } else {
         $process["uid"] = $process["deptid"] = $process["positionid"] = "";
     }
     if ($process["type"] == 1) {
         $childFlow = intval($data["childflow"]);
         $typeData = array("name" => FlowType::model()->fetchNameByFlowId($childFlow), "processto" => $data["prcsback"], "autouserop" => !empty($data["backuserop"]) ? implode(",", StringUtil::getId($data["backuserop"])) : "", "autouser" => !empty($data["backuser"]) ? implode(",", StringUtil::getId($data["backuser"])) : "", "childflow" => $childFlow, "relationout" => $data["map"]);
     } else {
         $autoUser = !empty($data["autouser"]) ? implode(",", StringUtil::getId($data["autouser"])) : "";
         $autoType = intval($data["autotype"]);
         if ($autoType == 7) {
             $autoUser = intval($data["itemid"]);
         } elseif ($autoType == 8) {
             $autoUser = intval($data["autoprcsuser"]);
         }
         $typeData = array("name" => StringUtil::filterCleanHtml($data["name"]), "plugin" => $data["plugin"], "pluginsave" => $data["pluginsave"], "feedback" => intval($data["feedback"]), "signlook" => intval($data["signlook"]), "autotype" => $autoType, "autouserop" => !empty($data["autouserop"]) ? implode(",", StringUtil::getId($data["autouserop"])) : "", "autouser" => $autoUser, "userfilter" => intval($data["userfilter"]), "timeout" => $data["timeout"], "syncdeal" => intval($data["syncdeal"]), "userlock" => isset($data["userlock"]) ? 1 : 0, "turnpriv" => isset($data["turnpriv"]) ? 1 : 0, "topdefault" => intval($data["topdefault"]), "gathernode" => intval($data["gathernode"]), "allowback" => $data["allowback"], "childflow" => 0, "autobaseuser" => intval($data["autobaseuser"]));
     }
     $process = array_merge($process, $typeData);
     $write = isset($data["write"]) ? $data["write"] : array();
     $secret = isset($data["secret"]) ? $data["secret"] : array();
     $check = isset($data["check"]) ? $data["check"] : array();
     $micro = isset($data["micro"]) ? $data["micro"] : array();
     $checkSelect = isset($data["check_select"]) ? $data["check_select"] : array();
     if (!empty($write)) {
         $prcsItem = $checkItem = array();
         foreach ($write as $title) {
             $prcsItem[] = $title;
             if (in_array($title, $check)) {
                 $key = array_search($title, $check);
                 if (isset($checkSelect[$key])) {
                     $checkItem[] = sprintf("%s=%s", $title, $checkSelect[$key]);
                 }
             }
         }
         $process["processitem"] = implode(",", $prcsItem);
         $process["checkitem"] = implode(",", $checkItem);
     } else {
         $process["processitem"] = $process["checkitem"] = "";
     }
     if (!empty($secret)) {
         $process["hiddenitem"] = implode(",", $secret);
     } else {
         $process["hiddenitem"] = "";
     }
     if (!empty($micro)) {
         $process["processitemauto"] = implode(",", $micro);
     } else {
         $process["processitemauto"] = "";
     }
     if (isset($data["conresult"])) {
         foreach ($data["conresult"] as $id => $cond) {
             FlowProcessTurn::model()->deleteAll(sprintf("`flowid` = '%d' AND `processid` = '%d' AND `to` = '%d'", $this->flow->getID(), $process["processid"], $id));
             $desc = $data["condesc"][$id];
             FlowProcessTurn::model()->add(array("processout" => $cond, "processid" => $process["processid"], "conditiondesc" => $desc, "flowid" => $this->flow->getID(), "to" => $id));
         }
     }
     return $process;
 }
Example #25
0
 private function update()
 {
     $diaryId = $_POST["diaryid"];
     $diary = Diary::model()->fetchByPk($diaryId);
     $uid = Ibos::app()->user->uid;
     if (!ICDiary::checkReadScope($uid, $diary)) {
         $this->error(Ibos::lang("You do not have permission to edit the log"), $this->createUrl("default/index"));
     }
     if (isset($_POST["originalPlan"])) {
         foreach ($_POST["originalPlan"] as $key => $value) {
             if (isset($value)) {
                 DiaryRecord::model()->modify($key, array("schedule" => $value));
             }
         }
     }
     DiaryRecord::model()->deleteAll("diaryid=:diaryid AND planflag=:planflag", array(":diaryid" => $diaryId, ":planflag" => 0));
     if (!empty($_POST["planOutside"])) {
         $planOutside = array_filter($_POST["planOutside"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
         DiaryRecord::model()->addRecord($planOutside, $diaryId, $_POST["diarytime"], $uid, "outside");
     }
     $attributes = array("content" => $_POST["diaryContent"]);
     if (array_key_exists("shareuid", $_POST)) {
         $shareUidArr = StringUtil::getId($_POST["shareuid"]);
         $attributes["shareuid"] = implode(",", $shareUidArr);
     }
     Diary::model()->modify($diaryId, $attributes);
     $attachmentid = trim($_POST["attachmentid"], ",");
     AttachUtil::updateAttach($attachmentid);
     Diary::model()->modify($diaryId, array("attachmentid" => $attachmentid));
     $isInstallCalendar = ModuleUtil::getIsEnabled("calendar");
     if ($isInstallCalendar) {
         Calendars::model()->deleteALL("`calendarid` IN(select `cid` from {{calendar_record}} where `did`={$diaryId})");
         CalendarRecord::model()->deleteAll("did = {$diaryId}");
     }
     DiaryRecord::model()->deleteAll("plantime=:plantime AND uid=:uid AND planflag=:planflag", array(":plantime" => strtotime($_POST["plantime"]), ":uid" => $uid, ":planflag" => 1));
     if (!isset($_POST["plan"])) {
         $this->error(Ibos::lang("Please fill out at least one work plan"), $this->createUrl("default/edit", array("diaryid" => $diaryId)));
     }
     $plan = array_filter($_POST["plan"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
     DiaryRecord::model()->addRecord($plan, $diaryId, strtotime($_POST["plantime"]), $uid, "new");
     $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("default/index"));
 }
Example #26
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) : "");
         $nopriv = "";
         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"]);
                 if ($baseUid) {
                     $baseuser = User::model()->fetchByUid($baseUid);
                     $autodept = $baseuser["deptid"];
                 } else {
                     $autodept = 0;
                 }
             } 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)) {
                         if (strpos($value, "u") === false) {
                             continue;
                         } else {
                             $value = implode(",", StringUtil::getId($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        \t<div class=\"control-group\">\r\n\t\t\t\t<label class=\"control-label\">&nbsp;</label>\r\n        \t\t<div class=\"controls\">\r\n        \t\t\t<select name=\"topflag{$index}\" id=\"topflag{$index}\">\r\n        \t\t\t\t<option value=\"0\">{$lang["Host"]}</option>\r\n        \t\t\t\t<option value=\"1\">{$lang["First receiver host"]}</option>\r\n        \t\t\t\t<option value=\"2\">{$lang["No host"]}</option>\r\n        \t\t\t</select>\r\n        \t\t</div>\r\n        \t</div>\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 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}\" 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                var lockHostOption = (puo.attr(\"islock\") == 1);// 是否锁定主办人选项,即不可修改\r\n\t\t\t\tvar topdef = '{$process["topdefault"]}';\r\n\t\t\t\t// 主办类型选择\r\n\t\t\t\t\$(\"#topflag{$index}\").on(\"change\", function(){\r\n\t\t\t\t\t\$(this).closest(\".control-group\").next().toggle(this.value == \"0\");\r\n\t\t\t\t}).val(topdef).change().prop(\"readonly\", lockHostOption);\r\n                puo.userSelect({\r\n                    data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user',\r\n                    maximumSelectionSize:'1'\r\n                });\r\n                pu.userSelect({\r\n                    data:Ibos.data.includes(prcsData{$index}),\r\n\t\t\t\t\ttype:'user'\r\n                });\r\n            });\r\n        </script>";
     }
     return $tablestr;
 }
Example #27
0
 private function update()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $repid = $_POST["repid"];
         $typeid = $_POST["typeid"];
         $uid = Ibos::app()->user->uid;
         $editRepData = array("uid" => $uid, "begindate" => strtotime($_POST["begindate"]), "enddate" => strtotime($_POST["enddate"]), "typeid" => $typeid, "subject" => StringUtil::filterCleanHtml($_POST["subject"]), "content" => $_POST["content"], "attachmentid" => $_POST["attachmentid"], "toid" => implode(",", StringUtil::getId($_POST["toid"])));
         Report::model()->modify($repid, $editRepData);
         if (isset($_POST["orgPlan"])) {
             foreach ($_POST["orgPlan"] as $recordid => $orgPlan) {
                 $updateData = array("process" => intval($orgPlan["process"]), "exedetail" => StringUtil::filterCleanHtml($orgPlan["exedetail"]));
                 if ($updateData["process"] == self::COMPLETE_FALG) {
                     $updateData["flag"] = 1;
                 }
                 ReportRecord::model()->modify($recordid, $updateData);
             }
         }
         ReportRecord::model()->deleteAll("repid=:repid AND planflag!=:planflag", array(":repid" => $repid, ":planflag" => 0));
         $isInstallCalendar = ModuleUtil::getIsEnabled("calendar");
         if ($isInstallCalendar) {
             Calendars::model()->deleteALL("`calendarid` IN(select `cid` from {{calendar_rep_record}} where `repid`={$repid})");
             CalendarRepRecord::model()->deleteAll("repid = {$repid}");
         }
         if (isset($_POST["outSidePlan"])) {
             $outSidePlan = array_filter($_POST["outSidePlan"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
             if (!empty($outSidePlan)) {
                 ReportRecord::model()->addPlans($outSidePlan, $repid, $editRepData["begindate"], $editRepData["enddate"], $uid, 1);
             }
         }
         if (isset($_POST["nextPlan"])) {
             $nextPlan = array_filter($_POST["nextPlan"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
             if (!empty($nextPlan)) {
                 ReportRecord::model()->addPlans($nextPlan, $repid, strtotime($_POST["planBegindate"]), strtotime($_POST["planEnddate"]), $uid, 2);
             }
         }
         $attachmentid = trim($_POST["attachmentid"], ",");
         AttachUtil::updateAttach($attachmentid);
         $this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("default/index"));
     }
 }
Example #28
0
 private function addOrUpdateArticle($type, $data, $uid)
 {
     $attributes = Article::model()->create();
     $attributes["approver"] = $uid;
     $attributes["author"] = $uid;
     $publishScope = StringUtil::getId($data["publishScope"], true);
     $publishScope = ArticleUtil::handleSelectBoxData($publishScope);
     $attributes["deptid"] = $publishScope["deptid"];
     $attributes["positionid"] = $publishScope["positionid"];
     $attributes["uid"] = $publishScope["uid"];
     $attributes["votestatus"] = isset($data["votestatus"]) ? $data["votestatus"] : 0;
     $attributes["commentstatus"] = isset($data["commentstatus"]) ? $data["commentstatus"] : 0;
     if ($attributes["status"] == 2) {
         $catid = intval($attributes["catid"]);
         $category = ArticleCategory::model()->fetchByPk($catid);
         $attributes["status"] = empty($category["aid"]) ? 1 : 2;
         $attributes["approver"] = !empty($category["aid"]) ? 0 : $uid;
     }
     if ($type == "add") {
         $attributes["addtime"] = TIMESTAMP;
         return Article::model()->add($attributes, true);
     } elseif ($type == "update") {
         $attributes["uptime"] = TIMESTAMP;
         return Article::model()->updateByPk($attributes["articleid"], $attributes);
     }
 }
Example #29
0
 public static function joinInterviewSearchCondition(array $search, $condition)
 {
     $searchCondition = "";
     $realname = $search["realname"];
     $interviewtime = $search["interviewtime"];
     $interviewer = implode(",", StringUtil::getId($search["interviewer"]));
     $type = $search["type"];
     if (!empty($realname)) {
         $searchCondition .= " rd.realname LIKE '%{$realname}%' AND ";
     }
     if ($interviewtime != -1) {
         $maxTime = TIMESTAMP;
         $minTime = TIMESTAMP - $interviewtime * 24 * 60 * 60;
         $searchCondition .= " ri.interviewtime>='{$minTime}' AND ri.interviewtime<='{$maxTime}' AND ";
     }
     if (!empty($interviewer)) {
         $searchCondition .= " ri.interviewer='{$interviewer}' AND ";
     }
     if ($type != -1) {
         $searchCondition .= " ri.type='{$type}' AND ";
     }
     $searchCondition = empty($searchCondition) ? "" : substr($searchCondition, 0, -4);
     return $condition . $searchCondition;
 }
Example #30
0
 private function handlePostData()
 {
     $chargeuid = StringUtil::getId($_POST["chargeuid"]);
     $participantuid = StringUtil::getId($_POST["participantuid"]);
     $data = array("subject" => StringUtil::filterStr($_POST["subject"]), "description" => StringUtil::filterStr($_POST["description"]), "chargeuid" => implode(",", $chargeuid), "participantuid" => implode(",", $participantuid), "attachmentid" => trim($_POST["attachmentid"], ","), "starttime" => empty($_POST["starttime"]) ? TIMESTAMP : strtotime($_POST["starttime"]), "endtime" => strtotime($_POST["endtime"]));
     return $data;
 }