Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. class Admin_Controller extends MY_Controller {
  4.  
  5.     public function __construct() {
  6.         parent::__construct();
  7.         if (!$this->isLoggedIn()) {
  8.             redirect('/home');
  9.         }
  10.  
  11.         $this->template->set_master_template('desktop/templates/admin');
  12.         $this->data['page'] = new stdClass();
  13.         $this->data['page']->title = "Administration Control Panel";
  14.         $this->data['allusers'] = $this->user_model->get_all();
  15.         $this->data['allgroups'] = $this->group_model->get_all();
  16.         $this->data['allpages'] = $this->page_model->get_all();
  17.         $this->template->set_breadcrumb($this->data['page']->title, site_url('admin'));
  18.         $this->template->write_view('adminnav', 'desktop/views/admin/partials/navmenu');
  19.     }
  20.  
  21.     protected function isLoggedIn() {
  22.         if (($this->session->userdata('id')) == '') {
  23.             return False;
  24.         }
  25.         else {
  26.             return True;
  27.         }
  28.     }
  29.  
  30.     protected function isAdmin() {
  31.         if ($this->isLoggedIn() && $this->user_model->get($this->session->userdata('id'))->group == 1) {
  32.             return True;
  33.         }
  34.         else {
  35.             return False;
  36.         }
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement