コード例 #1
0
ファイル: app_message.php プロジェクト: momoim/momo-api
 private function _user($uid, $avatar_size = 130)
 {
     //外部应用不需获取用户信息
     if ($this->is_app_standalone) {
         return array('id' => $uid, 'name' => '', 'avatar' => '');
     }
     if (!$uid) {
         return array('id' => 0, 'name' => '', 'avatar' => '', 'nick' => array(), 'mobile' => '', 'zone_code' => '');
     }
     if (!$this->_cache_users[$uid]) {
         $user_info = sns::getuser($uid);
         $nicks = Friend_Model::instance()->get_contact_formatted_name($this->uid, $user_info['mobile'], $user_info['zone_code']);
         $mobile = $user_info['mobile'];
         $this->_cache_users[$uid] = array('id' => (int) $uid, 'name' => $user_info['realname'], 'avatar' => sns::getavatar($uid, $avatar_size), 'nick' => $nicks, 'mobile' => $mobile, 'zone_code' => $user_info['zone_code']);
     }
     return $this->_cache_users[$uid];
 }
コード例 #2
0
ファイル: user.php プロジェクト: momoim/momo-api
 public function __construct()
 {
     parent::__construct();
     $this->model = User_Model::instance();
     $this->friend_model = Friend_Model::instance();
 }
コード例 #3
0
ファイル: deal.php プロジェクト: momoim/momo-api
 /**
  * 
  * @param $user_id
  * @return unknown_type
  */
 private function _get_relation_contact_uids($user_id)
 {
     $contact_uids = array();
     $contact_uids = Friend_Model::instance()->get_user_link_cache($user_id);
     return $contact_uids;
 }
コード例 #4
0
ファイル: feed.php プロジェクト: momoim/momo-api
 /**
  *
  * 评论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;
         }
     }
 }
コード例 #5
0
ファイル: activity.php プロジェクト: momoim/momo-api
 /**
  * 检查用户是否有查看活动的权限
  * @param array $activity 
  * @param float $uid
  * return boolean
  */
 private function _check_activity_view_permission($activity, $uid)
 {
     $permit = true;
     $apply_type = $this->model->getActivityApplyType($activity['aid'], $uid);
     if ($activity['gid'] == 0 && $apply_type == 0) {
         $permit = false;
         $friendModel = Friend_Model::instance();
         $isFriend = $friendModel->check_isfriend($activity['creator_id'], $uid);
         $fidList = $friendModel->getAllFriendIDs($uid);
         $friendsIsJoin = false;
         if ($fidList) {
             $fids = implode(',', $fidList);
             $friendsIsJoin = $this->model->checkFriendsIsJoined($activity['aid'], $fids);
         }
         $invite = $this->model->getUserInviteUnset($activity['aid'], $uid);
         $isCompanyMember = false;
         if ($activity['belong_type'] == Kohana::config('activity.belongType.company')) {
             $companyModel = new Company_Model();
             $companyId = floatval($activity['belong_id']);
             $isCompanyMember = $companyModel->isCompanyMember($companyId, $uid);
         }
         if ($invite || $isCompanyMember) {
             $permit = true;
         } else {
             if ($activity['is_allow_invite'] && $friendsIsJoin) {
                 $permit = true;
             }
         }
     }
     return $permit;
 }
コード例 #6
0
ファイル: message.php プロジェクト: momoim/momo-api
 public function agree_group()
 {
     $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'];
     $grade = $this->groupModel->getmembergrade($gid, $this->user_id);
     if ($grade > 0) {
         $this->model->putChangeTplByid($this->user_id, $message_id, 1);
         $this->send_response(400, NULL, '400108:您已经是群成员了');
     }
     $group_info = $this->groupModel->getGroupInfo($gid);
     if (!$group_info) {
         $this->model->putChangeTplByid($this->user_id, $message_id, 4);
         $this->send_response(400, NULL, '400109:群不存在');
     }
     //查询群组成员总数是否超出最大限制(暂定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, 3);
         $this->send_response(400, NULL, '400110:群成员人数已满');
     }
     $result = $this->groupModel->addGroupMember($gid, $this->user_id, 1);
     $this->groupModel->addMemberNum($gid);
     $feedModel = new Feed_Model();
     if ($group_info['type'] == Kohana::config('group.type.private')) {
         $dateline = time();
         try {
             //添加群组通讯录联系人
             $this->groupContactModel->addGroupContactByUserCard($gid, $this->user_id, $dateline);
         } catch (Exception $exc) {
             $this->send_response(400, NULL, '400111:导入个人名片到群组通讯录联系人失败');
         }
         $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($this->user_id, 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($this->user_id, $group_info['creator_id']);
         if ($isFriend) {
             $commentModel->saveComment($group_info['feed_id'], '加入了本群', $group_info['creator_id']);
         }
     }
     if ($group_info['group_feed_id']) {
         $commentModel->saveComment($group_info['group_feed_id'], '加入了本群', $group_info['creator_id']);
     }
     //添加群到首页tab列表
     $userModel = new User_Model();
     $userModel->insertTag($this->user_id, 7, $gid);
     $feedModel->addTab($gid, $group_info['gname'], 7, $this->user_id);
     //删除邀请表对应的记录
     $this->model->putChangeTplByid($this->user_id, $message_id, 1);
     $this->send_response(200);
 }
