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
|
|
|
public function __get($propName) |
48
|
|
|
{ |
49
|
|
|
if(isset($this->intData[$propName])) |
50
|
|
|
{ |
51
|
|
|
return $this->intData[$propName]; |
52
|
|
|
} |
53
|
|
|
return parent::__get($propName); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function __set($propName, $value) |
57
|
|
|
{ |
58
|
|
|
$this->intData[$propName] = $value; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function __isset($propName) |
62
|
|
|
{ |
63
|
|
|
return isset($this->intData[$propName]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the user's password as specified during registration |
68
|
|
|
* |
69
|
|
|
* We need the ability to obtain the user's unhashed plain text password to allow for it to be sent |
70
|
|
|
* to the correct backend which will hash it |
71
|
|
|
* |
72
|
|
|
* @return boolean|string The current password |
73
|
|
|
*/ |
74
|
|
|
public function getPassword() |
75
|
|
|
{ |
76
|
|
|
return false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Set the user's email address |
81
|
|
|
* |
82
|
|
|
* @param string $email The user's new email address |
83
|
|
|
* |
84
|
|
|
* @return boolean true if the user's email address was changed, false otherwise |
85
|
|
|
*/ |
86
|
|
|
public function setEmail($email) |
87
|
|
|
{ |
88
|
|
|
$this->email = $email; |
|
|
|
|
89
|
|
|
return true; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Set the user's given (first) name |
94
|
|
|
* |
95
|
|
|
* @param string $givenName The user's new given name |
96
|
|
|
* |
97
|
|
|
* @return boolean true if the user's given name was changed, false otherwise |
98
|
|
|
*/ |
99
|
|
|
public function setGivenName($givenName) |
100
|
|
|
{ |
101
|
|
|
$this->givenName = $givenName; |
|
|
|
|
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Set the user's last name |
107
|
|
|
* |
108
|
|
|
* @param string $sn The user's new last name |
109
|
|
|
* |
110
|
|
|
* @return boolean true if the user's last name was changed, false otherwise |
111
|
|
|
*/ |
112
|
|
|
public function setLastName($sn) |
113
|
|
|
{ |
114
|
|
|
$this->sn = $sn; |
|
|
|
|
115
|
|
|
return true; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Serialize the user data into a format usable by the json_encode method |
120
|
|
|
* |
121
|
|
|
* @return array A simple keyed array representing the user |
122
|
|
|
*/ |
123
|
|
|
public function jsonSerialize() |
124
|
|
|
{ |
125
|
|
|
$user = array(); |
126
|
|
|
$user['hash'] = $this->getHash(); |
127
|
|
|
$user['mail'] = $this->mail; |
|
|
|
|
128
|
|
|
$user['uid'] = $this->uid; |
|
|
|
|
129
|
|
|
$time = $this->getRegistrationTime(); |
130
|
|
|
if($time !== false) |
131
|
|
|
{ |
132
|
|
|
$user['time'] = $time->format(\DateTime::RFC822); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
$user['class'] = get_class($this); |
135
|
|
|
return $user; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function sendEmail() |
139
|
|
|
{ |
140
|
|
|
$email_msg = new \Email\Email(); |
141
|
|
|
$email_msg->addToAddress($this->mail); |
|
|
|
|
142
|
|
|
$email_msg->setTextBody('Thank you for signing up with Burning Flipside. Your registration is not complete until you goto the address below. |
143
|
|
|
https://profiles.burningflipside.com/finish.php?hash='.$this->getHash().' |
144
|
|
|
Thank you, |
145
|
|
|
Burning Flipside Technology Team'); |
146
|
|
|
$email_msg->setHTMLBody('Thank you for signing up with Burning Flipside. Your registration is not complete until you follow the link below.<br/> |
147
|
|
|
<a href="https://profiles.burningflipside.com/finish.php?hash='.$this->getHash().'">Complete Registration</a><br/> |
148
|
|
|
Thank you,<br/> |
149
|
|
|
Burning Flipside Technology Team'); |
150
|
|
|
$email_msg->setSubject('Burning Flipside Registration'); |
151
|
|
|
$email_provider = \EmailProvider::getInstance(); |
152
|
|
|
if($email_provider->sendEmail($email_msg) === false) |
153
|
|
|
{ |
154
|
|
|
throw new \Exception('Unable to send email!'); |
155
|
|
|
} |
156
|
|
|
return true; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function delete() |
160
|
|
|
{ |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
164
|
|
|
|
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write 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.