function fbconnect_block in Facebook Connect 6
Same name and namespace in other branches
- 5 fbconnect.module \fbconnect_block()
Implementation of hook_block().
File
- ./
fbconnect.module, line 116
Code
function fbconnect_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Fbconnect friend');
$blocks[0]['cache'] = BLOCK_NO_CACHE;
return $blocks;
case 'view':
$fbuid = fbconnect_get_fbuid(true);
if (user_is_logged_in() && $fbuid) {
$cid = 'fbconnect:' . $fbuid;
$cached = cache_get($cid, 'cache_block');
if ($cached->data) {
$content = $cached->data;
}
else {
$friends = fbconnect_get_connected_friends($fbuid);
if ($friends) {
foreach ($friends as $friend) {
$row[] = theme('username', $friend);
}
$content = theme('item_list', $row);
cache_set($cid, $content, 'cache_block', time() + 3600);
}
}
$blocks['subject'] = t('Facebook friends');
$blocks['content'] = l(t('Invite friends'), 'fbconnect/invite/friends') . $content;
return $blocks;
}
break;
}
}