body<=
";
}
my $remote = LJ::get_remote();
LJ::Support::init_remote($remote);
my $sp = LJ::Support::load_request($spid);
if ($sp->{'authcode'} ne $authcode) {
return "";
}
if ($action eq "touch") {
return ""
if LJ::Support::is_locked($sp);
LJ::Support::touch_request($spid)
or return "";
$ret .= ("{'state'} eq "open" ? "will stay open now."
: "has been re-opened now.").
" Please comment back telling us why you've touched this request:".
" p?>");
my $auth = LJ::Support::mini_auth($sp);
$ret .= '
";
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 "{spid}'>request has been locked. 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 "{spid}'>request has been unlocked. p?>";
}
if ($action eq "close") {
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() WHERE spid=$spid");
}
my $remote = LJ::get_remote();
my $is_admin = LJ::check_priv($remote, "supportclose");
if ($is_admin)
{
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.bml?id=$next");
} else {
return "
";
}
}
return "";
}
return;
_code?>
<=body
page?>
link: htdocs/support/see_request.bml
_c?>