removed the permissions bit on the repo creation - will happen later,
authorpaulr <me@pjr.cc>
Fri, 4 Nov 2011 07:58:02 +0000 (18:58 +1100)
committerpaulr <me@pjr.cc>
Fri, 4 Nov 2011 07:58:02 +0000 (18:58 +1100)
we'll use "sensible" defaults like read-only to everyone, write to the
creator only

gwvplib/gwvpgitcontrol.php
gwvplib/gwvprepoadmin.php

index 55f9bd5..d78fcde 100644 (file)
@@ -1,5 +1,13 @@
 <?php
 
+function gwvp_repoExists($name)
+{
+       global $repo_base;
+       
+       if(file_exists("$repo_base/$name.git")) return true;
+       else return false;
+}
+
 function gwvp_createGitRepo($name)
 {
        global $repo_base;
index df122d6..106ff4b 100644 (file)
@@ -48,8 +48,12 @@ function gwvp_DoCreateRepoPage()
        global $BASE_URL;
        
        $reponame = $_REQUEST["reponame"];
+       $repodesc = $_REQUEST["repodesc"];
        
-       if(gwvp_createGitRepo($reponame)) {
+       if(gwvp_repoExists($reponame)) {
+               gwvp_SendMessage("error", "a repository with the name <b>\"$reponame\"</b> already exists");
+               header("Location: $BASE_URL/admin/repos/create?reponameobv=$reponame&repodescobv=$repodesc");
+       } else if(gwvp_createGitRepo($reponame)) {
                gwvp_SendMessage("info", "Repo, $reponame, created");
                header("Location: $BASE_URL/admin/repos");
        }
@@ -61,34 +65,19 @@ function gwvp_CreateRepoPageBody()
 {
        global $BASE_URL, $repo_base;
        
+       $reponameobv = "";
+       $repodescobv = "";
+       
+       if(isset($_REQUEST["reponameobv"])) $reponameobv = $_REQUEST["reponameobv"];
+       if(isset($_REQUEST["repodescobv"])) $repodescobv = $_REQUEST["repodescobv"];
+       
        echo "<h2>Create a Repo</h2>";
        echo "<form method=\"post\" action=\"$BASE_URL/admin/repos/docreate\">";
        echo "<table>";
-       echo "<tr><td>Repository Name</td><td><input type=\"text\" name=\"reponame\"></td></tr>";
-       echo "<tr><td>Repository Description</td><td><input type=\"text\" name=\"repodesc\"></td></tr>";
-       echo "</table>";
-       echo "<h3>Permissions</h3>";
-       
-       // no, this bit is wrong, need to come up with something better
-       echo "<table border=\"1\">";
-       echo "<tr><td>Anonymous</td><td>Authenticated</td><td>Group</td></tr>";
-       echo "<tr><td valign=\"top\">";
-       // anon permission dialog
-       echo "<input type=\"checkbox\" name=\"anonvisible\"> Can anonymous users see the repo?<br>";
-       echo "<input type=\"checkbox\" name=\"anonclone\"> Can anonymous user clone from the repo (read-only)?<br>";
-       echo "</td><td>";
-       // authed permission dialog
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user see the repo?<br>";
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone from the repo (read-only)?<br>";
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone *TO* the repo (read/write)?<br>";
-       echo "</td><td>";
-       // group permissions dialog
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user see the repo?<br>";
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone from the repo (read-only)?<br>";
-       echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone *TO* the repo (read/write)?<br>";
-       
-       echo "</td></tr>";
+       echo "<tr><td>Repository Name</td><td><input type=\"text\" name=\"reponame\" value=\"$reponameobv\"></td></tr>";
+       echo "<tr><td>Repository Description</td><td><input type=\"text\" name=\"repodesc\" value=\"$repodescobv\"></td></tr>";
        echo "</table>";
+
        echo "<input type=\"submit\" name=\"create\" value=\"Create\"><br>";
        echo "</form>";
 }