function fb_infinite_form_alter in Drupal for Facebook 5.2
Same name and namespace in other branches
- 5 fb_infinite.module \fb_infinite_form_alter()
Implementation of hook_form_alter.
File
- ./
fb_infinite.module, line 65 - This module manages an infinite session for each Facebook App. http://wiki.developers.facebook.com/index.php/Infinite_session_keys
Code
function fb_infinite_form_alter($form_id, &$form) {
//drupal_set_message("fb_infinte_form_alter($form_id) " . dpr($form, 1));
// Add our settings to the fb_app edit form.
if (is_array($form['fb_app_data'])) {
$node = $form['#node'];
$fb_app_data = fb_app_get_data($node->fb_app);
$fb_infinite_data = $fb_app_data['fb_infinite'];
$form['fb_app_data']['fb_infinite'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Facebook infinite session settings'),
'#description' => t('An infinite session key is required to access the Facebook API from non-canvas pages. For example, a cron job.'),
);
if (!$node->nid) {
// User must save apikey and secret before we can prompt for infinite session key.
$form['fb_app_data']['fb_infinite']['message'] = array(
'#value' => '<p>' . t('Save your apikey and secret settings first. Then return here to set up the infinite session.') . '</p>',
);
}
else {
if ($node->fb_app->canvas) {
$form['fb_app_data']['fb_infinite']['help'] = array(
'#value' => t('<a href=!url target=_blank>Get your session key</a>. If prompted to log in, be sure to check the box that prevents your session from expiring.', array(
'!url' => "http://apps.facebook.com/" . $node->fb_app->canvas . "/fb/infinite/display",
)),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
else {
$form['fb_app_data']['fb_infinite']['help'] = array(
'#value' => t('Configure canvas pages for additional help generating an infinite session key.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
$form['fb_app_data']['fb_infinite']['fbu'] = array(
'#type' => textfield,
'#title' => t('Facebook User ID'),
'#default_value' => $fb_infinite_data['fbu'],
);
$form['fb_app_data']['fb_infinite']['key'] = array(
'#type' => textfield,
'#title' => t('Infinite Session Key'),
'#default_value' => $fb_infinite_data['key'],
);
/* so far, I can't get this to work.
$form['fb_app_data']['fb_infinite']['code'] =
array('#type' => textfield,
'#title' => t('One-time code'),
'#description' => t('Get a one-time code from facebook, <a href=!url target=_blank>here</a>.',
array('!url' => "http://www.facebook.com/code_gen.php?v=1.0&api_key=" . $node->fb_app->apikey)),
);
*/
}
}
}