function antispam_moderation_form in AntiSpam 6
Same name and namespace in other branches
- 7 antispam.admin.inc \antispam_moderation_form()
1 string reference to 'antispam_moderation_form'
- antispam_callback_queue in ./
antispam.admin.inc - Menu callback; Moderation queue.
File
- ./
antispam.admin.inc, line 663
Code
function antispam_moderation_form(&$form_state, $mode = '', $submode = '', $sql = array()) {
drupal_add_js('misc/tableselect.js');
// Build the moderation queue form.
$form = array();
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Moderator actions'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$form['#theme'] = 'antispam_moderation_form';
extract($sql);
$options = array(
'' => t('<select operation>'),
);
foreach (antispam_moderator_operations($mode, $submode) as $key => $operation_info) {
$options[$key] = $operation_info['title'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => '',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Moderate'),
);
if ($mode == 'nodes') {
$sql_stmt = str_replace('%cond', $sql_nodes_cond[$submode], $sql_nodes_stmt);
$sql_cnt = str_replace('%cond', $sql_nodes_cond[$submode], $sql_nodes_cnt);
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
$form['header'] = array(
'#type' => 'value',
'#value' => array(
theme('table_select_header_cell'),
array(
'data' => t('Title'),
'field' => 'title',
),
array(
'data' => t('Type'),
'field' => 'type',
),
array(
'data' => t('Author'),
'field' => 'name',
),
array(
'data' => t('Status'),
'field' => 'status',
),
array(
'data' => t('Spaminess'),
'field' => 'spaminess',
'sort' => 'desc',
),
array(
'data' => t('Last changed'),
'field' => 'changed',
'sort' => 'desc',
),
),
);
}
else {
$form['header'] = array(
'#type' => 'value',
'#value' => array(
theme('table_select_header_cell'),
array(
'data' => t('Title'),
'field' => 'title',
),
array(
'data' => t('Type'),
'field' => 'type',
),
array(
'data' => t('Author'),
'field' => 'name',
),
array(
'data' => t('Status'),
'field' => 'status',
),
array(
'data' => t('Last changed'),
'field' => 'changed',
'sort' => 'desc',
),
),
);
}
}
else {
// comments
$sql_stmt = str_replace('%cond', $sql_comments_cond[$submode], $sql_comments_stmt);
$sql_cnt = str_replace('%cond', $sql_comments_cond[$submode], $sql_comments_cnt);
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
$form['header'] = array(
'#type' => 'value',
'#value' => array(
theme('table_select_header_cell'),
array(
'data' => t('Subject'),
'field' => 'subject',
),
array(
'data' => t('Author'),
'field' => 'name',
),
array(
'data' => t('Status'),
'field' => 'status',
),
array(
'data' => t('Spaminess'),
'field' => 'spaminess',
'sort' => 'desc',
),
array(
'data' => t('Last changed'),
'field' => 'timestamp',
'sort' => 'desc',
),
),
);
}
else {
$form['header'] = array(
'#type' => 'value',
'#value' => array(
theme('table_select_header_cell'),
array(
'data' => t('Subject'),
'field' => 'subject',
),
array(
'data' => t('Author'),
'field' => 'name',
),
array(
'data' => t('Status'),
'field' => 'status',
),
array(
'data' => t('Last changed'),
'field' => 'timestamp',
'sort' => 'desc',
),
),
);
}
}
$records_per_page = variable_get('antispam_records_per_page', 50);
$result = pager_query($sql_stmt . tablesort_sql($form['header']['#value']), $records_per_page, 0, $sql_cnt);
$items = array();
$now = time();
while ($content = db_fetch_object($result)) {
if ($mode == 'nodes') {
$items[$content->nid] = '';
$form['title'][$content->nid] = array(
'#value' => l($content->title, 'node/' . $content->nid, array(
'attributes' => array(
'title' => truncate_utf8($content->body, BODY_TOOLTIP_LEN),
),
)) . ' ' . theme('mark', node_mark($content->nid, $content->changed)),
);
$form['type'][$content->nid] = array(
'#value' => node_get_types('name', $content),
);
$form['author'][$content->nid] = array(
'#value' => theme('username', $content),
);
$form['status'][$content->nid] = array(
'#value' => $content->status ? t('published') : t('not published'),
);
if ($content->spam_mark) {
$form['status'][$content->nid]['#value'] .= '/' . t('spam');
}
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
$form['spaminess'][$content->nid] = array(
'#type' => 'markup',
'#value' => _antispam_spaminess_bar($content->spaminess),
);
}
$form['created'][$content->nid] = array(
'#value' => t('%time ago', array(
'%time' => format_interval($now - $content->changed),
)),
);
}
else {
// comments
$items[$content->cid] = '';
$content->name = $content->uid ? $content->registered_name : $content->name;
$form['title'][$content->cid] = array(
'#value' => l($content->subject, 'node/' . $content->nid, array(
'attributes' => array(
'title' => truncate_utf8($content->comment, BODY_TOOLTIP_LEN),
),
'fragment' => 'comment-' . $content->cid,
)) . ' ' . theme('mark', node_mark($content->cid, $content->timestamp)),
);
$form['author'][$content->cid] = array(
'#value' => theme('username', $content),
);
$form['status'][$content->cid] = array(
'#value' => $content->status == COMMENT_PUBLISHED ? t('published') : t('not published'),
);
if ($content->spam_mark) {
$form['status'][$content->cid]['#value'] .= '/' . t('spam');
}
if (antispam_get_service_provider() == DEFENSIO_SERVICE) {
$form['spaminess'][$content->cid] = array(
'#type' => 'markup',
'#value' => _antispam_spaminess_bar($content->spaminess),
);
}
$form['created'][$content->cid] = array(
'#value' => t('%time ago', array(
'%time' => format_interval($now - $content->timestamp),
)),
);
}
}
$form['mode'] = array(
'#type' => 'hidden',
'#value' => $mode,
);
$form['submode'] = array(
'#type' => 'hidden',
'#value' => $submode,
);
$form['items'] = array(
'#type' => 'checkboxes',
'#options' => $items,
);
$form['pager'] = array(
'#value' => theme('pager', NULL, $records_per_page, 0),
);
return $form;
}