コード例 #1
0
 public function __construct()
 {
     HackademicController::__construct();
     // Login Controller, do nothing
     if (get_class($this) == 'LoginController') {
     } elseif (!$this->isLoggedIn()) {
         // Else if not logged in, go to login page
         header('Location: ' . SOURCE_ROOT_PATH . "admin/pages/login.php");
     } elseif ($this->isLoggedIn()) {
         // Else if is logged in
         if ($this->isAdmin() || $this->isTeacher()) {
             // If is Admin or Teacher, go to Admin Dashboard
             $menu = MenuController::go();
             $this->addToView("main_menu_admin", $menu);
         } else {
             header('Location: ' . SOURCE_ROOT_PATH);
         }
         // Else go to main site
     }
 }
コード例 #2
0
 /**
  * Constructor to initialize the Main Controller
  */
 public function __construct()
 {
     if (!self::$session_exists) {
         self::$session_exists = 1;
         session_start();
     }
     $this->smarty = new SmartyHackademic();
     $this->app_session = new Session();
     if ($this->isLoggedIn()) {
         $this->addToView('is_logged_in', true);
         $this->addToView('logged_in_user', $this->getLoggedInUser());
     }
     if ($this->isAdmin()) {
         $this->addToView('user_type', true);
     }
     $menu = FrontendMenuController::go();
     $this->addToView('main_menu', $menu);
     $challenge_menu = ChallengeMenuController::go();
     $this->addToView('challenge_menu', $challenge_menu);
     if ($this->isLoggedIn()) {
         $usermenu = UserMenuController::go();
         $this->addToView('user_menu', $usermenu);
     }
 }