当前位置: 首页>>代码示例>>PHP>>正文


PHP User_Model::instance方法代码示例

本文整理汇总了PHP中User_Model::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP User_Model::instance方法的具体用法?PHP User_Model::instance怎么用?PHP User_Model::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User_Model的用法示例。


在下文中一共展示了User_Model::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setFirst

 public function setFirst()
 {
     // 获取要赠送的短信的条数
     $sms_count = 0;
     $fields = array();
     // 如果还没设置过信息,则进行设置,并送短信
     foreach ($this->_support as $field => $smsCount) {
         $this->_field = $field;
         if (!$this->hasSet() && $this->_support[$this->_field] > 0) {
             $sms_count += $smsCount;
             $fields[] = $field;
         }
     }
     if ($sms_count > 0) {
         // 赠送短信,并发送通知
         $user = User_Model::instance();
         $smsUpdateStr = $this->smsUpdateStr();
         $content = '您好,这是您第一次设置' . $smsUpdateStr . ',系统赠送了' . $sms_count . '条短信给您';
         // echo $content;
         try {
             // @todo 应该支持事务操作
             $updated = $this->updateField($fields);
             $user->present_sms($this->_uid, $sms_count, $content, false);
         } catch (Exception $e) {
         }
     }
     return $sms_count;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:28,代码来源:set_info_1st_time.php

示例2:

 /**
  * 单例模式
  * @return User_Model
  */
 public static function &instance()
 {
     if (!isset(self::$instance)) {
         // Create a new instance
         self::$instance = new User_Model();
     }
     return self::$instance;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:12,代码来源:user.php

示例3: add

 public function add()
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     $data = $this->get_data();
     $uid = isset($data['user_id']) ? $data['user_id'] : 0;
     if ($uid = (int) $uid) {
         if ($this->model->check_isfriend($this->user_id, $uid)) {
             $this->send_response(400, NULL, "你们已经是好友");
         }
         if (!User_Model::instance()->get_user_by_id($uid)) {
             $this->send_response(400, NULL, "用户不存在");
         }
         $status = $this->model->add_friend($this->user_id, $uid);
         $this->send_response(200, array("status" => $status));
     }
     $this->send_response(400, NULL, "输入有误");
 }
开发者ID:momoim,项目名称:momo-api,代码行数:19,代码来源:friend.php

示例4: getsmscount

 /**
  *
  * 获取可用短信条数
  */
 public static function getsmscount($uid)
 {
     $data = User_Model::instance()->get_sms_count($uid);
     return $data;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:9,代码来源:sns.php

示例5: event

 public function event($result)
 {
     //$list=array(1,482,15);
     //if(!in_array($result['sender_uid'], $list)) return;
     if (empty($result["receive_time"])) {
         //第一次打开
         $start_time = strtotime('2011-12-31 00:00:00');
         $end_time = strtotime('2012-01-05 23:59:59');
         $now = time();
         if ($now > $start_time && $now < $end_time) {
             //活动期间
             if ($result["content_type"] == 1) {
                 //音频
                 $sender_uid = $result['sender_uid'];
                 $query = $this->db->query("select * from tmp_event_20111225 where uid=" . $sender_uid);
                 $r = $query->result_array(FALSE);
                 if ($r) {
                 } else {
                     //发送者还未获得奖励
                     $content = "恭喜您成功通过MO短信发送语音信息,获得15张6寸彩照的免费冲印大礼,您的免费冲印优惠码:913030,在线冲印地址: http://t.momo.im/71guu (您可以通过电脑登录momo.im网站访问冲印链接),优惠码使用演示: http://ly.91.com/s";
                     User_Model::instance()->present_mo_notice(Kohana::config('uap.xiaomo'), $sender_uid, $content);
                     $this->db->query("insert into tmp_event_20111225 (uid,receiver_uid,open_time) values (" . $sender_uid . "," . $result['receiver_uid'] . "," . $now . ")");
                 }
             }
         }
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:27,代码来源:url.php

示例6: is_user_exist

 /**
  * 检查机器人是否存在
  * @param $robot_id 机器人ID
  * @return bool
  */
 public function is_user_exist($robot_id)
 {
     $user_info = User_Model::instance()->get_user_info($robot_id);
     if ($user_info) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:14,代码来源:app.php

示例7: destroy

 /**
  * 删除群
  * @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, '删除群失败');
 }
开发者ID:momoim,项目名称:momo-api,代码行数:33,代码来源:group.php

示例8: add

 /**
  * 
  * 添加群成员
  * @param $id
  */
 public function add($id = 0)
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     $data = $this->get_data();
     $uid = $data['uid'] ? $data['uid'] : '';
     if (empty($uid)) {
         $this->send_response(400, NULL, '400403:成员uid为空');
     }
     $uids = explode(',', $uid);
     $groupId = (int) $id;
     if (empty($id)) {
         $this->send_response(400, NULL, '400401:群ID为空');
     }
     $groupInfo = $this->model->getGroupInfo($groupId);
     if (!$groupInfo) {
         $this->send_response(400, NULL, '400402:群不存在');
     }
     $user = sns::getuser($this->user_id);
     /*
         	$grade = $this->model->getMemberGrade($groupId, $this->user_id);
     if($grade < Kohana::config('group.grade.manager')) {
         $this->send_response(400, NULL, '400404:非群管理员,无权限添加成员');
     }
     */
     //查询群组成员总数是否超出最大限制(暂定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 + count($uids) >= $maxMemberNum) {
         $this->send_response(400, NULL, '400110:群成员人数已满');
     }
     $add_uids = array();
     foreach ($uids as $v) {
         $grade = $this->model->getMemberGrade($groupId, $v);
         if (!$grade) {
             $add_uids[] = $v;
         }
     }
     $i = 0;
     $content = $user['realname'] . '将您加入到群"' . $groupInfo['gname'] . '"';
     $opt = array('group' => array('type' => 1, 'id' => $groupId, 'name' => $groupInfo['gname']));
     $xiaomo_uid = Kohana::config('uap.xiaomo');
     if (count($add_uids) > 0) {
         foreach ($add_uids as $u) {
             if ($this->model->addGroupMember($groupId, $u, 1)) {
                 $i++;
                 Tab_Model::instance()->create($u, 1, $groupId);
                 $this->model->addMemberNum($groupId);
                 User_Model::instance()->present_mo_notice($xiaomo_uid, $u, $content, $opt);
             }
         }
     }
     $this->send_response(200, array('num' => $i));
 }
开发者ID:momoim,项目名称:momo-api,代码行数:64,代码来源:group_member.php

示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->model = User_Model::instance();
     $this->friend_model = Friend_Model::instance();
 }
开发者ID:momoim,项目名称:momo-api,代码行数:6,代码来源:user.php

示例10: invite_create

 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);
 }
