/** * 查看好友列表 * @method GET */ public function index() { if ($this->get_method() != 'GET') { $this->send_response(405, NULL, '请求的方法不存在'); } $page = (int) $this->input->get("page", 1); if ($page <= 0) { $this->send_response(400, NULL, "输入有误"); } $pos = (int) $this->input->get("pagesize", self::MAX_PAGESIZE); if ($pos < 0 || $pos > self::MAX_PAGESIZE) { $this->send_response(400, NULL, "输入有误"); } $start = ($page - 1) * $pos; $result = $this->model->getAllFriendIDs($this->user_id, FALSE); $total = count($result); if (!$total) { $this->send_response(200, array("count" => $total, "start" => 0, "pos" => 0, "data" => array())); } $fids = array_slice($result, $start, $pos); $res = array(); foreach ($fids as $fid) { $res[] = array('id' => (int) $fid, 'avatar' => sns::getavatar($fid), 'name' => sns::getrealname($fid)); } $this->send_response(200, array("count" => $total, "start" => $start, "pos" => $pos, "data" => $res)); }
/** * 添加赞 */ 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, '赞失败,你已经赞过'); }
/** * 获取群成员列表 */ public function index($id = NULL) { $data = $this->get_data(); $id = (int) $id; $result = NULL; if ($this->get_method() != 'GET') { $this->send_response(405, NULL, '请求的方法不存在'); } elseif (empty($id)) { $this->send_response(400, NULL, '400401:群ID为空'); } $groupInfo = $this->model->getGroupInfo($id); if (!$groupInfo) { $this->send_response(400, NULL, '400402:群不存在'); } $grade = $this->model->getMemberGrade($id, $this->user_id); if ($grade < Kohana::config('group.grade.normal')) { $this->send_response(400, NULL, '400403:非群成员,无权限查看成员列表'); } $start = 0; $maxMemberNum = Kohana::config('group.maxMemberNum'); if ($groupInfo['type'] == Kohana::config('group.type.public')) { $pos = $maxMemberNum['public']; } else { $pos = $maxMemberNum['private']; } $result = $this->model->getGroupMember($id, $start, $pos); $memberList = array(); foreach ($result as $value) { if ($value['uid'] == Kohana::config('uap.xiaomo')) { continue; } $member = array(); $member['id'] = floatval($value['uid']); $member['name'] = sns::getrealname($value['uid']); $member['avatar'] = sns::getavatar($value['uid']); $member['grade'] = intval($value['grade']); $member['zone_code'] = $value['zone_code']; $member['mobile'] = $value['mobile']; $memberList[] = $member; unset($member); } $this->send_response(200, $memberList); }
/** * 取得反馈 */ public function index() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, '请求的方法不存在'); } $data = $this->get_data(); $text = isset($data['text']) ? trim($data['text']) : ''; $contact = isset($data['contact']) ? trim($data['contact']) : ''; $kind = isset($data['kind']) ? trim($data['kind']) : ''; $source = $this->get_source(); if (empty($text)) { $this->send_response(400, NULL, '400901:反馈内容不能为空'); } if (empty($source)) { $this->send_response(400, NULL, '400902:客户端类型id不能为空'); } $this->user_id = $this->getUid(); $name = sns::getrealname($this->user_id); $text = html::specialchars($text); $array = array('uid' => $this->user_id, 'name' => $name, 'content' => $text, 'contact' => $contact, 'kind' => $kind, 'client_id' => $source, 'addtime' => time()); $return = $this->model->saveData($array); $this->send_response(200); }
/** * 获取用户参加的所有活动列表(确认参加与可能参加) * @param int $aid 活动id * @param int $apply_type 参与活动类型,默认为参加类型 * @param bool $now 活动是否正在进行(未结束状态) * @return array */ public function userAllJoinActivity($uid, $apply_type = 1, $now = false) { $aidList = array(); $activityList = array(); $join = Kohana::config('activity.apply_type.join'); $interest = Kohana::config('activity.apply_type.interest'); $query = $this->db->query("SELECT aid FROM action_member WHERE uid = {$uid} AND (apply_type = {$join} OR apply_type = {$interest}) ORDER BY apply_time DESC"); if ($query->count() != 0) { $aidList = $query->result_array(FALSE); } $nowtime = time(); foreach ($aidList as $value) { $activity = $this->getActivityInfo($value['aid'], false); $activity['creator_name'] = sns::getrealname($activity['creator_id']); if ($now && $nowtime > $activity['end_time'] + Kohana::config('activity.additional_time')) { continue; } if (date('Y', $activity['start_time']) != date('Y', $activity['end_time']) || date('Y') != date('Y', $activity['start_time'])) { $activity['start_time'] = date('Y年m月d日 H:i', $activity['start_time']); $activity['end_time'] = date('Y年m月d日 H:i', $activity['end_time']); } else { if (date('Y-m-d', $activity['start_time']) != date('Y-m-d', $activity['end_time'])) { $activity['start_time'] = date('m月d日 H:i', $activity['start_time']); $activity['end_time'] = date('m月d日 H:i', $activity['end_time']); } else { $activity['start_time'] = date('m月d日 H:i', $activity['start_time']); $activity['end_time'] = date('H:i', $activity['end_time']); } } $activityList[] = $activity; } return $activityList; }
public function message_opt_friend_apply($data, $message_id, $mini) { $location = ''; $sex = 0; $together_count = 0; $same_friend = array(); $result = $this->getNoticeInfo(array('id' => $message_id, 'authorid' => $this->uid), true); if ($result) { $tmp = $result['body'] ? json_decode($result['body'], true) : array("explain" => ""); //取得共同好友 $friendModel = new Friend_Model(); $ffids = $friendModel->getAllFriendIDs($result['authorid'], false); $mfids = $friendModel->getAllFriendIDs($this->uid, false); $together = array_intersect($ffids, $mfids); $data = sns::getuser($result['authorid']); $tmp['reside'] = ''; if ($data['resideprovince'] || $data['residecity']) { $config = Kohana::config_load('cityarray'); //加载城市数组 $province = isset($data['resideprovince']) ? isset($config['province'][$data['resideprovince']]) ? $config['province'][$data['resideprovince']] : '' : ""; $city = isset($data['residecity']) ? isset($config['city'][$data['residecity']]) ? $config['city'][$data['residecity']] : '' : ""; $location = $province . " " . $city; } $sex = $data['sex'] == 1 ? "男" : "女"; $tmp['fid'] = $result['authorid']; $tmp['explain'] = $tmp['explain'] ? str::unhtmlspecialchars($tmp['explain']) : ''; unset($data, $ffids, $mfids, $config); $str = ""; $urlpre = url::base(); $avatar = sns::getavatar($result['authorid']); if (!empty($together)) { $together_count = count($together); $i = 0; foreach ($together as $val) { $item = array(); $item['id'] = $val; $item['name'] = sns::getrealname($val); $same_friend[] = $item; if (9 < ++$i) { break; } } } } return array('location' => $location, 'sex' => $sex, 'together_count' => $together_count, 'together' => $same_friend); }
private function bulid_user_hyperlinks(&$matches) { if ($matches[1] == sns::getrealname($matches[2]) || !$matches[2]) { $this->at2id[] = array('id' => $matches[2], 'name' => $matches[1]); return '[@' . (count($this->at2id) - 1) . ']'; } return $matches[0]; }
/** * * 评论mo短信 * @param string $feedid * @param array $at */ private function mo_sms_comment($commentid, $feedid, $receiver_uid, $receiver_name, $moid = '', $auto) { $type = $this->format_type($typeid); $sender_uid = $this->uid; $sender_name = sns::getrealname($this->uid); //检查接收者是否在自己联系人中,并且接收者级别<3 if (Friend_Model::instance()->check_iscontact($sender_uid, $receiver_uid)) { $receiver_status = sns::getstatus($receiver_uid); if ($receiver_status >= 3 && $auto == true) { return false; } } else { return false; } //接收者的用户基本要<2x if (!$this->is_mo_sms_sent('comment', $feedid, $sender_uid, $receiver_uid, $moid)) { $receiver_info = sns::getuser($receiver_uid); $url_code = Url_Model::instance()->create('status', $sender_uid, $sender_name, $receiver_uid, $receiver_name, $receiver_info['mobile'], $receiver_info['zone_code'], $feedid); $short_url = MO_SMS_JUMP . $url_code; $comment_row = $this->comment_new->findOne(array('id' => $commentid)); if ($comment_row) { $content = str::cnSubstr($this->feed_at_format($comment_row['content'], $comment_row['at']), 0, 15) . '..'; $data = array(); $data['sender']['id'] = $sender_uid; $data['sender']['name'] = $sender_name; $data['receiver'][] = $receiver_uid; $data['timestamp'] = time(); $data['content']['text'] = $sender_name . '分享了:' . $content . ',点开互动: ' . $short_url; $mq_msg = array("kind" => "mobile_sms", "data" => $data); $this->mq_send(json_encode($mq_msg), $this->uid, 'momo_im'); $this->mo_sms_log('comment', $commentid, $feedid, $this->uid, $receiver_uid, $moid); if ($moid) { $this->update_my_mo($moid); } return true; } } }
/** * 创建活动 */ public function create() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, '请求的方法不存在'); } $data = $this->get_data(); if (!$data) { $this->send_response(400, NULL, '400505:活动信息非法'); } $post = new Validation($data); $post->add_rules('title', 'required', 'length[1, 30]'); $post->add_rules('start_at', 'required', 'numeric'); $post->add_rules('end_at', 'required', 'numeric'); $post->add_rules('spot', 'required', 'length[1, 30]'); $post->add_rules('type', 'required', 'numeric', array($this, '_check_type_validation')); $post->add_rules('is_allow_invite', 'required', 'numeric', array($this, '_check_allow_invite_validation')); $post->add_rules('content', 'length[0, 300]'); $post->add_rules('group_ids', array($this, '_check_group_ids_validation')); $post->add_callbacks(TRUE, array($this, '_check_time_validation')); if ($post->validate()) { $activity = array(); $form = $post->as_array(); $activity['creator_id'] = $this->user_id; $activity['title'] = $form['title']; $activity['start_time'] = $form['start_at']; $activity['end_time'] = $form['end_at']; $nowTime = time(); $activity['create_time'] = $nowTime; $activity['spot'] = $form['spot']; $activity['type'] = $form['type']; $activity['is_allow_invite'] = $form['is_allow_invite']; if (isset($form['content'])) { $activity['content'] = $form['content']; } $groupIds = array(); if (isset($form['group_ids'])) { $groupIds = $form['group_ids']; } $groupModel = new Group_Model(); $gidArray = array(); foreach ($groupIds as $id) { $id = floatval($id); if ($id != -1) { $groupInfo = $groupModel->getGroupInfo($id); if (!$groupInfo) { $this->send_response(400, NULL, '400506:活动发布到的群不存在'); } $grade = $groupModel->getMemberGrade($id, $this->user_id); if ($grade < 1) { $this->send_response(400, NULL, '400507:您不是活动指定发布到群的成员'); } } $gidArray[] = $id; } if (!$gidArray) { $activity['is_publish'] = 0; } else { $activity['is_publish'] = 1; } $activity_id = $this->model->add($activity); $activityMember = array('aid' => $activity_id, 'uid' => $this->user_id, 'apply_type' => Kohana::config('activity.apply_type.join'), 'apply_time' => $nowTime, 'grade' => Kohana::config('activity.grade.creator')); $result = $this->model->applyActivity($activityMember); $this->model->addActivityUser($activity_id, $this->user_id); $friendModel = new Friend_Model(); $fidList = $friendModel->getAllFriendIDs($this->user_id, false); //活动动态发送到指定momo成员 foreach ($gidArray as $gid) { $this->model->addActivityGroup($activity_id, $gid); if ($gid == -1) { $friendModel = new Friend_Model(); $fidList = $friendModel->getAllFriendIDs($this->user_id, false); foreach ($fidList as $fid) { $this->model->addActivityUser($activity_id, $fid); } } else { $this->model->addActivityGroup($activity_id, $gid); $members = $groupModel->getGroupAllMember($gid); foreach ($members as $value) { $this->model->addActivityUser($activity_id, $value['uid']); } } } $feedModel = new Feed_Model(); $title = array('uid' => $this->user_id, 'name' => sns::getrealname($this->user_id), 'id' => $activity_id, 'title' => $activity['title']); $messageModel = new Message_Model(); if ($activity['is_publish']) { $feedModel->addFeed($this->user_id, 'action_add', Kohana::config('uap.app.action'), $title, array(), $activity_id); } $this->send_response(200, array('id' => floatval($activity_id))); } $errors = $post->errors(); $this->send_response(400, NULL, '400505:活动信息非法'); }
/** * * 获取群组管理员 */ private function _get_group_manager($gid) { $gm_user = array(); $gm = $this->model->getGroupManager($gid); if ($gm) { foreach ($gm as $v) { $gm_user[] = array('id' => $v['uid'], 'name' => sns::getrealname($v['uid']), 'avatar' => sns::getavatar($v['uid'])); } } return $gm_user; }
public function sendfacefeed($pid, $album_id = 0, $img = "", $appid = 0) { $return = false; if ($pid) { $feed_flag = 1; if ($feed_flag == 1) { //发送好友动态 $data = $this->db->getRow("album_pic", "pic_width, pic_height", "pic_id={$pid}"); if ($data['pic_height'] >= 780 || $data['pic_width'] >= 780) { if ($height >= $width) { $height_780 = 780; $width_780 = intval($data['pic_width'] / ($data['pic_height'] / 780)); } else { $width_780 = 780; $height_780 = intval($data['pic_height'] / ($data['pic_width'] / 780)); } } else { $height_780 = $data['pic_height']; $width_780 = $data['pic_width']; } $this->feed = new Feed_Model(); if (!$img) { $img = Kohana::config('album.recordThumb') . 'thumb/' . $pid . '_120.jpg'; } $realname = sns::getrealname($this->uid); $feedkey = sns::getFeedUniqid('user_face_update'); $feed = array('title' => array('uid' => $this->uid, 'name' => sns::getrealname($this->uid), 'time' => time(), 'appid' => $appid), 'body' => array('uid' => $this->uid, 'image' => $img, 'name' => $realname, 'pid' => $pid, 'img_780' => Kohana::config('album.recordThumb') . 'thumb/' . $pid . '_780.jpg', 'aid' => $album_id, 'height_780' => $height_780, 'width_780' => $width_780)); $result = $this->feed->addFeed($this->uid, 'user_face_update', Kohana::config('uap.app.user'), $feed['title'], $feed['body'], $feedkey, '', '', array(), $appid); $return = $result['code'] == 200 ? true : false; } } return $return; }
/** * 管理员接受群组申请 * @return <type> */ public function agree_group_admin() { $data = $this->get_data(); $message_id = $data['id']; if (empty($message_id)) { $this->send_response(400, NULL, '400102:消息id非法'); } $result = $this->model->getNoticeInfo(array('id' => $message_id, 'uid' => $this->user_id), true); if (!$result) { $this->send_response(400, NULL, '400101:消息体不存在或已经被处理'); } $group_tmp = json_decode($result['title'], true); $gid = $group_tmp['group'][0]['id']; $gname = $group_tmp['group'][0]['name']; $group_info = $this->groupModel->getGroupInfo($gid); if (!$group_info) { $this->model->putChangeTplByid($this->user_id, $message_id, 6); $this->send_response(400, NULL, '400109:群不存在'); } $grade = $this->groupModel->getmembergrade($gid, $this->user_id); if ($grade < 2) { $this->model->putChangeTplByid($this->user_id, $message_id, 5); $this->send_response(400, NULL, '400111:你不是群组管理员,无权进行此操作'); } $req_uid = $result['authorid']; $apply = $this->groupModel->getUserApplyGroup($gid, $req_uid); if (!$apply) { $this->send_response(400, NULL, '400112:群申请记录不存在'); } if ($apply['status'] && $apply['manager_uid'] != $this->user_id) { $this->model->putChangeTplByid($this->user_id, $message_id, 3); $this->send_response(400, NULL, '400113:请求已被其他管理员处理'); } $gname = $group_info['gname']; $username = sns::getrealname($this->user_id); $title = array('uid' => $this->user_id, 'name' => $username, 'group' => array(array('id' => $gid, 'name' => $gname))); $grade = $this->groupModel->getmembergrade($gid, $req_uid); if ($grade > 0) { //已经是群成员 $this->model->putChangeTplByid($this->user_id, $message_id, 3); $this->send_response(400, NULL, '400108:已经是群成员'); } //查询群组成员总数是否超出最大限制(暂定100) $memberNum = $group_info['member_number']; if ($group_info['type'] == Kohana::config('group.type.public')) { $maxMemberNum = Kohana::config('group.maxMemberNum.public'); } else { $maxMemberNum = Kohana::config('group.maxMemberNum.private'); } if ($memberNum >= $maxMemberNum) { $this->model->putChangeTplByid($this->user_id, $message_id, 4); $this->send_response(400, NULL, '400114:群组成员人数已满'); } $ret = $this->groupModel->addGroupMember($gid, $req_uid, 1); $this->groupModel->addMemberNum($gid); $feedModel = new Feed_Model(); if ($group_info['type'] == Kohana::config('group.type.private')) { $dateline = time(); try { //添加群组通讯录联系人 $ret = $this->groupContactModel->addGroupContactByUserCard($gid, $req_uid, $dateline); } catch (Exception $exc) { $this->send_response(400, NULL, '400115:导入个人名片到群组通讯录联系人失败'); } $ginfo['modify_time'] = $dateline; $ret = $this->groupModel->modifyGroup($gid, $ginfo); } else { if ($group_info['type'] == Kohana::config('group.type.public')) { //发送加入公开群组动态 $application = array('id' => floatval($gid), 'title' => '查看群组', 'url' => 'group/' . $gid); $feedModel->addFeed($req_uid, 2, $text = '加入了群组:' . $group_info['gname'], $this->get_source(), $application, $at = array(), $images = array(), $sync = array(), $group_type = 0, $group_id = 0, $retweet_id = 0, $allow_rt = 0, $allow_comment = 1, $allow_praise = 1, $allow_del = 1, $allow_hide = 1); } } $commentModel = new Comment_Model(); if ($group_info['feed_id']) { $friendModel = Friend_Model::instance(); $isFriend = $friendModel->check_isfriend($req_uid, $group_info['creator_id']); if ($isFriend) { $commentModel->saveComment($group_info['feed_id'], '加入了本群', $group_info['creator_id'], 0, 0, $req_uid); } } if ($group_info['group_feed_id']) { $commentModel->saveComment($group_info['group_feed_id'], '加入了本群', $group_info['creator_id'], 0, 0, $req_uid); } //添加群到首页tab列表 $userModel = new User_Model(); $userModel->insertTag($req_uid, 7, $gid); $feedModel->addTab($gid, $group_info['gname'], 7, $req_uid); $appid = Kohana::config('uap.app.group'); // 添加通知 $this->model->putAddNotice($req_uid, $appid, 'agreeJoinGroup', $title); $this->model->putChangeTplByid($this->user_id, $message_id, 1); //更新申请加入群记录状态 $this->groupModel->dealApplyMember($gid, $req_uid, $this->user_id); $this->send_response(200); }
/** * 根据需求查询 * @param string $query 查询字符串 * @return array */ public function cypher($query) { $result = $this->_graph_query($query, 25); if ($result) { $cols = $result->getColumns(); $return = array(); foreach ($result as $i => $row) { /** @var Everyman\Neo4j\PropertyContainer[] $row */ foreach ($cols as $col) { if ($row[$col] instanceof Everyman\Neo4j\Node) { /** @var Everyman\Neo4j\Node[] $row */ $return[$i][$col]['meta']['id'] = $row[$col]->getId(); $return[$i][$col]['property'] = $row[$col]->getProperties(); if ($user_id = $row[$col]->getProperty('uid')) { $return[$i][$col]['property']['name'] = sns::getrealname($user_id); $return[$i][$col]['property']['avatar'] = sns::getavatar($user_id); } } elseif ($row[$col] instanceof Everyman\Neo4j\Relationship) { /** @var Everyman\Neo4j\Relationship[] $row */ $return[$i][$col]['meta']['id'] = $row[$col]->getId(); $return[$i][$col]['meta']['type'] = $row[$col]->getType(); $return[$i][$col]['meta']['start_node'] = $row[$col]->getStartNode()->getId(); $return[$i][$col]['meta']['end_node'] = $row[$col]->getEndNode()->getId(); $return[$i][$col]['property'] = $row[$col]->getProperties(); } elseif ($row[$col] instanceof Everyman\Neo4j\Query\Row) { foreach ($row[$col] as $j => $r) { if ($r instanceof Everyman\Neo4j\Node) { /** @var Everyman\Neo4j\Node[] $row */ $return[$i][$col][$j]['meta']['id'] = $r->getId(); $return[$i][$col][$j]['property'] = $r->getProperties(); if ($user_id = $r->getProperty('uid')) { $return[$i][$col][$j]['property']['name'] = sns::getrealname($user_id); $return[$i][$col][$j]['property']['avatar'] = sns::getavatar($user_id); } } elseif ($r instanceof Everyman\Neo4j\Relationship) { /** @var Everyman\Neo4j\Relationship[] $row */ $return[$i][$col][$j]['meta']['id'] = $row[$col]->getId(); $return[$i][$col][$j]['meta']['type'] = $row[$col]->getType(); $return[$i][$col][$j]['meta']['start_node'] = $row[$col]->getStartNode()->getId(); $return[$i][$col][$j]['meta']['end_node'] = $row[$col]->getEndNode()->getId(); $return[$i][$col][$j]['property'] = $r->getProperties(); } else { $return[$i][$col][$j] = $r; } } } else { $return[$i][$col] = $row[$col]; } } } return $return; } return false; }
/** * * 整理活动内容 * @param unknown_type $item */ private function _arrange_event_item($item, $is_item = true, $list_user = false) { $arranged_item = array(); if (!empty($item)) { $arranged_item['id'] = $item['eid']; $arranged_item['gid'] = $item['gid']; $arranged_item['type'] = $item['type']; $arranged_item['title'] = $item['title']; $arranged_item['summary'] = $item['summary']; $arranged_item['content'] = $item['content']; $arranged_item['organizer'] = array('id' => $item['organizer'], 'name' => sns::getrealname($item['organizer']), 'avatar' => sns::getavatar($item['organizer'])); $arranged_item['start_time'] = $item['start_time']; $arranged_item['end_time'] = $item['end_time']; $event_images = $this->_list_event_image($item['eid']); $arranged_item['cover_image'] = array(); if ($event_images['cover_image']) { $arranged_item['cover_image'] = $event_images['cover_image']; } $arranged_item['images'] = $event_images['list_image'] ? $event_images['list_image'] : array(); $arranged_item['assemble_location'] = $item['assemble_location'] ? unserialize($item['assemble_location']) : array(); $arranged_item['event_location'] = $item['event_location'] ? unserialize($item['event_location']) : array(); $arranged_item['fee'] = $item['fee']; $arranged_item['deadline'] = $item['deadline']; $arranged_item['apply_desc'] = $item['apply_desc']; $arranged_item['private'] = $item['private']; $arranged_item['apply_doc'] = $this->model->getEventApplyDoc($item['eid']); $arranged_item['city'] = $this->model->getCityName($item['city']); if ($this->user_id) { $arranged_item['apply_type'] = $this->_check_apply_type($item['apply_type'], $item['eid'], $this->user_id); } $arranged_item['joined'] = array('number' => $this->model->getUserCount(array('eid' => $item['eid'], 'apply_type' => Kohana::config('event.apply_type.joined')))); $arranged_item['interested'] = array('number' => $this->model->getUserCount(array('eid' => $item['eid'], 'apply_type' => Kohana::config('event.apply_type.interested')))); if ($is_item) { $refused_user = $this->model->getEventUser($item['eid'], Kohana::config('event.apply_type.refused')); $arranged_item['refused']['number'] = $this->model->getUserCount(array('eid' => $item['eid'], 'apply_type' => Kohana::config('event.apply_type.refused'))); $unconfirmed_user = $this->model->getEventUser($item['eid'], Kohana::config('event.apply_type.unconfirmed')); $arranged_item['unconfirmed']['number'] = $this->model->getUserCount(array('eid' => $item['eid'], 'apply_type' => Kohana::config('event.apply_type.unconfirmed'))); //必须要登录情况下才能看到成员列表 if ($list_user && $this->user_id) { $joined_user = $this->model->getEventUser($item['eid'], Kohana::config('event.apply_type.joined')); $arranged_item['joined']['user'] = $this->_arrange_user_list($joined_user, Kohana::config('event.apply_type.joined'), $item); $interested_user = $this->model->getEventUser($item['eid'], Kohana::config('event.apply_type.interested')); $arranged_item['interested']['user'] = $this->_arrange_user_list($interested_user, Kohana::config('event.apply_type.interested'), $item); $arranged_item['refused']['user'] = $this->_arrange_user_list($refused_user, Kohana::config('event.apply_type.refused'), $item); $arranged_item['unconfirmed']['user'] = $this->_arrange_user_list($unconfirmed_user, Kohana::config('event.apply_type.unconfirmed'), $item); } } $arranged_item['status'] = $this->_check_event_status($item['start_time'], $item['end_time'], $item['status'], $item['eid'], $item['deadline']); } return $arranged_item; }
public function saveComment($status_id, $content, $feed_uid, $client_id = 0, $reply_commentid = 0, $uid = 0, $group_member = array()) { $this->at2id = array(); $comment_at = array(); $isall = 0; if (strpos($content, '@全部成员(0)') !== false) { $isall = 1; } $addfeed = new Feed_Model(); $doc = $addfeed->findFeed($status_id); $this->group_id = (int) $doc['group_id']; $content = preg_replace_callback('#\\b(https?)://[-A-Z0-9+&\\#/%?=~_|!:,.;]*[-A-Z0-9+&\\#/%=~_|]#i', array($this, 'bulid_hyperlinks'), $content); $content = preg_replace_callback('/@([^@]+?)\\(([0-9]*)\\)/', array($this, 'bulid_user_hyperlinks'), $content); $comment_at = $this->at2id; $time = time(); $typeid = 4; $feed_uid = $doc['owner_uid']; $uid = $uid == 0 ? $this->uid : $uid; $content_link = $addfeed->atLink($content, $this->at2id); $m = new MongoClient(Kohana::config('uap.mongodb')); $comment_id = md5($status_id . '_' . $feed_uid . '_' . microtime()); $addTime = microtime(true) * 10000; $col = $this->m->selectCollection('im_user'); //右侧聊天窗口start $arr = $col->find(array('feedid' => $status_id)); if (!empty($arr)) { $source_name = api::get_source_name($client_id); $immsg = array("kind" => "im", "data" => array("id" => $comment_id, "statuses_id" => $status_id, "owner_uid" => $feed_uid, "user" => array('id' => $uid, 'name' => sns::getrealname($uid), 'avatar' => sns::getavatar($uid)), "datetime" => $addTime, "created_at" => sns::gettime($time), "source_name" => $source_name == 'MOMO网站' ? '' : $source_name, "text" => $content_link)); $uid_string = ''; foreach ($arr as $v) { if ($v['uid'] == $uid) { continue; } if (strlen($uid_string) > 200) { $this->mq_send(json_encode($immsg), substr($uid_string, 0, -1)); $uid_string = ''; } $uid_string .= $v['uid'] . '.'; } $this->mq_send(json_encode($immsg), substr($uid_string, 0, -1)); } //右侧聊天窗口end $client_id = $client_id ? $client_id : 0; $realname = sns::getrealname($uid); $array = array('id' => $comment_id, 'feedid' => $status_id, 'content' => $content, 'at' => $this->at2id, 'addtime' => $addTime, 'uid' => intval($uid), 'realname' => $realname, 'client_id' => intval($client_id), 'owner' => intval($feed_uid)); $this->comment->insert($array); if ($doc) { } $typeid = $doc['typeid']; $sended_uid = array(); //回复某人 if ($reply_commentid) { $reply_comment = $this->comment->findOne(array('id' => $reply_commentid)); $is_reply = false; if ($reply_comment['uid'] && count($this->at2id) > 0) { foreach ($this->at2id as $key => $var) { if ($var['id'] == $reply_comment['uid']) { $is_reply = true; $reply_key = key; continue; } } if ($is_reply) { $sended_uid[] = $reply_comment['uid']; unset($comment_at[$reply_key]); $addfeed->addAboutme($reply_comment['uid'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 6, $reply_comment); } } } //评论动态 if ($feed_uid != $this->uid && $reply_uid != $feed_uid) { if (!in_array($feed_uid, $sended_uid)) { $sended_uid[] = $feed_uid; $addfeed->addAboutme($feed_uid, $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 1); } } //群组评论动态 if (count($group_member) > 0) { foreach ($group_member as $member) { if (!in_array($member['uid'], $sended_uid) && $member['uid'] != $this->uid) { $sended_uid[] = $member['uid']; $addfeed->addAboutme($member['uid'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 1); } } } //动态中@某人 if (!empty($comment_at) && count($comment_at) > 0) { foreach ($comment_at as $key => $var) { if ($var['id'] != $feed_uid && !in_array($var['id'], $sended_uid) && !$var['group_id']) { $sended_uid[] = $var['id']; $addfeed->addAboutme($var['id'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 3); } } } $comment_list = array('id' => $comment_id, 'uid' => intval($uid), 'name' => $realname, 'created_at' => intval($time), 'text' => $content, 'at' => $this->at2id, 'source' => $client_id, 'im' => 0); $isbubble = $feed_uid == Kohana::config('uap.xiaomo') ? false : true; $addfeed->addFeedComment($status_id, $comment_list, $isbubble); $addfeed->updateFeed($status_id); $addfeed->delHidden($status_id); $addfeed->mo_sms('comment', $status_id, $comment_id, $this->at2mo); $return = array("success" => true, "data" => array("id" => $comment_id, "text" => $content_link)); return $return; }
/** * 获取关于我的动态,提供iphone,andriod使用 * @return <type> */ public function aboutme_alone() { $pos = $this->input->get('pagesize', 20); $start = $this->input->get('page', 1); $new = $this->input->get('new', 0); $pos = $pos > 100 ? 100 : $pos; $start = abs(($start - 1) * $pos); $arr = $this->feedModel->findAboutme($new, $pos, $start); $res = array(); if ($arr) { $i = 0; foreach ($arr as $row) { $res[$i]['id'] = $row['_id']; $res[$i]['statuses_id'] = $row['feed_id']; $res[$i]['kind'] = $row['kind']; $res[$i]['group'] = array('id' => $this->_st($row['group_id'], 0), 'name' => $this->_st($row['group_name'], '')); $res[$i]['text'] = $this->_st($this->feedModel->format_title($row['comment_content'], $this->source), ''); $res[$i]['source'] = $row['source'] == 0 ? '' : $this->get_source($row['source']); $res[$i]['user'] = array('id' => $this->_st($row['comment_uid'], 0), 'name' => $this->_st(sns::getrealname($row['comment_uid'])), 'avatar' => sns::getavatar($row['comment_uid'], 'small')); $res[$i]['new'] = $row['new'] == 1 ? true : false; $res[$i]['created_at'] = ceil($row['addtime'] / 10000); $aboutme_opt = array(); if ($row['kind'] == 6) { $content = $this->_st(strip_tags($row['reply_content']), ''); $aboutme_opt['reply_source'] = array('id' => $row['reply_id'], 'text' => $this->feedModel->format_title($content, $this->source), 'at' => $row['reply_at'], 'user' => array('id' => $row['reply_uid'], 'name' => $row['reply_name'], 'avatar' => sns::getavatar($row['reply_uid'], 'small'))); } elseif ($row['kind'] == 2) { $aboutme_opt['message'] = array('text' => $this->_st($this->feedModel->format_title($row['feed_content'], $this->source), ''), 'at' => $row['feed_at']); } else { $content = $this->_st(strip_tags($row['feed_content']), ''); $aboutme_opt['statuses'] = array('text' => $this->feedModel->format_title($content, $this->source), 'at' => $row['feed_at'], 'uid' => $this->_st($row['feed_uid'], 0), 'name' => $this->_st($row['feed_name'])); } if (in_array($row['kind'], array(1, 3, 6))) { $aboutme_opt['comment'] = array('id' => $row['comment_id'], 'text' => $this->_st($this->feedModel->format_title(str_replace(array('评论道:', '回复:'), '', $row['comment_content']), $this->source), ''), 'at' => $row['comment_at']); } $res[$i]['opt'] = $aboutme_opt; $i++; } $this->feedModel->updateAboutmeRead(); } $this->send_response(200, $res); }