.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 .= ""; # /filter line # mass closing table $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?>