fixing up the "is setup" check in the installer
[gwvp.git] / gwvplib / gwvprepoadmin.php
index 6552727..cb533bf 100644 (file)
@@ -28,6 +28,9 @@ function gwvp_RepoAdminCallMe()
                                                case "updateperms":
                                                        return "gwvp_UpdateRepoPerms";
                                                        break;
+                                               case "details":
+                                                       return "gwvp_RepoDetailsPage";
+                                                       break;
                                                default:
                                                        return "gwvp_RepoAdminPage";
                                        }                                       
@@ -57,6 +60,16 @@ function gwvp_CreateRepoPage()
        gwvp_goMainPage("gwvp_CreateRepoPageBody");
 }
 
+function gwvp_RepoDetailsPage()
+{
+       gwvp_goMainPage("gwvp_RepoDetailsPageBody");
+}
+
+function gwvp_RepoDetailsPageBody()
+{
+       echo "I am a repo details page";
+}
+
 function gwvp_UpdateRepoPerms()
 {
        global $LOGIN_TYPE, $BASE_URL;
@@ -241,6 +254,7 @@ function gwvp_RepoAdminPageBody()
        // next we need a repo list - with perms checking - ug
        // i must also remember that the home page will also contain a list of repos and that this page is solely for maintance
        // and creation of repos - so i dont need to get over-worked about the info stored on this page outside of those activities
+       echo "<h3>All Repositories</h3>";
        $rlist = gwvp_GetRepoList();
        echo "<table border=\"1\"><tr><th>Repo Name</th><th>Repo Description</th><th>Repo Owner</th></tr>";
        foreach($rlist as $u_res) {
@@ -248,7 +262,15 @@ function gwvp_RepoAdminPageBody()
                $rname = $u_res["name"];
                $rdesc = $u_res["description"];
                $rown = gwvp_getUserName($u_res["owner"]);
-               echo "<tr><td>$rname</td><td>$rdesc</td><td>$rown</td><td><a href=\"$BASE_URL/admin/repos/manage/$rid\">Details</a></td></tr>";
+               $manordetslink = "details";
+               $manordets = "Details";
+               if(isset($_SESSION["id"])) {
+                       if(gwvp_resolvRepoPerms($_SESSION["id"], $rid)>3) {
+                               $manordetslink = "manage";
+                               $manordets = "Manage";
+                       }
+               }
+               echo "<tr><td>$rname</td><td>$rdesc</td><td>$rown</td><td><a href=\"$BASE_URL/admin/repos/$manordetslink/$rid\">$manordets</a></td></tr>";
        }
        echo "</table>";
        
@@ -304,6 +326,8 @@ function gwvp_ManageRepoPageBody()
        echo "<input type=\"submit\" name=\"update\" value=\"Update\"><br>";
        echo "</form>";
        
+       
+       echo "<h3>Repository Permissions</h3>";
        echo "<form method=\"post\" action=\"$BASE_URL/admin/repos/updateperms/$rid\">";
        echo "<table>";
        echo "<tr bgcolor=\"#eeeee0\"><th>Visibility</th><th>Read/Clone</th><th>Write/Push</th></tr>";
@@ -315,10 +339,11 @@ function gwvp_ManageRepoPageBody()
        // visibility section
        $visin[0] = 0;
        echo "<table>";
-       echo "<tr><td>Allowed</td><td></td><td>All</td></tr>";
+       echo "<tr><th>Allowed</th><td></td><th>All</th></tr>";
        echo "<tr><td>";
        // list allowed users
        echo "<select name=\"vismembersin[]\" size=\"20\" multiple=\"true\">";
+       $ninvis = 0;
        foreach($repoperms as $v_perms) {
                if($v_perms["type"] == "visible") {
                        $who = $v_perms["ref"]; // now we need to disemble ref
@@ -328,8 +353,10 @@ function gwvp_ManageRepoPageBody()
                        $visin[$who] = true;
                        
                        echo "<option value=\"$pid\">$refid</option>";
+                       $ninvis++;
                }
        }
+       if($ninvis == 0) echo "<option>--------------</option>";
 
        echo "</select>";
        
@@ -340,21 +367,29 @@ function gwvp_ManageRepoPageBody()
        
        echo "</td><td>";
        // list all users/groups/specials
+       $noutvis = 0;
        echo "<select name=\"vismembersout[]\" size=\"20\" multiple=\"true\">";
        if(!isset($visin["anon"])) echo "<option value=\"anon\">Everyone</option>";
        if(!isset($visin["authed"])) echo "<option value=\"authed\">All Authenticated User</option>";
        foreach($groups as $u_groups) {
                $gname = $u_groups["name"];
                $gid = $u_groups["id"];
-               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($visin["group:$gid"])) echo "<option value=\"group:$gid\">Group: $gname</option>";
+               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($visin["group:$gid"])) {
+                       echo "<option value=\"group:$gid\">Group: $gname</option>";
+                       $noutvis++;
+               }
        }
        foreach($users as $u_users) {
                $uid = $u_users["id"];
                $email = $u_users["email"];
                $username = $u_users["username"];
                $fullname = $u_users["fullname"];
-               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($visin["user:$uid"])) echo "<option value=\"user:$uid\">User: $username</option>";
+               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($visin["user:$uid"])) {
+                       echo "<option value=\"user:$uid\">User: $username</option>";
+                       $noutvis++;
+               }
        }
