當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。