function fb_tab_config_form in Drupal for Facebook 6.3
Same name and namespace in other branches
- 7.3 fb_tab.module \fb_tab_config_form()
Build the tab config form. Invokes hook_fb_tab() to get the custom settings.
1 string reference to 'fb_tab_config_form'
- fb_tab_menu in ./
fb_tab.module
File
- ./
fb_tab.module, line 283 - This module provides support for "Profile Tabs" that can be added to facebook pages (no longer allowed for user profiles).
Code
function fb_tab_config_form($form_state, $profile_id) {
$fb_app = $GLOBALS['_fb_app'];
$fb = $GLOBALS['_fb'];
$config = fb_tab_get_page_config($fb_app, $profile_id);
$sr = $fb
->getSignedRequest();
$data = array(
'fb_app' => $fb_app,
'fb' => $fb,
'profile_id' => $profile_id,
'config' => isset($config['data']) ? $config['data'] : NULL,
'page' => $sr['page'],
);
try {
//$fbu = fb_facebook_user($fb);
$fbu = fb_require_authorization($fb);
$page_info = $fb
->api($profile_id, array(
'access_token' => fb_get_token($fb),
));
$admin_info = fb_fql_query($fb, "SELECT uid, type FROM page_admin WHERE uid={$fbu} AND page_id={$profile_id}");
// FQL not SQL, no {curly_brackets}
//dpm($admin_info, __FUNCTION__);
// @TODO: if not page admin, prompt user to login or deny access.
$form = array(
'info' => array(
'#type' => 'markup',
'#value' => t('Tab settings for <a href="!href">%page</a>', array(
'!href' => $page_info['link'],
'%page' => $page_info['name'],
)),
'#prefix' => '<h3>',
'#suffix' => '</h3>',
'#weight' => -99,
),
'label' => array(
'#type' => 'value',
'#value' => $fb_app->label,
),
'profile_id' => array(
'#type' => 'value',
'#value' => $profile_id,
),
'data' => array(
// Modules will add their fields here.
'#tree' => TRUE,
),
'submit' => array(
'#type' => 'submit',
'#value' => t('Submit'),
'#weight' => 90,
),
);
if (isset($config['fb_tab_id'])) {
$form['fb_tab_id'] = array(
'#type' => 'value',
'#value' => $config['fb_tab_id'],
);
}
$form['data'] = fb_invoke(FB_TAB_OP_FORM, $data, $form['data'], FB_TAB_HOOK);
//print('<pre>' . print_r($data, 1) . '</pre>'); flush();
//print(print_r($content, 1)); flush();
return $form;
} catch (Exception $e) {
fb_log_exception($e, t('Failed to get details for facebook page %profile_id', array(
'%profile_id' => $profile_id,
)));
return array(
'error' => array(
'#value' => t('Unable to set properties.'),
),
);
}
}