开发者ID:momoim,项目名称:momo-api,代码行数:42,代码来源:activity_member.php

示例11: is_contact

 /**
  * 获取我的联系人中是否存在该手机号码
  * @param int $user_id
  * @param string $friend_user_id
  * @return bool
  */
 public function is_contact($user_id, $friend_user_id)
 {
     //获取对方手机国家码和号码
     $user_info = User_Model::instance()->get_user_info($friend_user_id);
     if (!empty($user_info) and !empty($user_info['zone_code']) and !empty($user_info['mobile'])) {
         $search = '+' . $user_info['zone_code'] . $user_info['mobile'];
         $list = $this->get($user_id);
         foreach ($list as $val) {
             foreach ($val['tels'] as $tel) {
                 if ($tel['search'] == $search) {
                     return TRUE;
                 }
             }
         }
     }
     return FALSE;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:23,代码来源:contact.php

示例12: retrunAllow

 /**
  * 决定是否显示评论框
  * @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;
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:28,代码来源:comment.php

示例13: destroyToken

 /**
  * 取消授权
  * @param Int $user_id
  * @param String $type
  * @return Boolean
  */
 public function destroyToken($user_id, $type = null)
 {
     $where['uid'] = $user_id;
     if ($type !== null) {
         $where['site'] = $type;
     }
     $query = $this->db->set(array("oauth_token" => "", "oauth_token_secret" => "", "disable" => "Y"))->where($where)->update('oauth_token');
     if ($query->count()) {
         //@todo 查找url匹配再删除
         $status = $this->db->delete("personal_urls", array("uid" => $user_id, "type" => $type));
         if (count($status) < 0) {
             return FALSE;
         }
         //执行用户信息完善度信息更新
         $user_model = User_Model::instance();
         $user_info = $user_model->get_user_info($user_id);
         $member_field = array("completed" => $user_info['completed'] - 10);
         $user_model->update_user_info($user_id, $member_field);
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:29,代码来源:bind.php

示例14: counts

 /**
  * 系统消息统计
  * @return <type>
  */
 public function counts()
 {
     $messageModel = new Message_Model();
     $res = $messageModel->getNewNoticeNum($this->uid);
     //获取新通知条数
     if ($res) {
         $noticeNum = (int) $res;
     } else {
         $noticeNum = 0;
     }
     $aboutmeNum = $this->feedModel->aboutMeNewCount();
     // 取得新的消息的统计
     $smsNum = User_Model::instance()->get_sms_count($this->uid);
     $this->send_response(200, array('message_count' => $noticeNum, 'aboutme_count' => $aboutmeNum, 'sms_count' => $smsNum));
 }
开发者ID:momoim,项目名称:momo-api,代码行数:19,代码来源:statuses.php

示例15: __construct

 /**
  * 构造函数
  */
 public function __construct()
 {
     parent::__construct();
     $session = Session::instance();
     $session->set('request_time', microtime(TRUE));
     $this->method = $_SERVER['REQUEST_METHOD'];
     $current_url = url::current();
     $this->current_url = $current_url;
     $url_arr = explode('/', $current_url);
     $dot_pos = strrpos($current_url, '.');
     $back_slash_pos = strpos($current_url, '/');
     if ($back_slash_pos === FALSE) {
         //防止没有设置返回类型的输入
         $this->root = substr($current_url, 0, $dot_pos ? $dot_pos : strlen($current_url));
     } else {
         $this->root = substr($current_url, 0, $back_slash_pos);
         if (isset($url_arr[1]) && !preg_match("/\\d+/is", $url_arr[1])) {
             $this->second = preg_replace('/.(xml|json)$/', '', $url_arr[1]);
         }
     }
     // 不需要授权的模块
     if (in_array($this->root, $this->un_authorized)) {
         return TRUE;
     }
     // 不需要授权的接口
     $url = preg_replace('/.(xml|json)$/', '', $this->current_url);
     if (in_array($url, $this->no_auth)) {
         return TRUE;
     }
     $headers = self::get_all_headers();
     $access_token = $this->get_access_token($headers);
     if (empty($access_token)) {
         $this->send_response(401, NULL, Kohana::lang('authorization.missing_auth'));
     }
     $token = User_Model::instance()->get_access_token($access_token);
     if (empty($token)) {
         $this->send_response(401, NULL, Kohana::lang('authorization.missing_auth'));
     }
     if (isset($token['expires']) && time() > $token['expires']) {
         $this->send_response(401, NULL, Kohana::lang('authorization.auth_expired'));
     }
     $this->user_id = $this->uid = $token['id'];
     return TRUE;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:47,代码来源:MY_Controller.php


注:本文中的User_Model::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。