protected function setListPageSize($size) { $size = intval($size); if (0 < $size && in_array($size, array(10, 20, 30, 40, 50))) { MainUtil::setCookie("workflow_pagesize_" . $this->uid, $size); } }
protected function setListPageSize($size) { $size = intval($size); if (0 < $size && in_array($size, array(5, 10, 20))) { MainUtil::setCookie("email_pagesize_" . $this->uid, $size, 0, 0); } }
public function afterLogin($fromCookie) { $uid = $this->getId(); MainUtil::setCookie("lastactivity", TIMESTAMP); UserStatus::model()->updateByPk($uid, array("lastip" => EnvUtil::getClientIp(), "lastvisit" => TIMESTAMP, "lastactivity" => TIMESTAMP, "invisible" => 1)); if (!$fromCookie) { Ibos::app()->session->isNew = true; Ibos::app()->session->updateSession(); } }
protected function doLogin($userName, $passWord, $loginType, $account, $autoLogin = 1, $cookieTime = 0, $inajax = 0) { if (!$passWord || $passWord != addslashes($passWord)) { $this->error(Ibos::lang("Passwd illegal")); } $errornum = $this->loginCheck($account); $ip = Ibos::app()->setting->get("clientip"); $identity = new ICUserIdentity($userName, $passWord, $loginType); $result = $identity->authenticate(); if (0 < $result) { $user = Ibos::app()->user; if (empty($autoLogin)) { $user->setState($user::AUTH_TIMEOUT_VAR, TIMESTAMP + $account["timeout"]); } else { MainUtil::setCookie("autologin", 1, $cookieTime); } $user->login($identity, $cookieTime); if ($user->uid != 1) { MainUtil::checkLicenseLimit(true); } if (!$inajax) { $urlForward = EnvUtil::referer(); $log = array("terminal" => "web", "password" => StringUtil::passwordMask($passWord), "ip" => $ip, "user" => $userName, "loginType" => $loginType, "address" => "", "gps" => ""); Log::write($log, "login", sprintf("module.user.%d", $user->uid)); $rule = UserUtil::updateCreditByAction("daylogin", $user->uid); if (!$rule["updateCredit"]) { UserUtil::checkUserGroup($user->uid); } $this->success(Ibos::lang("Login succeed", "", array("{username}" => $user->realname)), $urlForward); } else { $this->ajaxReturn(array("isSuccess" => true)); } } elseif ($result === 0) { $this->error(Ibos::lang("User not fount", "", array("{username}" => $userName)), "", array(), array("error" => $result)); } elseif ($result === -1) { $this->error(Ibos::lang("User lock", "", array("{username}" => $userName)), "", array(), array("error" => $result)); } elseif ($result === -2) { $this->error(Ibos::lang("User disabled", "", array("{username}" => $userName)), "", array(), array("error" => $result)); } elseif ($result === -3) { FailedLogin::model()->updateFailed($ip); list($ip1, $ip2) = explode(".", $ip); $newIp = $ip1 . "." . $ip2; FailedIp::model()->insertIp($newIp); $log = array("user" => $userName, "password" => StringUtil::passwordMask($passWord), "ip" => $ip); Log::write($log, "illegal", "module.user.login"); if ($errornum) { $this->error("登录失败,您还可以尝试" . ($errornum - 1) . "次"); } else { $this->error(Ibos::lang("User name or password is not correct"), "", array(), array("error" => $result)); } } }
public static function hookSyncUser($uid, $pwd = "", $syncFlag = 1) { $type = ""; $imCfg = array(); foreach (Ibos::app()->setting->get("setting/im") as $imType => $config) { if ($config["open"] == "1") { $type = $imType; $imCfg = $config; break; } } if (!empty($type) && !empty($imCfg) && $imCfg["syncuser"] == "1") { MainUtil::setCookie("hooksyncuser", 1, 30); MainUtil::setCookie("syncurl", Ibos::app()->createUrl("organization/api/syncUser", array("type" => $type, "uid" => $uid, "pwd" => $pwd, "flag" => $syncFlag)), 30); } }
private function search() { $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->condition, 10 * 60); } if ($type == "advanced_search") { $this->condition = ArticleUtil::joinSearchCondition($_POST["search"], $this->condition); } elseif ($type == "normal_search") { $keyword = $_POST["keyword"]; $this->condition = " subject LIKE '%{$keyword}%' "; MainUtil::setCookie("keyword", $keyword, 10 * 60); } else { $this->condition = $conditionCookie; } if ($this->condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->condition, 10 * 60); } }
protected function search() { $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } if ($type == "advanced_search") { $search = $_POST["search"]; $this->_condition = ReportUtil::joinSearchCondition($search); } elseif ($type == "normal_search") { $keyword = $_POST["keyword"]; MainUtil::setCookie("keyword", $keyword, 10 * 60); $this->_condition = " ( content LIKE '%{$keyword}%' OR subject LIKE '%{$keyword}%' ) "; } else { $this->_condition = $conditionCookie; } if ($this->_condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } }
public function actionSearch() { $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->condition, 10 * 60); } if ($type == "advanced_search") { $search = $_POST["search"]; $methodName = "join" . ucfirst($this->id) . "SearchCondition"; $this->condition = RecruitUtil::$methodName($search, $this->condition); } elseif ($type == "normal_search") { $keyword = $_POST["keyword"]; $this->condition = " rd.realname LIKE '%{$keyword}%' "; } else { $this->condition = $conditionCookie; } if ($this->condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->condition, 10 * 60); } $this->actionIndex(); }
private function search() { $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } if (EnvUtil::getRequest("search")) { $keyword = EnvUtil::getRequest("keyword"); if (!empty($keyword)) { $this->_condition = " (`subject` LIKE '%{$keyword}%' "; $users = User::model()->fetchAll("`realname` LIKE '%{$keyword}%'"); if (!empty($users)) { $uids = ConvertUtil::getSubByKey($users, "uid"); $uidStr = implode(",", $uids); $this->_condition .= " OR FIND_IN_SET(`designeeuid`, '{$uidStr}') OR FIND_IN_SET( `chargeuid`, '{$uidStr}' ) "; foreach ($uids as $uid) { $this->_condition .= " OR FIND_IN_SET({$uid}, `participantuid`)"; } } $this->_condition .= ")"; } $daterange = EnvUtil::getRequest("daterange"); if (!empty($daterange)) { $time = explode(" - ", $daterange); $starttime = $time[0]; $endtime = $time[1]; $st = strtotime($starttime); $et = strtotime($endtime); $this->_condition = AssignmentUtil::joinCondition($this->_condition, "`starttime` >= {$st} AND `endtime` <= {$et}"); } MainUtil::setCookie("keyword", $keyword, 10 * 60); MainUtil::setCookie("daterange", $daterange, 10 * 60); } else { $this->_condition = $conditionCookie; } if ($this->_condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } }
private function search() { $uid = $this->uid; $complete = $this->complete; $type = EnvUtil::getRequest("type"); $conditionCookie = MainUtil::getCookie("condition"); if (empty($conditionCookie)) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } if ($type == "normal_search") { $keyword = EnvUtil::getRequest("keyword"); MainUtil::setCookie("keyword", $keyword, 10 * 60); $pTasks = Tasks::model()->fetchPTasks($uid, $complete, $keyword); $cTasks = Tasks::model()->fetchCTasks($uid, $complete, $keyword); $array = array(); foreach ($pTasks as $task) { $array[] = $task["id"]; } foreach ($cTasks as $task) { $array[] = $task["pid"]; } $pids = array_unique($array); $pidTemp = ""; foreach ($pids as $v) { $pidTemp .= "\"" . $v . "\","; } $pidStr = rtrim($pidTemp, ","); if (!empty($pidStr)) { $this->_condition = " uid='{$uid}' AND id IN({$pidStr}) AND allcomplete='{$complete}'"; } else { $this->_condition = " uid='{$uid}' AND id IN('') AND allcomplete='{$complete}'"; } } else { $this->_condition = $conditionCookie; } if ($this->_condition != MainUtil::getCookie("condition")) { MainUtil::setCookie("condition", $this->_condition, 10 * 60); } }
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); }
public function actionIndex() { $flow = new ICFlowType(intval($this->flowid)); if (EnvUtil::submitCheck("formhash")) { $data = array(); $readOnly = $_POST["readonly"]; $hidden = $_POST["hidden"]; $saveflag = $_POST["saveflag"]; $fbAttachmentId = $_POST["fbattachmentid"]; $attachmentId = $_POST["attachmentid"]; $content = isset($_POST["content"]) ? StringUtil::filterCleanHtml($_POST["content"]) : ""; $topflag = $_POST["topflag"]; $this->checkRunAccess($this->runid, $this->processid, $this->createUrl("list/index")); if (FlowRunProcess::model()->getIsOp($this->uid, $this->runid, $this->processid)) { $formData = array(); $structure = $flow->form->parser->structure; foreach ($structure as $index => $item) { if (StringUtil::findIn($hidden, $item["itemid"]) || StringUtil::findIn($readOnly, $item["itemid"])) { continue; } $value = isset($_POST[$index]) ? $_POST[$index] : ""; $formData[$index] = $value; } $formData && $this->handleImgComponent($formData); $formData && FlowDataN::model()->update($this->flowid, $this->runid, $formData); } if (!empty($content) || !empty($fbAttachmentId)) { $fbData = array("runid" => $this->runid, "processid" => $this->processid, "flowprocess" => $this->flowprocess, "uid" => $this->uid, "content" => $content, "attachmentid" => $fbAttachmentId, "edittime" => TIMESTAMP); FlowRunfeedback::model()->add($fbData); AttachUtil::updateAttach($fbAttachmentId, $this->runid); } FlowRun::model()->modify($this->runid, array("attachmentid" => $attachmentId)); AttachUtil::updateAttach($attachmentId, $this->runid); $plugin = FlowProcess::model()->fetchSavePlugin($this->flowid, $this->flowprocess); if (!empty($plugin)) { $pluginFile = "./system/modules/workflow/plugins/save/" . $plugin; if (file_exists($pluginFile)) { include_once $pluginFile; } } switch ($saveflag) { case "save": MainUtil::setCookie("save_flag", 1); $this->redirect($this->createUrl("form/index", array("key" => $this->key))); break; case "turn": MainUtil::setCookie("turn_flag", 1); $this->redirect($this->createUrl("form/index", array("key" => $this->key))); break; case "end": case "finish": if ($saveflag == "end") { $param = array("opflag" => 1); } else { $param = array("topflag" => $topflag); } $this->redirect($this->createUrl("handle/complete", array_merge($param, array("key" => $this->key)))); break; default: break; } } else { $this->checkRunDel(); $this->checkIllegal(); $len = strlen($flow->autonum); for ($i = 0; $i < $flow->autolen - $len; $i++) { $flow->autonum = "0" . $flow->autonum; } $runProcess = new ICFlowRunProcess($this->runid, $this->processid, $this->flowprocess, $this->uid); $checkitem = ""; if ($flow->isFixed()) { $process = new ICFlowProcess($this->flowid, $this->flowprocess); if ($runProcess->opflag != 0) { $checkitem = $process->checkitem; } if (0 < $process->allowback) { $isAllowBack = $this->isAllowBack($runProcess->parent); } } else { $process = array(); } $run = new ICFlowRun($this->runid); $hasOtherOPUser = FlowRunProcess::model()->getHasOtherOPUser($this->runid, $this->processid, $this->flowprocess, $this->uid); if ($runProcess->flag == FlowConst::PRCS_UN_RECEIVE) { $this->setSelfToHandle($runProcess->id); } if ($runProcess->topflag == 1 && $runProcess->opflag == 1) { FlowRunProcess::model()->updateTop($this->uid, $this->runid, $this->processid, $this->flowprocess); } if ($runProcess->topflag == 2) { if (!$hasOtherOPUser) { $runProcess->opflag = 1; } } if ($this->processid == 1) { FlowRun::model()->modify($this->runid, array("beginuser" => $this->uid, "begintime" => TIMESTAMP)); if (!empty($run->parentrun)) { $this->setParentToHandle($run->parentrun, $this->runid); } } $preProcess = $this->processid - 1; if ($preProcess) { if ($flow->isFree() || $flow->isFixed() && $process->gathernode != 1) { $this->setProcessDone($preProcess); } } if ($flow->isFixed() && $process->timeout != 0) { if ($runProcess->flag == FlowConst::PRCS_UN_RECEIVE && $this->processid != 1) { $processBegin = FlowRunProcess::model()->fetchDeliverTime($this->runid, $preProcess); } else { $processBegin = $runProcess->processtime ? $runProcess->processtime : TIMESTAMP; } $timeUsed = TIMESTAMP - $processBegin; } $viewer = new ICFlowFormViewer(array("flow" => $flow, "form" => $flow->getForm(), "run" => $run, "process" => $process, "rp" => $runProcess)); $data = array_merge(array("flow" => $flow->toArray(), "run" => $run->toArray(), "processid" => $this->processid, "process" => !empty($process) ? $process->toArray() : $process, "checkItem" => $checkitem, "prcscache" => WfCommonUtil::loadProcessCache($this->flowid), "rp" => $runProcess->toArray(), "fbSigned" => $this->isFeedBackSigned(), "allowBack" => isset($isAllowBack) ? $isAllowBack : false, "timeUsed" => isset($timeUsed) ? $timeUsed : 0, "uploadConfig" => AttachUtil::getUploadConfig()), $viewer->render()); if ($this->isEnabledAttachment($flow, $run, $process, $runProcess)) { $data["allowAttach"] = true; if (!empty($run->attachmentid)) { $attachPurv = $this->getAttachPriv($flow, $process, $runProcess); $down = $attachPurv["down"]; $edit = $attachPurv["edit"]; $del = $attachPurv["del"]; $data["attachData"] = AttachUtil::getAttach($run->attachmentid, $down, $down, $edit, $del); } } else { $data["allowAttach"] = false; } if ($flow->isFixed() && $process->feedback != 1 || $flow->isFree()) { $data["allowFeedback"] = true; } else { $data["allowFeedback"] = false; } if ($data["allowBack"]) { $data["backlist"] = $this->getBackList($runProcess->flowprocess); } $data["feedback"] = WfHandleUtil::loadFeedback($flow->getID(), $run->getID(), $flow->type, $this->uid); if ($flow->isFree() && $runProcess->opflag == "1") { $hasDefault = FlowRunProcess::model()->getHasDefaultStep($this->runid, $this->processid); if (!$hasDefault) { $data["defaultEnd"] = true; } } if ($flow->isFree() && $runProcess->topflag == "2") { if (!$hasOtherOPUser) { $data["otherEnd"] = true; } } $this->setPageTitle(Ibos::lang("Handle work")); $this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Workflow")), array("name" => Ibos::lang("My work"), "url" => $this->createUrl("list/index")), array("name" => Ibos::lang("Handle work")))); $this->render("index", $data); } }
private function checkAccess() { if (isset($this->user["uid"]) && $this->user["uid"] == 0) { $this->_access = 0; } elseif ($this->_isAdministrator) { $lastactivity = MainUtil::getCookie("lastactivity"); $frozenTime = intval(TIMESTAMP - $lastactivity); if ($frozenTime < $this->_cookieLife) { $this->_access = 1; MainUtil::setCookie("lastactivity", TIMESTAMP); } else { $this->_access = -1; } } else { $this->_access = -1; } if ($this->_access == 1) { Ibos::app()->session->update(); } else { $requestUrl = Ibos::app()->getRequest()->getUrl(); $loginUrl = Ibos::app()->getUrlManager()->createUrl($this->loginUrl); if (strpos($requestUrl, $loginUrl) !== 0) { $this->userLogin(); } } }
public function updateUserCount($creditArr, $uids = 0, $checkGroup = true, $ruletxt = "") { if (Ibos::app()->user->isGuest) { return null; } $setting = Ibos::app()->setting->toArray(); if (!$uids) { $uids = intval(Ibos::app()->user->uid); } $uids = is_array($uids) ? $uids : array($uids); if ($uids && ($creditArr || $this->_extraSql)) { if ($this->_extraSql) { $creditArr = array_merge($creditArr, $this->_extraSql); } $sql = array(); $allowkey = array("extcredits1", "extcredits2", "extcredits3", "extcredits4", "extcredits5", "oltime", "attachsize"); $creditRemind = $setting["setting"]["creditremind"] && Ibos::app()->user->uid && $uids == array(Ibos::app()->user->uid); if ($creditRemind) { if (!isset($setting["cookiecredits"])) { $setting["cookiecredits"] = !empty($_COOKIE["creditnotice"]) ? explode("D", $_COOKIE["creditremind"]) : array_fill(0, 6, 0); for ($i = 1; $i <= 5; $i++) { $setting["cookiecreditsbase"][$i] = UserUtil::getUserProfile("extcredits" . $i); } } if ($ruletxt) { $setting["cookiecreditsrule"][$ruletxt] = $ruletxt; } } foreach ($creditArr as $key => $value) { if (!empty($key) && $value && in_array($key, $allowkey)) { $sql[$key] = $value; if ($creditRemind && substr($key, 0, 10) == "extcredits") { $i = substr($key, 10); $setting["cookiecredits"][$i] += $value; } } } if ($creditRemind) { MainUtil::setCookie("creditremind", implode("D", $setting["cookiecredits"]) . "D" . Ibos::app()->user->uid); MainUtil::setCookie("creditbase", "0D" . implode("D", $setting["cookiecreditsbase"])); if (!empty($setting["cookiecreditsrule"])) { MainUtil::setCookie("creditrule", strip_tags(implode("\t", $setting["cookiecreditsrule"]))); } } Ibos::app()->setting->copyFrom($setting); if ($sql) { UserCount::model()->increase($uids, $sql); } if ($checkGroup && count($uids) == 1) { $this->checkUserGroup($uids[0]); } $this->setExtraSql(array()); } }
public function actionLogout() { Ibos::app()->user->logout(); MainUtil::setCookie("autologin", 0, 0); $this->ajaxReturn(array("login" => false), "JSONP"); }
public function actionDesign() { if (filter_input(INPUT_GET, "op") == "showcomponet") { $type = filter_input(INPUT_GET, "type"); return $this->renderPartial("ic" . $type, null, false); } $formId = intval(EnvUtil::getRequest("formid")); $mode = EnvUtil::getRequest("mode"); if (!in_array($mode, array("advanced", "simple"))) { $mode = "advanced"; } if (EnvUtil::submitCheck("formhash")) { $content = preg_replace("/<form.*?>(.*?)<\\/form>/is", "", $_POST["content"]); if ($_POST["op"] == "version") { $verMax = FlowFormVersion::model()->getMaxMark($formId); $mark = $verMax ? $verMax + 1 : 1; $oldForm = FlowFormType::model()->fetchByPk($formId); $data = array("formid" => $formId, "printmodel" => $oldForm["printmodel"], "printmodel_short" => $oldForm["printmodelshort"], "script" => $oldForm["script"], "css" => $oldForm["css"], "time" => TIMESTAMP, "mark" => $mark); FlowFormVersion::model()->add($data); MainUtil::setCookie("form_op_version", 1, 30, 0); } else { $this->setAllGuideInfo($formId); MainUtil::setCookie("form_op_save", 1, 30, 0); } FlowFormType::model()->modify($formId, array("printmodel" => $content)); CacheUtil::rm("form_" . $formId); $form = new ICFlowForm($formId); $form->parser->parse(); $url = $this->createUrl("formtype/design", array("mode" => $mode, "formid" => $formId)); $this->redirect($url); exit; } $form = new ICFlowForm($formId); $arr = $form->toArray(); $data = array("form" => $arr, "mode" => $mode, "formid" => $formId); $this->layout = false; $this->render("designer" . ucfirst($mode), $data, false, array("workflow.item")); }
public function showMessage($message, $jumpUrl = "", $params = array(), $status = 1, $ajax = false) { if ($ajax === true || Ibos::app()->request->getIsAjaxRequest()) { $data = is_array($ajax) ? $ajax : array(); $data["msg"] = $message; $data["isSuccess"] = $status; $data["url"] = $jumpUrl; $this->ajaxReturn($data); } $params["message"] = $message; $params["autoJump"] = isset($params["autoJump"]) ? $params["autoJump"] : true; if (!$params["autoJump"]) { $params["jumpLinksOptions"] = isset($params["jumpLinksOptions"]) && is_array($params["jumpLinksOptions"]) ? $params["jumpLinksOptions"] : array(); } else { $params["jumpLinksOptions"] = array(); } if (!empty($jumpUrl)) { $params["jumpUrl"] = $jumpUrl; } else { $params["jumpUrl"] = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ""; } if (!isset($params["timeout"])) { if ($status) { $params["timeout"] = 1; } else { $params["timeout"] = 5; } } $params["msgTitle"] = $status ? Ibos::lang("Operation successful", "message") : Ibos::lang("Operation failure", "message"); if (isset($params["closeWin"])) { $params["jumpUrl"] = "javascript:window.close();"; } $params["script"] = isset($params["script"]) ? trim($params["script"]) : null; if (!isset($params["messageType"])) { $params["messageType"] = $status ? "success" : "error"; } if ($status) { MainUtil::setCookie("globalRemind", urlencode($params["message"]), 30); MainUtil::setCookie("globalRemindType", $params["messageType"], 30); $this->redirect($params["jumpUrl"]); } else { $viewPath = $basePath = Ibos::app()->getViewPath(); $viewFile = $this->resolveViewFile("showMessage", $viewPath, $basePath); $output = $this->renderFile($viewFile, $params, true); echo $output; } exit; }
public function update() { if ($this->sid !== null) { if ($this->isNew) { $this->delete(); Session::model()->add($this->var); } else { if (IN_DASHBOARD) { MainUtil::setCookie("lastactivity", TIMESTAMP); } Session::model()->updateByPk($this->var["sid"], $this->var); } Ibos::app()->setting->set("session", $this->var); MainUtil::setCookie("sid", $this->sid, 86400); } }
public function actionForm() { $key = EnvUtil::getRequest("key"); if ($key) { $this->key = $key; $param = WfCommonUtil::param($key, "DECODE"); $this->_extraAttributes = $param; $this->runid = $param["runid"]; $this->flowid = $param["flowid"]; $this->processid = $param["processid"]; $this->flowprocess = $param["flowprocess"]; } else { $this->ajaxReturn("<script>alert('工作流数据错误,可能已转交或被回退')</script>", "EVAL"); } $flow = new ICFlowType(intval($this->flowid)); if ($_SERVER["REQUEST_METHOD"] == "POST") { $data = array(); $readOnly = $_POST["readonly"]; $hidden = $_POST["hidden"]; $saveflag = $_POST["saveflag"]; $fbAttachmentID = $_POST["fbattachmentid"]; $attachmentID = $_POST["attachmentid"]; $content = isset($_POST["content"]) ? StringUtil::filterCleanHtml($_POST["content"]) : ""; $topflag = $_POST["topflag"]; $this->checkRunAccess($this->runid, $this->processid, $this->createUrl("list/index")); if (FlowRunProcess::model()->getIsOp($this->uid, $this->runid, $this->processid)) { $enablefiledArr = explode(",", $_POST["enablefiled"]); $formData = array(); $structure = $flow->form->parser->structure; foreach ($structure as $index => $item) { if (!in_array("data_" . $item["itemid"], $enablefiledArr)) { continue; } $value = isset($_POST[$index]) ? $_POST[$index] : ""; $formData[$index] = $value; } $formData && $this->handleImgComponent($formData); $formData && FlowDataN::model()->update($this->flowid, $this->runid, $formData); } if (!empty($content) || !empty($fbAttachmentID)) { $fbData = array("runid" => $this->runid, "processid" => $this->processid, "flowprocess" => $this->flowprocess, "uid" => $this->uid, "content" => $content, "attachmentid" => $fbAttachmentID, "edittime" => TIMESTAMP); FlowRunfeedback::model()->add($fbData); AttachUtil::updateAttach($fbAttachmentID, $this->runid); } FlowRun::model()->modify($this->runid, array("attachmentid" => $attachmentID)); AttachUtil::updateAttach($attachmentID, $this->runid); $plugin = FlowProcess::model()->fetchSavePlugin($this->flowid, $this->flowprocess); if (!empty($plugin)) { $pluginFile = "./system/modules/workflow/plugins/save/" . $plugin; if (file_exists($pluginFile)) { include_once $pluginFile; } } switch ($saveflag) { case "save": MainUtil::setCookie("save_flag", 1, 300); $this->ajaxReturn("<script>alert('保存成功')</script>", "EVAL"); break; case "turn": MainUtil::setCookie("turn_flag", 1, 300); break; case "end": case "finish": if ($saveflag == "end") { $param = array("opflag" => 1); } else { $param = array("topflag" => $topflag); } $this->redirect($this->createUrl("handle/complete", array_merge($param, array("key" => $this->key)))); break; default: break; } } else { $this->checkRunDel(); $this->checkIllegal(); $len = strlen($flow->autonum); for ($i = 0; $i < $flow->autolen - $len; $i++) { $flow->autonum = "0" . $flow->autonum; } $runProcess = new ICFlowRunProcess($this->runid, $this->processid, $this->flowprocess, $this->uid); $checkitem = ""; if ($flow->isFixed()) { $process = new ICFlowProcess($this->flowid, $this->flowprocess); if ($runProcess->opflag != 0) { $checkitem = $process->checkitem; } if (0 < $process->allowback) { $isAllowBack = true; } } else { $process = array(); } $run = new ICFlowRun($this->runid); $hasOtherOPUser = FlowRunProcess::model()->getHasOtherOPUser($this->runid, $this->processid, $this->flowprocess, $this->uid); if ($runProcess->flag == self::UN_RECEIVE) { $this->setSelfToHandle($runProcess->id); } if ($runProcess->topflag == 1 && $runProcess->opflag == 1) { FlowRunProcess::model()->updateTop($this->uid, $this->runid, $this->processid, $this->flowprocess); } if ($runProcess->topflag == 2) { if (!$hasOtherOPUser) { $runProcess->opflag = 1; } } if ($this->processid == 1) { FlowRun::model()->modify($this->runid, array("beginuser" => $this->uid, "begintime" => TIMESTAMP)); if (!empty($run->parentrun)) { $this->setParentToHandle($run->parentrun, $this->runid); } } $preProcess = $this->processid - 1; if ($preProcess) { if ($flow->isFree() || $flow->isFixed() && $process->gathernode != self::FORCE) { $this->setProcessDone($preProcess); } } if ($flow->isFixed() && $process->timeout != 0) { if ($runProcess->flag == self::UN_RECEIVE && $this->processid !== 1) { $processBegin = FlowRunProcess::model()->fetchDeliverTime($this->runid, $preProcess); } else { $processBegin = $runProcess->processtime ? $runProcess->processtime : TIMESTAMP; } $timeUsed = TIMESTAMP - $processBegin; } $viewer = new ICFlowFormViewer(array("flow" => $flow, "form" => $flow->getForm(), "run" => $run, "process" => $process, "rp" => $runProcess)); $data = array_merge(array("flow" => $flow->toArray(), "run" => $run->toArray(), "process" => !empty($process) ? $process->toArray() : $process, "checkItem" => $checkitem, "prcscache" => WfCommonUtil::loadProcessCache($this->flowid), "rp" => $runProcess->toArray(), "rpcache" => WfPreviewUtil::getViewFlowData($this->runid, $this->flowid, $this->uid, $remindUid), "fbSigned" => $this->isFeedBackSigned(), "allowBack" => isset($isAllowBack) ? $isAllowBack : false, "timeUsed" => isset($timeUsed) ? $timeUsed : 0, "uploadConfig" => AttachUtil::getUploadConfig()), $viewer->render(true, false, true)); $formdata = array("run" => $data["run"], "flow" => $data["flow"], "enableArr" => "", "valueArr" => "", "emptyArr" => ""); $data["enablefiled"] = array(); if (is_array($data["model"]["itemData"])) { if (isset($data["prcscache"][$data["rp"]["flowprocess"]]["processitem"])) { $enableFiled = explode(",", $data["prcscache"][$data["rp"]["flowprocess"]]["processitem"]); } else { $enableFiled = array(); } foreach ($data["model"]["itemData"] as $k => $v) { if (substr($k, 0, 5) != "data_") { continue; } $data["model"]["structure"][$k]["value"] = $v; if (in_array($data["model"]["structure"][$k]["data-title"], $enableFiled)) { $data["enablefiled"][] = $k; $data["model"]["structure"][$k]["value"] = $data["model"]["eleout"][$k]; $formdata["enableArr"][] = $data["model"]["structure"][$k]; continue; } if ($v != "") { $formdata["valueArr"][] = $data["model"]["structure"][$k]; continue; } $formdata["emptyArr"][] = $data["model"]["structure"][$k]; } } $data["model"] = $this->renderPartial("application.modules.mobile.views.work.form", $formdata, true); $data["model"] .= "<input type=\"hidden\" name=\"key\" value=\"" . $this->key . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"hidden\" value=\"" . $data["hidden"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"readonly\" value=\"" . $data["readonly"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"attachmentid\" id=\"attachmentid\" value=\"" . $data["run"]["attachmentid"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"fbattachmentid\" id=\"fbattachmentid\" value=\"\">"; $data["model"] .= "<input type=\"hidden\" name=\"topflag\" value=\"" . $data["rp"]["opflag"] . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"saveflag\">"; $data["model"] .= "<input type=\"hidden\" name=\"formhash\" value=\"" . FORMHASH . "\">"; $data["model"] .= "<input type=\"hidden\" name=\"enablefiled\" value=\"" . implode(",", $data["enablefiled"]) . "\">"; if ($this->isEnabledAttachment($flow, $run, $process, $runProcess)) { $data["allowAttach"] = true; if (!empty($run->attachmentid)) { $attachPurv = $this->getAttachPriv($flow, $process, $runProcess); $down = $attachPurv["down"]; $edit = $attachPurv["edit"]; $del = $attachPurv["del"]; $data["attachData"] = AttachUtil::getAttach($run->attachmentid, $down, $down, $edit, $del); } } else { $data["allowAttach"] = false; } if ($flow->isFixed() && $process->feedback != 1) { $data["allowFeedback"] = true; $data["feedback"] = WfHandleUtil::loadFeedback($flow->getID(), $run->getID(), $flow->type, $this->uid); } else { $data["allowFeedback"] = false; } if ($flow->isFree() && $runProcess->opflag == "1") { $hasDefault = FlowRunProcess::model()->getHasDefaultStep($this->runid, $this->processid); if (!$hasDefault) { $data["defaultEnd"] = true; } } if ($flow->isFree() && $runProcess->topflag == "2") { if (!$hasOtherOPUser) { $data["otherEnd"] = true; } } $this->ajaxReturn($data, "JSONP"); } }
private function remind() { if (Ibos::app()->request->isAjaxRequest) { $date = EnvUtil::getRequest("date"); $dateTime = strtotime($date); $getUids = trim(EnvUtil::getRequest("uids"), ","); $uidArr = explode(",", $getUids); $uid = Ibos::app()->user->uid; if (empty($uidArr)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("No user to remind"))); } foreach ($uidArr as $subUid) { if (!UserUtil::checkIsSub($uid, $subUid)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("No permission to remind"))); } } $dashboardConfig = $this->getDiaryConfig(); $config = array("{name}" => User::model()->fetchRealnameByUid($uid), "{title}" => Ibos::lang("Remind title", "", array("y" => date("Y", $dateTime), "m" => date("m", $dateTime), "d" => date("d", $dateTime))), "{content}" => $dashboardConfig["remindcontent"]); if (0 < count($uidArr)) { Notify::model()->sendNotify($uidArr, "diary_message", $config, $uid); } $todayTime = strtotime(date("Y-m-d")); MainUtil::setCookie("reminded_" . $dateTime, md5($dateTime), $todayTime + 24 * 60 * 60 - TIMESTAMP); $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Remind succeed"))); } }
protected function complete($runId, $processId, $opflag = 1, $topflag = 0, $inajax = 0, $flowProcess = "", $op = "") { $flowType = FlowRun::model()->fetchFlowTypeByRunId($runId); if ($opflag || $op == "manage") { $pidNext = $processId + 1; if (FlowRunProcess::model()->getHasDefaultStep($runId, $pidNext)) { if ($op != "manage") { if ($inajax) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Subsequent default steps in the process"))); } else { $this->error(Ibos::lang("Subsequent default steps in the process"), $this->createUrl("list/index")); } } else { FlowRunProcess::model()->deleteByIDScope($runId, $pidNext); } } if ($op != "manage") { FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND uid = %d", $runId, $processId, $this->uid)); } else { FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND delivertime = 0", $runId)); FlowRunProcess::model()->updateAll(array("processtime" => TIMESTAMP), sprintf("runid = %d AND processtime = 0", $runId)); } FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), "runid = {$runId}"); FlowRun::model()->modify($runId, array("endtime" => TIMESTAMP)); $content = $op != "manage" ? Ibos::lang("Form endflow") : Ibos::app()->user->realname . Ibos::lang("Forced end process"); WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content); $parentRun = FlowRun::model()->fetchParentByRunID($runId); if ($parentRun != 0) { $parentFlowId = FlowRun::model()->fetchFlowIdByRunId($parentRun); $temp = FlowRunProcess::model()->fetchIDByChild($parentRun, $runId); if ($temp) { $parentProcessId = $temp["processid"]; $parentFlowprocess = $temp["flowprocess"]; } $parentProcess = FlowProcess::model()->fetchProcess($parentFlowId, $parentFlowprocess); if ($parentProcess) { $prcsBack = $parentProcess["processto"]; $backUserOp = $parentProcess["autouserop"]; $backUser = $parentProcess["autouser"]; } FlowRunProcess::model()->updateToOver($parentRun, $parentProcessId, $parentFlowprocess); if ($prcsBack != "") { $parentProcessIdNew = $parentProcessId + 1; $data = array("runid" => $parentRun, "processid" => $parentProcessIdNew, "uid" => $backUserOp, "flag" => 1, "flowprocess" => $prcsBack, "opflag" => 1, "topflag" => 0, "parent" => $parentFlowprocess); FlowRunProcess::model()->add($data); $backUserArr = explode(",", $backUser); for ($k = 0; $k < count($backUserArr); $k++) { if ($backUserArr[$k] != "" && $backUserArr[$k] != $backUserOp) { $data = array("runid" => $parentRun, "processid" => $parentProcessIdNew, "uid" => $backUserArr[$k], "flag" => 1, "flowprocess" => $prcsBack, "opflag" => 0, "topflag" => 0, "parent" => $parentFlowprocess); FlowRunProcess::model()->add($data); } } } elseif (!FlowRunProcess::model()->getIsNotOver($parentRun)) { FlowRun::model()->modify($parentRun, array("endtime" => TIMESTAMP)); } } $flag = EnvUtil::getRequest("flag"); if ($flowType == 2 && $flag != 1) { $inajax && $this->ajaxReturn(array("isSuccess" => true)); $this->redirect($this->createUrl("list/index")); } $inajax && $this->ajaxReturn(array("isSuccess" => true)); } else { $flowId = FlowRun::model()->fetchFlowIDByRunID($runId); if ($topflag == 2) { if (!FlowRunProcess::model()->getHasOtherOPUser($runId, $processId, $flowProcess, $this->uid)) { if (is_null($flowProcess) || $flowProcess == "0") { $turnpage = "showNextFree"; } else { $turnpage = "showNext"; } $param = array("flowid" => $flowId, "processid" => $processId, "flowprocess" => $flowProcess, "runid" => $runId); $url = $this->createUrl("handle/" . $turnpage, array("key" => WfCommonUtil::param($param), "topflag" => $topflag)); $this->ajaxReturn(array("status" => 2, "url" => $url)); } } $con = sprintf("runid = %d AND processid = %d AND uid = %d", $runId, $processId, $this->uid); if ($flowProcess !== "" && $flowProcess !== "0") { $con .= " AND flowprocess = " . $flowProcess; } FlowRunProcess::model()->updateAll(array("flag" => "4", "delivertime" => TIMESTAMP), $con); if (!FlowRunProcess::model()->getHasOtherAgentNotDone($runId, $processId)) { $run = FlowRun::model()->fetchByPk($runId); $uid = FlowRunProcess::model()->fetchNotDoneOpuser($runId, $processId); if ($uid) { $param = array("runid" => $runId, "flowid" => $flowId, "processid" => $processId, "flowprocess" => $flowProcess); $config = array("{runname}" => $run["name"], "{url}" => Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param($param)))); Notify::model()->sendNotify($uid, "workflow_sign_notice", $config); } } MainUtil::setCookie("flow_complete_flag", 1, 30); $url = Ibos::app()->urlManager->createUrl("workflow/list/index", array("op" => "list", "type" => "trans", "sort" => "all")); $this->redirect($url); } }
public function handleCheckUpgrade($event) { if (!Ibos::app()->user->isGuest && Ibos::app()->user->isadministrator) { $upgrade = Ibos::app()->setting->get("setting/upgrade"); if (!empty($upgrade)) { Ibos::app()->setting->set("newversion", 1); } $cookie = Ibos::app()->setting->get("cookie"); $needUpgrade = isset($cookie["checkupgrade"]); if ($needUpgrade) { $checkReturn = upgradeUtil::checkUpgrade(); Ibos::app()->setting->set("newversion", $checkReturn ? 1 : 0); MainUtil::setCookie("checkupgrade", 1, 7200); } } }
public function actionSendRemind() { if (EnvUtil::submitCheck("formhash")) { $toId = $_POST["toid"]; $runId = intval($_POST["runid"]); $message = StringUtil::filterCleanHtml($_POST["message"]); Notify::model()->sendNotify($toId, "workflow_todo_remind", array("{message}" => $message)); MainUtil::setCookie("workflow_todo_remind_" . $runId, 1, 60); $this->ajaxReturn(array("isSuccess" => true)); } }
$properties = array("company_id" => $cid, "company_token" => $imCfg["token"], "app_id" => $imCfg["appid"], "client_ip" => EnvUtil::getClientIp()); $api = new BQQApi($properties); $status = $api->getVerifyStatus(array("open_id" => $openId, "hashskey" => $hashskey)); if ($status["ret"] == 0) { $config = @(include PATH_ROOT . "/system/config/config.php"); if (empty($config)) { throw new Exception(Ibos::Lang("Config not found", "error")); } else { define("IN_MOBILE", EnvUtil::checkInMobile()); $global = array("clientip" => EnvUtil::getClientIp(), "config" => $config, "timestamp" => time()); Ibos::app()->setting->copyFrom($global); handleloadsyscache(); $saltkey = MainUtil::getCookie("saltkey"); if (empty($saltkey)) { $saltkey = StringUtil::random(8); MainUtil::setCookie("saltkey", $saltkey, 86400 * 30, 1, 1); } $curUser = User::model()->fetchByUid($uid); $identity = new ICUserIdentity($curUser["username"], $curUser["password"]); $identity->setId($uid); $identity->setPersistentStates($curUser); $ip = Ibos::app()->setting->get("clientip"); foreach ($_COOKIE as $k => $v) { $cookiePath = $config["cookie"]["cookiepath"]; $cookieDomain = $config["cookie"]["cookiedomain"]; $secure = $_SERVER["SERVER_PORT"] == 443 ? 1 : 0; @setcookie($k, "", time() - 86400, $cookiePath, $cookieDomain, $secure, false); } $account = Ibos::app()->setting->get("setting/account"); $user = Ibos::app()->user; if ($account["allowshare"] != 1) {
private function guideNextTime() { $uid = Ibos::app()->user->uid; MainUtil::setCookie("guideNextTime", md5($uid)); }