You are here

function cmf_admin_comments_form in Content Management Filter 5

Same name and namespace in other branches
  1. 6.2 comment.inc \cmf_admin_comments_form()
  2. 6 comment.inc \cmf_admin_comments_form()
  3. 7 comment.inc \cmf_admin_comments_form()

Defines the form for comments administration filter results.

Return value

array with forms properties

See also

cmf_admin_comments_form_validate()

cmf_admin_comments_form_submit()

1 string reference to 'cmf_admin_comments_form'
cmf_admin_content_page in ./cmf.module
Called when user goes to example.com/admin/content/filter

File

./comment.inc, line 17
Content management filter module file

Code

function cmf_admin_comments_form() {
  $destination = drupal_get_destination();

  // build an 'Update options' form
  if (user_access('filter and manage site content')) {
    $form['options'] = array(
      '#type' => 'fieldset',
      '#title' => t('Update options'),
      '#prefix' => '<div class="container-inline">',
      '#suffix' => '</div>',
    );
    $options = array();
    foreach (comment_operations() 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 we want to display
  $form['header'] = array(
    '#type' => 'value',
    '#value' => cmf_build_header(),
  );
  $result = cmf_perform_query($form['header']['#value']);

  // build a table listing the appropriate comments
  while ($comment = db_fetch_object($result)) {
    $comments[$comment->cid] = '';
    if ($_SESSION['cmf_show_nid']) {
      $form['cmf_id'][$comment->cid] = array(
        '#value' => l($comment->nid, 'node/' . $comment->nid, array(
          'title' => t('Node !nid, Comment !cid', array(
            '!nid' => $comment->nid,
            '!cid' => $comment->cid,
          )),
        ), 'comment-' . $comment->cid),
      );
    }
    $form['title'][$comment->cid] = array(
      '#value' => l($comment->subject, 'node/' . $comment->nid, array(
        'title' => truncate_utf8($comment->comment, 128, TRUE, TRUE),
      ), NULL, 'comment-' . $comment->cid),
    );
    $form['kind'][$comment->cid] = array(
      '#value' => _cmf_get_img('comment', t('comment')),
    );
    $form['type'][$comment->cid] = $comment->type == 'forum' ? array(
      '#value' => '<p title="' . _cmf_get_forum($comment->nid) . '">' . theme('cmf_type', $comment->type) . '</p>',
    ) : array(
      '#value' => theme('cmf_type', $comment->type),
    );
    if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
      $form['username'][$comment->cid] = array(
        '#value' => theme('cmf_user', $comment->uid),
      );
    }
    $form['status'][$comment->cid] = array(
      '#value' => $comment->status ? t('not published') : t('published'),
    );
    $form['created'][$comment->cid] = array(
      '#value' => format_date($comment->created, 'small'),
    );
    if (user_access('filter and manage site content')) {
      $form['operations'][$comment->cid] = array(
        '#value' => l(_cmf_get_img('edit', t('edit')) . ' ' . t('edit'), 'comment/edit/' . $comment->cid, array(), $destination, NULL, FALSE, TRUE),
      );
    }
  }
  if (user_access('filter and manage site content')) {
    $form['comments'] = array(
      '#type' => 'checkboxes',
      '#options' => $comments,
    );
  }
  $form['pager'] = array(
    '#value' => theme('pager', NULL, $_SESSION['cmf_max_rows'], 0),
  );
  return $form;
}