diff options
Diffstat (limited to 'lib/VNWeb/Discussions/Board.pm')
-rw-r--r-- | lib/VNWeb/Discussions/Board.pm | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/VNWeb/Discussions/Board.pm b/lib/VNWeb/Discussions/Board.pm index edce6789..9fa9e304 100644 --- a/lib/VNWeb/Discussions/Board.pm +++ b/lib/VNWeb/Discussions/Board.pm @@ -5,23 +5,22 @@ use VNWeb::Discussions::Lib; TUWF::get qr{/t/(all|$BOARD_RE)}, sub { - my($type, $id) = tuwf->capture(1) =~ /^([^0-9]+)([0-9]*)$/; + my $id = tuwf->capture(1); + my($type) = $id =~ /^([^0-9]+)/; + $id = undef if $id !~ /[0-9]$/; my $page = tuwf->validate(get => p => { upage => 1 })->data; - my $obj = !$id ? undef : - $type eq 'v' ? tuwf->dbRowi('SELECT id, title, original, hidden AS entry_hidden, locked AS entry_locked FROM vn WHERE id =', \$id) : - $type eq 'p' ? tuwf->dbRowi('SELECT id, name, original, hidden AS entry_hidden, locked AS entry_locked FROM producers WHERE id =', \$id) : - $type eq 'u' ? tuwf->dbRowi('SELECT id,', sql_user(), 'FROM users u WHERE id =', \$id) : undef; + my $obj = $id ? dbobj $id : undef; return tuwf->resNotFound if $id && !$obj->{id}; + return tuwf->resNotFound if $id && $id =~ /^u/ && $obj->{entry_hidden} && !auth->isMod; - my $ititle = $obj && ($obj->{title} || $obj->{name} || user_displayname $obj); - my $title = $obj ? "Related discussions for $ititle" : $type eq 'all' ? 'All boards' : $BOARD_TYPE{$type}{txt}; - my $createurl = '/t/'.($id ? $type.$id : $type eq 'db' ? 'db' : 'ge').'/new'; + my $title = $obj ? "Related discussions for $obj->{title}[1]" : $type eq 'all' ? 'All boards' : $BOARD_TYPE{$type}{txt}; + my $createurl = '/t/'.($id || ($type eq 'db' ? 'db' : 'ge')).'/new'; - framework_ title => $title, type => $type, dbobj => $obj, tab => 'disc', + framework_ title => $title, dbobj => $obj, tab => 'disc', sub { - div_ class => 'mainbox', sub { + article_ sub { h1_ $title; boardtypes_ $type; boardsearch_ $type if !$id; @@ -32,12 +31,12 @@ TUWF::get qr{/t/(all|$BOARD_RE)}, sub { threadlist_ where => $type ne 'all' && sql('t.id IN(SELECT tid FROM threads_boards WHERE type =', \$type, $id ? ('AND iid =', \$id) : (), ')'), - boards => $type ne 'all' && sql('NOT (tb.type =', \$type, 'AND tb.iid =', \($id||0), ')'), + boards => $type ne 'all' && sql('NOT (tb.type =', \$type, 'AND tb.iid IS NOT DISTINCT FROM', \$id, ')'), results => 50, sort => $type eq 'an' ? 't.id DESC' : undef, page => $page, paginate => sub { "?p=$_" } - or div_ class => 'mainbox', sub { + or article_ sub { h1_ 'An empty board'; p_ class => 'center', sub { txt_ "Nobody's started a discussion on this board yet. Why not "; |