/** * 添加赞 */ public function create() { $post = $this->get_data(); $statuses_id = $post['statuses_id']; if (empty($statuses_id)) { $this->send_response(400, NULL, '对象id为空'); } $feed = new Feed_Model(); $doc = $feed->findFeed($statuses_id); if (!$doc) { $this->send_response(404, NULL, '该动态不存在'); } $owner = $doc['owner_uid']; $had_praise = 0; foreach ($doc['like_list'] as $key => $var) { $uid = $var['uid'] ? $var['uid'] : $var['id']; if ((int) $uid == (int) $this->uid) { $had_praise = 1; break; } } $group_member = array(); if ($doc['group_type'] > 0) { $grade = Group_Model::instance()->getMemberGrade($doc['group_id'], $this->uid); if ($grade < 1) { $this->send_response(400, NULL, '400:你不是该群成员,无权限赞'); } $group_member = Group_Model::instance()->getGroupAllMember($doc['group_id']); } $is_bubble = $owner == Kohana::config('uap.xiaomo') ? false : true; if ($doc['last_updated'] && $had_praise == 0) { if (count($group_member) > 0) { foreach ($group_member as $member) { if ($member['uid'] != $this->uid) { if (!$feed->addAboutme($member['uid'], $this->uid, $doc['typeid'], 0, '', array(), $statuses_id, 4)) { $this->send_response(400, NULL, $feed->get_error_msg()); } } } } elseif ($owner != $this->uid) { if (!$feed->addAboutme($owner, $this->uid, $doc['typeid'], 0, '', array(), $statuses_id, 4)) { $this->send_response(400, NULL, $feed->get_error_msg()); } } $feed->addLike($this->uid, sns::getrealname($this->uid), $statuses_id, $is_bubble); if ($doc['group_type'] == 1 && $doc['group_id']) { Tab_Model::instance()->lastModify($this->uid, 1, $doc['group_id']); } $this->send_response(200); } $this->send_response(400, NULL, '赞失败,你已经赞过'); }