當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserUtil::getUserNameById方法代碼示例

本文整理匯總了PHP中UserUtil::getUserNameById方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserUtil::getUserNameById方法的具體用法?PHP UserUtil::getUserNameById怎麽用?PHP UserUtil::getUserNameById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserUtil的用法示例。


在下文中一共展示了UserUtil::getUserNameById方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 /**
  *  run this action
  *  @param:  NULL
  *  @return: NULL
  *  @access: public
  */
 public function run()
 {
     //取得參數
     $id = $this->getParameterFromGET('id');
     if (!$id) {
         $this->AlertAndBack(USER_IS_EMPTY);
         return;
     }
     //檢查用戶名是否存在
     $sql = 'select count(*) as num from base_user_info where id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($id));
     $rows = $res->FetchRow();
     if (!$rows['num']) {
         $this->AlertAndBack(USER_IS_NOT_EXISTS);
         return;
     }
     $name = UserUtil::getUserNameById($this->db, $id);
     //檢查用戶是否已經在黑名單中
     $sql = 'select count(*) as num from black_list_by_user where lower(user_name)=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array(strtolower($name)));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $this->AlertAndBack(USER_HAD_BEEN_ADDED);
         return;
     }
     $sql = 'insert into black_list_by_user (user_name) values (?)';
     $sth = $this->db->Prepare($sql);
     $this->db->Execute($sth, array($name));
     $this->AlertAndBack(USER_HAD_BEEN_SUCCESS_ADDED);
     return;
 }
開發者ID:hylinux,項目名稱:ltebbs,代碼行數:39,代碼來源:PutUserBlackList.class.php

