1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PendingUser class |
4
|
|
|
* |
5
|
|
|
* This file describes the PendingUser classes |
6
|
|
|
* |
7
|
|
|
* PHP version 5 and 7 |
8
|
|
|
* |
9
|
|
|
* @author Patrick Boyd / [email protected] |
10
|
|
|
* @copyright Copyright (c) 2015, Austin Artistic Reconstruction |
11
|
|
|
* @license http://www.apache.org/licenses/ Apache 2.0 License |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Auth; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A class to abstract access to PendingUsers (users that have not completed registration) regardless of the Authentication type used. |
18
|
|
|
* |
19
|
|
|
* This class is the primary method to access pending user information. |
20
|
|
|
*/ |
21
|
|
|
class PendingUser extends User |
22
|
|
|
{ |
23
|
|
|
protected $intData = array(); |
24
|
|
|
|
25
|
|
|
public function getHash() |
26
|
|
|
{ |
27
|
|
|
return false; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getRegistrationTime() |
31
|
|
|
{ |
32
|
|
|
return false; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Is this user in the Group or a child of that group? |
37
|
|
|
* |
38
|
|
|
* @param string $name The name of the group to check if the user is in |
39
|
|
|
* |
40
|
|
|
* @return boolean True if the user is in the group, false otherwise |
41
|
|
|
*/ |
42
|
|
|
public function isInGroupNamed($name) |
43
|
|
|
{ |
44
|
|
|
return false; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The email address for the user |
49
|
|
|
* |
50
|
|
|
* @return string The user's email address |
51
|
|
|
*/ |
52
|
|
|
public function getEmail() |
53
|
|
|
{ |
54
|
|
|
if(isset($this->email)) |
55
|
|
|
{ |
56
|
|
|
return $this->email; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
return parent::getEmail(); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function __get($propName) |
62
|
|
|
{ |
63
|
|
|
if(isset($this->intData[$propName])) |
64
|
|
|
{ |
65
|
|
|
return $this->intData[$propName]; |
66
|
|
|
} |
67
|
|
|
return parent::__get($propName); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function __set($propName, $value) |
71
|
|
|
{ |
72
|
|
|
$this->intData[$propName] = $value; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* The last name for the user |
77
|
|
|
* |
78
|
|
|
* @return string The user's last name |
79
|
|
|
*/ |
80
|
|
|
public function getLastName() |
81
|
|
|
{ |
82
|
|
|
if(isset($this->sn)) |
83
|
|
|
{ |
84
|
|
|
return $this->sn; |
|
|
|
|
85
|
|
|
} |
86
|
|
|
return parent::getLastName(); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the user's password as specified during registration |
91
|
|
|
* |
92
|
|
|
* We need the ability to obtain the user's unhashed plain text password to allow for it to be sent |
93
|
|
|
* to the correct backend which will hash it |
94
|
|
|
* |
95
|
|
|
* @return boolean|string The current password |
96
|
|
|
*/ |
97
|
|
|
public function getPassword() |
98
|
|
|
{ |
99
|
|
|
return false; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* The supplemental login types that the user can use to login |
104
|
|
|
* |
105
|
|
|
* @return array The user's login providers |
106
|
|
|
*/ |
107
|
|
|
public function getLoginProviders() |
108
|
|
|
{ |
109
|
|
|
if(isset($this->host)) |
110
|
|
|
{ |
111
|
|
|
return $this->host; |
|
|
|
|
112
|
|
|
} |
113
|
|
|
return parent::getLoginProviders(); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Add a supplemental login type that the user can use to login |
118
|
|
|
* |
119
|
|
|
* @param string $provider The hostname for the provider |
120
|
|
|
* |
121
|
|
|
* @return true|false true if the addition worked, false otherwise |
122
|
|
|
*/ |
123
|
|
|
public function addLoginProvider($provider) |
124
|
|
|
{ |
125
|
|
|
if(isset($this->host)) |
126
|
|
|
{ |
127
|
|
|
array_push($this->host, $provider); |
|
|
|
|
128
|
|
|
} |
129
|
|
|
else |
130
|
|
|
{ |
131
|
|
|
$this->host = array($provider); |
|
|
|
|
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Set the user's email address |
137
|
|
|
* |
138
|
|
|
* @param string $email The user's new email address |
139
|
|
|
* |
140
|
|
|
* @return boolean true if the user's email address was changed, false otherwise |
141
|
|
|
*/ |
142
|
|
|
public function setEmail($email) |
143
|
|
|
{ |
144
|
|
|
$this->email = $email; |
|
|
|
|
145
|
|
|
return true; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set the user's given (first) name |
150
|
|
|
* |
151
|
|
|
* @param string $givenName The user's new given name |
152
|
|
|
* |
153
|
|
|
* @return boolean true if the user's given name was changed, false otherwise |
154
|
|
|
*/ |
155
|
|
|
public function setGivenName($givenName) |
156
|
|
|
{ |
157
|
|
|
$this->givenName = $givenName; |
|
|
|
|
158
|
|
|
return true; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Set the user's last name |
163
|
|
|
* |
164
|
|
|
* @param string $sn The user's new last name |
165
|
|
|
* |
166
|
|
|
* @return boolean true if the user's last name was changed, false otherwise |
167
|
|
|
*/ |
168
|
|
|
public function setLastName($sn) |
169
|
|
|
{ |
170
|
|
|
$this->sn = $sn; |
|
|
|
|
171
|
|
|
return true; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Serialize the user data into a format usable by the json_encode method |
176
|
|
|
* |
177
|
|
|
* @return array A simple keyed array representing the user |
178
|
|
|
*/ |
179
|
|
|
public function jsonSerialize() |
180
|
|
|
{ |
181
|
|
|
$user = array(); |
182
|
|
|
$user['hash'] = $this->getHash(); |
183
|
|
|
$user['mail'] = $this->getEmail(); |
184
|
|
|
$user['uid'] = $this->getUid(); |
185
|
|
|
$time = $this->getRegistrationTime(); |
186
|
|
|
if($time !== false) |
187
|
|
|
{ |
188
|
|
|
$user['time'] = $time->format(\DateTime::RFC822); |
|
|
|
|
189
|
|
|
} |
190
|
|
|
$user['class'] = get_class($this); |
191
|
|
|
return $user; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function sendEmail() |
195
|
|
|
{ |
196
|
|
|
$email_msg = new \Email\Email(); |
197
|
|
|
$email_msg->addToAddress($this->getEmail()); |
198
|
|
|
$email_msg->setTextBody('Thank you for signing up with Burning Flipside. Your registration is not complete until you goto the address below. |
199
|
|
|
https://profiles.burningflipside.com/finish.php?hash='.$this->getHash().' |
200
|
|
|
Thank you, |
201
|
|
|
Burning Flipside Technology Team'); |
202
|
|
|
$email_msg->setHTMLBody('Thank you for signing up with Burning Flipside. Your registration is not complete until you follow the link below.<br/> |
203
|
|
|
<a href="https://profiles.burningflipside.com/finish.php?hash='.$this->getHash().'">Complete Registration</a><br/> |
204
|
|
|
Thank you,<br/> |
205
|
|
|
Burning Flipside Technology Team'); |
206
|
|
|
$email_msg->setSubject('Burning Flipside Registration'); |
207
|
|
|
$email_provider = \EmailProvider::getInstance(); |
208
|
|
|
if($email_provider->sendEmail($email_msg) === false) |
209
|
|
|
{ |
210
|
|
|
throw new \Exception('Unable to send email!'); |
211
|
|
|
} |
212
|
|
|
return true; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public function delete() |
216
|
|
|
{ |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
220
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.