Skip to content

Instantly share code, notes, and snippets.

@asika32764
Created June 2, 2016 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asika32764/8f3ebfccbb804635fa75861394941c0e to your computer and use it in GitHub Desktop.
Save asika32764/8f3ebfccbb804635fa75861394941c0e to your computer and use it in GitHub Desktop.
<?php
/**
* Part of ihealth project.
*
* @copyright Copyright (C) 2011 - 2014 SMS Taiwan, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
use Windwalker\Data\Data;
/**
* Class UserHelper
*
* @since 1.0
*/
class UserHelper
{
/**
* isLogin
*
* @param integer $id
*
* @return boolean
*/
public static function isLogin($id = null)
{
$user = \JFactory::getUser($id);
return !$user->guest;
}
/**
* isGuest
*
* @param integer $id
*
* @return boolean
*/
public static function isGuest($id = null)
{
$user = \JFactory::getUser($id);
return (boolean) $user->guest;
}
/**
* goToLogin
*
* @param mixed $return
*
* @return void
*/
public static function goToLogin($return = false)
{
\JFactory::getApplication()->redirect(static::getLoginUrl($return));
return;
}
/**
* getLoginUrl
*
* @param bool $return
*
* @return string
*/
public static function getLoginUrl($return = false)
{
$query = array(
'option' => 'com_users',
'view' => 'login'
);
if ($return)
{
if ($return === true)
{
$return = \JUri::getInstance();
}
$query['return'] = base64_encode((string) $return);
}
return \JRoute::_('index.php?' . http_build_query($query));
}
/**
* goToSchedules
*
* @return void
*
* @deprecated Use RedirectHelper instead.
*/
public static function goToSchedules()
{
RedirectHelper::goToSchedules();
return;
}
/**
* goToRegistration
*
* @return void
*
* @deprecated Use RedirectHelper instead.
*/
public static function goToRegistration()
{
RedirectHelper::goToRegistration();
return;
}
/**
* getRegistrationUrl
*
* @return string
*
* @deprecated Use RedirectHelper instead.
*/
public static function getRegistrationUrl()
{
$query = array(
'option' => 'com_users',
'view' => 'registrtion'
);
return \JRoute::_('index.php?' . http_build_query($query));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment