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;
$header = array(
'subject' => array('data' => t('Subject'), 'field' => 'subject'),
'author' => array('data' => t('Author'), 'field' => 'name'),
'posted_in' => array('data' => t('Posted in'), 'field' => 'node_title'),
'time' => array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
'operations' => array('data' => t('Operations')),
);
$query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
$query->join('users', 'u', 'u.uid = c.uid');
$query->join('node', 'n', 'n.nid = c.nid');
$query->addField('u', 'name', 'registered_name');
$query->addField('n', 'title', 'node_title');
$result = $query
->fields('c', array('subject', 'nid', 'cid', 'comment', 'timestamp', 'status', 'name', 'homepage'))
->fields('u', array('uid'))
->condition('c.status', $status)
->limit(50)
->orderByHeader($header)
->execute();
// Build a table listing the appropriate comments.
$options = array();
$destination = drupal_get_destination();
foreach ($result as $comment) {
$options[$comment->cid] = array(
'subject' => l($comment->subject, 'comment/' . $comment->cid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid)),
'author' => theme('username', $comment),
'posted_in' => l($comment->node_title, 'node/' . $comment->nid),
'time' => format_date($comment->timestamp, 'small'),
'operations' => l(t('edit'), 'comment/edit/' . $comment->cid, array('query' => $destination)),
);
}
$form['comments'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No comments available.'),
);
$form['pager'] = array(
'#markup' => theme('pager', NULL)
);
return $form;
}