Beispiel #1
0
 public function deleteWeiboJoinTopic($feedId)
 {
     $del["feedid"] = $feedId;
     $topicId = $this->getDbConnection()->createCommand()->select("topicid")->from("{{feed_topic_link}}")->where("feedid = " . intval($feedId))->queryScalar();
     if ($topicId) {
         FeedTopicLink::model()->deleteAllByAttributes($del);
         $this->updateCounters(array("count" => 1), "topicid = " . intval($topicId));
         $recommend = $this->getDbConnection()->createCommand()->select("recommend")->from($this->tableName())->where("topicid = " . $topicId)->queryScalar();
         if ($recommend == 1) {
             CacheUtil::rm("feed_topic_recommend");
         }
     }
 }
Beispiel #2
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;
 }