body<= "; } my $remote = LJ::get_remote(); LJ::Support::init_remote($remote); my $sp = LJ::Support::load_request($spid); if ($sp->{'authcode'} ne $authcode) { return ""; } my $auth = LJ::Support::mini_auth($sp); if ($action eq "touch") { return "" if LJ::Support::is_locked($sp); LJ::Support::touch_request($spid) or return ""; return BML::redirect("$LJ::SITEROOT/support/see_request?id=$spid") if LJ::Support::can_close($sp, $remote); $ret .= ("{'state'} eq "open" ? $ML{'.will.stay.open.now'} : $ML{'.has.been.reopened'}) . $ML{'.please.comment'} . " p?>"); $ret .= '
'; # hidden values $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; $ret .= '\n"; $ret .= ""; # textarea for their message body $ret .= '
From:'; if ($remote && $remote->{'userid'}) { $ret .= "{'user'} ljuser?>"; } else { $ret .= "(not logged in)"; } $ret .= "
Reply Type:"; $ret .= ''; $ret .= "$ML{'.more.info'}"; $ret .= "
' . $ML{'.message'} . ''; $ret .= '
'; $ret .= "\n
\n"; $ret .= ''; $ret .= "\n
"; return $ret; } if ($action eq 'lock') { return "" unless $remote && LJ::Support::can_lock($sp, $remote); return "" if LJ::Support::is_locked($sp); # close this request and IC on it LJ::Support::lock($sp); LJ::Support::append_request($sp, { body => '(Locking request.)', remote => $remote, type => 'internal', }); return ""href='/support/see_request?id=$sp->{spid}'"}) . " p?>"; } if ($action eq 'unlock') { return "" unless $remote && LJ::Support::can_lock($sp, $remote); return "" unless LJ::Support::is_locked($sp); # reopen this request and IC on it LJ::Support::unlock($sp); LJ::Support::append_request($sp, { body => '(Unlocking request.)', remote => $remote, type => 'internal', }); return ""href='/support/see_request?id=$sp->{spid}'"})." p?>"; } if ($action eq "close") { return "" unless LJ::Support::can_close($sp, $remote, $auth); if ($sp->{'state'} eq "open") { my $dbh = LJ::get_db_writer(); $splid += 0; if ($splid) { $sth = $dbh->prepare("SELECT userid, timelogged, spid, type FROM supportlog WHERE splid=$splid"); $sth->execute; my ($userid, $timelogged, $aspid, $type) = $sth->fetchrow_array; if ($aspid != $spid) { return ""; } ## can't credit yourself. if ($userid != $sp->{'requserid'} && $type eq "answer") { my $cats = LJ::Support::load_cats($sp->{'spcatid'}); my $secold = $timelogged - $sp->{'timecreate'}; my $points = LJ::Support::calc_points($sp, $secold); LJ::Support::set_points($spid, $userid, $points); } } $dbh->do("UPDATE support SET state='closed', timeclosed=UNIX_TIMESTAMP(), timemodified=UNIX_TIMESTAMP() WHERE spid=$spid"); } my $remote = LJ::get_remote(); if (LJ::Support::can_close_cat($sp, $remote)) { my $dbr = LJ::get_db_reader(); my $catid = $sp->{'_cat'}->{'spcatid'}; my $sql = "SELECT MIN(spid) FROM support WHERE spcatid=$catid AND state='open' AND timelasthelp>timetouched AND spid>$spid"; my $sth = $dbr->prepare($sql); $sth->execute; my $next = $sth->fetchrow_array; if ($next) { return BML::redirect("$LJ::SITEROOT/support/see_request?id=$next"); } else { return " "; } } return ""; } return; _code?> <=body page?>