Rev Author Line No. Line
228 kaklik 1 <?php
2  
3 /**
4 * User class.
5 *
6 * @author Tamlyn Rhodes <tam at zenology dot co dot uk>
7 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
8 * @copyright (c)2003, 2004 Tamlyn Rhodes
9 * @version $Id: user.class.php,v 1.5 2006/03/14 19:38:54 tamlyn Exp $
10 */
11  
12 /**
13 * Class used to represent a user.
14 * @package singapore
15 * @author Tamlyn Rhodes <tam at zenology dot co dot uk>
16 * @copyright (c)2003, 2004 Tamlyn Rhodes
17 */
18 class sgUser
19 {
20 /**
21 * Username of user. Special cases are 'guest' and 'admin'.
22 * @var string
23 */
24 var $username = "";
25  
26 /**
27 * MD5 hash of password
28 * @var string
29 */
30 var $userpass = "5f4dcc3b5aa765d61d8327deb882cf99";
31  
32 /**
33 * Bit-field of permissions
34 * @var int
35 */
36 var $permissions = 0;
37  
38 /**
39 * Space-separated list of groups of which the user is a member
40 * @var string
41 */
42 var $groups = "";
43  
44 /**
45 * Email address of user
46 * @var string
47 */
48 var $email = "";
49  
50 /**
51 * The name or title of the user
52 * @var string
53 */
54 var $fullname = "";
55  
56 /**
57 *Description of user account
58 * @var string
59 */
60 var $description = "";
61  
62 /**
63 * Statistics (what's this? I don't know!)
64 * @var string
65 */
66 var $stats = "";
67  
68 /**
69 * Constructor ensures username and userpass have values
70 */
71 function sgUser($username, $userpass)
72 {
73 $this->username = $username;
74 $this->userpass = $userpass;
75 }
76  
77 /**
78 * Checks if currently logged in user is an administrator.
79 *
80 * @return bool true on success; false otherwise
81 */
82 function isAdmin()
83 {
84 return $this->permissions & SG_ADMIN;
85 }
86  
87 /**
88 * Checks if currently logged in user is a guest.
89 *
90 * @return bool true on success; false otherwise
91 */
92 function isGuest()
93 {
94 return $this->username == "guest";
95 }
96  
97 /**
98 * Checks if this user is the owner of the specified item.
99 *
100 * @param sgItem the item to check
101 * @return bool true if this user is the owner; false otherwise
102 */
103 function isOwner($item)
104 {
105 return $item->owner == $this->username;
106 }
107  
108 /**
109 * Checks if this user is a member of the group(s) supplied
110 *
111 * @return bool true on success; false otherwise
112 */
113 function isInGroup($groups)
114 {
115 return (bool) array_intersect(explode(" ",$groups),explode(" ",$this->groups));
116 }
117  
118  
119 }
120  
121 ?>