comment_admin_overview($type = 'new', $arg)
drupal/modules/comment/comment.admin.inc, line 36
Form builder; Builds the comment overview form for the admin.
ingroup forms @see comment_admin_overview_validate() @see comment_admin_overview_submit() @see theme_comment_admin_overview()
$type Not used.
$arg Current path's fourth component deciding the form type (Published comments/Approval queue).
The form structure.
| Name | Description |
|---|---|
| Form builder functions | Functions that build an abstract representation of a HTML form. |
function comment_admin_overview($type = 'new', $arg) {
// Build an 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array();
foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
$options[$key] = $value[0];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'publish',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
// Load the comments that need to be displayed.
$status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
$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('Posted in'), 'field' => 'node_title'),
array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
array('data' => t('Operations')),
));
$result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d' . tablesort_sql($form['header']['#value']), 50, 0, NULL, $status);
// Build a table listing the appropriate comments.
$destination = drupal_get_destination();
while ($comment = db_fetch_object($result)) {
$comments[$comment->cid] = '';
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
$form['subject'][$comment->cid] = array(
'#markup' => l($comment->subject, 'node/' . $comment->nid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid))
);
$form['username'][$comment->cid] = array(
'#markup' => theme('username', $comment)
);
$form['node_title'][$comment->cid] = array(
'#markup' => l($comment->node_title, 'node/' . $comment->nid)
);
$form['timestamp'][$comment->cid] = array(
'#markup' => format_date($comment->timestamp, 'small')
);
$form['operations'][$comment->cid] = array(
'#markup' => l(t('edit'), 'comment/edit/' . $comment->cid, array('query' => $destination))
);
}
$form['comments'] = array(
'#type' => 'checkboxes',
'#options' => isset($comments) ? $comments: array()
);
$form['pager'] = array(
'#markup' => theme('pager', NULL, 50, 0)
);
return $form;
}