#!/usr/bin/perl -w
###############################################################################
# submit.pl - this code inputs user submission into the system to be
# approved by authors
#
# Copyright (C) 1997 Rob "CmdrTaco" Malda
# malda@slashdot.org
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# $Id: submit.pl,v 1.1.1.1 2000/10/08 09:03:29 alessio Exp $
###############################################################################
use strict;
use lib '../';
use vars '%I';
use vars '%L';
use Slash;
#################################################################
sub main {
*I = getSlashConf();
*L = \%Slash::L;
getSlash();
my $id = getFormkeyId($I{U}{uid});
my($section, $op, $seclev, $aid) = (
$I{F}{section}, $I{F}{op}, $I{U}{aseclev}, $I{U}{aid}
);
$I{F}{del} ||= "0";
$I{F}{op} ||= "";
$I{F}{from} = stripByMode($I{F}{from}) if $I{F}{from};
$I{F}{subj} = stripByMode($I{F}{subj}) if $I{F}{subj};
$I{F}{email} = stripByMode($I{F}{email}) if $I{F}{email};
# Show submission title on browser's titlebar.
my($tbtitle) = $I{F}{title};
if ($tbtitle) {
$tbtitle =~ s/^"?(.+?)"?$/"$1"/;
$tbtitle = "- $tbtitle";
}
$section = "admin" if $seclev > 100;
header("$I{sitename} $L{Submissions}$tbtitle", $section);
# print "from $I{F}{from} email $I{F}{email} subject $I{F}{subj} \n";
#adminMenu() if $seclev > 100;
if ($op eq "list" && ($seclev > 99 || $I{submiss_view})) {
titlebar("100%", "$L{Submissions} " . ($seclev > 99 ? 'Admin' : "$L{List}"));
submissionEd();
} elsif ($op eq "Update" && $seclev > 99) {
titlebar("100%", "$L{Deleting} $I{F}{subid}");
rmSub();
submissionEd();
} elsif ($op eq "GenQuickies" && $seclev > 99) {
titlebar("100%", "Quickies Generated");
genQuickies();
submissionEd();
} elsif (! $op) {
yourPendingSubmissions();
titlebar("100%", "$I{sitename} $L{Submissions}", "c");
displayForm($I{U}{nickname}, $I{U}{fakeemail}, $I{F}{section}, $id);
} elsif ($op eq "$L{PreviewStory}") {
titlebar("100%", "$I{sitename} $L{Submission_Preview}", "c");
# insert the fact that the form has been displayed,
# but not submitted at this point
insertFormkey("submissions",$id,"submission");
displayForm($I{F}{from}, $I{F}{email}, $I{F}{section}, $id);
} elsif ($op eq "viewsub" && ($seclev > 99 || $I{submiss_view})) {
previewForm($aid, $I{F}{subid});
} elsif ($op eq "$L{SubmitStory}") {
saveSub($id);
yourPendingSubmissions();
} else {
print "Huh?";
# foreach (keys %{$I{U}}) { print "$_ = $I{U}{$_} " }
}
footer();
}
#################################################################
sub yourPendingSubmissions {
return unless $I{U}{uid} > 0;
my $c = sqlSelectMany("*", "submissions", "uid=$I{U}{uid}");
if ($c->rows) {
my($count) = sqlSelect("count(*)", "submissions", "del=0");
titlebar("100%", "$L{Your_Recent_Submissions} ($L{total}:$count)");
print <$L{Here_are_your_recent_submissions_to} $I{sitename},
$L{and_their_status_within_the_system}:
EOT
while (my $S = $c->fetchrow_hashref) {
print "