public static function delete($id) { if (!Request::is_admin()) { Response::redirect(''); } # perform the categories deletion Badwords::delete($id); # push a flash message Session::push('flash-message', 'That badwords sensor has deleted successfully!'); # redirect to main page Response::redirect('badwords'); }
public static function delete($id) { if (!Request::is_admin()) { Response::redirect(''); } # perform the categories deletion Categories::delete($id); # push flash-message Session::push('flash-message', 'That category has deleted successfuly!'); # redirect to main page Response::redirect('categories'); }
/** * @param $id */ public static function delete($id) { $comment = Comments::findByPK($id); if (!Request::is_authenticated()) { Response::redirect(''); } else { if (Request::user()->id !== $comment['id_account'] and !Request::is_admin()) { Session::push('flash-message', 'You does not have permission to delete the other Member\'s post!'); Response::redirect(''); } } # perform the post deletion Comments::delete($id); # redirect to main page Response::redirect(''); }
public static function index() { # if user was login before and the session is still valid if (Request::is_authenticated()) { if (Request::is_admin()) { AdminController::index(); } else { MemberController::index(); } } else { $posts = Posts::all((new DbCriteria())->order_by('created_at')->DESC()); # set criteria $criteria = (new DbCriteria())->order_by('viewers')->DESC()->LIMIT(5); $hotposts = Posts::all($criteria)->fetchAll(); $users = Accounts::find(['type' => 2]); $categories = Categories::all(); # /app/views/home.php View::render('home', ['hotposts' => $hotposts, 'posts' => $posts, 'users' => $users, 'categories' => $categories]); } }
<?php use Ngaji\Http\Request; if (Request::is_authenticated()) { $account = app\models\Accounts::findByPK(Request::user()->id); } ?> <? if (Request::is_admin()): ?> <!-- Logo --> <?php echo Html::anchor('', '<b>IniForum</b>LTE', ['class' => 'logo']); ?> <nav class="navbar navbar-static-top" role="navigation"> <!-- Sidebar toggle button--> <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle navigation</span> </a> <!-- Navbar Right Menu --> <div class="navbar-custom-menu"> <ul class="nav navbar-nav"> <li class="dropdown user user-menu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <?php echo Html::loadIMG($account['photo'], ['class' => 'user-image', 'alt' => 'User Image']); ?> <span class="hidden-xs"><?php echo Request::get_user('name'); ?> </span> </a>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> <!-- Bootstrap 3.3.2 --> <?php echo Html::load('css', 'bootstrap.min.css'); echo Html::load('css', 'font-awesome.min.css'); ?> <link href="http://code.ionicframework.com/ionicons/2.0.0/css/ionicons.min.css" rel="stylesheet" type="text/css"/> <!-- Theme style --> <?php echo Html::load('css', 'dist/AdminLTE.min.css'); ?> <!-- AdminLTE Skins. Choose a skin from the css/skins folder instead of downloading all of them to reduce the load. --> <?php echo Html::load('css', 'dist/skins/skin-blue.min.css'); ?> <!--custom style--> <style> <? if (!\Ngaji\Http\Request::is_admin()) : ?> .content-wrapper { padding-top: 60px; } <? endif; ?> </style>