Package name: SA FBConnect
Package version: 0.1 RC1-2
Package type: modification
Installation instructions for SMF versions: 2.0 - 2.99.99
PHP script to execute: installScript.phpFiles installed
- Themes/default/FB_Connect.template.php will be copied to $themedir
- Themes/default/FB_Connect_admin.template.php will be copied to $themedir
- Themes/default/images/facebook.png will be copied to $imagesdir
Directories installed
- Sources/FB_Connect will be copied to $sourcedir
- fbc will be copied to $boarddir
Modifications to SMF files
In file $languagedir/Modifications.english.php
Add to end of file:
$txt['fb_admin_logs'] = 'Facebook Logs';
$txt['fb_admin_logs_member'] = 'Member';
$txt['fb_admin_logs_memberid'] = 'Member ID';
$txt['fb_admin_logs_dr'] = 'Date Registerd';
$txt['fb_admin_logs_fuid'] = 'Facebook Userid';
$txt['fb_admin_logs_name'] = 'Facebook Name';
$txt['fb_admin_logs_pro'] = 'Facebook Profile';
$txt['fb_admin_commets_box'] = 'Comments Box Options';
$txt['fb_admin_commets_post'] = 'Number Comments To Show In comments box';
$txt['fb_app_comments_boxid'] = 'Your Comments Box XIDThe unique identifier for this set of comments. Comments can contain alphanumeric characters (Aa-Zz, 0-9), hyphens (-), percent (%), period (.), and underscores (_) (in effect, the result of any urlencode can be a valid XID).';
$txt['fb_admin_setsh1'] = 'Enable Topics to be Shared on Facebook from this board';
$txt['fb_admin_setsh2'] = 'enableing this will show a share topic icon for facebook';
$txt['fb_admin_set1'] = 'Main Options';
$txt['fb_admin_set2'] = 'Fan Page Options';
$txt['fb_admin_set3'] = 'Api Key and Secret';
$txt['fb_app_facebook_log_out'] = 'enable Facebook logout featurewill logout the user from facebook upon loggong out from site';
$txt['fb_app_width'] = 'Fan box width';
$txt['fb_app_key'] = 'Facebook Application Key';
$txt['fb_app_sharetopic'] = 'Enable share topic feature';
$txt['fb_app_fans'] = 'Enable Fan Page';
$txt['fb_enable_fb_com'] = 'Enable facebook Comments System';
$txt['fb_app_connection'] = 'Fans to show';
$txt['fb_app_pageid'] = 'Your applications page idcan be found in you applications url';
$txt['fb_app_stream'] = 'Fan displayset To 0 To to show just fans or 1 to show stream and fans';
$txt['fb_app_secret'] = 'Facebook Application Secret';
$txt['fb_integrate'] = 'Integrate forum account with Facebook.';
$txt['fb_update'] = 'Update Your Facebook status.';
$txt['fb_admin'] = 'SA Facebook Connect';
$txt['fb_admin_main'] = 'Main Settings';
$txt['fb_enable'] = 'Enable Facebook Connect Mod';
$txt['fb_enable_wt_mod'] = 'Enable Support For VBGamers Welcome Topic Mod';
$txt['fb_invite'] = 'Invite Freinds To Join';
$txt['fb_title'] = 'Facebook Connect';
$txt['fb_title1'] = 'You are successfully connected with facebook!';
$txt['fb_title2'] = 'Here are some things you can do with Facebook Connect';
$txt['fb_title3'] = 'You Are not Connected With Facebook!';
$txt['fb_title_inv'] = 'Facebook Invite';
$txt['fb_inv'] = 'This is a invitation from';
$txt['fb_inv_app'] = 'application';
$txt['fb_inv1'] = 'Go to A';
$txt['fb_inv2'] = 'Page!';
$txt['fb_inv3'] = 'Invite your friends to use';
$txt['fb_inv4'] = 'Thank you for inviting';
$txt['fb_inv5'] = 'of your friends on';
$txt['fb_inv6'] = 'Click here to return to';
$txt['fb_inv7'] = 'has started using';
$txt['fb_inv8'] = 'and thought it\'s so cool even you should try it out!';
$txt['fb_inv9'] = 'Put';
$txt['fb_inv10'] = 'on your profile';
$txt['fb_avatar'] = 'Update your avatar to Your facebook Pic';
$txt['fb_avatar1'] = 'Facebook Avatar';
$txt['fb_avatar2'] = 'your avatar has been changed';
$txt['fb_avatar3'] = 'are you sure you want to update you avatar?';
$txt['fb_yes'] = 'yes';
$txt['fb_no'] = 'no';
$txt['fb_or'] = 'or';
$txt['fb_sync'] = 'Facebook Sync';
$txt['fb_sync1'] = 'Are You sure You Want To sync Your Facebook And Forum Accounts?';
$txt['fb_share'] = 'Share This site On facebook';
$txt['fb_fans'] = 'Fan Page';
$txt['fb_fans1'] = 'Facebook Fan Page';
$txt['fb_haslogged'] = 'has logged in to';
$txt['fb_haslogged2'] = 'using facebook connect';
$txt['fb_reg1'] = 'Facebook Login';
$txt['fb_reg2'] = '(you only need to do this once)';
$txt['fb_reg8'] = 'Display Name';
$txt['fb_reg3'] = 'Go';
$txt['fb_reg4'] = 'Please Enter a User Name';
$txt['fb_reg44'] = 'Required Information';
$txt['fb_reg45'] = 'Additional Information';
$txt['permissiongroup_simple_facebookperm'] = 'Facebook Connect';
$txt['permissiongroup_facebookperm'] = 'Facebook Connect';
$txt['permissionhelp_share_topic'] = 'If the user is allowed to Share Topics on Facebook';
$txt['permissionname_share_topic'] = 'Share Topics on Facebook';
$txt['fbshare_share'] = 'Share Boards';
$txt['fb_custom_profile'] = 'Enable Custom Profile Feilds Support';
In file $languagedir/Modifications.english-utf8.php
Add to end of file:
$txt['fb_admin_logs'] = 'Facebook Logs';
$txt['fb_admin_logs_member'] = 'Member';
$txt['fb_admin_logs_memberid'] = 'Member ID';
$txt['fb_admin_logs_dr'] = 'Date Registerd';
$txt['fb_admin_logs_fuid'] = 'Facebook Userid';
$txt['fb_admin_logs_name'] = 'Facebook Name';
$txt['fb_admin_logs_pro'] = 'Facebook Profile';
$txt['fb_admin_commets_box'] = 'Comments Box Options';
$txt['fb_admin_commets_post'] = 'Number Comments To Show In comments box';
$txt['fb_app_comments_boxid'] = 'Your Comments Box XIDThe unique identifier for this set of comments. Comments can contain alphanumeric characters (Aa-Zz, 0-9), hyphens (-), percent (%), period (.), and underscores (_) (in effect, the result of any urlencode can be a valid XID).';
$txt['fb_admin_setsh1'] = 'Enable Topics to be Shared on Facebook from this board';
$txt['fb_admin_setsh2'] = 'enableing this will show a share topic icon for facebook';
$txt['fb_admin_set1'] = 'Main Options';
$txt['fb_admin_set2'] = 'Fan Page Options';
$txt['fb_admin_set3'] = 'Api Key and Secret';
$txt['fb_app_facebook_log_out'] = 'enable Facebook logout featurewill logout the user from facebook upon loggong out from site';
$txt['fb_app_width'] = 'Fan box width';
$txt['fb_app_key'] = 'Facebook Application Key';
$txt['fb_app_sharetopic'] = 'Enable share topic feature';
$txt['fb_app_fans'] = 'Enable Fan Page';
$txt['fb_enable_fb_com'] = 'Enable facebook Comments System';
$txt['fb_app_connection'] = 'Fans to show';
$txt['fb_app_pageid'] = 'Your applications page idcan be found in you applications url';
$txt['fb_app_stream'] = 'Fan displayset To 0 To to show just fans or 1 to show stream and fans';
$txt['fb_app_secret'] = 'Facebook Application Secret';
$txt['fb_integrate'] = 'Integrate forum account with Facebook.';
$txt['fb_update'] = 'Update Your Facebook status.';
$txt['fb_admin'] = 'SA Facebook Connect';
$txt['fb_admin_main'] = 'Main Settings';
$txt['fb_enable'] = 'Enable Facebook Connect Mod';
$txt['fb_enable_wt_mod'] = 'Enable Support For VBGamers Welcome Topic Mod';
$txt['fb_invite'] = 'Invite Freinds To Join';
$txt['fb_title'] = 'Facebook Connect';
$txt['fb_title1'] = 'You are successfully connected with facebook!';
$txt['fb_title2'] = 'Here are some things you can do with Facebook Connect';
$txt['fb_title3'] = 'You Are not Connected With Facebook!';
$txt['fb_title_inv'] = 'Facebook Invite';
$txt['fb_inv'] = 'This is a invitation from';
$txt['fb_inv_app'] = 'application';
$txt['fb_inv1'] = 'Go to A';
$txt['fb_inv2'] = 'Page!';
$txt['fb_inv3'] = 'Invite your friends to use';
$txt['fb_inv4'] = 'Thank you for inviting';
$txt['fb_inv5'] = 'of your friends on';
$txt['fb_inv6'] = 'Click here to return to';
$txt['fb_inv7'] = 'has started using';
$txt['fb_inv8'] = 'and thought it\'s so cool even you should try it out!';
$txt['fb_inv9'] = 'Put';
$txt['fb_inv10'] = 'on your profile';
$txt['fb_avatar'] = 'Update your avatar to Your facebook Pic';
$txt['fb_avatar1'] = 'Facebook Avatar';
$txt['fb_avatar2'] = 'your avatar has been changed';
$txt['fb_avatar3'] = 'are you sure you want to update you avatar?';
$txt['fb_yes'] = 'yes';
$txt['fb_no'] = 'no';
$txt['fb_or'] = 'or';
$txt['fb_sync'] = 'Facebook Sync';
$txt['fb_sync1'] = 'Are You sure You Want To sync Your Facebook And Forum Accounts?';
$txt['fb_share'] = 'Share This site On facebook';
$txt['fb_fans'] = 'Fan Page';
$txt['fb_fans1'] = 'Facebook Fan Page';
$txt['fb_haslogged'] = 'has logged in to';
$txt['fb_haslogged2'] = 'using facebook connect';
$txt['fb_reg1'] = 'Facebook Login';
$txt['fb_reg2'] = '(you only need to do this once)';
$txt['fb_reg8'] = 'Display Name';
$txt['fb_reg3'] = 'Go';
$txt['fb_reg4'] = 'Please Enter a User Name';
$txt['fb_reg44'] = 'Required Information';
$txt['fb_reg45'] = 'Additional Information';
$txt['permissiongroup_simple_facebookperm'] = 'Facebook Connect';
$txt['permissiongroup_facebookperm'] = 'Facebook Connect';
$txt['permissionhelp_share_topic'] = 'If the user is allowed to Share Topics on Facebook';
$txt['permissionname_share_topic'] = 'Share Topics on Facebook';
$txt['fbshare_share'] = 'Share Boards';
$txt['fb_custom_profile'] = 'Enable Custom Profile Feilds Support';
In file $sourcedir/ManagePermissions.php
Find:$groupLevels['global']['standard'] = array_merge($groupLevels['global']['restrict'], array(
Add after:
'share_topic',
Find:
$permissionList = array(
'membergroup' => array(
Add after:
'share_topic' => array(false, 'facebookperm', 'facebookperm'),
Find:
'simple' => array(
'view_basic_info',
Add after:
'facebookperm',
Find:
'classic' => array(
'general',
Add after:
'facebookperm',
In file $themedir/Login.template.php
Find:"submit" value="', $txt['login'], '" class="button_submit" />
Add after:
';
echo'';show_facebook();echo'
';
echo'
In file $themedir/ManageBoards.template.php
Find:"checkbox" id="redirect_enable" name="redirect_enable"', $context['board']['topics'] ? ' disabled="disabled"' : '', $context['board']['redirect'] != '' ? ' checked="checked"' : '', ' onclick="refreshOptions();" class="input_check" />
';
Add after:
echo '
';
In file $themedir/Display.template.php
Find:echo '
';
Add after:
';
$allowed_share_topic = allowedTo('share_topic');
if($modSettings['fb_app_sharetopic'] && $allowed_share_topic)
{
foreach ($context['fbshare_boards'] as $board)
if($board['fbshare_enable'] == 1)
echo'
"share">
';
}
echo'
In file $sourcedir/ManageBoards.php
Find:$boardOptions['posts_count'] = isset($_POST['count']);
Add after:
$boardOptions['fbshare_enable'] = isset($_POST['fbshare_enable']);
In file $sourcedir/Subs-Boards.php
Find:// This setting is a little twisted in the database...
if (isset($boardOptions['posts_count']))
{
$boardUpdates[] = 'count_posts = {int:count_posts}';
$boardUpdateParameters['count_posts'] = $boardOptions['posts_count'] ? 0 : 1;
}
Add after:
if (isset($boardOptions['fbshare_enable']))
{
$boardUpdates[] = 'fbshare_enable = {int:fbshare_enable}';
$boardUpdateParameters['fbshare_enable'] = $boardOptions['fbshare_enable'] ? 0 : 1;
}
Find:b.num_posts, b.num_topics, c.id_cat, c.name AS cat_name, c.cat_order, c.can_collapse
Add after:
, b.fbshare_enable
Find:'profile' => $row['id_profile'],
Add after:
'fbshare_enable' => $row['fbshare_enable'],
In file $sourcedir/PortaMx/Class/user_login.php
Find:"float:'.$R_L.';margin-'.$R_L.':4px;" type="submit" value="'. $txt['login'] .'" />
"clear:both;" />'. $txt['quick_login_dec'] .'
}
Add after:
show_facebook();
Find:
}
Add after:
echo'' ;show_facebook();echo'';
In file $sourcedir/PortalBlocks.php
Find:', sprintf($txt['welcome_guest'], $txt['guest_title']);
Add after:
show_facebook();
Find:
echo '
', sp_embed_image('arrow'), ' , $scripturl, '?action=profile">', $txt['profile'], ' ', sp_embed_image('arrow'), ' , $scripturl, '?action=logout;sesc=', $context['session_id'], '">', $txt['logout'], '';
Add before:
show_facebook();
In file $sourcedir/Subs-EzPortalMain2.php
Find:// Avatar
if (!empty($context['user']['avatar']))
echo $context['user']['avatar']['image'], '
';
Add before:
show_facebook();
Find:
"submit" value="', $txt['ezp_built_login'], '" />
Add after:
';
show_facebook();
echo'
In file $sourcedir/Display.php
Find:redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
}
Add after:
function fbshare_boards()
{
global $topic, $board, $smcFunc, $context;
$req = $smcFunc['db_query']('', '
SELECT
t.id_topic, t.id_board, b.id_board, b.fbshare_enable
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards b ON t.id_board = b.id_board
WHERE fbshare_enable = {int:one} AND t.id_topic = {int:current_topic}',
array(
'one' => 1,
'current_topic' => $topic,
)
);
$cats = array();
$context['fbshare_boards'] = array();
while ($row = $smcFunc['db_fetch_assoc']($req))
{
$context['fbshare_boards'][] = array(
'fbshare_enable' => $row['fbshare_enable'],
'id_topic' => $row['id_topic'],
);
}
}
Find:
// What are you gonna display if these are empty?!
if (empty($topic))
fatal_lang_error('no_board', false);
Add before:
fbshare_boards();
In file $themedir/css/index.css
Find:#forumposts h3 span#author, #forumposts h3 span#top_subject
{
float: left;
}
Add before:
#forumposts h3 span#facebook
{
float: right;
margin: 6px 0.5em 0 0;
}
In file $boarddir/index.php
Find:'xmlhttp' => array('Xml.php', 'XMLhttpMain'),
Add after:
'facebook' => array('FB_Connect/FB_Connect.php', 'FB_Connect'),
Find:
call_user_func(smf_main());
Add after:
loadFbc();
In file $sourcedir/Subs.php
Find:'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
Replace with:
'logout2' => array(
'title' => $txt['logout'],
'href' => '#" onclick="doLoggedOutFacebookUser();"',
'show' => !$user_info['is_guest'] && !empty($modSettings['fb_app_facebook_log_out']),
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'] && empty($modSettings['fb_app_facebook_log_out']),
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
In file $sourcedir/Admin.php
Find:'languages' => array(
'label' => $txt['language_configuration'],
Add before:
'fb' => array(
'label' => $txt['fb_admin'],
'file' => 'FB_Connect/Facebook_connect_admin.php',
'function' => 'conAdmin',
// 'icon' => 'modifications.gif',
'subsections' => array(
'settingsa' => array($txt['fb_admin_main']),
'fbshare' => array($txt['fbshare_share'], 'enabled' => !empty($modSettings['fb_app_sharetopic'])),
'fblogs' => array($txt['fb_admin_logs']),
),
),
In file $sourcedir/Subs-Members.php
Find:// Delete the member.
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}members
WHERE id_member IN ({array_int:users})',
array(
'users' => $users,
)
);
Add after:
// Delete Facebook sync.
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}facebook_sync
WHERE id_member IN ({array_int:users})',
array(
'users' => $users,
)
);
In file $sourcedir/Profile.php
Find:$check_password = $context['user']['is_owner'] && in_array($profile_include_data['current_area'], $context['password_areas']);
Do something with this: (position not specified)
loadFbc();
$check_password = $context['user']['is_owner'] && !isset($context['user']['fb']) && in_array($profile_include_data['current_area'], $context['password_areas']);
In file $sourcedir/Load.php
Add to end of file:
function loadFbc() {
global $context, $smcFunc, $modSettings;
$request = $smcFunc['db_query']('', "
SELECT id_member
FROM {db_prefix}facebook_sync
WHERE id_member = {int:uid}
LIMIT 1",
array(
'uid' => $context['user']['id'],
)
);
while($result = $smcFunc['db_fetch_assoc']($request)) {
$context['user']['fb'] = $result['id_member'];
}
$smcFunc['db_free_result']($request);
if(!empty($result))
$context['user']['fb'] = $result;
}
In file $themedir/index.template.php
Find:function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
Replace with:
function template_html_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings, $boardurl;
Find:
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
Replace with:
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
"http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" ', $context['right_to_left'] ? ' dir="rtl"' : '', '>
Find:
// Output any remaining HTML headers. (from mods, maybe?)
echo $context['html_headers'];
Add before:
echo'
';
Find:
';
Add after:
echo'';
Find:
function template_body_above()
Add before:
function show_facebook()
{
global $boardurl, $settings, $context, $txt, $modSettings, $scripturl;
if($modSettings['fb_enable'])
{
if ($context['user']['is_logged'])
{
if(isset($context['user']['fb'])) {
echo '. $settings['images_url'] . '/facebook.png" alt="'.$txt['fb_title'].'" /> '.$txt['fb_title'].'';
}
else {
echo '. $settings['images_url'] . '/facebook.png" alt="'.$txt['fb_title'].'" /> '.$txt['fb_integrate'].'';
}
echo'
';
}
else
{
echo'';
}
}
}
Find:
if (!empty($modSettings['enableOpenID']))
echo'
';
echo '
';
Add after:
show_facebook();
Find:
function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
Replace with:
function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $sc, $modSettings, $boarddir, $boardurl;
echo'';
if(isset($_GET['fb_feed']))
{
include_once $boarddir.'/fbc/facebook/php/facebook.php';
$api_key = ''.$modSettings['fb_app_key'].'';
$secret = ''.$modSettings['fb_app_secret'].'';
$fb = new Facebook($api_key,$secret);
$fb_user = $fb->get_loggedin_user();
$user_id = $fb->require_login();
$user_details = $fb->api_client->users_getInfo($fb_user, array('first_name','last_name'));
$firstName = $user_details[0]['first_name'];
$lastName = $user_details[0]['last_name'];
$name = ''.$firstName.' '.$lastName.'';
echo'';
}
Find:
if (!empty($context['user']['avatar']))
echo '
'
, $context['user']['avatar']['image'], '';
Add before:
show_facebook();