diff options
author | Russ Allbery <rra@stanford.edu> | 2007-09-18 18:35:50 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-09-18 18:35:50 +0000 |
commit | 3c2cff4bfc0f7560d5264fbe9b0af402646ed373 (patch) | |
tree | 1fce219d5fded5ebac02b1bde866528a8271e4ff /perl/Wallet | |
parent | 488ad0911d63d46d9adad156edafc7d5d4d84df5 (diff) |
Add flag_set and flag_clear to Wallet::Server.
Diffstat (limited to 'perl/Wallet')
-rw-r--r-- | perl/Wallet/Server.pm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/perl/Wallet/Server.pm b/perl/Wallet/Server.pm index c417451..71294c8 100644 --- a/perl/Wallet/Server.pm +++ b/perl/Wallet/Server.pm @@ -352,6 +352,34 @@ sub destroy { } ############################################################################## +# Object flag methods +############################################################################## + +# Clear a flag on an object. Takes the object and the flag. Returns true on +# success or undef and sets the internal error on failure. +sub flag_clear { + my ($self, $type, $name, $flag) = @_; + my $object = $self->retrieve ($type, $name); + return undef unless defined $object; + return undef unless $self->acl_check ($object, 'flags'); + my $result = $object->flag_clear ($flag, $self->{user}, $self->{host}); + $self->error ($object->error) unless defined $result; + return $result; +} + +# Set a flag on an object. Takes the object and the flag. Returns true on +# success or undef and sets the internal error on failure. +sub flag_set { + my ($self, $type, $name, $flag) = @_; + my $object = $self->retrieve ($type, $name); + return undef unless defined $object; + return undef unless $self->acl_check ($object, 'flags'); + my $result = $object->flag_set ($flag, $self->{user}, $self->{host}); + $self->error ($object->error) unless defined $result; + return $result; +} + +############################################################################## # ACL methods ############################################################################## @@ -692,6 +720,18 @@ seconds since epoch. To set an expiration, the current user must be authorized by the ADMIN ACL. Returns true for success and false for failure. +=item flag_clear(TYPE, NAME, FLAG) + +Clears the flag FLAG on the object identified by TYPE and NAME. To clear a +flag, the current user must be authorized by the ADMIN ACL or the flags ACL +on the object. + +=item flag_set(TYPE, NAME, FLAG) + +Sets the flag FLAG on the object identified by TYPE and NAME. To set a +flag, the current user must be authorized by the ADMIN ACL or the flags ACL +on the object. + =item get(TYPE, NAME) Returns the data associated with the object identified by TYPE and NAME. |