You are here

function heartbeat_comments_admin_overview in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 modules/heartbeat_comments/heartbeat_comments.admin.inc \heartbeat_comments_admin_overview()

Form builder; Builds the comment overview form for the admin.

Return value

The form structure.

See also

heartbeat_comments_admin_overview_validate()

heartbeat_comments_admin_overview_submit()

theme_heartbeat_comments_admin_overview()

1 string reference to 'heartbeat_comments_admin_overview'
heartbeat_comments_admin in modules/heartbeat_comments/heartbeat_comments.admin.inc
Menu callback; present an administrative comment listing.

File

modules/heartbeat_comments/heartbeat_comments.admin.inc, line 32
Admin page callbacks for the heartbeat comments module.

Code

function heartbeat_comments_admin_overview() {
  $form['options']['operation'] = array(
    '#type' => 'hidden',
    '#default_value' => 'delete',
  );
  $form['options']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Delete selected'),
  );

  // load the comments that we want to display
  $form['header'] = array(
    '#type' => 'value',
    '#value' => array(
      theme('table_select_header_cell'),
      array(
        'data' => t('Comment'),
        'field' => 'subject',
      ),
      array(
        'data' => t('Author'),
        'field' => 'name',
      ),
      array(
        'data' => t('Reacted on'),
        'field' => 'heartbeat_title',
      ),
      array(
        'data' => t('Time'),
        'field' => 'timestamp',
        'sort' => 'desc',
      ),
    ),
  );
  $result = pager_query('SELECT c.hcid, c.uid, c.uaid, c.message AS \'subject\', c.cleared, c.time, ha.message AS \'heartbeat_title\', u.name AS registered_name, u.uid  FROM {heartbeat_comments} c LEFT JOIN {heartbeat_activity} ha ON ha.uaid = c.uaid LEFT JOIN {users} u ON u.uid = c.uid ' . tablesort_sql($form['header']['#value']), 50, 0, NULL);

  // build a table listing the appropriate comments
  $destination = drupal_get_destination();
  $anon = variable_get('anonymous', 'Anonymous user');
  while ($comment = db_fetch_object($result)) {
    $comments[$comment->hcid] = '';
    $comment->name = $comment->uid ? $comment->registered_name : $anon;
    $comment->heartbeat_title = truncate_utf8(strip_tags($comment->heartbeat_title), 50);
    $comment_message = truncate_utf8(strip_tags($comment->subject), 70);
    $form['subject'][$comment->hcid] = array(
      '#value' => $comment_message,
    );
    $form['username'][$comment->hcid] = array(
      '#value' => theme('username', $comment),
    );
    $form['heartbeat_title'][$comment->hcid] = array(
      '#value' => l($comment->heartbeat_title, 'heartbeat/message/' . $comment->uaid),
    );
    $form['timestamp'][$comment->hcid] = array(
      '#value' => $comment->time,
    );
  }
  $form['comments'] = array(
    '#type' => 'checkboxes',
    '#options' => isset($comments) ? $comments : array(),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}