function feedback_admin_view_form in Feedback 7.2
Same name and namespace in other branches
- 5.2 feedback.module \feedback_admin_view_form()
- 6.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 - Implements hook_menu().
File
- ./
feedback.admin.inc, line 11 - Administrative functionality for Feedback module.
Code
function feedback_admin_view_form($form, &$form_state) {
$form['#attached']['js'][] = drupal_get_path('module', 'feedback') . '/feedback.admin.js';
$status_headings = array(
FEEDBACK_OPEN => t('Open feedback messages'),
FEEDBACK_PROCESSED => 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'),
t('Operations'),
);
// 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,
);
$query = db_select('feedback', 'f')
->extend('PagerDefault')
->extend('TableSort');
$query
->join('users', 'u', 'f.uid = u.uid');
$query
->fields('f')
->limit(50);
foreach (array(
FEEDBACK_OPEN,
FEEDBACK_PROCESSED,
) as $status) {
$status_query = clone $query;
$fids = $status_query
->element($status)
->condition('f.status', $status)
->execute()
->fetchCol();
$form['feedback-messages'][$status] = array(
'#type' => 'fieldset',
'#title' => $status_headings[$status],
'#collapsible' => TRUE,
'#collapsed' => $status,
'#attributes' => array(
'class' => array(
'feedback-messages',
),
),
);
if (!empty($fids)) {
$entries = feedback_load_multiple($fids);
foreach ($entries as $fid => $entry) {
$form['feedback-messages'][$status][$fid] = array(
'#type' => 'checkbox',
'#return_value' => FEEDBACK_PROCESSED,
'#default_value' => FALSE,
);
$form['feedback-messages'][$status][$fid]['location'] = array(
'#markup' => l(truncate_utf8($entry->location, 32, FALSE, TRUE), $entry->url),
);
$form['feedback-messages'][$status][$fid]['date'] = array(
'#markup' => format_date($entry->timestamp, 'small'),
);
$form['feedback-messages'][$status][$fid]['user'] = array(
'#markup' => check_plain(format_username($entry)),
);
feedback_build_content($entry, 'teaser');
$form['feedback-messages'][$status][$fid]['message'] = $entry->content;
unset($entry->content);
$form['feedback-messages'][$status][$fid]['operations'] = array(
'#theme' => 'links',
'#links' => array(
'edit' => array(
'title' => t('edit'),
'href' => "admin/reports/feedback/{$fid}/edit",
),
'delete' => array(
'title' => t('delete'),
'href' => "admin/reports/feedback/{$fid}/delete",
),
),
'#attributes' => array(),
);
}
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
// Hide the submit button, if there are no entries at all.
'#access' => !empty($entries),
);
return $form;
}