public function addDigg($feedId, $uid) { $data["feedid"] = $feedId; $data["uid"] = $uid; $data["uid"] = !$data["uid"] ? Ibos::app()->user->uid : $data["uid"]; if (!$data["uid"]) { $this->addError("addDigg", "未登录不能赞"); return false; } $isExit = $this->getIsExists($feedId, $uid); if ($isExit) { $this->addError("addDigg", "你已经赞过"); return false; } $data["ctime"] = time(); $res = $this->add($data); if ($res) { $feed = Source::getSourceInfo("feed", $feedId); Feed::model()->updateCounters(array("diggcount" => 1), "feedid = " . $feedId); Feed::model()->cleanCache($feedId); $user = User::model()->fetchByUid($uid); $config["{user}"] = $user["realname"]; $config["{sourceContent}"] = StringUtil::filterCleanHtml($feed["source_body"]); $config["{sourceContent}"] = str_replace("◆", "", $config["{sourceContent}"]); $config["{sourceContent}"] = StringUtil::cutStr($config["{sourceContent}"], 34); $config["{url}"] = $feed["source_url"]; $config["{content}"] = Ibos::app()->getController()->renderPartial("application.modules.message.views.remindcontent", array("recentFeeds" => Feed::model()->getRecentFeeds()), true); Notify::model()->sendNotify($feed["uid"], "message_digg", $config); UserUtil::updateCreditByAction("diggweibo", $uid); UserUtil::updateCreditByAction("diggedweibo", $feed["uid"]); } return $res; }
public function setFocus($setFocus, $runId, $uid) { $run = $this->fetchByPk(intval($runId)); $focusUser = $run["focususer"]; if ($setFocus) { if (StringUtil::findIn($focusUser, $uid)) { return false; } else { $focusUser = array_unique(array_merge(array($uid), !empty($focusUser) ? explode(",", $focusUser) : array())); $allUser = FlowRunProcess::model()->fetchAllUidByRunId($runId); if (!empty($allUser)) { $config = array("{runName}" => $run["name"], "{userName}" => User::model()->fetchRealNameByUid($uid)); Notify::model()->sendNotify($allUser, "workflow_focus_notice", $config); } } } elseif (!StringUtil::findIn($focusUser, $uid)) { return false; } else { $userPart = explode(",", $focusUser); $index = array_search($uid, $userPart); if (is_int($index)) { unset($userPart[$index]); } $focusUser = $userPart; } return $this->modify($runId, array("focususer" => implode(",", $focusUser))); }
public function actionSetup() { $formSubmit = EnvUtil::submitCheck("formhash"); if ($formSubmit) { $data =& $_POST; foreach (array("sendemail", "sendsms", "sendmessage") as $field) { if (!empty($data[$field])) { $ids = array_keys($data[$field]); $idstr = implode(",", $ids); Notify::model()->updateAll(array($field => 1), sprintf("FIND_IN_SET(id,'%s')", $idstr)); Notify::model()->updateAll(array($field => 0), sprintf("NOT FIND_IN_SET(id,'%s')", $idstr)); } else { Notify::model()->updateAll(array($field => 0)); } } CacheUtil::update("NotifyNode"); $this->success(Ibos::lang("Save succeed", "message")); } else { $nodeList = Notify::model()->getNodeList(); foreach ($nodeList as &$node) { $node["moduleName"] = Module::model()->fetchNameByModule($node["module"]); } $this->render("setup", array("nodeList" => $nodeList)); } }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $this->setPageTitle('通知'); $type = Yii::app()->request->getQuery('type'); $type_arr = Notify::model()->type_arr; $user = new User(); $notifys = array(); $uid = Yii::app()->user->id; $model = new Notify(); //初始化 $criteria = new CDbCriteria(); $criteria->order = 'ctime'; $criteria->condition = "t.uid=:uid"; $criteria->params = array(':uid' => $uid); if (!array_key_exists($type, $type_arr)) { $type = 'all'; } if ($type != 'all') { $condition = "cate = '{$cate}'"; $criteria->addCondition($condition); } //取得数据总数,分页显示 $total = $model->count($criteria); $pages = new CPagination($total); $pages->pageSize = 20; $pages->applyLimit($criteria); //获取数据集 $notifys = $model->findAll($criteria); $data = array('type' => $type, 'type_arr' => $type_arr, 'notifys' => $notifys, 'user' => $user, 'pages' => $pages); $this->render('index', $data); }
public function readNotify($array) { $criteria = new CDbCriteria(); foreach ($array as $id) { $criteria->addCondition('id=' . (int) $id, 'OR'); } Notify::model()->updateAll(array('read' => Notify::READ), $criteria); }
public function send($bodyId, $bodyData, $inboxId = EmailBaseController::INBOX_ID) { $toids = $bodyData["toids"] . "," . $bodyData["copytoids"] . "," . $bodyData["secrettoids"]; $toid = StringUtil::filterStr($toids); foreach (explode(",", $toid) as $uid) { $email = array("toid" => $uid, "fid" => $inboxId, "bodyid" => $bodyId); $newId = $this->add($email, true); $config = array("{sender}" => Ibos::app()->user->realname, "{subject}" => $bodyData["subject"], "{url}" => Ibos::app()->urlManager->createUrl("email/content/show", array("id" => $newId)), "{content}" => Ibos::app()->getController()->renderPartial("application.modules.email.views.remindcontent", array("body" => $bodyData), true)); Notify::model()->sendNotify($uid, "email_message", $config); } }
public function actionNotifications($id = 0, $action = '') { if ($id) { $notify = Notify::model()->findByPK($id); if (!$notify) { throw new CHttpException(404, Yii::t('errors', 'Wrong notify')); } elseif ($action) { if ($notify->status == 2 || $notify->status == 3) { throw new CHttpException(404, Yii::t('errors', 'Status already set')); } if ($notify->shared_id) { $cam = Shared::model()->findByPK($notify->shared_id); if (!$cam) { $notify->delete(); throw new CHttpException(404, Yii::t('errors', 'Wrong cam')); } } else { $notify->delete(); throw new CHttpException(404, Yii::t('errors', 'Wrong cam')); } $n = new Notify(); $id = Yii::app()->user->getId(); if ($action == 'approve') { //TODO specify user and cam $n->note(Yii::t('user', 'User approve shared cam'), array($id, $notify->creator_id, 0)); $cam->is_approved = 1; $cam->save(); $notify->status = 2; $notify->save(); } elseif ($action == 'disapprove') { $n->note(Yii::t('user', 'User decline shared cam'), array($id, $notify->creator_id, 0)); $cam->is_approved = 0; $cam->save(); $notify->status = 3; $notify->save(); } else { throw new CHttpException(404, Yii::t('errors', 'Wrong action')); } } else { throw new CHttpException(404, Yii::t('errors', 'Wrong action')); } } $new = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => 1)); $old = Notify::model()->findAllByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => array(0, 2, 3)), array('order' => 'time DESC')); foreach ($new as $notify) { if ($notify->shared_id == 0) { $notify->status = 0; $notify->save(); } } $this->render('notify', array('new' => $new, 'old' => $old)); }
public function addComment($data, $forApi = false, $notCount = false, $lessUids = null) { $add = $this->escapeData($data); if ($add["content"] === "") { $this->addError("comment", Ibos::lang("Required comment content", "message.default")); return false; } $add["isdel"] = 0; $res = $this->add($add, true); if ($res) { isset($data["touid"]) && !empty($data["touid"]) && ($lessUids[] = intval($data["touid"])); $scream = explode("//", $data["content"]); Atme::model()->addAtme("message", "comment", trim($scream[0]), $res, null, $lessUids); $table = ucfirst($add["table"]); $pk = $table::model()->getTableSchema()->primaryKey; $table::model()->updateCounters(array("commentcount" => 1), "`{$pk}` = {$add["rowid"]}"); if (Ibos::app()->user->uid != $add["moduleuid"] && $add["moduleuid"] != "") { !$notCount && UserData::model()->updateKey("unread_comment", 1, true, $add["moduleuid"]); } if (!empty($add["touid"]) && $add["touid"] != Ibos::app()->user->uid && $add["touid"] != $add["moduleuid"]) { !$notCount && UserData::model()->updateKey("unread_comment", 1, true, $add["touid"]); } if ($add["table"] == "feed") { if (Ibos::app()->user->uid != $add["uid"]) { UserUtil::updateCreditByAction("addcomment", Ibos::app()->user->uid); UserUtil::updateCreditByAction("getcomment", $data["moduleuid"]); } Feed::model()->cleanCache($add["rowid"]); } if ($add["touid"] != Ibos::app()->user->uid || $add["moduleuid"] != Ibos::app()->user->uid && $add["moduleuid"] != "") { $author = User::model()->fetchByUid(Ibos::app()->user->uid); $config["{name}"] = $author["realname"]; $sourceInfo = Source::getCommentSource($add, $forApi); $config["{url}"] = $sourceInfo["source_url"]; $config["{sourceContent}"] = StringUtil::parseHtml($sourceInfo["source_content"]); if (!empty($add["touid"])) { $config["{commentType}"] = "回复了我的评论:"; Notify::model()->sendNotify($add["touid"], "comment", $config); } else { $config["{commentType}"] = "评论了我的微博:"; if (!empty($add["moduleuid"])) { Notify::model()->sendNotify($add["moduleuid"], "comment", $config); } } } } return $res; }
/** * @param $notify_id * @param $user_id * @param int $status_id * @return bool|NotifyStatus */ public static function changeReadStatus($notify_id, $user_id, $status_id = Notify::READ) { $notify = Notify::model()->exists('id=:id', ['id' => $notify_id]); if (!$notify || (int) $user_id <= 0) { return false; } $status = self::model()->findByAttributes(['notify_id' => $notify_id, 'user_id' => (int) $user_id]); if (!$status) { $status = new self(); $status->notify_id = $notify_id; $status->user_id = $user_id; } $status->read_status = $status_id == Notify::READ || $status_id == Notify::NOT_READ ? $status_id : Notify::READ; if ($status->save()) { return $status; } else { return false; } }
public function actionGetUserNotify($email) { header("Content-Type: text/xml"); $performer = 9; $notify = Notify::model()->findAll(array('condition' => 'performer_id=:performer_id', 'limit' => '3', 'params' => array(':performer_id' => $performer))); $dom = new domDocument("1.0", "cp1251"); // Создаём XML-документ версии 1.0 с кодировкой utf-8 $root = $dom->createElement("notifys"); // Создаём корневой элемент $dom->appendChild($root); foreach ($notify as $n) { $notify = $dom->createElement("notify"); $header = $dom->createElement("header", $n->header); $description = $dom->createElement("description", strip_tags($n->description)); $link = $dom->createElement("link", Notify::getCreateXmlUrl($n->route, $n->route_params)); $notify->appendChild($header); $notify->appendChild($description); $notify->appendChild($link); $root->appendChild($notify); } $import = simplexml_import_dom($dom); echo $import->asXML(); }
public function actionAdd() { if (!Ibos::app()->request->getIsAjaxRequest()) { $this->error(IBos::lang("Parameters error", "error"), $this->createUrl("schedule/index")); } if (!$this->checkAddPermission()) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("No permission to add schedule"))); } $getStartTime = EnvUtil::getRequest("CalendarStartTime"); $sTime = empty($getStartTime) ? date("y-m-d h:i", time()) : $getStartTime; $getEndTime = EnvUtil::getRequest("CalendarEndTime"); $eTime = empty($getEndTime) ? date("y-m-d h:i", time()) : $getEndTime; $getTitle = EnvUtil::getRequest("CalendarTitle"); $title = empty($getTitle) ? "" : $getTitle; if ($this->uid != $this->upuid) { $title .= " (" . User::model()->fetchRealnameByUid($this->upuid) . ")"; } $getIsAllDayEvent = EnvUtil::getRequest("IsAllDayEvent"); $isAllDayEvent = empty($getIsAllDayEvent) ? 0 : intval($getIsAllDayEvent); $getCategory = EnvUtil::getRequest("Category"); $category = empty($getCategory) ? -1 : $getCategory; $schedule = array("uid" => $this->uid, "subject" => $title, "starttime" => CalendarUtil::js2PhpTime($sTime), "endtime" => CalendarUtil::js2PhpTime($eTime), "isalldayevent" => $isAllDayEvent, "category" => $category, "uptime" => time(), "upuid" => $this->upuid); $addId = Calendars::model()->add($schedule, true); if ($addId) { $ret["isSuccess"] = true; $ret["msg"] = "success"; $ret["data"] = intval($addId); if ($this->upuid != $this->uid) { $config = array("{sender}" => User::model()->fetchRealnameByUid($this->upuid), "{subject}" => $title, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($this->uid, "add_calendar_message", $config, $this->upuid); } } else { $ret["isSuccess"] = false; $ret["msg"] = "fail"; } $this->ajaxReturn($ret); }
public function doFollow($uid, $fid) { if (intval($uid) <= 0 || $fid <= 0) { $this->addError("doFollow", Ibos::lang("Parameters error", "error")); return false; } if ($uid == $fid) { $this->addError("doFollow", Ibos::lang("Following myself forbidden", "message.default")); return false; } if (!User::model()->fetchByUid($fid)) { $this->addError("doFollow", Ibos::lang("Following people noexist", "message.default")); return false; } $followState = $this->getFollowState($uid, $fid); if (0 == $followState["following"]) { $map["uid"] = $uid; $map["fid"] = $fid; $map["ctime"] = time(); $result = $this->add($map); $user = User::model()->fetchByUid($uid); $config = array("{user}" => $user["realname"], "{url}" => Ibos::app()->urlManager->createUrl("weibo/personal/follower")); Notify::model()->sendNotify($fid, "user_follow", $config); if ($result) { $this->addError("doFollow", Ibos::lang("Add follow success", "message.default")); $this->_updateFollowCount($uid, $fid, true); $followState["following"] = 1; return $followState; } else { $this->addError("doFollow", Ibos::lang("Add follow fail", "message.default")); return false; } } else { $this->addError("doFollow", Ibos::lang("Following", "message.default")); return false; } }
public function actionAdd() { if (EnvUtil::submitCheck("formhash")) { if (!$this->checkTaskPermission()) { $this->error(Ibos::lang("No permission to add task"), $this->createUrl("task/index")); } foreach ($_POST as $key => $value) { $_POST[$key] = StringUtil::filterCleanHtml($value); } $_POST["upuid"] = $this->upuid; $_POST["uid"] = $this->uid; $_POST["addtime"] = time(); if (!isset($_POST["pid"])) { $count = Tasks::model()->count("pid=:pid", array(":pid" => "")); $_POST["sort"] = $count + 1; } Tasks::model()->add($_POST, true); if ($this->upuid != $this->uid) { $config = array("{sender}" => User::model()->fetchRealnameByUid($this->upuid), "{subject}" => $_POST["text"], "{url}" => Ibos::app()->urlManager->createUrl("calendar/task/index")); Notify::model()->sendNotify($this->uid, "task_message", $config, $this->upuid); } $this->ajaxReturn(array("isSuccess" => true)); } }
private function save() { if (EnvUtil::submitCheck("formhash")) { $postData = $_POST; $uid = Ibos::app()->user->uid; $postData["uid"] = $uid; $postData["subject"] = StringUtil::filterCleanHtml($_POST["subject"]); $toidArr = StringUtil::getId($postData["toid"]); $postData["toid"] = implode(",", $toidArr); $postData["begindate"] = strtotime($postData["begindate"]); $postData["enddate"] = strtotime($postData["enddate"]); $reportData = ICReport::handleSaveData($postData); $repid = Report::model()->add($reportData, true); if ($repid) { if (!empty($postData["attachmentid"])) { AttachUtil::updateAttach($postData["attachmentid"]); } $orgPlan = $outSidePlan = array(); if (array_key_exists("orgPlan", $_POST)) { $orgPlan = $_POST["orgPlan"]; } if (!empty($orgPlan)) { foreach ($orgPlan as $recordid => $val) { $updateData = array("process" => intval($val["process"]), "exedetail" => StringUtil::filterCleanHtml($val["exedetail"])); if ($updateData["process"] == self::COMPLETE_FALG) { $updateData["flag"] = 1; } ReportRecord::model()->modify($recordid, $updateData); } } if (array_key_exists("outSidePlan", $_POST)) { $outSidePlan = array_filter($_POST["outSidePlan"], create_function("\$v", "return !empty(\$v[\"content\"]);")); } if (!empty($outSidePlan)) { ReportRecord::model()->addPlans($outSidePlan, $repid, $postData["begindate"], $postData["enddate"], $uid, 1); } $nextPlan = array_filter($_POST["nextPlan"], create_function("\$v", "return !empty(\$v[\"content\"]);")); ReportRecord::model()->addPlans($nextPlan, $repid, strtotime($_POST["planBegindate"]), strtotime($_POST["planEnddate"]), $uid, 2); $wbconf = WbCommonUtil::getSetting(true); if (isset($wbconf["wbmovement"]["report"]) && $wbconf["wbmovement"]["report"] == 1) { $userid = $postData["toid"]; $supUid = UserUtil::getSupUid($uid); if (0 < intval($supUid) && !in_array($supUid, explode(",", $userid))) { $userid = $userid . "," . $supUid; } $data = array("title" => Ibos::lang("Feed title", "", array("{subject}" => $postData["subject"], "{url}" => Ibos::app()->urlManager->createUrl("report/review/show", array("repid" => $repid)))), "body" => StringUtil::cutStr($_POST["content"], 140), "actdesc" => Ibos::lang("Post report"), "userid" => trim($userid, ","), "deptid" => "", "positionid" => ""); WbfeedUtil::pushFeed($uid, "report", "report", $repid, $data); } UserUtil::updateCreditByAction("addreport", $uid); if (!empty($toidArr)) { $config = array("{sender}" => User::model()->fetchRealnameByUid($uid), "{subject}" => $reportData["subject"], "{url}" => Ibos::app()->urlManager->createUrl("report/review/show", array("repid" => $repid))); Notify::model()->sendNotify($toidArr, "report_message", $config, $uid); } $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("default/index")); } else { $this->error(Ibos::lang("Save faild", "message"), $this->createUrl("default/index")); } } }
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); } }
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); }
protected function getRemind() { $user = $this->getUser(); $user["remindsetting"] = !empty($user["remindsetting"]) ? unserialize($user["remindsetting"]) : array(); $nodeList = Notify::model()->getNodeList(); $apiOpen = CloudApi::getInstance()->isOpen(); foreach ($nodeList as $id => &$node) { $node["moduleName"] = Module::model()->fetchNameByModule($node["module"]); $node["appdisabled"] = !$apiOpen ? 1 : 0; $node["maildisabled"] = $user["validationemail"] == 0 || !$node["sendemail"] ? 1 : 0; $node["smsdisabled"] = $user["validationmobile"] == 0 || !$node["sendsms"] ? 1 : 0; if (empty($user["remindsetting"])) { $node["emailcheck"] = $node["smscheck"] = $node["appcheck"] = 1; } elseif (isset($user["remindsetting"][$id])) { $node["appcheck"] = isset($user["remindsetting"][$id]["app"]) ? $user["remindsetting"][$id]["app"] : 0; $node["emailcheck"] = isset($user["remindsetting"][$id]["email"]) ? $user["remindsetting"][$id]["email"] : 0; $node["smscheck"] = isset($user["remindsetting"][$id]["sms"]) ? $user["remindsetting"][$id]["sms"] : 0; } else { $node["emailcheck"] = $node["smscheck"] = $node["appcheck"] = 0; } } return array("nodeList" => $nodeList); }
public static function createNewRun($flowId, $uid, $uidstr, $pid = 0, $remind = 0, $startTime = "") { if (!$startTime) { $startTime = TIMESTAMP; } $flow = new ICFlowType(intval($flowId)); $runName = self::replaceAutoName($flow, $uid, !!$pid); $maxRunId = FlowRun::model()->getMaxRunId(); if ($maxRunId) { $runId = $maxRunId + 1; } $data = array("runid" => $runId, "name" => $runName, "flowid" => $flowId, "beginuser" => $uid, "begintime" => $startTime, "parentrun" => $pid); FlowRun::model()->add($data); if (strstr($runName, "{RUN}") !== false) { $runName = str_replace("{RUN}", $runId, $runName); FlowRun::model()->modify($runId, array("name" => $runName)); } foreach (explode(",", trim($uidstr, ",")) as $k => $v) { if ($v == $uid) { $opflag = 1; } else { $opflag = 0; } $wrpdata = array("runid" => $runId, "processid" => 1, "uid" => $v, "flag" => 1, "flowprocess" => 1, "opflag" => $opflag, "createtime" => $startTime); FlowRunProcess::model()->add($wrpdata); } if ($remind) { $remindUrl = Ibos::app()->urlManager->createUrl("workflow/form/index", array("key" => WfCommonUtil::param(array("runid" => $runId, "flowid" => $flowId, "processid" => 1, "flowprocess" => 1)))); $config = array("{url}" => $remindUrl, "{runname}" => $runName, "{runid}" => $runId); Notify::model()->sendNotify($uid, "workflow_new_notice", $config); } if ($pid != 0) { $pflowId = FlowRun::model()->fetchFlowIdByRunId($pid); $pRundata = WfHandleUtil::getRunData($pid); $pfield = $subFlow = array(); $relation = FlowProcess::model()->fetchRelationOut($pflowId, $flowId); if ($relation) { $relationArr = explode(",", trim($relation, ",")); foreach ($relationArr as $field) { $pfield[] = substr($field, 0, strpos($field, "=>")); $subFlow[] = substr($field, strpos($field, "=>") + strlen("=>")); } } $runData = array("runid" => $runId, "name" => $runName, "begin" => $startTime, "beginuser" => $uid); } $structure = $flow->form->parser->structure; if (is_array($structure) && 0 < count($structure)) { foreach ($structure as $k => $v) { if ($v["data-type"] !== "label") { if ($v["data-type"] == "checkbox") { if (stristr($v["content"], "checked") || stristr($v["content"], " checked=\"checked\"")) { $itemData = "on"; } else { $itemData = ""; } } if ($v["data-type"] != "select" && $v["data-type"] != "listview") { $itemData = isset($v["data-value"]) ? $v["data-value"] : ""; $itemData = str_replace("\"", "", $itemData); if ($v["data-type"] == "auto") { $itemData = ""; } } if ($pid != 0 && in_array($v["data-title"], $subFlow)) { $i = array_search($v["data-title"], $subFlow); $ptitle = $pfield[$i]; $itemData = $pRundata["{$ptitle}"]; if (is_array($itemData) && $v["data-type"] == "listview") { $itemDataStr = ""; $newDataStr = ""; for ($j = 1; $j < count($itemData); ++$j) { foreach ($itemData[$j] as $val) { $newDataStr .= $val . "`"; } $itemDataStr .= $newDataStr . "\r\n"; $newDataStr = ""; } $itemData = $itemDataStr; } } $runData[$k] = $itemData; } } } WfCommonUtil::addRunData($flowId, $runData, $structure); return $runId; }
private function save() { $uid = Ibos::app()->user->uid; $realname = User::model()->fetchRealnameByUid($uid); $originalPlan = $planOutside = array(); 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)); } } $date = $_POST["todayDate"] . " " . Ibos::lang("Weekday", "date") . DateTimeUtil::getWeekDay(strtotime($_POST["todayDate"])); $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" => ""); if (!empty($_POST["attachmentid"])) { AttachUtil::updateAttach($_POST["attachmentid"]); } $diary["attachmentid"] = $_POST["attachmentid"]; $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"); $wbconf = WbCommonUtil::getSetting(true); if (isset($wbconf["wbmovement"]["diary"]) && $wbconf["wbmovement"]["diary"] == 1) { $supUid = UserUtil::getSupUid($uid); if (0 < intval($supUid)) { $data = array("title" => Ibos::lang("Feed title", "", array("{subject}" => $realname . " " . $date . " " . Ibos::lang("Work diary"), "{url}" => Ibos::app()->urlManager->createUrl("diary/review/show", array("diaryid" => $diaryId)))), "body" => StringUtil::cutStr($diary["content"], 140), "actdesc" => Ibos::lang("Post diary"), "userid" => $supUid, "deptid" => "", "positionid" => ""); WbfeedUtil::pushFeed($uid, "diary", "diary", $diaryId, $data); } } UserUtil::updateCreditByAction("adddiary", $uid); $upUid = UserUtil::getSupUid($uid); if (!empty($upUid)) { $config = array("{sender}" => User::model()->fetchRealnameByUid($uid), "{title}" => Ibos::lang("New diary title", "", array("{sub}" => $realname, "{date}" => $date)), "{content}" => $this->renderPartial("remindcontent", array("realname" => $realname, "date" => $date, "lang" => Ibos::getLangSources(), "originalPlan" => array_values($originalPlan), "planOutside" => array_values($planOutside), "content" => StringUtil::cutStr(strip_tags($_POST["diaryContent"]), 200), "plantime" => $_POST["plantime"] . " " . Ibos::lang("Weekday", "date") . DateTimeUtil::getWeekDay(strtotime($_POST["plantime"])), "plan" => array_values($plan)), true), "{url}" => Ibos::app()->urlManager->createUrl("diary/review/show", array("diaryid" => $diaryId))); Notify::model()->sendNotify($upUid, "diary_message", $config, $uid); } $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("default/index")); }
public function actionTurnNextPost() { $runId = $_GET["runid"]; $flowId = $_GET["flowid"]; $processId = $_GET["processid"]; $flowProcess = $_GET["flowprocess"]; $topflag = isset($_GET["topflag"]) ? $_GET["topflag"] : null; $this->nextAccessCheck($topflag, $runId, $processId); $plugin = FlowProcess::model()->fetchTurnPlugin($flowId, $flowProcess); if ($plugin) { $pluginFile = "./system/modules/workflow/plugins/turn/" . $plugin; if (file_exists($pluginFile)) { include_once $pluginFile; } } $prcsTo = $_GET["processto"]; $prcsToArr = explode(",", trim($prcsTo, ",")); $prcsChooseArr = $_GET["prcs_choose"]; $prcsChoose = implode($prcsChooseArr, ","); $message = $_GET["message"]; $toId = $nextId = $beginUserId = $toallId = ""; $ext = array("{url}" => Ibos::app()->urlManager->createUrl("workflow/list/index", array("op" => "category")), "{message}" => $message); if (isset($_GET["remind"][1])) { $nextId = ""; if (isset($_GET["prcs_user_op"])) { $nextId = intval($_GET["prcs_user_op"]); } else { foreach ($prcsChooseArr as $k => $v) { if (isset($_GET["prcs_user_op" . $k])) { $nextId .= $_GET["prcs_user_op" . $k] . ","; } } $nextId = trim($nextId, ","); } } if (isset($_GET["remind"][2])) { $beginuser = FlowRunProcess::model()->fetchAllOPUid($runId, 1, true); if ($beginuser) { $beginUserId = StringUtil::wrapId($beginuser[0]["uid"]); } } if (isset($_GET["remind"]["3"])) { $toallId = ""; if (isset($_GET["prcs_user"])) { $toallId = filter_input(INPUT_POST, "prcs_user", FILTER_SANITIZE_STRING); } else { foreach ($prcsChooseArr as $k => $v) { if (isset($_GET["prcs_user" . $k])) { $toallId .= filter_input(INPUT_POST, "prcs_user" . $k, FILTER_SANITIZE_STRING); } } } } $idstr = $nextId . "," . $beginUserId . "," . $toallId; $toId = StringUtil::filterStr($idstr); if ($toId) { Notify::model()->sendNotify($toId, "workflow_turn_notice", $ext); } if ($prcsChoose == "") { $prcsUserOp = isset($_GET["prcs_user_op"]) ? intval($_GET["prcs_user_op"]) : ""; $prcsUser = isset($_GET["prcs_user"]) ? $_GET["prcs_user"] : ""; $run = FlowRun::model()->fetchByPk($runId); if ($run) { $pId = $run["parentrun"]; $runName = $run["name"]; } FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND processid = %d AND flowprocess = %d", $runId, $processId, $flowProcess)); FlowRunProcess::model()->updateAll(array("flag" => FlowConst::PRCS_DONE), sprintf("runid = %d AND flag = 3", $runId)); FlowRunProcess::model()->updateAll(array("delivertime" => TIMESTAMP), sprintf("runid = %d AND processid = %d AND flowprocess = %d AND uid = %d", $runId, $processId, $flowProcess, $this->uid)); $isUnique = FlowRunProcess::model()->getIsUnique($runId); if (!$isUnique) { FlowRun::model()->modify($runId, array("endtime" => TIMESTAMP)); } if ($pId != 0) { $parentflowId = FlowRun::model()->fetchFlowIdByRunId($pId); $parentFormId = FlowType::model()->fetchFormIDByFlowID($parentflowId); $parentPrcs = FlowRunProcess::model()->fetchIDByChild($pId, $runId); if ($parentPrcs) { $parentPrcsId = $parentPrcs["processid"]; $parentFlowProcess = $parentPrcs["flowprocess"]; } $parentProcess = FlowProcess::model()->fetchProcess($parentflowId, $parentPrcsId); if ($parentProcess["relationout"] !== "") { $relationArr = explode(",", trim($parentProcess["relationout"], ",")); $src = $des = $set = array(); foreach ($relationArr as $field) { $src[] = substr($field, 0, strpos($field, "=>")); $des[] = substr($field, strpos($field, "=>") + strlen("=>")); } $runData = WfHandleUtil::getRunData($runId); $form = new ICFlowForm($parentFormId); $structure = $form->parser->structure; foreach ($structure as $k => $v) { if ($v["data-type"] !== "label" && in_array($v["data-title"], $des)) { $i = array_search($v["data-title"], $des); $ptitle = $src[$i]; $itemData = $runData[$ptitle]; if (is_array($itemData) && $v["data-type"] == "listview") { $itemDataStr = ""; $newDataStr = ""; for ($j = 1; $j < count($itemData); ++$j) { foreach ($itemData[$i] as $val) { $newDataStr .= $val . "`"; } $itemDataStr .= $newDataStr . "\r\n"; $newDataStr = ""; } $itemData = $itemDataStr; } $field = "data_" . $v["itemid"]; $set[$field] = $itemData; } } if (!empty($set)) { FlowDataN::model()->update($parentflowId, $pId, $set); } } WfHandleUtil::updateParentOver($runId, $pId); $prcsBack = $_GET["prcsback"] . ""; if ($prcsBack != "") { $parentPrcsIdNew = $parentPrcsId + 1; $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $prcsUserOp, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 1, "topflag" => 0, "parent" => $parentFlowProcess); FlowRunProcess::model()->add($data); foreach (explode(",", trim($prcsUser, ",")) as $k => $v) { if ($v != $prcsUserOp && !empty($v)) { $data = array("runid" => $pId, "processid" => $parentPrcsIdNew, "uid" => $v, "flag" => "1", "flowprocess" => $prcsBack, "opflag" => 0, "topflag" => 0, "parent" => $parentFlowProcess); FlowRunProcess::model()->add($data); } } $parentRunName = FlowRun::model()->fetchNameByRunID($pId); $content = "[{$runName}]" . Ibos::lang("Log return the parent process") . ":[{$parentRunName}]"; WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content); FlowRun::model()->modify($pId, array("endtime" => null)); } } $content = Ibos::lang("Form endflow"); WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content); } else { $freeother = FlowType::model()->fetchFreeOtherByFlowID($flowId); $prcsChooseArrCount = count($prcsChooseArr); for ($i = 0; $i < $prcsChooseArrCount; $i++) { $flowPrcsNext = $prcsToArr[$prcsChooseArr[$i]]; $prcsIdNew = $processId + 1; $str = "prcs_user_op" . $prcsChooseArr[$i]; $prcsUserOp = $_GET[$str]; if (empty($prcsUserOp)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => "必须选择主办人"), "JSONP"); exit; } if ($freeother == 2) { $prcsUserOp = WfHandleUtil::turnOther($prcsUserOp, $flowId, $runId, $processId, $flowProcess); } $str = "prcs_user" . $prcsChooseArr[$i]; $prcsUser = explode(",", $_GET[$str]); array_push($prcsUser, $prcsUserOp); $prcsUser = implode(",", array_unique($prcsUser)); if ($freeother == 2) { $prcsUser = WfHandleUtil::turnOther($prcsUser, $flowId, $runId, $processId, $flowProcess, $prcsUserOp); } $str = "topflag" . $prcsChooseArr[$i]; $topflag = intval($_GET[$str]); $fp = FlowProcess::model()->fetchProcess($flowId, $flowPrcsNext); if ($fp["childflow"] == 0) { $_topflag = FlowRunProcess::model()->fetchTopflag($runId, $prcsIdNew, $flowPrcsNext); if ($_topflag) { $topflag = $_topflag; } $isOpHandle = FlowRunProcess::model()->getIsOpOnTurn($runId, $prcsIdNew, $flowPrcsNext); if ($isOpHandle) { $prcsUserOp = ""; $t_flag = 1; } else { $t_flag = 0; } foreach (explode(",", trim($prcsUser)) as $k => $v) { if ($v == $prcsUserOp || $topflag == 1) { $opflag = 1; } else { $opflag = 0; } if ($topflag == 2) { $opflag = 0; } $workedId = FlowRunProcess::model()->fetchProcessIDOnTurn($runId, $prcsIdNew, $flowPrcsNext, $v, $fp["gathernode"]); if (!$workedId) { $wrp = FlowRunProcess::model()->fetchRunProcess($runId, $processId, $flowProcess, $this->uid); if ($wrp) { $otherUser = $wrp["otheruser"] != "" ? $wrp["otheruser"] : ""; } else { $otherUser = ""; } $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $v, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => $opflag, "topflag" => $topflag, "parent" => $flowProcess, "createtime" => TIMESTAMP, "otheruser" => $otherUser); FlowRunProcess::model()->add($data); } else { if ($prcsIdNew < $workedId) { $prcsIdNew = $workedId; } $lastPrcsId = $workedId; FlowRunProcess::model()->updateTurn($flowProcess, $prcsIdNew, $runId, $lastPrcsId, $flowPrcsNext, $v); } } if ($t_flag == 1) { FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess); } else { FlowRunProcess::model()->updateToTrans($runId, $processId, $flowProcess); } $userNameStr = User::model()->fetchRealnamesByUids($prcsUser); $content = Ibos::lang("To the steps") . $prcsIdNew . "," . Ibos::lang("Transactor") . ":" . $userNameStr; WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content); } else { $runidNew = WfNewUtil::createNewRun($fp["childflow"], $prcsUserOp, $prcsUser, $runId); $data = array("runid" => $runId, "processid" => $prcsIdNew, "uid" => $prcsUserOp, "flag" => 1, "flowprocess" => $flowPrcsNext, "opflag" => 1, "topflag" => 0, "parent" => $flowProcess, "childrun" => $runidNew, "createtime" => TIMESTAMP); FlowRunProcess::model()->add($data); FlowRunProcess::model()->updateToOver($runId, $processId, $flowProcess); $content = Ibos::lang("Log new subflow") . $runidNew; WfCommonUtil::runlog($runId, $processId, $flowProcess, $this->uid, 1, $content); } } } $this->ajaxReturn(array("isSuccess" => true), "JSONP"); }
<?php Nav::model()->deleteAllByAttributes(array("module" => "workflow")); Notify::model()->deleteAllByAttributes(array("module" => "workflow")); NotifyMessage::model()->deleteAllByAttributes(array("module" => "workflow")); CacheUtil::set("notifyNode", null); Node::model()->deleteAllByAttributes(array("module" => "workflow")); NodeRelated::model()->deleteAllByAttributes(array("module" => "workflow")); AuthItem::model()->deleteAll("name LIKE 'workflow%'"); AuthItemChild::model()->deleteAll("child LIKE 'workflow%'"); MenuCommon::model()->deleteAllByAttributes(array("module" => "workflow")); $settingFields = "wfremindbefore,wfremindafter,sealfrom"; Setting::model()->deleteAll("FIND_IN_SET(skey,'{$settingFields}')"); Menu::model()->deleteAllByAttributes(array("m" => "workflow")); Nav::model()->deleteAllByAttributes(array("module" => "workflow")); Node::model()->deleteAllByAttributes(array("module" => "workflow")); NodeRelated::model()->deleteAllByAttributes(array("module" => "workflow")); AuthItem::model()->deleteAll("name LIKE 'workflow%'"); AuthItemChild::model()->deleteAll("child LIKE 'workflow%'"); $db = Ibos::app()->db->createCommand(); $prefix = $db->getConnection()->tablePrefix; $tables = $db->setText("SHOW TABLES LIKE '" . str_replace("_", "\\_", $prefix . "flow_data_%") . "'")->queryAll(false); foreach ($tables as $table) { $tableName = $table[0]; !empty($tableName) && $db->dropTable($tableName); }
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)); } }
<?php $row = cron::model()->fetch(array("select" => "`lastrun`,`nextrun`", "condition" => "filename = :filename", "params" => array(":filename" => basename(__FILE__)))); $clist = Calendars::model()->listCalendarByRange($row["lastrun"], $row["nextrun"] + 86400 * 3); foreach ($clist["events"] as $calendar) { if ($calendar["isalldayevent"] == 1) { $start_date = date("Y-m-d", $calendar["starttime"]); $remind_date_min = $start_date . " 07:59:00"; $remind_date_max = $start_date . " 10:01:00"; $remind_time_min = strtotime($remind_date_min); $remind_time_max = strtotime($remind_date_max); if ($remind_time_min < time() && time() < $remind_time_max) { $stime = date("m-d", $calendar["starttime"]); $title = $stime . "全天日程"; $subject = StringUtil::cutStr($calendar["subject"], 20); $config = array("{subject}" => $subject, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($calendar["uid"], "calendar_message", $config); } } elseif ($calendar["starttime"] <= $row["nextrun"]) { $stime = date("m-d H:i", $calendar["starttime"]); $etime = date("m-d H:i", $calendar["endtime"]); $title = $stime . " 至 " . $etime . "日程"; $subject = StringUtil::cutStr($calendar["subject"], 20); $config = array("{subject}" => $subject, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($calendar["uid"], "calendar_message", $config); } }
public function actionMark() { $op = EnvUtil::getRequest("op"); $opList = array("todo", "read", "unread", "sendreceipt", "cancelreceipt", "del", "restore", "batchdel", "move"); if (!in_array($op, $opList)) { exit; } $ids = EnvUtil::getRequest("emailids"); $id = StringUtil::filterStr($ids); $extends = array(); $condition = "toid = " . $this->uid . " AND FIND_IN_SET(emailid,\"" . $id . "\")"; $valueDriver = array("read" => array("isread", 1), "unread" => array("isread", 0), "sendreceipt" => array("isreceipt", 1), "cancelreceipt" => array("isreceipt", 2), "restore" => array("isdel", 0)); switch ($op) { case "del": case "batchdel": if ($op == "del") { $next = Email::model()->fetchNext($id, $this->uid, $this->fid, $this->archiveId); if (!empty($next)) { $extends["url"] = $this->createUrl("content/show", array("id" => $next["emailid"], "archiveid" => $this->archiveId)); } else { $extends["url"] = $this->createUrl("list/index"); } } $status = Email::model()->setField("isdel", 3, $condition); break; case "move": $fid = intval(EnvUtil::getRequest("fid")); $status = Email::model()->updateAll(array("fid" => $fid, "isdel" => 0), $condition); break; case "todo": $markFlag = EnvUtil::getRequest("ismark"); $ismark = strcasecmp($markFlag, "true") == 0 ? 1 : 0; $status = Email::model()->setField("ismark", $ismark, $condition); break; case "sendreceipt": $fromInfo = Ibos::app()->db->createCommand()->select("eb.bodyid,eb.subject,eb.fromid")->from("{{email_body}} eb")->leftJoin("{{email}} e", "e.bodyid = eb.bodyid")->where("e.emailid = " . intval($id))->queryRow(); if ($fromInfo) { $config = array("{reader}" => Ibos::app()->user->realname, "{url}" => Ibos::app()->urlManager->createUrl("email/content/show", array("id" => $fromInfo["bodyid"])), "{title}" => $fromInfo["subject"]); Notify::model()->sendNotify($fromInfo["fromid"], "email_receive_message", $config); } default: if (isset($valueDriver[$op])) { $value = $valueDriver[$op][1][0]; $valueDriver; $status = Email::model()->setField($key, $value, $condition); } else { $status = false; } break; } $errorMsg = !$status ? Ibos::lang("Operation failure", "message") : ""; $this->ajaxReturn(array_merge(array("isSuccess" => !!$status, "errorMsg" => $errorMsg), $extends)); }
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"))); } }
private function back() { $uid = Ibos::app()->user->uid; $artIds = trim(EnvUtil::getRequest("articleids"), ","); $reason = StringUtil::filterCleanHtml(EnvUtil::getRequest("reason")); $ids = explode(",", $artIds); if (empty($ids)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Parameters error", "error"))); } $sender = User::model()->fetchRealnameByUid($uid); foreach ($ids as $artId) { $art = Article::model()->fetchByPk($artId); $categoryName = ArticleCategory::model()->fetchCateNameByCatid($art["catid"]); if (!$this->checkIsApprovaler($art, $uid)) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You do not have permission to verify the article"))); } $config = array("{sender}" => $sender, "{subject}" => $art["subject"], "{category}" => $categoryName, "{content}" => $reason, "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("type" => "notallow"))); Notify::model()->sendNotify($art["author"], "article_back_message", $config, $uid); ArticleBack::model()->addBack($artId, $uid, $reason, TIMESTAMP); } $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message"))); }
public function checkUserGroup($uid) { $uid = intval($uid); $user = User::model()->fetchByUid($uid); if (empty($user)) { return 0; } $credits = $this->countCredit($uid, false); $updateArray = array(); $groupId = $user["groupid"]; if (0 < $user["groupid"]) { $group = UserGroup::model()->fetchByPk($user["groupid"]); } else { $group = array(); } if ($user["credits"] != $credits) { $updateArray["credits"] = $credits; $user["credits"] = $credits; } $user["credits"] = $user["credits"] == "" ? 0 : $user["credits"]; $sendNotify = false; if (empty($group) || !($group["creditshigher"] <= $user["credits"]) && $user["credits"] < $group["creditslower"]) { $newGroup = UserGroup::model()->fetchByCredits($user["credits"]); if (!empty($newGroup)) { if ($user["groupid"] != $newGroup["gid"]) { $updateArray["groupid"] = $groupId = $newGroup["gid"]; $sendNotify = true; } } } if ($updateArray) { User::model()->modify($uid, $updateArray); UserUtil::cleanCache($uid); } if ($sendNotify) { Notify::model()->sendNotify($uid, "user_group_upgrade", array("{groupname}" => $newGroup["title"], "{url}" => Ibos::app()->urlManager->createUrl("user/home/credit", array("op" => "level", "uid" => $uid)))); } return $groupId; }
public function handleNode($event) { CacheUtil::set("notifyNode", NULL); Notify::model()->getNodeList(); }
</li>--> </ul> </li> <?php } ?> <li> <a href="<?php echo $this->createUrl('users/notifications'); ?> "> <?php echo Yii::t('menu', 'Notifications'); ?> <span class="badge"><?php echo Notify::model()->countByAttributes(array('dest_id' => Yii::app()->user->getId(), 'status' => 1)); ?> </span> </a> </li> <?php if (Yii::app()->user->permissions == 2 || Yii::app()->user->permissions == 3) { ?> <li><?php echo CHtml::link(Yii::t('menu', 'Cams'), $this->createUrl('cams/manage')); ?> </li> <?php } ?> <li class="dropdown">
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); } }