X-Git-Url: http://git.pjr.cc/?p=gwvp.git;a=blobdiff_plain;f=gwvplib%2Fgwvpgitcontrol.php;fp=gwvplib%2Fgwvpgitcontrol.php;h=d1b0699e68ee819290025f8e7d442bf6e75c52b3;hp=6383f9e89c7f4644634374b5149f51480d568620;hb=98ea64d926a23982b9cfb5b468be87f882268566;hpb=20d1cc1a856b039329b382a8119454099896c938 diff --git a/gwvplib/gwvpgitcontrol.php b/gwvplib/gwvpgitcontrol.php index 6383f9e..d1b0699 100644 --- a/gwvplib/gwvpgitcontrol.php +++ b/gwvplib/gwvpgitcontrol.php @@ -379,12 +379,49 @@ function gwvp_resolvRepoPerms($userid, $repoid) $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