diff options
Diffstat (limited to 'lib/VNWeb/User/List.pm')
-rw-r--r-- | lib/VNWeb/User/List.pm | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/VNWeb/User/List.pm b/lib/VNWeb/User/List.pm index 04c5d420..7fe5cb43 100644 --- a/lib/VNWeb/User/List.pm +++ b/lib/VNWeb/User/List.pm @@ -9,7 +9,7 @@ sub listing_ { my sub url { '?'.query_encode %$opt, @_ } paginate_ \&url, $opt->{p}, [$count, 50], 't'; - div_ class => 'mainbox browse userlist', sub { + article_ class => 'browse userlist', sub { table_ class => 'stripe', sub { thead_ sub { tr_ sub { td_ class => 'tc1', sub { txt_ 'Username'; sortable_ 'username', $opt, \&url }; @@ -27,19 +27,19 @@ sub listing_ { td_ class => 'tc2', fmtdate $l->{registered}; td_ class => 'tc3', sub { txt_ '0' if !$l->{c_vns}; - a_ href => "/u$l->{user_id}/ulist?vnlist=1", $l->{c_vns} if $l->{c_vns}; + a_ href => "/$l->{user_id}/ulist?vnlist=1", $l->{c_vns} if $l->{c_vns}; }; td_ class => 'tc4', sub { txt_ '0' if !$l->{c_votes}; - a_ href => "/u$l->{user_id}/ulist?votes=1", $l->{c_votes} if $l->{c_votes}; + a_ href => "/$l->{user_id}/ulist?votes=1", $l->{c_votes} if $l->{c_votes}; }; td_ class => 'tc5', sub { txt_ '0' if !$l->{c_wish}; - a_ href => "/u$l->{user_id}/ulist?wishlist=1", $l->{c_wish} if $l->{c_wish}; + a_ href => "/$l->{user_id}/ulist?wishlist=1", $l->{c_wish} if $l->{c_wish}; }; td_ class => 'tc6', sub { txt_ '-' if !$l->{c_changes}; - a_ href => "/u$l->{user_id}/hist", $l->{c_changes} if $l->{c_changes}; + a_ href => "/$l->{user_id}/hist", $l->{c_changes} if $l->{c_changes}; }; td_ class => 'tc7', sub { txt_ '-' if !$l->{c_tags}; @@ -67,19 +67,22 @@ TUWF::get qr{/u/(?<char>[0a-z]|all)}, sub { )->data; my @where = ( - $char eq 'all' ? () : $char eq '0' ? "ascii(username) not between ascii('a') and ascii('z')" : "username like '$char%'", + 'username IS NOT NULL', + auth->permUsermod ? () : 'email_confirmed', + $char eq 'all' ? () : sql('match_firstchar(username, ', \$char, ')'), $opt->{q} ? sql_or( - $opt->{q} =~ /^u?([0-9]+)$/ ? sql 'id =', \"$1" : (), - sql 'position(', \$opt->{q}, 'in username) > 0' + auth->permUsermod && $opt->{q} =~ /@/ ? sql('id IN(SELECT uid FROM user_emailtoid(', \$opt->{q}, '))') : (), + $opt->{q} =~ /^u?$RE{num}$/ ? sql 'id =', \"u$1" : (), + $opt->{q} =~ /@/ ? () : sql('username ILIKE', \('%'.sql_like($opt->{q}).'%')), ) : () ); my $list = tuwf->dbPagei({ results => 50, page => $opt->{p} }, 'SELECT', sql_user(), ',', sql_totime('registered'), 'as registered, c_vns, c_votes, c_wish, c_changes, c_tags, c_imgvotes FROM users u - WHERE', sql_and('id > 0', @where), + WHERE', sql_and(@where), 'ORDER BY', { - username => 'username', + username => 'lower(username)', registered => 'id', vns => 'c_vns', votes => 'c_votes', @@ -93,15 +96,20 @@ TUWF::get qr{/u/(?<char>[0a-z]|all)}, sub { my $count = @where ? tuwf->dbVali('SELECT count(*) FROM users WHERE', sql_and @where) : $totalusers; framework_ title => 'Browse users', sub { - div_ class => 'mainbox', sub { + article_ sub { h1_ 'Browse users'; form_ action => '/u/all', method => 'get', sub { - searchbox_ u => $opt->{q}; + fieldset_ class => 'search', sub { + input_ type => 'text', name => 'q', id => 'q', class => 'text', value => $opt->{q}//''; + input_ type => 'submit', class => 'submit', value => 'Search!'; + } }; p_ class => 'browseopts', sub { a_ href => "/u/$_", $_ eq $char ? (class => 'optselected') : (), $_ eq 'all' ? 'ALL' : $_ ? uc $_ : '#' for ('all', 'a'..'z', 0); }; + b_ 'The given email address is on the opt-out list.' + if auth->permUsermod && $opt->{q} && $opt->{q} =~ /@/ && tuwf->dbVali('SELECT email_optout_check(', \$opt->{q}, ')'); }; listing_ $opt, $list, $count if $count; }; |