You are here

function cmf_admin_comments_form in Content Management Filter 7

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

Defines the form for comments administration filter results.

Return value

array with forms properties

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
@brief Content management filter comment operations file.

Code

function cmf_admin_comments_form($form_state, $user_page_user = NULL) {
  $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($user_page_user),
  );
  $result = cmf_perform_query($form['header']['#value'], NULL, $user_page_user);

  // 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(
          'attributes' => array(
            'title' => t('Node !nid, Comment !cid', array(
              '!nid' => $comment->nid,
              '!cid' => $comment->cid,
            )),
          ),
          'fragment' => 'comment-' . $comment->cid,
        )),
      );
    }
    $form['title'][$comment->cid] = array(
      '#value' => l($comment->subject, 'node/' . $comment->nid, array(
        'attributes' => array(
          'title' => check_plain($comment->comment),
        ),
        'fragment' => '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 (!_cmf_valid_user($user_page_user)) {
      $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(
          'query' => $destination,
          'html' => 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),
  );
  $form['#user_page_user'] = $user_page_user;
  return $form;
}