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
{
protected $modes = array(
'main' => array(
'controller' => 'social_ui',
'path' => null,
'ui' => 'social_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
// 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
'main/pages' => array('caption'=>LAN_SOCIAL_ADMIN_01, 'perm'=>'P'),
'main/configure' => array('caption'=> LAN_SOCIAL_ADMIN_02, 'perm' => 'P'),
'main/add' => array('caption'=> LAN_SOCIAL_ADMIN_44, 'perm' => 'P'),
'main/unsupported' => array('caption'=> LAN_SOCIAL_ADMIN_47, 'perm' => 'P'),
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'),
);
protected $adminMenuAliases = array(
'main/modify' => 'main/add'
);
protected $menuTitle = LAN_PLUGIN_SOCIAL_NAME;
public function init()
{
$slcm = new social_login_config(e107::getConfig());
$supported_providers = $slcm->getSupportedProviders();
$configured_providers = $slcm->getConfiguredProviders();
$unsupported_providers = array_diff($configured_providers, $supported_providers);
if(empty($unsupported_providers) && !deftrue('e_DEBUG'))
{
unset($this->adminMenu['main/unsupported']);
}
else
{
$this->adminMenu['main/unsupported']['badge'] = array('value' => count($unsupported_providers), 'type'=>'warning');
}
}
}
require_once("includes/social_login_config.php");
class social_ui extends e_admin_ui
{
protected $pluginTitle = LAN_PLUGIN_SOCIAL_NAME;
protected $pluginName = 'social';
// protected $eventName = 'social-social'; // remove comment to enable event triggers in admin.
// protected $table = 'social';
protected $pid = 'social_id';
protected $perPage = 10;
protected $batchDelete = true;
// protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = '';
protected $fields = array( );
protected $fieldpref = array();
protected $preftabs = array(LAN_LOGIN, LAN_SOCIAL_ADMIN_14, LAN_SOCIAL_ADMIN_15, LAN_SOCIAL_ADMIN_16, LAN_SOCIAL_ADMIN_17, LAN_SOCIAL_ADMIN_37);
protected $prefs = array(
'facebook_comments_limit' => array('title'=> LAN_SOCIAL_ADMIN_18, 'type'=>'number', 'tab'=>2, 'data' => 'int','help'=>LAN_SOCIAL_ADMIN_29),
'facebook_comments_theme' => array('title'=> LAN_SOCIAL_ADMIN_19, 'type'=>'dropdown', 'tab'=>2, 'writeParms'=>array('optArray'=>array('light'=>LAN_SOCIAL_ADMIN_35,'dark'=>LAN_SOCIAL_ADMIN_36)), 'data' => 'str','help'=>''),
'facebook_comments_loadingtext' => array('title'=> LAN_SOCIAL_ADMIN_21, 'type'=>'text', 'tab'=>2, 'data' => 'str', 'writeParms'=>array('placeholder'=>LAN_SOCIAL_ADMIN_30), 'help'=>''),
'facebook_like_menu_theme' => array('title'=> LAN_SOCIAL_ADMIN_19, 'type'=>'dropdown', 'tab'=>3, 'writeParms'=>array('optArray'=>array('light'=>LAN_SOCIAL_ADMIN_35,'dark'=>LAN_SOCIAL_ADMIN_36)), 'data' => 'str'),
'facebook_like_menu_action' => array('title'=> LAN_SOCIAL_ADMIN_20, 'type'=>'dropdown', 'tab'=>3, 'writeParms'=>array('optArray'=>array('like'=>'Like','recommend'=>LAN_SOCIAL_ADMIN_32)), 'data' => 'str'),
'facebook_like_menu_width' => array('title'=> LAN_SOCIAL_ADMIN_22, 'type'=>'number', 'tab'=>3, 'data' => 'int','help'=>LAN_SOCIAL_ADMIN_31),
// 'facebook_like_menu_ref' => array('title'=> "Referrer", 'type'=>'text', 'tab'=>2, 'data' => 'str', 'writeParms'=>'size=xxlarge', 'help'=>'Leave blank to use Site Url'),
'twitter_menu_theme' => array('title'=> LAN_SOCIAL_ADMIN_19, 'type'=>'dropdown', 'tab'=>4, 'writeParms'=>array('optArray'=>array('light'=>LAN_SOCIAL_ADMIN_35,'dark'=>LAN_SOCIAL_ADMIN_36)), 'data' => 'str'),
'twitter_menu_height' => array('title'=> LAN_SOCIAL_ADMIN_23, 'type'=>'number', 'tab'=>4, 'data' => 'int','help'=>LAN_SOCIAL_ADMIN_33),
'twitter_menu_limit' => array('title'=> LAN_SOCIAL_ADMIN_18, 'type'=>'number', 'tab'=>4, 'data' => 'int','help'=>LAN_SOCIAL_ADMIN_34),
'sharing_mode' => array('title'=> LAN_SOCIAL_ADMIN_24, 'type'=>'dropdown', 'tab'=>1, 'writeParms'=>array('optArray'=>array('normal'=>LAN_SOCIAL_ADMIN_25,'dropdown'=>LAN_SOCIAL_ADMIN_26,'off'=>LAN_SOCIAL_ADMIN_27)), 'data' => 'str','help'=>''),
'sharing_hashtags' => array('title'=> 'Hashtags', 'type'=>'tags', 'tab'=>1, 'data' => 'str','help'=>LAN_SOCIAL_ADMIN_28),
'sharing_providers' => array('title'=> LAN_SOCIAL_ADMIN_39, 'type'=>'checkboxes', 'tab'=>1, 'writeParms'=>array(), 'data' => 'str','help'=>''),
'xup_login_update_username' => array('title'=> LAN_SOCIAL_ADMIN_40, 'type'=>'bool', 'tab'=>0, 'writeParms'=>array(), 'data' => 'str','help'=>''),
'xup_login_update_avatar' => array('title'=> LAN_SOCIAL_ADMIN_41, 'type'=>'bool', 'tab'=>0, 'writeParms'=>array(), 'data' => 'str','help'=>''),
'og_image' => array('title'=> LAN_SOCIAL_ADMIN_42, 'type'=>'image', 'tab'=>5, 'data' => 'str','help'=>'og:image'),
);
protected $social_logins = array();
/**
* @var social_login_config
*/
protected $social_login_config_manager;
protected $social_external = array();
const TEST_URL = SITEURL."?route=system/xup/test";
public function init()
{
$this->social_login_config_manager = new social_login_config(e107::getConfig());
if(!empty($_POST['save_social_logins']) )
{
$cfg = e107::getConfig();
foreach ($_POST['social_login'] as $provider_name => $raw_updated_social_login)
{
$this->social_login_config_manager->setProviderConfig($provider_name, $raw_updated_social_login);
}
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);
}
if(!empty($_POST['save_social_pages']) && isset($_POST['xurl']))
{
$cfg = e107::getConfig();
$cfg->setPref('xurl', $_POST['xurl']);
$cfg->save(true, true, true);
}
$tp = e107::getParser();
require_once(e_PLUGIN."social/e_shortcode.php");
$obj = new social_shortcodes;
$providers = $obj->getProviders();
foreach($providers as $k=>$v)
{
$this->prefs['sharing_providers']['writeParms']['optArray'][$k] = $k;
}
}
// ------- Customize Create --------
public function beforeCreate($new_data, $old_data)
{
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
// do something
}
public function onCreateError($new_data, $old_data)
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
// do something
}
public function onUpdateError($new_data, $old_data, $id)
{
// do something
}
function renderHelp()
{
$action = $this->getAction();
switch($action)
{
case "configure":
$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;
break;
}
if($action == 'configure' || $action == 'add')
{
$notice .= "
".LAN_SOCIAL_ADMIN_08."
".self::TEST_URL."";
$callBack = SITEURL;
$notice .= "
".LAN_SOCIAL_ADMIN_09."".$callBack."";
}
$tp = e107::getParser();
return array("caption"=>LAN_HELP,'text'=> $tp->toHTML($notice,true));
}
public function unsupportedPage()
{
$slcm = $this->social_login_config_manager;
$supported_providers = $slcm->getSupportedProviders();
$configured_providers = $slcm->getConfiguredProviders();
$unsupported_providers = array_diff($configured_providers, $supported_providers);
// $configured_providers = array_diff($configured_providers, $unsupported_providers);
return $this->generateSocialLoginSection($unsupported_providers, true );
}
public function pagesPage()
{
$frm = $this->getUI();
$pref = e107::pref('core');
$text2 = "
". $frm->help($help)." | ".$frm->text($keypref, varset($pref['xurl'][$k]), false, $opts). " |
".$frm->radio_switch('social_login_active', $slcm->isFlagActive($slcm::ENABLE_BIT_GLOBAL))."
".LAN_SOCIAL_ADMIN_07."
|
|
".$frm->radio_switch('social_login_test_page', $slcm->isFlagActive($slcm::ENABLE_BIT_TEST_PAGE))."
".LAN_SOCIAL_ADMIN_50."
|
" . LAN_SOCIAL_ADMIN_04 . " | " . LAN_TYPE . " | " . LAN_CONFIGURE . " | " . LAN_SOCIAL_ADMIN_03 . " |
---|
".LAN_ACTIVE." | " . $textEnabled . " |
".LAN_NAME." | |
".LAN_TYPE." | $provider_type |
".$this->getLabel($fieldSlash)." | ";
$text .= $frm->text("social_login[$provider_name][$field]", $placeholder, 256, $frm_options);
$text .= " $description ";
$text .= " |
".$this->getLabel($fieldSlash)." | "; $text .= "".$frm->text("social_login[$provider_name][$field]", $slcm->getProviderConfig($provider_name, $fieldSlash), 256, $frm_options).
" $description ";
$text .= " |