.green { background-color: #d0eed0; } .yellow { background-color: #eeeed0; } .red { background-color: #eed0d0; } .clicked { background-color: #d0d0ee; } <=head title=>Support Requests body<= request; my $remote = LJ::get_remote(); LJ::Support::init_remote($remote); return $ML{'.interim'} if (!$remote || !$remote->{'_priv'}) && $r->header_in("Referer") eq "$LJ::SITEROOT/support/"; my $cats = LJ::Support::load_cats(); my $state = $FORM{'state'}; $state = 'open' unless $state =~ /^(?:open|closed|green|youreplied)$/; my $filtercat = $FORM{'cat'}; $filtercat = "" unless ($filtercat =~ /^[\w\-]+$/); my $fcat = LJ::Support::get_cat_by_key($cats, $filtercat); my $can_read = LJ::Support::can_read_cat($fcat, $remote); # determine if user can close stuff my $can_close = 0; if ($remote && $state =~ /(?:green|open)/ && $filtercat) { $can_close = 1 if LJ::check_priv($remote, 'supportclose', $filtercat); # private cats/only this cat $can_close = 1 if $fcat->{public_read} && LJ::check_priv($remote, 'supportclose', ''); # public cats } my $append; if ($state eq "closed") { $ret .= "click here. p?>"; } elsif ($state eq "youreplied") { return "" unless $remote; $ret .= ""; } else { $ret .= "closed reports are also " . "available. If you help somebody out and they confirm you helped them, you get the number " . "of points indicated in the status column. These points will show up on your userinfo page. p?>"; $append = 1; } my @support_log; # if we have a cat to filter to and we have abstracts for it my $rct = 0; my $abstracts = 0; if ($filtercat && $LJ::SUPPORT_ABSTRACTS{$filtercat} && $fcat && $can_read && $state ne 'youreplied') { # yes, we should show abstracts for this category, so do so if ($state eq "closed") { $sth = $dbr->prepare("SELECT s.*, SUBSTRING(sl.message, 1, 200) AS 'message' " . "FROM support s, supportlog sl " . "WHERE s.state='closed' AND s.spid = sl.spid AND sl.type = 'req' " . "AND s.timeclosed > (UNIX_TIMESTAMP() - (3600*24)) " . "AND s.spcatid = ?"); } else { # triggers on green, open $sth = $dbr->prepare("SELECT s.*, SUBSTRING(sl.message, 1, 200) AS 'message' " . "FROM support s, supportlog sl " . "WHERE s.state='open' AND s.spid = sl.spid AND sl.type = 'req' " . "AND s.spcatid = ?"); } $sth->execute($fcat->{spcatid}); push @support_log, $_ while $_ = $sth->fetchrow_hashref(); $rct = scalar(@support_log); $abstracts = 1; } else { my $filterwhere; if ($filtercat eq "_nonpublic") { $filterwhere = " AND s.spcatid IN (0"; foreach my $cat (values %$cats) { $filterwhere .= ", $cat->{'spcatid'}" if !$cat->{'public_read'} && LJ::Support::can_read_cat($cat, $remote); } $filterwhere .= ")"; } elsif ($filtercat eq "_nonprivate") { $filterwhere = " AND s.spcatid IN (0"; foreach my $cat (values %$cats) { $filterwhere .= ", $cat->{'spcatid'}" if $cat->{public_read}; } $filterwhere .= ")"; } else { if ($can_read) { $filterwhere = " AND s.spcatid=$fcat->{'spcatid'}"; } else { $filtercat = ""; } } my $dbr = LJ::get_db_reader(); if ($state eq "closed") { $sth = $dbr->prepare("SELECT s.* FROM support s WHERE s.state='closed' AND " . "s.timeclosed>UNIX_TIMESTAMP()-(3600*24) $filterwhere"); } elsif ($state eq "youreplied") { $sth = $dbr->prepare("SELECT s.* FROM support s, support_youreplied yr " . "WHERE yr.userid=$remote->{'userid'} AND s.spid=yr.spid $filterwhere " . "AND (s.state='open' OR (s.state='closed' AND s.timeclosed>UNIX_TIMESTAMP()-(3600*24)))"); } else { # triggers on green, open $sth = $dbr->prepare("SELECT s.* FROM support s WHERE s.state='open' $filterwhere"); } $sth->execute; # For the You Replied filter, we might be getting some rows multiple times (when # multiple log rows exist for $remote), which is still better than using DISTINCT # in the query which uses a temporary table, so ensure uniqueness here. my %spids_seen; while (my $sprow = $sth->fetchrow_hashref) { next if $spids_seen{$sprow->{'spid'}}; $spids_seen{$sprow->{'spid'}} = 1; push @support_log, $sprow; $rct++; } } my $sort = $FORM{sort}; $sort = 'date' unless $sort =~ /^id|summary|area|date$/; $ret .= "

[$rct total open requests]

" if $append; if ($sort eq 'id') { @support_log = sort { $a->{spid} <=> $b->{spid} } @support_log; } elsif ($sort eq 'date') { @support_log = sort { $b->{timecreate} <=> $a->{timecreate} } @support_log; } elsif ($sort eq 'summary') { @support_log = sort { $a->{subject} cmp $b->{subject} } @support_log; } elsif ($sort eq 'area') { @support_log = sort { $cats->{$a->{spcatid}}->{catname} cmp $cats->{$b->{spcatid}}->{catname} } @support_log; } # filter line: $ret .= "
Show only "; $ret .= ""; $ret .= ""; $ret .= " requests of type: \n"; $ret .= "
"; # /filter line # mass closing table $ret .= "
" if $can_close; # start the rest of the table my $uri = "$LJ::SITEROOT/support/help.bml?cat=$filtercat&state=$state"; $ret .= "

\n"; $ret .= "\n" if $can_close; my @headers = ( id => "ID#", summary => "Summary", area => "Problem Area", date => "Posted" ); while (my ($sorttype, $desc) = splice(@headers, 0, 2)) { if ($sort eq $sorttype) { $ret .= "\n"; } else { $ret .= "\n"; } } $ret .= "\n"; $ret .= ""; foreach my $sp (@support_log) { LJ::Support::fill_request_with_cat($sp, $cats); next unless (LJ::Support::can_read($sp, $remote)); my $status = "open"; my $barbg = "green"; if ($sp->{'timeclosed'}) { $status = "closed"; $barbg = "red"; } elsif ($sp->{'timelasthelp'} > $sp->{'timetouched'}+5) { $status = "answered
awaiting close"; $barbg = "yellow"; } elsif ($sp->{'timelasthelp'} && $sp->{'timetouched'} > $sp->{'timelasthelp'}+5) { $status = "answered
still needs help"; $barbg = "green"; } next if $state eq "green" && $barbg ne "green"; # fix up the subject if needed eval { if ($sp->{'subject'} =~ /^=\?(utf-8)?/i) { my @subj_data; @subj_data = MIME::Words::decode_mimewords($sp->{'subject'}); if (scalar(@subj_data)) { if (!$1) { $sp->{'subject'} = Unicode::MapUTF8::to_utf8({-string=>$subj_data[0][0], -charset=>$subj_data[0][1]}); } else { $sp->{'subject'} = $subj_data[0][0]; } } } }; # fix up the message if we have one my $temp = LJ::text_trim($sp->{message}, 0, 100); # 100 character max if ($temp ne $sp->{message}) { $sp->{message} = LJ::ehtml($temp) . " ..."; } else { $sp->{message} = LJ::ehtml($sp->{message}) . " "; } my $des = $abstracts ? "
$sp->{message}" : ''; # other content for this request my $summary = LJ::ehtml($sp->{'subject'}); my $secold = time() - $sp->{'timecreate'}; my $age = LJ::ago_text($secold); my $probarea = $sp->{_cat}->{'catname'}; my $points = LJ::Support::calc_points($sp, $secold); unless ($status eq "closed") { $status .= "
($points point"; if ($points > 1) { $status .= "s"; } $status .= ")"; } my ($style, $js) = ("class='$barbg'", ''); if ($can_close) { $js = "id='r$sp->{spid}' onclick='doClick($sp->{spid});'"; } # generate the HTML for this row $ret .= "\n"; if ($can_close) { $ret .= "\n"; $js = "onclick='return doClick($sp->{spid});'"; } $ret .= ""; $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; $ret .= ""; } $ret .= "
 X$desc$descStatus
" . LJ::html_check({ name => "check_$sp->{spid}", id => "check_$sp->{spid}", onclick => "doClick($sp->{spid});", }) . "{'spid'}\" $js>$sp->{'spid'}$summary$des$probarea$age$status
\n"; # mass close button if ($can_close && $rct) { my $time = time(); $ret .= LJ::html_hidden('ids', join(':', map { $_->{spid} } @support_log), 'spcatid', $fcat->{spcatid}, 'ret', "/support/help.bml?state=$state&cat=$filtercat&time=$time"); $ret .= "
"; $ret .= LJ::html_submit('action:move', 'Move Marked Requests'); $ret .= " to "; $ret .= LJ::html_select({ 'name' => 'changecat', selected => '' }, '', '(no change)', map { $_->{'spcatid'}, "---> $_->{'catname'}" } LJ::Support::sorted_cats($cats)); $ret .= "

"; $ret .= LJ::html_submit('action:close', 'Close Marked Requests', { onclick => 'return confirm("Are you sure you want to close the marked requests?");' }); $ret .= " (this is permanent)"; $ret .= "

"; } return $ret; _code?>

Back to the support area.

<=body page?> link: htdocs/support/help.bml, htdocs/support/see_request.bml link: htdocs/support/index.bml form: htdocs/support/help.bml _c?>