function UNUSED_site_disclaimer_views_pre_render in Site Disclaimer 6
Same name and namespace in other branches
- 7 views/site_disclaimer.views.inc \UNUSED_site_disclaimer_views_pre_render()
Implementation of hook views_pre_render(). Performs data sort after the query is executed.
Related topics
File
- views/
site_disclaimer.views.inc, line 80 - Provide views data and handlers for site_disclaimer.module
Code
function UNUSED_site_disclaimer_views_pre_render(&$view) {
$query = $view->query;
if ($query->base_table == 'users' && isset($query->site_disclaimer_handler_sort_tou_version)) {
$rows =& $view->result;
$option = $query->site_disclaimer_handler_sort_tou_version[0];
// FIXME: should we iterate and sort by each option? foreach ($query->site_disclaimer_handler_sort_tou_version as $option) {...
// The fundamental problem is that we will not be able to maintain other sort orders performed by query.
//$option['form_data_fieldname'] = 'site_disclaimer';
if (isset($option['form_data_fieldname'])) {
// Extract field from user data into the recordset, so we can sort by it
$field_alias = isset($option['field_alias']) ? $option['field_alias'] : $option['table'] . '_' . 'data';
// $desc = (stripos($query->orderby[0], 'DESC') !== false);
// FIXME: this [0] is not going to work with multi-sort queries.
$desc = $option['order'] == 'DESC';
//watchdog('debug','IN tou_sort field_alias='.$field_alias.' query=<pre>'.print_r($query,1).'</pre>');
foreach ($rows as $key => $result) {
$form_data = unserialize($result->{$field_alias});
// if ($form_data) {
// foreach ($form_data as $k => $v) {
// if ($k == $option['form_data_fieldname']) {
$v = isset($form_data[$option['form_data_fieldname']]) ? $form_data[$option['form_data_fieldname']] : '';
$rows[$key]->site_disclaimer_sortby = drupal_strtolower($v);
// Case-insensitive
// }
// }
// }
}
// Now sort the data
usort($rows, $desc ? 'site_disclaimer_rsort' : 'site_disclaimer_sort');
}
//watchdog('debug','tou_sort desc='.$desc.' result=<pre>'.print_r($view->result,1).'</pre> query=<pre>'.print_r($query,1).'</pre>');
}
}