function feedback_admin_view_form in Feedback 6.2
Same name and namespace in other branches
- 5.2 feedback.module \feedback_admin_view_form()
- 7.2 feedback.admin.inc \feedback_admin_view_form()
Build a (sortable) form containing a checkbox for each feedback entry.
1 string reference to 'feedback_admin_view_form'
- feedback_menu in ./
feedback.module - Implementation of hook_menu().
File
- ./
feedback.admin.inc, line 11 - Administrative functionality for Feedback module.
Code
function feedback_admin_view_form() {
$form = array();
$status_headings = array(
0 => t('Open feedback messages'),
1 => t('Processed feedback messages'),
);
$form['#feedback_header'] = array(
array(),
array(
'data' => t('Location'),
'field' => 'f.location_masked',
'sort' => 'asc',
),
array(
'data' => t('Date'),
'field' => 'f.timestamp',
),
array(
'data' => t('User'),
'field' => 'u.name',
),
t('Message'),
);
// Hack to prevent pager_query() from issuing PHP notices.
if (!isset($_GET['page'])) {
$_GET['page'] = '';
}
if (count(explode(',', $_GET['page'])) < 2) {
$_GET['page'] .= ',0';
}
$form['feedback-messages'] = array(
'#tree' => TRUE,
);
foreach (array(
0,
1,
) as $status) {
$sql = "SELECT f.*, u.name FROM {feedback} f INNER JOIN {users} u ON f.uid = u.uid WHERE f.status = %d";
$count_query = "SELECT COUNT(fid) FROM {feedback} WHERE status = %d";
$tablesort = tablesort_sql($form['#feedback_header']);
$result = pager_query($sql . $tablesort, 50, $status, $count_query, $status);
$form['feedback-messages'][$status] = array(
'#type' => 'fieldset',
'#title' => $status_headings[$status],
'#collapsible' => TRUE,
'#collapsed' => $status,
'#attributes' => array(
'class' => 'feedback-messages',
),
);
while ($entry = db_fetch_object($result)) {
$form['feedback-messages'][$status][$entry->fid] = array(
'#type' => 'checkbox',
'#return_value' => 1,
'#default_value' => FALSE,
);
$form['feedback-messages'][$status][$entry->fid]['location'] = array(
'#value' => l(truncate_utf8($entry->location, 32, FALSE, TRUE), $entry->url),
);
$form['feedback-messages'][$status][$entry->fid]['date'] = array(
'#value' => format_date($entry->timestamp, 'small'),
);
$form['feedback-messages'][$status][$entry->fid]['user'] = array(
'#value' => theme('username', $entry),
);
$form['feedback-messages'][$status][$entry->fid]['message'] = array(
'#value' => feedback_format_message($entry),
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}