|
From: Chris W. <la...@us...> - 2001-11-20 03:30:58
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_user/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv17800/OpenInteract
Modified Files:
User.pm
Log Message:
added 'is_in_group()' method to user object (thanks Jochen)
Index: User.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_user/OpenInteract/User.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** User.pm 2001/09/14 20:50:25 1.5
--- User.pm 2001/11/20 03:30:54 1.6
***************
*** 87,90 ****
--- 87,101 ----
}
+
+ sub is_in_group {
+ my ( $self, $group_spec ) = @_;
+ my $check_group_id = ( ref $group_spec )
+ ? $group_spec->id : $group_spec;
+ foreach my $group ( @{ $R->{auth}{group} } ) {
+ return 1 if ( $group->id == $check_group_id );
+ }
+ return undef;
+ }
+
1;
***************
*** 105,111 ****
$user->increment_login();
print "Username: $user->{username}\n";
!
=head1 DESCRIPTION
=head1 METHODS
--- 116,130 ----
$user->increment_login();
print "Username: $user->{username}\n";
!
! # See if the user is in a particular group
! if ( $user->is_in_group( $group ) ) {
! print "Enter!";
! }
!
!
=head1 DESCRIPTION
+ Basic methods for user objects
+
=head1 METHODS
***************
*** 124,127 ****
--- 143,153 ----
Return a 1 if the password matches what is in the database, a 0 if
not.
+
+ B<is_in_group( $group | $group_id )>
+
+ Ask a user object if it belongs to a particular group. You can pass
+ either a group object or its ID.
+
+ Returns true if the user is in the group, false, if not.
=head1 TO DO
|