YaWK
24.1
Yet another WebKit
profile.php
Go to the documentation of this file.
1
<?php
2
/** Userpage Plugin */
3
namespace
YAWK\PLUGINS\USERPAGE
{
4
/**
5
* <b>Profile class extends class userpage</b>
6
* <p>serve functions to check if the user is logged in and display the profile page on wich he can change
7
* his personal settings such as username, password and so on. </p>
8
* <p><i>Class covers frontend functionality.
9
* See Methods Summary for Details!</i></p>
10
*
11
* @author Daniel Retzl <
[email protected]
>
12
* @copyright 2009-2015 Daniel Retzl
13
* @version 1.0.0
14
* @brief Userpage Profile Class
15
*/
16
class
profile
17
{
18
/** * @param string html content */
19
protected
$html
=
''
;
20
/** * @param object settings object */
21
protected
$settings
;
22
/** * @param string username */
23
protected
$username
;
24
/** * @param object user object*/
25
protected
$user
;
26
27
/**
28
* @brief init: check if user is logged in and draw profile or show login box
29
* @param object $db database
30
* @return string html output
31
*/
32
public
function
init
(
$db
)
33
{
34
global
$user
;
35
36
// profile obj username property
37
$this->username = $_SESSION[
'username'
];
38
39
// create new user object
40
$user
= new \YAWK\user(
$db
);
41
42
// load user properties
43
$user
->loadProperties(
$db
, $this->username);
44
45
// check if user is logged in
46
if
(
$user
->isLoggedIn(
$db
,
$user
->username))
47
{
// user is logged in, draw profile page
48
$this->html .=
self::drawProfile
(
$db
,
$user
);
49
return
$this->html
;
50
}
51
else
52
{
// user is not logged in
53
echo \YAWK\alert::draw(
"danger"
,
"Error!"
,
"Obviously you are not correctly logged in. Please re-login!"
,
""
,6800);
54
return \YAWK\user::drawLoginBox(
""
,
""
);
55
}
56
}
57
58
/**
59
* @brief draw user profile for frontend editing
60
* @param object $db database
61
* @param object $user user object
62
* @return null store in object setting: $this->html
63
*/
64
public
function
drawProfile
(
$db
,
$user
){
65
// get profile settings
66
$changeUsername =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeUsername"
);
67
$changePassword =
\YAWK\settings::getSetting
(
$db
,
"userpage_changePassword"
);
68
$changeEmail =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeEmail"
);
69
$changeFirstname =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeFirstname"
);
70
$changeLastname =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeLastname"
);
71
$changeStreet =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeStreet"
);
72
$changeZipcode =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeZipcode"
);
73
$changeCity =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeCity"
);
74
$changeCountry =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeCountry"
);
75
$changeState =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeState"
);
76
$changeUrl =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeUrl"
);
77
$changeTwitter =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeTwitter"
);
78
$changeFacebook =
\YAWK\settings::getSetting
(
$db
,
"userpage_changeFacebook"
);
79
// form header
80
$this->html .=
"<form id=\"form\" class=\"form-inline\" action=\"welcome.html\" method=\"POST\">"
;
81
$this->html .=
"
82
<fieldset>
83
<legend><i class=\"fa fa-user\"></i> Profile Settings <small>Change your personal data.</small></legend>"
;
84
85
/* div row
86
$this->html .="<div class=\"container-fluid\"><div class=\"row\">
87
<div class=\"col-md-12\">";
88
*/
89
90
/* USERNAME */
91
if
($changeUsername ===
'1'
){
92
$this->html .=
"<small><i class=\"fa fa-user\"></i></small> Username<br>
93
<input type=\"text\" class=\"form-control\" id=\"newUsername\" name=\"newUsername\" value=\"$user->username\" placeholder=\"set new username\">
94
<label for=\"newUsername\" class=\"small\"> change your username</label> <br>"
;
95
}
96
/* EMAIL */
97
if
($changeEmail ===
'0'
) {
98
$disabled =
"disabled aria-disabled=\"true\""
;
99
$disabledLabel =
"The email address is part of your account and cannot be changed."
;
100
}
101
else
{
102
$disabled =
''
;
103
$disabledLabel =
"change email address"
;
104
$this->html .=
"<small><i class=\"fa fa-envelope-o\"></i></small> Email<br>
105
<input type=\"text\" class=\"form-control\" value=\"$user->email\" id=\"newEmail\" name=\"newEmail\" $disabled placeholder=\"$user->email\">
106
<label for=\"newEmail\" class=\"small\"> $disabledLabel</label><br><br>"
;
107
}
108
/* PASSWORD */
109
if
($changePassword ===
'1'
){
110
$this->html .=
"<small><i class=\"fa fa-lock\"></i></small> Password<br>
111
<input type=\"password\" class=\"form-control\" id=\"newPassword1\" name=\"newPassword1\" placeholder=\"****\">
112
<label for=\"newPassword1\" class=\"small\"> new password</label> <br>
113
<input type=\"password\" class=\"form-control\" id=\"newPassword2\" name=\"newPassword2\" placeholder=\"****\">
114
<label for=\"newPassword2\" class=\"small\"> new password <small>(again)</small></label> <br><br>"
;
115
}
116
/* FIRST NAME */
117
if
($changeFirstname ===
'1'
){
118
$this->html .=
"<small><i class=\"fa fa-user\"></i></small> First Name<br>
119
<input type=\"text\" class=\"form-control\" id=\"newFirstname\" name=\"firstname\" value=\"$user->firstname\" placeholder=\"set new firstname\">
120
<label for=\"newFirstname\" class=\"small\"> change your first name</label> <br>"
;
121
}
122
/* LAST NAME */
123
if
($changeLastname ===
'1'
){
124
$this->html .=
"<small><i class=\"fa fa-user\"></i></small> Last Name<br>
125
<input type=\"text\" class=\"form-control\" id=\"newLastname\" name=\"lastname\" value=\"$user->lastname\" placeholder=\"set new lastname\">
126
<label for=\"newLastname\" class=\"small\"> change your last name</label> <br><br>"
;
127
}
128
/* STREET */
129
if
($changeStreet ===
'1'
){
130
$this->html .=
"<small><i class=\"fa fa-home\"></i></small> Street<br>
131
<input type=\"text\" class=\"form-control\" id=\"newStreet\" name=\"street\" value=\"$user->street\" placeholder=\"set new street\">
132
<label for=\"newStreet\" class=\"small\"> change your street</label> <br>"
;
133
}
134
/* ZIPCODE */
135
if
($changeZipcode ===
'1'
){
136
$this->html .=
"<small><i class=\"fa fa-home\"></i></small> Zipcode<br>
137
<input type=\"text\" class=\"form-control\" id=\"newZipcode\" name=\"zipcode\" value=\"$user->zipcode\" placeholder=\"set new zipcode\">
138
<label for=\"newZipcode\" class=\"small\"> change your zipcode</label> <br>"
;
139
}
140
/* CITY */
141
if
($changeCity ===
'1'
){
142
$this->html .=
"<small><i class=\"fa fa-home\"></i></small> City<br>
143
<input type=\"text\" class=\"form-control\" id=\"newCity\" name=\"city\" value=\"$user->city\" placeholder=\"set new city\">
144
<label for=\"newCity\" class=\"small\"> change your city</label> <br>"
;
145
}
146
/* STATE */
147
if
($changeState ===
'1'
){
148
$this->html .=
"<small><i class=\"fa fa-home\"></i></small> State<br>
149
<input type=\"text\" class=\"form-control\" id=\"newState\" name=\"state\" value=\"$user->country\" placeholder=\"set new state\">
150
<label for=\"newState\" class=\"small\"> change your state</label> "
;
151
}
152
/* COUNTRY */
153
if
($changeCountry ===
'1'
){
154
$this->html .=
"<small><i class=\"fa fa-home\"></i></small> Country<br>
155
<input type=\"text\" class=\"form-control\" id=\"newCountry\" name=\"country\" value=\"$user->country\" placeholder=\"set new country\">
156
<label for=\"newCountry\" class=\"small\"> change your country</label> "
;
157
}
158
/* URL */
159
if
($changeUrl ===
'1'
){
160
$this->html .=
"<br><small><i class=\"fa fa-external-link\"></i></small> Website URL*<br>
161
<input type=\"text\" class=\"form-control\" id=\"newUrl\" name=\"url\" size=\"42\" value=\"$user->url\" placeholder=\"set new website url\">
162
<label for=\"newUrl\" class=\"small\"> *optional</label> <br>"
;
163
}
164
/* FACEBOOK */
165
if
($changeFacebook ===
'1'
){
166
$this->html .=
"<small><i class=\"fa fa-facebook-official\"></i></small> Facebook URL*<br>
167
<input type=\"text\" class=\"form-control\" id=\"newFacebook\" size=\"42\" value=\"$user->facebook\" name=\"facebook\" placeholder=\"set new facebook url\">
168
<label for=\"newFacebook\" class=\"small\"> *optional</label> <br>"
;
169
}
170
/* TWITTER */
171
if
($changeTwitter ===
'1'
){
172
$this->html .=
"<small><i class=\"fa fa-twitter\"></i></small> Twitter URL*<br>
173
<input type=\"text\" class=\"form-control\" id=\"newTwitter\" size=\"42\" value=\"$user->twitter\" name=\"twitter\" placeholder=\"set new twitter url\">
174
<label for=\"newTwitter\" class=\"small\"> *optional</label> <br><br>"
;
175
}
176
$this->html .=
""
;
177
$this->html .=
"<input type=\"submit\" name=\"submit\" value=\"Speichern\" class=\"btn btn-success\">"
;
178
$this->html .=
"<input type=\"hidden\" name=\"profile-update\" value=\"1\">"
;
179
$this->html .=
"<input type=\"hidden\" name=\"uid\" value=\"$user->id\">"
;
180
$this->html .=
"</fieldset><br><br><br>"
;
181
// </div></div></div>
182
return
null
;
183
}
184
}
185
}
YAWK\PLUGINS\USERPAGE\profile
Userpage Profile Class.
Definition:
profile.php:17
YAWK\PLUGINS\USERPAGE\profile\init
init($db)
init: check if user is logged in and draw profile or show login box
Definition:
profile.php:32
YAWK\PLUGINS\USERPAGE\profile\$settings
$settings
Definition:
profile.php:21
YAWK\PLUGINS\USERPAGE\profile\drawProfile
drawProfile($db, $user)
draw user profile for frontend editing
Definition:
profile.php:64
YAWK\PLUGINS\USERPAGE\profile\$html
$html
Definition:
profile.php:19
YAWK\PLUGINS\USERPAGE\profile\$username
$username
Definition:
profile.php:23
YAWK\PLUGINS\USERPAGE\profile\$user
$user
Definition:
profile.php:25
YAWK\settings\getSetting
static getSetting($db, $property)
Get and return value for property from settings database.
Definition:
settings.php:470
$db
$db
Definition:
dismiss-notifications.php:4
YAWK\PLUGINS\USERPAGE
Definition:
profile.php:3
yawk.io
system
plugins
userpage
classes
profile.php
Generated on Tue Jan 16 2024 21:59:03 for YaWK by
doxygen 1.9.1