YaWK  24.1
Yet another WebKit
YAWK\PLUGINS\USERPAGE\profile Class Reference

Userpage Profile Class. More...

Public Member Functions

 drawProfile ($db, $user)
 draw user profile for frontend editing More...
 
 init ($db)
 init: check if user is logged in and draw profile or show login box More...
 

Protected Attributes

 $html = ''
 
 $settings
 
 $user
 
 $username
 

Detailed Description

Userpage Profile Class.

Profile class extends class userpage

serve functions to check if the user is logged in and display the profile page on wich he can change his personal settings such as username, password and so on.

Class covers frontend functionality. See Methods Summary for Details!

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 16 of file profile.php.

Member Function Documentation

◆ drawProfile()

YAWK\PLUGINS\USERPAGE\profile::drawProfile (   $db,
  $user 
)

draw user profile for frontend editing

Parameters
object$dbdatabase
object$useruser object
Returns
null store in object setting: $this->html

Definition at line 64 of file profile.php.

64  {
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> &nbsp;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\"> &nbsp;change your username</label> &nbsp;<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\"> &nbsp;$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\"> &nbsp;new password</label> &nbsp;<br>
113  <input type=\"password\" class=\"form-control\" id=\"newPassword2\" name=\"newPassword2\" placeholder=\"****\">
114  <label for=\"newPassword2\" class=\"small\"> &nbsp;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\"> &nbsp;change your first name</label> &nbsp;<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\"> &nbsp;change your last name</label> &nbsp;<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\"> &nbsp;change your street</label> &nbsp;<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\"> &nbsp;change your zipcode</label> &nbsp;<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\"> &nbsp;change your city</label> &nbsp;<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\"> &nbsp;change your state</label> &nbsp;";
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\"> &nbsp;change your country</label> &nbsp;";
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\"> &nbsp;*optional</label> &nbsp;<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\"> &nbsp;*optional</label> &nbsp;<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\"> &nbsp;*optional</label> &nbsp;<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  }
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470

References $db, and YAWK\settings\getSetting().

Referenced by YAWK\PLUGINS\USERPAGE\profile\init().

◆ init()

YAWK\PLUGINS\USERPAGE\profile::init (   $db)

init: check if user is logged in and draw profile or show login box

Parameters
object$dbdatabase
Returns
string html output

Definition at line 32 of file profile.php.

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  }
drawProfile($db, $user)
draw user profile for frontend editing
Definition: profile.php:64

References $db, YAWK\PLUGINS\USERPAGE\profile\$html, YAWK\PLUGINS\USERPAGE\profile\$user, and YAWK\PLUGINS\USERPAGE\profile\drawProfile().

Member Data Documentation

◆ $html

YAWK\PLUGINS\USERPAGE\profile::$html = ''
protected
  • Parameters
    stringhtml content

Definition at line 19 of file profile.php.

Referenced by YAWK\PLUGINS\USERPAGE\profile\init().

◆ $settings

YAWK\PLUGINS\USERPAGE\profile::$settings
protected
  • Parameters
    objectsettings object

Definition at line 21 of file profile.php.

◆ $user

YAWK\PLUGINS\USERPAGE\profile::$user
protected
  • Parameters
    objectuser object

Definition at line 25 of file profile.php.

Referenced by YAWK\PLUGINS\USERPAGE\profile\init().

◆ $username

YAWK\PLUGINS\USERPAGE\profile::$username
protected
  • Parameters
    stringusername

Definition at line 23 of file profile.php.


The documentation for this class was generated from the following file: