? facebook-platform Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/README.txt,v retrieving revision 1.9 diff -u -u -p -r1.9 README.txt --- README.txt 7 Apr 2008 20:56:49 -0000 1.9 +++ README.txt 24 May 2008 04:15:26 -0000 @@ -19,7 +19,7 @@ To install: - Download the facebook-platform PHP code from developer.facebook.com. Extract it into the 'modules/fb' directory, so you have - modules/fb/facebook-application/ + modules/fb/facebook-platform/ wget http://developers.facebook.com/clientlibs/facebook-platform.tar.gz tar xvzf facebook-platform.tar.gz @@ -30,13 +30,15 @@ tar xvzf facebook-platform.tar.gz you may encounter uncaught exceptions using the PHP5 API. - Edit your settings.php file (sites/default/settings.php, depending - on your install) to include settings.inc (in this directory). For + on your install) to include fb_settings.inc (in this directory). For example: require_once "profiles/custom/modules/fb/fb_settings.inc"; (Or whatever path is appropriate, could be - "sites/all/module/fb/fb_settings.inc") + "sites/all/module/fb/fb_settings.inc"). + Include fb_settings.inc at the *end* of your settings.php file to + avoid overwriting optional $conf array manual overrides. - Enable the Facebook modules via the drupal admin pages, as usual. You must enable at least fb.module and fb_app.module. You will Index: fb.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb.info --- fb.info 26 Sep 2007 17:08:21 -0000 1.1 +++ fb.info 24 May 2008 04:15:26 -0000 @@ -1,3 +1,4 @@ name = Facebook API description = Imports and uses the Facebook API. package = Facebook +core = 6.x Index: fb.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb.install,v retrieving revision 1.2 diff -u -u -p -r1.2 fb.install --- fb.install 7 Apr 2008 20:56:49 -0000 1.2 +++ fb.install 24 May 2008 04:15:26 -0000 @@ -5,20 +5,19 @@ function _fb_install_set_weight() { } function fb_install() { + //drupal_install_schema('fb'); _fb_install_set_weight(); } -function fb_update_1() { - _fb_install_set_weight(); + +function fb_uninstall() { + //drupal_uninstall_schema('fb'); + _fb_install_set_weight(); } -/** - * The callback URL has changed and this requires manual updates to App settings. - */ -function fb_update_2() { - $message = t('Warning! The Drupal for Facebook modules have changed. Manual intervention is required! See !url1 or !url2.', - array('!url1' => l('http://apps.facebook.com/drupalforfacebook/node/1055', 'http://apps.facebook.com/drupalforfacebook/node/1055'), - '!url2' => l('http://drupalforfacebook.org/node/1055','http://drupalforfacebook.org/node/1055'))); - drupal_set_message($message); - watchdog('fb', $message); +/* +function fb_schema() { + //this cannot return nothing, or common.inc reports error + $schema = array(); + return $schema; } -?> \ No newline at end of file +*/ \ No newline at end of file Index: fb.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb.module,v retrieving revision 1.18 diff -u -u -p -r1.18 fb.module --- fb.module 20 May 2008 05:36:59 -0000 1.18 +++ fb.module 24 May 2008 04:15:27 -0000 @@ -48,7 +48,7 @@ function fb_init() { array('!drupal_for_facebook' => l(t('Drupal for Facebook'), 'http://drupal.org/project/fb'), // This link should work with clean URLs // disabled. - '!readme' => 'README.txt')), 'error'); + '!readme' => 'README.txt')), 'error'); } @@ -192,9 +192,9 @@ function fb_api_init($fb_app, $fbu) { // get_loggedin_user does not really test it. if ($fbu_orig != FB_FBU_CURRENT && !$fb->get_loggedin_user()) { // An FBU other than CURRENT was specified, but we failed to log in. - watchdog('fb', t('Failed to log into facebook app %app as user %user', - array('%app' => $fb_app->title, - '%user' => $fbu_orig)), WATCHDOG_ERROR); + watchdog('fb', 'Failed to log into facebook app %app as user %user', + array('%app' => $fb_app->title, + '%user' => $fbu_orig), WATCHDOG_ERROR); } } @@ -246,7 +246,7 @@ function fb_init_pathXXX($fb_app, $resto $original = array('base_url' => $base_url, 'base_path' => $base_path); - /** + /* $base_path = "/$fb_app->canvas/"; // TODO: make the "apps.facebook.com" part configurable. $base_url = "http://apps.facebook.com/$fb_app->canvas"; @@ -254,7 +254,7 @@ function fb_init_pathXXX($fb_app, $resto // New way: $base_path = $fb_old_base_url . '/'; $base_url = ''; - **/ + */ if (!variable_get('clean_url', FALSE)) { $original['clean_url'] = FALSE; @@ -438,15 +438,15 @@ function fb_user_load($fbu = NULL) { if (!$account) $account = user_load(array('uid' => variable_get('fb_facebook_user', 2))); if (!$account) - watchdog('fb', t('Failed to load user from facebook fbu=%fbu', - array('%fbu' => $fbu)), 'error'); + watchdog('fb', 'Failed to load user from facebook fbu=%fbu', + array('%fbu' => $fbu), 'error'); $account->fbu = $fbu; return $account; } } -function fb_form_alter($form_id, &$form) { +function fb_form_alter(&$form, &$form_state, $form_id) { // Because facebook users don't have email, it can't be required on user form if ($form_id == 'user_register') { if (user_access('administer users')) { @@ -461,26 +461,21 @@ function fb_form_alter($form_id, &$form) } -function fb_menu($may_cache) { +function fb_menu() { $items = array(); - if (!$may_cache) { - // Initialization moved to fb_init(), nothing to do here. - } - else { // When forms are submitted directly to us, we cache the results, // and show them later via this callback - $items[] = array('path' => 'fb/form_cache', - 'callback' => '_fb_form_cache_cb', + $items['fb/form_cache'] = array( + 'page callback' => '_fb_form_cache_cb', 'type' => MENU_CALLBACK, - 'access' => TRUE); + 'access callback' => TRUE); // A page to help determine infinite session keys - $items[] = array('path' => 'fb/session', - 'callback' => '_fb_session_cb', + $items['fb/session'] = array( + 'page callback' => '_fb_session_cb', 'type' => MENU_CALLBACK, - 'access' => TRUE); // TODO: restrict access? - } + 'access callback' => TRUE); // TODO: restrict access? return $items; } @@ -627,4 +622,3 @@ function fb_report_exception($exception) } -?> \ No newline at end of file Index: fb_app.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_app.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_app.info --- fb_app.info 26 Sep 2007 17:08:21 -0000 1.1 +++ fb_app.info 24 May 2008 04:15:27 -0000 @@ -1,5 +1,6 @@ name = Facebook Application description = Create one or more facebook applications. package = Facebook -dependencies = fb +dependencies[] = fb +core = 6.x Index: fb_app.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_app.install,v retrieving revision 1.3 diff -u -u -p -r1.3 fb_app.install --- fb_app.install 18 Mar 2008 02:47:55 -0000 1.3 +++ fb_app.install 24 May 2008 04:15:27 -0000 @@ -6,60 +6,63 @@ */ // TODO: some of these tables should be created by othe module install files. -Function fb_app_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query(" -CREATE TABLE IF NOT EXISTS {fb_app} ( -nid int(11) unsigned NOT NULL, -label varchar(128) NOT NULL, -apikey varchar(128) NOT NULL, -id varchar(128) NOT NULL, -secret varchar(128) NOT NULL, -canvas varchar(128) NOT NULL, -require_login int(4) NOT NULL, -create_account int(4) NOT NULL, -unique_account int(4) NOT NULL, -rid int(10) unsigned NOT NULL, -data longtext, -PRIMARY KEY (nid), -UNIQUE KEY (apikey) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; -"); - db_query(" -CREATE TABLE IF NOT EXISTS {fb_app_block} ( -nid int(11) unsigned NOT NULL, -delta varchar(32) NOT NULL, -format int(11) DEFAULT 0, -body longtext NOT NULL, -PRIMARY KEY (nid, delta) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; -"); +/** + * hook_install() + */ +function fb_app_install() { + // Create tables. + drupal_install_schema('fb_app'); + + drupal_set_message(t('Facebook Application module installed. Please grant yourself permissions and then browse to Create Content => Facebook Application to get started.', array('!perm' => url('admin/user/permissions'), '!create' => url('node/add/fb-app')))); +} - // This table schema has to match the cache_filter table. - db_query(" -CREATE TABLE {fb_cache_filter} ( -cid varchar(255) NOT NULL default '', -data longblob, -expire int NOT NULL default '0', -created int NOT NULL default '0', -headers text, -PRIMARY KEY (cid), -INDEX expire (expire) -) /*!40100 DEFAULT CHARACTER SET UTF8 */; +/** + * hook_uninstall() + */ +function fb_app_uninstall() { + // Remove tables. + drupal_uninstall_schema('fb_app'); +} -"); - } - - drupal_set_message(t('Facebook Application module installed. Please grant yourself permissions and then browse to Create Content => Facebook Application to get started.', array('!perm' => url('admin/user/access'), '!create' => url('node/add/fb-app')))); - +function fb_app_schema() { + $schema['fb_app'] = array( + 'description' => 'Main FB_APP table', + 'fields' => array( + 'nid' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'label' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'apikey' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'id' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'secret' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'canvas' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'require_login' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'create_account' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'unique_account' => array('type' => 'int', 'length' => 4, 'not null' => TRUE, ), + 'rid' => array('type' => 'int', 'length' => 10, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'data' => array('type' => 'text', 'size' => 'big', ), + ), + 'unique keys' => array( + 'apikey' => array('apikey'), + ), + 'primary key' => array('nid'), + ); + $schema['fb_app_block'] = array( + 'fields' => array( + 'nid' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'delta' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, ), + 'format' => array('type' => 'int', 'length' => 11, 'default' => 0, ), + 'body' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE, ), + ), + 'primary key' => array('nid', 'delta'), + ); + $schema['fb_cache_filter'] = drupal_get_schema_unprocessed('system', 'cache'); + + return $schema; } -function fb_app_update_1() { +function fb_app_update_6100() { // Add id field - $ret[] = update_sql('ALTER TABLE {fb_app} ADD id varchar(128) NOT NULL'); - return $ret; -} -?> \ No newline at end of file + $ret = array(); + db_add_field($ret, 'fb_app', 'id', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, )); + return $ret; +} \ No newline at end of file Index: fb_app.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_app.module,v retrieving revision 1.11 diff -u -u -p -r1.11 fb_app.module --- fb_app.module 20 May 2008 05:33:08 -0000 1.11 +++ fb_app.module 24 May 2008 04:15:27 -0000 @@ -10,8 +10,7 @@ define('FB_APP_REQ_API_KEY', 'fb_sig_api * hook_fb */ function fb_app_fb($fb, $fb_app, $op, &$return, $data) { - - //drupal_set_message("fb_app_fb($fb_app->label, $op)" . dpr($fb_app, 1)); + //dpm(func_get_args(), "fb_app_fb"); if ($op == FB_OP_GET_APP) { // This operation determines which app the request is for. Theoretically, @@ -34,7 +33,7 @@ function fb_app_fb($fb, $fb_app, $op, &$ } else { if (function_exists('fb_settings')) { - // See settings.inc + // See fb_settings.inc if ($nid = fb_settings(FB_SETTINGS_APP_NID)) { // Here if we're in iframe, using our /fb_canvas/nid/ path convention. $fb_app = db_fetch_object(db_query("SELECT * FROM {fb_app} fb INNER JOIN {node} n ON n.nid=fb.nid WHERE fb.nid=%d and status=1", @@ -84,7 +83,7 @@ function fb_app_node_info() { ); } -function fb_app_access($op, $node) { +function fb_app_access($op, $node, $account) { if (user_access('administer fb apps')) return TRUE; if ($op == 'create' && user_access('create fb apps')) @@ -231,11 +230,26 @@ function fb_app_view($node, $teaser=FALS return $node; } + +function fb_app_theme() { + return array( + 'fb_app' => array( + 'arguments' => array('data' => NULL), + ), + 'dl' => array( + 'arguments' => array('items' => NULL), + ), + 'fb_app_user_info' => array( + 'arguments' => array('fb_app' => NULL, 'info' => NULL), + ), + ); +} + function theme_fb_app($data) { return theme('dl', array(t('Label') => $data->label, t('API Key') => $data->apikey, t('Secret') => $data->secret, - t('About page') => $data->id ? url("http://www.facebook.com/apps/application.php", "id=$data->id") : t('N/A'), + t('About page') => $data->id ? url("http://www.facebook.com/apps/application.php", array('query' => "id=$data->id")) : t('N/A'), // TODO: edit and logout URLs )); @@ -275,9 +289,9 @@ function fb_app_insert($node) { _fb_app_blocks_update($node); - watchdog('fb_app', t('Created Facebook Application %label. Created role %role.', + watchdog('fb_app', 'Created Facebook Application %label. Created role %role.', array('%label' => $fb_app->label, - '%role' => $role_name)), + '%role' => $role_name), WATCHDOG_NOTICE, l($node->title, 'node/'.$node->nid)); @@ -413,7 +427,7 @@ function fb_app_user($op, &$edit, &$acco function theme_fb_app_user_info($fb_app, $info) { if ($info['pic_big']) $output .= '

