public static function hasView($feedid, $uid) { $feed = Feed::model()->get($feedid); $feedUser = User::model()->fetchByUid($feed["uid"]); $user = User::model()->fetchByUid($uid); if ($feed && $feed["view"] !== WbConst::SELF_VIEW_SCOPE) { $fuDeptIds = StringUtil::filterStr($feedUser["alldeptid"] . "," . $feedUser["alldowndeptid"]); $deptIds = StringUtil::filterStr($user["alldeptid"] . "," . $user["allupdeptid"]); if ($feed["view"] == WbConst::ALL_VIEW_SCOPE) { return true; } elseif ($feed["view"] == WbConst::SELFDEPT_VIEW_SCOPE) { if (StringUtil::findIn($fuDeptIds, $deptIds)) { return true; } } else { if (StringUtil::findIn($feed["userid"], $uid)) { return true; } if (StringUtil::findIn($feed["positionid"], $user["allposid"])) { return true; } if (StringUtil::findIn($fuDeptIds, $deptIds)) { return true; } } } return false; }
public function loadModel($id) { $model = Feed::model()->findByPk($id); if (null === $model) { throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.')); } return $model; }
private static function getInfoFromFeed($table, $rowId, $forApi) { $info = Feed::model()->getFeedInfo($rowId, $forApi); $info["source_user_info"] = User::model()->fetchByUid($info["uid"]); $info["source_user"] = $info["uid"] == Ibos::app()->user->uid ? Ibos::lang("Me", "message.default") : "<a href=\"" . $info["source_user_info"]["space_url"] . "\" class=\"anchor\" target=\"_blank\">" . $info["source_user_info"]["realname"] . "</a>"; $info["source_type"] = "微博"; $info["source_title"] = ""; $info["source_url"] = Ibos::app()->urlManager->createUrl("weibo/personal/feed", array("feedid" => $rowId, "uid" => $info["uid"])); $info["source_content"] = $info["content"]; $info["ctime"] = $info["ctime"]; return $info; }
public function actionIndex() { $userId = Yii::app()->user->id; $sql = "(select f.* from dxd_course_learn cl inner join dxd_course_feed cf on cl.courseId=cf.courseId inner join dxd_feed f on cf.feedid=f.id where cl.userId={$userId})" . "union (select f2.* from dxd_user_follow uf inner join dxd_user_feed ufd on uf.followed_userId=ufd.userId inner join dxd_feed f2 on ufd.feedid=f2.id where uf.follow_userId={$userId})" . ' order by addTime desc'; $feeds = Feed::model()->findAllBySql($sql); // $count=Yii::app()->db->createCommand($sql)->queryScalar(); /* $dataProvider =new CSqlDataProvider($sql,array('keyField'=>'id', 'totalItemCount'=>$count, 'pagination'=>array( 'pageSize'=>30, )));*/ $dataProvider = new CArrayDataProvider($feeds); $this->render('index', array('dataProvider' => $dataProvider)); }
public function actionManage() { $op = EnvUtil::getRequest("op"); if (EnvUtil::submitCheck("formhash")) { if (!in_array($op, array("delFeed", "deleteFeed", "feedRecover"))) { exit; } $ids = EnvUtil::getRequest("ids"); foreach (explode(",", $ids) as $id) { Feed::model()->doEditFeed($id, $op); } $this->ajaxReturn(array("isSuccess" => true)); } else { if (!in_array($op, array("list", "recycle"))) { $op = "list"; } $map = ""; if ($op == "list") { $map = "isdel = 0"; } else { $map = "isdel = 1"; } if (EnvUtil::getRequest("search")) { $key = StringUtil::filterCleanHtml(EnvUtil::getRequest("search")); $count = Feed::model()->countSearchFeeds($key); $inSearch = true; } else { $count = Feed::model()->count($map); $inSearch = false; } $pages = PageUtil::create($count); if ($inSearch) { $list = Feed::model()->searchFeeds($key, null, $pages->getLimit(), $pages->getOffset()); } else { $list = Feed::model()->getList($map, $pages->getLimit(), $pages->getOffset()); } $data = array("op" => $op, "list" => $list, "pages" => $pages, "moduleAssetUrl" => Ibos::app()->assetManager->getAssetsUrl("weibo")); $this->render("manage", $data); } }
public function actionAllowedlist() { $feedId = intval(EnvUtil::getRequest("feedid")); $feed = Feed::model()->getFeedInfo($feedId); if (!$feed) { exit("该条动态不存在"); } $list = array(); if ($feed["view"] == "1") { $list["users"] = Ibos::lang("My self"); } elseif (!empty($feed["userid"])) { $list["users"] = User::model()->fetchRealnamesByUids($feed["userid"]); } if (!empty($feed["deptid"])) { if ($feed["deptid"] == "alldept" || $feed["view"] == "0") { $list["dept"] = Ibos::lang("All dept"); } else { if ($feed["view"] == "2") { $deptIds = StringUtil::filterStr(Ibos::app()->user->alldeptid . "," . Ibos::app()->user->alldowndeptid); } else { $deptIds = $feed["deptid"]; } if (!empty($deptIds)) { $list["dept"] = Department::model()->fetchDeptNameByDeptId($deptIds); } else { $list["dept"] = ""; } } } if (!empty($feed["positionid"])) { $list["pos"] = Position::model()->fetchPosNameByPosId($feed["positionid"]); } $this->renderPartial("allowedlist", $list); }
public function delDigg($feedId, $uid) { $data["feedid"] = $feedId; $data["uid"] = $uid; $data["uid"] = !$data["uid"] ? Ibos::app()->user->uid : $data["uid"]; if (!$data["uid"]) { $this->addError("delDigg", "未登录不能取消赞"); return false; } $isExit = $this->getIsExists($feedId, $uid); if (!$isExit) { $this->addError("delDigg", "取消赞失败,您可能已取消过赞信息"); return false; } $res = $this->deleteAllByAttributes($data); if ($res) { Feed::model()->updateCounters(array("diggcount" => -1), "feedid=" . $feedId); Feed::model()->cleanCache($feedId); } return $res; }
protected function getData($var) { $data = array(); $type = isset($var["new"]) ? "new" . $var["type"] : $var["type"]; $where = "isdel = 0 AND uid = " . $this->getUid() . ($this->getIsMe() ? "" : " AND " . WbfeedUtil::getViewCondition(Ibos::app()->user->uid)); switch ($type) { case "all": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $loadId = isset($var["loadId"]) ? $var["loadId"] : 0; $list = Feed::model()->searchFeed($var["feedkey"], "all", $loadId, $var["nums"], $pages->getOffset(), "", $this->getUid()); $count = Feed::model()->countSearchAll($var["feedkey"], $loadId); } else { if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND type = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); $count = Feed::model()->count($where); } break; case "movement": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $loadId = isset($var["loadId"]) ? $var["loadId"] : 0; $list = Feed::model()->searchFeed($var["feedkey"], "movement", $loadId, $var["nums"], $pages->getOffset(), "", $this->getUid()); $count = Feed::model()->countSearchMovement($var["feedkey"], $loadId); } else { if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND module = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } else { $where .= " AND module != 'weibo'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); $count = Feed::model()->count($where); } break; case "newmovement": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d AND uid = %d", WbfeedUtil::getViewCondition(Ibos::app()->user->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $count = Feed::model()->count($where); $data["count"] = count($list); } break; case "newall": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 %s AND feedid > %d AND uid = %d", $this->getIsMe() ? "" : " AND " . WbfeedUtil::getViewCondition(Ibos::app()->user->uid), intval($var["maxId"]), $this->getUid()); $list = Feed::model()->getList($where); $count = Feed::model()->countFollowingFeed($where); $data["count"] = count($list); } break; default: break; } $count = isset($count) ? $count : WbConst::MAX_VIEW_FEED_NUMS; $pages = PageUtil::create($count, WbConst::DEF_LIST_FEED_NUMS); if (!isset($var["new"])) { $pages->route = "personal/index"; $currentUrl = (string) Ibos::app()->getRequest()->getUrl(); $replaceUrl = str_replace("weibo/personal/loadmore", "weibo/personal/index", $currentUrl); $data["pageData"] = $this->widget("IWPage", array("pages" => $pages, "currentUrl" => $replaceUrl), true); } if (!empty($list)) { $data["firstId"] = $list[0]["feedid"]; $data["lastId"] = $list[count($list) - 1]["feedid"]; $feedids = ConvertUtil::getSubByKey($list, "feedid"); $diggArr = FeedDigg::model()->checkIsDigg($feedids, $this->getUid()); foreach ($list as &$v) { switch ($v["module"]) { case "mobile": break; default: $v["from"] = EnvUtil::getFromClient($v["from"], $v["module"]); break; } } $data["html"] = $this->renderPartial("application.modules.message.views.feed.feedlist", array("list" => $list, "diggArr" => $diggArr), true); } else { $data["html"] = ""; $data["firstId"] = $data["lastId"] = 0; } return $data; }
protected function getData($var) { $data = array(); $type = isset($var["new"]) ? "new" . $var["type"] : $var["type"]; switch ($type) { case "following": $pages = PageUtil::create(1000, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "following", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a."); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND a.feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND a.type = '" . $var["feedtype"] . "'"; } $list = Feed::model()->getFollowingFeed($where, $var["nums"], $pages->getOffset()); } break; case "all": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "all", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND type = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); } break; case "movement": $pages = PageUtil::create(WbConst::MAX_VIEW_FEED_NUMS, WbConst::DEF_LIST_FEED_NUMS); if (!empty($var["feedkey"])) { $list = Feed::model()->searchFeed($var["feedkey"], "movement", $var["loadId"], $var["nums"], $pages->getOffset()); } else { $where = "isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid); if (isset($var["loadId"]) && 0 < $var["loadId"]) { $where .= " AND feedid < '" . intval($var["loadId"]) . "'"; } if (!empty($var["feedtype"]) && $var["feedtype"] !== "all") { $where .= " AND module = '" . StringUtil::filterCleanHtml($var["feedtype"]) . "'"; } else { $where .= " AND module != 'weibo'"; } $list = Feed::model()->getList($where, $var["nums"], $pages->getOffset()); } break; case "newmovement": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $data["count"] = count($list); } break; case "newfollowing": $where = "a.isdel = 0 AND " . WbfeedUtil::getViewCondition($this->uid, "a."); if (0 < $var["maxId"]) { $where .= " AND a.feedid > '" . intval($var["maxId"]) . "'"; $list = Feed::model()->getFollowingFeed($where); $data["count"] = count($list); } break; case "newall": if (0 < $var["maxId"]) { $where = sprintf("isdel = 0 AND %s AND feedid > %d AND uid <> %d", WbfeedUtil::getViewCondition($this->uid), intval($var["maxId"]), $this->uid); $list = Feed::model()->getList($where); $data["count"] = count($list); } break; default: break; } if (!isset($var["new"])) { $pages->route = "home/index"; } if (!empty($list)) { $data["firstId"] = $list[0]["feedid"]; $data["lastId"] = $list[count($list) - 1]["feedid"]; $feedids = ConvertUtil::getSubByKey($list, "feedid"); $diggArr = FeedDigg::model()->checkIsDigg($feedids, $this->uid); foreach ($list as &$v) { switch ($v["module"]) { case "mobile": break; default: $v["from"] = EnvUtil::getFromClient($v["from"], $v["module"]); break; } if (isset($v["attach_id"][0])) { $_tmp = AttachUtil::getAttachData($v["attach_id"][0]); $v["attach_url"] = FileUtil::getAttachUrl() . "/" . $_tmp[$v["attach_id"][0]]["attachment"]; } if (isset($v["api_source"]["attach"][0]["attach_url"])) { $v["api_source"]["attach_url"] = $v["api_source"]["attach"][0]["attach_url"]; unset($v["api_source"]["attach"]); unset($v["api_source"]["source_body"]); } unset($v["user_info"]); unset($v["body"]); unset($v["sourceInfo"]); unset($v["api_source"]["source_user_info"]); unset($v["api_source"]["avatar_big"]); unset($v["api_source"]["avatar_middle"]); unset($v["api_source"]["avatar_small"]); unset($v["api_source"]["source_url"]); unset($v["feeddata"]); } $data["list"] = $list; $data["diggArr"] = $diggArr; } else { $data["list"] = array(); $data["firstId"] = $data["lastId"] = 0; } return $data; }
public function commentRecover($id) { if (empty($id)) { return false; } $con = "cid = " . $id; $criteria = array("select" => "cid,module,`table`,rowid,moduleuid,uid", "condition" => $con); $comment = $this->fetch($criteria); $save["isdel"] = 0; if ($this->updateAll($save, $con)) { $model = ucfirst($comment["table"]); $model::model()->updateCounters(array("commentcount" => 1), "`" . $comment["table"] . "id`=" . $comment["rowid"]); switch ($comment["table"]) { case "feed": $feedIds = $this->fetch(array("select" => "rowid", "condition" => $con)); $feedId = array($feedIds["rowid"]); Feed::model()->cleanCache($feedId); break; } return true; } return false; }
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); }