more repo admin gui, added a component for controlling cmd line git
[gwvp.git] / gwvplib / gwvprepoadmin.php
1 <?php
2 $CALL_ME_FUNCTIONS["repoadmin"] = "gwvp_RepoAdminCallMe";
3
4 $MENU_ITEMS["20repos"]["text"] = "Repo Admin";
5 $MENU_ITEMS["20repos"]["link"] = "$BASE_URL/admin/repos";
6
7 function gwvp_RepoAdminCallMe()
8 {
9         if(isset($_REQUEST["q"])) {
10                 $query = $_REQUEST["q"];
11                 $qspl = explode("/", $query);
12                 if(isset($qspl[0]) && isset($qspl[1])) {
13                         if($qspl[0] == "admin" && $qspl[1] == "repos") {
14                                 if(isset($qspl[2])) {
15                                         switch($qspl[2]) {
16                                                 case "create":
17                                                         return "gwvp_CreateRepoPage";
18                                                         break;
19                                                 case "docreate":
20                                                         return "gwvp_DoCreateRepoPage";
21                                                         break;
22                                                 default:
23                                                         return "gwvp_RepoAdminPage";
24                                         }                                       
25                                 } else {
26                                         return "gwvp_RepoAdminPage";
27                                 }
28                         }
29                 } 
30                 else return false;
31         }
32         
33         return false;
34 }
35
36 function gwvp_RepoAdminPage()
37 {
38         gwvp_goMainPage("gwvp_RepoAdminPageBody");
39 }
40
41 function gwvp_CreateRepoPage()
42 {
43         gwvp_goMainPage("gwvp_CreateRepoPageBody");
44 }
45
46 function gwvp_DoCreateRepoPage()
47 {
48         global $BASE_URL;
49         
50         $reponame = $_REQUEST["reponame"];
51         
52         if(gwvp_createGitRepo($reponame)) {
53                 gwvp_SendMessage("info", "Repo, $reponame, created");
54                 header("Location: $BASE_URL/admin/repos");
55         }
56         
57         
58 }
59
60 function gwvp_CreateRepoPageBody()
61 {
62         global $BASE_URL, $repo_base;
63         
64         echo "<h2>Create a Repo</h2>";
65         echo "<form method=\"post\" action=\"$BASE_URL/admin/repos/docreate\">";
66         echo "<table>";
67         echo "<tr><td>Repository Name</td><td><input type=\"text\" name=\"reponame\"></td></tr>";
68         echo "<tr><td>Repository Description</td><td><input type=\"text\" name=\"repodesc\"></td></tr>";
69         echo "</table>";
70         echo "<h3>Permissions</h3>";
71         
72         // no, this bit is wrong, need to come up with something better
73         echo "<table border=\"1\">";
74         echo "<tr><td>Anonymous</td><td>Authenticated</td><td>Group</td></tr>";
75         echo "<tr><td valign=\"top\">";
76         // anon permission dialog
77         echo "<input type=\"checkbox\" name=\"anonvisible\"> Can anonymous users see the repo?<br>";
78         echo "<input type=\"checkbox\" name=\"anonclone\"> Can anonymous user clone from the repo (read-only)?<br>";
79         echo "</td><td>";
80         // authed permission dialog
81         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user see the repo?<br>";
82         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone from the repo (read-only)?<br>";
83         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone *TO* the repo (read/write)?<br>";
84         echo "</td><td>";
85         // group permissions dialog
86         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user see the repo?<br>";
87         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone from the repo (read-only)?<br>";
88         echo "<input type=\"checkbox\" name=\"authdvisible\"> Can any authenticated user clone *TO* the repo (read/write)?<br>";
89         
90         echo "</td></tr>";
91         echo "</table>";
92         echo "<input type=\"submit\" name=\"create\" value=\"Create\"><br>";
93         echo "</form>";
94 }
95
96 function gwvp_RepoAdminPageBody()
97 {
98         // first we need a menu
99         global $BASE_URL;
100         
101         echo "<h2>Repo Management</h2>";
102         echo "<a href=\"$BASE_URL/admin/repos/create\">Create a Repo</a><br>";
103         
104         
105         // next we need a repo list - with perms checking - ug
106         // i must also remember that the home page will also contain a list of repos and that this page is solely for maintance
107         // and creation of repos - so i dont need to get over-worked about the info stored on this page outside of those activities
108         $rlist = gwvp_GetRepoList();
109         echo "<table border=\"1\"><tr><th>Repo Name</th><th>Repo Description</th><th>Repo Owner</th></tr>";
110         foreach($rlist as $u_res) {
111                 $rname = $u_res["name"];
112                 $rdesc = $u_res["description"];
113                 $rown = $u_res["owner"];
114                 echo "<tr><td>$rname</td><td>$rdesc</td><td>$rown</td></tr>";
115         }
116         echo "</table>";
117         
118         return;
119 }
120
121
122
123 ?>