コード例 #7
0
ファイル: contact.php プロジェクト: momoim/momo-api
 /**
  * 执行清空缓存
  * @return void
  */
 public function do_task()
 {
     if (!empty($this->task_data)) {
         $user_id = $this->task_data['user_id'];
         $added_ids = $this->task_data['added_ids'];
         $updated_ids = $this->task_data['updated_ids'];
         $deleted_ids = $this->task_data['deleted_ids'];
         $recycled_ids = $this->task_data['recycled_ids'];
         $ids = array_merge($added_ids, $updated_ids, $deleted_ids);
         if ($updated_ids or $recycled_ids or $deleted_ids) {
             $this->update_cache($user_id, 'recycled_list_update');
         }
         if (!empty($ids) or $this->is_snapshot) {
             Category_Model::instance()->clear_cache($user_id);
         }
         if (!empty($ids)) {
             foreach ($ids as $id) {
                 $this->cache->delete($this->cache_pre . 'find_by_id_' . $user_id . '_' . $id);
             }
             $this->cache->delete($this->cache_pre . 'get_list_' . $user_id);
             $this->cache->delete($this->cache_pre . 'get_count_' . $user_id);
             Friend_Model::instance()->del_user_link_cache($user_id);
         }
     }
 }
コード例 #8
0
ファイル: comment.php プロジェクト: momoim/momo-api
 /**
  * 决定是否显示评论框
  * @param int $vuid 登录者id
  * @param int $uid 所有者id
  */
 public function retrunAllow($vuid, $uid)
 {
     if ($vuid == $uid) {
         return 1;
     }
     $right = User_Model::instance()->getRights($uid, 'allowcomment');
     if ($right == 0) {
         //任何人可以访问
         return 1;
     } elseif ($right == 1) {
         //仅好友
         $return = Friend_Model::instance()->getCheckIsFriend($vuid, $uid);
         if ($return) {
             //如果是好友返回1
             return 1;
         } else {
             //如果不是好友返回2
             return 2;
         }
     } else {
         return 0;
     }
 }
コード例 #9
0
ファイル: statuses.php プロジェクト: momoim/momo-api
 /**
  * 检查用户查看权限
  * @return <type>
  */
 public function checkPermission($fid, $content)
 {
     if ($this->uid != $fid) {
         $friendModel = Friend_Model::instance();
         if (!$friendModel->check_isfriend($this->uid, $fid)) {
             return '对方不是你的好友,无权限查看源内容';
         }
     }
     return $content;
 }
コード例 #10
0
ファイル: search.php プロジェクト: momoim/momo-api
 /**
  * 
  * 获取用户的mix_id
  */
 private function get_user_mix_ids()
 {
     $uids = array();
     //联系人
     $uids = Friend_Model::instance()->get_user_link_cache($this->user_id);
     //群组
     $group_array = Group_Model::instance()->getUserAllGroupId($this->user_id);
     if ($group_array) {
         foreach ($group_array as $group) {
             $uids[] = '1_' . $group['gid'];
         }
     }
     array_push($uids, $this->user_id);
     return $uids;
 }
