mirror of
https://github.com/e107inc/e107.git
synced 2025-08-17 03:54:09 +02:00
Merge pull request #4099 from Deltik/fix-3492
New 3rd-party PHP dependency manager for e107 core and HybridAuth upgrade.
This commit is contained in:
@@ -20,39 +20,21 @@ class core_system_xup_controller extends eController
|
||||
{
|
||||
|
||||
var $backUrl = null;
|
||||
|
||||
|
||||
/**
|
||||
* @var SocialLoginConfigManager
|
||||
*/
|
||||
private $social_login_config_manager;
|
||||
|
||||
public function __construct(eRequest $request, eResponse $response = null)
|
||||
{
|
||||
parent::__construct($request, $response);
|
||||
require_once(e_PLUGIN."social/SocialLoginConfigManager.php");
|
||||
$this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
//$back = 'system/xup/test';
|
||||
$this->backUrl = vartrue($_GET['back']) ? base64_decode($_GET['back']) : true;
|
||||
}
|
||||
|
||||
public function actionSignup()
|
||||
{
|
||||
$allow = true;
|
||||
$session = e107::getSession();
|
||||
if($session->get('HAuthError'))
|
||||
{
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->signup($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
$this->backUrl = isset($_GET['back']) ? $_GET['back'] : null;
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
@@ -64,25 +46,34 @@ class core_system_xup_controller extends eController
|
||||
$allow = false;
|
||||
$session->set('HAuthError', null);
|
||||
}
|
||||
|
||||
|
||||
if($allow && vartrue($_GET['provider']))
|
||||
{
|
||||
require_once(e_HANDLER."user_handler.php");
|
||||
$provider = new e_user_provider($_GET['provider']);
|
||||
$provider = e107::getUserProvider($_GET['provider']);
|
||||
try
|
||||
{
|
||||
$provider->login($this->backUrl); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
$provider->login($this->backUrl, true, false); // redirect to test page is expected, if true - redirect to SITEURL
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
}
|
||||
}
|
||||
|
||||
e107::getRedirect()->redirect(true === $this->backUrl ? SITEURL : $this->backUrl);
|
||||
}
|
||||
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
require_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
|
||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
|
||||
if (!$manager->isFlagActive($manager::ENABLE_BIT_TEST_PAGE))
|
||||
{
|
||||
e107::getRedirect()->redirect(SITEURL);
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<h3>'.LAN_XUP_ERRM_07.'</h3>';
|
||||
|
||||
if(getperms('0'))
|
||||
@@ -91,7 +82,7 @@ class core_system_xup_controller extends eController
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($_GET['lgt']))
|
||||
if(isset($_GET['logout']))
|
||||
{
|
||||
e107::getUser()->logout();
|
||||
}
|
||||
@@ -113,52 +104,23 @@ class core_system_xup_controller extends eController
|
||||
echo ' '.LAN_XUP_ERRM_11.' '.(e107::getUser()->isUser() && !empty($profileData) ? '<span class="label label-success">true</span>' : '<span class="label label-danger">false</span>');
|
||||
|
||||
|
||||
$testUrl = SITEURL."?route=system/xup/test";
|
||||
$providers = e107::getPref('social_login', array());
|
||||
|
||||
$testUrl = SITEURL."?route=system/xup/test";
|
||||
$providers = $manager->getValidConfiguredProviderConfigs();
|
||||
|
||||
foreach($providers as $key=>$var)
|
||||
{
|
||||
if($var['enabled'] == 1)
|
||||
{
|
||||
echo '<h3>'.$key.'</h3><ul>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/login?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_09, array('x'=>$key)).'</a></li>';
|
||||
echo '<li><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/signup?provider='.$key.'&back='.base64_encode($testUrl)).'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></li>';
|
||||
|
||||
echo "</ul>";
|
||||
}
|
||||
|
||||
// print_a($var);
|
||||
}
|
||||
|
||||
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?lgt').'">'.LAN_XUP_ERRM_12.'</a>';
|
||||
|
||||
/*
|
||||
echo '<h3>Facebook</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Facebook').'">Test login with Facebook</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Facebook').'">Test signup with Facebook</a>';
|
||||
|
||||
echo '<h3>Twitter</h3>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/login?provider=Twitter').'">Test login with Twitter</a>';
|
||||
echo '<br /><a href="'.e107::getUrl()->create('system/xup/signup?provider=Twitter').'">Test signup with Twitter</a>';
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public function actionEndpoint()
|
||||
{
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
|
||||
require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
|
||||
require_once( e_HANDLER."hybridauth/vendor/autoload.php");
|
||||
$testLoginUrl = e107::getUrl()->create('system/xup/login', [
|
||||
'provider' => $key,
|
||||
'back' => $testUrl,
|
||||
]);
|
||||
|
||||
try
|
||||
{
|
||||
Hybrid_Endpoint::process();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
|
||||
$session = e107::getSession();
|
||||
$session->set('HAuthError', true);
|
||||
echo '<h4>'.$key.'</h4>';
|
||||
echo '<div><a class="btn btn-default btn-secondary" href="'.$testLoginUrl.'">'.e107::getParser()->lanVars(LAN_XUP_ERRM_10, array('x'=>$key)).'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<br /><br /><a class="btn btn-default btn-secondary" href="'.e107::getUrl()->create('system/xup/test?logout=true').'">'.LAN_XUP_ERRM_12.'</a>';
|
||||
}
|
||||
}
|
||||
|
@@ -65,95 +65,85 @@ class signup_shortcodes extends e_shortcode
|
||||
// TODO - template
|
||||
function sc_signup_xup_login($parm)
|
||||
{
|
||||
$pref = e107::getPref('social_login_active');
|
||||
$tp = e107::getParser();
|
||||
|
||||
if (!e107::getUserProvider()->isSocialLoginEnabled()) return '';
|
||||
|
||||
$size = empty($parm['size']) ? '3x' : $parm['size'];
|
||||
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
||||
|
||||
|
||||
if(!empty($pref))
|
||||
{
|
||||
$text = "";
|
||||
$providers = e107::getPref('social_login');
|
||||
|
||||
foreach($providers as $p=>$v)
|
||||
{
|
||||
$p = strtolower($p);
|
||||
if($v['enabled'] == 1)
|
||||
{
|
||||
|
||||
// $text .= "<a href='".e107::getUrl()->create('system/xup/login?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'><img class='e-tip' title='Register using your {$p} account' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' /></a>";
|
||||
|
||||
$ic = strtolower($p);
|
||||
|
||||
if($ic == 'live')
|
||||
{
|
||||
$ic = 'windows';
|
||||
}
|
||||
|
||||
// 'signup' Creates a new XUP user if not found, otherwise it logs the person in.
|
||||
|
||||
$button = (defset('FONTAWESOME')) ? $tp->toGlyph('fa-'.$ic, array('size'=>$size, 'fw'=>true)) : "<img class='e-tip' title='".$tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p)."' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' />";
|
||||
$text .= " <a title='".$tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p)." ' role='button' class='signup-xup ".$class."' href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'>".$button."</a> ";
|
||||
}
|
||||
//TODO different icon options. see: http://zocial.smcllns.com/
|
||||
}
|
||||
|
||||
// $text .= "<hr />";
|
||||
return $text;
|
||||
}
|
||||
return $this->generateXupLoginButtons("login", $size, $class);
|
||||
}
|
||||
|
||||
// TODO - template
|
||||
function sc_signup_xup_signup($parm)
|
||||
{
|
||||
$pref = e107::getPref('social_login_active');
|
||||
if (!e107::getUserProvider()->isSocialLoginEnabled()) return '';
|
||||
|
||||
$size = empty($parm['size']) ? '2x' : $parm['size'];
|
||||
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
||||
|
||||
if($size == '2x')
|
||||
{
|
||||
$class .= ' btn-lg';
|
||||
}
|
||||
|
||||
return $this->generateXupLoginButtons("signup", $size, $class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param $size
|
||||
* @param $class
|
||||
* @return string
|
||||
*/
|
||||
private function generateXupLoginButtons($type, $size, $class)
|
||||
{
|
||||
$text = "";
|
||||
$tp = e107::getParser();
|
||||
|
||||
|
||||
|
||||
if(!empty($pref))
|
||||
$lan_plugin_social_xup = '';
|
||||
switch ($type)
|
||||
{
|
||||
$text = "";
|
||||
$providers = e107::pref('core', 'social_login');
|
||||
|
||||
$size = empty($parm['size']) ? '2x' : $parm['size'];
|
||||
$class = empty($parm['class']) ? 'btn btn-primary' : $parm['class'] ;
|
||||
|
||||
if($size == '2x')
|
||||
case "login":
|
||||
$lan_plugin_social_xup = LAN_PLUGIN_SOCIAL_XUP_REG;
|
||||
break;
|
||||
case "signup":
|
||||
$lan_plugin_social_xup = LAN_PLUGIN_SOCIAL_XUP_SIGNUP;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
$providers = $manager->getValidConfiguredProviderConfigs();
|
||||
|
||||
foreach ($providers as $p => $v)
|
||||
{
|
||||
if ($v['enabled'] == 1)
|
||||
{
|
||||
$class .= ' btn-lg';
|
||||
}
|
||||
$ic = strtolower($p);
|
||||
|
||||
|
||||
foreach($providers as $p=>$v)
|
||||
{
|
||||
|
||||
|
||||
$p = strtolower($p);
|
||||
if($v['enabled'] == 1)
|
||||
switch ($ic)
|
||||
{
|
||||
$ic = strtolower($p);
|
||||
|
||||
if($ic == 'live')
|
||||
{
|
||||
case 'windowslive':
|
||||
$ic = 'windows';
|
||||
}
|
||||
|
||||
$button = (defset('FONTAWESOME')) ? "<span title='".$tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_REG, $p)."'>".$tp->toGlyph('fa-'.$ic, array('size'=>$size, 'fw'=>true))."</span>" : "<img class='e-tip' title='".$tp->lanVars(LAN_PLUGIN_SOCIAL_XUP_SIGNUP, $p)."' src='".e_IMAGE_ABS."xup/{$p}.png' alt='' />";
|
||||
|
||||
$text .= " <a class='signup-xup ".$class."' role='button' href='".e107::getUrl()->create('system/xup/signup?provider='.$p.'&back='.base64_encode(e_REQUEST_URL))."'>".$button."</a> ";
|
||||
break;
|
||||
}
|
||||
//TODO different icon options. see: http://zocial.smcllns.com/
|
||||
}
|
||||
|
||||
// $text .= "<hr />";
|
||||
return $text;
|
||||
}
|
||||
|
||||
if (defset('FONTAWESOME') && in_array($ic, e107::getMedia()->getGlyphs()))
|
||||
$button = "<span title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "'>" . $tp->toGlyph('fa-' . $ic, array('size' => $size, 'fw' => true)) . "</span>";
|
||||
elseif (is_file(e107::getFolder('images') . "xup/{$ic}.png"))
|
||||
$button = "<img class='e-tip' title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "' src='" . e_IMAGE_ABS . "xup/{$ic}.png' alt='' />";
|
||||
else
|
||||
$button = "<span title='" . $tp->lanVars($lan_plugin_social_xup, $p) . "'>$p</span>";
|
||||
|
||||
$callback_url = e107::getUserProvider($p)->generateCallbackUrl(e_REQUEST_URL);
|
||||
$text .= " <a title='" . $tp->lanVars($lan_plugin_social_xup, $p) . " ' role='button' class='signup-xup $class' href='$callback_url'>$button</a> ";
|
||||
}
|
||||
//TODO different icon options. see: http://zocial.smcllns.com/
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_signup_form_open()
|
||||
{
|
||||
return "<form action='".e_SELF."' method='post' id='signupform' autocomplete='off'><div>".e107::getForm()->token()."</div>";
|
||||
|
Reference in New Issue
Block a user