'; - $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', NULL, 'id='.$info['uid']); + $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', array('query' => 'id=' . $info['uid'])); if ($info['is_app_user']) $output .= '

' . t('!fb_link uses %title', array('!fb_link' => $fb_link, @@ -444,5 +458,4 @@ function fb_app_token_values($type = 'al } return $values; } - ?> \ No newline at end of file Index: fb_canvas.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_canvas.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_canvas.info --- fb_canvas.info 7 Apr 2008 20:56:49 -0000 1.1 +++ fb_canvas.info 24 May 2008 04:15:27 -0000 @@ -1,5 +1,8 @@ name=Facebook Application Canvas Pages description=Support for Facebook Canvas Pages package = Facebook -dependencies = fb fb_app +dependencies[] = fb +dependencies[] = fb_app +core = 6.x +version = "6.x-1.x-dev" Index: fb_canvas.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_canvas.module,v retrieving revision 1.7 diff -u -u -p -r1.7 fb_canvas.module --- fb_canvas.module 20 May 2008 05:35:09 -0000 1.7 +++ fb_canvas.module 24 May 2008 04:15:27 -0000 @@ -22,11 +22,6 @@ function fb_canvas_fb($fb, $fb_app, $op, $custom_theme = $fb_canvas_data['theme_fbml']; else if (fb_canvas_is_iframe()) $custom_theme = $fb_canvas_data['theme_iframe']; - - // This is for backward compatability (delete eventually) - if (!$custom_theme) - $custom_theme = variable_get('fb_theme', 'fb_fbml'); - // Special handling for forms, as they are submitted directly to us, not // to apps.facebook.com/canvas @@ -71,7 +66,7 @@ function fb_canvas_fb($fb, $fb_app, $op, $token = uniqid('fb_'); $cid = session_id() . "_$token"; watchdog('fb', "Storing cached form page $cid, then redirecting"); - cache_set($cid, 'cache_page', $output, time() + (60 * 5), drupal_get_headers()); // (60 * 5) == 5 minutes + cache_set($cid, $output, 'cache_page', time() + (60 * 5), drupal_get_headers()); // (60 * 5) == 5 minutes $dest = 'http://apps.facebook.com/' . $fb_app->canvas . "/fb/form_cache/$cid"; // $fb->redirect($url); // Does not work! @@ -100,7 +95,7 @@ function fb_canvas_fb($fb, $fb_app, $op, /** * Implementation of hook_form_alter. */ -function fb_canvas_form_alter($form_id, &$form) { +function fb_canvas_form_alter(&$form, &$form_state, $form_id) { // Add our settings to the fb_app edit form. if (is_array($form['fb_app_data'])) { $node = $form['#node']; @@ -140,30 +135,32 @@ function fb_canvas_form_alter($form_id, '#default_value' => $fb_canvas_data['front_added'], ); + /* XXX menu code here needs updating to D6 // Allow primary links to be different on facebook versus the rest of the // site. Code from menu_configure() in menu.module. - $root_menus = menu_get_root_menus(); - - $primary_options = $root_menus; - $primary_options[0] = t(''); - $secondary_options = $root_menus; - $secondary_options[0] = t(''); - - $form['fb_app_data']['fb_canvas']['primary_links'] = - array('#type' => 'select', - '#title' => t('Menu containing primary links'), - '#description' => t('Your application can have primary links different from those used elsewhere on your site.'), - '#default_value' => $fb_canvas_data['primary_links'], - '#options' => $primary_options, - ); - $form['fb_app_data']['fb_canvas']['secondary_links'] = - array('#type' => 'select', - '#title' => t('Menu containing secondary links'), - '#default_value' => $fb_canvas_data['secondary_links'], - '#options' => $secondary_options, - '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'), + $primary = variable_get('menu_primary_links_source', 'primary-links'); + $primary_options = array_merge($menu_options, array('' => t(''))); + $form['fb_app_data']['fb_canvas']['menu_primary_links_source'] = + array( + '#type' => 'select', + '#title' => t('Source for the primary links'), + '#default_value' => $fb_canvas_data['primary_links'], + '#options' => $primary_options, + '#tree' => FALSE, + '#description' => t('Your application can have primary links different from those used elsewhere on your site.'), ); + $secondary_options = array_merge($menu_options, array('' => t(''))); + $form['fb_app_data']['fb_canvas']["menu_secondary_links_source"] = + array( + '#type' => 'select', + '#title' => t('Source for the secondary links'), + '#default_value' => $fb_canvas_data['secondary_links'], + '#options' => $secondary_options, + '#tree' => FALSE, + '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'), + ); +*/ // Override themes $themes = system_theme_data(); @@ -203,7 +200,7 @@ function fb_canvas_form_alter($form_id, // We need to make sure the action goes to our domain and not apps.facebook.com if ($form['#action'] == '') { - $form['#action'] = $_GET['q']; + $form['#action'] = $_GET['q']; //TODO: somewhere the canvas is getting prepended to form action urls. form submit doesn't work } $form['#action'] = _fb_canvas_make_form_action_local($form['#action']); // Let's hope no subsequent hook_form_alters mess with #action. @@ -222,8 +219,8 @@ function fb_canvas_nodeapi(&$node, $op, $output = theme('dl', array(t('Canvas page') => "http://apps.facebook.com/$fb_app->canvas", t('Callback URL') => t("%clean_url
(or %advanced_url only if your theme is designed to support PAGE_TYPE.)
Make sure you have enabled clean URLs, and include the trailing '/'.", - array("%clean_url" => url('', NULL, NULL, TRUE) . FB_SETTINGS_APP_NID . '/' . $node->nid .'/', - "%advanced_url" => url('', NULL, NULL, TRUE) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/' . FB_SETTINGS_PAGE_TYPE . '/PAGE_TYPE/', + array("%clean_url" => url('', array('absolute' => TRUE)) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/', + "%advanced_url" => url('', array('absolute' => TRUE)) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/'. FB_SETTINGS_PAGE_TYPE . '/PAGE_TYPE/', ) ), )); @@ -353,7 +350,15 @@ function fb_canvas_process($output, $add if (fb_canvas_is_fbml()) { //dpm($output, "before fb_canvas_process"); // We're producing FBML for a canvas page + + /* + TODO: $output['logo'] is not being processed properly by these + patterns. fb_canvas_process() returns '/sites/all/themes/fb_fbml/logo.png' + and Facebook complains "Relative URLs not allowed here" + LOGO is turned off in theme settings for now. + */ + // Change links to use canvas on Facebook $patterns[] = "|=\"{$base}|"; $replacements[] = "=\"/{$fb_app->canvas}/"; @@ -418,4 +423,3 @@ function fb_canvas_process($output, $add else return $output; } -?> \ No newline at end of file Index: fb_devel.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_devel.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_devel.info --- fb_devel.info 7 Apr 2008 20:56:49 -0000 1.1 +++ fb_devel.info 24 May 2008 04:15:27 -0000 @@ -1,6 +1,8 @@ name=Drupal for Facebook Development and Debugging description=Blocks and messages that help when developing Apps. package = Facebook -dependencies = fb devel +dependencies[] = fb +dependencies[] = devel +core = 6.x Index: fb_devel.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_devel.module,v retrieving revision 1.3 diff -u -u -p -r1.3 fb_devel.module --- fb_devel.module 8 May 2008 02:16:03 -0000 1.3 +++ fb_devel.module 24 May 2008 04:15:27 -0000 @@ -1,18 +1,13 @@ 'fb/debug', - 'callback' => '_fb_debug_cb', - 'type' => MENU_CALLBACK, - 'access' => TRUE, // TODO: restrict access - ); - - } +function fb_devel_menu() { + $items['fb/debug'] = array('page callback' => '_fb_debug_cb', + 'type' => MENU_CALLBACK, + 'access callback' => TRUE, // TODO: restrict access + ); + return $items; - } +} function fb_devel_fb($fb, $fb_app, $op, &$return, $data) { @@ -26,7 +21,7 @@ function fb_devel_fb($fb, $fb_app, $op, '!url' => "http://www.facebook.com/developers/apps.php", )); drupal_set_message($message, 'error'); - watchdog('fb_devel', $message); + watchdog('fb_devel', $message, array(), WATCHDOG_ERROR); } // Theme sanity check @@ -38,7 +33,7 @@ function fb_devel_fb($fb, $fb_app, $op, // disabled. '!readme' => 'README.txt')); drupal_set_message($message, 'error'); - watchdog('fb_devel', $message); + watchdog('fb_devel', $message, array(), WATCHDOG_ERROR); } } Index: fb_form.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_form.info,v retrieving revision 1.2 diff -u -u -p -r1.2 fb_form.info --- fb_form.info 5 May 2008 22:14:18 -0000 1.2 +++ fb_form.info 24 May 2008 04:15:27 -0000 @@ -1,4 +1,8 @@ name = Facebook Forms description = Enables FBML form elements via Drupal Form API. Provides commonly needed forms such as invite friends to install application. package = Facebook -dependencies = fb +dependencies[] = fb +core = 6.x + +version = "6.x-1.x-dev" + Index: fb_form.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_form.module,v retrieving revision 1.3 diff -u -u -p -r1.3 fb_form.module --- fb_form.module 8 May 2008 02:14:29 -0000 1.3 +++ fb_form.module 24 May 2008 04:15:27 -0000 @@ -15,23 +15,21 @@ /** * hook_menu. */ -function fb_form_menu($may_cache) { +function fb_form_menu() { $items = array(); - if ($may_cache) { - // Page allowing a user to invite their friends to add the app. - $items[] = array('path' => 'fb/invite', - 'callback' => 'fb_form_invite_page', - 'access' => TRUE, + // Page allowing a user to invite their friends to add the app. + $items['fb/invite'] = array( + 'page callback' => 'fb_form_invite_page', + 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); - } return $items; } /** * hook_form_alter. */ -function fb_form_form_alter($form_id, &$form) { +function fb_form_form_alter(&$form, &$form_state, $form_id) { // Drupal allows no clean way to set $form['#type'], so we hack... if ($type = $form['#type_hack']) { $form['#type'] = $type; @@ -52,7 +50,7 @@ function fb_form_invite_page() { if (function_exists('fb_canvas_is_fbml') && !fb_canvas_is_fbml()) { - drupal_set_message(t('Unable to display page. FBML required.'), 'error'); + drupal_set_message('Unable to display page. FBML required.', 'error'); drupal_not_found(); exit(); } @@ -162,7 +160,7 @@ function fb_form_friend_options($fbu) { $items = array(); if ($fb) { - $query = "SELECT last_name, first_name, uid, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=$fbu)"; + $query = "SELECT last_name, first_name, uid, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=$fbu)"; //TODO: db_query this to be safe? $result = $fb->api_client->fql_query($query); // TODO: sort results by name @@ -176,14 +174,14 @@ function fb_form_friend_options($fbu) { function fb_form_group_member_options($fbg, $fbu) { global $fb; - $query = "SELECT uid FROM group_member WHERE gid=$fbg"; + $query = "SELECT uid FROM group_member WHERE gid=$fbg"; //TODO: db_query this? $result = $fb->api_client->fql_query($query); drupal_set_message("fb_form_group_member_options($fbg, $fbu) query $query returns" . dpr($result, 1)); - $query = "SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid FROM group_member WHERE gid=$fbg)"; + $query = "SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid FROM group_member WHERE gid=$fbg)"; //TODO: db_query to be safe? $result = $fb->api_client->fql_query($query); drupal_set_message("fb_form_group_member_options($fbg, $fbu) query $query returns" . dpr($result, 1)); @@ -254,7 +252,7 @@ function friend_selector_process($orig) static $options = NULL; if (!$options) { - $query = "SELECT last_name, first_name, uid, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=".fb_facebook_user().")"; + $query = "SELECT last_name, first_name, uid, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=". fb_facebook_user() .")"; $result = $fb->api_client->fql_query($query); // TODO: sort results by name @@ -279,6 +277,14 @@ function friend_selector_value(&$form) { //drupal_set_message("friend_selector_value" . dpr($form, 1)); } +function fb_form_theme() { + return array( + 'friend_selectorXXX' => array( + 'arguments' => array('fbu' => NULL), + ), + ); +} + // TODO: provide some alternative when NOT a facebook app. // deprecated! function theme_friend_selector($fbu = NULL) { @@ -289,4 +295,3 @@ function theme_friend_selector($fbu = NU $output = ""; return $output; } -?> \ No newline at end of file Index: fb_infinite.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_infinite.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_infinite.info --- fb_infinite.info 15 Oct 2007 18:39:09 -0000 1.1 +++ fb_infinite.info 24 May 2008 04:15:27 -0000 @@ -1,5 +1,7 @@ name=Facebook Infinite Session description=Configure an infinite session that allows use of the Facebook API from non-canvas pages. For example, to access Facebook API from a cron job. package = Facebook -dependencies = fb +dependencies[] = fb +core = 6.x +version = "6.x-1.x-dev" Index: fb_infinite.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_infinite.module,v retrieving revision 1.3 diff -u -u -p -r1.3 fb_infinite.module --- fb_infinite.module 13 May 2008 14:54:26 -0000 1.3 +++ fb_infinite.module 24 May 2008 04:15:27 -0000 @@ -24,43 +24,52 @@ function fb_infinite_fb($fb, $fb_app, $o /** * hook_menu */ -function fb_infinite_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array('path' => 'fb/infinite/display', - 'title' => t('Facebook session information'), - 'access' => user_access('administer fb apps'), // perm defined in fb_app.module - 'callback' => 'fb_infinite_display_page', - 'type' => MENU_CALLBACK, +function fb_infinite_menu() { + $items['fb/infinite/display'] = + array('title' => t('Facebook session information'), + 'page callback' => 'fb_infinite_display_page', + 'access callback' => 'user_access', + 'access arguments' => array('administer fb apps'), // perm defined in fb_app.module + 'type' => MENU_CALLBACK, ); - } - else { - if (arg(0) == 'node' && is_numeric(arg(1))) { - $node = node_load(arg(1)); - if ($node->type == 'fb_app') { - // Only show if infinite session is configured. - $fb_app_data = fb_app_get_data($node->fb_app); - $fb_infinite_data = $fb_app_data['fb_infinite']; - if ($fb_infinite_data['key']) { - $items[] = array('path' => "node/$node->nid/fb/infinite/test", - 'title' => t('Infinite session test'), - 'type' => MENU_LOCAL_TASK, - 'access' => node_access('update', $node), - 'callback' => 'fb_infinite_test_page', - 'callback arguments' => array($node->nid), - ); - } - } + + $items['node/%fb_infinite/fb/infinite/test'] = + array('title' => 'Infinite session test', + 'page callback' => 'fb_infinite_test_page', + 'page arguments' => array(1), + 'access callback' => 'node_access', + 'access arguments' => array('update', 1), + 'type' => MENU_LOCAL_TASK, + ); + + return $items; +} + + +/** + * Implementation of hook_load to create custom loader for hook_menu + * Checks a fb_app nid to see if infinite session is configured + * + * see "Defining your own wildcard loader" - http://drupal.org/node/209056 + * passing $nid not needed if menu_get_object were to work + */ +function fb_infinite_load($nid) { + $fb_app = fb_get_app(array('nid' => $nid)); + if ($fb_app) { + // Only allow menu item if infinite session is configured. + $fb_app_data = fb_app_get_data($fb_app); + $fb_infinite_data = $fb_app_data['fb_infinite']; + if (isset($fb_infinite_data['key'])) { + return $fb_app; } } - return $items; } /** * Implementation of hook_form_alter. */ -function fb_infinite_form_alter($form_id, &$form) { - //drupal_set_message("fb_infinte_form_alter($form_id) " . dpr($form, 1)); +function fb_infinite_form_alter(&$form, &$form_state, $form_id) { + //drupal_set_message("fb_infinite_form_alter($form_id) " . dpr($form, 1)) . dpr($form_state, 1)); // Add our settings to the fb_app edit form. if (is_array($form['fb_app_data'])) { @@ -117,7 +126,7 @@ function fb_infinite_form_alter($form_id function fb_infinite_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { if ($node->type == 'fb_app') { - if ($op == 'submit') { + if ($op == 'presave') { $fb_app_data = $node->fb_app_data; $fb_infinite_data = $fb_app_data['fb_infinite']; @@ -162,14 +171,13 @@ function fb_infinite_display_page() { /** * Menu callback to test infinite session values. */ -function fb_infinite_test_page($nid) { +function fb_infinite_test_page($fb_app) { if ($GLOBALS['fb']) { $url = $GLOBALS['fb_old_base_url'] . "?q=".$_GET['q']; return t('Do not use this page from a canvas page. Try !link.', array('!link' => l($url, $url))); } - - $fb_app = fb_get_app(array('nid' => $nid)); + $fb = fb_api_init($fb_app, FB_FBU_INFINITE_SESSION); $fbu = $fb->api_client->users_getLoggedInUser(); if ($fbu) { @@ -183,20 +191,19 @@ function fb_infinite_test_page($nid) { 'status', )); $info = $info[0]; - $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', NULL, 'id='.$info['uid']); + $fb_link = l($info['name'], 'http://www.facebook.com/profile.php', array('query' => 'id='.$info['uid'])); - drupal_set_message(t('Infinite session key is working.')); + drupal_set_message('Infinite session key is working.'); $output .= '

'.t('Facebook infinite session user: !user', array('!user' => $fb_link)) . '

'; $output .= '

'.t('This page cannot test that the session key will never expire. If your cron jobs start to fail, return here to test the login again.').'

'; return $output; } else { - drupal_set_message(t('Infinite session key test failed.'), 'error'); + drupal_set_message('Infinite session key test failed.', 'error'); // TODO: provide helpful hints of how to fix the problem. $output .= '

'.t('Unable to log into Facebook using infinite session key.').'

'; } return $output; } -?> \ No newline at end of file Index: fb_session.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_session.inc,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_session.inc --- fb_session.inc 7 Apr 2008 20:56:49 -0000 1.1 +++ fb_session.inc 24 May 2008 04:15:27 -0000 @@ -24,4 +24,4 @@ else { // Important: edit the path where includes/session.inc is included so // that it works for your system. -require_once('includes/session.inc'); \ No newline at end of file +require_once('./includes/session.inc'); \ No newline at end of file Index: fb_settings.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_settings.inc,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_settings.inc --- fb_settings.inc 7 Apr 2008 20:56:49 -0000 1.1 +++ fb_settings.inc 24 May 2008 04:15:27 -0000 @@ -4,6 +4,7 @@ define('FB_SETTINGS_APP_NID', 'fb_cb'); define('FB_SETTINGS_PAGE_TYPE', 'fb_cb_type'); +// NOTE: can't use variable_set() -- database.inc hasn't loaded yet, so db_query() in variable_set() fails if (!is_array($conf)) $conf = array(); @@ -44,20 +45,51 @@ if ($nid = _fb_settings_parse_nid()) } /** - * Implementation of conf_url_rewrite + * Implementation of conf_url_rewrite_inbound * * Defines the URL rewrite if not defined already. If it is defined already, - * or your using 118n modules, you should define a custom_url_rewrite in - * settings.php which calls fb_canvas_url_rewrite in addition to any others + * or your using 118n modules, you should define a custom_url_rewrite_inbound in + * settings.php which calls fb_canvas_url_rewrite_inbound in addition to any others * that need to be called. The order will be important! */ -if(!function_exists('custom_url_rewrite')) { - function custom_url_rewrite($type, $path, $original) { - return fb_settings_url_rewrite($type, $path, $original); +//TODO: this needs confirmation. +//custom_url_rewrite was dropped in 6.x so I split the 'source' portion of the old function +//into _inbound and the 'alias' portion into _outbound versions +//really guessing here, but it seems to be working +if(!function_exists('custom_url_rewrite_inbound')) { + function custom_url_rewrite_inbound(&$result, $path, $path_language) { + fb_settings_url_rewrite_inbound($result, $path, $path_language); } } +if(!function_exists('custom_url_rewrite_outbound')) { + function custom_url_rewrite_outbound(&$path, &$options, $original_path) { + fb_settings_url_rewrite_outbound($path, $options, $original_path); + } +} + +//TODO: especially verify this one - not sure what to do with Absolute paths, if anything +//TODO: problem with _fb_canvas_make_form_action_local - is it caused by this? +//TODO: I don't think the fb_canvas_is_fbml() and fb_canvas_is_iframe() functions are returning the right values either +function fb_settings_url_rewrite_outbound(&$path, $options, $original_path) { + if (function_exists('fb_canvas_is_fbml')) { + global $fb_app; + if (fb_canvas_is_iframe()) { + //TODO: do something else? + $path = $fb_app->canvas .'/'. $path; + } + else if (fb_canvas_is_fbml()) { + //if (!$options['absolute']) + //something + //else + $path = $fb_app->canvas .'/'. $path; + // + } + //var_dump(array($path => $options)); + } + return $path; +} /** * Rewrite URLs for facebook canvas pages. @@ -66,58 +98,52 @@ if(!function_exists('custom_url_rewrite' * set when serving canvas pages. However, it gets called before * modules are loaded. So it must live here. */ -function fb_settings_url_rewrite($type, $path, $original){ - //dpm(func_get_args(), 'fb_canvas_url_rewrite'); +function fb_settings_url_rewrite_inbound(&$result, $path, $path_language){ + //$origpath = $path; + //dpm(func_get_args(), 'fb_canvas_url_rewrite_inbound'); + //watchdog('fb_settings', "fb_settings_url_rewrite_inbound($result, $path, $path_language)", array(), WATCHDOG_DEBUG); $prefixes = array(FB_SETTINGS_APP_NID, FB_SETTINGS_PAGE_TYPE); - if ($type == 'source') { - // See if this is a request for us. - if (strpos($path, FB_SETTINGS_APP_NID . '/') === 0) { + + // See if this is a request for us. + if (strpos($path, FB_SETTINGS_APP_NID . '/') === 0) { // Too soon for arg() function. - $args = explode('/', $path); - while (count($args) && in_array($args[0], $prefixes)) { - $key = array_shift($args); - $value = array_shift($args); - fb_settings($key, $value); // Store for use later. + $args = explode('/', $path); + while (count($args) && in_array($args[0], $prefixes)) { + $key = array_shift($args); + $value = array_shift($args); + $app_nid = fb_settings($key, $value); // Store for use later. + } + if ($app_nid = fb_settings(FB_SETTINGS_APP_NID)) { + if (count($args)) { + $path = implode('/', $args); // remaining args + $alias = drupal_lookup_path('source', $path, $path_language); //can't use drupal_get_normal_path, it calls custom_url_rewrite_inbound + if ($alias) + $path = $alias; } - if ($app_nid = fb_settings(FB_SETTINGS_APP_NID)) { - if (count($args)) { - $path = implode('/', $args); // remaining args - $path = drupal_get_normal_path($path); - } - else - // frontpage - $path = drupal_get_normal_path(variable_get('site_frontpage', 'node')); + else { + // frontpage + $path = variable_get('site_frontpage', 'node'); + $alias = drupal_lookup_path('source', $path, $path_language); + if ($alias) + $path = $alias; + $_REQUEST['destination'] = $path; //required workaround for compatibility with Global Redirect module, best practice? } - } + } } - else if ($type == 'alias') { - if (function_exists('fb_canvas_is_fbml')) { - $pre = ''; - if (fb_canvas_is_iframe()) { - // Rewrite for iframes - foreach ($prefixes as $prefix) - if ($value = fb_settings($prefix)) - $pre .= $prefix . '/'. fb_settings($prefix) . '/'; - $path = $pre . $path; - } - else if (fb_canvas_is_fbml()) { - // Rewrite for FBML - //$path = $fb_app->canvas . '/' . $path; // old way - // For now, same as for iframes, but may be different one day - foreach ($prefixes as $prefix) - if ($value = fb_settings($prefix)) - $pre .= $prefix . '/'. fb_settings($prefix) . '/'; - $path = $pre . $path; - } - } + else { //resolve aliases for non-fb-callbacks + $alias = drupal_lookup_path('source', $path, $path_language); + if ($alias) + $path = $alias; } - return $path; + + $result = $path; } function fb_settings($key, $value = NULL) { static $cache = array(); if (isset($value)) $cache[$key] = $value; + return $cache[$key]; } @@ -127,14 +153,12 @@ function fb_settings($key, $value = NULL */ function _fb_settings_parse_nid() { if (isset($_GET['q'])) { - $path = $_GET['q']; - if (strpos($path, FB_SETTINGS_APP_NID . '/') === 0) { - // Too soon for arg() function. - $args = explode('/', $path); - return $args[1]; - } + $path = $_GET['q']; + if (strpos($path, FB_SETTINGS_APP_NID . '/') === 0) { + // Too soon for arg() function. + $args = explode('/', $path); + return $args[1]; + } } } - -?> \ No newline at end of file Index: fb_user.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_user.info,v retrieving revision 1.1 diff -u -u -p -r1.1 fb_user.info --- fb_user.info 26 Sep 2007 17:08:21 -0000 1.1 +++ fb_user.info 24 May 2008 04:15:27 -0000 @@ -1,5 +1,8 @@ name=Facebook User Management description=User handling code. package = Facebook -dependencies = fb fb_app +dependencies[] = fb +dependencies[] = fb_app +core = 6.x +version = "6.x-1.x-dev" Index: fb_user.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_user.install,v retrieving revision 1.3 diff -u -u -p -r1.3 fb_user.install --- fb_user.install 20 May 2008 05:37:52 -0000 1.3 +++ fb_user.install 24 May 2008 04:15:27 -0000 @@ -1,39 +1,37 @@ $db_type)), 'error'); - } - foreach ($query as $q) { - $status = db_query ($q); - if (!$status) { - drupal_set_message(t('Error installing fb_user: %error %query', - array('%query' => '
'.$q.'
', - '%error' => db_error())), - 'error'); - } - } + // Create tables. + drupal_install_schema('fb_user'); +} + + +/** + * Implementation of hook_uninstall(). + */ +function fb_user_uninstall() { + // Remove tables. + drupal_uninstall_schema('fb_user'); +} + + +function fb_user_schema() { + $schema['fb_user_app'] = + array('fields' => array('apikey' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'fbu' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'added' => array('type' => 'int', 'length' => 4, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'time_cron' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'time_access' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + 'session_key' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, ), + 'session_key_expires' => array('type' => 'int', 'length' => 11, 'unsigned' => TRUE, 'not null' => TRUE, ), + ), + 'primary key' => array('apikey', 'fbu'), + ); + return $schema; } function fb_user_update_1() { Index: fb_user.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_user.module,v retrieving revision 1.11 diff -u -u -p -r1.11 fb_user.module --- fb_user.module 20 May 2008 05:37:52 -0000 1.11 +++ fb_user.module 24 May 2008 04:15:27 -0000 @@ -23,26 +23,23 @@ define('FB_USER_SYNC_PATH', 'fb_user/syn define('FB_USER_POST_ADD_PATH', 'fb_user/post_add'); define('FB_USER_POST_REMOVE_PATH', 'fb_user/post_remove'); -function fb_user_menu($may_cache) { - $items = array(); - if ($may_cache) { - global $user; - $items[] = array('path' => FB_USER_SYNC_PATH, - 'access' => $user->uid > 0, // TODO: support anonymous adds - 'callback' => 'fb_user_sync_cb', +function fb_user_menu() { + global $user; + $items[FB_USER_SYNC_PATH] = array( + 'access callback' => $user->uid > 0, // TODO: support anonymous adds + 'page callback' => 'fb_user_sync_cb', 'type' => MENU_CALLBACK, - ); - $items[] = array('path' => FB_USER_POST_ADD_PATH, - 'access' => TRUE, - 'callback' => 'fb_user_post_add_cb', + ); + $items[FB_USER_POST_ADD_PATH] = array( + 'access callback' => TRUE, + 'page callback' => 'fb_user_post_add_cb', 'type' => MENU_CALLBACK, - ); - $items[] = array('path' => FB_USER_POST_REMOVE_PATH, - 'access' => TRUE, - 'callback' => 'fb_user_post_remove_cb', + ); + $items[FB_USER_POST_REMOVE_PATH] = array( + 'access callback' => TRUE, + 'page callback' => 'fb_user_post_remove_cb', 'type' => MENU_CALLBACK, - ); - } + ); return $items; } @@ -140,7 +137,7 @@ function fb_user_post_add_form() { } // And if the user's account is recognized, we can skip this. if ($user->uid && FALSE) { - drupal_goto(""); + drupal_goto(variable_get('site_frontpage', 'node')); //TODO: used to be "" - is this acceptable? exit(); } @@ -168,7 +165,7 @@ function fb_user_post_add_form() { $form['redirect']['frontpage'] = array('#type' => 'radio', '#title' => t('I will register later', $t), '#description' => t('Use this application without registering on %sitename.', $t), - '#return_value' => '', + '#return_value' => variable_get('site_frontpage', 'node'), //TODO: used to be "" - is this acceptable? '#parents' => $parents, ); $form['submit'] = array('#type' => 'submit', @@ -179,11 +176,11 @@ function fb_user_post_add_form() { return $form; } -function fb_user_post_add_form_submit($form_id, $values) { +function fb_user_post_add_form_submit($form, &$form_state) { //dpm(func_get_args(), 'fb_user_post_add_form_submit'); // Here we simply redirect the user to the appropriate page - return $values['redirect']; + return $form_state['values']['redirect']; } /** @@ -193,7 +190,7 @@ function fb_user_post_add_form_submit($f */ function fb_user_post_remove_cb() { global $fb, $fb_app, $user; - watchdog('debug', 'fb_user_post_remove_cb' . dprint_r($_REQUEST, 1) . dprint_r($user, 1) . dprint_r($fb_app, 1)); + watchdog('fb_user', 'fb_user_post_remove_cb'. dprint_r($_REQUEST, 1) . dprint_r($user, 1) . dprint_r($fb_app, 1), array(), WATCHDOG_DEBUG); // Update our database to reflect application is NOT added _fb_user_track($fb, $fb_app, $user); // Nothing to return @@ -212,10 +209,15 @@ function _fb_user_sync_redirect($redirec // so better to generate our own. $key = uniqid('fb_user_'); - cache_set($key, 'cache', serialize($cache_data), CACHE_TEMPORARY); + cache_set($key, serialize($cache_data), 'cache', CACHE_TEMPORARY); // Note that drupal_goto will fail here, but $fb->redirect succeeds. - $fb->redirect(url($redirect, 'auth_token='.$key, NULL, TRUE)); + $fb->redirect(url($redirect, array( + 'query' => 'auth_token='.$key, + 'absolute' => TRUE, + ) + ) + ); exit(); } @@ -232,7 +234,7 @@ function fb_user_sync_cb() { // On canvas pages, require user to add the app... if ($fb) { - watchdog('debug', 'fb_user_sync_cb request ' . dprint_r($_REQUEST, 1)); + watchdog('fb_user', 'fb_user_sync_cb request '. dprint_r($_REQUEST, 1), array(), WATCHDOG_DEBUG); $fb->require_add(); @@ -260,27 +262,27 @@ function fb_user_sync_cb() { drupal_access_denied(); exit(); } - watchdog('debug', 'got the data ' . dprint_r($data, 1)); + watchdog('fb_user', 'got the data '. dprint_r($data, 1), array(), WATCHDOG_DEBUG); $fbu = $data['fbu']; $fb_app = $data['fb_app']; drupal_set_title(t('Added %appname Application', array('%appname' => $fb_app->title))); if ($fbu && $fb_app) { $authname = _fb_user_authname($fb_app, $fbu); - watchdog('fb_user', t('Syncing local user %uid with facebook user %fbu via authmap entry %authname', + watchdog('fb_user', 'Syncing local user %uid with facebook user %fbu via authmap entry %authname', array('%fbu' => $fbu, '%uid' => $user->uid, - '%authname' => $authname))); + '%authname' => $authname)); user_set_authmaps($user, array('authname_fb_user' => $authname)); - watchdog('fb_user', t('Synced local user %uid with facebook user %fbu via authmap entry %authname', + watchdog('fb_user', 'Synced local user %uid with facebook user %fbu via authmap entry %authname', array('%fbu' => $fbu, '%uid' => $user->uid, - '%authname' => $authname))); + '%authname' => $authname)); drupal_set_message(t('Your local account is linked to your Facebook profile.', array('!localurl' => url('user/'.$user->uid), - '!facebookurl' => url('http://www.facebook.com/profile.php', 'id='.$fbu)))); + '!facebookurl' => url('http://www.facebook.com/profile.php', array('query' => 'id='. $fbu))))); // Give the user feedback that the sync has been successful. // Query facebook to learn more about their facebook account. @@ -483,7 +485,7 @@ function fb_user_nodeapi(&$node, $op, $a if (user_access('administer fb apps')) { $fb_app = $node->fb_app; $output = theme('dl', array(t('Post-add URL') => "http://apps.facebook.com/{$fb_app->canvas}/".FB_USER_POST_ADD_PATH."?redirect=", - t('Post-remove URL') => url(FB_SETTINGS_APP_NID .'/'. $node->nid . '/' . FB_USER_POST_REMOVE_PATH, NULL, NULL, TRUE), + t('Post-remove URL') => url(FB_SETTINGS_APP_NID .'/'. $node->nid .'/'. FB_USER_POST_REMOVE_PATH, array('absolute' => TRUE)), t('Add URL') => "http://apps.facebook.com/{$fb_app->canvas}/".FB_USER_SYNC_PATH . '
' . t('(Send an authenticated user to this URL so that local account will be authmapped to facebook account.)'))); $node->content['fb_user'] = array('#value' => $output, '#weight' => 2, @@ -492,7 +494,7 @@ function fb_user_nodeapi(&$node, $op, $a } } -function fb_user_form_alter($form_id, &$form) { +function fb_user_form_alter(&$form, &$form_state, $form_id) { //drupal_set_message("fb_user_form_alter($form_id) " . dpr($form, 1)); // Add our settings to the fb_app edit form. @@ -675,6 +677,14 @@ function fb_user_user($op, &$edit, &$acc } } +function fb_user_theme() { + return array( + 'fb_app_name_with_links' => array( + 'arguments' => array('fb_app', 'is_added' => NULL), + ), + ); +} + function theme_fb_app_name_with_links($fb_app, $is_added = NULL) { $output = $fb_app->title; // TODO add link to about page @@ -764,7 +774,7 @@ function fb_user_create_local_user($fb, $account = user_save('', $user_default); - watchdog('fb_user', t('New user: %name %email.', array('%name' => $name, '%email' => '<'. $mail .'>')), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit')); + watchdog('fb_user', 'New user: %name %email.', array('%name' => $name, '%email' => '<'. $mail .'>'), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit')); // Allow third-party modules to act after account creation. $config = _fb_invoke($fb_app, FB_OP_POST_USER, @@ -773,8 +783,8 @@ function fb_user_create_local_user($fb, // TODO: move this to fb_action. Temporarily disabled. if (FALSE) { // Prepare to send an email. - $base = url('', NULL, NULL, TRUE); - $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!password' => $user_default['pass'], '!uri' => $base, '!uri_brief' => substr($base, strlen('http://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '!login_url' => user_pass_reset_url($account)); + $base = url('', array('absolute' => TRUE)); + $variables = array('!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!password' => $user_default['pass'], '!uri' => $base, '!uri_brief' => substr($base, strlen('http://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', array('absolute' => TRUE)), '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)), '!login_url' => user_pass_reset_url($account)); $subject = _user_mail_text('welcome_subject', $variables); $body = _user_mail_text('welcome_body', $variables); @@ -802,7 +812,7 @@ function fb_user_create_local_user($fb, */ function fb_user_get_local_user($fbu, $fb_app) { // TODO: this query probably needs to search for one authname or the other, not both. - $result = db_query("SELECT am.* FROM authmap am WHERE am.authname='%s' OR am.authname='%s' ORDER BY am.authname", + $result = db_query("SELECT am.* FROM {authmap} am WHERE am.authname='%s' OR am.authname='%s' ORDER BY am.authname", "$fbu-$fb_app->apikey@facebook.com", "$fbu@facebook.com"); if ($data = db_fetch_object($result)) { $account = user_load(array('uid' => $data->uid)); @@ -872,5 +882,3 @@ function fb_user_token_values($type = 'a return $values; } - -?> \ No newline at end of file Index: themes/fb_fbml/fb_fbml.info =================================================================== RCS file: themes/fb_fbml/fb_fbml.info diff -N themes/fb_fbml/fb_fbml.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ themes/fb_fbml/fb_fbml.info 24 May 2008 04:15:27 -0000 @@ -0,0 +1,4 @@ +name = fb_fbml +description = Use on Facebook FBML canvas pages only. +core = 6.x +engine = phptemplate \ No newline at end of file Index: themes/fb_fbml/template.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/fb/themes/fb_fbml/template.php,v retrieving revision 1.8 diff -u -u -p -r1.8 template.php --- themes/fb_fbml/template.php 8 May 2008 02:16:03 -0000 1.8 +++ themes/fb_fbml/template.php 24 May 2008 04:15:27 -0000 @@ -1,21 +1,30 @@ array(), + 'content' => $content, + 'show_blocks' => $show_blocks, + 'show_messages' => $show_messages, + ); + $hook = 'page'; + template_preprocess($variables, $hook); + template_preprocess_page($variables, $hook); + // If any modules implement a preprocess function, they're SOL, we don't know about it. -function fb_fbml_page($content, $show_blocks = TRUE) { - $output = phptemplate_page($content, $show_blocks); + $template_file = path_to_theme() . '/page.tpl.php'; + $output = theme_render_template($template_file, $variables); if (function_exists('fb_canvas_process')) { $output = fb_canvas_process($output); } return $output; - } function _phptemplate_variables($hook, $vars = array()) { global $fb_app, $user; if ($hook == 'page') { - $vars['styles'] = _phptemplate_callback('styles', $vars); + $vars['styles'] = theme_render_template('styles.tpl.php', $vars); // Enforce that only admins see admin block. This can be done (more // cleanly?) elsewhere. But we're doing it here to make sure. @@ -93,6 +102,23 @@ function fb_fbml_regions() { function phptemplate_menu_local_tasks() { global $fb; if ($fb && $fb->in_fb_canvas()) { + $output = ''; + + if ($primary = menu_primary_local_tasks()) { + $output .= "\n". $primary ."\n"; + } + if ($secondary = menu_secondary_local_tasks()) { + // TODO: use fbml for secondary tabs + $output .= "
    \n". $secondary ."
\n"; + } + + } + else + $output = theme_menu_local_tasks(); + + return $output; + + if (FALSE) { // OLD WAY XXX $local_tasks = menu_get_local_tasks(); $pid = menu_get_active_nontask_item(); $output = '';