Users.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: Users.php 25756 2011-11-22 02:47:45Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class Cloud_Service_Server_Users extends Cloud_Service_Server_Restful {
  12. protected static $_instance;
  13. public static function getInstance() {
  14. if (!(self::$_instance instanceof self)) {
  15. self::$_instance = new self();
  16. }
  17. return self::$_instance;
  18. }
  19. public function onUsersGetInfo($uIds, $fields = array(), $isExtra = false) {
  20. $users = $this->getUsers($uIds, false, true, $isExtra, false);
  21. $result = array();
  22. if ($users) {
  23. if ($fields) {
  24. foreach($users as $key => $user) {
  25. foreach($user as $k => $v) {
  26. if (in_array($k, $fields)) {
  27. $result[$key][$k] = $v;
  28. }
  29. }
  30. }
  31. }
  32. }
  33. if (!$result) {
  34. $result = $users;
  35. }
  36. return $result;
  37. }
  38. public function onUsersGetFriendInfo($uId, $num = MY_FRIEND_NUM_LIMIT, $isExtra = false) {
  39. $users = $this->getUsers(array($uId), false, true, $isExtra, true, $num, false, true);
  40. $totalNum = C::t('home_friend')->count_by_uid($uId);
  41. $friends = $users[0]['friends'];
  42. unset($users[0]['friends']);
  43. $result = array('totalNum' => $totalNum,
  44. 'friends' => $friends,
  45. 'me' => $users[0],
  46. );
  47. return $result;
  48. }
  49. public function onUsersGetExtraInfo($uIds) {
  50. $result = $this->getExtraByUsers($uIds);
  51. return $result;
  52. }
  53. public function onUsersGetFormHash($uId, $userAgent) {
  54. global $_G;
  55. $uId = intval($uId);
  56. if (!$uId) {
  57. return false;
  58. }
  59. $member = getuserbyuid($uId, 1);
  60. $_G['username'] = $member['username'];
  61. $_G['uid'] = $member['uid'];
  62. $_G['authkey'] = md5($_G['config']['security']['authkey'] . $userAgent);
  63. return formhash();
  64. }
  65. }