function forward_block_view in Forward 7.2
Same name and namespace in other branches
- 7.3 forward.module \forward_block_view()
- 7 forward.module \forward_block_view()
Implements hook_block_view().
File
- ./
forward.module, line 1370
Code
function forward_block_view($delta) {
switch ($delta) {
case 'stats':
if (user_access('access content')) {
$block = array();
$query = db_select('forward_statistics', 'f');
$query
->leftJoin('node', 'n', 'f.nid = n.nid');
$query
->fields('f');
$query
->fields('n', array(
'nid',
'title',
));
$query
->range(0, 5);
$query
->addTag('node_access');
switch (variable_get('forward_block_type', 'allTime')) {
case 'allTime':
$query
->condition('f.forward_count', 0, '>');
$query
->orderBy('f.forward_count', 'DESC');
$block['subject'] = t("Most Emailed");
$block['content'] = node_title_list($query
->execute());
break;
case 'recent':
$query
->orderBy('f.last_forward_timestamp', 'DESC');
$block['subject'] = t("Most Recently Emailed");
$block['content'] = node_title_list($query
->execute());
break;
}
return $block;
}
break;
case 'form':
if (user_access('access forward')) {
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$node = node_load(arg(1));
if (!variable_get('forward_display_' . $node->type, 1)) {
return array();
}
}
else {
$node = NULL;
}
if (variable_get('forward_block_form', 'link') == 'link') {
$content = theme('forward_link', array(
'node' => $node,
'block' => TRUE,
));
}
else {
if ($node) {
$content = drupal_get_form('forward_form', 'node/' . $node->nid, $node);
}
else {
$content = drupal_get_form('forward_form', $_GET['q']);
}
}
return array(
'subject' => t('Forward'),
'content' => $content,
);
}
}
}