'Code/Programming',
'doc' => 'Documentation',
'creative' => 'Creative (Styles/Art/Presentation)',
'biz' => 'Business Issues & Leadership',
'other' => 'Other');
my @cats = qw(code doc creative biz other);
my $user = LJ::canonical_username($FORM{'user'});
if (!$mode && $user) { $mode = "user"; }
if (!$mode && $FORM{'cat'}) { $mode = "cat"; }
my $table = sub {
my ($list, $title, $des) = @_;
$body .= "" if $title;
$body .= "" if $des;
$body .= "
";
my $inccat = $list->[0]->{'cat'} ? "Category | " : "";
$body .= "$inccatItem | Date |
\n";
foreach my $it (@$list) {
my $item = LJ::eall($it->{'des'});
if ($it->{'url'} =~ m!^https?://!) {
$item = "{'url'}\">$item";
}
my $date = substr($it->{'dateadd'}, 0, 10);
my $user = $it->{'user'} ? LJ::ljuser($it->{'user'}) . ": " : "";
my $cat = exists $it->{'cat'} ? "$it->{'cat'} | " : "";
$body .= "$cat$user$item [{'coid'}\">detail] | $date |
";
}
$body .= "
";
};
if ($mode eq "")
{
$title = "Contributors";
$body = "senior staff who oversee all operations. p?>".
"";
$body .= "";
$body .= "Category:";
foreach my $cat (@cats) {
$body .= "- $cats{$cat}
\n";
}
$body .= "
";
$body .= "Last 60 Days";
$body .= "By user";
$body .= " p?>";
$body .= "add yourself. p?>";
return;
}
if ($mode eq "user")
{
my $u = LJ::load_user($user);
unless ($u) {
$title = "Error";
$body = "Invalid username.";
return;
}
$title = "Contributions from $user";
$body .= "[<< Back]
";
my $dbr = LJ::get_db_reader();
$sth = $dbr->prepare("SELECT coid, cat, des, url, dateadd, acks ".
"FROM contributed WHERE userid=?");
$sth->execute($u->{'userid'});
my (@ack, @unack);
while ($_ = $sth->fetchrow_hashref) {
push @ack, $_ if $_->{'acks'};
push @unack, $_ unless $_->{'acks'};
}
unless (@ack || @unack) {
$body .= " has not declared any contributions.";
}
$table->(\@ack, "Acknowledged Contributions",
"These contributions have been acknowledged by others in the community:") if @ack;
$table->(\@unack, "Unacknowledged Contributions",
"These contributions have been declared, but not yet acknowledged by anyone:") if @unack;
return;
}
if ($mode eq "recent")
{
$title = "Recent Contributions";
$body .= "[<< Back]
";
my $extra = $FORM{'unack'} ? "" : "AND c.acks > 0";
my $dbr = LJ::get_db_reader();
$sth = $dbr->prepare("SELECT u.user, c.coid, c.cat, c.des, c.url, c.dateadd, c.acks ".
"FROM contributed c, useridmap u ".
"WHERE u.userid=c.userid ".
"AND c.dateadd > DATE_SUB(NOW(), INTERVAL 60 DAY) $extra ".
"ORDER BY c.dateadd DESC");
$sth->execute();
my (@ack, @unack);
while ($_ = $sth->fetchrow_hashref) {
push @ack, $_ if $_->{'acks'};
push @unack, $_ unless $_->{'acks'};
}
unless (@ack || @unack) {
$body .= "No contributions filed in last 60 days.";
}
$table->(\@ack, "Acknowledged Contributions",
"These recent contributions have been acknowledged by others in the community:") if @ack;
$table->(\@unack, "Unacknowledged Contributions",
"These recent contributions have been declared, but not yet acknowledged by anyone:") if @unack;
return;
}
if ($mode eq "cat")
{
my $cat = $FORM{'cat'};
$body .= "[<< Back]
";
unless ($cats{$cat}) {
$body .= "Invalid category";
return;
}
$title = $cats{$cat};
my $dbr = LJ::get_db_reader();
$sth = $dbr->prepare("SELECT u.user, c.coid, c.des, c.url, c.dateadd ".
"FROM contributed c, useridmap u ".
"WHERE u.userid=c.userid ".
"AND c.cat=? AND c.acks>0 ".
"ORDER BY c.dateadd");
$sth->execute($cat);
my (@con);
while ($_ = $sth->fetchrow_hashref) {
push @con, $_;
}
unless (@con) {
$body .= "No contributions in this category";
return;
}
$table->(\@con);
$body .= "[<< Back]
";
return;
}
if ($mode eq "delete")
{
my $coid = $FORM{'coid'}+0;
unless ($remote) {
$title = "Delete Contribution - Error";
$body .= "login. p?>";
return;
}
my $admin = LJ::check_priv($remote, "contrib_delete");
unless ($admin) {
$title = "Delete Contribution - Error";
$body .= "";
return;
}
unless ($coid) {
$title = "Delete Contribution - Error";
$body .= "";
return;
}
my $dbh = LJ::get_db_writer();
$dbh->do("DELETE FROM contributed WHERE coid=$coid");
$dbh->do("DELETE FROM contributedack WHERE coid=$coid");
$title = "Delete Contribution - Success";
$body .= "";
return;
}
if ($mode eq "add")
{
$title = "Add Contribution(s)";
unless ($remote) {
$body .= "login. p?>";
return;
}
$body .= "";
$body .= "Back to the contributions list.";
return;
}
if ($mode eq "add_do")
{
$title = "Add Contribution";
unless ($remote) {
$body .= "login. p?>";
return;
}
unless (LJ::did_post()) {
$body .= "";
return;
}
for (my $i = 0; $i < 5; $i++)
{
my $des = $FORM{"des_${i}"};
my $user = $FORM{"user_${i}"};
my $cat = $FORM{"cat_${i}"};
my $url = $FORM{"url_${i}"};
$des = LJ::trim($des);
next if $des eq "";
my $userid = LJ::get_userid($user);
unless ($userid) {
$body .= "- $user - $des
- Can not find user $user
";
next;
}
# must be ack'ed to add somebody other than yourself.
my $acks = 0;
if ($userid != $remote->{'userid'}) {
unless (LJ::Contrib::is_acked($remote->{'userid'})) {
$body .= "- - $des
- You have to be an acknowledged contributor before you can add someone else.
";
next;
}
$acks = 1;
}
my $dbh = LJ::get_db_writer();
$dbh->do("INSERT INTO contributed (userid, cat, des, url, dateadd, acks) VALUES ".
"($userid, ?, ?, ?, NOW(), $acks)", undef, $cat, $des, $url);
my $coid = $dbh->{'mysql_insertid'};
if ($coid) {
if ($acks) {
$dbh->do("REPLACE INTO contributedack (coid, ackuserid) VALUES ($coid, $remote->{'userid'})");
}
$body .= "- - " . LJ::ehtml($des) . "
- Added. You can view it here
";
} else {
$body .= "- - " . LJ::ehtml($des) . "
- Error... not added.
";
}
}
$body .= "";
$body .= "Back to the contributions list.";
return;
}
if ($mode eq "detail")
{
$title = "Contribution Detail";
my $coid = $FORM{'coid'}+0;
my $dbr = LJ::get_db_reader();
my $sth = $dbr->prepare("SELECT userid, cat, des, url, dateadd, acks FROM contributed WHERE coid=$coid");
$sth->execute;
my $co = $sth->fetchrow_hashref;
unless ($co) {
$body = "Contribution not found.";
return;
}
my $admin = LJ::check_priv($remote, "contrib_delete");
my $u = LJ::load_userid($co->{'userid'});
my $url = $co->{'url'} ? "{'url'}\">$co->{'url'}" : "-";
my $edes = LJ::ehtml($co->{'des'});
$body .= <
User: | {'user'} ljuser?> - $u->{'name'} |
Category: | $cats{$co->{'cat'}} ({'user'}\">view all) |
Description: | $edes |
URL: | $url |
Date Added: | $co->{'dateadd'} |
# Acks: | $co->{'acks'} |
TABLE
$body .= "";
$body .= "";
$sth = $dbr->prepare("SELECT u.user FROM contributedack c, useridmap u WHERE u.userid=c.ackuserid AND c.coid=$coid ORDER BY u.user");
$sth->execute;
my $a_ct = 0;
while (my ($userack) = $sth->fetchrow_array) {
$body .= "\n";
$a_ct++;
}
unless ($a_ct) {
$body .= "(None)";
}
$body .= "";
$body .= "A contribution isn't shown on the main page unless it's acknowledged by other contributors. To acknowledge this item, click the button below. Only acknowledge it if you know for a fact it was done and if you were related to the item. For instance, if you were a leader of a group and gave somebody the project, then you should acknowledge it. Another reason to acknowledge a contribution is if that contribution was very notable and you just want to give them props. Just don't acknowledge a contribution you weren't involved with and didn't even know about. p?>";
$body .= "";
$body .= "";
if ($admin) {
$body .= "";
}
$body .= "";
$body .= "";
$body .= "Back to the contributions list.";
return;
}
if ($mode eq "ack")
{
$title = "Acknowledge";
unless ($remote) {
$body .= "login before acknowledging contributions. p?>";
return;
}
unless (LJ::did_post()) {
$body .= "";
return;
}
my $dbr = LJ::get_db_reader();
my $coid = $FORM{'coid'}+0;
my $sth = $dbr->prepare("SELECT userid, cat, des, url, dateadd, acks FROM contributed WHERE coid=$coid");
$sth->execute;
my $co = $sth->fetchrow_hashref;
unless ($co) {
$body = "Contribution not found.";
return;
}
if ($co->{'userid'} == $remote->{'userid'}) {
$body .= "";
return;
}
unless (LJ::Contrib::is_acked($remote->{'userid'})) {
$body .= "";
return;
}
LJ::Contrib::ack($coid, $remote->{'userid'});
$body = "this contribution. p?>";
$body .= "";
$body .= "Back to the contributions list.";
return;
}
$title = "Unknown mode";
$body = "Unknown mode.";
return;
}
_code?>
body=>
page?>
lib: cgi-bin/ljlib.pl
link: htdocs/login.bml
_c?>