diff options
| author | fukachan <fukachan> | 2005-12-18 12:34:25 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2005-12-18 12:34:25 +0000 |
| commit | 79ac371ce448d4a44ff1f52ed37f91399567ce92 (patch) | |
| tree | 5b6772cd62f9a9d47085435c37328734d2f2ad53 /fml | |
| parent | d6e180ee0bb54b92c24d9e9e01ee73596a69c477 (diff) | |
| download | fml8-79ac371ce448d4a44ff1f52ed37f91399567ce92.tar.gz fml8-79ac371ce448d4a44ff1f52ed37f91399567ce92.tar.bz2 fml8-79ac371ce448d4a44ff1f52ed37f91399567ce92.zip | |
implement id(), set(), get()
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Confirm.pm | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/fml/lib/FML/Confirm.pm b/fml/lib/FML/Confirm.pm index e545ef73..e157828f 100644 --- a/fml/lib/FML/Confirm.pm +++ b/fml/lib/FML/Confirm.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Confirm.pm,v 1.17 2004/07/23 04:02:46 fukachan Exp $ +# $FML: Confirm.pm,v 1.18 2005/05/27 03:03:31 fukachan Exp $ # package FML::Confirm; @@ -115,10 +115,24 @@ sub assign_id # 2. save the time map: { MD5 => ASSIGNED_UNIX_TIME } $self->store_id( $md5sum ); + # 3. internal later use. + $self->{ _cur_id } = $md5sum; + return $id; } +# Descriptions: return the current confirmation id. +# Arguments: OBJ($self) +# Side Effects: none +# Return Value: STR +sub id +{ + my ($self) = @_; + return( $self->{ _cur_id } || undef ); +} + + =head2 store_id($id, $comment) save id into databse with comment if specified. @@ -227,6 +241,48 @@ sub get_address } +=head2 set($id, $key, $value) + +=head2 get($id, $key) + +=cut + + +# Descriptions: get $key value for $id. +# Arguments: OBJ($self) STR($id) STR($key) STR($value) +# Side Effects: none +# Return Value: STR +sub set +{ + my ($self, $id, $key, $value) = @_; + + my $db = $self->_open_db(); + if (defined $db) { + $db->{ "$key-$id" } = $value; + $self->_close_db(); + } +} + + +# Descriptions: get $key value for $id. +# Arguments: OBJ($self) STR($id) STR($key) +# Side Effects: none +# Return Value: STR +sub get +{ + my ($self, $id, $key) = @_; + my $found = ''; + + my $db = $self->_open_db(); + if (defined $db) { + $found = $db->{ "$key-$id" } || ''; + $self->_close_db(); + } + + return $found; +} + + =head2 is_expired($id, $howold) check if request for $id is expired or not. |
