Created
June 2, 2016 03:50
-
-
Save asika32764/8f3ebfccbb804635fa75861394941c0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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