コード例 #1
0
ファイル: activity.php プロジェクト: momoim/momo-api
 public function userAboutActivityNum($uid, $end = 0)
 {
     $groupModel = new Group_Model();
     $gidList = $groupModel->getUserAllGroupId($uid);
     $gids = '';
     $separator = '';
     foreach ($gidList as $value) {
         $gids .= $separator . $value['gid'];
         $separator = ',';
     }
     $friendModel = new Friend_Model();
     $fidList = $friendModel->getAllFriendIDs($uid);
     $fids = '';
     if ($fidList) {
         $fids = implode(',', $fidList);
     }
     $applyAids = $this->getApplyAids($uid);
     $companyModel = Company_Model::instance();
     $companyList = $companyModel->getCompanyList($uid);
     $companyIds = "";
     $separator = '';
     foreach ($companyList as $value) {
         $companyIds .= $separator . $value['cid'];
         $separator = ',';
     }
     $belongType = Kohana::config('activity.belongType.company');
     if (!empty($companyIds)) {
         if (empty($applyAids)) {
             $separator = '';
         } else {
             $separator = ',';
         }
         $activityList = $this->getBelongActivityList($belongType, $companyIds);
         foreach ($activityList as $value) {
             $applyAids .= $separator . $value['aid'];
             $separator = ',';
         }
     }
     if ($fids) {
         $where = "(gid = -1 AND creator_id in ({$fids}))";
         $friendApplyaids = $this->getFriendsApplyAids($fids);
         if ($friendApplyaids) {
             $where .= " OR (is_allow_invite = 1 AND aid IN ({$friendApplyaids}))";
         }
     }
     if ($gids) {
         if ($where) {
             $where .= " OR gid in ({$gids})";
         } else {
             $where .= "gid in ({$gids})";
         }
     }
     if ($applyAids) {
         if ($where) {
             $where .= " OR aid in ({$applyAids})";
         } else {
             $where .= "aid in ({$applyAids})";
         }
     }
     if (!$where) {
         return 0;
     }
     if ($end == 0) {
         //未结束的活动
         $nowTime = time();
         $where = "{$nowTime} < end_time AND " . "({$where})";
     }
     $query = $this->db->query("SELECT COUNT(DISTINCT aid) AS num FROM action WHERE {$where}");
     $result = $query->result_array(FALSE);
     return (int) $result[0]['num'];
 }
コード例 #2
0
ファイル: group_contact.php プロジェクト: momoim/momo-api
 /**
  * 更新自己在所有群组的联系人头像
  * @param int $uid 用户ID
  */
 public function updateGroupContactAvatar($uid, $avatarUrl = '')
 {
     $groupModel = new Group_Model();
     $gidList = $groupModel->getUserAllGroupId($uid);
     if ($gidList) {
         $dateline = time();
         $groupInfo['modify_time'] = $dateline;
         //获取头像新地址
         if (!$avatarUrl) {
             $avatarUrl = $this->getSpaceAvatar($uid);
         }
         if (!empty($avatarUrl) && $avatarUrl != Kohana::config('contact.avatar')) {
             foreach ($gidList as $value) {
                 $gid = $value['gid'];
                 $gcid = $this->getGroupCidbyGidAndUid($gid, $uid);
                 if (!$gcid) {
                     continue;
                 }
                 $this->editGroupContactAvatar($gid, $gcid, $avatarUrl, 1);
                 $this->_updateGroupContactModified($gid, $gcid, $dateline);
                 //对应修改群组的修改时间,提供手机端接口同步使用
                 $groupModel->modifyGroup($gid, $groupInfo);
             }
         }
     }
 }
コード例 #3
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);
 }