diff --git a/mysql/edit_dbase.cgi b/mysql/edit_dbase.cgi index 725477a2a..016083173 100755 --- a/mysql/edit_dbase.cgi +++ b/mysql/edit_dbase.cgi @@ -74,7 +74,7 @@ elsif (@titles || @indexes) { ( map { "!".$_ } @indexes ), ( map { "*".$_ } @views ), ); - if ($config{'style'}) { + if ($displayconfig{'style'}) { foreach $t (@titles) { local $c = &execute_sql($in{'db'}, "select count(*) from ".quotestr($t)); diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index ff90744e6..9f951da04 100644 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -33,6 +33,7 @@ if ($module_info{'usermin'}) { $max_dbs = $userconfig{'max_dbs'}; $commands_file = "$user_module_config_directory/commands"; $sql_charset = $userconfig{'charset'}; + %displayconfig = %userconfig; } else { # Webmin connects to the database as the user specified in the per-user @@ -54,6 +55,7 @@ else { $max_dbs = $config{'max_dbs'}; $commands_file = "$module_config_directory/commands"; $sql_charset = $config{'charset'}; + %displayconfig = %config; } $authstr = &make_authstr(); $master_db = 'mysql'; @@ -444,14 +446,14 @@ else { # Outputs a table that is split into two parts sub split_table { -local $mid = int((@{$_[1]}+1) / 2); +local $mid = int((@{$_[2]}+1) / 2); local ($i, $j); print "\n"; -foreach $s ([0, $mid-1], [$mid, @{$_[1]}-1]) { +foreach $s ([0, $mid-1], [$mid, @{$_[2]}-1]) { print "
\n"; # Header - local @tds = ( "width=5" ); + local @tds = $_[1] ? ( "width=5" ) : ( ); if ($s->[0] <= $s->[1]) { local @hcols; foreach $t (@{$_[0]}) { @@ -466,7 +468,12 @@ foreach $s ([0, $mid-1], [$mid, @{$_[1]}-1]) { for($j=4; $j<@_; $j++) { push(@cols, $_[$j]->[$i]); } - print &ui_checked_columns_row(\@cols, \@tds, "d", $_[1]->[$i]); + if ($_[1]) { + print &ui_checked_columns_row(\@cols, \@tds, "d", $_[1]->[$i]); + } + else { + print &ui_columns_row(\@cols, \@tds); + } } if ($s->[0] <= $s->[1]) { print &ui_columns_end(); diff --git a/mysql/view-lib.pl b/mysql/view-lib.pl index ecb2bece7..6fd6fa792 100644 --- a/mysql/view-lib.pl +++ b/mysql/view-lib.pl @@ -51,10 +51,10 @@ sub get_search_limit local %in = %{$_[0]}; $in{'start'} ||= 0; if ($module_name eq "mysql") { - return "limit $in{'start'},$config{'perpage'}"; + return "limit $in{'start'},$displayconfig{'perpage'}"; } else { - return "limit $config{'perpage'} offset $in{'start'}"; + return "limit $displayconfig{'perpage'} offset $in{'start'}"; } } diff --git a/mysql/view_table.cgi b/mysql/view_table.cgi index c7398cbee..a158840e9 100755 --- a/mysql/view_table.cgi +++ b/mysql/view_table.cgi @@ -45,22 +45,22 @@ $d = &execute_sql_safe($in{'db'}, "select count(*) from "."e_table($in{'table'})." ".$search); $total = int($d->{'data'}->[0]->[0]); if ($in{'jump'} > 0) { - $in{'start'} = int($in{'jump'} / $config{'perpage'}) * - $config{'perpage'}; + $in{'start'} = int($in{'jump'} / $displayconfig{'perpage'}) * + $displayconfig{'perpage'}; if ($in{'start'} >= $total) { - $in{'start'} = $total - $config{'perpage'}; - $in{'start'} = int(($in{'start'} / $config{'perpage'}) + 1) * - $config{'perpage'}; + $in{'start'} = $total - $displayconfig{'perpage'}; + $in{'start'} = int(($in{'start'} / $displayconfig{'perpage'}) + 1) * + $displayconfig{'perpage'}; } } else { $in{'start'} = int($in{'start'}); } -if ($in{'new'} && $total > $config{'perpage'}) { +if ($in{'new'} && $total > $displayconfig{'perpage'}) { # go to the last screen for adding a row - $in{'start'} = $total - $config{'perpage'}; - $in{'start'} = int(($in{'start'} / $config{'perpage'}) + 1) * - $config{'perpage'}; + $in{'start'} = $total - $displayconfig{'perpage'}; + $in{'start'} = int(($in{'start'} / $displayconfig{'perpage'}) + 1) * + $displayconfig{'perpage'}; } # Get limiting and sorting SQL @@ -114,7 +114,7 @@ elsif ($in{'save'}) { $d = &execute_sql($in{'db'}, $where_select); @t = map { $_->{'field'} } @str; $count = 0; - for($j=0; $j<$config{'perpage'}; $j++) { + for($j=0; $j<$displayconfig{'perpage'}; $j++) { next if (!defined($in{"${j}_$t[0]"})); local (@where, @set); local @r = @{$d->{'data'}->[$j]}; @@ -141,7 +141,7 @@ elsif ($in{'save'}) { local $ij = $in{"${j}_$t[$i]"}; local $ijdef = $in{"${j}_$t[$i]_def"}; next if ($ijdef || !defined($ij)); - if (!$config{'blob_mode'} || !&is_blob($str[$i])) { + if (!$displayconfig{'blob_mode'} || !&is_blob($str[$i])) { $ij =~ s/\r//g; } push(@set, "estr($t[$i])." = ?"); @@ -161,7 +161,7 @@ elsif ($in{'save'}) { elsif ($in{'savenew'}) { # Adding a new row for($j=0; $j<@str; $j++) { - if (!$config{'blob_mode'} || !&is_blob($str[$j])) { + if (!$displayconfig{'blob_mode'} || !&is_blob($str[$j])) { $in{$j} =~ s/\r//g; } push(@set, $in{$j} eq '' ? undef : $in{$j}); @@ -180,23 +180,23 @@ elsif ($in{'cancel'} || $in{'new'}) { $desc = &text('table_header', "$in{'table'}", "$in{'db'}"); &ui_print_header($desc, $text{'view_title'}, ""); -if ($in{'start'} || $total > $config{'perpage'}) { +if ($in{'start'} || $total > $displayconfig{'perpage'}) { print "
\n"; if ($in{'start'}) { printf "". "\n", $in{'db'}, $in{'table'}, - $in{'start'} - $config{'perpage'}, + $in{'start'} - $displayconfig{'perpage'}, $searchargs, $sortargs; } print "",&text('view_pos', $in{'start'}+1, - $in{'start'}+$config{'perpage'} > $total ? $total : - $in{'start'}+$config{'perpage'}, $total),"\n"; - if ($in{'start'}+$config{'perpage'} < $total) { + $in{'start'}+$displayconfig{'perpage'} > $total ? $total : + $in{'start'}+$displayconfig{'perpage'}, $total),"\n"; + if ($in{'start'}+$displayconfig{'perpage'} < $total) { printf "". " ", $in{'db'}, $in{'table'}, - $in{'start'} + $config{'perpage'}, + $in{'start'} + $displayconfig{'perpage'}, $searchargs, $sortargs; } print "
\n"; @@ -227,7 +227,7 @@ if ($in{'sortfield'}) { print "
\n"; -if ($config{'blob_mode'}) { +if ($displayconfig{'blob_mode'}) { print &ui_form_start("view_table.cgi", "form-data"); } else { @@ -268,7 +268,7 @@ if ($total || $in{'new'}) { $w = 10 if ($w < 10); for($i=0; $i<@data; $i++) { local @d = map { $_ eq "NULL" ? undef : $_ } @{$data[$i]}; - if ($row{$i} && ($config{'add_mode'} || $has_blob)) { + if ($row{$i} && ($displayconfig{'add_mode'} || $has_blob)) { # Show multi-line row editor $et = "\n"; $et .= " ". @@ -277,7 +277,7 @@ if ($total || $in{'new'}) { local $nm = $i == $realrows ? $j : "${i}_$str[$j]->{'field'}"; $et .= "
$text{'view_field'}
$str[$j]->{'field'} \n"; - if ($config{'blob_mode'} && + if ($displayconfig{'blob_mode'} && &is_blob($str[$j]) && $d[$j]) { # Show as keep/upload inputs $et .= &ui_radio($nm."_def", 1, @@ -285,7 +285,7 @@ if ($total || $in{'new'}) { [ 0, $text{'view_set'} ] ])." ". &ui_upload($nm); } - elsif ($config{'blob_mode'} && + elsif ($displayconfig{'blob_mode'} && &is_blob($str[$j])) { # Show upload input $et .= &ui_upload($nm); @@ -323,7 +323,7 @@ if ($total || $in{'new'}) { local $l = $d[$j] =~ tr/\n/\n/; local $nm = $i == $realrows ? $j : "${i}_$d->{'titles'}->[$j]"; - if ($config{'blob_mode'} && + if ($displayconfig{'blob_mode'} && &is_blob($str[$j])) { # Cannot edit this blob push(@cols, undef); @@ -361,7 +361,7 @@ if ($total || $in{'new'}) { local @cols; local $j = 0; foreach $c (@d) { - if ($config{'blob_mode'} && + if ($displayconfig{'blob_mode'} && &is_blob($str[$j]) && $c ne '') { # Show download link for blob push(@cols, "$text{'view_download'}"); @@ -417,7 +417,7 @@ else { print &ui_form_end([ [ "new", $text{'view_new'} ] ]); } -if (!$in{'field'} && $total > $config{'perpage'}) { +if (!$in{'field'} && $total > $displayconfig{'perpage'}) { # Show search and jump buttons print "
\n"; print "\n";