Adding karma.

This commit is contained in:
JT Smith 2002-06-19 02:44:54 +00:00
parent c2f4800620
commit e3847cb9b1

View file

@ -108,19 +108,34 @@ sub insufficient {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub isInGroup { sub isInGroup {
my ($gid, $uid, $result); my ($gid, $uid, @data, %group, %user);
($gid, $uid) = @_; ($gid, $uid) = @_;
if ($uid eq "") { if ($uid eq "") {
$uid = $session{user}{userId}; $uid = $session{user}{userId};
} }
### The "Everyone" group automatically returns true.
if ($gid == 7) { if ($gid == 7) {
return 1; # If the "Everyone" group is specified then return true regardless of the user. return 1;
} }
($result) = WebGUI::SQL->quickArray("select count(*) from groupings where groupId='$gid' and userId='$uid' and expireDate>".time()); ### Lookup the actual grouping.
if ($result < 1 && $gid != 3) { # admins can @data = WebGUI::SQL->quickArray("select count(*) from groupings where groupId='$gid' and userId='$uid' and expireDate>".time());
$result = isInGroup(3, $uid); # do anything any if ($data[0] > 0) {
} # user can do return 1;
return $result; }
### Get data for auxillary checks.
tie %group, 'Tie::CPHash';
%group = WebGUI::SQL->quickHash("select karmaThreshold from groups where groupId='$gid'");
tie %user, 'Tie::CPHash';
%user = WebGUI::SQL->quickHash("select karma from users where userId='$uid'");
### Check karma levels.
if ($user{karma} >= $group{karmaThreshold}) {
return 1;
}
### Admins can do anything!
if ($gid != 3) {
return isInGroup(3, $uid);
}
return 0;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------