summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.txt26
-rw-r--r--contrib/fb_friend.install2
-rw-r--r--contrib/fb_test.module21
-rw-r--r--fb.admin.inc20
-rw-r--r--fb.js26
-rw-r--r--fb.module39
-rw-r--r--fb_app.admin.inc28
-rw-r--r--fb_app.install4
-rw-r--r--fb_app.module13
-rw-r--r--fb_connect.module6
-rw-r--r--fb_devel.module17
-rw-r--r--fb_tab.admin.inc31
-rw-r--r--fb_tab.module42
13 files changed, 138 insertions, 137 deletions
diff --git a/README.txt b/README.txt
index 156065f..924a7d9 100644
--- a/README.txt
+++ b/README.txt
@@ -23,14 +23,15 @@ To upgrade from on D7 version to the next:
To install:
-- Make sure you have an up-to-date PHP client from facebook.
+- Make sure you have a PHP client from facebook (version < 3.0.0).
+ The 3.0.0 or higher versions are not supported by this version of Drupal for Facebook.
Download from http://github.com/facebook/php-sdk.
Extract the files, and place them in sites/all/libraries/facebook-php-sdk.
If you have the Libraries API module installed, you may place the files in
another recognised location (such as sites/all/libraries), providing that the
directory is named 'facebook-php-sdk'.
-
+
Or, to manually set the location of the php-sdk in any other directory, edit
your settings.php to include a line similar to this (add to the section where
the $conf variable is defined, or the very end of settings.php. And
@@ -40,16 +41,6 @@ To install:
See also http://drupal.org/node/923804
-- Your theme needs the following attribute at the end of the <html> tag:
-
- xmlns:fb="http://www.facebook.com/2008/fbml"
-
- Typically, this means copying the html.tpl.php file from /modules/system into the
- templates folder of your theme and modifying it. More detail can be found at
- http://www.drupalforfacebook.org/node/1106. Note this
- applies to themes used for Facebook Connect, iframe Canvas Pages, and Social
- Plugins (i.e. like buttons). Without this attribute, IE will fail.
-
- To support canvas pages and/or page tabs, url rewriting and other
settings must be initialized before modules are loaded, so you must
add this code to your settings.php. This is done by adding these
@@ -122,7 +113,14 @@ Enable the fb_devel.module and add the block it provides (called
fb_devel.module will catch some errors and write useful information to
Drupal's log and status page.
-Disable Global Redirect, if you have that module installed. Users
+Use your browser's view source feature, and search page source for any
+<script> tag which includes facebook's javascript,
+"http://connect.facebook.net/en_US/all.js". fb.js will include this
+for you. Including it too soon will break many features. So remove
+it from any block, node, template or whatever that adds it to the
+page. Similarly, do not include any <div id="fb-root">.
+
+Disable Global Redirect, if you have that module installed. Users
have reported problems with it and Drupal for Facebook. Any module
which implements custom url rewrites could interfere with canvas page
and profile tab support.
@@ -158,7 +156,7 @@ $conf['fb_verbose'] = TRUE; // debug output
// More efficient connect session discovery.
// Required if supporting one connect app and different canvas apps.
-//$conf['fb_apikey'] = '123.....XYZ'; // Your connect app's apikey goes here.
+//$conf['fb_id'] = '123.....XYZ'; // Your connect app's ID goes here.
// Enable URL rewriting (for canvas page apps).
include "sites/all/modules/fb/fb_url_rewrite.inc";
diff --git a/contrib/fb_friend.install b/contrib/fb_friend.install
index 108b765..1b52378 100644
--- a/contrib/fb_friend.install
+++ b/contrib/fb_friend.install
@@ -45,7 +45,7 @@ function fb_friend_schema() {
'type' => 'int',
'not null' => TRUE,
'default' => 0),
- 'label' => array( /* Would it be better to store apikey? */
+ 'label' => array( /* Would it be better to store id? */
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
diff --git a/contrib/fb_test.module b/contrib/fb_test.module
index 0d10455..1eb967b 100644
--- a/contrib/fb_test.module
+++ b/contrib/fb_test.module
@@ -5,6 +5,9 @@
* http://developers.facebook.com/docs/test_users
*/
+/**
+ * Implements hook_menu().
+ */
function fb_test_menu() {
// Admin pages
@@ -26,7 +29,7 @@ function fb_test_detail_page($fb_app) {
return $output;
}
-function fb_test_create_form(&$form, &$form_state, $fb_app) {
+function fb_test_create_form($form, &$form_state, $fb_app) {
$form['#fb_app'] = $fb_app;
// @TODO make this a dropdown, limit to 50 total test accounts.
@@ -44,9 +47,7 @@ function fb_test_create_form(&$form, &$form_state, $fb_app) {
// Which permissions?
$perms = array();
drupal_alter('fb_required_perms', $perms); // @TODO pass fb_app to this function.
- if (count($perms)) {
- $default_perms = implode(',', $perms);
- }
+ $default_perms = count($perms) ? implode(',', $perms) : '';
$form['perms'] = array(
'#type' => 'textfield',
@@ -73,8 +74,16 @@ function fb_test_create_form_submit($form, &$form_state) {
'permissions' => $values['perms'],
'access_token' => fb_get_token($fb),
));
+ dpm($result, __FUNCTION__);
+ if (isset($result['id'])) {
+ drupal_set_message(t("Created user !name. Email: %email | Password: %password", array(
+ '!name' => "<fb:name uid=" . $result['id'] . "></fb:name>",
+ '%email' => $result['email'],
+ '%password' => $result['password'],
+ )));
+ }
}
- drupal_set_message(t('Created %num test accounts.', array('%num' => $values['how_many'])));
+ drupal_set_message(t('Created %num test accounts. Please make note of passwords (they will not be available again).', array('%num' => $values['how_many'])));
}
catch (Exception $e) {
fb_log_exception($e, t('Failed to create test accounts.'));
@@ -99,7 +108,7 @@ function fb_test_accounts_form($form, &$form_state, $fb_app) {
'access_token' => $test_account['access_token'], // Only when account is authorized
));
if ($data['name']) {
- $markup .= " $data[name] <a href=$data[link]>(profile)</a> ";
+ $markup .= " $data[name] (<a href=$data[link]>profile</a> | <a href=https://graph.facebook.com/{$test_account[id]}?access_token={$test_account[access_token]}>graph</a> | <a href=https://graph.facebook.com/{$test_account[id]}?access_token=" . fb_get_token($fb) . ">graph2</a>) ";
}
}
diff --git a/fb.admin.inc b/fb.admin.inc
index df0e034..c937504 100644
--- a/fb.admin.inc
+++ b/fb.admin.inc
@@ -122,7 +122,6 @@ function fb_admin_app_page($fb_app = NULL) {
$props_map = array(
t('Name') => 'name',
t('Label') => 'label',
- t('API Key') => 'apikey',
t('ID') => 'id',
);
$output = "<dl>\n";
@@ -160,20 +159,20 @@ function fb_admin_get_app_properties(&$fb_app) {
$props_map = fb_invoke(FB_ADMIN_OP_LIST_PROPERTIES, array('fb_app' => $fb_app), $props_map, FB_ADMIN_HOOK);
}
- if (!isset($cache[$fb_app->apikey])) {
+ if (!isset($cache[$fb_app->id])) {
if ($fb = fb_api_init($fb_app)) {
try {
$props = fb_call_method($fb, 'admin.getAppProperties', array(
'properties' => implode(',', array_values($props_map)),
));
- $cache[$fb_app->apikey] = $props;
+ $cache[$fb_app->id] = $props;
} catch (Exception $e) {
fb_log_exception($e, t('Failed to get application properties (%label) from Facebook', array('%label' => $fb_app->label)));
}
}
}
else {
- $props = $cache[$fb_app->apikey];
+ $props = $cache[$fb_app->id];
}
// Update $fb_app with the values we got from facebook api.
@@ -196,8 +195,8 @@ function fb_admin_get_app_options($include_current = FALSE, $key = 'label') {
if ($include_current)
$options[FB_APP_CURRENT] = t('<current>');
foreach ($apps as $app) {
- if ($key == 'apikey') {
- $options[$app->apikey] = $app->label;
+ if ($key == 'id') { // Still needed?
+ $options[$app->id] = $app->label;
}
else {
$options[$app->label] = $app->label;
@@ -310,7 +309,7 @@ function fb_admin_settings() {
'#type' => 'checkbox',
'#title' => t('Set FB Cookie'),
'#default_value' => variable_get(FB_VAR_USE_COOKIE, TRUE),
- '#description' => t('Tell Facebook\'s libraries to set a cookie, named fbs_<em>APIKEY</em>, when user connects. Makes facebook applications run smoother, but fails when third-party cookies are denied by user\'s browser.'),
+ '#description' => t('Tell Facebook\'s libraries to set a cookie, named fbs_<em>ID</em>, when user connects. Makes facebook applications run smoother, but fails when third-party cookies are denied by user\'s browser.'),
);
$form['fb_admin_session'][FB_VAR_USE_SESSION] = array(
@@ -320,6 +319,13 @@ function fb_admin_settings() {
'#description' => t('Store tokens and data needed by facebook\'s libraries in Drupal\'s session. Helps applications work even when third-party cookies are denied.'),
);
+ $form['fb_admin_session'][FB_VAR_RELOAD_APPEND_HASH] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Append hash on javascript page reload'),
+ '#default_value' => variable_get(FB_VAR_RELOAD_APPEND_HASH, FALSE),
+ '#description' => t('When fb.js reloads (on session change), append a query parameter which serves two purposes. First, it will break through a cache which may be desireable when facebook session changes. Second, it prevents infinite reloads when third-party cookies are not enabled. Enable this if you encounter either of those problems.'),
+ );
+
$form['fb_admin_languages'] = array(
'#title' => t('Languages and Locales'),
'#type' => 'fieldset',
diff --git a/fb.js b/fb.js
index a605cd5..c64bd97 100644
--- a/fb.js
+++ b/fb.js
@@ -69,20 +69,23 @@ FB_JS.getUrlVars = function(href) {
/**
* Reload the current page, whether on canvas page or facebook connect.
+ *
+ * append fbsig, a hash of the session data, to avoid infinite reloads
+ * in some cases.
*/
FB_JS.reload = function(destination) {
- // Determine fbu.
+ // Determine url hash.
var session = FB.getSession();
- var fbu;
+ var fbhash;
if (session != null)
- fbu = session.uid;
+ fbhash = session.sig; // Use sig rather than compute a new hash.
else
- fbu = 0;
+ fbhash = 0;
- // Avoid infinite reloads
+ // Avoid infinite reloads. Still needed? It would be nice to do away with this code if not needed.
///@TODO - does not work on iframe because facebook does not pass url args to canvas frame when cookies not accepted. http://forum.developers.facebook.net/viewtopic.php?id=77236
var vars = FB_JS.getUrlVars(window.location.href);
- if (vars.fbu == fbu) {
+ if (vars.fbhash == fbhash) {
return; // Do not reload (again)
}
@@ -108,11 +111,13 @@ FB_JS.reload = function(destination) {
path = destination.substr(0, destination.indexOf('?'));
}
- // Add fbu to params before reload.
- vars.push('fbu=' + fbu);
+ // Add fbhash to params before reload.
+ if (Drupal.settings.fb.reload_url_append_hash) {
+ vars.push('fbhash=' + fbhash);
+ }
// Use window.top for iframe canvas pages.
- destination = path + '?' + vars.join('&');
+ destination = vars.length ? (path + '?' + vars.join('&')) : path;
if(Drupal.settings.fb.reload_url_fragment) {
destination = destination + "#" + Drupal.settings.fb.reload_url_fragment;
@@ -199,7 +204,8 @@ FB_JS.ajaxEvent = function(event_type, request_data) {
// FB._apikey might be an apikey or might be an appid!
if (FB._apiKey == Drupal.settings.fb.fb_init_settings.appId ||
FB._apiKey == Drupal.settings.fb.fb_init_settings.apiKey) {
- request_data.apikey = Drupal.settings.fb.fb_init_settings.apiKey;
+ request_data.apikey = Drupal.settings.fb.fb_init_settings.apiKey; // deprecated
+ request_data.appId = Drupal.settings.fb.fb_init_settings.appId;
}
// Other values to pass to ajax handler.
diff --git a/fb.module b/fb.module
index 2de14a0..19dea02 100644
--- a/fb.module
+++ b/fb.module
@@ -57,6 +57,7 @@ define('FB_VAR_APIKEY', 'fb_apikey'); // Deprecated. Use FB_VAR_ID
define('FB_VAR_ID', 'fb_id');
define('FB_VAR_USE_COOKIE', 'fb_use_cookie');
define('FB_VAR_USE_SESSION', 'fb_use_session');
+define('FB_VAR_RELOAD_APPEND_HASH', 'fb_reload_append_hash');
define('FB_VAR_CURL_NOVERIFY', 'fb_curl_noverify');
// node_access realms (belongs here?)
@@ -178,10 +179,10 @@ function fb_init() {
// An App is configured.
// Javascript settings needed by fb.js.
- fb_js_settings('apikey', $_fb_app->apikey);
+ //fb_js_settings('apikey', $_fb_app->apikey); // deprecated XXX
fb_js_settings('label', $_fb_app->label);
fb_js_settings('page_type', fb_settings(FB_SETTINGS_TYPE)); // canvas or connect.
- $fb_init_settings['apiKey'] = $_fb_app->apikey;
+ //$fb_init_settings['apiKey'] = $_fb_app->apikey;
$fb_init_settings['appId'] = $_fb_app->id;
// Initialize the PHP API.
@@ -199,15 +200,15 @@ function fb_init() {
$_fb->setSession(json_decode($_REQUEST['fb_js_session'], TRUE));
$session = $_fb->getSession();
}
- elseif (isset($_SESSION['fb'][$_fb_app->apikey]['session']) && arg(0) != 'logout') {
+ elseif (isset($_SESSION['fb'][$_fb_app->id]['session']) && arg(0) != 'logout') {
// Use the session previously stored.
- $_fb->setSession($_SESSION['fb'][$_fb_app->apikey]['session']);
+ $_fb->setSession($_SESSION['fb'][$_fb_app->id]['session']);
}
// Store session for future use. We'll need it if third-party cookies
// disabled, or we are not using facebook's cookie.
if (isset($session) && variable_get(FB_VAR_USE_SESSION, TRUE)) {
- $_SESSION['fb'][$_fb_app->apikey]['session'] = $session;
+ $_SESSION['fb'][$_fb_app->id]['session'] = $session;
}
// Make javascript work even when third-party cookies disabled.
@@ -222,7 +223,7 @@ function fb_init() {
_fb_logout();
$_fb->setSession(NULL);
unset($session);
- unset($_SESSION['fb'][$_fb_app->apikey]);
+ unset($_SESSION['fb'][$_fb_app->id]);
unset($fb_init_settings['session']);
}
}
@@ -276,7 +277,7 @@ function fb_init() {
'fb_canvas' => fb_is_canvas(),
'language' => (object) array('prefix' => NULL, 'language' => NULL), // http://drupal.org/node/1000452
)));
-
+ fb_js_settings('reload_url_append_hash', variable_get(FB_VAR_RELOAD_APPEND_HASH, FALSE));
}
if ($channel = variable_get(FB_VAR_JS_CHANNEL, TRUE)) {
@@ -372,8 +373,8 @@ function fb_api_init($fb_app) {
// or at least not overwrite previously declared handler.
set_exception_handler('fb_handle_exception');
- if (isset($cache[$fb_app->apikey])) {
- return $cache[$fb_app->apikey];
+ if (isset($cache[$fb_app->id])) {
+ return $cache[$fb_app->id];
}
// Find Facebook's PHP SDK. Use libraries API if enabled.
@@ -408,7 +409,7 @@ function fb_api_init($fb_app) {
}
// Cache the result, in case we're called again.
- $cache[$fb_app->apikey] = $fb;
+ $cache[$fb_app->id] = $fb;
return $fb;
}
@@ -726,7 +727,7 @@ function _fb_logout() {
// Clean up facebook cookies.
if (isset($GLOBALS['_fb_app'])) {
- if (isset($_COOKIE['fbs_' . $GLOBALS['_fb_app']->apikey])) {
+ if (isset($_COOKIE['fbs_' . $GLOBALS['_fb_app']->apikey])) { // still needed?
setcookie('fbs_' . $GLOBALS['_fb_app']->apikey, '', time() - 42000, '/');
}
if (isset($_COOKIE['fbs_' . $GLOBALS['_fb_app']->id])) {
@@ -888,12 +889,12 @@ function fb_get_object_fbu($object) {
/**
- * Convenience method to get app info based on apikey or nid.
+ * Convenience method to get app info based on id or nid.
*/
function fb_get_app($search_data) {
// $search_data can be an apikey, or an array of other search params.
if (!is_array($search_data))
- $search_data = array('apikey' => $search_data);
+ $search_data = array('id' => $search_data);
$fb_app = fb_invoke(FB_OP_GET_APP, $search_data);
return $fb_app;
@@ -1185,7 +1186,7 @@ function fb_invoke($op, $data = NULL, $return = NULL, $hook = FB_HOOK) {
'%function' => $function,
'%op' => $op,
'%label' => $data['fb_app']->label,
- '%apikey' => $data['fb_app']->apikey,
+ '%id' => $data['fb_app']->id,
'!app' => l($data['fb_app']->label, FB_PATH_ADMIN_APPS . '/' . $data['fb_app']->label),
)));
}
@@ -1482,8 +1483,8 @@ function fb_ajax_event($event_type) {
global $_fb, $_fb_app;
$js_array = array();
- if (isset($_REQUEST['apikey'])) {
- $_fb_app = fb_get_app(array('apikey' => $_REQUEST['apikey']));
+ if (isset($_REQUEST['appId'])) {
+ $_fb_app = fb_get_app(array('id' => $_REQUEST['appId']));
if ($_fb_app) {
$_fb = fb_api_init($_fb_app);
// Data to pass to hook_fb.
@@ -1498,7 +1499,7 @@ function fb_ajax_event($event_type) {
}
else {
- watchdog('fb', 'fb_ajax_event did not find application %id', array('%id' => $_REQUEST['apikey']), WATCHDOG_ERROR);
+ watchdog('fb', 'fb_ajax_event did not find application %id', array('%id' => $_REQUEST['appId']), WATCHDOG_ERROR);
}
if ($event_type == 'session_change') {
@@ -1512,10 +1513,10 @@ function fb_ajax_event($event_type) {
}
else {
- watchdog('fb', 'fb_ajax_event called badly. Not passed apikey.', array(), WATCHDOG_ERROR);
+ watchdog('fb', 'fb_ajax_event called badly. Not passed app id.', array(), WATCHDOG_ERROR);
// Trying to track down what makes this happen.
if (fb_verbose() == 'extreme') {
- watchdog('fb', 'fb_ajax_event called badly. Not passed apikey. trace: !trace', array(
+ watchdog('fb', 'fb_ajax_event called badly. Not passed app id. trace: !trace', array(
'!trace' => '<pre>' . print_r(debug_backtrace(), 1) . '</pre>',
), WATCHDOG_ERROR);
}
diff --git a/fb_app.admin.inc b/fb_app.admin.inc
index 2d7fe00..5b1e3b1 100644
--- a/fb_app.admin.inc
+++ b/fb_app.admin.inc
@@ -54,7 +54,7 @@ function fb_app_edit_form($form, $form_state, $fb_app = NULL) {
// Defaults for new app.
$fb_app = (object) array(
'label' => NULL,
- 'apikey' => NULL,
+ 'apikey' => NULL, // deprecated.
'canvas' => NULL,
'fba_id' => NULL,
'id' => NULL,
@@ -81,7 +81,7 @@ function fb_app_edit_form($form, $form_state, $fb_app = NULL) {
<li>If building a Canvas Page App, specify a Canvas Path.</li>
<li>Upload icon and logo images. The icon appears in News Feed stories and the logo appears in the Connect dialog when the user connects with your site.</li>
<li>Click Submit.</li>
-<li>Copy the displayed API Key, Application Secret and App ID into this form.</li>
+<li>Copy the displayed App ID and Application Secret into this form.</li>
</ol>';
$form['helptext'] = array(
@@ -117,13 +117,6 @@ function fb_app_edit_form($form, $form_state, $fb_app = NULL) {
'#default_value' => $fb_app->id,
'#description' => t('Facebook will generate this value when you create the application.'),
);
- $form['apikey'] = array(
- '#type' => 'textfield',
- '#title' => t('API Key'),
- '#required' => TRUE,
- '#default_value' => $fb_app->apikey,
- '#description' => t('Facebook will generate this value when you create the application.'),
- );
$form['secret'] = array(
'#type' => 'textfield',
'#title' => t('Secret'),
@@ -192,7 +185,7 @@ function fb_app_edit_form_validate($form, &$form_state) {
fb_admin_get_app_properties($fb_app);
if (!$fb_app->application_name) {
// Don't use form_set_error(), as that will prevent the user from saving any data.
- drupal_set_message(t("Unable to get application properties. Possibly, you've given the wrong apikey or secret. Possibly, this server is unable to reach facebook's servers. Your application will not work properly!"), 'error');
+ drupal_set_message(t("Unable to get application properties. Possibly, you've given the wrong id or secret. Possibly, this server is unable to reach facebook's servers. Your application will not work properly!"), 'error');
$fb_app->application_name = 'UNKOWN';
}
}
@@ -214,7 +207,7 @@ function fb_app_admin_form_submit($form, &$form_state) {
->fields(array(
'label' => $fb_app->label,
'status' => $fb_app->status,
- 'apikey' => $fb_app->apikey,
+ 'apikey' => $fb_app->id, // Note, apikey deprecated. Using ID.
'secret' => $fb_app->secret,
'id' => $fb_app->id,
// Canvas and title are learned from facebook, not the form.
@@ -251,7 +244,7 @@ function fb_app_admin_form_submit($form, &$form_state) {
->fields(array(
'label' => $fb_app->label,
'status' => $fb_app->status,
- 'apikey' => $fb_app->apikey,
+ 'apikey' => $fb_app->id, // Note, apikey deprecated. Using ID.
'secret' => $fb_app->secret,
'id' => $fb_app->id,
// Canvas and title are learned from facebook, not the form.
@@ -261,15 +254,16 @@ function fb_app_admin_form_submit($form, &$form_state) {
))
->execute();
- watchdog('fb_app', 'Created Facebook Application %label.',
- array('%label' => $fb_app->label,
+ watchdog('fb_app', 'Created Facebook Application %label.', array(
+ '%label' => $fb_app->label,
),
WATCHDOG_NOTICE,
l(t('view apps'), FB_PATH_ADMIN_APPS));
- drupal_set_message(t('Created facebook application %title (%label).',
- array('%label' => $fb_app->label,
- '%title' => $fb_app->application_name)));
+ drupal_set_message(t('Created facebook application %title (%label).', array(
+ '%label' => $fb_app->label,
+ '%title' => $fb_app->application_name,
+ )));
}
catch (Exception $e) {
// Log the exception to watchdog.
diff --git a/fb_app.install b/fb_app.install
index 7dcae24..6af3c34 100644
--- a/fb_app.install
+++ b/fb_app.install
@@ -111,7 +111,7 @@ function fb_app_update_7301() {
->execute();
drupal_set_message(t("Changed fb application name from %label_old to %label_new. Please adjust any custom code or settings which rely on app's label.", array(
- '%label_old' => $label_old,
+ '%label_old' => $label_old,
'%label_new' => $label_new,
)), 'warning');
@@ -146,3 +146,5 @@ function fb_app_update_7301() {
}
return $ret;
}
+
+
diff --git a/fb_app.module b/fb_app.module
index 0a35504..b625fac 100644
--- a/fb_app.module
+++ b/fb_app.module
@@ -34,10 +34,11 @@ function fb_app_fb($op, $data, &$return) {
// We also support these ways to query an app. Columns in fb_app table.
foreach (array(
- 'fba_id' => ':fba_id',
- 'id' => ':id',
- 'apikey' => ':apikey',
- 'label' => ':label') as $key => $placeholder) {
+ 'fba_id' => ':fba_id',
+ 'id' => ':id',
+ 'apikey' => ':apikey', // deprecated
+ 'label' => ':label',
+ ) as $key => $placeholder) {
if (isset($data[$key])) {
$where[] = "$key = $placeholder";
$args[$placeholder] = $data[$key];
@@ -79,7 +80,7 @@ function fb_app_fb($op, $data, &$return) {
if (!$return && ($id = fb_settings(FB_SETTINGS_ID))) {
$return = fb_get_app(array('id' => $id));
}
- elseif (!$return && ($apikey = fb_settings(FB_SETTINGS_APIKEY))) {
+ elseif (!$return && ($apikey = fb_settings(FB_SETTINGS_APIKEY))) { // deprecated XXX
$return = fb_get_app(array('apikey' => $apikey));
}
}
@@ -185,7 +186,7 @@ function theme_fb_app($fb_app) {
$props_map = fb_invoke(FB_OP_LIST_PROPERTIES, array('fb_app' => $fb_app), array());
$data = array(
t('Label') => $fb_app->label,
- t('API Key') => $fb_app->apikey,
+ t('App ID') => $fb_app->id,
//t('Secret') => $fb_app->secret,
);
foreach ($props_map as $name => $key) {
diff --git a/fb_connect.module b/fb_connect.module
index d9af6ea..05c205c 100644
--- a/fb_connect.module
+++ b/fb_connect.module
@@ -89,7 +89,11 @@ function _fb_connect_set_app($fb_app = NULL) {
function fb_connect_fb($op, $data, &$return) {
if ($op == FB_OP_CURRENT_APP && !$return && !fb_is_canvas()) {
// This will cause fb.module to set the global $_fb when user is logged in via fbConnect.
- if ($apikey = variable_get(FB_VAR_APIKEY, NULL)) {
+ if ($id = variable_get(FB_VAR_ID, NULL)) {
+ // Use $conf['fb_id'] if set in settings.php.
+ $return = fb_get_app(array('id' => $id));
+ }
+ elseif ($apikey = variable_get(FB_VAR_APIKEY, NULL)) { // Deprecated. Use fb_id instead.
// Use $conf['fb_apikey'] if set in settings.php.
$return = fb_get_app(array('apikey' => $apikey));
}
diff --git a/fb_devel.module b/fb_devel.module
index 8a82341..d8e38bb 100644
--- a/fb_devel.module
+++ b/fb_devel.module
@@ -87,7 +87,7 @@ function fb_devel_init() {
- // $conf['fb_apikey'] sanity check
+ // $conf['fb_apikey'] sanity check.
if ($apikey = variable_get(FB_VAR_APIKEY, NULL)) {
$fb_app = fb_get_app(array('apikey' => $apikey));
$message = t('Drupal for Facebook no longer uses the \'fb_apikey\' variable. Change $conf[\'fb_apikey\'] in your settings.php. Use $conf[\'fb_id\'] instead, and make the value the app id (%app_id) instead of the apikey.', array(
@@ -132,13 +132,14 @@ function fb_devel_init() {
// Old url rewrite sanity check.
if ($id = fb_settings(FB_SETTINGS_CB)) {
- if ($GLOBALS['_fb_app']->apikey == $id) {
- $message = t('Facebook callback URLs have changed. They now include the app\'s ID, instead of APIKEY. Your application %label has not been updated. Either <a target=_top href=!sync_url>sync properties</a> or manually change callbacks on remote settings.', array(
- '%label' => $GLOBALS['_fb_app']->title,
- '!sync_url' => url(FB_PATH_ADMIN_APPS . '/' . $GLOBALS['_fb_app']->label . '/fb/set_props', array(
- 'fb_url_alter' => FALSE,
- )),
- ));
+ if ($GLOBALS['_fb_app']->id != $id && $GLOBALS['_fb_app']->apikey == $id) {
+ $message = 'Facebook callback URLs have changed. They now include the app\'s ID, instead of APIKEY. Your application %label has not been updated. Either <a target=_top href=!sync_url>sync properties</a> or manually change callbacks on remote settings.';
+ $args = array(
+ '%label' => $GLOBALS['_fb_app']->title,
+ '!sync_url' => url(FB_PATH_ADMIN_APPS . '/' . $GLOBALS['_fb_app']->label . '/fb/set_props', array(
+ 'fb_url_alter' => FALSE,
+ )),
+ );
if (user_access('access administration pages')) {
drupal_set_message(t($message, $args), 'warning');
}
diff --git a/fb_tab.admin.inc b/fb_tab.admin.inc
index f622c61..f0007f3 100644
--- a/fb_tab.admin.inc
+++ b/fb_tab.admin.inc
@@ -7,6 +7,7 @@
/**
* Implements hook_fb_admin().
+ *
*/
function fb_tab_fb_admin($op, $data, &$return) {
$fb = isset($data['fb']) ? $data['fb'] : NULL;
@@ -14,8 +15,27 @@ function fb_tab_fb_admin($op, $data, &$return) {
$config = _fb_tab_get_config($fb_app);
if ($op == FB_ADMIN_OP_SET_PROPERTIES) {
$return['tab_default_name'] = $config['tab_default_name'];
- $return['profile_tab_url'] = $config['profile_tab_url'];
- //$return['edit_url'] = $config['edit_url']; // Apparently not used by facebook.
+
+ if ($config['profile_tab_url']) {
+ $return['profile_tab_url'] = url($config['profile_tab_url'], array(
+ 'absolute' => TRUE,
+ 'fb_canvas' => FALSE,
+ ));;
+ }
+ else {
+ $return['profile_tab_url'] = '';
+ }
+
+ if ($config['edit_url']) {
+ // http://forum.developers.facebook.net/viewtopic.php?id=88920
+ $return['edit_url'] = url($config['edit_url'], array(
+ 'absolute' => TRUE,
+ 'fb_canvas' => $fb_app->label, // @TODO make canvas optional
+ ));;
+ }
+ else {
+ $return['edit_url'] = '';
+ }
}
elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) {
$return[t('Profile Tab Name')] = 'tab_default_name';
@@ -108,15 +128,14 @@ function fb_tab_admin_form_alter(&$form, &$form_state, $form_id) {
'#default_value' => $config['profile_tab_url'],
'#description' => t('Recommended value is %tab_path. You may choose another if you have defined a custom menu item or view.', array('%tab_path' => FB_TAB_PATH_VIEW)),
);
- /* XXX is this used by facebook?
+
$form['fb_app_data']['fb_tab']['edit_url'] = array(
'#type' => 'textfield',
'#title' => 'Edit URL',
'#default_value' => $config['edit_url'],
'#description' => t('Recommended value is %edit_url.', array(
- '%edit_url' => url(FB_TAB_PATH_FORM, array('absolute'=> TRUE)))),
+ '%edit_url' => FB_TAB_PATH_FORM,
+ )),
);
- $form['fb_app_data']['fb_tab']['edit_url']['#description'] .= '<br/>' . t('Note that this field is apparently unused by facebook.');
- */
}
}
diff --git a/fb_tab.module b/fb_tab.module
index 306a4d7..d2be94e 100644
--- a/fb_tab.module
+++ b/fb_tab.module
@@ -193,47 +193,6 @@ function fb_tab_form_alter(&$form, &$form_state, $form_id) {
//require 'fb_canvas.admin.inc';
fb_tab_admin_form_alter($form, $form_state, $form_id);
}
-
- if (fb_is_tab()) {
- // Most Drupal forms have an action that assumes Drupal's base_path.
- // But in the case of FBML, we need to make it explicit.
- $form['#action'] = url(request_path(), array('absolute' => TRUE));
- //dpm(__FUNCTION__ . " changed action to " . $form['#action']);
- }
-}
-
-function _fb_tab_make_form_action_local($action = NULL) {
- global $base_path;
-
- if (!isset($action)) {
- // Is this ever reached?
- $action = request_path();
- }
-
- // If action is fully qualified, do not change it
- if (strpos($action, ':')) {
- return $action;
- }
-
- $relative = url('');
- $absolute = url('', array('absolute' => TRUE));
- $base_path = base_path(); // By default, '#action' will be request_uri(), which starts with base_path();
- global $_fb_app;
-
- if (strpos($action, $relative) === 0) {
- // If here, the action was made by call to url() and we prepended
- // canvas_name. Now remove the canvas name for a proper absolute url.
- // (Comment forms reach this clause but node forms do not.)
- $action = substr($action, strlen($relative));
- }
- elseif ($base_path && strpos($action, $base_path) === 0) {
- $action = substr($action, strlen($base_path));
- }
-
- $action = url(ltrim($action, '/'), array('absolute' => TRUE));
-
- return $action;
-
}
/**
@@ -248,6 +207,7 @@ function _fb_tab_get_config($fb_app) {
'custom_theme' => NULL,
'tab_default_name' => isset($fb_app->title) ? $fb_app->title : NULL,
'profile_tab_url' => FB_TAB_PATH_VIEW,
+ 'edit_url' => FB_TAB_PATH_FORM,
);
return $config;
}