make isUserAdmin do what the POD says (returns 0, 1), and clarify it

(deliberately passed null string or undef causes query instead of set).
Add tests to Group.t to check that behavior.
This commit is contained in:
Colin Kuskie 2006-03-19 06:10:44 +00:00
parent 0eb6ec7b01
commit abfa6ed1ac
3 changed files with 39 additions and 18 deletions

View file

@ -133,7 +133,8 @@ sub addGroups {
=head2 addUsers ( users [, expireOffset ] )
Adds users to this group.
Adds users to this group. If a user is already a member of a group, their expiration date
is updated.
=head3 users
@ -155,6 +156,7 @@ sub addUsers {
my ($isIn) = $self->session->db->quickArray("select count(*) from groupings where groupId=? and userId=?", [$self->getId, $uid]);
unless ($isIn) {
$self->session->db->write("insert into groupings (groupId,userId,expireDate) values (?,?,?)", [$self->getId, $uid, ($self->session->datetime->time()+$expireOffset)]);
$self->session->stow->delete("gotGroupsForUser");
} else {
$self->userGroupExpireDate($uid,($self->session->datetime->time()+$expireOffset));
}
@ -281,6 +283,7 @@ sub deleteUsers {
foreach my $uid (@{$users}) {
$self->session->db->write("delete from groupings where groupId=? and userId=?",[$self->getId, $uid]);
}
$self->session->stow->delete("gotGroupsForUser");
}
#-------------------------------------------------------------------
@ -937,7 +940,7 @@ sub set {
=head2 userIsAdmin ( [ userId, value ] )
Returns a 1 or 0 depending upon whether the user is a sub-admin for this group.
Sets or returns $userid's status as a group admin in this group.
=head3 userId
@ -945,7 +948,8 @@ A guid that is the unique identifier for a user. Defaults to the currently logge
=head3 value
If specified the admin flag will be set to this value.
If defined and not the empty string, the admin flag will be set to this value. Otherwise,
returns 1 if the user has been set as a group admin and 0 if the user hasn't.
=cut
@ -958,7 +962,7 @@ sub userIsAdmin {
return $value;
} else {
my ($admin) = $self->session->db->quickArray("select groupAdmin from groupings where groupId=? and userId=?", [$self->getId, $userId]);
return $admin;
return ($admin ? 1 : 0);
}
}

View file

@ -647,7 +647,7 @@ Be aware that any database links you create here will be available to all conten
},
'977 description' => {
message => q|Set this to yes to make this user a secondary admin. Secondary admins have the ability
message => q|Set this to yes to make this user a group admin. Group admins have the ability
to add or remove users from their groups.
|,
lastUpdated => 1132359856,
@ -1036,7 +1036,7 @@ removed from the system after a set period of time. That period of time is set
},
'977' => {
message => q|Is secondary admin?|,
message => q|Is group admin?|,
lastUpdated => 1053803387
},
@ -1280,9 +1280,7 @@ When users are added to the system they are put into the registered users group.
<p>
<b>Secondary Admins</b><br> Users in the Secondary Admins group may
add new users, but cannot edit users. Also, if you are a Secondary
Admin and are a member of a different group, you can be set as an admin for that group. This
will allow you to add or remove members from that group.
add new users, but cannot edit users.
<p>
<b>Style Managers</b><br>