Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's a fix for the trackback_spam_admin_overview function, which is broken in the current CVS version. This also implements a 'check / uncheck all' button, as per my issue http://drupal.org/node/66623.
Simply replace the existing trackback_spam_admin_overview function declaration in trackback.module with this one:
/**
* Menu callback; present an administrative spam trackback listing.
*/
function trackback_spam_admin_overview($type = 'new') {
$spam_module_exists = module_exist('spam');
$operations = array();
if (module_exist('spam')) {
$operations['spam_spam_trackback'] = t('Mark the selected trackbacks as spam');
$operations['spam_notspam_trackback'] = t('Mark the selected trackbacks as not spam');
}
$operations['spam_publish_trackback'] = t('Publish the selected trackbacks');
if (module_exist('spam')) {
$operations['spam_delete_trackback'] = t('Delete the selected trackbacks (no confirmation)');
}
else {
$operations['trackback_delete'] = t('Delete the selected trackbacks (no confirmation)');
}
if ($op = $_POST['op']) {
$edit = $_POST['edit'];
if ($op == t('Update trackbacks') && isset($edit['operation']) && isset($edit['status']) && isset($operations[$edit['operation']])) {
$function = $edit['operation'];
foreach ($edit['status'] as $trid => $value) {
if ($value) {
$function($trid);
}
}
drupal_set_message(t('The update has been performed.'));
}
}
$status = ($type == 'approval') ? 0 : 1;
$sql = 'SELECT tr.*, s.probability FROM {trackback_received} tr LEFT JOIN {spam_tracker} s ON tr.trid = s.id WHERE s.source = \'trackback\' AND s.probability >= 80';
$sql .= tablesort_sql(trackback_admin_table_header($spam_module_exists));
$result = pager_query($sql, 50);
$form = array();
$form['trackbacks'] = array('#theme' => 'trackback_admin_table');
$form['trackbacks']['spam_module_exists'] = array('#type' => 'value', '#value' => $spam_module_exists);
$form['trackbacks']['status'] = array('#tree' => TRUE);
while ($trackback = db_fetch_object($result)) {
# $form['trackbacks']['status'] = array('#tree' => TRUE);
$form['trackbacks']['status'][$trackback->trid] = array('#type' => 'checkbox');
$form['trackbacks'][$trackback->trid] = array();
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => l($trackback->subject, $trackback->status ? 'node/'. $trackback->nid : 'admin/trackback/edit/'. $trackback->trid, array('title' => truncate_utf8($trackback->excerpt, 128)), NULL, $trackback->status ? 'trackback-'. $trackback->trid : NULL) .' '. theme('mark', node_mark($trackback->nid, $trackback->created)));
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => theme('username', $trackback));
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => $trackback->site);
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => $trackback->status != 0 ? t('Published') : t('Not published'));
if ($spam_module_exists) {
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => $trackback->probability >= variable_get('spam_threshold', 80) ? t('Spam') : t('Not Spam'));
}
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => format_date($trackback->created, 'small'));
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => l(t('edit'), 'admin/trackback/edit/'. $trackback->trid));
$form['trackbacks'][$trackback->trid][] = array('#type' => 'value', '#value' => l(t('delete'), 'admin/trackback/delete/'. $trackback->trid));
}
$form['checkall'] = array(
'#type' => 'fieldset',
'#title' => t('Check / uncheck all')
);
$form['checkall']['operation'] = array(
'#prefix' => '<script type="text/javascript">
function checkUncheckAll(theElement) {
//documentation for this script at http://www.shawnolson.net/a/693/
var theForm = document.getElementById(\'trackback_admin_overview\'), z = 0;
while (theForm[z].name != \'checkall\') {
if (theForm[z].type == \'checkbox\') {
theForm[z].checked = theElement.checked;
}
z++;
}
}
</script>',
'#type' => 'checkbox',
'#attributes' => array('onclick' => 'checkUncheckAll(this);'),
'#default_value' => 0,
'#title' => t('Check / uncheck all items in the list')
);
# $form[] = array('#type' => 'markup', '#value' => theme('pager', NULL, 50, 0));
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
$form['update'] = array(
'#type' => 'fieldset',
'#title' => t('Update options')
);
$form['update']['operation'] = array(
'#prefix' => '<div class="container-inline">',
'#type' => 'select',
'#default_value' => 0,
'#options' => $operations
);
$form['update']['op'] = array(
'#type' => 'submit',
'#value' => t('Update trackbacks'),
'#suffix' => '</div>'
);
return drupal_get_form('trackback_admin_overview', $form);
}
Comments
Comment #1
handelaar CreditAttribution: handelaar commented