[siesta-commit] siesta/lib/Siesta/Plugin Subscribe.pm,1.10,1.11

[prev] [thread] [next] [lurker] [Date index for 2002/09/20]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta/Plugin Subscribe.pm,1.10,1.11
Date: 21:32 on 20 Sep 2002
Update of /cvsroot/siesta/siesta/lib/Siesta/Plugin
In directory usw-pr-cvs1:/tmp/cvs-serv24478/lib/Siesta/Plugin

Modified Files:
	Subscribe.pm 
Log Message:
perltidy

Index: Subscribe.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Plugin/Subscribe.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Subscribe.pm	20 Sep 2002 13:29:39 -0000	1.10
+++ Subscribe.pm	20 Sep 2002 20:32:05 -0000	1.11
@@ -21,10 +21,9 @@
     # check to see if they're already subbed
     my %members = map { $_->id() => 1 } $list->members();
 
-
-    if ($members{$user_id}) {
-    	$self->already_subbed($mail);
-	return 1;
+    if ( $members{$user_id} ) {
+        $self->already_subbed($mail);
+        return 1;
     }
 
     # XXX should this be done implicitly by $list->add_member?
@@ -35,72 +34,74 @@
 
     # now check to see if there's a key for them
     $mail->user($user);
-    my $value = $self->config($mail,'request');
+    my $value = $self->config( $mail, 'request' );
 
     # and get the value from subject
     my ($sub) = $mail->subject() =~ /SUBSCRIBE\s+(.+)/;
 
+    # if there is 
+    if ( defined $sub ) {
 
+        # are they the same
+        if ( defined $value && ( $value eq $sub ) ) {
 
-    # if there is 
-    if (defined $sub)
-    {
-	# are they the same
-	if (defined $value && ($value eq $sub)) {
-		# tell them they've been subscribed
-		$self->successfully_subbed($mail);
-	} elsif (!(defined $value) || !($value eq $sub)) {
-		# tell them that their key is invalid
-		$self->invalid_key($mail);
-	}
- 
-    # otherwise
-    } else {
-	# send a key
-	$self->send_key($mail);
+            # tell them they've been subscribed
+            $self->successfully_subbed($mail);
+        }
+        elsif ( !( defined $value ) || !( $value eq $sub ) ) {
+
+            # tell them that their key is invalid
+            $self->invalid_key($mail);
+        }
+
+        # otherwise
     }
+    else {
 
+        # send a key
+        $self->send_key($mail);
+    }
 
     # now go through the database and remove any old keys
     my $clone = $mail->clone();
+
     # remove the user and the list so that
     # we can clean as much up as possible
     $clone->user(undef);
     $clone->list(undef);
+
     # get the time a month ago
-    my $date = time() - (60 * 60 * 24 * 31);
+    my $date = time() - ( 60 * 60 * 24 * 31 );
+
     # $self->delete_config($clone, 'request', $date);
     # TODO     
 
 }
 
-
-
 # mail the person and the list owner and 
 # tell them they've been subbed
-sub successfully_subbed
-{
-       my $self = shift;
-       my $mail = shift;
-       my $list = $mail->list();
-       my $user = $mail->user(); 
+sub successfully_subbed {
+    my $self = shift;
+    my $mail = shift;
+    my $list = $mail->list();
+    my $user = $mail->user();
 
-       # delete the key already in the db
-       $self->delete_config($mail,'request');
+    # delete the key already in the db
+    $self->delete_config( $mail, 'request' );
 
+    # add the user to the list and if that fails, send an error
+    # TODO should this be a seperate send method?
+    unless ( $list->add_member( $user->id ) ) {
+        $self->already_subbed($mail);
+        return;
+    }
 
-       # add the user to the list and if that fails, send an error
-       # TODO should this be a seperate send method?
-       unless($list->add_member($user->id)) {
-		$self->already_subbed($mail);
-		return;
-       }
-       # mail the listowner and tell them that someone subbed 
-       $mail->reply( to   => $list->owner,
-                     body => $user->id."  JOIN " . $list->id );
+    # mail the listowner and tell them that someone subbed 
+    $mail->reply( to   => $list->owner,
+                  body => $user->id . "  JOIN " . $list->id );
 
-       # mail the person and tell them that they've been subbed
-       $mail->reply( body => <<END);
+    # mail the person and tell them that they've been subbed
+    $mail->reply( body => <<END);
 Hi,
  You have been successfully subscribed to ${ \( $list->id ) }
 
@@ -110,17 +111,15 @@
 
 }
 
-
 # Tell them they've already been subbed
-sub already_subbed
-{
+sub already_subbed {
 
-       my $self = shift;
-       my $mail = shift;
-       my $list = $mail->list();
+    my $self = shift;
+    my $mail = shift;
+    my $list = $mail->list();
 
-       # mail them and reject them
-       $mail->reply( body => <<END);
+    # mail them and reject them
+    $mail->reply( body => <<END);
 Hi,
  You could not be subscribed to ${ \( $list->id ) }.
 
@@ -132,17 +131,15 @@
 END
 }
 
-
 # Tell them that the key they passed was invalid
-sub invalid_key
-{
+sub invalid_key {
 
-       my $self = shift;
-       my $mail = shift;
-       my $list = $mail->list();
-   
-       # mail them and reject them
-       $mail->reply( body => <<END);
+    my $self = shift;
+    my $mail = shift;
+    my $list = $mail->list();
+
+    # mail them and reject them
+    $mail->reply( body => <<END);
 Hi,
  You could not be subscribed to ${ \( $list->id ) }.
 
@@ -153,22 +150,19 @@
 END
 }
 
-
 # send them a unique key
-sub send_key
-{
-	my $self = shift;
-	my $mail = shift;
-	my $list = $mail->list();
+sub send_key {
+    my $self = shift;
+    my $mail = shift;
+    my $list = $mail->list();
 
-	# generate a unique value 
-	my $value = md5_hex($$.time().{}.rand());
-        $self->config($mail,'request', $value);
+    # generate a unique value 
+    my $value = md5_hex( $$ . time() . {} . rand() );
+    $self->config( $mail, 'request', $value );
 
-	
-        # mail them with a a request	
-	$mail->subject("SUBSCRIBE $value");
-        $mail->reply( body => <<END);
+    # mail them with a a request	
+    $mail->subject("SUBSCRIBE $value");
+    $mail->reply( body => <<END);
 Hi,
  You have requested to be subscribed to  ${ \( $list->id ) }.
 
@@ -183,8 +177,7 @@
 
 }
 
-
-
 =cut
+
 
 1;



Generated at 13:57 on 01 Jul 2004 by mariachi 0.52