permissions check/management code
authorPaul J R <me@pjr.cc>
Fri, 21 Sep 2012 00:34:13 +0000 (10:34 +1000)
committerPaul J R <me@pjr.cc>
Fri, 21 Sep 2012 00:34:13 +0000 (10:34 +1000)
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_view.php

index 4e939af..63b8f84 100644 (file)
@@ -142,6 +142,30 @@ function gwvpmini_ChangeRepoPerm($rid, $uid, $acc)
        
 }
 
+function gwvpmini_GetRepoPerms($rid)
+{
+       $conn = gwvpmini_ConnectDB();\r
+       \r
+       $sql = "select repos_perms from repos where repos_id='$rid'";\r
+       \r
+       $res = $conn->query($sql);\r
+       \r
+       $cperms_t = false;\r
+       if($res !== false) foreach($res as $row) {\r
+               $cperms_t = $row[0];\r
+       }\r
+       \r
+       if($cperms_t === false) return 0;\r
+       \r
+       error_log("PERMSCHECK $rid, $uid:".print_r($dets, true));\r
+       \r
+       if($dets === false) return 0;\r
+       \r
+       if($dets["ownerid"] == $uid) return 2;\r
+       \r
+       $permsarray = unserialize(base64_decode($cperms_t));
+}
+
 //returns 0 for none, 1 for read, 2 for writes
 function gwvpmini_GetRepoPerm($rid, $uid)
 {
@@ -153,8 +177,6 @@ function gwvpmini_GetRepoPerm($rid, $uid)
        \r
        $res = $conn->query($sql);
        
-       error_log("PERMCHECK: FUCK U! $sql");\r
-       \r
        $cperms_t = false;\r
        if($res !== false) foreach($res as $row) {\r
                $cperms_t = $row[0];\r
index 47effbe..5862068 100644 (file)
@@ -91,8 +91,11 @@ function gwvpmini_RepoViewPageBody()
                
                error_log("BPERMS: $bperms");
                
+               if($bperms == "x") $cspan = 3;
+               else $cspan = 2;
+               
+               echo "<table border=\"1\"><tr valign=\"top\"><tr><th colspan=\"$cspan\">Permissions</th></tr><td>";
                echo "<form method=\"post\" action=\"$BASE_URL/updaterepobaseperms/$repo_view_call\">";
-               echo "Base Permissions ";
                echo "<select name=\"base_perms\">";
                echo "<option value=\"a\"$anyo>Anyone can read</option>";
                echo "<option value=\"r\"$regd>Only registered users can read</option>";
@@ -100,6 +103,18 @@ function gwvpmini_RepoViewPageBody()
                echo "</select>";
                echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
                echo "</form>";
+               if($bperms == "x") {
+                       echo "</td><td>Readers<br>";
+                       echo "<form method=\"post\" action=\"$BASE_URL/repoaddreader/$repo_view_call\">";
+                       echo "<input type=\"text\" name=\"readerusername\"> <input type=\"submit\" name=\"Add\" value=\"Add\">";
+                       echo "</form><br>";
+               }
+               
+               echo "</td><td>Contributors";
+               echo "<form method=\"post\" action=\"$BASE_URL/repoaddcontrib/$repo_view_call\">";
+               echo "<input type=\"text\" name=\"contribusername\"> <input type=\"submit\" name=\"Add\" value=\"Add\">";
+               echo "</form><br>";
+               echo "</td></tr></table>";
        }
        //echo "command: git log --git-dir=$repo_base/$repo_view_call.git --pretty=format:\"%H\" -10";
        $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%H\" -10", "r");