You are here

function cmf_admin_both_form in Content Management Filter 5

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

Defines the form for mixed content administration filter results.

Return value

array with forms properties

See also

cmf_admin_both_form_validate()

cmf_admin_both_form_submit()

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

File

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

Code

function cmf_admin_both_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>',
    );
    $form['options']['operation'] = array(
      '#type' => 'select',
      '#options' => array(
        'publish' => t('Publish'),
        'unpublish' => t('Unpublish'),
        'delete' => t('Delete'),
      ),
      '#default_value' => 'publish',
    );
    $form['options']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update'),
    );
  }

  // load the objects 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 objects
  while ($object = db_fetch_object($result)) {
    if ($object->cid == 0) {
      $objects['n-' . $object->nid] = '';
      if ($_SESSION['cmf_show_nid']) {
        $form['cmf_id']['n-' . $object->nid] = array(
          '#value' => l($object->nid, 'node/' . $object->nid, array(
            'title' => t('Node !nid', array(
              '!nid' => $object->nid,
            )),
          )),
        );
      }
      $form['title']['n-' . $object->nid] = array(
        '#value' => l($object->title, 'node/' . $object->nid, array(
          'title' => truncate_utf8($object->body, 128, TRUE, TRUE),
        ), 'node-' . $object->nid) . ' ' . theme('mark', node_mark($object->nid, $object->changed)),
      );
      $form['kind']['n-' . $object->nid] = array(
        '#value' => _cmf_get_img('node', t('node')),
      );
      $form['type']['n-' . $object->nid] = $object->type == 'forum' ? array(
        '#value' => '<p title="' . _cmf_get_forum($object->nid) . '">' . check_plain(node_get_types('name', $object)) . '</p>',
      ) : array(
        '#value' => check_plain(node_get_types('name', $object)),
      );
      if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
        $form['username']['n-' . $object->nid] = array(
          '#value' => theme('cmf_user', $object->uid),
        );
      }
      $status = array();
      $status[] = $object->status ? t('published') : t('not published');
      if ($object->promote) {
        $status[] = t('promoted');
      }
      if ($object->sticky > 0) {

        // >0 allows for sticky-encoded weighting.
        $status[] = t('sticky');
      }
      if ($object->moderate) {
        $status[] = t('moderated');
      }
      $form['status']['n-' . $object->nid] = array(
        '#value' => implode(', ', $status),
      );
      $form['created']['n-' . $object->nid] = array(
        '#value' => format_date($object->created, 'small'),
      );
      if (user_access('filter and manage site content')) {
        $form['operations']['n-' . $object->nid] = array(
          '#value' => l(_cmf_get_img('edit', t('edit')) . ' ' . t('edit'), 'node/' . $object->nid . '/edit', array(), $destination, NULL, FALSE, TRUE),
        );
      }
    }
    else {
      $objects['c-' . $object->cid] = '';
      if ($_SESSION['cmf_show_nid']) {
        $form['cmf_id']['c-' . $object->cid] = array(
          '#value' => l($object->nid, 'node/' . $object->nid, array(
            'title' => t('Node !nid, Comment !cid', array(
              '!nid' => $object->nid,
              '!cid' => $object->cid,
            )),
          ), 'comment-' . $object->cid),
        );
      }
      $form['title']['c-' . $object->cid] = array(
        '#value' => l($object->title, 'node/' . $object->nid, array(
          'title' => truncate_utf8($object->comment, 128),
        ), NULL, 'comment-' . $object->cid),
      );
      $form['kind']['c-' . $object->cid] = array(
        '#value' => _cmf_get_img('comment', t('comment')),
      );
      $form['type']['c-' . $object->cid] = $object->type == 'forum' ? array(
        '#value' => '<p title="' . _cmf_get_forum($object->nid) . '">' . theme('cmf_type', $object->type) . '</p>',
      ) : array(
        '#value' => theme('cmf_type', $object->type),
      );
      if (!(arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0)) {
        $form['username']['c-' . $object->cid] = array(
          '#value' => theme('cmf_user', $object->uid),
        );
      }
      $form['status']['c-' . $object->cid] = array(
        '#value' => $object->status ? t('not published') : t('published'),
      );
      $form['created']['c-' . $object->cid] = array(
        '#value' => format_date($object->created, 'small'),
      );
      if (user_access('filter and manage site content')) {
        $form['operations']['c-' . $object->cid] = array(
          '#value' => l(_cmf_get_img('edit', t('edit')) . ' ' . t('edit'), 'comment/edit/' . $object->cid, array(), $destination, NULL, FALSE, TRUE),
        );
      }
    }
  }
  if (user_access('filter and manage site content')) {
    $form['objects'] = array(
      '#type' => 'checkboxes',
      '#options' => $objects,
    );
  }
  $form['pager'] = array(
    '#value' => theme('pager', NULL, $_SESSION['cmf_max_rows'], 0),
  );
  return $form;
}