Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public function actionShare()
 {
     if (empty($_GET["curid"])) {
         $map["feedid"] = EnvUtil::getRequest("sid");
     } else {
         $map["feedid"] = EnvUtil::getRequest("curid");
     }
     $map["isdel"] = 0;
     $isExist = Feed::model()->countByAttributes($map);
     if ($isExist == 0) {
         $return["isSuccess"] = false;
         $return["data"] = "内容已被删除,转发失败";
         $this->ajaxReturn($return);
     }
     $return = Feed::model()->shareFeed($_GET, "share");
     if ($return["isSuccess"]) {
         $module = $_GET["module"];
         if ($module == "weibo") {
             UserUtil::updateCreditByAction("forwardweibo", Ibos::app()->user->uid);
             $suid = Ibos::app()->db->createCommand()->select("uid")->from("{{feed}}")->where(sprintf("feedid = %d AND isdel = 0", $map["feedid"]))->queryScalar();
             $suid && UserUtil::updateCreditByAction("forwardedweibo", $suid);
         }
     }
     $this->ajaxReturn($return, "JSONP");
 }
Esempio n. 3
0
 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));
         }
     }
 }
Esempio n. 4
0
 private function save()
 {
     $data = ICResumeDetail::processAddRequestData();
     $resume = array("input" => Ibos::app()->user->uid, "positionid" => $data["positionid"], "entrytime" => TIMESTAMP, "uptime" => TIMESTAMP, "status" => $data["status"], "statustime" => strtotime(date("Y-m-d")));
     $resumeId = Resume::model()->add($resume, true);
     if ($resumeId) {
         $data["resumeid"] = $resumeId;
         $data["birthday"] = strtotime($data["birthday"]);
         ResumeDetail::model()->add($data);
         if (!empty($data["avatarid"])) {
             AttachUtil::updateAttach($data["avatarid"]);
         }
         if (!empty($data["attachmentid"])) {
             AttachUtil::updateAttach($data["attachmentid"]);
         }
         $uid = Ibos::app()->user->uid;
         UserUtil::updateCreditByAction("addresume", $uid);
         $this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("resume/index"));
     }
 }
Esempio n. 5
0
 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"));
         }
     }
 }