示例2: run

 /**
  * 顯示用戶發送短信的界麵
  */
 public function run()
 {
     //求得用戶的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     $smarty = $this->getSmarty();
     $user_name = $_SESSION['user']['name'];
     $smarty->assign('view_user_name', $user_name);
     //用戶的所在組
     $sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('user_roles', $rows['group_name']);
     $user_header = UserUtil::getUserHeader($this->db, $user_id);
     $smarty->assign('head_url', $user_header);
     //查詢新的短消息的數量
     $sql = 'select count(*) as num from message_inbox where user_id=? and is_read = 0 ';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('new_message_label', $rows['num']);
     //共有短消息數
     $sql = 'select count(*) as num from message_inbox where user_id=? ';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('total_message_number', $rows['num']);
     //取得用戶注冊時間
     $sql = 'select register_date from base_user_info where id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheExecute(60 * 60, $stmt, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('user_register_date', $rows['register_date']);
     //取得用戶最後的登錄時間
     $sql = 'SELECT from_unixtime(last_time) as lastlogout FROM `user_last_time_logout` where user_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheExecute(60 * 60, $stmt, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('user_last_logout', $rows['lastlogout']);
     //發表的主題數
     $sql = 'select count(*) as num from bbs_subject where author = ?';
     $stmt = $this->db->Prepare($sql);
     $res = $this->db->CacheExecute(10, $stmt, array($user_name));
     $rows = $res->FetchRow();
     $smarty->assign('all_topic_number', $rows['num']);
     //參與的帖子數
     $sql = 'select count(*) as num from bbs_reply where author=?';
     $stmt = $this->db->Prepare($sql);
     $res = $this->db->CacheExecute(10, $stmt, array($user_name));
     $rows = $res->FetchRow();
     $smarty->assign('all_reply_number', $rows['num']);
     ///擁有的短消息的數量
     $sql = 'select count(*) as num from message_inbox where user_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheExecute(20, $stmt, array($user_id));
     $rows = $res->FetchRow();
     $number_inbox = $rows['num'];
     $sql = 'select count(*) as num from message_outbox where user_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheExecute(20, $stmt, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('message_all_number', $number_inbox + $rows['num']);
     //擁有的收藏數
     $sql = 'select count(*) as num from favor where user_id=?';
     $stmt = $this->db->prepare($sql);
     $res = $this->db->CacheExecute(10, $stmt, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('favor_amount', $rows['num']);
     $fck = new FCKeditor("content");
     $fck->BasePath = FCKEDITOR_BASEPATH;
     $fck->ToolbarSet = 'Basic';
     $fck->Height = '400';
     $fck->Width = '98%';
     $smarty->assign('fck', $fck);
     //檢查用戶是否傳入了id
     //如果傳入了id,則為其預填需要
     //發送的的用戶名
     $send_user_id = $this->getParameter('id');
     $send_user_name = UserUtil::getUserNameById($this->db, $send_user_id);
     $smarty->assign('send_user_name', $send_user_name);
     $smarty->assign('backurl', $this->getParameter('backurl'));
     $smarty->display('showsend.tmpl');
 }
開發者ID:hylinux,項目名稱:ltebbs,代碼行數:86,代碼來源:ShowSend.class.php

示例3: run

 /**
  * 查看用戶的個人信息
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //取得用戶的id
     $user_id = $this->getParameterFromGET('id');
     if (!$user_id && $user_id != 0) {
         $this->AlertAndBack(VU_USER_ID_IS_EMPTY);
         return;
     }
     if ($user_id == 0) {
         $this->AlertAndBack(VU_USER_IS_SYSTEM);
         return;
     }
     if (!UserUtil::isExists($this->db, $user_id)) {
         $this->AlertAndBack(VU_USER_IS_NOT_EXISTS);
         return;
     }
     $smarty = $this->getSmarty();
     //back url
     $back_url = 'index.php?module=user&action=view&id=' . $user_id;
     $back_url = base64_encode($back_url);
     $smarty->assign('backurl', $back_url);
     //assign user id
     $smarty->assign('user_id', $user_id);
     //用戶名
     $user_name = UserUtil::getUserNameById($this->db, $user_id);
     $smarty->assign('view_user_name', $user_name);
     //用戶所在的組
     $sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     $smarty->assign('user_roles', $rows['group_name']);
     //判斷用戶是否在線
     $sql = 'select count(*) as num from online_user where user_name =? ';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_name));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $smarty->assign('user_is_online', 1);
     } else {
         $smarty->assign('user_is_online', 0);
     }
     //求用戶的頭像
     $user_header = UserUtil::getUserHeader($this->db, $user_id);
     $smarty->assign('head_url', $user_header);
     $sql = 'select user_gender,user_birthday, public_birthday, user_email, public_user_email, ' . 'user_website, public_website, register_date, user_icq, public_user_icq, user_AIM, ' . 'public_user_AIM, user_msn, public_user_msn, user_yahoo, public_user_yahoo,user_skype, ' . ' public_user_skype, user_qq, public_user_qq, user_hometown, user_favor, user_sign ' . ' from base_user_info where id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     //性別
     $smarty->assign('user_sex', $rows['user_gender']);
     //生日
     if ($rows['public_birthday']) {
         $smarty->assign('user_birthday', $rows['user_birthday']);
     } else {
         $smarty->assign('user_birthday', VU_NOT_PUBLIC);
     }
     //電子郵件
     if ($rows['public_user_email']) {
         $smarty->assign('user_email', $rows['user_email']);
     } else {
         $smarty->assign('user_email', VU_NOT_PUBLIC);
     }
     //個人網站
     if ($rows['public_website']) {
         $smarty->assign('user_website', $rows['user_website']);
     } else {
         $smarty->assign('user_website', VU_NOT_PUBLIC);
     }
     //注冊日期
     $smarty->assign('user_register_date', $rows['register_date']);
     //ICQ
     if ($rows['public_user_icq']) {
         $smarty->assign('user_icq', $rows['user_icq']);
     } else {
         $smarty->assign('user_icq', VU_NOT_PUBLIC);
     }
     //AIM
     if ($rows['public_user_AIM']) {
         $smarty->assign('user_aim', $rows['user_AIM']);
     } else {
         $smarty->assign('user_aim', VU_NOT_PUBLIC);
     }
     //MSN
     if ($rows['public_user_msn']) {
         $smarty->assign('user_msn', $rows['user_msn']);
     } else {
         $smarty->assign('user_msn', VU_NOT_PUBLIC);
     }
     //Yahoo
     if ($rows['public_user_yahoo']) {
         $smarty->assign('user_yahoo', $rows['user_yahoo']);
     } else {
         $smarty->assign('user_yahoo', VU_NOT_PUBLIC);
//.........這裏部分代碼省略.........
開發者ID:hylinux,項目名稱:ltebbs,代碼行數:101,代碼來源:ViewUser.class.php


注:本文中的UserUtil::getUserNameById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。