Exemplo n.º 1
0
 public function put($uid, $module = "weibo", $type = "", $data = array(), $rowid = 0, $table = "feed", $extUid = null, $lessUids = null, $isAtMe = true, $isRepost = 0)
 {
     if (!$uid || $type == "") {
         $this->addError("putFeed", Ibos::lang("Operation failure", "message"));
         return false;
     }
     if (!in_array($type, array("post", "repost", "postimage"))) {
         $type = "post";
     }
     if (!ModuleUtil::getIsEnabled($module)) {
         $module = "weibo";
         $type = "post";
         $table = "feed";
     }
     $table = strtolower($table);
     $data["uid"] = $uid;
     $data["module"] = $module;
     $data["type"] = $type;
     $data["rowid"] = $rowid;
     $data["table"] = $table;
     $data["ctime"] = time();
     $data["from"] = isset($data["from"]) ? intval($data["from"]) : EnvUtil::getVisitorClient();
     $data["isdel"] = $data["commentcount"] = $data["diggcount"] = $data["repostcount"] = 0;
     $data["isrepost"] = $isRepost;
     $content = $this->formatFeedContent($data["body"]);
     $data["body"] = $content["body"];
     $data["content"] = $content["content"];
     $data["body"] .= isset($data["source_url"]) ? $data["source_url"] : "";
     $data["content"] .= isset($data["source_url"]) ? $data["source_url"] : "";
     $feedId = $this->add($data, true);
     if (!$feedId) {
         return false;
     }
     $data["content"] = str_replace(chr(31), "", $data["content"]);
     $data["body"] = str_replace(chr(31), "", $data["body"]);
     $feedData = array("feedid" => $feedId, "feeddata" => serialize($data), "clientip" => EnvUtil::getClientIp(), "feedcontent" => $data["body"]);
     $feedDataId = FeedData::model()->add($feedData, true);
     if ($feedId && $feedDataId) {
         if ($data["isrepost"] == 1) {
             if ($isAtMe) {
                 $content = $data["content"];
             } else {
                 $content = $data["body"];
             }
             $extUid[] = isset($data["sourceInfo"]["transpond_data"]) ? $data["sourceInfo"]["transpond_data"]["uid"] : null;
             if ($isAtMe && !empty($data["curid"])) {
                 $appRowData = $this->get($data["curid"]);
                 $extUid[] = $appRowData["uid"];
             }
         } else {
             $content = $data["content"];
             Atme::model()->updateRecentAt($content);
         }
         Atme::model()->addAtme("weibo", "feed", $content, $feedId, $extUid, $lessUids);
         $data["clientip"] = EnvUtil::getClientIp();
         $data["feedid"] = $feedId;
         $data["feeddata"] = serialize($data);
         $return = $this->setFeedCache($data);
         $return["user_info"] = User::model()->fetchByUid($uid);
         $return["feedid"] = $feedId;
         $return["rowid"] = $data["rowid"];
         if ($module == "weibo") {
             UserData::model()->updateKey("feed_count", 1);
             UserData::model()->updateKey("weibo_count", 1);
         }
         return $return;
     } else {
         $this->addError("putFeed", Ibos::lang("Operation failure", "message"));
         return false;
     }
 }