You are here

function heartbeat_messages_admin_overview in Heartbeat 6.4

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

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

Return value

The form structure.

See also

heartbeat_messages_admin_overview_validate()

heartbeat_messages_admin_overview_submit()

theme_heartbeat_messages_admin_overview()

1 string reference to 'heartbeat_messages_admin_overview'
heartbeat_activity_admin in ./heartbeat.admin.inc
Callback menu page for heartbeat content administration.

File

./heartbeat.admin.inc, line 35
Admnistration tasks for heartbeat.

Code

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

  // load the comments that we want to display
  $form['header'] = array(
    '#type' => 'value',
    '#value' => array(
      theme('table_select_header_cell'),
      array(
        'data' => t('Activity message'),
        'field' => 'message',
      ),
      array(
        'data' => t('Author'),
        'field' => 'name',
      ),
      array(
        'data' => t('Language'),
        'field' => 'language',
      ),
      array(
        'data' => t('Time'),
        'field' => 'timestamp',
        'sort' => 'desc',
      ),
      array(
        'data' => t('Operations'),
      ),
    ),
  );
  $result = pager_query('SELECT DISTINCT ha.message AS \'message\', ha.uaid, ha.timestamp, ha.language, u.name AS registered_name, u.uid FROM {heartbeat_activity} ha LEFT JOIN {users} u ON u.uid = ha.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 ($message = db_fetch_object($result)) {
    $rows[$message->uaid] = '';
    $message->name = $message->uid ? $message->registered_name : $anon;
    $title = strip_tags($message->message);
    $form['message'][$message->uaid] = array(
      '#value' => l($title, 'heartbeat/message/' . $message->uaid, array(
        'attributes' => array(
          'title' => truncate_utf8($title, 128),
        ),
        'fragment' => 'heartbeat-message-' . $message->uaid,
      )),
    );
    $form['username'][$message->uaid] = array(
      '#value' => theme('username', $message),
    );
    $form['timestamp'][$message->uaid] = array(
      '#value' => format_date($message->timestamp, 'small'),
    );
    $form['language'][$message->uaid] = array(
      '#value' => $message->language,
    );
    $form['operations'][$message->uaid] = array(
      '#value' => l(t('view'), 'heartbeat/message/' . $message->uaid . '', array(
        'query' => $destination,
      )),
    );
    $form['operations'][$message->uaid]['#value'] .= ' - ' . l(t('delete'), 'heartbeat/delete/' . $message->uaid . '', array(
      'query' => $destination,
    ));
  }
  $form['heartbeat-activity'] = array(
    '#type' => 'checkboxes',
    '#options' => isset($rows) ? $rows : array(),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}