diff --git a/e107_plugins/facebook/facebook_config.php b/e107_plugins/facebook/facebook_config.php
index 2b5f33390..9fd712f7c 100644
--- a/e107_plugins/facebook/facebook_config.php
+++ b/e107_plugins/facebook/facebook_config.php
@@ -14,26 +14,102 @@ if (!getperms("P"))
exit();
}*/
-
-
-require_once (e_ADMIN."auth.php");
-
-$fb = new facebook_admin;
-
-
-if (isset($_POST['save-settings']))
+class facebook_admin extends e_admin_dispatcher
{
- $fb->save_settings();
- $fb->message = "
Preferences Updated!
";
+
+ protected $modes = array(
+ 'main' => array(
+ 'controller' => 'facebook_main_ui',
+ 'path' => null,
+ 'ui' => 'facebook_admin_form_ui',
+ 'uipath' => null
+ )
+ );
+
+ protected $adminMenu = array(
+ 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => '0'),
+ 'main/custom' => array('caption'=> 'Instructions', 'perm' => '0')
+ );
+
+ protected $menuTitle = 'Facebook';
+}
+
+
+
+class facebook_main_ui extends e_admin_ui
+{
+ protected $pluginTitle = 'Facebook Connect';
+ protected $pluginName = 'facebook';
+
+
+ protected $prefs = array(
+ 'Facebook_App-Bundle' => array('title'=> 'Facebook Application ID', 'type'=>'text'),
+ 'Facebook_Api-Key' => array('title'=> 'Facebook API Key', 'type'=>'text'),
+ 'Facebook_Secret-Key' => array('title'=> 'Facebook Secret Key', 'type'=>'text')
+ );
+
+ function customPage()
+ {
+ global $ns,$pref;
+
+ $text = '
+
+
+
Setting Up Your Application and Getting an API Key
+
+
+
+
+ If you don\'t already have a Facebook Platform API key for your site, create an application with the Facebook Developer application.
+ Note: Even if you have created an application and received an API key, you should review steps 1.4 through 1.7 and make sure your application settings are appropriate.
+
+
+ - 1. Go to http://www.facebook.com/developers/createapp.php to create a new application.
+
- 2. Enter a name for your application in the Application Name field.
+
- 3. Accept the Developer Terms of Service, then click Save Changes.
+
- 4. On the Basic tab, keep all of the defaults.
+
- 5. Take note of the API Key, you\'ll need this shortly.
+ - 6. Click the Connect tab. Set Connect URL to the top-level directory of the site where you plan to implement Facebook Connect (this is usually your domain, like http://www.example.com, but could also be a subdirectory).
+
- 7. You should include a logo that appears on the Facebook Connect dialog. Next to Facebook Connect Logo, click Change your Facebook Connect logo and browse to an image file. The logo can be up to 99 pixels wide by 22 pixels tall, and must be in JPG, GIF, or PNG format.
+
- 8. If you plan to implement Facebook Connect across a number of subdomains of your site (for example, foo.example.com and bar.example.com), you need to enter a Base Domain (which would be example.com in this case). Specifying a base domain allows you to make calls using the PHP and JavaScript client libraries as well as get and store session information for any subdomain of the base domain. For more information about subdomains, see Supporting Subdomains In Facebook Connect.
+
- 9. Click Save Changes.
+
+ |
+
+
+
+ ';
+
+ return $text;
+ }
+
+}
+
+class facebook_admin_form_ui extends e_admin_form_ui
+{
+
+ function init()
+ {
+
+ }
+
}
-$fb->pref_form();
-
-require_once (e_ADMIN."footer.php");
+new facebook_admin();
-class facebook_admin
+require_once(e_ADMIN."auth.php");
+
+e107::getAdminUI()->runPage();
+
+require_once(e_ADMIN."footer.php");
+exit;
+
+
+
+
+class facebook_aasdadmin
{
var $message;
@@ -106,37 +182,7 @@ class facebook_admin
- function display_help()
- {
- global $ns,$pref;
-
- $text = '
-
-
Setting Up Your Application and Getting an API Key
-
-
-
- If you don\'t already have a Facebook Platform API key for your site, create an application with the Facebook Developer application.
- Note: Even if you have created an application and received an API key, you should review steps 1.4 through 1.7 and make sure your application settings are appropriate.
-
-
- - 1. Go to http://www.facebook.com/developers/createapp.php to create a new application.
-
- 2. Enter a name for your application in the Application Name field.
-
- 3. Accept the Developer Terms of Service, then click Save Changes.
-
- 4. On the Basic tab, keep all of the defaults.
-
- 5. Take note of the API Key, you\'ll need this shortly.
- - 6. Click the Connect tab. Set Connect URL to the top-level directory of the site where you plan to implement Facebook Connect (this is usually your domain, like http://www.example.com, but could also be a subdirectory).
-
- 7. You should include a logo that appears on the Facebook Connect dialog. Next to Facebook Connect Logo, click Change your Facebook Connect logo and browse to an image file. The logo can be up to 99 pixels wide by 22 pixels tall, and must be in JPG, GIF, or PNG format.
-
- 8. If you plan to implement Facebook Connect across a number of subdomains of your site (for example, foo.example.com and bar.example.com), you need to enter a Base Domain (which would be example.com in this case). Specifying a base domain allows you to make calls using the PHP and JavaScript client libraries as well as get and store session information for any subdomain of the base domain. For more information about subdomains, see Supporting Subdomains In Facebook Connect.
-
- 9. Click Save Changes.
-
- |
-
-
-
';
-
- return $text;
- }
+
}
diff --git a/e107_plugins/facebook/facebook_function.php b/e107_plugins/facebook/facebook_function.php
index 0a7c6184e..273ba43b9 100644
--- a/e107_plugins/facebook/facebook_function.php
+++ b/e107_plugins/facebook/facebook_function.php
@@ -1,25 +1,27 @@
get_loggedin_user();
- }catch (FacebookRestClientException $e) {
+ }
+ catch (FacebookRestClientException $e)
+ {
//echo "Facebook connect error:".$e->getCode();
}
return null;
@@ -33,76 +35,63 @@ function is_fb() {
*
*/
-function Add_Facebook_Connect_User ( $info = '', $user_id ) {
-
-
-
- /* $full = array (
- 'facebook_about_me' => Get_Facebook_Info ( 'about_me' ) ,
- 'facebook_activities' => Get_Facebook_Info ( 'activities' ) ,
- 'facebook_birthday_date' => Get_Facebook_Info ( 'birthday_date' ) ,
- 'facebook_books' => Get_Facebook_Info ( 'books' ) ,
- 'facebook_education_history' => Get_Facebook_Info ( 'education_history' ) ,
- 'facebook_hometown_location' => Get_Facebook_Info ( 'hometown_location' ) ,
- 'facebook_hs_info' => Get_Facebook_Info ( 'hs_info' ) ,
- 'facebook_interests' => Get_Facebook_Info ( 'interests' ) ,
- 'facebook_is_app_user' => Get_Facebook_Info ( 'is_app_user' ) ,
- 'facebook_is_blocked' => Get_Facebook_Info ( 'is_blocked' ) ,
- 'facebook_meeting_for' => Get_Facebook_Info ( 'meeting_for' ) ,
- 'facebook_meeting_sex' => Get_Facebook_Info ( 'meeting_sex' ) ,
- 'facebook_movies' => Get_Facebook_Info ( 'movies' ) ,
- 'facebook_music' => Get_Facebook_Info ( 'music' ) ,
- 'facebook_notes_count' => Get_Facebook_Info ( 'notes_count' ) ,
- 'facebook_pic' => Get_Facebook_Info ( 'pic' ) ,
- 'facebook_pic_with_logo' => Get_Facebook_Info ( 'pic_with_logo' ) ,
- 'facebook_pic_big' => Get_Facebook_Info ( 'pic_big' ) ,
- 'facebook_pic_big_with_logo' => Get_Facebook_Info ( 'pic_big_with_logo' ) ,
- 'facebook_pic_small' => Get_Facebook_Info ( 'pic_small' ) ,
- 'facebook_pic_small_with_logo' => Get_Facebook_Info ( 'pic_small_with_logo' ) ,
- 'facebook_pic_square' => Get_Facebook_Info ( 'pic_square' ) ,
- 'facebook_pic_square_with_logo' => Get_Facebook_Info ( 'pic_square_with_logo' ) ,
- 'facebook_political' => Get_Facebook_Info ( 'political' ) ,
- 'facebook_profile_blurb' => Get_Facebook_Info ( 'profile_blurb' ) ,
- 'facebook_profile_update_time' => Get_Facebook_Info ( 'profile_update_time' ) ,
- 'facebook_quotes' => Get_Facebook_Info ( 'quotes' ) ,
- 'facebook_relationship_status' => Get_Facebook_Info ( 'relationship_status' ) ,
- 'facebook_significant_other_id' => Get_Facebook_Info ( 'significant_other_id' ) ,
- 'facebook_tv' => Get_Facebook_Info ( 'tv' ) ,
- 'facebook_wall_count' => Get_Facebook_Info ( 'wall_count' ) ,
- 'facebook_website' => Get_Facebook_Info ( 'website' ) ,
- 'facebook_religion' => Get_Facebook_Info ( 'religion' ) ,
- 'facebook_work_history' => Get_Facebook_Info ( 'work_history' )
- ) ; */
-
- $standard = array (
- 'facebook_connected' => '1',
- 'facebook_uid' => is_fb() ,
- 'facebook_user_id' => $user_id,
- 'facebook_last_name' => Get_Facebook_Info ( 'last_name' ) ,
- 'facebook_username' => Get_Facebook_Info ( 'username' ) ,
- 'facebook_name' => Get_Facebook_Info ( 'name' ) ,
- //'facebook_affiliations' => Get_Facebook_Info ( 'affiliations' ) ,
- 'facebook_sex' => Get_Facebook_Info ( 'sex' ) ,
- 'facebook_timezone' => Get_Facebook_Info ( 'timezone' ) ,
- 'facebook_birthday' => Get_Facebook_Info ( 'birthday' ) ,
- 'facebook_profile_url' => Get_Facebook_Info ( 'profile_url' ) ,
- //'facebook_proxied_email' => Get_Facebook_Info ( 'proxied_emai' ) ,
- 'facebook_email_hashes' => Get_Facebook_Info ( 'email_hashes' ) ,
- 'facebook_first_name' => Get_Facebook_Info ( 'first_name' ) ,
- 'facebook_current_location' => Get_Facebook_Info ( 'current_location' ) ,
- 'facebook_locale' => Get_Facebook_Info ( 'locale' )
- ) ;
-
- $query = $standard;
-
- if ( trim ( $info ) == 'full' ) {
-
- $query = array_push ( $standard, $full ) ;
-
- }
- global $sql;
-
- $sql->db_Insert ( 'facebook', $query ) ;
+function Add_Facebook_Connect_User($info = '', $user_id)
+{
+
+ /* $full = array (
+ 'facebook_about_me' => Get_Facebook_Info ( 'about_me' ) ,
+ 'facebook_activities' => Get_Facebook_Info ( 'activities' ) ,
+ 'facebook_birthday_date' => Get_Facebook_Info ( 'birthday_date' ) ,
+ 'facebook_books' => Get_Facebook_Info ( 'books' ) ,
+ 'facebook_education_history' => Get_Facebook_Info ( 'education_history' ) ,
+ 'facebook_hometown_location' => Get_Facebook_Info ( 'hometown_location' ) ,
+ 'facebook_hs_info' => Get_Facebook_Info ( 'hs_info' ) ,
+ 'facebook_interests' => Get_Facebook_Info ( 'interests' ) ,
+ 'facebook_is_app_user' => Get_Facebook_Info ( 'is_app_user' ) ,
+ 'facebook_is_blocked' => Get_Facebook_Info ( 'is_blocked' ) ,
+ 'facebook_meeting_for' => Get_Facebook_Info ( 'meeting_for' ) ,
+ 'facebook_meeting_sex' => Get_Facebook_Info ( 'meeting_sex' ) ,
+ 'facebook_movies' => Get_Facebook_Info ( 'movies' ) ,
+ 'facebook_music' => Get_Facebook_Info ( 'music' ) ,
+ 'facebook_notes_count' => Get_Facebook_Info ( 'notes_count' ) ,
+ 'facebook_pic' => Get_Facebook_Info ( 'pic' ) ,
+ 'facebook_pic_with_logo' => Get_Facebook_Info ( 'pic_with_logo' ) ,
+ 'facebook_pic_big' => Get_Facebook_Info ( 'pic_big' ) ,
+ 'facebook_pic_big_with_logo' => Get_Facebook_Info ( 'pic_big_with_logo' ) ,
+ 'facebook_pic_small' => Get_Facebook_Info ( 'pic_small' ) ,
+ 'facebook_pic_small_with_logo' => Get_Facebook_Info ( 'pic_small_with_logo' ) ,
+ 'facebook_pic_square' => Get_Facebook_Info ( 'pic_square' ) ,
+ 'facebook_pic_square_with_logo' => Get_Facebook_Info ( 'pic_square_with_logo' ) ,
+ 'facebook_political' => Get_Facebook_Info ( 'political' ) ,
+ 'facebook_profile_blurb' => Get_Facebook_Info ( 'profile_blurb' ) ,
+ 'facebook_profile_update_time' => Get_Facebook_Info ( 'profile_update_time' ) ,
+ 'facebook_quotes' => Get_Facebook_Info ( 'quotes' ) ,
+ 'facebook_relationship_status' => Get_Facebook_Info ( 'relationship_status' ) ,
+ 'facebook_significant_other_id' => Get_Facebook_Info ( 'significant_other_id' ) ,
+ 'facebook_tv' => Get_Facebook_Info ( 'tv' ) ,
+ 'facebook_wall_count' => Get_Facebook_Info ( 'wall_count' ) ,
+ 'facebook_website' => Get_Facebook_Info ( 'website' ) ,
+ 'facebook_religion' => Get_Facebook_Info ( 'religion' ) ,
+ 'facebook_work_history' => Get_Facebook_Info ( 'work_history' )
+ ) ; */
+
+ $standard = array('facebook_connected'=>'1', 'facebook_uid'=>is_fb(), 'facebook_user_id'=>$user_id, 'facebook_last_name'=>Get_Facebook_Info('last_name'), 'facebook_username'=>Get_Facebook_Info('username'), 'facebook_name'=>Get_Facebook_Info('name'),
+ //'facebook_affiliations' => Get_Facebook_Info ( 'affiliations' ) ,
+ 'facebook_sex'=>Get_Facebook_Info('sex'), 'facebook_timezone'=>Get_Facebook_Info('timezone'), 'facebook_birthday'=>Get_Facebook_Info('birthday'), 'facebook_profile_url'=>Get_Facebook_Info('profile_url'),
+ //'facebook_proxied_email' => Get_Facebook_Info ( 'proxied_emai' ) ,
+ 'facebook_email_hashes'=>Get_Facebook_Info('email_hashes'), 'facebook_first_name'=>Get_Facebook_Info('first_name'), 'facebook_current_location'=>Get_Facebook_Info('current_location'), 'facebook_locale'=>Get_Facebook_Info('locale'));
+
+ $query = $standard;
+
+ if (trim($info) == 'full')
+ {
+
+ $query = array_push($standard, $full);
+
+ }
+ global $sql;
+
+ $sql->db_Insert('facebook', $query);
}
@@ -111,54 +100,53 @@ function Add_Facebook_Connect_User ( $info = '', $user_id ) {
*
*/
-function Render_Facebook_Profile() {
- if ( is_fb() ) {
-
- $html .= '';
- $html .= 'Welcome, ' . Get_Facebook_Info ( 'name' );
- $html .= '
';
- $html .= '';
- $html .= '';
- $html .= getProfilePic ( is_fb() , true ) ;
- $html .= '';
- $html .= '
';
-
-
- //check for User Permission
-
- if ( Has_App_Permission( 'publish_stream' ) == 0 ) {
-
- $html .= '';
- $html .= '';
- $html .= 'Would you like our application to read from and post to your News Feed?';
- $html .= '';
- $html .= '
';
-
- }
-
- /*
- if ( ADMIN )
- {
+function Render_Facebook_Profile()
+{
+ if (is_fb())
+ {
+
+ $html .= '';
+ $html .= 'Welcome, '.Get_Facebook_Info('name');
+ $html .= '
';
+ $html .= '';
+ $html .= '';
+ $html .= getProfilePic(is_fb(), true);
+ $html .= '';
+ $html .= '
';
+
+ //check for User Permission
+
+ if (Has_App_Permission('publish_stream') == 0)
+ {
+
+ $html .= '';
+ $html .= '';
+ $html .= 'Would you like our application to read from and post to your News Feed?';
+ $html .= '';
+ $html .= '
';
+
+ }
+
+ /*
+ if ( ADMIN )
+ {
+ $html .= '→ Admin Area
';
+ }
+ $html .= '
→ Settings
';
+ $html .= '→ Profile
';
+
+ */
- $html .= '→ Admin Area
';
-
- }
-
- $html .= '
→ Settings
';
- $html .= '→ Profile
';
-
- */
-
- $html .= '';
- $html .= '
Logout ';
- $html .= '
';
-
- $html .= '';
-
- return $html;
- }
+ $html .= '';
+ $html .= '
Logout ';
+ $html .= '
';
+
+ $html .= '';
+
+ return $html;
+ }
}
/**
@@ -166,47 +154,49 @@ function Render_Facebook_Profile() {
*
*/
-function facebook_client() {
- global $pref;
-
- static $facebook = null;
-
- if ( $facebook === null ) {
- $facebook = new Facebook ( $pref[ 'Facebook_Api-Key' ], $pref[ 'Facebook_Secret-Key' ] ) ;
-
- if ( !$facebook ) {
- // Could not create facebook client!
- }
-
- }
- return $facebook;
+function facebook_client()
+{
+ global $pref;
+
+ $pref = e107::getPlugConfig()->getPref();
+
+ static $facebook = null;
+
+ if ($facebook === null)
+ {
+ $facebook = new Facebook($pref['Facebook_Api-Key'], $pref['Facebook_Secret-Key']);
+
+ if (!$facebook)
+ {
+ // Could not create facebook client!
+ }
+
+ }
+ return $facebook;
}
-
/**
* since 2009 User Permission Required for Post Stream
*
* http://wiki.developers.facebook.com/index.php/Users.hasAppPermission
*
- * $ext_perm = email, read_stream, publish_stream, offline_access, status_update, photo_upload, create_event, rsvp_event, sms, video_upload, create_note, share_item.
- *
- * return 0 OR 1
- */
-
-
- function Has_App_Permission( $ext_perm ) {
-
- if ( is_fb() ) {
-
-$HasAppPermission = facebook_client()->api_client->users_hasAppPermission ( $ext_perm , is_fb() ) ;
-
- return $HasAppPermission;
-
- }
-
- }
-
+ * $ext_perm = email, read_stream, publish_stream, offline_access, status_update, photo_upload, create_event, rsvp_event, sms, video_upload, create_note, share_item.
+ *
+ * return 0 OR 1
+ */
+function Has_App_Permission($ext_perm)
+{
+
+ if (is_fb())
+ {
+
+ $HasAppPermission = facebook_client()->api_client->users_hasAppPermission($ext_perm, is_fb());
+
+ return $HasAppPermission;
+
+ }
+}
/**
* Function for retrieve Facebook info by using his API
@@ -214,41 +204,41 @@ $HasAppPermission = facebook_client()->api_client->users_hasAppPermission ( $ext
* more info: http://wiki.developers.facebook.com/index.php/User_ ( FQL )
*
*/
-
-function Get_Facebook_Info ( $info , $friend = '' ) {
-
-
-
- if ( is_fb() ) {
-
- $uid = is_fb();
-
- if ( $friend != '' ) {
-
- $uid = $friend;
-
- }
-
-
- $info_data = facebook_client()->api_client->users_getInfo ( $uid, $info ) ;
-
- if ( ! empty ( $info_data ) ) {
-
- $data[ $info ] = $info_data[ 0 ][ $info ];
-
- if ( is_array ( $data[ $info ] ) ) {
-
- $data[ $info ] = implode ( ',', $info_data[0][ $info ] ) ;
-
- }
-
- $text = $data[ $info ] ? $data[ $info ] : null;
-
- }
-
- return $text;
- }
-
+function Get_Facebook_Info($info, $friend = '')
+{
+
+ if (is_fb())
+ {
+
+ $uid = is_fb();
+
+ if ($friend != '')
+ {
+
+ $uid = $friend;
+
+ }
+
+ $info_data = facebook_client()->api_client->users_getInfo($uid, $info);
+
+ if (! empty($info_data))
+ {
+
+ $data[$info] = $info_data[0][$info];
+
+ if (is_array($data[$info]))
+ {
+
+ $data[$info] = implode(',', $info_data[0][$info]);
+
+ }
+
+ $text = $data[$info] ? $data[$info] : null;
+
+ }
+
+ return $text;
+ }
}
@@ -257,52 +247,42 @@ function Get_Facebook_Info ( $info , $friend = '' ) {
*
*/
-function Fb_Connect_Me() {
-
- global $sql;
- $sql4 = new db;
-if ( !$sql4->db_select("user_extended","*","user_facebookID = '".is_fb()."' ") ) {
-
- $nickname = username_exists ( Get_Facebook_Info ( 'first_name' ) );
- $password = md5 ( is_fb() ) ;
- $username = "FacebookUser_".is_fb() ;
-
-$sql2 = new db;
-
- $sql2->db_Insert ( 'user',
- array (
- 'user_name' => $nickname,
- 'user_loginname' => $username,
- 'user_password' => $password,
- 'user_login' => Get_Facebook_Info ( 'name' ) ,
- 'user_image' => Get_Facebook_Info ( 'pic' )
- )
- ) ;
-$sql3 = new db;
- $sql3->db_Insert ( 'user_extended',
- array (
- 'user_extended_id' => last_user() ,
- 'user_facebookID' => is_fb()
- )
- ) ;
-
- Add_Facebook_Connect_User('',last_user());
-
- set_cookies ( last_user(), md5 ( $password ) ) ;
-
- header ( 'Location:' . e_SELF ) ;
-}
+function Fb_Connect_Me()
+{
+
+ global $sql;
+ $sql4 = new db;
+ if (!$sql4->db_select("user_extended", "*", "user_facebookID = '".is_fb()."' "))
+ {
+
+ $nickname = username_exists(Get_Facebook_Info('first_name'));
+ $password = md5(is_fb());
+ $username = "FacebookUser_".is_fb();
+
+ $sql2 = new db;
+
+ $sql2->db_Insert('user', array('user_name'=>$nickname, 'user_loginname'=>$username, 'user_password'=>$password, 'user_login'=>Get_Facebook_Info('name'), 'user_image'=>Get_Facebook_Info('pic')));
+ $sql3 = new db;
+ $sql3->db_Insert('user_extended', array('user_extended_id'=>last_user(), 'user_facebookID'=>is_fb()));
+
+ Add_Facebook_Connect_User('', last_user());
+
+ set_cookies(last_user(), md5($password));
+
+ header('Location:'.e_SELF);
+ }
}
-function UEID () {
-
- global $sql;
-
- $sql->db_Select ( "user_extended", "user_facebookID", "user_extended_id = '".USERID."' " ) ;
-
- $row = $sql->db_Fetch() ;
-
- return $row[ 'user_facebookID' ];
+function UEID()
+{
+
+ global $sql;
+
+ $sql->db_Select("user_extended", "user_facebookID", "user_extended_id = '".USERID."' ");
+
+ $row = $sql->db_Fetch();
+
+ return $row['user_facebookID'];
}
/**
@@ -310,241 +290,231 @@ function UEID () {
*
*/
-function Fb_LogOut() {
-
- //$uid = UEID() ? UEID() : is_fb();
-
- global $sql;
- if ( $sql->db_Select ( "facebook", "*", "facebook_connected = '1' AND facebook_user_id = '".USERID."' " ) ) {
- $row = $sql->db_Fetch();
- extract($row);
-
- $sql2 = new db;
- $sql2->db_Update ( "facebook", "facebook_connected = '0' WHERE facebook_uid = '". $facebook_uid ."' " ) ;
- header ( 'Location: ' . e_SELF ) ;
- }
+function Fb_LogOut()
+{
+
+ //$uid = UEID() ? UEID() : is_fb();
+
+ global $sql;
+ if ($sql->db_Select("facebook", "*", "facebook_connected = '1' AND facebook_user_id = '".USERID."' "))
+ {
+ $row = $sql->db_Fetch();
+ extract($row);
+
+ $sql2 = new db;
+ $sql2->db_Update("facebook", "facebook_connected = '0' WHERE facebook_uid = '".$facebook_uid."' ");
+ header('Location: '.e_SELF);
+ }
}
/**
* Re-Login in e107 without request new Facebook session!
*
*/
-
-function Fb_LogIn() {
- $sql = new db;
- $sql2 = new db;
- if ( $sql->db_Update ( "facebook", "facebook_connected = '1' WHERE facebook_uid = '".is_fb() ."' " ) ) {
-
- Log_In_Registered_User();
-
- } else if ( $sql2->db_Select ( "user_extended", "*", "user_facebookID = '".is_fb() ."' " ) ) {
- $row2 = $sql2->db_Fetch();
- extract($row2);
-
- Add_Facebook_Connect_User( '' , $user_extended_id );
-
- Log_In_Registered_User();
-
- } else {
-
- Fb_Connect_Me();
-
- }
-
- header ( 'Location: ' . e_SELF ) ;
+function Fb_LogIn()
+{
+ $sql = new db;
+ $sql2 = new db;
+ if ($sql->db_Update("facebook", "facebook_connected = '1' WHERE facebook_uid = '".is_fb()."' "))
+ {
+
+ Log_In_Registered_User();
+
+ }
+ else if ($sql2->db_Select("user_extended", "*", "user_facebookID = '".is_fb()."' "))
+ {
+ $row2 = $sql2->db_Fetch();
+ extract($row2);
+
+ Add_Facebook_Connect_User('', $user_extended_id);
+
+ Log_In_Registered_User();
+
+ }
+ else
+ {
+
+ Fb_Connect_Me();
+
+ }
+
+ header('Location: '.e_SELF);
}
-
/**
* check for e107 connection status: 1 = logged In , 0 = logged Out
*
*/
-
-function your_facebook_is() {
- $uid = is_fb();
- return ( $uid ) ?
- 'your facebook id is: '. $uid .''
- :'';
+function your_facebook_is()
+{
+ $uid = is_fb();
+ return ($uid) ? 'your facebook id is: '.$uid.'' : '';
}
-function Get_Connection_Status() {
- $sql = new db;
- $sql2 = new db;
-
- if ( ( $sql->db_Select ( "facebook", "*", "facebook_uid = '".is_fb() ."' " ) ) ||
-
- ( $sql2->db_Select ( "user_extended", "*", "user_facebookID = '".is_fb() ."' " ) )
-
-
- ) {
- $row = $sql->db_Fetch() ;
- return $row[ 'facebook_connected' ] ? $row[ 'facebook_connected' ] : '0';
-
- } else {
-
- return '';
-
- }
+function Get_Connection_Status()
+{
+ $sql = new db;
+ $sql2 = new db;
+
+ if (($sql->db_Select("facebook", "*", "facebook_uid = '".is_fb()."' ")) ||
+ ($sql2->db_Select("user_extended", "*", "user_facebookID = '".is_fb()."' "))
+ )
+ {
+ $row = $sql->db_Fetch();
+ return $row['facebook_connected'] ? $row['facebook_connected'] : '0';
+
+ }
+ else
+ {
+
+ return '';
+
+ }
}
/**
* Ensure e107 and Facebook Are well linked!
*
*/
-
-function Facebook_User_Is_Connected() {
- global $sql;
-
- if ( $sql->db_select("user_extended", "*", "user_extended_id = '".get_id_from_uid ( is_fb() )."' AND user_facebookID = '".is_fb()."' ") ) {
-
- return true;
-
- } else {
-
- return false;
-
- }
-
+function Facebook_User_Is_Connected()
+{
+ global $sql;
+
+ if ($sql->db_select("user_extended", "*", "user_extended_id = '".get_id_from_uid(is_fb())."' AND user_facebookID = '".is_fb()."' "))
+ {
+ return true;
+
+ }
+ else
+ {
+ return false;
+ }
}
/**
* Log out from Facebook by JS
*
*/
+function Facebook_LogOut()
+{
+
+ if (is_fb())
+ {
+ onloadRegister('facebook_log_out(); ');
+
+ Fb_LogOut();
+ }
- function Facebook_LogOut() {
+}
- if ( is_fb () ) {
- onloadRegister ( 'facebook_log_out(); ' );
+/**
+ *
+ *
+ */
+function Delete_Duplicate_Facebook_User()
+{
+ $sql = e107::getDb();
+ $id = get_id_from_uid(is_fb());
+
+ $sql->db_Delete("user_extended", "user_extended_id='".$id."'");
+ $sql->db_Delete("facebook", "facebook_uid='".is_fb()."'");
+ $sql->db_Delete("user", "user_loginname='FacebookUser_".is_fb()."'");
- Fb_LogOut();
- }
+}
- }
-
-
-
- /**
- *
- *
- *
- *
- */
-
-
- function Delete_Duplicate_Facebook_User() {
-
- $id = get_id_from_uid ( is_fb() );
-
- $sql1->db_Delete("user_extended", "user_extended_id='".$id."'");
- $sql2->db_Delete("facebook", "facebook_uid='".is_fb()."'");
- $sql3->db_Delete("user", "user_loginname='FacebookUser_".is_fb()."'");
-
-
- }
-
- function Switch_Facebook_User() {
-
- $sql1 = new db;
- $sql2 = new db;
- $sql3 = new db;
- $sql4 = new db;
-
- if ( !$sql1->db_Insert ( 'user_extended',
- array (
- 'user_extended_id' => USERID ,
- 'user_facebookID' => is_fb()
- ))) {
-
- $sql2->db_Update ( "user_extended", "user_facebookID = '".is_fb()."' WHERE user_extended_id = '". USERID ."' " ) ;
-
- }
-
- $id = get_id_from_uid ( is_fb() );
-
- $sql3->db_Update ( "user_extended", "user_facebookID = '' WHERE user_extended_id = '". $id ."' " );
- $sql4->db_Update ( "facebook", "facebook_user_id = '".USERID."' WHERE facebook_uid = '". is_fb() ."' " );
- }
-
+function Switch_Facebook_User()
+{
+
+ $sql1 = new db;
+ $sql2 = new db;
+ $sql3 = new db;
+ $sql4 = new db;
+
+ if (!$sql1->db_Insert('user_extended', array('user_extended_id'=>USERID, 'user_facebookID'=>is_fb())))
+ {
+
+ $sql2->db_Update("user_extended", "user_facebookID = '".is_fb()."' WHERE user_extended_id = '".USERID."' ");
+
+ }
+
+ $id = get_id_from_uid(is_fb());
+
+ $sql3->db_Update("user_extended", "user_facebookID = '' WHERE user_extended_id = '".$id."' ");
+ $sql4->db_Update("facebook", "facebook_user_id = '".USERID."' WHERE facebook_uid = '".is_fb()."' ");
+}
/**
* check for Facebook presence and validation
*
*/
-
-
- function single_uid(){
-
- $sql = new db;
-
-
- $count = $sql->db_Count("user_extended", "(*)",
- "WHERE user_facebookID = '".is_fb()."'");
- return $count;
+function single_uid()
+{
+ $sql = e107::getDb();
+
+ $count = $sql->db_Count("user_extended", "(*)", "WHERE user_facebookID = '".is_fb()."'");
+ return $count;
}
-
-
-
-function uid_check() {
-
- $sql = new db;
- $sql2 = new db;
- $sql3 = new db;
- $sql4 = new db;
- $sql5 = new db;
- $sql6 = new db;
-
- $msg = "";
-
- if ( $sql->db_select ( "user_extended", "*","user_facebookID = '".is_fb()."' AND user_extended_id !='".USERID."'" ) ) {
-
-
- // header ( 'Location: ' . e_SELF ) ;
-
- $msg .= "";
- $msg .= "";
-
- } else if ( $sql->db_select ( "user_extended", "*", "user_facebookID != '".is_fb()."' ") ) {
-
-
- $msg = " " . your_facebook_is() . "
";
-
- } else if ( $sql->db_select ( "user_extended", "*", "user_facebookID = '' ") ) {
-
-
-
- $msg = "" . your_facebook_is() . "
";
-
- } else {
-
- $msg = '
+function uid_check()
+{
+ $sql = e107::getDb();
+ $sql = new db;
+ $sql2 = new db;
+ $sql3 = new db;
+ $sql4 = new db;
+ $sql5 = new db;
+ $sql6 = new db;
+
+ $msg = "";
+
+ if ($sql->db_select("user_extended", "*", "user_facebookID = '".is_fb()."' AND user_extended_id !='".USERID."'"))
+ {
+
+ // header ( 'Location: ' . e_SELF ) ;
+
+ $msg .= "";
+ $msg .= "";
+
+ }
+ else if ($sql->db_select("user_extended", "*", "user_facebookID != '".is_fb()."' "))
+ {
+
+ $msg = " ".your_facebook_is()."
";
+
+ }
+ else if ($sql->db_select("user_extended", "*", "user_facebookID = '' "))
+ {
+
+ $msg = "".your_facebook_is()."
";
+
+ }
+ else
+ {
+
+ $msg = '
';
-
- }
-
- return $msg;
+
+ }
+
+ return $msg;
}
-function uid_exists() {
-
- global $sql;
-
- if( $sql->db_select ( "user_extended", "*","user_extended_id = '".USERID."' AND user_facebookID = '".is_fb()."'") ) {
-
- $row = $sql->db_Fetch() ;
-
- return $row[ 'user_extended_id' ];
-
- } else {
-
- return null;
-
- }
-
+function uid_exists()
+{
+ $sql = e107::getDb();
+
+ if ($sql->db_select("user_extended", "*", "user_extended_id = '".USERID."' AND user_facebookID = '".is_fb()."'"))
+ {
+ $row = $sql->db_Fetch();
+ return $row['user_extended_id'];
+ }
+ else
+ {
+ return null;
+ }
}
/**
@@ -552,107 +522,98 @@ function uid_exists() {
*
*/
-function fb_icon() {
- return "
";
+function fb_icon()
+{
+ return "
";
}
-
/**
* get profile picture by requesting it to Facebook; but we can use also the infos stored in facebook table!
*
*/
-function getProfilePic ( $uid, $show_logo = false ) {
- return ( $uid ) ? ( '' )
- :'
';
+function getProfilePic($uid, $show_logo = false)
+{
+ return ($uid) ? ('') : '
';
}
-
/**
* get USERID by knowing his Facebook ID
*
*/
-function get_id_from_uid ( $uid ) {
-
- global $sql;
-
- $sql->db_Select( "facebook", "*", "facebook_uid = '$uid' " ) ;
-
- $row = $sql->db_Fetch() ;
-
- return $row[ 'facebook_user_id' ];
+function get_id_from_uid($uid)
+{
+ $sql = e107::getDb();
+
+ $sql->db_Select("facebook", "*", "facebook_uid = '$uid' ");
+
+ $row = $sql->db_Fetch();
+
+ return $row['facebook_user_id'];
}
-
-function render_facebook_init_js ( $uid ) {
-
- global $pref, $sql;
-
- $text .=
- '
+function render_facebook_init_js($uid)
+{
+
+ $sql = e107::getDb();
+ $pref = e107::getPlugConfig()->getPref();
+
+ $text .= '
- ';
-
- $text .= onloadRegister ( sprintf ( "facebook_onload(%s);", ( $uid ) ? "true" : "false" ) ) ;
-
- return $text;
+ ';
+
+ $text .= onloadRegister(sprintf("facebook_onload(%s);", ($uid) ? "true" : "false"));
+
+ return $text;
}
-
-
-
-
- /*
+/**
* Render a custom button to log in via Facebook.
* When the button is clicked, the Facebook JS library pops up a Connect dialog
* to authenticate the user.
* If the user authenticates the application, the handler specified by the
* onlogin attribute will be triggered.
*
- * @param $size size of the button. one of ( 'small', 'medium', 'large' )
+ * @param $size size of the button. one of ( 'small', 'medium', 'large' )
* http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_light_medium_long.gif
*/
-function Render_Facebook_Connect_Button ( $size = 'medium' ) {
-
-if ( !is_fb() ) {
-
- /* return '
';*/
-
- return '';
-
+function Render_Facebook_Connect_Button($size = 'medium')
+{
+
+ if (!is_fb())
+ {
+ /* return '
';*/
+
+ return '';
+
+ }
}
-}
-
/**
* Render pseudo Facebook button when USER logOut from e107
*
*/
-function Render_Fcuk_Facebook_Connect_Button() {
-
- return '
+function Render_Fcuk_Facebook_Connect_Button()
+{
+ return '
+ Welcome '.Get_Facebook_Info('name').' !
Click below to Login
- Welcome '.Get_Facebook_Info ( 'name' ).' !
Click below to Login
-
-
-
+
+
';
}
-function register_feed_form_js() {
-
- onloadRegister ( "facebook_publish_feed_story('".getStreamToPublish()."');" );
-
+function register_feed_form_js()
+{
+ onloadRegister("facebook_publish_feed_story('".getStreamToPublish()."');");
}
/*
@@ -660,9 +621,10 @@ function register_feed_form_js() {
* it wants to actually refresh it, so we want to prevent the browser from
* caching them.
*/
-function prevent_cache_headers() {
- header ( 'Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0' ) ;
- header ( 'Pragma: no-cache' ) ;
+function prevent_cache_headers()
+{
+ header('Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: no-cache');
}
/*
@@ -670,28 +632,32 @@ function prevent_cache_headers() {
*
* This is printed in render_footer() , so make sure to include that on all pages.
*/
-function onloadRegister ( $js ) {
- global $onload_js;
- $onload_js .= $js;
+function onloadRegister($js)
+{
+ global $onload_js;
+ $onload_js .= $js;
}
-
/**
* expire Facebook session = logOut
* not used yet!
*/
-function fb_expire_session() {
- try {
-
- $fbclient = & facebook_client() ;
- if ( $fbclient && $fbclient->get_loggedin_user() != "" ) {
- $fbclient->expire_session() ;
- }
- } catch ( Exception $e )
- {
- //nothing, probably an expired session
- }
+function fb_expire_session()
+{
+ try
+ {
+
+ $fbclient = &facebook_client();
+ if ($fbclient && $fbclient->get_loggedin_user() != "")
+ {
+ $fbclient->expire_session();
+ }
+ }
+ catch (Exception $e)
+ {
+ //nothing, probably an expired session
+ }
}
/**
@@ -699,10 +665,9 @@ function fb_expire_session() {
*
*/
-function Get_Fecebook_Status ( $uid ) {
- return ( $uid ) ?
- ''
- :'';
+function Get_Fecebook_Status($uid)
+{
+ return ($uid) ? '' : '';
}
/**
@@ -710,63 +675,57 @@ function Get_Fecebook_Status ( $uid ) {
*
*/
-
-function Render_Invite_Friends_Link() {
- return ' → Invite them to Connect. ';
+function Render_Invite_Friends_Link()
+{
+ return ' → Invite them to Connect. ';
}
-
-
-function Render_Fun_Box ( $stream , $connections , $width ) {
-
- global $pref;
-
- return '';
-
+function Render_Fun_Box($stream, $connections, $width)
+{
+ $pref = e107::getPlugConfig()->getPref();
+ return '';
}
-
-
-
-
/**
* Render all Facebook User Friends
*
*/
-
-function Render_Facebook_Friends_Table() {
-
- $friends = facebook_client()->api_client->friends_get();
-
- $n = ( count($friends) * 60 / 2 );
-
- if ( $n > 300 ) {
-
- $n = 300;
-
- }
-
- if ( is_array ( $friends ) && !empty ( $friends ) ) {
-
- $html .= '';
-
- foreach ( $friends as $friend ) {
-
- if ( $friend ) {
-
-
- $html .= '
' . getProfilePic ( $friend ) . '
';
-
- }
- }
-
- $html .= '
';
- return $html;
- } else {
- return '';
- }
+function Render_Facebook_Friends_Table()
+{
+
+ $friends = facebook_client()->api_client->friends_get();
+
+ $n = (count($friends) * 60 / 2);
+
+ if ($n > 300)
+ {
+
+ $n = 300;
+
+ }
+
+ if (is_array($friends) && ! empty($friends))
+ {
+
+ $html .= '';
+
+ foreach ($friends as $friend)
+ {
+
+ if ($friend)
+ {
+ $html .= '
'.getProfilePic($friend).'
';
+ }
+ }
+
+ $html .= '
';
+ return $html;
+ }
+ else
+ {
+ return '';
+ }
}
/**
@@ -774,43 +733,44 @@ function Render_Facebook_Friends_Table() {
*
*/
-
-function Render_Connect_Invite_Friends() {
- //$friends = facebook_client()->api_client->friends_get() ;
- //$has_existing_friends = count ( $friends ) ;
- //$more = $has_existing_friends?' more':'';
- $num = '';
-
- if ( $num > 0 ) {
- //$one_friend_text = 'You have one' . $more . ' Facebook friend that also join on ' . SITENAME;
- //$multiple_friends_text = 'You have ' . $num.$more . ' Facebook friends that also join on ' . SITENAME;
- //$invite_link = 'Invite them to Connect.';
-
- //$html = '';
- $html .= '';
-
- $html .= '';
- $html .= '';
- $html .= 'Invite them to Connect.';
- $html .= '';
- return $html;
-
- }
+function Render_Connect_Invite_Friends()
+{
+ //$friends = facebook_client()->api_client->friends_get() ;
+ //$has_existing_friends = count ( $friends ) ;
+ //$more = $has_existing_friends?' more':'';
+ $num = '';
+
+ if ($num > 0)
+ {
+ //$one_friend_text = 'You have one' . $more . ' Facebook friend that also join on ' . SITENAME;
+ //$multiple_friends_text = 'You have ' . $num.$more . ' Facebook friends that also join on ' . SITENAME;
+ //$invite_link = 'Invite them to Connect.';
+
+ //$html = '';
+ $html .= '';
+
+ $html .= '';
+ $html .= '';
+ $html .= 'Invite them to Connect.';
+ $html .= '';
+ return $html;
+
+ }
}
-
/*
* Make the API call to register the feed forms. This is a setup call that only
* needs to be made once.
*
*/
-function register_feed_forms() {
- $one_line_stories = $short_stories = $full_stories = array() ;
-
- $one_line_stories[ ] = '{*actor*} went for a {*distance*} run at {*location*} . ';
-
- $form_id = facebook_client()->api_client->feed_registerTemplateBundle ( $one_line_stories ) ;
- return $form_id;
+function register_feed_forms()
+{
+ $one_line_stories = $short_stories = $full_stories = array();
+
+ $one_line_stories[] = '{*actor*} went for a {*distance*} run at {*location*} . ';
+
+ $form_id = facebook_client()->api_client->feed_registerTemplateBundle($one_line_stories);
+ return $form_id;
}
/**
@@ -818,43 +778,46 @@ function register_feed_forms() {
*
*/
-function username_exists ( $user ) {
-
- $sql = new db;
- if ( $sql->db_Select ( "user", "user_loginname", "user_loginname = '$user' " ) ) {
- $sql2 = new db;
- $count = $sql2->db_Count ( "user", "(*)",
- "WHERE $name LIKE '$user%' " ) ;
- $num = $count+1;
- return username_exists ( $user.$num ) ;
-
- } else {
-
- return $user;
- }
+function username_exists($user)
+{
+ $sql = e107::getDb();
+ $sql = e107::getDb('sql2');
+ if ($sql->db_Select("user", "user_loginname", "user_loginname = '$user' "))
+ {
+ $count = $sql2->db_Count("user", "(*)", "WHERE $name LIKE '$user%' ");
+ $num = $count + 1;
+ return username_exists($user.$num);
+
+ }
+ else
+ {
+
+ return $user;
+ }
}
-
/**
* Set Login cookies
*
*/
-function set_cookies ( $id, $pwd ) {
- global $pref;
- $cockiename = $pref[ 'cookie_name' ]?$pref[ 'cookie_name' ]:'e107cookie';
- $cookieval = $id.".".$pwd;
-
- if ( $pref[ 'user_tracking' ] == 'session' ) {
- $_SESSION[ $cockiename ] = $cookieval;
- } else {
- cookie ( $cockiename, $cookieval, ( time() +3600*24*30 ) ) ;
-
-
- }
-
- return $_SESSION[ $cockiename ];
+function set_cookies($id, $pwd)
+{
+ global $pref;
+ $cockiename = $pref['cookie_name'] ? $pref['cookie_name'] : 'e107cookie';
+ $cookieval = $id.".".$pwd;
+
+ if ($pref['user_tracking'] == 'session')
+ {
+ $_SESSION[$cockiename] = $cookieval;
+ }
+ else
+ {
+ cookie($cockiename, $cookieval, (time() + 3600 * 24 * 30));
+ }
+
+ return $_SESSION[$cockiename];
}
/**
@@ -862,35 +825,34 @@ function set_cookies ( $id, $pwd ) {
* not used yet!
*/
-function get_info ( $info , $uid ) {
-
- $sql = new db;
-
- if ( $sql->db_select ( "user", "*", "user_id = '$uid'" ) ) {
-
- $row = $sql->db_Fetch();
-
- extract ( $row ) ;
-
- return $row[ $info ];
-
- } else {
-
- return false;
-
- }
+function get_info($info, $uid)
+{
+ $sql = e107::getDb();
+
+ if ($sql->db_select("user", "*", "user_id = '$uid'"))
+ {
+ $row = $sql->db_Fetch();
+ extract($row);
+ return $row[$info];
+ }
+ else
+ {
+ return false;
+ }
}
-function Log_In_Registered_User(){
-if ( !USER ) {
-
- $uid = get_id_from_uid ( is_fb() );
-
- set_cookies ( get_info( 'user_id' , $uid ), md5 ( get_info( 'user_password' , $uid) ) ) ;
-
- header ( 'Location:' . e_SELF ) ;
-
-}
+function Log_In_Registered_User()
+{
+ if (!USER)
+ {
+
+ $uid = get_id_from_uid(is_fb());
+
+ set_cookies(get_info('user_id', $uid), md5(get_info('user_password', $uid)));
+
+ header('Location:'.e_SELF);
+
+ }
}
/**
@@ -898,9 +860,10 @@ if ( !USER ) {
*
*/
-function last_user() {
- $sql = new db;
- $qry = "SELECT
+function last_user()
+{
+ $sql = new db;
+ $qry = "SELECT
user_id
FROM
#user
@@ -909,7 +872,7 @@ function last_user() {
FROM
#user
) ";
- $sql->db_Select_gen( $qry ) ;
- $row = $sql->db_Fetch() ;
- return $row[ 'user_id' ];
+ $sql->db_Select_gen($qry);
+ $row = $sql->db_Fetch();
+ return $row['user_id'];
}