if($qspl[0] == "updaterepobaseperms") {
return "gwvpmini_UpdateRepoBasePerms";
}
+ if($qspl[0] == "repoaddreader") {
+ return "gwvpmini_AddRepoReader";
+ }
+ if($qspl[0] == "repoaddcontrib") {
+ return "gwvpmini_AddRepoContributor";
+ }
+ if($qspl[0] == "reporemovereaders") {
+ return "gwvpmini_RemoveRepoReader";
+ }
+ if($qspl[0] == "reporemovecontribs") {
+ return "gwvpmini_RemoveRepoContributor";
+ }
return false;\r
}\r
else return false;\r
echo "<b>$desc</b><br>";
if($owner_view) {
- $bperms = gwvpmini_GetRepoPerm(gwvpmini_GetRepoId($repo_view_call), "b");
+ $bperms_f = gwvpmini_GetRepoPerms(gwvpmini_GetRepoId($repo_view_call));
+
+ $bperms = $bperms_f["b"];
$anyo = "";
$regd = "";
echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
echo "</form>";
if($bperms == "x") {
- echo "</td><td>Readers<br>";
+ echo "</td><td><b>Readers</b><br>";
+ echo "<form method=\"post\" action=\"$BASE_URL/reporemovereaders/$repo_view_call\">";
+ $nl = 0;
+ foreach($bperms_f as $key=>$val) {
+ if($val == 1) {
+ $dets = gwvpmini_getUser(null, null, $key);
+ echo get_gravatar($dets["email"], 18, 'mm', 'g', true)." <input type=\"checkbox\" name=\"$key\"> ".$dets["username"]."<br>";
+ $nl = 1;
+ }
+ }
+ if($nl==1) echo "<input type=\"submit\" name=\"remove\" value=\"Remove Selected\">";
+ echo "</form>";
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 "</td><td><b>Contributors</b><br>";
+ echo "<form method=\"post\" action=\"$BASE_URL/reporemovecontribs/$repo_view_call\">";
+ $nl = 0;
+ foreach($bperms_f as $key=>$val) {\r
+ if($val == 2) {\r
+ $dets = gwvpmini_getUser(null, null, $key);\r
+ echo get_gravatar($dets["email"], 18, 'mm', 'g', true)." <input type=\"checkbox\" name=\"$key\"> ".$dets["username"]."<br>";
+ $nl = 1;\r
+ }\r
+ }\r
+ if($nl==1) echo "<input type=\"submit\" name=\"remove\" value=\"Remove Selected\">";\r
+ echo "</form>";
+
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>";
}\r
header("Location: $BASE_URL/view/$repo_view_call");
+}
+
+function gwvpmini_AddRepoReader()
+{
+ global $BASE_URL, $repo_view_call;\r
+ \r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ error_log("PLOOP:qview".print_r($qspl, true));\r
+ }\r
+ \r
+ if(isset($qspl[1])) $repo_view_call = $qspl[1];\r
+ else {\r
+ error_log("PLOOP: no repo name");
+ // TODO: btw, this makes no sense\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ $newperms = $_REQUEST["base_perms"];\r
+ \r
+ $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);\r
+ $desc = gwvpmini_GetRepoDescFromName($repo_view_call);\r
+ \r
+ $owner_name = $owner["username"];\r
+ \r
+ $owner_view = false;\r
+ if(isset($_SESSION["id"])) {\r
+ if($owner["id"] == $_SESSION["id"]) {\r
+ $owner_view = true;\r
+ }\r
+ }
+ if(!$owner_view) {
+ gwvpmini_SendMessage("error", "failure updating permission for repo");\r
+ error_log("PLOOP: attempt to update from non-owner");
+ header("Location: $BASE_URL/view/$repo_view_call");
+ return;
+ }\r
+
+ $auid = gwvpmini_GetUserId($_REQUEST["readerusername"]);
+
+ if($auid == $_SESSION["id"]) {
+ gwvpmini_SendMessage("error", "You cannot add yourself as a reader as you already own the repo");
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;
+ }
+
+ if($auid > 0) {\r
+ $rid = gwvpmini_GetRepoId($repo_view_call);
+
+ gwvpmini_ChangeRepoPerm($rid, $auid, 1);
+ gwvpmini_SendMessage("info", "Added user ".$_REQUEST["readerusername"]." as a reader");
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;
+ } else {
+ gwvpmini_SendMessage("error", "Couldnt find user with username of ".$_REQUEST["readerusername"]);
+ header("Location: $BASE_URL/view/$repo_view_call");
+ return;
+ }
+
+
+}
+
+function gwvpmini_AddRepoContributor()
+{
+ global $BASE_URL, $repo_view_call;\r
+ \r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ error_log("PLOOP:qview".print_r($qspl, true));\r
+ }\r
+ \r
+ if(isset($qspl[1])) $repo_view_call = $qspl[1];\r
+ else {\r
+ error_log("PLOOP: no repo name");\r
+ // TODO: btw, this makes no sense\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ $newperms = $_REQUEST["base_perms"];\r
+ \r
+ $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);\r
+ $desc = gwvpmini_GetRepoDescFromName($repo_view_call);\r
+ \r
+ $owner_name = $owner["username"];\r
+ \r
+ $owner_view = false;\r
+ if(isset($_SESSION["id"])) {\r
+ if($owner["id"] == $_SESSION["id"]) {\r
+ $owner_view = true;\r
+ }\r
+ }\r
+ if(!$owner_view) {\r
+ gwvpmini_SendMessage("error", "failure updating permission for repo");\r
+ error_log("PLOOP: attempt to update from non-owner");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ $auid = gwvpmini_GetUserId($_REQUEST["contribusername"]);\r
+ \r
+ if($auid == $_SESSION["id"]) {\r
+ gwvpmini_SendMessage("error", "You cannot add yourself as a contributor as you already own the repo");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ if($auid > 0) {\r
+ $rid = gwvpmini_GetRepoId($repo_view_call);\r
+ \r
+ gwvpmini_ChangeRepoPerm($rid, $auid, 2);\r
+ gwvpmini_SendMessage("info", "Added user ".$_REQUEST["contribusername"]." as a contributor");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ } else {\r
+ gwvpmini_SendMessage("error", "Couldnt find user with username of ".$_REQUEST["contribusername"]);\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }
+}
+
+function gwvpmini_RemoveRepoContributor()
+{
+
+ global $BASE_URL, $repo_view_call;\r
+ \r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ error_log("PLOOP:qview".print_r($qspl, true));\r
+ }\r
+ \r
+ if(isset($qspl[1])) $repo_view_call = $qspl[1];\r
+ else {\r
+ error_log("PLOOP: no repo name");\r
+ // TODO: btw, this makes no sense\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ \r
+ $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);\r
+ $desc = gwvpmini_GetRepoDescFromName($repo_view_call);\r
+ \r
+ $owner_name = $owner["username"];\r
+ \r
+ $owner_view = false;\r
+ if(isset($_SESSION["id"])) {\r
+ if($owner["id"] == $_SESSION["id"]) {\r
+ $owner_view = true;\r
+ }\r
+ }\r
+ if(!$owner_view) {\r
+ gwvpmini_SendMessage("error", "failure updating permission for repo");\r
+ error_log("PLOOP: attempt to update from non-owner");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }
+
+ $rid = gwvpmini_GetRepoId($repo_view_call);
+
+ $bperms_f = gwvpmini_GetRepoPerms($rid);
+
+ foreach($bperms_f as $key=>$val) {
+ if($val == 2) {
+ if(isset($_REQUEST["$key"])) {
+ gwvpmini_ChangeRepoPerm($rid, $key, 0);
+ }
+ }
+ }
+
+ gwvpmini_SendMessage("info", "Repo permissions updated");
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+
+}\r
+
+\r
+function gwvpmini_RemoveRepoReader()\r
+{\r
+\r
+ global $BASE_URL, $repo_view_call;\r
+\r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ error_log("PLOOP:qview".print_r($qspl, true));\r
+ }\r
+\r
+ if(isset($qspl[1])) $repo_view_call = $qspl[1];\r
+ else {\r
+ error_log("PLOOP: no repo name");\r
+ // TODO: btw, this makes no sense\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+\r
+\r
+ $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);\r
+ $desc = gwvpmini_GetRepoDescFromName($repo_view_call);\r
+\r
+ $owner_name = $owner["username"];\r
+\r
+ $owner_view = false;\r
+ if(isset($_SESSION["id"])) {\r
+ if($owner["id"] == $_SESSION["id"]) {\r
+ $owner_view = true;\r
+ }\r
+ }\r
+ if(!$owner_view) {\r
+ gwvpmini_SendMessage("error", "failure updating permission for repo");\r
+ error_log("PLOOP: attempt to update from non-owner");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+\r
+ $rid = gwvpmini_GetRepoId($repo_view_call);\r
+\r
+ $bperms_f = gwvpmini_GetRepoPerms($rid);\r
+\r
+ foreach($bperms_f as $key=>$val) {\r
+ if($val == 1) {\r
+ if(isset($_REQUEST["$key"])) {\r
+ gwvpmini_ChangeRepoPerm($rid, $key, 0);\r
+ }\r
+ }\r
+ }\r
+\r
+ gwvpmini_SendMessage("info", "Repo permissions updated");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+\r
}\r
?>
\ No newline at end of file