function fb_connect_block_view in Drupal for Facebook 7.3
Same name and namespace in other branches
- 7.4 fb_connect.module \fb_connect_block_view()
File
- ./
fb_connect.module, line 258 - Support for Facebook Connect features
Code
function fb_connect_block_view($delta = '') {
if (!fb_is_tab()) {
// Hide block on tabs, where the $fbu is actually the page, not the user.
if (strpos($delta, 'login_') === 0) {
// Login block
$label = substr($delta, 6);
// length of 'login_'
$fb_app = fb_get_app(array(
'label' => $label,
));
if ($fb_app && ($fb = fb_connect_app_init($fb_app))) {
$fbu = $fb
->getUser();
//_fb_connect_add_js($fb_app); moved to fb_connect_app_init()
$base = drupal_get_path('module', 'fb_connect');
$defaults = variable_get('fb_connect_block_' . $delta, _fb_connect_block_login_defaults());
if (!$fbu && $GLOBALS['user']->uid >= 1) {
// Render only logged in user markup.
$subject = $defaults['user_not_connected']['title'];
$content = $defaults['user_not_connected']['body']['value'];
$format = $defaults['user_not_connected']['body']['format'];
$subject_connected = NULL;
$content_connected = NULL;
}
else {
// Render both connected and not connected markup.
$subject = $defaults['anon_not_connected']['title'];
$content = $defaults['anon_not_connected']['body']['value'];
$format = $defaults['anon_not_connected']['body']['format'];
$subject_connected = $defaults['connected']['title'];
$content_connected = $defaults['connected']['body']['value'];
$content_connected = str_replace('!fbu', 'loggedinuser', $content_connected);
// support deprecated !fbu
}
// substitute fbu
$content = str_replace('!fbu', $fbu, $content);
// substitute perms
$perms = array();
drupal_alter('fb_required_perms', $perms);
$content = str_replace('!perms', implode(',', $perms), $content);
// Filter output according to settings in block configuration
$subject = check_plain($subject);
if ($format) {
$content = check_markup($content, $format, '', FALSE);
}
if ($subject_connected !== NULL) {
$subject_connected = check_plain($subject_connected);
if ($format_connected = $defaults['connected']['body']['format']) {
$content_connected = check_markup($content_connected, $format_connected, FALSE);
}
}
$block = array(
// Theme fb_markup uses javascript to show/hide the right markup.
'subject' => theme('fb_markup', array(
'not_connected' => $subject,
'connected' => $subject_connected,
)),
'content' => theme('fb_markup', array(
'not_connected' => $content,
'connected' => $content_connected,
)),
);
return $block;
}
}
}
}