function salesforce_admin_page in Salesforce Suite 5
admin page for viewing the salesforce_logs table
1 string reference to 'salesforce_admin_page'
- salesforce_menu in ./
salesforce.module - Implementation of hook_menu().
File
- ./
salesforce.module, line 308 - Original Creator, Maintainer & Developer: Steve McKenzie (http://drupal.org/user/45890) Drupal and Salesforce.com (mainly only working with contacts / leads but can be extended to do anything the salesforce API version 6 can do) Current…
Code
function salesforce_admin_page() {
theme('add_style', drupal_get_path('module', 'salesforce') . '/salesforce.css');
// in 4.7 was arg(2), now arg(3) works!
$op = arg(3);
if ($op) {
$breadcrumb = drupal_get_breadcrumb();
$breadcrumb[] = l(t('salesforce'), 'admin/salesforce');
drupal_set_breadcrumb($breadcrumb);
drupal_set_title(t('SalesForce - %op', array(
'%op' => ucfirst($op) . 's',
)));
switch ($op) {
default:
$output .= _salesforce_admin_list($op);
break;
break;
}
}
else {
drupal_set_title(t('SalesForce'));
$result = db_query("SELECT sid, type, type_id, message, timestamp, status FROM {salesforce_log} ORDER BY timestamp DESC");
$total = db_num_rows($result);
$output .= '<p>' . t('All tasks that were not completed successfully are logged and displayed here. If you have a cron job setup to use drupal\'s cron.php, these logged items will be attempted again on cron run.') . '</p>' . "\n";
if ($total > 0) {
// table columns (damn these big ass arrays kinda bug me)
$cols = array(
array(
'data' => t('ID'),
'class' => 'id',
),
t('type'),
t('user'),
array(
'data' => 'message',
'class' => 'message',
),
t('date'),
array(
'data' => t('status'),
'class' => 'status',
),
array(
'data' => t('operations'),
'class' => 'op',
),
);
while ($row = db_fetch_object($result)) {
if ($row->status) {
$state = 'active';
}
else {
$state = 'completed';
}
// this row kinda looks nasty but ya.. here it is
$rows[] = array(
'class' => $state,
'data' => array(
$row->sid,
str_replace('_', ' ', $row->type),
theme('username', user_load(array(
'uid' => $row->type_id,
))),
$row->message,
format_date(strtotime($row->timestamp), 'large'),
$state,
($row->status ? l(t('run'), 'admin/salesforce/log/run/' . $row->sid) . ' | ' . l(t('disable'), 'admin/salesforce/log/disable/' . $row->sid, array(
'onclick' => 'if (confirm("' . t('are you sure you want to disable this log?') . '")) { return true; } else { return false; }',
)) . ' | ' : l(t('enable'), 'admin/salesforce/log/enable/' . $row->sid) . ' | ') . l(t('delete'), 'admin/salesforce/log/delete/' . $row->sid, array(
'onclick' => 'if (confirm("' . t('are you sure you want to delete this log?') . '")) { return true; } else { return false; }',
)),
),
);
}
$rows[] = array(
array(
'class' => 'total',
'colspan' => 7,
'data' => t('<strong>Total:</strong> %total', array(
'%total' => $total,
)),
),
);
$output .= theme('table', $cols, $rows, array(
'class' => 'salesforce_admin',
));
}
else {
$output .= '<p><strong>' . t('currently no logged items') . '</strong></p>' . "\n";
}
}
print theme('page', $output);
}