Skip to content

Commit

Permalink
Latest Zoo
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianAker committed Sep 12, 2002
1 parent 1425122 commit f946c19
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 60 deletions.
34 changes: 16 additions & 18 deletions plugins/Zoo/Zoo.pm
Expand Up @@ -245,7 +245,7 @@ sub _set {
}

sub addFof {
my($self, $uid, $person) = @_;
my($self, $uid, $person, $original) = @_;
my $slashdb = getCurrentDB();

# First we do the main person
Expand All @@ -256,12 +256,12 @@ sub addFof {
}
my $people = $slashdb->getUser($uid, 'people');
# First we clean up, then we reapply
$people->{FOF()}{$person} += 1;
$people->{FOF()}{$person}{$original} = 1;
$slashdb->setUser($uid, { people => $people });
}

sub addEof {
my($self, $uid, $person) = @_;
my($self, $uid, $person, $original) = @_;
my $slashdb = getCurrentDB();

# First we do the main person
Expand All @@ -272,12 +272,12 @@ sub addEof {
}
my $people = $slashdb->getUser($uid, 'people');
# First we clean up, then we reapply
$people->{EOF()}{$person} += 1;
$people->{EOF()}{$person}{$original} = 1;
$slashdb->setUser($uid, { people => $people });
}

sub deleteFof {
my($self, $uid, $person) = @_;
my($self, $uid, $person, $original) = @_;
my $slashdb = getCurrentDB();

# First we do the main person
Expand All @@ -288,17 +288,16 @@ sub deleteFof {
$self->sqlUpdate('people', { -fof => "fof - 1" }, "uid = $uid AND person = $person");
}
my $people = $slashdb->getUser($uid, 'people');
# First we clean up, then we reapply
if ($people->{FOF()}{$person} >= 1) {
$people->{FOF()}{$person} -= 1;
} else {
delete $people->{FOF()}{$person};
}
# First we clean up
delete $people->{FOF()}{$person}{$original};
# Now delete the hash if there are no longer people pointing to it
delete $people->{FOF()}{$person}
unless (keys %{$people->{FOF()}{$person}});
$slashdb->setUser($uid, { people => $people });
}

sub deleteEof {
my($self, $uid, $person) = @_;
my($self, $uid, $person, $original) = @_;
my $slashdb = getCurrentDB();

# First we do the main person
Expand All @@ -309,12 +308,11 @@ sub deleteEof {
$self->sqlUpdate('people', { '-eof' => "eof - 1" }, "uid = $uid AND person = $person");
}
my $people = $slashdb->getUser($uid, 'people');
# First we clean up, then we reapply
if ($people->{EOF()}{$person} >= 1) {
$people->{EOF()}{$person} -= 1;
} else {
delete $people->{EOF()}{$person};
}
# First we clean up
delete $people->{EOF()}{$person}{$original};
# Now delete the hash if there are no longer people pointing to it
delete $people->{EOF()}{$person}
unless (keys %{$people->{EOF()}{$person}});
$slashdb->setUser($uid, { people => $people });
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/Zoo/mysql_prep
@@ -1,9 +1,9 @@
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Friends','[% constants.rootdir %]/my/friends/',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Fans','[% constants.rootdir %]/my/fans/',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Foes','[% constants.rootdir %]/my/foes/',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Freaks','[% constants.rootdir %]/my/freaks/',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Friends of Friends','[% constants.rootdir %]/my/friends/friends',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Foes of Friends','[% constants.rootdir %]/my/friends/foes',1,1);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Fans','[% constants.rootdir %]/my/fans/',1,2);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Foes','[% constants.rootdir %]/my/foes/',1,3);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Freaks','[% constants.rootdir %]/my/freaks/',1,4);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Friends of Friends','[% constants.rootdir %]/my/friends/friends',1,5);
INSERT INTO menus (menu, label, value, seclev, menuorder) VALUES ('zoo','Foes of Friends','[% constants.rootdir %]/my/friends/foes',1,6);
INSERT INTO vars (name,value,description) VALUES ('people_max','200','Maximum number of friends/foes you can have');
INSERT INTO vars (name,value,description) VALUES ('people_max_subscriber','400','Maximum number of friends/foes you can have');
INSERT INTO vars (name,value,description) VALUES ('zoo_process_limit','2000','Number of FOF/FOE to process during job run');
6 changes: 3 additions & 3 deletions plugins/Zoo/templates/confirm;zoo;default
Expand Up @@ -24,7 +24,7 @@ __template__
<TABLE>
<TR>
<TD>
So do you want to remove your relationship with <B>[% nickname | strip_literal %]</B>?
So do you want to remove your relationship with <B><A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/">[% nickname %]</A></B>?
</TD>
<TD>
<INPUT TYPE="RADIO" NAME="type" VALUE="neutral"[% IF type == 'neutral' %]CHECKED[% END %]>
Expand Down Expand Up @@ -56,11 +56,11 @@ Curious <A HREF="[% constants.rootdir %]/faq/com-mod.shtml#cm2200"> what these i
<TABLE WIDTH="100%">
<TR>
<TD>
<P><FONT COLOR="[% user.bg.3 %]"><B>Friends of Friends</B></FONT> <IMG BORDER=0 SRC="[% constants.imagedir %]/fof.gif" ALT="Friends of Friends">
<P><FONT COLOR="[% user.bg.3 %]"><B>Fans of <A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/">[% nickname %]</A></B></FONT> <IMG BORDER=0 SRC="[% constants.imagedir %]/fof.gif" ALT="Friends of Friends">
&nbsp;<A HREF="/my/comments/">[% IF user.people_bonus_fof %]([% user.people_bonus_fof %])</A> [% END %]
</TD>
<TD>
<P><FONT COLOR="[% user.bg.3 %]"><B>Foes of Friends</B></FONT> <IMG BORDER=0 SRC="[% constants.imagedir %]/eof.gif" ALT="Foes of Friends">
<P><FONT COLOR="[% user.bg.3 %]"><B>Freaks of <A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/">[% nickname %]</A></B></FONT> <IMG BORDER=0 SRC="[% constants.imagedir %]/eof.gif" ALT="Foes of Friends">
&nbsp;<A HREF="/my/comments/">[% IF user.people_bonus_eof %]([% user.people_bonus_eof %])</A> [% END %]
</TD>
</TR>
Expand Down
30 changes: 15 additions & 15 deletions plugins/Zoo/templates/data;zoo;default
Expand Up @@ -21,28 +21,28 @@ __template__
[% constants.sitename %] Friend/Foe System