コード例 #11
0
ファイル: life_service.php プロジェクト: momoim/momo-api
 /**
  * 取得列表json数据
  * @method GET
  * 
  * fail=1 失效
  * sale=1 供 dealer=2 求
  * city=城市名(eg:福州)
  * circle:1、好友; 6、熟人; 8、同城
  * cate:1二手物品,2租房,3售房,4团购
  * keyword:用户输入
  * |myfav=1 我的收藏
  * |mytrade=1 我的二手
  * |myrent=1 我的租房
  * |replymy=1 回复我的
  * |hide=1 我的隐藏
  * 
  * @access public
  * @return void
  */
 public function index()
 {
     if ($this->input->get("hide", 0)) {
         $start = (int) $this->input->get('page', 1);
         if ($start <= 0) {
             $this->send_response(400, NULL, "输入有误");
         }
         $pos = (int) $this->input->get('pagesize', 20);
         if ($pos <= 0 || $pos > self::MAX_PAGESIZE) {
             $this->send_response(400, NULL, "输入有误");
         }
         $start = abs(($start - 1) * $pos);
         $result = $this->model->get_hidden_ids($this->user_id, $start, $pos);
         self::get_market_json(array("object_id" => array('$in' => $result), "status" => "all"), "", false);
         return null;
     }
     if ($this->input->get("myfav", 0)) {
         $start = (int) $this->input->get('page', 1);
         if ($start <= 0) {
             $this->send_response(400, NULL, "输入有误");
         }
         $pos = (int) $this->input->get('pagesize', 20);
         if ($pos <= 0 || $pos > self::MAX_PAGESIZE) {
             $this->send_response(400, NULL, "输入有误");
         }
         $start = abs(($start - 1) * $pos);
         $result = $this->model->get_favorite_ids($this->user_id, $start, $pos);
         self::get_market_json(array("object_id" => array('$in' => $result), "status" => "all"), "", false);
         return null;
     }
     if ($this->input->get("mytrade", 0)) {
         self::get_market_json(array("user_id" => (int) $this->user_id, "category" => 1, "status" => "all"), "", false);
         return null;
     }
     if ($this->input->get("myrent", 0)) {
         self::get_market_json(array("user_id" => (int) $this->user_id, "category" => 2, "status" => "all"), "", false);
         return null;
     }
     if ($this->input->get("replymy", 0)) {
         $this->send_response(501, null, "暂不支持");
         return null;
     }
     $fail = $this->input->get("fail", 0);
     $sale = $this->input->get("sale", 0);
     $city = $this->input->get("city", "");
     $circle = $this->input->get("circle", 0);
     $cate = $this->input->get("cate", 0);
     $keyword = $this->input->get("keyword", "");
     $keyword = $keyword ? strtr(trim($keyword), array("." => "", "*" => "", "+" => "", "?" => "", "[" => "", "]" => "", "(" => "", ")" => "", "," => "", "," => "")) : "";
     $where = array();
     if ($fail) {
         $where['status'] = 'all';
     }
     if ($sale && in_array($sale, array('1', '2'))) {
         $where['type'] = (int) $sale;
     }
     if ($city) {
         $where['city'] = $city;
     }
     if ($cate && in_array($cate, array('1', '2', '3', '4', '5'))) {
         $where['category'] = (int) $cate;
     }
     //取得两个月内的隐藏数据
     $lastmonth = mktime(0, 0, 0, date("m") - 2, date("d"), date("Y"));
     $not_id = $this->model->get_hidden_ids($this->uid, null, null, $lastmonth);
     if (!empty($not_id)) {
         $where['object_id'] = array('$nin' => $not_id);
     }
     //权限处理 没选权限默认是同城
     if ($circle && in_array($circle, array('1', '6'))) {
         do {
             $user_ids = array();
             if ($circle == 1) {
                 $user_ids = Friend_Model::instance()->getAllFriendIDs($this->user_id);
                 array_walk($user_ids, function (&$item) {
                     $item = (int) $item;
                 });
                 $user_ids[] = (int) $this->user_id;
                 $where['privacy'] = array('$in' => array(1, 7, 9, 15));
                 break;
             }
             if ($circle == 6) {
                 $sub_model = new Company_Model();
                 $cids = $sub_model->getCompanyList($this->user_id);
                 foreach ($cids as $v) {
                     $uids = $sub_model->getCompanyMemberIds($v["cid"]);
                     $user_ids = array_merge($user_ids, $uids);
                 }
                 $sub_model = new Group_Model();
                 $gids = $sub_model->getUserAllGroupId($this->user_id);
                 foreach ($gids as $v) {
                     $uids = $sub_model->getGroupAllMember($v["gid"]);
                     array_walk($uids, function (&$item) {
                         $item = $item["uid"];
                     });
                     $user_ids = array_merge($user_ids, $uids);
                 }
                 unset($cids, $gids, $sub_model);
                 array_walk($user_ids, function (&$item) {
                     $item = (int) $item;
                 });
                 $user_ids[] = (int) $this->user_id;
                 $user_ids = array_unique($user_ids);
                 $where['privacy'] = array('$in' => array(6, 7, 14, 15));
                 break;
             }
         } while (0);
         $where['user_id'] = array('$in' => $user_ids);
     } else {
         // 同城,(钩上同城选项)或者(好友、群友、同事、在同城)
         $where['privacy'] = array('$in' => array(0, 8, 9, 14, 15));
         if (!$city) {
             $where['city'] = self::city_visitors();
         }
     }
     self::get_market_json($where, $keyword);
 }