YaWK  24.1
Yet another WebKit
userpage.php
Go to the documentation of this file.
1 <?php
2 namespace YAWK\PLUGINS\USERPAGE {
3  /**
4  * <b>Userpage Plugin </b>
5  * <p>Userpage Class check and build the userpage.</p>
6  * <p><i>Class covers frontend functionality.
7  * See Methods Summary for Details!</i></p>
8  *
9  * @author Daniel Retzl <[email protected]>
10  * @copyright 2009-2015 Daniel Retzl
11  * @version 1.0.0
12  * @brief Userpage Profile Class
13  */
14  class userpage
15  {
16  /** * @param string dashboard */
17  protected $dashboard;
18  /** * @param string append tab */
19  protected $appendTab;
20  /** * @param string append panel */
21  protected $appendPanel;
22 
23  /**
24  * @brief userpage constructor.
25  * @param object $db database
26  * @param object $user user object
27  */
28  public function __construct($db, $user){
29  /* property $user */
30  if (isset($username) && (!empty($username)))
31  {
32  $this->user = $username;
33  }
34  $this->usergroup = \YAWK\user::getGroup($db);
35  }
36 
37  /**
38  * @brief init function check if backend is allowed and load userpage
39  * @param object $db database
40  * @param object $user user
41  * @return bool|null|string
42  */
43  public function init($db, $user, $lang){
44  if ($this->usergroup['backend_allowed'] !== '1'){
45  // backend access not allowed
46  // check usergroup
47  if ($this->usergroup['backend_allowed'] === '0') {
48  // load userpage
49  return $this->getUserPage($db, $user, $lang);
50  }
51  else
52  { // throw error
53  return \YAWK\alert::draw("danger", "Error", "Could not load userpage. Something strange has happened.","",6800);
54  }
55  }
56  else {
57  // backend access granted, load root page
58  if (\YAWK\user::isAdmin($db)){
59  return $this->getRootPage($db, $user);
60  }
61  }
62  return null;
63  }
64 
65  /**
66  * @brief getUserPage is a wrapper for buildPage
67  * @param object $db database
68  * @param object $user object
69  * @param object $lang language
70  * @return string buildPage function
71  */
72  public function getUserPage($db, $user, $lang) {
73  return $this->buildPage($db, $user->username, $user->gid, $this->appendTab, $this->appendPanel, $this->dashboard, $lang);
74  }
75 
76  /**
77  * @brief detect admin and build a special 'ROOT' page with admin functions... TODO: in development
78  * @param object $db database
79  * @param object $user object
80  * @return string buildPage with admin functions
81  */
82  public function getRootPage($db, $user) {
83  // check, if admin tab is enabled
84  if (\YAWK\settings::getSetting($db, "userpage_admin") === '1'){
85  // prepare dashboard
86  $this->dashboard = "<h5 class=\"btn-danger\">*** ROOT MODE ***</h5>";
87  // root mode notice
88  $this->dashboard .= "Hello $user->username! You are logged in with root access.";
89 
90  // append admin panel + tab
91  $this->appendTab = "<li class=\"nav-item\" role=\"admin\"><a href=\"#admin\" class=\"nav-link\" aria-controls=\"admin\" role=\"tab\" data-toggle=\"tab\">
92  <i class=\"fa fa-wrench\"></i>&nbsp; Admin</a></li>";
93  $this->appendPanel = "<div role=\"tabpanel\" class=\"tab-pane animated fadeIn\" id=\"admin\"><h4>
94  <i class=\"fa fa-lock fa-2x\"></i> &nbsp;Admin Stuff...</h4></div>";
95  }
96  else {
97  $this->appendTab = "";
98  $this->appendPanel = "";
99  }
100  return self::buildPage($db, $user->username, $user->gid, $this->appendTab, $this->appendPanel, $this->dashboard, $lang);
101  }
102 
103  /**
104  * @brief build the user page and draw html output
105  * @param object $db database
106  * @param object $user object
107  * @param int $usergroup group ID
108  * @param string $appendTab the tab to append, if
109  * @param string $appendPanel the panel to append, if
110  * @param string $dashboard some dashboard content
111  * @return string draw html output
112  */
113  public static function buildPage($db, $user, $usergroup, $appendTab, $appendPanel, $dashboard, $lang)
114  { /** @var $db \YAWK\db */
115  // ADDITIONAL CODE ------------------
116  // IF ADMINs SHOULD GET THEIR OWN WELCOME-USERPAGE
117  // if ($usergroup['backend_allowed'] === '1') {
118  // get soundblog artist button
119  /* GET ACTIVE TABS */
120  $activeTab = \YAWK\settings::getSetting($db, "userpage_activeTab");
121  if ($activeTab == "Dashboard") {
122  $activeDashboardTab = "class=\"active\"";
123  $activeDashboardPane = "active";
124  }
125  else {
126  $activeDashboardTab = "";
127  $activeDashboardPane = "";
128  }
129  if ($activeTab == "Profile") {
130  $activeProfileTab = "class=\"active\"";
131  $activeProfilePane = "active";
132  }
133  else {
134  $activeProfileTab = "";
135  $activeProfilePane = "";
136  }
137  if ($activeTab == "Messages") {
138  $activeMessagesTab = "class=\"active\"";
139  $activeMessagesPane = "active";
140  }
141  else {
142  $activeMessagesTab = "";
143  $activeMessagesPane = "";
144  }
145  if ($activeTab == "Settings") {
146  $activeSettingsTab = "class=\"active\"";
147  $activeSettingsPane = "active";
148  }
149  else {
150  $activeSettingsTab = "";
151  $activeSettingsPane = "";
152  }
153  if ($activeTab == "Stats") {
154  $activeStatsTab = "class=\"active\"";
155  $activeStatsPane = "active";
156  }
157  else {
158  $activeStatsTab = "";
159  $activeStatsPane = "";
160  }
161  if ($activeTab == "Help") {
162  $activeHelpTab = "class=\"active\"";
163  $activeHelpPane = "active";
164  }
165  else {
166  $activeHelpTab = "";
167  $activeHelpPane = "";
168  }
169  if ($activeTab == "Admin") {
170  $activeAdminTab = "class=\"active\"";
171  $activeAdminPane = "active";
172  }
173  else {
174  $activeAdminTab = "";
175  $activeAdminPane = "";
176  }
177 
178  $dashboard .= "
179  <div class=\"col-md-4\">
180  col 1
181  </div>
182  <div class=\"col-md-8\">
183  col 2
184  </div>";
185 
186  $html = "";
187  $signup_hellotextsub = \YAWK\settings::getSetting($db, "userpage_hellotextsub");
188  if ($signup_hellotextsub) {
189  $subtext = "&nbsp;<small>$signup_hellotextsub</small>";
190  }
191  else {
192  $subtext = "";
193  }
194  if (\YAWK\settings::getSetting($db, "userpage_hello") === '1'){
195  $html .= "<h2>".\YAWK\settings::getSetting($db, "userpage_hellotext")."&nbsp;$_SESSION[username]!$subtext";
196  }
197  if (\YAWK\settings::getSetting($db, "userpage_hellogroup") === '1'){
198  $userGroupName = \YAWK\user::getGroupNameFromID($db, $usergroup);
199  $html .= "<br><small>You are logged in as $userGroupName</small>";
200  }
201  $html .= "</h2><div>
202  <!-- Nav tabs -->
203  <ul class=\"nav nav-tabs\" role=\"tablist\">";
204  // dashboard TAB
205  if (\YAWK\settings::getSetting($db, "userpage_dashboard") === '1'){
206  $html .= "<li class=\"nav-item\" role=\"presentation\" $activeDashboardTab><a href=\"#home\" class=\"nav-link active\" aria-controls=\"home\" role=\"tab\" data-toggle=\"tab\">
207  <i class=\"fa fa-home\"></i>&nbsp; Userpage</a></li>";
208  }
209  // profile TAB
210  if (\YAWK\settings::getSetting($db, "userpage_profile") === '1') {
211  $html .= "<li class=\"nav-item\" role=\"presentation\" $activeProfileTab><a href=\"#profile\" class=\"nav-link\" aria-controls=\"profile\" role=\"tab\" data-toggle=\"tab\">
212  <i class=\"fa fa-user\"></i>&nbsp; Edit Profile</a></li>";
213  }
214  // messages TAB
215  if (\YAWK\settings::getSetting($db, "userpage_msgplugin") === '1') {
216  $html .="<li class=\"nav-item\" role = \"presentation\" $activeMessagesTab><a href=\"#messages\" class=\"nav-link\" aria-controls=\"messages\" role=\"tab\" data-toggle=\"tab\">
217  <i class=\"fa fa-envelope\"></i>&nbsp; Messages</a></li>";
218  }
219  // settings TAB
220  if (\YAWK\settings::getSetting($db, "userpage_settings") === '1') {
221  $html .= "<li class=\"nav-item\" role=\"presentation\" $activeSettingsTab><a href=\"#settings\" class=\"nav-link\" aria-controls=\"settings\" role=\"tab\" data-toggle=\"tab\">
222  <i class=\"fa fa-cog\"></i>&nbsp; Settings</a></li>";
223  }
224  // stats TAB
225  if (\YAWK\settings::getSetting($db, "userpage_stats") === '1') {
226  $html .= "<li class=\"nav-item\" role=\"presentation\" $activeStatsTab><a href=\"#stats\" class=\"nav-link\" aria-controls=\"stats\" role=\"tab\" data-toggle=\"tab\">
227  <i class=\"fa fa-line-chart\"></i>&nbsp; Stats</a></li>";
228  }
229  // help TAB
230  if (\YAWK\settings::getSetting($db, "userpage_help") === '1') {
231  $signup_help = 1;
232  $html .= "<li class=\"nav-item\" role=\"presentation\" $activeHelpTab><a href=\"#help\" class=\"nav-link\" aria-controls=\"help\" role=\"tab\" data-toggle=\"tab\">
233  <i class=\"fa fa-question-circle\"></i>&nbsp; Help</a></li>";
234  }
235  // append TAB
236  $html .= "$appendTab
237  </ul>
238 
239  <!-- CONTENT -->
240  <!-- Tab panes -->
241  <div class=\"tab-content\">";
242  // dashboard TAB CONTENT
243  if (\YAWK\settings::getSetting($db, "userpage_dashboard") === '1'){
244  $html .= "<div role=\"tabpanel\" class=\"tab-pane $activeDashboardPane animated fadeIn\" id=\"home\">
245  <!-- ID HOME == user dashboard -->
246  ".$dashboard."
247  </div>";
248  }
249  // profile TAB CONTENT
250  if (\YAWK\settings::getSetting($db, "userpage_profile") === '1') {
251  $html .= "<div role=\"tabpanel\" class=\"tab-pane $activeProfilePane animated fadeIn\" id=\"profile\"><br>";
252  // profile class include
253  include 'system/plugins/userpage/classes/profile.php';
254  $profile = new \YAWK\PLUGINS\USERPAGE\profile();
255  $html .= $profile->init($db);
256  $html .= "</div>";
257  }
258  // message plg TAB CONTENT
259  if (\YAWK\settings::getSetting($db, "userpage_msgplugin") === '1'){
260  $html .= "<div role=\"tabpanel\" class=\"tab-pane $activeMessagesPane animated fadeIn\" id=\"messages\">";
261  // message plugin include
262  include 'system/plugins/messages/classes/messages.php';
263  $messages = new \YAWK\PLUGINS\MESSAGES\messages($db, "frontend");
264  $html .= $messages->init($db, $lang);
265  $html .= "</div>";
266  }
267  // settings TAB CONTENT
268  if (\YAWK\settings::getSetting($db, "userpage_settings") === '1'){
269  $html .= "<div role=\"tabpanel\" class=\"tab-pane $activeSettingsPane animated fadeIn\" id=\"settings\"><br>";
270  // settings class include
271  include 'system/plugins/userpage/classes/settings.php';
272  $settings = new \YAWK\PLUGINS\USERPAGE\settings();
273  $html .= $settings->init($db);
274  $html .= "</div>";
275 
276  }
277  // stats TAB CONTENT
278  if (\YAWK\settings::getSetting($db, "userpage_stats") === '1') {
279  $html .="<div role=\"tabpanel\" class=\"tab-pane $activeStatsPane animated fadeIn\" id=\"stats\">";
280 
281  include 'system/plugins/userpage/classes/stats.php';
282  $stats = new \YAWK\PLUGINS\USERPAGE\stats($db);
283  $html .= $stats->init();
284  $html .="</div>";
285  }
286 
287  // help TAB CONTENT
288  if (\YAWK\settings::getSetting($db, "userpage_help") === '1') {
289  $html .="<div role=\"tabpanel\" class=\"tab-pane $activeHelpPane animated fadeIn\" id=\"help\">";$html .= \YAWK\settings::getLongSetting($db, "userpage_helptext");$html .="</div>";
290  }
291  // append panel TAB CONTENT
292  $html .="$appendPanel
293  </div>
294  </div>";
295  return $html;
296  } // end buildpage
297  } // end class
298 } // end namespace
$activeTab
Definition: userpage.php:155
print $lang['SETTINGS_SAVE']
Definition: userpage.php:282
Userpage Profile Class.
Definition: userpage.php:15
getUserPage($db, $user, $lang)
getUserPage is a wrapper for buildPage
Definition: userpage.php:72
__construct($db, $user)
userpage constructor.
Definition: userpage.php:28
init($db, $user, $lang)
init function check if backend is allowed and load userpage
Definition: userpage.php:43
getRootPage($db, $user)
detect admin and build a special 'ROOT' page with admin functions... TODO: in development
Definition: userpage.php:82
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470
static getLongSetting($db, $property)
Get and return longValue for property from settings database.
Definition: settings.php:527
The default user class. Provide all functions to handle the user object.
Definition: user.php:17
$subtext
Definition: jplayer.php:19
$messages
Definition: mailbox.php:35
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
if(isset($_POST['save'])) $settings