[% CASE 'confirm' %]
Your Relationship with [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Your Relationship with <A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF"><A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A></FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'nofriends' %]
[% nickname %]([% uid %]) is all alone in the world.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) is all alone in the world.

[% CASE 'nofans' %]
[% nickname %]([% uid %]) is either loved by all or just invisible.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) is either loved by all or just invisible.

[% CASE 'nofreaks' %]
[% nickname %]([% uid %]) is hated by no one.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) is hated by no one.

[% CASE 'nofoes' %]
[% nickname %]([% uid %]) loves everyone or plays their cards very close to their chest.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) loves everyone or plays their cards very close to their chest.

[% CASE 'nofriendsoffriends' %]
[% nickname %]([% uid %]) friend's have no friends, they need better friends.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) friend's have no friends, they need better friends.

[% CASE 'nofriendsenemies' %]
[% nickname %]([% uid %]) friend's have no foes.
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) friend's have no foes.

[% CASE 'noall' %]
[% nickname %] is unknown to the world
<A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) is unknown to the world

[% CASE 'yournofriends' %]
You are alone in the world.
Expand All @@ -69,25 +69,25 @@ __template__
No one knows you exist.

[% CASE 'friendshead' %]
Friends of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Friends of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'foeshead' %]
Foes of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Foes of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'fanshead' %]
Fans of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Fans of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'freakshead' %]
Freaks of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Freaks of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'friendsenemieshead' %]
Foes of the Friends of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Foes of the Friends of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'friendsoffriendshead' %]
Friends of the Friends of [% nickname %]([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]
Friends of the Friends of <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>([% uid %]) [% PROCESS zoo_icons person=uid implied="" %]

[% CASE 'yourhead' %]
Everyone who thinks anything about [% nickname %]
Everyone who thinks anything about <A HREF="[% constants.rootdir %]/[% nickname | fixparam %]/"><FONT COLOR="#FFFFFF">[% nickname %]</FONT></A>

[% CASE 'yourfriendshead' %]
Your friends
Expand Down
2 changes: 1 addition & 1 deletion plugins/Zoo/templates/plainlist;zoo;default
Expand Up @@ -16,7 +16,7 @@ __template__
[% USE Slash %]
<TABLE WIDTH="90%" BORDER="0" CELLPADDING="2" CELLSPACING="0">
[% UNLESS editable %]
<A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/">[% nickname %]'s</A> <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/friends/">friends</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/fans/">fans</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/foes/">foes</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/freaks/">freaks</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/fof/">friends of friends</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/eof/">foes of friends</A>.
<A HREF="[% constants.rootdir %]/~[% nickname | fixparam %]/">[% nickname %]'s</A> <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/friends/">friends</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/fans/">fans</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/foes/">foes</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/freaks/">freaks</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/friends/friends/">friends of friends</A>, <A HREf="[% constants.rootdir %]/~[% nickname | fixparam %]/friends/foes/">foes of friends</A>.
<P>
[% END %]
[% FOREACH somebody = people %]
Expand Down
29 changes: 15 additions & 14 deletions plugins/Zoo/zoo.pl
Expand Up @@ -170,7 +170,7 @@ sub friends {
if ($editable) {
print getData('yournofriends');
} else {
print getData('nofriends', { nickname => $nick });
print getData('nofriends', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ sub fof {
_printHead("yourfriendsoffriendshead");
$implied = FOF;
} else {
_printHead("friendsoffriendshead", { nickname => $nick });
_printHead("friendsoffriendshead", { nickname => $nick, uid => $uid });
}

if (@$friends) {
Expand All @@ -209,7 +209,7 @@ sub fof {
if ($editable) {
print getData('yournofriendsoffriends');
} else {
print getData('nofriendsoffriends', { nickname => $nick });
print getData('nofriendsoffriends', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ sub enof {
if ($editable) {
print getData('yournofriendsenemies');
} else {
print getData('nofriendsenemies', { nickname => $nick });
print getData('nofriendsenemies', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -287,7 +287,7 @@ sub foes {
if ($editable) {
print getData('yournofoes');
} else {
print getData('nofoes', { nickname => $nick });
print getData('nofoes', { nickname => $nick, uid => $uid });
}
}
}
Expand All @@ -305,7 +305,6 @@ sub fans {
$nick = $user->{nick};
}
my $editable = ($uid == $user->{uid} ? 1 : 0);
#my $fans = $zoo->getFans($uid);
my $fans = $zoo->getRelationships($uid, FAN);

if ($form->{content_type} eq 'rss') {
Expand All @@ -324,7 +323,7 @@ sub fans {
if ($editable) {
print getData('yournofans');
} else {
print getData('nofans', { nickname => $nick });
print getData('nofans', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -362,7 +361,7 @@ sub freaks {
if ($editable) {
print getData('yournofreaks');
} else {
print getData('nofreaks', { nickname => $nick });
print getData('nofreaks', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -397,7 +396,7 @@ sub all {
if ($editable) {
print getData('yournoall');
} else {
print getData('noall', { nickname => $nick });
print getData('noall', { nickname => $nick, uid => $uid });
}
}
}
Expand Down Expand Up @@ -448,7 +447,7 @@ sub check {

if ($form->{uid}) {
my $nickname = $slashdb->getUser($form->{uid}, 'nickname');
my $compare = $slashdb->getUser($form->{uid}, 'people');
#my $compare = $slashdb->getUser($form->{uid}, 'people');
_printHead("confirm", { nickname => $nickname, uid => $form->{uid} });
if ($form->{uid} == $user->{uid} || $form->{uid} == $constants->{anonymous_coward_uid} ) {
print getData("no_go");
Expand All @@ -465,14 +464,14 @@ sub check {
# }
# }
my (%mutual, @mutual);
for my $person (keys %{$user->{people}{FOF()}}) {
if ($compare->{FOF()}{$person}) {
if ($user->{people}{FOF()}{$form->{uid}}) {
for my $person (keys %{$user->{people}{FOF()}{$form->{uid}}}) {
push @{$mutual{FOF()}}, $person;
push @mutual, $person;
}
}
for my $person (keys %{$user->{people}{EOF()}}) {
if ($compare->{EOF()}{$person}) {
if ($user->{people}{EOF()}{$form->{uid}}) {
for my $person (keys %{$user->{people}{EOF()}{$form->{uid}}}) {
push @{$mutual{EOF()}}, $person;
push @mutual, $person;
}
Expand All @@ -498,7 +497,9 @@ sub _printHead {
my($head, $data) = @_;
my $title = getData($head, $data);
header($title);
print STDERR "ZOO zoohead \n";
slashDisplay("zoohead", { title => $title });
print STDERR "ZOO zoohead \n";
}

sub _rss {
Expand Down
8 changes: 4 additions & 4 deletions plugins/Zoo/zoo_run_people_log.pl
Expand Up @@ -23,15 +23,15 @@
for(@$friends) {
if ($job->{type} eq 'friend') {
if ($job->{action} eq 'add') {
$zoo->addFof($_, $job->{person});
$zoo->addFof($_, $job->{person}, $job->{uid});
} else {
$zoo->deleteFof($_, $job->{person});
$zoo->deleteFof($_, $job->{person}, $job->{uid});
}
} else {
if ($job->{action} eq 'add') {
$zoo->addEof($_, $job->{person});
$zoo->addEof($_, $job->{person}, $job->{uid});
} else {
$zoo->deleteEof($_, $job->{person});
$zoo->deleteEof($_, $job->{person}, $job->{uid});
}
}
}
Expand Down

0 comments on commit f946c19

Please sign in to comment.