mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-03 22:27:54 +02:00
Use sorting function
git-svn-id: file:///svn/phpbb/trunk@3873 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2e36408fab
commit
e2c2953245
@ -21,7 +21,7 @@
|
||||
|
||||
if (!empty($setmodules))
|
||||
{
|
||||
if (!$auth->acl_get('a_general'))
|
||||
if (!$auth->acl_get('a_'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -40,21 +40,30 @@ require($phpbb_root_path . 'extension.inc');
|
||||
require('pagestart.' . $phpEx);
|
||||
|
||||
// Do we have styles admin permissions?
|
||||
if (!$auth->acl_get('a_general'))
|
||||
if (!$auth->acl_get('a_'))
|
||||
{
|
||||
trigger_error($user->lang['NO_ADMIN']);
|
||||
}
|
||||
|
||||
|
||||
// Set some variables
|
||||
$forum_id = (isset($_REQUEST['f'])) ? intval($_REQUEST['f']) : 0;
|
||||
$start = (isset($_GET['start'])) ? intval($_GET['start']) : 0;
|
||||
$mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : 'admin';
|
||||
|
||||
|
||||
// Sort keys
|
||||
$sort_days = (!empty($_REQUEST['st'])) ? max(intval($_REQUEST['st']), 0) : 0;
|
||||
$sort_key = (!empty($_REQUEST['sk'])) ? htmlspecialchars($_REQUEST['sk']) : 't';
|
||||
$sort_dir = (!empty($_REQUEST['sd'])) ? htmlspecialchars($_REQUEST['sd']) : 'd';
|
||||
|
||||
|
||||
// Define some vars depending on which logs we're looking at
|
||||
$log_table_sql = ($mode == 'admin') ? LOG_ADMIN_TABLE : LOG_MOD_TABLE;
|
||||
$l_title = ($mode == 'admin') ? $user->lang['ADMIN_LOGS'] : $user->lang['MOD_LOGS'];
|
||||
$l_title_explain = ($mode == 'admin') ? $user->lang['ADMIN_LOGS_EXPLAIN'] : $user->lang['MOD_LOGS_EXPLAIN'];
|
||||
|
||||
|
||||
// Delete entries if requested and able
|
||||
if ((isset($_POST['delmarked']) || isset($_POST['delall'])) && $auth->acl_get('a_clearlogs'))
|
||||
{
|
||||
@ -75,54 +84,19 @@ if ((isset($_POST['delmarked']) || isset($_POST['delall'])) && $auth->acl_get('a
|
||||
add_log('admin', 'log_' . $mode . '_clear');
|
||||
}
|
||||
|
||||
// Sorting ... this could become a function
|
||||
if (isset($_POST['sort']) || $start)
|
||||
{
|
||||
if (!empty($_POST['sort_days']))
|
||||
{
|
||||
$sort_days = intval($_POST['sort_days']);
|
||||
$where_sql = time() - ($sort_days * 86400);
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql = 0;
|
||||
}
|
||||
|
||||
$sort_key = (isset($_REQUEST['sort_key'])) ? $_REQUEST['sort_key'] : '';
|
||||
$sort_dir = (isset($_REQUEST['sort_dir'])) ? $_REQUEST['sort_dir'] : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_sql = 0;
|
||||
|
||||
$sort_days = 0;
|
||||
$sort_key = 't';
|
||||
$sort_dir = 'd';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$previous_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
||||
// Sorting
|
||||
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
|
||||
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
|
||||
$sort_by = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
|
||||
|
||||
$sort_day_options = '';
|
||||
foreach ($previous_days as $day => $text)
|
||||
{
|
||||
$selected = ($sort_days == $day) ? ' selected="selected"' : '';
|
||||
$sort_day_options .= '<option value="' . $day . '"' . $selected . '>' . $text . '</option>';
|
||||
}
|
||||
$s_limit_days = $s_sort_key = $s_sort_dir = '';
|
||||
gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir);
|
||||
|
||||
$sort_key_options = '';
|
||||
foreach ($sort_by_text as $key => $text)
|
||||
{
|
||||
$selected = ($sort_key == $key) ? ' selected="selected"' : '';
|
||||
$sort_key_options .= '<option value="' . $key . '"' . $selected . '>' . $text . '</option>';
|
||||
}
|
||||
// Define where and sort sql for use in displaying logs
|
||||
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
|
||||
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
$sort_order_options = ($sort_dir == 'a') ? '<option value="a" selected="selected">' . $user->lang['SORT_ASCENDING'] . '</option><option value="d">' . $user->lang['SORT_DESCENDING'] . '</option>' : '<option value="a">' . $user->lang['SORT_ASCENDING'] . '</option><option value="d" selected="selected">' . $user->lang['SORT_DESCENDING'] . '</option>';
|
||||
|
||||
$sort_sql = $sort_by[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
|
||||
|
||||
// Output page
|
||||
page_header($l_title);
|
||||
@ -156,7 +130,7 @@ if ($mode == 'mod')
|
||||
|
||||
<table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0">
|
||||
<tr>
|
||||
<td class="cat" colspan="5" height="28" align="center"><span class="gensmall"><?php echo $user->lang['DISPLAY_LOG']; ?>: <select name="sort_days"><?php echo $sort_day_options; ?></select> <?php echo $user->lang['SORT_BY']; ?> <select name="sort_key"><?php echo $sort_key_options; ?></select> <select name="sort_dir"><?php echo $sort_order_options; ?></select> <input class="liteoption" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></span></td>
|
||||
<td class="cat" colspan="5" height="28" align="center"><span class="gensmall"><?php echo $user->lang['DISPLAY_LOG']; ?>: <?php echo $s_limit_days; ?> <?php echo $user->lang['SORT_BY']; ?> <?php echo $s_sort_key; ?> <?php echo $s_sort_dir; ?> <input class="liteoption" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="15%" height="25" nowrap="nowrap"><?php echo $user->lang['USERNAME']; ?></th>
|
||||
@ -172,7 +146,7 @@ if ($mode == 'mod')
|
||||
//
|
||||
$log_data = array();
|
||||
$log_count = 0;
|
||||
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, $where_sql, $sort_sql);
|
||||
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, $sql_where, $sql_sort);
|
||||
|
||||
if ($log_count)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user