Esempio n. 6
0
 public function actionSave()
 {
     $uid = Ibos::app()->user->uid;
     $originalPlan = $planOutside = "";
     if (array_key_exists("originalPlan", $_POST)) {
         $originalPlan = $_POST["originalPlan"];
     }
     if (array_key_exists("planOutside", $_POST)) {
         $planOutside = array_filter($_POST["planOutside"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
     }
     if (!empty($originalPlan)) {
         foreach ($originalPlan as $key => $value) {
             DiaryRecord::model()->modify($key, array("schedule" => $value));
         }
     }
     $shareUidArr = isset($_POST["shareuid"]) ? StringUtil::getId($_POST["shareuid"]) : array();
     $diary = array("uid" => $uid, "diarytime" => strtotime($_POST["todayDate"]), "nextdiarytime" => strtotime($_POST["plantime"]), "addtime" => TIMESTAMP, "content" => $_POST["diaryContent"], "shareuid" => implode(",", $shareUidArr), "readeruid" => "", "remark" => "", "attention" => "");
     $diaryId = Diary::model()->add($diary, true);
     if (!empty($planOutside)) {
         DiaryRecord::model()->addRecord($planOutside, $diaryId, strtotime($_POST["todayDate"]), $uid, "outside");
     }
     $plan = array_filter($_POST["plan"], create_function("\$v", "return !empty(\$v[\"content\"]);"));
     DiaryRecord::model()->addRecord($plan, $diaryId, strtotime($_POST["plantime"]), $uid, "new");
     UserUtil::updateCreditByAction("adddiary", $uid);
     $this->ajaxReturn($diaryId, "JSONP");
 }
Esempio n. 7
0
 public static function runlog($runId, $processId, $flowProcess, $uid, $logtype, $content, $toid = "")
 {
     $userip = EnvUtil::getClientIp();
     $run = new ICFlowRun($runId);
     $data = array("runid" => $runId, "runname" => $run->name, "flowid" => $run->flowid, "processid" => $processId, "flowprocess" => $flowProcess, "uid" => $uid, "time" => TIMESTAMP, "type" => $logtype, "ip" => $userip, "content" => $content, "toid" => $toid);
     if (FlowRunLog::model()->add($data)) {
         UserUtil::updateCreditByAction("wfnextpost", $uid);
         return true;
     }
     return false;
 }
Esempio n. 8
0
 public function actionShareFeed()
 {
     if (EnvUtil::submitCheck("formhash")) {
         $post = $_POST;
         foreach ($post as $key => $val) {
             $post[$key] = StringUtil::filterCleanHtml($post[$key]);
         }
         if (empty($post["curid"])) {
             $map["feedid"] = $post["sid"];
         } else {
             $map["feedid"] = $post["curid"];
         }
         $map["isdel"] = 0;
         $isExist = Feed::model()->countByAttributes($map);
         if ($isExist == 0) {
             $return["isSuccess"] = false;
             $return["data"] = "内容已被删除,转发失败";
             $this->ajaxReturn($return);
         }
         $return = Feed::model()->shareFeed($post, "share");
         if ($return["isSuccess"]) {
             $module = $post["module"];
             if ($module == "weibo") {
                 UserUtil::updateCreditByAction("forwardweibo", Ibos::app()->user->uid);
                 $suid = Ibos::app()->db->createCommand()->select("uid")->from("{{feed}}")->where(sprintf("feedid = %d AND isdel = 0", $map["feedid"]))->queryScalar();
                 $suid && UserUtil::updateCreditByAction("forwardedweibo", $suid);
             }
             $lang = Ibos::getLangSources();
             $return["data"] = $this->renderPartial("feedlist", array("list" => array($return["data"]), "lang" => $lang), true);
         }
         $this->ajaxReturn($return);
     }
 }
Esempio n. 9
0
 private function verifyComplete($artId, $uid)
 {
     Article::model()->updateAllStatusAndApproverByPks($artId, $uid, 1);
     ArticleApproval::model()->deleteAll("articleid={$artId}");
     $article = Article::model()->fetchByPk($artId);
     if (!empty($article)) {
         $wbconf = WbCommonUtil::getSetting(true);
         if (isset($wbconf["wbmovement"]["article"]) && $wbconf["wbmovement"]["article"] == 1) {
             $publishScope = array("deptid" => $article["deptid"], "positionid" => $article["positionid"], "uid" => $article["uid"]);
             $data = array("title" => Ibos::lang("Feed title", "", array("{subject}" => $article["subject"], "{url}" => Ibos::app()->urlManager->createUrl("article/default/index", array("op" => "show", "articleid" => $article["articleid"])))), "body" => $article["content"], "actdesc" => Ibos::lang("Post news"), "userid" => $publishScope["uid"], "deptid" => $publishScope["deptid"], "positionid" => $publishScope["positionid"]);
             if ($article["type"] == self::ARTICLE_TYPE_PICTURE) {
                 $type = "postimage";
                 $picture = ArticlePicture::model()->fetchByAttributes(array("articleid" => $article["articleid"]));
                 $data["attach_id"] = $picture["aid"];
             } else {
                 $type = "post";
             }
             WbfeedUtil::pushFeed($article["author"], "article", "article", $article["articleid"], $data, $type);
         }
         UserUtil::updateCreditByAction("addarticle", $article["author"]);
     }
 }
Esempio n. 10
0
 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"));
 }
Esempio n. 11
0
 private function updateToWeibo($data, $sourceInfo, $lessUids)
 {
     $commentInfo = Source::getSourceInfo($data["table"], $data["rowid"], false, $data["module"]);
     $oldInfo = isset($commentInfo["sourceInfo"]) ? $commentInfo["sourceInfo"] : $commentInfo;
     $arr = array("post", "postimage");
     $scream = "";
     if (!in_array($sourceInfo["type"], $arr)) {
         $scream = "//@" . $commentInfo["source_user_info"]["realname"] . ":" . $commentInfo["source_content"];
     }
     if (!empty($data["tocid"])) {
         $replyInfo = Comment::model()->getCommentInfo($data["tocid"], false);
         $replyScream = "//@" . $replyInfo["user_info"]["realname"] . " :";
         $data["content"] .= $replyScream . $replyInfo["content"];
     }
     $s["body"] = $data["content"] . $scream;
     $s["curid"] = null;
     $s["sid"] = $oldInfo["source_id"];
     $s["module"] = $oldInfo["module"];
     $s["type"] = $oldInfo["source_table"];
     $s["comment"] = 1;
     $s["comment_touid"] = $data["moduleuid"];
     if ($sourceInfo["type"] == "post" && empty($data["touid"])) {
         $lessUids[] = Ibos::app()->user->uid;
     }
     Feed::model()->shareFeed($s, "comment", $lessUids);
     UserUtil::updateCreditByAction("forwardedweibo", Ibos::app()->user->uid);
 }
Esempio n. 12
0
 private function save($bodyId, $bodyData)
 {
     if (!empty($bodyData["attachmentid"]) && $bodyId) {
         AttachUtil::updateAttach($bodyData["attachmentid"], $bodyId);
     }
     if ($bodyData["issend"]) {
         Email::model()->send($bodyId, $bodyData);
         if (!empty($bodyData["towebmail"])) {
             $toUsers = StringUtil::filterStr($bodyData["towebmail"], ";");
             if (!empty($toUsers)) {
                 $webBox = EmailWeb::model()->fetchByPk($bodyData["fromwebid"]);
                 WebMailUtil::sendWebMail($toUsers, $bodyData, $webBox);
             }
         }
         UserUtil::updateCreditByAction("postmail", $this->uid);
         $message = Ibos::lang("Send succeed");
     } else {
         $message = Ibos::lang("Save succeed", "message");
     }
     if (Yii::app()->request->getIsAjaxRequest()) {
         $this->ajaxReturn(array("isSuccess" => true, "messsage" => $message));
     } else {
         $this->success($message, $this->createUrl("list/index"));
     }
 }
Esempio n. 13
0
 private function updateVerify($op)
 {
     $uid = $this->getUid();
     $session = new CHttpSession();
     $session->open();
     $data = $session["verifyData"];
     if ($op == "email") {
         User::model()->updateByUid($uid, array("validationemail" => 1, "email" => $data));
     } elseif ($op == "mobile") {
         User::model()->updateByUid($uid, array("validationmobile" => 1, "mobile" => $data));
     }
     UserUtil::updateCreditByAction("verify" . $op, $this->getUid());
 }
Esempio n. 14
0
 private function verifyComplete($docid, $uid)
 {
     Officialdoc::model()->updateAllStatusByDocids($docid, 1, $uid);
     OfficialdocApproval::model()->deleteAll("docid={$docid}");
     $doc = Officialdoc::model()->fetchByPk($docid);
     if (!empty($doc)) {
         $wbconf = WbCommonUtil::getSetting(true);
         if (isset($wbconf["wbmovement"]["article"]) && $wbconf["wbmovement"]["article"] == 1) {
             $publishScope = array("deptid" => $doc["deptid"], "positionid" => $doc["positionid"], "uid" => $doc["uid"]);
             $data = array("title" => Ibos::lang("Feed title", "", array("{subject}" => $doc["subject"], "{url}" => Ibos::app()->urlManager->createUrl("officialdoc/officialdoc/show", array("docid" => $doc["docid"])))), "body" => $doc["content"], "actdesc" => Ibos::lang("Post officialdoc"), "userid" => $publishScope["uid"], "deptid" => $publishScope["deptid"], "positionid" => $publishScope["positionid"]);
             WbfeedUtil::pushFeed($doc["author"], "officialdoc", "officialdoc", $doc["docid"], $data);
         }
         UserUtil::updateCreditByAction("addofficialdoc", $doc["author"]);
     }
 }
Esempio n. 15
0
         $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) {
             $user->setStateKeyPrefix(Ibos::app()->setting->get("sid"));
         }
         $user->login($identity);
         $log = array("terminal" => "bqqsso", "password" => "", "ip" => $ip, "user" => $curUser["username"], "loginType" => $identity::LOGIN_BY_USERNAME, "address" => "", "gps" => "");
         Log::write($log, "login", sprintf("module.user.%d", $uid));
         $rule = UserUtil::updateCreditByAction("daylogin", $uid);
         if (!$rule["updateCredit"]) {
             UserUtil::checkUserGroup($uid);
         }
         if ($returnurl == "index") {
             header("Location: ../../index.php", true);
         } else {
             $url = parse_url($returnurl);
             if (isset($url["scheme"])) {
                 header("Location:" . $returnurl, true);
             } else {
                 header("Location:../../" . $returnurl, true);
             }
         }
     }
 } else {
Esempio n. 16
0
 public function deleteComment($ids, $uid = null, $module = "")
 {
     $ids = is_array($ids) ? $ids : explode(",", $ids);
     $map = array("and");
     $map[] = array("in", "cid", $ids);
     $comments = $this->getDbConnection()->createCommand()->select("cid,module,table,rowid,moduleuid,uid")->from($this->tableName())->where($map)->queryAll();
     if (empty($comments)) {
         return false;
     }
     foreach ($comments as $value) {
         Atme::model()->deleteAtme($value["table"], null, $value["cid"], null);
     }
     $_comments = array();
     foreach ($comments as $comment) {
         $_comments[$comment["table"]][$comment["rowid"]][] = $comment["cid"];
     }
     $cids = ConvertUtil::getSubByKey($comments, "cid");
     $res = $this->updateAll(array("isdel" => 1), "`cid` IN (" . implode(",", $cids) . ")");
     if ($res) {
         foreach ($_comments as $tableName => $rows) {
             foreach ($rows as $rowid => $cid) {
                 $_table = ucfirst($tableName);
                 $field = $_table::model()->getTableSchema()->primaryKey;
                 if (empty($field)) {
                     $field = $tableName . "id";
                 }
                 $_table::model()->updateCounters(array("commentcount" => -count($cid)), "`{$field}`={$rowid}");
                 if ($module == "weibo" || $module == "feed") {
                     $_table::model()->cleanCache($rowid);
                 }
             }
         }
         if ($uid) {
             UserUtil::updateCreditByAction("delcomment", $uid);
         }
     }
     $this->addError("deletecomment", $res != false ? Ibos::lang("Operation succeed", "message") : Ibos::lang("Operation failure", "message"));
     return $res;
 }
Esempio n. 17
0
 protected function toFinished($assignmentId)
 {
     $assignment = Assignment::model()->fetchByPk($assignmentId);
     $isDesigneeuid = $this->checkIsDesigneeuid($assignment["designeeuid"]);
     $isChargeuid = $this->checkIsChargeuid($assignment["chargeuid"]);
     if (!$isDesigneeuid && !$isChargeuid) {
         $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Only the sponsors or head have permission to complete")));
     }
     $updateSuccess = Assignment::model()->modify($assignmentId, array("status" => 2, "finishtime" => TIMESTAMP));
     if ($updateSuccess) {
         $this->sendNotify($assignmentId, $assignment["subject"], $assignment["designeeuid"], "assignment_finish_message");
         UserUtil::updateCreditByAction("finishassignment", Ibos::app()->user->uid);
         $this->addStepComment($assignmentId, Ibos::lang("Finish the assignment"));
         AssignmentLog::model()->addLog($assignmentId, "finish", Ibos::lang("Finish the assignment"));
         $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message")));
     } else {
         $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("The assignment has been completed")));
     }
 }
