Request # body<= {'dbh'}; my $dbr = $dbs->{'reader'}; my $sth; my $spid = $FORM{'id'}+0; my $auth = $FORM{'auth'}; my $sp = LJ::Support::load_request($dbh, $spid); unless ($sp) { return ""; } my $cats = LJ::Support::load_cats($dbh); my $email = $sp->{'reqemail'}; my $u = {}; if ($sp->{'reqtype'} eq "user") { $u = LJ::load_userid($dbs, $sp->{'requserid'}); $email = $u->{'email'}; LJ::load_user_props($dbs, $u, "s1_lastn_style", "s1_calendar_style", "s1_day_style", "s1_friends_style", "stylesys", "s2_style", ); } my $winner; # who closed it? if ($sp->{'state'} eq "closed") { $sth = $dbh->prepare("SELECT u.user, sp.points FROM user u, supportpoints sp WHERE u.userid=sp.userid AND sp.spid=?"); $sth->execute($spid); $winner = $sth->fetchrow_hashref; } my $owner_mode = 0; my $remote = LJ::get_remote($dbh); LJ::Support::init_remote($dbh, $remote); # load category this request is in my $problemarea = $sp->{_cat}->{'catname'}; my $catkey = $sp->{_cat}->{'catkey'}; unless (LJ::Support::can_read($sp, $remote, $auth)) { return ""; } if (LJ::Support::can_close($dbh, $sp, $remote, $auth)) { $owner_mode = 1; } ### request info table my $ret = ""; $ret .= "\n"; $ret .= "\n"; # account type $ret .= "\n"; $ret .= "\n"; $ret .= "\n"; my $timecreate = LJ::time_to_http($sp->{'timecreate'}); my $age = LJ::ago_text(time() - $sp->{'timecreate'}); $ret .= "\n"; my $state = $sp->{'state'}; if ($state eq "open") { # check if it's still open or needing help or what if ($sp->{'timelasthelp'} > ($sp->{'timetouched'}+5)) { # open, answered $state = "answered (awaiting close)"; } elsif ($sp->{'timelasthelp'} && $sp->{'timetouched'} > $sp->{'timelasthelp'}+5) { # open, still needs help $state = "answered (still needs help)"; } else { # default $state = "open"; } } if ($state eq "closed" && $winner && LJ::Support::can_see_helper($dbh, $sp, $remote)) { my $s = $winner->{'points'} > 1 ? "s" : ""; my $wuser = $winner->{'user'}; $state .= " ($winner->{'points'} point$s to "; $state .= LJ::ljuser($wuser, { 'full' => 1 }) . ")"; } $ret .= "\n"; $ret .= "\n"; $ret .= "
From:"; if ($u->{'defaultpicid'}) { my %pic; my $picid = $u->{'defaultpicid'}; LJ::load_userpics($dbs, \%pic, [ $picid ]); $ret .= ""; $ret .= "$u->{"; $ret .= ""; } # show requester name + email { my $visemail = $email; if ($sp->{_cat}->{'public_read'}) { $visemail =~ s/^.+\@/********\@/; } $ret .= LJ::eall($sp->{'reqname'}) . " ($visemail)"; } $ret .= "
Account type:"; $ret .= LJ::name_caps($u->{'caps'}) || "Unknown"; $ret .= "
$LJ::SITENAMESHORT:"; if ($u->{'userid'}) { $ret .= "username: {'user'} ljuserf?>"; $ret .= "
style: "; if ($u->{'stylesys'} == 2) { $ret .= "(S2) "; if ($u->{'s2_style'}) { my $s2style = LJ::S2::load_style($dbr, $u->{'s2_style'}); my $pub = LJ::S2::get_public_layers(); # cached foreach my $lay (keys %{$s2style->{'layer'}}) { my $lid = $s2style->{'layer'}->{$lay}; $ret .= "$lay: "; $ret .= (defined $pub->{$lid} ? 'public' : 'user') . ", "; } } else { $ret .= "none"; } } else { $ret .= "(S1) "; foreach my $view (@LJ::views) { my $styid = $u->{"s1_${view}_style"}; my $viewuri = $view eq "lastn" ? "/users/$u->{'user'}/" : "/users/$u->{'user'}/$view"; if ($view eq "day") { my (undef,undef,undef,$dday,$dmon,$dyear) = localtime(time); $dyear+=1900; $dmon++; $dmon = $dmon <= 9 ? "0$dmon" : $dmon; $dday = $dday <= 9 ? "0$dday" : $dday; $viewuri = "/users/$u->{'user'}/$dyear/$dmon/$dday/"; } $ret .= "$view: $styid "; } if ($u->{'useoverrides'} eq 'Y') { $ret .= "
overrides: view "; } } $ret .= "
email validated? "; if ($u->{'status'} eq "A") { $ret .= "yes"; } if ($u->{'status'} eq "N") { $ret .= "no"; } if ($u->{'status'} eq "T") { $ret .= "transitioning (used to be validated, but changed email addresses and hasn't reconfirmed)"; } if ($u->{'clusterid'}) { $ret .= "
cluster: " . ($LJ::CLUSTERNAME{$u->{'clusterid'}} || $u->{'clusterid'}) . ""; } } else { $ret .= "not a user"; } $ret .= "
Support category:"; if (LJ::Support::can_read_cat($sp->{_cat}, $remote)) { $ret .= "$problemarea"; } else { $ret .= $problemarea; } $ret .= "
Time posted:$timecreate ($age)
Status:$state"; if ($owner_mode) { $ret .= $sp->{'state'} eq "open" ? ", {'authcode'}'>close without credit" : ""; $ret .= $sp->{'state'} eq "closed" ? ", {'authcode'}'>reopen this request" : ""; } $ret .= "
Summary:" . LJ::ehtml($sp->{'subject'}) . "
\n"; ### end request info table LJ::run_hooks("support_see_request_html", { 'u' => $u, 'email' => $email, 'sp' => $sp, 'retref' => \$ret, }); my %userinfo; $sth = $dbh->prepare("SELECT DISTINCT u.userid, u.user, u.name, u.defaultpicid " . "FROM supportlog s, user u WHERE s.spid=? AND u.userid=s.userid"); $sth->execute($spid); $userinfo{$_->{'userid'}} = $_ while ($_ = $sth->fetchrow_hashref); my %userpics; my @pics = map { $userinfo{$_}->{'defaultpicid'} } keys %userinfo; LJ::load_userpics($dbs, \%userpics, \@pics); my @screened; ### reply loop $sth = $dbh->prepare("SELECT splid, timelogged, UNIX_TIMESTAMP()-timelogged AS 'age', type, faqid, userid, message " . "FROM supportlog WHERE spid=? ORDER BY timelogged"); $sth->execute($spid); while (my $le = $sth->fetchrow_hashref) { next if ($le->{'type'} eq "internal" && ! (LJ::Support::can_read_internal($dbh, $sp, $remote) || ($remote && $remote->{'userid'} == $le->{'userid'} ))); next if ($le->{'type'} eq "screened" && ! (LJ::Support::can_read_screened($dbh, $sp, $remote) || ($remote && $remote->{'userid'} == $le->{'userid'} ))); if ($le->{'type'} eq "screened") { push @screened, $le; } my $message = $le->{'message'}; my %url; my $urlN = 0; $message =~ s!https?://\S+[a-zA-Z0-9_/&=\-]!$url{++$urlN} = "" . LJ::eall($&) . ""; ":URL:$urlN"!eg; $message = LJ::eall($message); $message =~ s/^\s+//; $message =~ s/\s+$//; $message =~ s/\n( +)/"\n" . "  "x length($1)/eg; $message =~ s/\n/
\n/g; $message =~ s/:URL:(\d+)/$url{$1}/eg; # special case: original request if ($le->{'type'} eq "req") { $ret .= "
\n"; $ret .= "Original Request:
\n"; $ret .= "
\n$message\n
"; next; } # reply header my $header = ""; if ($le->{'userid'} && LJ::Support::can_see_helper($dbh, $sp, $remote)) { my $up = $userinfo{$le->{'userid'}}; my $picid = $up->{'defaultpicid'}; $header = ""; if ($picid) { $header .= ""; } $header .= "
$up->{" . LJ::ljuser($up->{'user'}, { 'full' => 1 }) . " - " . LJ::eall($up->{'name'}) . "
\n"; } my $what = "Answer"; if ($le->{'type'} eq "internal") { $what = "Internal Comment"; } elsif ($le->{'type'} eq "comment") { $what = "Comment"; } elsif ($le->{'type'} eq "screened") { $what = "Screened Answer"; } $header .= "$what (\#$le->{'splid'})
"; my $timehelped = LJ::time_to_http($le->{'timelogged'}); my $age = LJ::ago_text($le->{'age'}); $header .= "Posted: $timehelped ($age)"; if ($owner_mode && $sp->{'state'} eq "open" && $le->{'type'} eq "answer") { $header .= ", {'authcode'};$le->{'splid'}'>credit fix here"; } my $bordercolor = "#000000"; if ($le->{'type'} eq "internal") { $bordercolor = "#ff0000"; } if ($le->{'type'} eq "answer") { $bordercolor = "#00c000"; } if ($le->{'type'} eq "screened") { $bordercolor = "#afaf00"; } # reply $ret .= "$header
\n"; $ret .= "\n"; $ret .= "
\n"; if ($le->{'faqid'}) { # faq question my $sth = $dbh->prepare("SELECT question FROM faq WHERE faqid=?"); $sth->execute($le->{'faqid'}); my $faqname = $sth->fetchrow_array; $ret .= "
"; $ret .= "FAQ Reference:
$faqname
\n"; } $ret .= "

$message

\n"; $ret .= "
\n"; } ### end reply loop # return if support item is closed if ($sp->{'state'} eq "closed") { return $ret; } $ret .= "

Post a comment or solution:

\n"; unless ($remote || LJ::Support::is_poster($sp, $remote, $auth)) { $ret .= "You must login to help people out.\n"; return $ret; } unless (LJ::Support::can_append($dbh, $sp, $remote, $auth)) { $ret .= "Sorry, you do not have access to answer people's support requests in this category.\n"; return $ret; } my @ans_type = LJ::Support::get_answer_types($dbh, $sp, $remote, $auth); my %ans_type = @ans_type; if ($ans_type{'answer'} || $ans_type{'screened'}) { $ret .= "Important Notes:"; $ret .= "Thanks! standout?>\n"; } # append_request form $ret .= "
\n"; # hidden values $ret .= LJ::html_hidden('spid', $spid, 'auth', $auth) . "\n"; # form $ret .= "\n"; $ret .= "\n"; if ($ans_type{'answer'} || $ans_type{'screened'}) { # FAQ reference $ret .= "\n"; } # answer type { $ret .= "\n"; } # helpers can do actions: if (LJ::Support::can_perform_actions($dbh, $sp, $remote) && ! LJ::Support::is_poster($sp, $remote, $auth)) { $ret .= "\n"; $ret .= "\n"; if (LJ::Support::can_help($dbh, $sp, $remote)) { $ret .= "\n"; } } # textarea for their message body $ret .= "
From:"; if ($remote && $remote->{'userid'}) { $ret .= "{'user'} ljuser?>"; } else { $ret .= "(not logged in)"; } $ret .= "
Reference FAQ:\n"; my %faqcat; my %faqq; $sth = $dbh->prepare("SELECT faqcat, faqcatname, catorder FROM faqcat WHERE faqcat<>'int-abuse'"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $faqcat{$_->{'faqcat'}} = $_; } $sth = $dbh->prepare("SELECT faqid, question, sortorder, faqcat, lastmodtime FROM faq WHERE faqcat<>'int-abuse'"); $sth->execute; while ($_ = $sth->fetchrow_hashref) { $faqq{$_->{'faqid'}} = $_; } my @faqlist = ('0', "(don't reference FAQ)"); foreach my $faqcat (sort { $faqcat{$a}->{'catorder'} <=> $faqcat{$b}->{'catorder'} } keys %faqcat) { push @faqlist, ('0', "[ $faqcat{$faqcat}->{'faqcatname'} ]"); foreach my $faqid (sort { $faqq{$a}->{'sortorder'} <=> $faqq{$b}->{'sortorder'} } grep { $faqq{$_}->{'faqcat'} eq $faqcat } keys %faqq) { next unless ($faqq{$faqid}->{'question'}); my $q = "... $faqq{$faqid}->{'question'}"; $q =~ s/^\s+//; $q =~ s/\s+$//; $q =~ s/\n/ /g; if (length($q) > 50) { $q = substr($q, 0, 50) . "..."; } push @faqlist, ($faqid, $q); } } $ret .= LJ::html_select({ 'name' => 'faqid' }, @faqlist) . "\n"; $ret .= "
Reply Type:"; if (@ans_type > 2) { $ret .= LJ::html_select({ 'name' => 'replytype' }, @ans_type) . "\n"; } else { $ret .= LJ::html_hidden('replytype', $ans_type[0]) . "\n"; $ret .= "$ans_type[1]"; } $ret .= "
\n"; $ret .= ""; $ret .= ""; if (@screened && LJ::Support::can_help($dbh, $sp, $remote)) { $ret .= ""; } $ret .= "
Change Category:
"; $ret .= LJ::html_select({ 'name' => 'changecat' }, ('', $sp->{'_cat'}->{'catname'}), map { $_->{'spcatid'}, "---> $_->{'catname'}" } LJ::Support::sorted_cats($cats)); $ret .= "
Approve Screened Answer:
"; $ret .= LJ::html_select({ 'name' => 'approveans' }, ('', ''), map { $_->{'splid'}, "\#$_->{'splid'} ($userinfo{$_->{'userid'}}->{'user'})" } @screened); $ret .= LJ::html_select({ 'name' => 'approveas' }, ("answer" => "as answer", "comment" => "as comment",)); $ret .= "
\n"; $ret .= "
Touch request:"; $ret .= LJ::html_check({ 'type' => 'checkbox', 'name' => 'touch' }); $ret .= "\n"; $ret .= "
Change summary:"; $ret .= LJ::html_check({ 'type' => 'checkbox', 'name' => 'changesum' }); $ret .= "\n"; $ret .= "
Message:"; $ret .= LJ::html_textarea({ 'rows' => '10', 'cols' => '50', 'wrap' => 'virtual', 'name' => 'body' }) . "
"; $ret .= "URLs are automatically link-ified, so just reference those. de?>
"; $ret .= LJ::html_submit('submitpost', "Post Comment/Solution"); $ret .= "
\n"; $ret .= "
\n"; return $ret; } _code?> Back to the list of open requests.
Back to the support area. <=body page?> link: htdocs/support/faqbrowse.bml, htdocs/styles/browse/styleinfo.bml link: htdocs/support/help.bml, htdocs/support/act.bml, htdocs/login.bml link: htdocs/guide/support.bml, htdocs/support/faq.bml, htdocs/support/index.bml link: htdocs/allpics.bml img: htdocs/userpic post: htdocs/support/append_request.bml _c?>