public function __construct() { parent::__construct(); $this->uid = $this->getUid(); $this->feedModel = Feed_Model::instance(); $this->new_format = $this->input->get('new_format', 0); $this->friendModel = Friend_Model::instance(); $this->groupModel = Group_Model::instance(); $this->activityModel = Activity_Model::instance(); }
/** * * 搜索 * @param string $query * @param int $start * @param int $group_id * @param int $pagesize */ private function search($query, $start, $group_id, $pagesize) { $options = array('offset' => $start, 'limit' => $pagesize); if ($group_id) { $options['group_id'] = $group_id; } $ids = $this->sphinx_query($query, $options); $cursor = $this->mongo_query($ids); if (is_null($cursor)) { return 0; } $result = array(); $i = 0; while ($cursor->hasNext()) { $doc = $cursor->getNext(); $result[] = Feed_Model::instance()->new_feedview($doc, 1, $this->source); $i++; } return $this->send_response(200, array('data' => $result)); }
/** * 删除群 * @param int $id 群组ID */ public function destroy($id = NULL) { if ($this->get_method() != 'POST') { $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.master')) { $this->send_response(400, NULL, '400413:非群主,无权限删除群'); } $memberList = $this->model->getGroupAllMember($id); $result = $this->model->delete($id); if ($result) { $feedModel = Feed_Model::instance(); $userModel = User_Model::instance(); $content = '您加入的群"' . $groupInfo['gname'] . '"已解散'; foreach ($memberList as $value) { $feedModel->deleteItem($id, 32, $value['uid']); $userModel->present_mo_notice(Kohana::config('uap.xiaomo'), $value['uid'], $content); } $this->send_response(200); } $this->send_response(400, NULL, '删除群失败'); }
public function invite_create() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, '请求的方法不存在'); } $data = $this->get_data(); $invite_code = trim($data['invite_code']); if (strlen($invite_code) != 32 || !preg_match('/^[0-9A-Za-z]{32}$/', $invite_code)) { $this->send_response(400, NULL, '活动邀请链接无效'); } $activityInviteModel = Activity_Invite_Model::instance(); $invite_info = $activityInviteModel->getInvitationInfo($invite_code); if (!$invite_info) { $this->send_response(400, NULL, '活动邀请链接无效'); } $aid = $invite_info['aid']; $activity = $this->model->getActivityInfo($aid); if (!$activity) { $this->send_response(400, NULL, '400502:活动不存在'); } $now_time = time(); if ($now_time > $activity['end_time']) { $this->send_response(400, NULL, '400502:活动已结束'); } $applyResult = $this->model->getActivityApplyType($aid, $this->user_id); if ($applyResult > 0) { $this->send_response(400, NULL, '你已经报名了该活动'); } $activityMember['aid'] = $aid; $activityMember['uid'] = $this->user_id; $activityMember['apply_type'] = Kohana::config('activity.apply_type.join'); $activityMember['apply_time'] = $now_time; $activityMember['grade'] = Kohana::config('activity.grade.normal'); $this->model->applyActivity($activityMember); $userModel = User_Model::instance(); $userModel->insertTag($this->user_id, 15, $aid); $apply_type = Kohana::config('activity.apply_type.join'); $this->_add_feed_comment($activity, 0, $apply_type, $this->user_id); $feedModel = Feed_Model::instance(); $feedModel->addTab($aid, $activity['title'], 15, $this->user_id); $this->send_response(200); }