Select boxes rather than several submit buttons ... must standardise these approaches across admin forms

git-svn-id: file:///svn/phpbb/trunk@4618 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-10-21 00:16:05 +00:00
parent 411683ffd4
commit da7feb37a8

View file

@ -23,10 +23,8 @@ if (!$auth->acl_get('a_'))
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
// Define some vars // Define some vars
$pane = (!empty($_GET['pane'])) ? htmlspecialchars($_GET['pane']) : ''; $pane = request_var('pane', '');
// Generate relevant output // Generate relevant output
if ($pane == 'top') if ($pane == 'top')
@ -56,14 +54,13 @@ else if ($pane == 'left')
$dir = @opendir('.'); $dir = @opendir('.');
$setmodules = 1; $setmodules = 1;
while ($file = @readdir($dir)) while ($file = readdir($dir))
{ {
if (preg_match('#^admin_(.*?)\.' . $phpEx . '$#', $file)) if (preg_match('#^admin_(.*?)\.' . $phpEx . '$#', $file))
{ {
include($file); include($file);
} }
} }
@closedir($dir); @closedir($dir);
unset($setmodules); unset($setmodules);
@ -104,7 +101,7 @@ else if ($pane == 'left')
{ {
if (!empty($file)) if (!empty($file))
{ {
$action = (!empty($user->lang[$action])) ? $user->lang[$action] : preg_replace('/_/', ' ', $action); $action = (!empty($user->lang[$action])) ? $user->lang[$action] : preg_replace('#_#', ' ', $action);
$row_class = ($row_class == 'row1') ? 'row2' : 'row1'; $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
@ -132,20 +129,21 @@ else if ($pane == 'left')
} }
elseif ($pane == 'right') elseif ($pane == 'right')
{ {
$activate = (isset($_POST['activate'])) ? true : false; $action = request_var('action', '');
$delete = (isset($_POST['delete'])) ? true : false;
$remind = (isset($_POST['remind'])) ? true : false;
$mark = implode(', ', request_var('mark', 0)); $mark = implode(', ', request_var('mark', 0));
if (($activate || $delete) && $mark) if ($mark)
{ {
switch ($action)
{
case 'activate':
case 'delete':
if (!$auth->acl_get('a_user')) if (!$auth->acl_get('a_user'))
{ {
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
$sql = ($activate) ? 'UPDATE ' . USERS_TABLE . ' SET user_type = ' . USER_NORMAL . " WHERE user_id IN ($mark)" : 'DELETE FROM ' . USERS_TABLE . " WHERE user_id IN ($mark)"; $sql = ($action == 'activate') ? 'UPDATE ' . USERS_TABLE . ' SET user_type = ' . USER_NORMAL . " WHERE user_id IN ($mark)" : 'DELETE FROM ' . USERS_TABLE . " WHERE user_id IN ($mark)";
$db->sql_query($sql); $db->sql_query($sql);
if (!$delete) if (!$delete)
@ -155,9 +153,9 @@ elseif ($pane == 'right')
$log_action = ($activate) ? 'log_index_activate' : 'log_index_delete'; $log_action = ($activate) ? 'log_index_activate' : 'log_index_delete';
add_log('admin', $log_action, $db->affected_rows()); add_log('admin', $log_action, $db->affected_rows());
} break;
else if ($remind && $mark)
{ case 'remind':
if (!$auth->acl_get('a_user')) if (!$auth->acl_get('a_user'))
{ {
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
@ -214,9 +212,13 @@ elseif ($pane == 'right')
unset($usernames); unset($usernames);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
break;
} }
else if (isset($_POST['online'])) }
switch ($action)
{ {
case 'online':
if (!$auth->acl_get('a_defaults')) if (!$auth->acl_get('a_defaults'))
{ {
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
@ -225,9 +227,9 @@ elseif ($pane == 'right')
set_config('record_online_users', 1); set_config('record_online_users', 1);
set_config('record_online_date', time()); set_config('record_online_date', time());
add_log('admin', 'LOG_RESET_ONLINE'); add_log('admin', 'LOG_RESET_ONLINE');
} break;
else if (isset($_POST['stats']))
{ case 'stats':
if (!$auth->acl_get('a_defaults')) if (!$auth->acl_get('a_defaults'))
{ {
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
@ -261,9 +263,9 @@ elseif ($pane == 'right')
set_config('num_users', $row['stat']); set_config('num_users', $row['stat']);
add_log('admin', 'LOG_RESYNC_STATS'); add_log('admin', 'LOG_RESYNC_STATS');
} break;
else if (isset($_POST['date']))
{ case 'date':
if (!$auth->acl_get('a_defaults')) if (!$auth->acl_get('a_defaults'))
{ {
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
@ -271,6 +273,7 @@ elseif ($pane == 'right')
set_config('board_startdate', time() - 1); set_config('board_startdate', time() - 1);
add_log('admin', 'LOG_RESET_DATE'); add_log('admin', 'LOG_RESET_DATE');
break;
} }
// Get forum statistics // Get forum statistics
@ -290,11 +293,11 @@ elseif ($pane == 'right')
if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path'])) if ($avatar_dir = @opendir($phpbb_root_path . $config['avatar_path']))
{ {
while ($file = @readdir($avatar_dir)) while ($file = readdir($avatar_dir))
{ {
if ($file != '.' && $file != '..') if ($file{0} != '.')
{ {
$avatar_dir_size += @filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file); $avatar_dir_size += filesize($phpbb_root_path . $config['avatar_path'] . '/' . $file);
} }
} }
@closedir($avatar_dir); @closedir($avatar_dir);
@ -319,7 +322,7 @@ elseif ($pane == 'right')
else else
{ {
// Couldn't open Avatar dir. // Couldn't open Avatar dir.
$avatar_dir_size = $user->lang['Not_available']; $avatar_dir_size = $user->lang['NOT_AVAILABLE'];
} }
if ($posts_per_day > $total_posts) if ($posts_per_day > $total_posts)
@ -463,7 +466,7 @@ elseif ($pane == 'right')
<td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td> <td class="row2"><b><?php echo ($config['gzip_compress']) ? $user->lang['ON'] : $user->lang['OFF']; ?></b></td>
</tr> </tr>
<tr> <tr>
<td class="cat" colspan="4" align="right"><input class="btnlite" type="submit" name="online" value="<?php echo $user->lang['RESET_ONLINE']; ?>" /> &nbsp;<input class="btnlite" type="submit" name="date" value="<?php echo $user->lang['RESET_DATE']; ?>" /> &nbsp;<input class="btnlite" type="submit" name="stats" value="<?php echo $user->lang['RESYNC_STATS']; ?>" />&nbsp;</td> <td class="cat" colspan="4" align="right"><select name="action"><option value="online"><?php echo $user->lang['RESET_ONLINE']; ?></option><option value="date"><?php echo $user->lang['RESET_DATE']; ?></option><option value="stats"><?php echo $user->lang['RESYNC_STATS']; ?></option></select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td>
</tr> </tr>
</table></form> </table></form>
@ -540,16 +543,16 @@ elseif ($pane == 'right')
?> ?>
<tr> <tr>
<td class="cat" colspan="3" height="28" align="right"><input class="btnlite" type="submit" name="activate" value="<?php echo $user->lang['ACTIVATE']; ?>" />&nbsp; <?php <td class="cat" colspan="3" height="28" align="right"><select name="action"><option value="activate"><?php echo $user->lang['ACTIVATE']; ?></option><?php
if (!empty($config['email_enable'])) if (!empty($config['email_enable']))
{ {
?><input class="btnlite" type="submit" name="remind" value="<?php echo $user->lang['REMIND']; ?>" />&nbsp; <?php ?><option value="remind"><?php echo $user->lang['REMIND']; ?></option><?php
} }
?><input class="btnlite" type="submit" name="delete" value="<?php echo $user->lang['DELETE']; ?>" />&nbsp;</td> ?><option value="delete"><?php echo $user->lang['DELETE']; ?></option> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;</td>
</tr> </tr>
<?php <?php