Esempio n. 18
0
 public function doEditFeed($feedid, $type, $uid = null)
 {
     $return = array("isSuccess" => false);
     if (empty($feedid)) {
     } else {
         $feedid = is_array($feedid) ? implode(",", $feedid) : intval($feedid);
         $con = sprintf("feedid = %d", $feedid);
         $isdel = $type == "delFeed" ? 1 : 0;
         if ($type == "deleteFeed") {
             $msg = array("user" => Ibos::app()->user->username, "ip" => EnvUtil::getClientIp(), "id" => $feedid, "value" => $this->get($feedid));
             Log::write($msg, "db", "module.weibo.deleteFeed");
             $res = $this->deleteAll($con);
             $res && $this->_deleteFeedAttach($feedid);
         } else {
             $ids = explode(",", $feedid);
             $feedList = $this->getFeeds($ids);
             $res = $this->updateAll(array("isdel" => $isdel), $con);
             if ($type == "feedRecover") {
                 foreach ($feedList as $v) {
                     UserData::model()->updateKey("feed_count", 1, true, $v["user_info"]["uid"]);
                     UserData::model()->updateKey("weibo_count", 1, true, $v["user_info"]["uid"]);
                 }
             } else {
                 foreach ($feedList as $v) {
                     UserData::model()->updateKey("feed_count", -1, false, $v["user_info"]["uid"]);
                     UserData::model()->updateKey("weibo_count", -1, false, $v["user_info"]["uid"]);
                 }
             }
             $this->cleanCache($ids);
             $query = $this->fetchAll(array("select" => "feedid", "condition" => sprintf("rowid = %d", $feedid)));
             $sids = ConvertUtil::getSubByKey($query, "feedid");
             $sids && $this->cleanCache($sids);
         }
         $commentQuery = $this->getDbConnection()->createCommand()->select("cid")->from("{{comment}}")->where(sprintf("`module` = 'weibo' AND `table` = 'feed' AND `rowid` = %d", $feedid))->queryAll();
         $commentIds = ConvertUtil::getSubByKey($commentQuery, "cid");
         $commentIds && Comment::model()->deleteComment($commentIds, null, "weibo");
         FeedTopic::model()->deleteWeiboJoinTopic($feedid);
         Atme::model()->deleteAtme("feed", null, $feedid);
         $topics = FeedTopicLink::model()->fetchAll(array("select" => "topicid", "condition" => "feedid=" . $feedid));
         $topicId = ConvertUtil::getSubByKey($topics, "topicid");
         $topicId && FeedTopic::model()->updateCounters(array("count" => -1), sprintf("FIND_IN_SET(topicid,'%s')", implode(",", $topicId)));
         FeedTopicLink::model()->deleteAll("feedid=" . $feedid);
         if ($res) {
             $return = array("isSuccess" => true);
             $uid && UserUtil::updateCreditByAction("deleteweibo", $uid);
         }
     }
     return $return;
 }