XOOPS  2.6.0
user.php
Go to the documentation of this file.
1 <?php
23 
30 class XoopsUser extends XoopsObject
31 {
37  private $_groups = array();
38 
43  private $_rank = null;
44 
49  private $_isOnline = null;
50 
57  public function __construct($id = null)
58  {
59  $this->initVar('uid', XOBJ_DTYPE_INT, null, false);
60  $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false, 60);
61  $this->initVar('uname', XOBJ_DTYPE_TXTBOX, null, true, 25);
62  $this->initVar('email', XOBJ_DTYPE_TXTBOX, null, true, 60);
63  $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false, 100);
64  $this->initVar('user_avatar', XOBJ_DTYPE_TXTBOX, null, false, 30);
65  $this->initVar('user_regdate', XOBJ_DTYPE_INT, null, false);
66  $this->initVar('user_icq', XOBJ_DTYPE_TXTBOX, null, false, 15);
67  $this->initVar('user_from', XOBJ_DTYPE_TXTBOX, null, false, 100);
68  $this->initVar('user_sig', XOBJ_DTYPE_TXTAREA, null, false, null);
69  $this->initVar('user_viewemail', XOBJ_DTYPE_INT, 0, false);
70  $this->initVar('actkey', XOBJ_DTYPE_OTHER, null, false);
71  $this->initVar('user_aim', XOBJ_DTYPE_TXTBOX, null, false, 18);
72  $this->initVar('user_yim', XOBJ_DTYPE_TXTBOX, null, false, 25);
73  $this->initVar('user_msnm', XOBJ_DTYPE_TXTBOX, null, false, 100);
74  $this->initVar('pass', XOBJ_DTYPE_TXTBOX, null, false, 255);
75  $this->initVar('posts', XOBJ_DTYPE_INT, null, false);
76  $this->initVar('attachsig', XOBJ_DTYPE_INT, 0, false);
77  $this->initVar('rank', XOBJ_DTYPE_INT, 0, false);
78  $this->initVar('level', XOBJ_DTYPE_INT, 0, false);
79  $this->initVar('theme', XOBJ_DTYPE_OTHER, null, false);
80  $this->initVar('timezone_offset', XOBJ_DTYPE_OTHER, '0.0', false);
81  $this->initVar('last_login', XOBJ_DTYPE_INT, 0, false);
82  $this->initVar('umode', XOBJ_DTYPE_OTHER, null, false);
83  $this->initVar('uorder', XOBJ_DTYPE_INT, 1, false);
84  // RMV-NOTIFY
85  $this->initVar('notify_method', XOBJ_DTYPE_OTHER, 1, false);
86  $this->initVar('notify_mode', XOBJ_DTYPE_OTHER, 0, false);
87  $this->initVar('user_occ', XOBJ_DTYPE_TXTBOX, null, false, 100);
88  $this->initVar('bio', XOBJ_DTYPE_TXTAREA, null, false, null);
89  $this->initVar('user_intrest', XOBJ_DTYPE_TXTBOX, null, false, 150);
90  $this->initVar('user_mailok', XOBJ_DTYPE_INT, 1, false);
91  // for backward compatibility
92  if (isset($id)) {
93  if (is_array($id)) {
94  $this->assignVars($id);
95  } else {
97  $member_handler = $xoops->getHandlerMember();
98  $user = $member_handler->getUser($id);
99  foreach ($user->vars as $k => $v) {
100  $this->assignVar($k, $v['value']);
101  }
102  }
103  }
104  }
105 
111  public function isGuest()
112  {
113  return false;
114  }
115 
124  public static function getUnameFromId($userid, $usereal = 0)
125  {
126  $xoops = xoops::getInstance();
127  $userid = intval($userid);
128  $usereal = intval($usereal);
129  if ($userid > 0) {
130  $member_handler = $xoops->getHandlerMember();
131  $user = $member_handler->getUser($userid);
132  if (is_object($user)) {
134  if ($usereal) {
135  $name = $user->getVar('name');
136  if ($name != '') {
137  return $ts->htmlSpecialChars($name);
138  } else {
139  return $ts->htmlSpecialChars($user->getVar('uname'));
140  }
141  } else {
142  return $ts->htmlSpecialChars($user->getVar('uname'));
143  }
144  }
145  }
146  return $xoops->getConfig('anonymous');
147  }
148 
155  public function incrementPost()
156  {
157  return Xoops::getInstance()->getHandlerMember()->updateUserByField($this, 'posts', $this->getVar('posts') + 1);
158  }
159 
165  public function setGroups($groupsArr)
166  {
167  if (is_array($groupsArr)) {
168  $this->_groups = $groupsArr;
169  }
170  }
171 
177  public function getGroups()
178  {
179  if (empty($this->_groups)) {
180  $this->_groups = Xoops::getInstance()->getHandlerMember()->getGroupsByUser($this->getVar('uid'));
181  }
182  return $this->_groups;
183  }
184 
191  public function groups()
192  {
193  $groups = $this->getGroups();
194  return $groups;
195  }
196 
207  public function isAdmin($module_id = null)
208  {
209  $xoops = xoops::getInstance();
210  if (is_null($module_id)) {
211  $module_id = $xoops->isModule() ? $xoops->module->getVar('mid', 'n') : 1;
212  } elseif (intval($module_id) < 1) {
213  $module_id = 0;
214  }
215  $moduleperm_handler = $xoops->getHandlerGroupperm();
216  return $moduleperm_handler->checkRight('module_admin', $module_id, $this->getGroups());
217  }
218 
224  public function rank()
225  {
227  if (!isset($this->_rank) && $xoops->isActiveModule('userrank')) {
228  $this->_rank = $xoops->getRank($this->getVar('rank'), $this->getVar('posts'));
229  }
230  return $this->_rank;
231  }
232 
238  public function isActive()
239  {
240  if ($this->getVar('level') == 0) {
241  return false;
242  }
243  return true;
244  }
245 
251  public function isOnline()
252  {
253  if (!isset($this->_isOnline)) {
254  $online_handler = Xoops::getInstance()->getHandlerOnline();
255  $this->_isOnline = ($online_handler->getCount(new Criteria('online_uid', $this->getVar('uid'))) > 0) ? true : false;
256  }
257  return $this->_isOnline;
258  }
259 
264  public function uid($format = '')
265  {
266  return $this->getVar('uid', $format);
267  }
268 
273  public function id($format = 'n')
274  {
275  return $this->getVar('uid', $format);
276  }
277 
282  public function name($format = '')
283  {
284  return $this->getVar('name', $format);
285  }
286 
291  public function uname($format = '')
292  {
293  return $this->getVar('uname', $format);
294  }
295 
300  public function email($format = '')
301  {
302  return $this->getVar('email', $format);
303  }
304 
309  public function url($format = '')
310  {
311  return $this->getVar('url', $format);
312  }
313 
318  public function user_avatar($format = '')
319  {
320  return $this->getVar('user_avatar', $format);
321  }
322 
327  public function user_regdate($format = '')
328  {
329  return $this->getVar('user_regdate', $format);
330  }
331 
336  public function user_icq($format = 'S')
337  {
338  return $this->getVar('user_icq', $format);
339  }
340 
345  public function user_from($format = '')
346  {
347  return $this->getVar('user_from', $format);
348  }
349 
354  public function user_sig($format = '')
355  {
356  return $this->getVar('user_sig', $format);
357  }
358 
363  public function user_viewemail($format = '')
364  {
365  return $this->getVar('user_viewemail', $format);
366  }
367 
372  public function actkey($format = '')
373  {
374  return $this->getVar('actkey', $format);
375  }
376 
381  public function user_aim($format = '')
382  {
383  return $this->getVar('user_aim', $format);
384  }
385 
390  public function user_yim($format = '')
391  {
392  return $this->getVar('user_yim', $format);
393  }
394 
399  public function user_msnm($format = '')
400  {
401  return $this->getVar('user_msnm', $format);
402  }
403 
408  public function pass($format = '')
409  {
410  return $this->getVar('pass', $format);
411  }
412 
417  public function posts($format = '')
418  {
419  return $this->getVar('posts', $format);
420  }
421 
426  public function attachsig($format = '')
427  {
428  return $this->getVar('attachsig', $format);
429  }
430 
435  public function level($format = '')
436  {
437  return $this->getVar('level', $format);
438  }
439 
444  public function theme($format = '')
445  {
446  return $this->getVar('theme', $format);
447  }
448 
453  public function timezone($format = '')
454  {
455  return $this->getVar('timezone_offset', $format);
456  }
457 
462  public function umode($format = '')
463  {
464  return $this->getVar('umode', $format);
465  }
466 
471  public function uorder($format = '')
472  {
473  return $this->getVar('uorder', $format);
474  }
475 
480  public function notify_method($format = '')
481  {
482  return $this->getVar('notify_method', $format);
483  }
484 
489  public function notify_mode($format = '')
490  {
491  return $this->getVar('notify_mode', $format);
492  }
493 
498  public function user_occ($format = '')
499  {
500  return $this->getVar('user_occ', $format);
501  }
502 
507  public function bio($format = '')
508  {
509  return $this->getVar('bio', $format);
510  }
511 
516  public function user_intrest($format = '')
517  {
518  return $this->getVar('user_intrest', $format);
519  }
520 }
521 
529 {
530 
536  public function __construct(Connection $db = null)
537  {
538  parent::__construct($db, 'users', 'XoopsUser', 'uid', 'uname');
539  }
540 
546  public function isGuest()
547  {
548  return true;
549  }
550 }
551 
562 {
563 
569  public function __construct(Connection $db = null)
570  {
571  parent::__construct($db, 'users', 'XoopsUser', 'uid', 'uname');
572  }
573 
574 }
$_groups
Definition: user.php:37
posts($format= '')
Definition: user.php:417
actkey($format= '')
Definition: user.php:372
setGroups($groupsArr)
Definition: user.php:165
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
user_yim($format= '')
Definition: user.php:390
user_intrest($format= '')
Definition: user.php:516
static getInstance()
Definition: Xoops.php:160
__construct(Connection $db=null)
Definition: user.php:569
$module_id
Definition: update.php:56
theme($format= '')
Definition: user.php:444
name($format= '')
Definition: user.php:282
$user
Definition: checklogin.php:47
uname($format= '')
Definition: user.php:291
isOnline()
Definition: user.php:251
bio($format= '')
Definition: user.php:507
$_isOnline
Definition: user.php:49
rank()
Definition: user.php:224
uid($format= '')
Definition: user.php:264
getVar($key, $format= 's')
user_occ($format= '')
Definition: user.php:498
user_regdate($format= '')
Definition: user.php:327
user_viewemail($format= '')
Definition: user.php:363
$id
Definition: admin_menu.php:36
attachsig($format= '')
Definition: user.php:426
isActive()
Definition: user.php:238
user_sig($format= '')
Definition: user.php:354
uorder($format= '')
Definition: user.php:471
user_aim($format= '')
Definition: user.php:381
const XOBJ_DTYPE_TXTAREA
Definition: XoopsObject.php:21
getGroups()
Definition: user.php:177
static getUnameFromId($userid, $usereal=0)
Definition: user.php:124
user_icq($format= 'S')
Definition: user.php:336
pass($format= '')
Definition: user.php:408
level($format= '')
Definition: user.php:435
timezone($format= '')
Definition: user.php:453
__construct(Connection $db=null)
Definition: user.php:536
incrementPost()
Definition: user.php:155
umode($format= '')
Definition: user.php:462
notify_method($format= '')
Definition: user.php:480
$groups
url($format= '')
Definition: user.php:309
user_from($format= '')
Definition: user.php:345
$_rank
Definition: user.php:43
user_avatar($format= '')
Definition: user.php:318
groups()
Definition: user.php:191
$xoops
Definition: user.php:29
email($format= '')
Definition: user.php:300
isGuest()
Definition: user.php:111
id($format= 'n')
Definition: user.php:273
user_msnm($format= '')
Definition: user.php:399
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
$moduleperm_handler
Definition: cp_header.php:31
__construct($id=null)
Definition: user.php:57
notify_mode($format= '')
Definition: user.php:489
isAdmin($module_id=null)
Definition: user.php:207