Exemple #1
0
 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();
 }
Exemple #2
0
 public function __construct()
 {
     parent::__construct();
     $this->model = new Message_Model();
     $this->message_type = null;
     $this->activityModel = Activity_Model::instance();
     $this->friendModel = Friend_Model::instance();
     $this->groupModel = Group_Model::instance();
     $this->groupContactModel = Group_Contact_Model::instance();
     $this->contactModel = Contact_Model::instance();
 }
Exemple #3
0
 /**
  * 添加赞
  */
 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, '赞失败,你已经赞过');
 }
Exemple #4
0
 public function getFriendFeedNew($uid, $uptime, $pretime, $downtime, $pos, $type_id = 0)
 {
     $uptime = $uptime . '';
     $downtime = $downtime . '';
     $pretime = $pretime . '';
     $direct = '';
     if ($uptime && $downtime) {
         $direct = 'middle';
     } else {
         if ($uptime) {
             $direct = 'up';
         } else {
             if ($downtime) {
                 $direct = 'down';
             } else {
                 if ($pretime) {
                     $direct = 'pre';
                 }
             }
         }
     }
     $uids = null;
     if (!$uids) {
         $uids = $this->friend->get_user_link_cache($uid);
         $uids[] = $uid . '';
         $uids[] = Kohana::config('uap.xiaomo');
         //群组动态
         $group_array = Group_Model::instance()->getUserAllGroupId($uid);
         if ($group_array) {
             foreach ($group_array as $group) {
                 $uids[] = '1_' . $group['gid'];
             }
         }
     }
     switch ($direct) {
         case 'pre':
             $condition = array('mix_id' => array('$in' => $uids), 'last_updated' => array('$gt' => $pretime), '_id' => array('$nin' => $this->hiddenId()));
             $deltime = $pretime;
             break;
         case 'up':
             $condition = array('mix_id' => array('$in' => $uids), 'last_updated' => array('$gt' => $uptime), '_id' => array('$nin' => $this->hiddenId()));
             $deltime = $uptime;
             break;
         case 'down':
             //$pos += 1;
             $condition = array('mix_id' => array('$in' => $uids), 'last_updated' => array('$lt' => $downtime), '_id' => array('$nin' => $this->hiddenId()));
             break;
         case 'middle':
             $condition = array('mix_id' => array('$in' => $uids), 'last_updated' => array('$lt' => $uptime, '$gt' => $downtime), '_id' => array('$nin' => $this->hiddenId()));
             break;
         default:
             $condition = array('mix_id' => array('$in' => $uids), '_id' => array('$nin' => $this->hiddenId()));
             break;
     }
     $id_del = array();
     if ($direct == 'pre' || $direct == 'up') {
         $con_del = array('qid' => array('$in' => $uids), 'time' => array('$gt' => $deltime));
         $cur = $this->m->selectCollection('feed_del');
         $arr_del = iterator_to_array($cur->find($con_del));
         foreach ($arr_del as $row_del) {
             if ($row_del['objid']) {
                 $id_del[] = array('id' => $row_del['objid']);
             }
         }
         $con_del = array('uid' => intval($uid), 'time' => array('$gt' => $deltime));
         $cur = $this->m->selectCollection('feed_hide');
         $arr_del = iterator_to_array($cur->find($con_del));
         foreach ($arr_del as $row_del) {
             if ($row_del['objid']) {
                 $id_del[] = array('id' => $row_del['objid']);
             }
         }
     }
     if ($type_id) {
         $condition['typeid'] = intval($type_id);
     }
     if ($direct == 'pre') {
         $col = $this->feed_new->find($condition)->sort(array('last_updated' => 1))->limit(intval($pos));
     } else {
         $col = $this->feed_new->find($condition)->sort(array('last_updated' => -1))->limit(intval($pos));
     }
     $arr = iterator_to_array($col);
     if ($direct == 'pre') {
         $arr = array_reverse($arr);
     }
     $count = count($arr);
     if ($count) {
         $res = array('code' => 200, 'result' => array('count' => $count, 'data' => $arr, 'delete' => $id_del));
     } else {
         $res = array('code' => 404, 'result' => array('delete' => $id_del));
     }
     return $res;
 }
Exemple #5
0
 /**
  * 从群组中删除
  * @param  $event_info   活动信息
  */
 private function _del_group_user($gid, $uid)
 {
     //从群组中删除
     if (Group_Model::instance()->delGroupMember($gid, $uid)) {
         Group_Model::instance()->reduceMemberNum($gid);
     }
     //从tab中删除
     Tab_Model::instance()->delete($uid, Kohana::config('group.type.event'), $gid);
 }
Exemple #6
0
 private function _add_feed_comment($activity, $old_apply_type, $apply_type, $uid)
 {
     $feedModel = new Feed_Model();
     if ($apply_type == Kohana::config('activity.apply_type.join')) {
         $feedStatus = "参加";
         $applyStatus = "参加";
     } else {
         if ($apply_type == Kohana::config('activity.apply_type.interest')) {
             $feedStatus = "关注";
             $applyStatus = "感兴趣";
         }
     }
     if ($activity['gid'] != 0) {
         if ($apply_type != Kohana::config('activity.apply_type.not_join')) {
             $commentModel = new Comment_Model();
             $content = "参与报名:" . $applyStatus;
             if ($activity['feed_id']) {
                 $feed_id = $activity['feed_id'];
                 $feedInfo = $feedModel->getFeedById($feed_id);
                 if ($feedInfo) {
                     $group_type = $feedInfo[$feed_id]['group_type'];
                     $group_id = $feedInfo[$feed_id]['group_id'];
                     $owner_uid = $feedInfo[$feed_id]['owner_uid'];
                     if (!$group_type) {
                         //好友
                         $friendModel = Friend_Model::instance();
                         $isFriend = $friendModel->check_isfriend($owner_uid, $uid);
                         if ($isFriend) {
                             $commentModel->saveComment($feed_id, $content, $owner_uid);
                         }
                     } else {
                         if ($group_type == 1) {
                             //群内
                             $groupModel = Group_Model::instance();
                             $grade = $groupModel->getMemberGrade($group_id, $uid);
                             if ($grade > 0) {
                                 $commentModel->saveComment($feed_id, $content, $owner_uid);
                             }
                         } else {
                             if ($group_type == 2) {
                                 //活动内
                                 $activityModel = Activity_Model::instance();
                                 $apply_type = $activityModel->getActivityApplyType($group_id, $uid);
                                 if ($apply_type > 0) {
                                     $commentModel->saveComment($feed_id, $content, $owner_uid);
                                 }
                             }
                         }
                     }
                 }
             }
             if ($activity['action_feed_id']) {
                 $commentModel->saveComment($activity['action_feed_id'], $content, $activity['creator_id']);
             }
         }
     }
     if (!$old_apply_type && ($apply_type == Kohana::config('activity.apply_type.join') || $apply_type == Kohana::config('activity.apply_type.interest')) && $activity['is_allow_invite']) {
         $application = array('id' => floatval($activity['aid']), 'title' => '查看活动', 'url' => 'action/showblogbox/' . $activity['aid']);
         $feedModel->addFeed($uid, 7, $text = $feedStatus . '了活动:' . $activity['title'], $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);
     }
 }
Exemple #7
0
 /**
  * 
  * 获取用户的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;
 }