Exemple #1
0
 /**
  * Class constructor
  * TuiyoController::__construct()
  * 
  * @return void
  */
 public function __construct($app = null, $authorise = true)
 {
     $this->current = $app;
     $doFoo = JRequest::getVar("do", null);
     $view = array(JRequest::getVar("view"), JRequest::getVar("redirect"));
     //Doable Tasks
     static $dos = array("help" => "showHelp", "login" => "doLogin", "register" => "registerUser", "exAPI" => "externalLogin", "start" => "createProfile", "setup" => "buildProfile", "signup" => "createUser");
     //Check that the user is logged In / Or allowable task
     if ($authorise && !array_key_exists($doFoo, $dos)) {
         $user = $GLOBALS['API']->get('user', null);
         if (!$user->isUserLoggedIn()) {
             //$document 	= $GLOBALS['API']->get('user', null);
             $welcome = JRoute::_(TUIYO_INDEX . '&redirect=welcome&do=login', false, null);
             $this->setRedirect($welcome, _("You must be logged in to view this section of our site"), "notice");
             $this->redirect();
         } elseif (!$user->hasProfile()) {
             //If user does not have a profile
             $start = JRoute::_(TUIYO_INDEX . "&redirect=core&do=start", false, null);
             $this->setRedirect($start);
             $this->redirect();
         }
         TuiyoControllerCore::authorise();
     }
     //Construct the parent aswell!
     parent::__construct();
     TuiyoEventLoader::preparePlugins("profile");
     //Authorise and register Task
     if (is_null($app) && array_key_exists($doFoo, $dos)) {
         $this->authorise();
         $this->registerTask($doFoo, $dos[$doFoo]);
         //die;
     } elseif (!array_key_exists($doFoo, $dos) && in_array("core", $view)) {
         $GLOBALS['mainframe']->redirect(JRoute::_(TUIYO_INDEX . "&view=welcome"));
     }
 }