$usergroups = gwvp_getGroupsForUser(null, $userid);
$maxperm = 0;
- foreach($repoperms as $perm) {
+ if($repoperms != false) foreach($repoperms as $perm) {
// need to go thru each perm, then check it agains the user we're trying to figure
// the perms on
+ switch($perm["type"]) {
+ case "read":
+ $permval = 2;
+ break;
+ case "visible":
+ $permval = 1;
+ break;
+ case "write":
+ $permval = 3;
+ break;
+ default:
+ $permval = 0;
+ }
-
+ // we only var if permval is greater then current
+ if($permval > $maxperm) {
+ //error_log("going into check for $maxperm/$permval, ".$perm["ref"]);
+ if($perm["ref"] == "anon") {
+ $maxperm = $permval;
+ } else if($perm["ref"] == "authed") {
+ $maxperm = $permval;
+ } else {
+ // now we do splits
+ $spl = explode(":", $perm["ref"]);
+ $idtype = $spl[0];
+ $idval = $spl[1];
+ if($idtype == "group") {
+ // function gwvp_IsGroupMember($email, $groupname)
+ if(gwvp_IsGroupMemberById($userid, $idval)) $maxperm = $permval;
+ } else if ($idtype == "user") {
+ //error_log("checking $userid, $idval");
+ if($userid == $idval) $maxperm = $permval;
+ }
+ }
+ }
}
+
+ // thats TOTALLY going to work... -_0 we should really write a unit test for this, but thats a bit
+ // hard given the db req's so for now, we'll leave it as is
+ return $maxperm;
}
?>
\ No newline at end of file