Suggestion Proposal Generator
body<=
" unless LJ::text_in(\%FORM);
my $remote = LJ::get_remote();
my $post_comm = 'suggestions';
unless ($remote) {
return "login. p?>";
}
if ($FORM{'completed'}) {
my $ret = "";
my @errors = ();
my @fields = ("title","description","fulldescription","benefits","issues","sugglist");
my $CRLF = "\x0D\x0A";
unless (LJ::did_post()) {
return "";
}
foreach $field (@fields) {
if (! $FORM{$field} ) {
push(@errors,"You forgot to fill out the $field field.");
}
}
return LJ::bad_input(@errors) if @errors;
my $out = "";
$out .= "
Title\n";
$out .= "$FORM{'title'}
";
$out .= "Short, concise description of the idea\n";
$out .= "$FORM{'description'}
";
$out .= "Full description of the idea\n";
$out .= "$FORM{'fulldescription'}
";
$out .= "An ordered list of benefits";
my @benefits = split(/$CRLF$CRLF/, $FORM{'benefits'});
$out .= "\n";
foreach my $benefit (@benefits) {
$benefit =~ s!$CRLF!
!g;
$out .= "- $benefit
\n";
}
$out .= "
";
$out .= "
An ordered list of problems/issues involved";
my @issues = split(/$CRLF$CRLF/, $FORM{'issues'});
$out .= "\n";
foreach my $issue (@issues) {
$issue =~ s!$CRLF!
\n!g;
$out .= "- $issue
\n";
}
$out .= "
";
$out .= "
An organized list, or a few short paragraphs detailing suggestions for implementation";
my @suggs = split(/$CRLF$CRLF/, $FORM{'sugglist'});
$out .= "\n";
foreach my $sugg (@suggs) {
$sugg =~ s!$CRLF!
\n!g;
$out .= "- $sugg
\n";
}
$out .= "
";
# post it
{
my ($sec,$min,$hour,$mday,$mon,$year) = localtime(time());
$year = $year + 1900;
$mon=sprintf("%02d", $mon+1);
$mday=sprintf("%02d", $mday);
my $rs = LJ::Protocol::do_request("postevent", {
'ver' => $LJ::PROTOCOL_VER,
'year' => $year,
'mon' => $mon,
'day' => $mday,
'hour' => $hour,
'min' => $min,
'username' => $remote->{'user'},
'event' => $out,
'usejournal' => $post_comm,
'props' => { 'opt_preformatted' => 0 },
'subject' => $FORM{'title'},
}, \$err, {
'noauth' => 1,
'usejournal_okay' => 1,
});
if ($err) {
my $errstr = LJ::Protocol::error_message($err);
$ret .= "";
} else {
$ret .= "\n";
my $user = LJ::ljuser($post_comm);
if ($rs->{'itemid'}) {
my $u = LJ::load_user($post_comm);
my $link = LJ::item_link($u, $rs->{'itemid'}, $rs->{'anum'});
$ret .= "view your suggestion. p?>";
} else {
$ret .= "";
}
}
}
return $ret;
} else {
return <<__EOF__
__EOF__
}
_code?>
<=body
page?>
post: htdocs/suggestions/generator.bml
link: htdocs/talkread.bml
_c?>