[siesta-commit] siesta/lib/Siesta List.pm,1.41,1.42 Plugin.pm,1.30,1.31 Preferences.pm,1.2,NONE

[prev] [thread] [next] [lurker] [Date index for 2003/03/16]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta List.pm,1.41,1.42 Plugin.pm,1.30,1.31 Preferences.pm,1.2,NONE
Date: 13:10 on 16 Mar 2003
Update of /cvsroot/siesta/siesta/lib/Siesta
In directory sc8-pr-cvs1:/tmp/cvs-serv23708/lib/Siesta

Modified Files:
	List.pm Plugin.pm 
Removed Files:
	Preferences.pm 
Log Message:
refactor the prefs system like billyo

Index: List.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/List.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- List.pm	16 Mar 2003 11:58:01 -0000	1.41
+++ List.pm	16 Mar 2003 13:10:36 -0000	1.42
@@ -242,4 +242,28 @@
     "$Siesta::Config::ROOT/queue/".$self->name."/";
 }
 
+=head2 ->pref( $plugin, $name, [$value] );
+
+=cut
+
+sub pref {
+    my $self = shift;
+    my $plugin = shift;
+    my $name  = shift;
+
+    my $config = $plugin->config->{$name}
+      or die "no such config option '$name'";
+    if (@_) {
+        my $value = shift;
+        if (defined $value) {
+            # okay, we're setting
+            Siesta->Storage->set_preference( ref $plugin, '', $self->id, $name, $value );
+        }
+        else {
+            Siesta->Storage->delete_preference( ref $plugin, '', $self->id, $name );
+        }
+    }
+    Storage->get_preference( ref $plugin, '', $self->id, $name ) || $config->{default};
+}
+
 1;

Index: Plugin.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Plugin.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- Plugin.pm	15 Mar 2003 20:15:42 -0000	1.30
+++ Plugin.pm	16 Mar 2003 13:10:36 -0000	1.31
@@ -28,46 +28,6 @@
 
 sub process { die "virtual" }
 
-=item ->preference($message, $key, [$value])
-
-gets (or sets) the value of key for this plugin based on the
-list and user.
-
-See B<Siesta::Storage> for more details.
-
-=cut
-
-sub preference {
-    my $self = shift;
-    my $mail = shift;
-
-    ( my $package = ref $self ) =~ s!^.*::!!;
-
-    my $list_id = defined $mail->list ? $mail->list->id : undef;
-    my $user_id = defined $mail->user ? $mail->user->id : undef;
-
-    return Siesta::Preferences::preference( $package, $user_id, $list_id, @_ );
-}
-
-=item ->delete_preference($message, $key)
-
-Deletes this particular config value from the database.
-
-=cut
-
-sub delete_preference {
-
-    my $self = shift;
-    my $mail = shift;
-
-    ( my $package = ref $self ) =~ s!^.*::!!;
-
-    my $list_id = defined $mail->list ? $mail->list->id : undef;
-    my $user_id = defined $mail->user ? $mail->user->id : undef;
-
-    return Siesta::Preferences::delete( $package, $user_id, $list_id, @_ );
-}
-
 =item ->options()
 
 Returns a hashref, the keys of which are the various config options a

--- Preferences.pm DELETED ---



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