function forward_block in Forward 5
Same name and namespace in other branches
- 6 forward.module \forward_block()
Implementation of hook_block().
File
- ./
forward.module, line 951
Code
function forward_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Most Emailed');
return $blocks;
case 'configure':
$block_options = array(
/*'today' => t('Most Emailed Today'),
'week' => t('Most Emailed This Week'),*/
'allTime' => t('Most Emailed of All Time'),
'recent' => t('Most Recently Emailed'),
);
$form['forward_block_type'] = array(
'#type' => 'radios',
'#title' => t('Block Type'),
'#default_value' => variable_get('forward_block_type', " "),
'#options' => $block_options,
'#description' => t('Choose the block type'),
'#required' => true,
);
return $form;
case 'save':
variable_set('forward_block_type', $edit['forward_block_type']);
break;
case 'view':
if (user_access('access content')) {
switch (variable_get('forward_block_type', 'allTime')) {
/*case 'today':
$pastday = time()-(24 * 60 * 60);
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastday .' GROUP BY n.nid, n.title ORDER BY cnt DESC';
$block['subject'] = t("Today's Most Emailed");
$block['content'] = node_title_list(db_query_range($query, 0, 5));
break;
case 'week':
$pastweek = time()-(7 * 24 * 60 * 60);
$query="SELECT n.nid, n.title, count(*) AS cnt FROM {forward_log} s LEFT JOIN {node} n ON s.nid = n.nid WHERE s.type='sent' AND n.status=1 AND timestamp > ". $pastweek .' GROUP BY n.nid, n.title ORDER BY cnt DESC';
$block['subject'] = t("This Week's Most Emailed");
$block['content'] = node_title_list(db_query_range($query, 0, 5));
break;*/
case 'allTime':
$query = "SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid WHERE forward_count > 0 ORDER BY f.clickthrough_count DESC";
$block['subject'] = t("Most Emailed");
$block['content'] = node_title_list(db_query_range($query, 0, 5));
break;
case 'recent':
$query = "SELECT n.nid, n.title, f.* FROM {forward_statistics} f LEFT JOIN {node} n ON f.nid = n.nid ORDER BY f.last_forward_timestamp DESC";
$block['subject'] = t("Most Recently Emailed");
$block['content'] = node_title_list(db_query_range($query, 0, 5));
break;
}
return $block;
}
}
}