function disqus_block_view in Disqus 7
Implements hook_block_view().
File
- ./
disqus.module, line 606 - The Disqus Drupal module.
Code
function disqus_block_view($delta = '') {
global $user;
$options = array(
'num_items' => variable_get($delta . '_items', 5),
'avatars' => variable_get($delta . '_showavatars', TRUE) ? array(
'avatar_size' => variable_get($delta . '_avatarsize', 32),
) : array(
'hide_avatars' => 1,
),
'color' => variable_get($delta . '_colortheme', 'blue'),
'default_tab' => variable_get($delta . '_defaulttabview', 'people'),
'excerpt_length' => variable_get($delta . '_excerpt_length', '200'),
'hide_mods' => variable_get($delta . '_hide_mods', FALSE) ? '1' : '0',
'domain' => variable_get('disqus_domain', ''),
);
if (!empty($options['domain'])) {
$subject = '';
$content = '';
switch ($delta) {
case 'disqus_recent_comments':
$subject = t('Recent Comments');
$content = _disqus_block_content('recent_comments_widget', $options);
break;
case 'disqus_popular_threads':
$subject = t('Popular Threads');
$content = _disqus_block_content('popular_threads_widget', $options);
break;
case 'disqus_top_commenters':
$subject = t('Top Commenters');
$content = _disqus_block_content('top_commenters_widget', $options);
break;
case 'disqus_combination_widget':
$subject = t('Comments');
$content = _disqus_block_content('combination_widget', $options);
break;
case 'disqus_comments':
if (variable_get('disqus_location', 'content_area') == 'block' && user_access('view disqus comments')) {
if ($object = menu_get_object()) {
// For nodes, display if the Disqus object is enabled.
if (isset($object->disqus) && $object->disqus['status']) {
$content = array(
'disqus' => array(
'#type' => 'disqus',
'#disqus' => $object->disqus,
),
'#cache' => array(
'bin' => 'cache_block',
'expire' => CACHE_TEMPORARY,
'keys' => array(
'disqus',
'disqus_comments',
'node',
(int) $object->nid,
variable_get('disqus_sso', FALSE) ? 'sso_' . $user->uid : 'no_sso',
user_access('administer blocks') ? 1 : 0,
),
),
);
}
}
else {
if ($object = menu_get_object('user')) {
if (isset($object->disqus)) {
$content = array(
'disqus' => array(
'#type' => 'disqus',
'#disqus' => $object->disqus,
),
'#cache' => array(
'bin' => 'cache_block',
'expire' => CACHE_TEMPORARY,
'keys' => array(
'disqus',
'disqus_comments',
'user',
(int) $object->uid,
variable_get('disqus_sso', FALSE) ? 'sso_' . $user->uid : 'no_sso',
user_access('administer blocks') ? 1 : 0,
),
),
);
}
}
}
}
break;
}
return array(
'subject' => $subject,
'content' => $content,
);
}
}