function forward_reporting in Forward 7.3
Callback function for log reporting
1 string reference to 'forward_reporting'
- forward_menu in ./
forward.module - Implements hook_menu().
File
- ./
forward.module, line 1157 - Allows forwarding of entities by email, and provides a record of how often each has been forwarded.
Code
function forward_reporting() {
$output = array();
$output['forward_totals'] = array(
'#markup' => '<p><strong>' . variable_get('forward_total', 0) . '</strong> ' . t('emails sent to') . ' <strong>' . variable_get('forward_recipients', 0) . '</strong> ' . t('recipients') . '</p>',
);
/**
* Most Forwarded Nodes
*/
$output['forward_most_heading'] = array(
'#markup' => '<h2>' . t('Most Forwarded Nodes') . '</h2>',
);
$rows = array();
$header = array(
array(
'data' => t('Title'),
),
array(
'data' => t('Path'),
),
array(
'data' => t('Forwards'),
),
array(
'data' => t('Clickthroughs'),
),
);
$result = db_query_range("SELECT n.title, f.* FROM {forward_statistics} f JOIN {node} n ON f.id = n.nid and f.type = 'node' ORDER BY f.forward_count DESC", 0, 10);
$num_rows = FALSE;
foreach ($result as $log) {
$num_rows = TRUE;
$_path = drupal_get_path_alias('node/' . $log->id);
$title = $log->id ? $log->title : 'Front Page';
$rows[] = array(
l(_forward_column_width($title), $_path),
l($_path, $_path),
$log->forward_count,
$log->clickthrough_count,
);
}
$output['forward_most_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No statistics available.'),
);
$output['forward_most_pager'] = array(
'#theme' => 'pager',
);
/**
* Most Clickthroughs
*/
$output['forward_clickthroughs_heading'] = array(
'#markup' => '<h2>' . t('Most Clickthroughs To Nodes') . '</h2>',
);
$rows = array();
$header = array(
array(
'data' => t('Title'),
),
array(
'data' => t('Path'),
),
array(
'data' => t('Forwards'),
),
array(
'data' => t('Clickthroughs'),
),
);
$result = db_query_range("SELECT n.title, f.* FROM {forward_statistics} f JOIN {node} n ON f.id = n.nid and f.type = 'node' ORDER BY f.clickthrough_count DESC", 0, 10);
$num_rows = FALSE;
foreach ($result as $log) {
$num_rows = TRUE;
$_path = drupal_get_path_alias('node/' . $log->id);
$title = $log->id ? $log->title : 'Front Page';
$rows[] = array(
l(_forward_column_width($title), $_path),
l($_path, $_path),
$log->forward_count,
$log->clickthrough_count,
);
}
$output['forward_clickthroughs_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No statistics available.'),
);
$output['forward_clickthroughs_pager'] = array(
'#theme' => 'pager',
);
/**
* Recently Forwarded Pages
*/
$output['forward_recent_heading'] = array(
'#markup' => '<h2>' . t('Recent Forward Activity') . '</h2><p>' . t('SENT = email sent, REF = email clickthrough') . '</p>',
);
$rows = array();
$header = array(
array(
'data' => t('Time'),
'field' => 'timestamp',
'sort' => 'desc',
),
array(
'data' => t('Type'),
'field' => 'type',
),
array(
'data' => t('Path'),
'field' => 'path',
),
array(
'data' => t('User ID'),
'field' => 'uid',
),
array(
'data' => t('Hostname'),
'field' => 'hostname',
),
);
$query = db_select('forward_log', 'f', array(
'target' => 'slave',
))
->extend('PagerDefault')
->extend('TableSort');
$query
->innerJoin('users', 'u', 'f.uid = u.uid');
$query
->fields('f', array(
'timestamp',
'type',
'path',
'uid',
'hostname',
))
->fields('u', array(
'name',
))
->limit(30)
->orderByHeader($header);
$result = $query
->execute();
$num_rows = FALSE;
foreach ($result as $log) {
$num_rows = TRUE;
$_path = drupal_get_path_alias($log->path);
$rows[] = array(
array(
'data' => format_date($log->timestamp, 'short'),
'nowrap' => 'nowrap',
),
$log->type,
l($_path, $_path),
l($log->name, 'user/' . $log->uid),
$log->hostname,
);
}
$output['forward_recent_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => t('No statistics available.'),
);
$output['forward_recent_pager'] = array(
'#theme' => 'pager',
);
drupal_set_title(t('Forward Tracking'));
return $output;
}