--- trackback.module 2006-04-22 11:26:12.000000000 +0100 +++ trackback.m0dule 2006-06-05 15:39:33.000000000 +0100 @@ -402,12 +402,13 @@ } $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))); @@ -421,8 +422,30 @@ $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' => '', + '#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', @@ -442,6 +465,8 @@ return drupal_get_form('trackback_admin_overview', $form); } + + function trackback_admin_table_header($spam_module_exists) { $header = array(); $header[] = array('data' => ''); @@ -719,75 +744,103 @@ } -function trackback_spam_admin_overview() { - drupal_set_title('spam trackbacks'); - $operations = array( - array(t('Mark the selected trackbacks as not spam'), 'spam_notspam_trackback'), - array(t('Unpublish the selected trackbacks'), 'spam_unpublish_trackback'), - array(t('Publish the selected trackbacks'), 'spam_publish_trackback'), - array(t('Delete the selected trackbacks (no confirmation)'), 'spam_delete_trackback') - ); - - $op = $_POST['op']; - - if ($op == t('Update trackbacks') && isset($_POST['edit']['operation']) && isset($_POST['edit']['status'])) { - $function = $operations[$_POST['edit']['operation']][1]; - foreach ($_POST['edit']['status'] as $trid => $value) { - if ($value) { - $function($trid); - } - } +function trackback_spam_admin_overview($type = 'new') { + $spam_module_exists = module_exist('spam'); - drupal_set_message(t('The update has been performed.')); + $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)'); } - $header = array( - array('data' => t('Select')), - array('data' => t('Subject'), 'field' => 'tr.subject'), - array('data' => t('Author'), 'field' => 'tr.name'), - array('data' => t('Host'), 'field' => 'tr.site'), - array('data' => t('Status'), 'field' => 'tr.status'), - array('data' => t('Time'), 'field' => 'tr.created', 'sort' => 'desc'), - array('data' => t('Operations'), 'colspan' => 2) - ); - - $sql = "SELECT tr.*, s.probability FROM {spam_tracker} s INNER JOIN {trackback_received} tr ON s.id = tr.trid WHERE s.source = 'trackback' AND s.probability >= 80"; - $sql .= tablesort_sql($header); - $result = pager_query($sql, 50); - - // Make sure the update controls are disabled if we don't have any rows - // to select from. - $disabled = !db_num_rows($result); + 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); + } + } - $options = array(); - foreach ($operations as $key => $value) { - $options[] = $value[0]; + drupal_set_message(t('The update has been performed.')); + } } - $form = form_select(NULL, 'operation', 0, $options, NULL, ($disabled ? 'disabled="disabled"' : '')); - $form .= form_submit(t('Update trackbacks'), 'op', ($disabled ? array('disabled' => 'disabled') : array())); - - $output .= form_group(t('Update options'), "