//$MENU_ITEMS["20repos"]["text"] = "Repo Admin";
//$MENU_ITEMS["20repos"]["link"] = "$BASE_URL/admin/repos";
+$HOME_PAGE_PROVIDERS["gitlog"] = "gwvp_GitLogProvider";
function gwvp_gitControlCallMe()
{
}
+function gwvp_GitLogProvider()
+{
+ echo "<br>gitload provider loaded on homepage<br>";
+}
+
function gwvp_repoPermissionCheck($repo, $user)
{
return true;
}
}
+function gwvp_canManageRepo($userid, $repoid)
+{
+ // only the owner or an admin can do these tasks
+ error_log("Checking repoid, $repoid against userid $userid");
+
+ if(gwvp_IsUserAdmin(null, null, $userid)) return true;
+ if(gwvp_IsRepoOwner($userid, $repoid)) return true;
+ return false;
+}
function gwvp_callGitBackend($repo)
{
$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