mirror of
https://github.com/e107inc/e107.git
synced 2025-07-28 10:20:45 +02:00
Interface fixes and refactoring to e107 conventions/standards.
This commit is contained in:
@@ -21,15 +21,15 @@ class core_system_xup_controller extends eController
|
||||
|
||||
var $backUrl = null;
|
||||
/**
|
||||
* @var SocialLoginConfigManager
|
||||
* @var social_login_config
|
||||
*/
|
||||
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());
|
||||
require_once(e_PLUGIN."social/includes/social_login_config.php");
|
||||
$this->social_login_config_manager = new social_login_config(e107::getConfig());
|
||||
}
|
||||
|
||||
public function init()
|
||||
@@ -65,8 +65,8 @@ class core_system_xup_controller extends eController
|
||||
|
||||
public function actionTest()
|
||||
{
|
||||
require_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
|
||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
require_once(e_PLUGIN . "social/includes/social_login_config.php");
|
||||
$manager = new social_login_config(e107::getConfig());
|
||||
|
||||
if (!$manager->isFlagActive($manager::ENABLE_BIT_TEST_PAGE))
|
||||
{
|
||||
|
@@ -112,7 +112,7 @@ class signup_shortcodes extends e_shortcode
|
||||
}
|
||||
|
||||
|
||||
$manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
$manager = new social_login_config(e107::getConfig());
|
||||
$providers = $manager->getValidConfiguredProviderConfigs();
|
||||
|
||||
foreach ($providers as $p => $v)
|
||||
|
@@ -343,7 +343,7 @@ class e107
|
||||
* @param $e107_paths
|
||||
* @param $e107_root_path
|
||||
* @param array $e107_config_override
|
||||
* @return e107
|
||||
* @return object|boolean e107
|
||||
*/
|
||||
public function initInstall($e107_paths, $e107_root_path, $e107_config_override = array())
|
||||
{
|
||||
|
@@ -1104,14 +1104,14 @@ class e_user_provider
|
||||
protected $hybridauth;
|
||||
protected $_config = array();
|
||||
/**
|
||||
* @var SocialLoginConfigManager
|
||||
* @var social_login_config
|
||||
*/
|
||||
protected $social_login_config_manager;
|
||||
|
||||
public function __construct($provider = null, $config = array())
|
||||
{
|
||||
require_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
|
||||
$this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
require_once(e_PLUGIN . "social/includes/social_login_config.php");
|
||||
$this->social_login_config_manager = new social_login_config(e107::getConfig());
|
||||
|
||||
if (!empty($config))
|
||||
{
|
||||
@@ -1432,7 +1432,7 @@ class e_user_provider
|
||||
*/
|
||||
public function isSocialLoginEnabled()
|
||||
{
|
||||
return $this->social_login_config_manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL);
|
||||
return $this->social_login_config_manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -12,6 +12,111 @@ if (!getperms('P'))
|
||||
e107::lan('social',true, true);
|
||||
e107::lan('social',false, true);
|
||||
|
||||
// test legacy upgrade interface.
|
||||
/*
|
||||
$legacy = array(
|
||||
'FakeProviderNeverExisted' =>
|
||||
array(
|
||||
'enabled' => '1',
|
||||
),
|
||||
'AOL' =>
|
||||
array(
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Facebook' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'scope' => 'c',
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Foursquare' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Github' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'scope' => 'c',
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Google' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'scope' => 'c',
|
||||
'enabled' => '1',
|
||||
),
|
||||
'LinkedIn' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Live' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
'OpenID' =>
|
||||
array(
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Steam' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'key' => 'a',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Twitter' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'key' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
'Yahoo' =>
|
||||
array(
|
||||
'keys' =>
|
||||
array(
|
||||
'id' => 'a',
|
||||
'secret' => 'b',
|
||||
),
|
||||
'enabled' => '1',
|
||||
),
|
||||
);
|
||||
|
||||
e107::getConfig()->setPref('social_login', $legacy);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class social_adminarea extends e_admin_dispatcher
|
||||
{
|
||||
|
||||
@@ -50,7 +155,7 @@ class social_adminarea extends e_admin_dispatcher
|
||||
|
||||
public function init()
|
||||
{
|
||||
$slcm = new SocialLoginConfigManager(e107::getConfig());
|
||||
$slcm = new social_login_config(e107::getConfig());
|
||||
$supported_providers = $slcm->getSupportedProviders();
|
||||
$configured_providers = $slcm->getConfiguredProviders();
|
||||
$unsupported_providers = array_diff($configured_providers, $supported_providers);
|
||||
@@ -70,7 +175,7 @@ class social_adminarea extends e_admin_dispatcher
|
||||
|
||||
|
||||
|
||||
require_once("SocialLoginConfigManager.php");
|
||||
require_once("includes/social_login_config.php");
|
||||
|
||||
class social_ui extends e_admin_ui
|
||||
{
|
||||
@@ -131,7 +236,7 @@ class social_ui extends e_admin_ui
|
||||
|
||||
protected $social_logins = array();
|
||||
/**
|
||||
* @var SocialLoginConfigManager
|
||||
* @var social_login_config
|
||||
*/
|
||||
protected $social_login_config_manager;
|
||||
|
||||
@@ -141,7 +246,7 @@ class social_ui extends e_admin_ui
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig());
|
||||
$this->social_login_config_manager = new social_login_config(e107::getConfig());
|
||||
|
||||
if(!empty($_POST['save_social_logins']) )
|
||||
{
|
||||
@@ -152,10 +257,14 @@ class social_ui extends e_admin_ui
|
||||
$this->social_login_config_manager->setProviderConfig($provider_name, $raw_updated_social_login);
|
||||
}
|
||||
|
||||
$social_login_flags =
|
||||
!!$_POST['social_login_active'] << SocialLoginConfigManager::ENABLE_BIT_GLOBAL |
|
||||
!!$_POST['social_login_test_page'] << SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE;
|
||||
$cfg->setPref(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, $social_login_flags);
|
||||
if(isset($_POST['social_login_active']))
|
||||
{
|
||||
$social_login_flags =
|
||||
!!$_POST['social_login_active'] << social_login_config::ENABLE_BIT_GLOBAL |
|
||||
!!$_POST['social_login_test_page'] << social_login_config::ENABLE_BIT_TEST_PAGE;
|
||||
$cfg->setPref(social_login_config::SOCIAL_LOGIN_FLAGS, $social_login_flags);
|
||||
}
|
||||
|
||||
$cfg->save(true, true, true);
|
||||
|
||||
}
|
||||
@@ -217,31 +326,37 @@ class social_ui extends e_admin_ui
|
||||
function renderHelp()
|
||||
{
|
||||
|
||||
|
||||
$action = $this->getAction();
|
||||
|
||||
switch($action)
|
||||
{
|
||||
|
||||
case "configure":
|
||||
$notice = LAN_SOCIAL_ADMIN_45."<br />";
|
||||
$notice = LAN_SOCIAL_ADMIN_45;
|
||||
break;
|
||||
|
||||
case "unsupported":
|
||||
$notice = LAN_SOCIAL_ADMIN_48;
|
||||
break;
|
||||
|
||||
case "prefs":
|
||||
return null; // todo?
|
||||
break;
|
||||
|
||||
default:
|
||||
case "add":
|
||||
$notice = LAN_SOCIAL_ADMIN_46."<br /><br />";
|
||||
$notice .= LAN_SOCIAL_ADMIN_08." <br /><br /><a href='".self::TEST_URL."' rel='external'>".self::TEST_URL."</a>";
|
||||
|
||||
$callBack = SITEURL;
|
||||
$notice .= "<br /><br />".LAN_SOCIAL_ADMIN_09."</br ><a href='".$callBack."'>".$callBack."</a>";
|
||||
$notice = LAN_SOCIAL_ADMIN_46;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if($action == 'configure' || $action == 'add')
|
||||
{
|
||||
$notice .= "<br /><br />".LAN_SOCIAL_ADMIN_08." <br /><br /><a href='".self::TEST_URL."' rel='external'>".self::TEST_URL."</a>";
|
||||
$callBack = SITEURL;
|
||||
$notice .= "<br /><br />".LAN_SOCIAL_ADMIN_09."</br ><a href='".$callBack."'>".$callBack."</a>";
|
||||
}
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
return array("caption"=>LAN_HELP,'text'=> $tp->toHTML($notice,true));
|
||||
@@ -256,7 +371,7 @@ class social_ui extends e_admin_ui
|
||||
$unsupported_providers = array_diff($configured_providers, $supported_providers);
|
||||
// $configured_providers = array_diff($configured_providers, $unsupported_providers);
|
||||
|
||||
return $this->generateSocialLoginSection($unsupported_providers );
|
||||
return $this->generateSocialLoginSection($unsupported_providers, true );
|
||||
|
||||
|
||||
}
|
||||
@@ -404,7 +519,7 @@ class social_ui extends e_admin_ui
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><label for='social-login-active-1'>".LAN_SOCIAL_ADMIN_02."</label>
|
||||
<td><label for='social-login-active-1'>".LAN_SOCIAL_ADMIN_51."</label>
|
||||
</td>
|
||||
<td>
|
||||
".$frm->radio_switch('social_login_active', $slcm->isFlagActive($slcm::ENABLE_BIT_GLOBAL))."
|
||||
@@ -455,7 +570,7 @@ class social_ui extends e_admin_ui
|
||||
* @param array $provider_names
|
||||
* @return string
|
||||
*/
|
||||
private function generateSocialLoginSection($provider_names)
|
||||
private function generateSocialLoginSection($provider_names, $readonly=false)
|
||||
{
|
||||
if(empty($provider_names))
|
||||
{
|
||||
@@ -482,7 +597,7 @@ class social_ui extends e_admin_ui
|
||||
|
||||
foreach ($provider_names as $provider_name)
|
||||
{
|
||||
$text .= $this->generateSocialLoginRow($provider_name);
|
||||
$text .= $this->generateSocialLoginRow($provider_name, $readonly);
|
||||
}
|
||||
|
||||
$text .= "</table>";
|
||||
@@ -566,7 +681,7 @@ class social_ui extends e_admin_ui
|
||||
* @param $provider_name
|
||||
* @return string Text to append
|
||||
*/
|
||||
private function generateSocialLoginRow($provider_name, $mode = 'list')
|
||||
private function generateSocialLoginRow($provider_name, $readonly = false)
|
||||
{
|
||||
$slcm = $this->social_login_config_manager;
|
||||
$provider_type = $slcm->getTypeOfProvider($provider_name);
|
||||
@@ -596,6 +711,11 @@ class social_ui extends e_admin_ui
|
||||
'placeholder' => self::getPlaceholderFor($provider_name, $fieldSlash),
|
||||
];
|
||||
|
||||
if($readonly)
|
||||
{
|
||||
$frm_options['readonly'] = 1; ;
|
||||
}
|
||||
|
||||
$text .= "<tr><td class='col-label'>".$this->getLabel($fieldSlash)."</td>";
|
||||
$text .= "<td>".$frm->text("social_login[$provider_name][$field]", $slcm->getProviderConfig($provider_name, $fieldSlash), 256, $frm_options).
|
||||
"<div class='smalltext field-help'>$description</div>";
|
||||
@@ -604,7 +724,16 @@ class social_ui extends e_admin_ui
|
||||
|
||||
$text .= "</table></td>";
|
||||
|
||||
$textEnabled = $frm->radio_switch("social_login[$provider_name][enabled]", $slcm->isProviderEnabled($provider_name), '', '', ['class' => 'e-expandit']);
|
||||
|
||||
if($readonly)
|
||||
{
|
||||
$textEnabled = ($slcm->isProviderEnabled($provider_name)) ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON;
|
||||
}
|
||||
else
|
||||
{
|
||||
$enabledOpts = ['class' => 'e-expandit'];
|
||||
$textEnabled = $frm->radio_switch("social_login[$provider_name][enabled]", $slcm->isProviderEnabled($provider_name), '', '', $enabledOpts);
|
||||
}
|
||||
|
||||
$text .= $textKeys . $textScope . "<td class='center'>" . $textEnabled . "</td>";
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
require_once(e_HANDLER . "user_handler.php");
|
||||
|
||||
class SocialLoginConfigManager
|
||||
class social_login_config
|
||||
{
|
||||
const SOCIAL_LOGIN_PREF = "social_login";
|
||||
|
||||
@@ -100,7 +100,7 @@ class SocialLoginConfigManager
|
||||
* $options['keys']['id'] string The OAuth1 client key or OAuth2 client ID
|
||||
* $options['keys']['secret'] string The OAuth1 or OAuth2 client secret
|
||||
* $options['scope'] string OAuth2 scopes, space-delimited
|
||||
* @see SocialLoginConfigManager::saveConfig() to commit to database.
|
||||
* @see social_login_config::saveConfig() to commit to database.
|
||||
*
|
||||
*/
|
||||
public function setProviderConfig($providerName, $options)
|
@@ -9,7 +9,7 @@
|
||||
|
||||
define("LAN_SOCIAL_ADMIN_00", "Applications");
|
||||
define("LAN_SOCIAL_ADMIN_01", "Pages");
|
||||
define("LAN_SOCIAL_ADMIN_02", "Social Signup/Login"); //tab
|
||||
define("LAN_SOCIAL_ADMIN_02", "Configured Login Providers"); //tab
|
||||
define("LAN_SOCIAL_ADMIN_03", "Signup/Login"); //bar
|
||||
define("LAN_SOCIAL_ADMIN_04", "Provider");
|
||||
define("LAN_SOCIAL_ADMIN_05", "Key/ID");
|
||||
@@ -53,7 +53,7 @@ define("LAN_SOCIAL_ADMIN_42", "Custom Image");
|
||||
|
||||
define("LAN_SOCIAL_ADMIN_43","A [database update] is required to continue using this plugin.");
|
||||
define("LAN_SOCIAL_ADMIN_44", "Add New Provider");
|
||||
define("LAN_SOCIAL_ADMIN_45", "These social login providers are currently configured.\nIf the master switch [b]Social Signup/Login[/b] is toggled on, each provider in this table that is also toggled on may be used for user registration and login. If you empty the fields of a provider here and save, it will move to the [b]Add New Providers[/b] section.");
|
||||
define("LAN_SOCIAL_ADMIN_45", "These social login providers are currently configured.\nIf the master switch [b]Social Signup/Login[/b] is toggled on, each provider in this table that is also toggled on may be used for user registration and login. If you empty the fields of a provider here and save, it will move to the [b]Add New Provider[/b] section.");
|
||||
define("LAN_SOCIAL_ADMIN_46", "These are the available social login providers, which have not been configured. Once you configure and save a provider here, it will move to the [b]Configured[/b] section.");
|
||||
define("LAN_SOCIAL_ADMIN_47", "Broken Configured Providers");
|
||||
define("LAN_SOCIAL_ADMIN_48", "These social login providers were configured in the past but no longer have an adapter that can support them.[br]This may be due to them no longer existing or being replaced by a different provider.");
|
||||
@@ -62,6 +62,7 @@ define("LAN_SOCIAL_ADMIN_50", "Enable or disable the social login test page");
|
||||
|
||||
define("LAN_SOCIAL_ADMIN_08", "Note: In most cases, you will need to obtain an application ID and secret key from social login providers.\nIf a provider's name is a link, that link should take you to the login application configuration documentation.\n\nYou may test your configuration with the following URL after enabling the [b]Test Page[/b] option:");
|
||||
define("LAN_SOCIAL_ADMIN_09", "Your callback URL is: ");
|
||||
define("LAN_SOCIAL_ADMIN_51", "Social Login System");
|
||||
|
||||
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once("SocialLoginConfigManager.php");
|
||||
require_once("includes/social_login_config.php");
|
||||
|
||||
class social_setup
|
||||
{
|
||||
@@ -30,8 +30,8 @@ class social_setup
|
||||
private function upgrade_required_provider_name_normalization()
|
||||
{
|
||||
$coreConfig = e107::getConfig();
|
||||
$manager = new SocialLoginConfigManager($coreConfig);
|
||||
$providerConfig = $coreConfig->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF);
|
||||
$manager = new social_login_config($coreConfig);
|
||||
$providerConfig = $coreConfig->getPref(social_login_config::SOCIAL_LOGIN_PREF);
|
||||
if (!is_array($providerConfig)) $providerConfig = [];
|
||||
$normalizedProviderNames = array_keys($providerConfig);
|
||||
foreach ($normalizedProviderNames as $normalizedProviderName)
|
||||
@@ -75,9 +75,9 @@ class social_setup
|
||||
{
|
||||
$coreConfig = e107::getConfig();
|
||||
$logger = e107::getMessage();
|
||||
$manager = new SocialLoginConfigManager($coreConfig);
|
||||
$manager = new social_login_config($coreConfig);
|
||||
|
||||
$providerConfig = $coreConfig->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF);
|
||||
$providerConfig = $coreConfig->getPref(social_login_config::SOCIAL_LOGIN_PREF);
|
||||
if (!is_array($providerConfig)) $providerConfig = [];
|
||||
|
||||
foreach ($providerConfig as $oldNormalizedProviderName => $oldOptions)
|
||||
@@ -107,7 +107,7 @@ class social_setup
|
||||
{
|
||||
$manager->setProviderConfig($denormalizedProviderName, $newOptions);
|
||||
$coreConfig->removePref(
|
||||
SocialLoginConfigManager::SOCIAL_LOGIN_PREF . '/' . $oldNormalizedProviderName
|
||||
social_login_config::SOCIAL_LOGIN_PREF . '/' . $oldNormalizedProviderName
|
||||
);
|
||||
$logger->addSuccess(
|
||||
"Updated name of social login provider $oldNormalizedProviderName → $actualNormalizedProviderName"
|
||||
|
@@ -17,7 +17,7 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
*/
|
||||
private $pref;
|
||||
/**
|
||||
* @var SocialLoginConfigManager
|
||||
* @var social_login_config
|
||||
*/
|
||||
private $manager;
|
||||
|
||||
@@ -26,10 +26,10 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
*/
|
||||
public function _before()
|
||||
{
|
||||
include_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
|
||||
include_once(e_PLUGIN . "social/includes/social_login_config.php");
|
||||
|
||||
$this->pref = $this->make('e_pref');
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, [
|
||||
$this->pref->set(social_login_config::SOCIAL_LOGIN_PREF, [
|
||||
'Twitter-OAuth1' => [
|
||||
'enabled' => true,
|
||||
'keys' => [
|
||||
@@ -52,35 +52,35 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
'enabled' => true,
|
||||
],
|
||||
]);
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->manager = new social_login_config($this->pref);
|
||||
}
|
||||
|
||||
public function testFlagSettingOff()
|
||||
{
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, 0x0);
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->pref->set(social_login_config::SOCIAL_LOGIN_FLAGS, 0x0);
|
||||
$this->manager = new social_login_config($this->pref);
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testFlagSettingGlobalOffPreventsOthersOn()
|
||||
{
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testFlagSettingGlobalOnAllowsOtherToggles()
|
||||
{
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 1);
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 0);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_GLOBAL, 1);
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 0);
|
||||
$this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,14 +89,14 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
*/
|
||||
public function testFlagGlobalOffTurnsAllOff()
|
||||
{
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, ~0);
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->pref->set(social_login_config::SOCIAL_LOGIN_FLAGS, ~0);
|
||||
$this->manager = new social_login_config($this->pref);
|
||||
$this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->manager->setFlag(social_login_config::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testIsProviderEnabled()
|
||||
@@ -166,8 +166,8 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
|
||||
public function testSetProviderConfigOverwritesNonArray()
|
||||
{
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, 'bad string!');
|
||||
$manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->pref->set(social_login_config::SOCIAL_LOGIN_PREF, 'bad string!');
|
||||
$manager = new social_login_config($this->pref);
|
||||
$expected = ['enabled' => true];
|
||||
|
||||
$manager->setProviderConfig('FirstProvider', $expected);
|
||||
|
@@ -12,30 +12,30 @@ class social_setupTest extends \Codeception\Test\Unit
|
||||
{
|
||||
public function _before()
|
||||
{
|
||||
include_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
|
||||
include_once(e_PLUGIN . "social/includes/social_login_config.php");
|
||||
include_once(e_PLUGIN . "social/social_setup.php");
|
||||
}
|
||||
|
||||
public function testUpgradeProviderNameNormalization()
|
||||
{
|
||||
e107::getConfig()->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, SOCIAL_LOGIN_LEGACY_DATA);
|
||||
e107::getConfig()->set(social_login_config::SOCIAL_LOGIN_PREF, SOCIAL_LOGIN_LEGACY_DATA);
|
||||
$social_setup = new social_setup();
|
||||
$this->assertTrue($social_setup->upgrade_required());
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL-OpenID"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Github"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Live"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/WindowsLive"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL-OpenID"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Github"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Live"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/WindowsLive"));
|
||||
|
||||
$social_setup->upgrade_pre();
|
||||
$this->assertFalse($social_setup->upgrade_required());
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL-OpenID"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Github"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Live"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/WindowsLive-OAuth2"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL-OpenID"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Github"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2"));
|
||||
$this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Live"));
|
||||
$this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/WindowsLive-OAuth2"));
|
||||
}
|
||||
|
||||
public function testUpgradeFixRenamedProvidersXup()
|
||||
|
Reference in New Issue
Block a user