You are here

function certificate_admin_clear_form in Certificate 8.3

Same name and namespace in other branches
  1. 6.2 certificate.admin.inc \certificate_admin_clear_form()
  2. 6 certificate.admin.inc \certificate_admin_clear_form()
  3. 7.2 certificate.admin.inc \certificate_admin_clear_form()
  4. 4.x certificate.admin.inc \certificate_admin_clear_form()
  5. 3.x certificate.admin.inc \certificate_admin_clear_form()

Form to clear certificate snapshots.

1 string reference to 'certificate_admin_clear_form'
certificate_menu in ./certificate.module
Implements hook_menu().

File

./certificate.admin.inc, line 389
Administrative pages for Certificate module.

Code

function certificate_admin_clear_form($form, &$form_state) {
  $form = array();
  $header = array(
    array(),
    array(
      'data' => 'Title',
      'field' => 'n.title',
    ),
    array(
      'data' => 'Count',
      'field' => 'count',
    ),
  );
  $sql = "SELECT *, count(cs.uid) AS count FROM {certificate_snapshots} cs\n  INNER JOIN {node} n ON (cs.nid = n.nid)\n  GROUP BY cs.nid";
  $result = db_query($sql);
  $nids = array();
  while ($row = $result
    ->fetch()) {
    $nids[$row->nid] = '';
    $form['cs']['title'][$row->nid]['#markup'] = $row->title;
    $form['cs']['count'][$row->nid]['#markup'] = $row->count;
  }
  $form['cs']['nids'] = array(
    '#type' => 'checkboxes',
    '#options' => $nids,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Clear',
  );
  return $form;
}