+       if($noutvis == 0) echo "<option>-------------------</option>";
        echo "</select>";
        
        echo "</td></tr>";
@@ -366,10 +401,11 @@ function gwvp_ManageRepoPageBody()
        // Read/clone/pull section
        $readin[0] = 0;
        echo "<table>";
-       echo "<tr><td>Allowed</td><td></td><td>All</td></tr>";
+       echo "<tr><th>Allowed</th><td></td><th>All</th></tr>";
        echo "<tr><td>";
        // list allowed users
        echo "<select name=\"readmembersin[]\" size=\"20\" multiple=\"true\">";
+       $ninread = 0;
        foreach($repoperms as $v_perms) {
                if($v_perms["type"] == "read") {
                        $who = $v_perms["ref"]; // now we need to disemble ref
@@ -379,8 +415,10 @@ function gwvp_ManageRepoPageBody()
                        $readin[$who] = true;
                        
                        echo "<option value=\"$pid\">$refid</option>";
+                       $ninread++;
                }
        }
+       if($ninread == 0) echo "<option>-------------------</option>";
 
        echo "</select>";
        
@@ -392,20 +430,28 @@ function gwvp_ManageRepoPageBody()
        echo "</td><td>";
        // list all users/groups/specials
        echo "<select name=\"readmembersout[]\" size=\"20\" multiple=\"true\">";
+       $noutread = 0;
        if(!isset($readin["anon"])) echo "<option value=\"anon\">Everyone</option>";
        if(!isset($readin["authed"])) echo "<option value=\"authed\">All Authenticated User</option>";
        foreach($groups as $u_groups) {
                $gname = $u_groups["name"];
                $gid = $u_groups["id"];
-               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($readin["group:$gid"])) echo "<option value=\"group:$gid\">Group: $gname</option>";
+               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($readin["group:$gid"])) {
+                       echo "<option value=\"group:$gid\">Group: $gname</option>";
+                       $noutread++;
+               }
        }
        foreach($users as $u_users) {
                $uid = $u_users["id"];
                $email = $u_users["email"];
                $username = $u_users["username"];
                $fullname = $u_users["fullname"];
-               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($readin["user:$uid"])) echo "<option value=\"user:$uid\">User: $username</option>";
+               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($readin["user:$uid"])) {
+                       echo "<option value=\"user:$uid\">User: $username</option>";
+                       $noutread++;
+               }
        }
+       if($noutread == 0) echo "<option>-------------------</option>";
        echo "</select>";
        
        echo "</td></tr>";
@@ -417,10 +463,11 @@ function gwvp_ManageRepoPageBody()
        // write/push section
        $writein[0] = 0;
        echo "<table>";
-       echo "<tr><td>Allowed</td><td></td><td>All</td></tr>";
+       echo "<tr><th>Allowed</th><td></td><th>All</th></tr>";
        echo "<tr><td>";
        // list allowed users
        echo "<select name=\"writemembersin[]\" size=\"20\" multiple=\"true\">";
+       $ninwrite = 0;
        foreach($repoperms as $v_perms) {
                if($v_perms["type"] == "write") {
                        $who = $v_perms["ref"]; // now we need to disemble ref
@@ -430,9 +477,10 @@ function gwvp_ManageRepoPageBody()
                        $writein[$who] = true;
                        
                        echo "<option value=\"$pid\">$refid</option>";
+                       $ninwrite++;
                }
        }
-
+       if($ninwrite == 0) echo "<option>-------------------</option>";
        echo "</select>";
        
        echo "</td><td>";
@@ -443,20 +491,28 @@ function gwvp_ManageRepoPageBody()
        echo "</td><td>";
        // list all users/groups/specials
        echo "<select name=\"writemembersout[]\" size=\"20\" multiple=\"true\">";
-       if(!isset($writein["anon"])) echo "<option value=\"anon\">Everyone</option>";
+       $noutwrite = 0;
+       // cant have anon for writes if(!isset($writein["anon"])) echo "<option value=\"anon\">Everyone</option>";
        if(!isset($writein["authed"])) echo "<option value=\"authed\">All Authenticated User</option>";
        foreach($groups as $u_groups) {
                $gname = $u_groups["name"];
                $gid = $u_groups["id"];
-               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($writein["group:$gid"])) echo "<option value=\"group:$gid\">Group: $gname</option>";
+               if(!gwvp_IsGroupAdmin(null, $gid)) if(!isset($writein["group:$gid"])) {
+                       $noutwrite++;
+                       echo "<option value=\"group:$gid\">Group: $gname</option>";
+               }
        }
        foreach($users as $u_users) {
                $uid = $u_users["id"];
                $email = $u_users["email"];
                $username = $u_users["username"];
                $fullname = $u_users["fullname"];
-               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($writein["user:$uid"])) echo "<option value=\"user:$uid\">User: $username</option>";
+               if(!gwvp_IsUserAdmin(null, null, $uid)) if(!isset($writein["user:$uid"])) {
+                       $noutwrite++;
+                       echo "<option value=\"user:$uid\">User: $username</option>";
+               }
        }
+       if($noutwrite == 0) echo "<option>-------------------</option>";
        echo "</select>";
        
        echo "</td></tr>";