Example #1
0
 /**
  * Renders a login page if necessary. If this is called via an ajax method, it will trigger a dialog instead.
  *
  * @access	public
  * @param	null
  * @return	string	Contents.
  */
 public static function requireLogin()
 {
     $document = JFactory::getDocument();
     $my = FD::user();
     if ($my->id > 0) {
         return true;
     }
     switch ($document->getType()) {
         case 'html':
             // Do some redirects here?
             $info = FD::info();
             $message = new stdClass();
             $message->message = JText::_('COM_EASYSOCIAL_PLEASE_LOGIN_FIRST');
             $message->type = SOCIAL_MSG_INFO;
             $info->set($message);
             // Get the application framework.
             $app = JFactory::getApplication();
             // Get the current URI.
             $callback = FRoute::current();
             FD::setCallback($callback);
             $url = FRoute::login(array(), false);
             $app->redirect($url);
             $app->close();
             break;
         case 'ajax':
             $ajax = FD::ajax();
             // Get the referer URI.
             $callback = FRoute::referer();
             if ($callback) {
                 FD::setCallback($callback);
             }
             $ajax->script('EasySocial.login();');
             return $ajax->send();
             break;
     }
 }
Example #2
0
 /**
  * Get's the current URI for callback
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function getCallback()
 {
     return FRoute::current(true);
 }