public function renderView() { if (User::isLoggedIn() && User::theUser()->isAdmin()) { $view = $this->getView(); if (file_exists(ADMIN_VIEWS_PATH . $view . '.view.php')) { require_once ADMIN_VIEWS_PATH . $view . '.view.php'; } else { require_once ADMIN_VIEWS_PATH . '404.view.php'; } } else { require_once ADMIN_VIEWS_PATH . 'restricted.view.php'; } }
public static function control() { $view = Path::get_path()['call_parts'][0]; $editUrl = HOST_NAME . 'admin/' . $view . '/edit/'; $deleteUrl = HOST_NAME . 'admin/' . $view . '/delete/'; $users = self::read("SELECT * FROM Users WHERE id != " . User::theUser()->id, PDO::FETCH_CLASS, __CLASS__); $table = '<table class="admin-table"> <tr> <th width="3%">#</th> <th>Username</th> <th width="10%" colspan="2">Control</th> </tr> '; if ($users != false) { if (is_object($users)) { $table .= '<tr> <td>' . $users->id . '</td> <td>' . $users->username . '</td> <td class="button"> <a href="' . $editUrl . $users->id . '"><i class="fa fa-edit"></i></a> <a href="' . $deleteUrl . $users->id . '" class="delete"><i class="fa fa-trash-o"></i></a> </td> </tr>'; } else { foreach ($users as $item) { $table .= '<tr> <td>' . $item->id . '</td> <td>' . $item->username . '</td> <td class="button"> <a href="' . $editUrl . $item->id . '"><i class="fa fa-edit"></i></a> <a href="' . $deleteUrl . $item->username . '" class="delete"><i class="fa fa-trash-o"></i></a> </td> </tr>'; } } } else { $table .= '<tr><td colspan="4">No User Found</td></tr>'; } $table .= '</table>'; return $table; }
</div><!-- end ./social --> <?php if (User::isLoggedIn()) { ?> <h4 class="welcome-message">Welcome <?php echo User::theUser()->username; ?> <a href="./logout">Logout</a> or, <a href="./admin">Go To CPanel</a> </h4> <?php } else { ?> <h4 class="welcome-message">Welcome Guest, <a href="./login">Login</a> <?php if (User::theUser()->privilege == 1) { ?> or <a href="./register">Register</a></h4> <?php } ?> </h4> <?php } // end else ?> <?php include WEB_TEMPLATE_PATH . 'nav.php'; ?>