From 3b2d8333b62290688f64e061023669463fd8f04c Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Thu, 14 Jun 2012 04:11:52 +0000 Subject: [PATCH] hybridAuth work - still some issues. --- e107_admin/prefs.php | 33 +++++--- e107_admin/sql/core_sql.php | 2 +- .../shortcodes/batch/signup_shortcodes.php | 4 +- e107_core/xml/default_install.xml | 2 + index.php | 79 +++++++++++++++++++ 5 files changed, 106 insertions(+), 14 deletions(-) diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 497e9fdda..d3147a857 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -63,7 +63,7 @@ if(isset($_POST['updateprefs'])) unset($_POST['updateprefs'], $_POST['sitelanguage']); - print_a($_POST); + $_POST['cookie_name'] = str_replace(array(" ", "."), "_", $_POST['cookie_name']); $_POST['cookie_name'] = preg_replace("#[^a-zA-Z0-9_]#", "", $_POST['cookie_name']); @@ -133,6 +133,7 @@ if(isset($_POST['updateprefs'])) { $newValue = $tp->toDB($value); } + $core_pref->update($key, $newValue); /*if($newValue != $core_pref->get($key)) { // Changed value @@ -733,8 +734,8 @@ $single_logins = array ( $text .= " -
- Single Login Options +
+ Social Login Options
Note: This section is not functional at the moment
@@ -743,14 +744,20 @@ $text .= " - + "; + if(!is_array($pref['social_login'])) + { + $pref['social_login'] = array(); + } + foreach($single_logins as $prov=>$val) - { + { + $text .= " @@ -761,22 +768,26 @@ $text .= " switch ($k) { case 'enabled': $eopt = array('class'=>'e-expandit'); - $text .= $frm->radio_switch('single_login['.$prov.'][enabled]', $pref['single_login'][$prov]['enabled'],'','',$eopt); + $text .= $frm->radio_switch('social_login['.$prov.'][enabled]', $pref['social_login'][$prov]['enabled'],'','',$eopt); break; case 'keys': // $cls = vartrue($pref['single_login'][$prov]['keys'][$tk]) ? "class='e-hideme'" : ''; - $sty = vartrue($pref['single_login'][$prov]['keys'][$tk]) ? "" : "display:none"; + $sty = vartrue($pref['social_login'][$prov]['keys'][$tk]) ? "" : "display:none"; $text .= "
"; foreach($v as $tk=>$idk) { $opt['placeholder'] = $tk; - $text .= "
".$frm->text('single_login['.$prov.'][keys]['.$tk.']', $pref['single_login'][$prov]['keys'][$tk],20,$opt); + $text .= "
".$frm->text('social_login['.$prov.'][keys]['.$tk.']', $pref['social_login'][$prov]['keys'][$tk],20,$opt); } $text .= "
"; break; + case 'scope': + $text .= $frm->hidden('social_login['.$prov.'][scope]','email'); + break; + default: break; @@ -793,7 +804,7 @@ $text .= " $text .= "
Enable Single LoginsEnable Social Logins - ".$frm->radio_switch('single_login_active', $pref['single_login_active'])." + ".$frm->radio_switch('social_login_active', $pref['social_login_active'])."
".$prov."
- ".pref_submit('single-login')." + ".pref_submit('sociallogin')."
"; @@ -1600,7 +1611,7 @@ function prefs_adminmenu() $var['core-prefs-date']['text'] = PRFLAN_21; $var['core-prefs-registration']['text'] = PRFLAN_28; $var['core-prefs-signup']['text'] = PRFLAN_19; - $var['core-prefs-single-login']['text'] = "Single-Login"; + $var['core-prefs-sociallogin']['text'] = "Social Logins"; $var['core-prefs-textpost']['text'] = PRFLAN_101; $var['core-prefs-security']['text'] = PRFLAN_47; $var['core-prefs-comments']['text'] = PRFLAN_210; diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index 1c8b12ab8..98b911728 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -519,7 +519,7 @@ CREATE TABLE user ( user_perms text NOT NULL, user_realm text NOT NULL, user_pwchange int(10) unsigned NOT NULL default '0', - user_xup varchar(100) NOT NULL default '', + user_xup text NOT NULL, PRIMARY KEY (user_id), UNIQUE KEY user_name (user_name), UNIQUE KEY user_loginname (user_loginname), diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php index 769142ba8..a5e563299 100755 --- a/e107_core/shortcodes/batch/signup_shortcodes.php +++ b/e107_core/shortcodes/batch/signup_shortcodes.php @@ -53,10 +53,10 @@ class signup_shortcodes extends e_shortcode if(vartrue($pref['single_login_active'])) { $text = ""; - $providers = array('facebook','twitter','google','yahoo'); + $providers = array('facebook','twitter','google','yahoo','blogger'); foreach($providers as $p) { - $text .= ""; + $text .= ""; } $text .= "
"; diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml index 8726fa851..c7ca21128 100644 --- a/e107_core/xml/default_install.xml +++ b/e107_core/xml/default_install.xml @@ -210,6 +210,8 @@ City, State, Country / 1 + 0 + 0 0 diff --git a/index.php b/index.php index 32e24611e..29ad65550 100644 --- a/index.php +++ b/index.php @@ -58,6 +58,85 @@ } $response->sendMeta(); + + +// -------------- Experimental ----------------- + + unset($_SESSION['E:SOCIAL']); + + if(!isset($_SESSION['E:SOCIAL']) && e107::getPref('social_login_active', false) && (e_ADMIN_AREA !== true)) + { + require_once(e_HANDLER."hybridauth/Hybrid/Auth.php"); + + $config = array( + "base_url" => SITEURL.$HANDLERS_DIRECTORY."hybridauth/", + "providers" => e107::getPref('social_login', array()) + ); + + print_a($config); + // $params = array("hauth_return_to" => e_SELF); + + $hybridauth = new Hybrid_Auth($config); + + $prov = (!isset($config['providers'][$_GET['provider']])) ? "Facebook" : $_GET['provider']; + + + $adapter = $hybridauth->authenticate( $prov); + $user_profile = $adapter->getUserProfile(); + + $prov_id = $prov."_".$user_profile->identifier; + + if($user_profile->identifier >0) + { + if (!$sql->db_Select("user", "*", "user_xup = '".$prov_id."' ")) // New User + { + $user_join = time(); + $user_pass = md5($user_profile->identifier.$user_join); + $user_loginname = "xup_".$user_profile->identifier; + + $insert = array( + 'user_name' => $user_profile->displayName, + 'user_email' => $user_profile->email, + 'user_loginname' => $user_loginname, + 'user_password' => $user_pass, + 'user_login' => $user_profile->displayName, + 'user_join' => $user_join, + 'user_xup' => $prov_id + ); + + if($newid = $sql->db_Insert('user',$insert,true)) + { + e107::getEvent()->trigger('usersup', $insert); + if(!USERID) + { + require_once(e_HANDLER.'login.php'); + $usr = new userlogin($user_loginname, $user_pass, 'signup', ''); + } + } + } + else // Existing User. + { + + } + + + } + // echo "CHECKING"; + $_SESSION['E:SOCIAL'] = (array) $user_profile; + echo "USERNAME=".USERNAME; + echo "
USEREMAIL=".USEREMAIL; + echo "
USERIMAGE=".USERIMAGE; + // print_a($_SESSION['E:SOCIAL']); + } + + +// ------------------------------------------- + + + + + + include_once(HEADERF); eFront::instance()->getResponse()->send('default', false, true); include_once(FOOTERF);