user add/remove
authorPaul J R <me@pjr.cc>
Tue, 18 Sep 2012 23:24:45 +0000 (09:24 +1000)
committerPaul J R <me@pjr.cc>
Tue, 18 Sep 2012 23:24:45 +0000 (09:24 +1000)
gwvpmini/gwvpmini.php
gwvpmini/gwvpmini_admin.php
gwvpmini/gwvpmini_gitrepo.php
gwvpmini/gwvpmini_view.php [new file with mode: 0644]

index e17cd84..696ef0f 100644 (file)
@@ -7,6 +7,7 @@ require_once("gwvpmini_setup.php");
 require_once("gwvpmini_gitrepo.php");
 require_once("gwvpmini_search.php");
 require_once("gwvpmini_gitbackend.php");
+require_once("gwvpmini_view.php");
 if(gwvpmini_isLoggedIn()) if(gwvpmini_isUserAdmin()) {
        require_once("gwvpmini_admin.php");
 }
index f1ad347..fcd6fa2 100644 (file)
@@ -16,8 +16,8 @@ function gwvpmini_AdminCallMe()
                if(isset($qspl[0])) {\r
                        if($qspl[0] == "admin") {\r
                                if(isset($qspl[1])) {\r
-                                       if($qspl[1] == "create") {\r
-                                               return "gwvpmini_RepoCreate";\r
+                                       if($qspl[1] == "user") {\r
+                                               return "gwvpmini_AdminUserCreate";\r
                                        }\r
                                } else {\r
                                        error_log("i got here, where next?");\r
@@ -41,6 +41,7 @@ function gwvpmini_AdminMainPageBody()
        global $BASE_URL;
        
        $totalusers = gwvpmini_GetNUsers();
+       echo "<table><tr valign=\"top\"><td>";
        echo "<h2>Users - $totalusers</h2>";
        echo "<table border=\"1\">";
        echo "<tr><th>Username</th><th>Email Address</th><th>Full Name</th><th>Description</th><th>Control</th></tr>";
@@ -53,6 +54,22 @@ function gwvpmini_AdminMainPageBody()
                echo "<tr><td>$un</td><td>$em</td><td>$fn</td><td>$ds</td><td><a href=\"$BASE_URL/admin/removeuser&id=$id\">Remove</a> <a href=\"$BASE_URL/admin/disableuser&id=$id\">Disable</a></td></tr>";
        }
        echo "</table>";
+       echo "</td><td>";
+       echo "<h3>Create User</h3>";
+       echo "<form method=\"post\" action=\"$BASE_URL/admin/user/create\">";
+       echo "<table border=\"1\">";\r
+       echo "<tr><th>Username</th><td><input type=\"text\" name=\"username\"></td></tr>";
+       echo "<tr><th>Password</th><td><input type=\"text\" name=\"password\"></td></tr>";
+       echo "<tr><th>Confirm Password</th><td><input type=\"text\" name=\"confpassword\"></td></tr>";
+       echo "<tr><th>Full Name</th><td><input type=\"text\" name=\"fullname\"></td></tr>";
+       echo "<tr><th>Description</th><td><input type=\"text\" name=\"desc\"></td></tr>";
+       echo "<tr><th>Email</th><td><input type=\"text\" name=\"email\"></td></tr>";
+       echo "<tr><th>Confirm Email</th><td><input type=\"text\" name=\"confemail\"></td></tr>";
+       echo "<tr><th>Admin?</th><td><input type=\"checkbox\" name=\"isadmin\"></td></tr>";
+       echo "<tr><td colspan=\"2\"><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
+       echo "</table>";
+       echo "</form>";
+       echo "</td></tr></table>";
        
        $totalrepos = gwvpmini_GetNRepos();
        echo "<h2>Repo's - $totalrepos</h2>";
@@ -68,4 +85,43 @@ function gwvpmini_AdminMainPageBody()
        echo "</table>";
 }\r
 
+
+function gwvpmini_AdminUserCreate()
+{
+       global $BASE_URL;
+       
+       $name = $_REQUEST["username"];
+       $pass1 = $_REQUEST["password"];
+       $pass2 = $_REQUEST["confpassword"];\r
+       $fname = $_REQUEST["fullname"];
+       $desc = $_REQUEST["desc"];
+       $email1 = $_REQUEST["email"];\r
+       $email2 = $_REQUEST["confemail"];
+       if(isset($_REQUEST["isadmin"])) $level = 1;
+       else $level = 0;\r
+       
+       $id = gwvpmini_GetUserId($name);
+       
+       if(!$id) {
+               if($pass1 != $pass2) {
+                       gwvpmini_SendMessage("error", "Passwords dont match");
+                       header("Location: $BASE_URL/admin");
+                       return;
+               }
+               if($email1 != $email2) {
+                       gwvpmini_SendMessage("error", "Email Addresses dont match");
+                       header("Location: $BASE_URL/admin");
+                       return;
+               }
+               
+               gwvpmini_AddUser($name, $pass1, $fname, $email1, $desc, $level, 0);
+               gwvpmini_SendMessage("info", "User $fname created");
+       } else {
+               gwvpmini_SendMessage("error", "User $name already exists, cant create");
+       }
+       
+       header("Location: $BASE_URL/admin");
+       return;
+       
+}
 ?>
\ No newline at end of file
index 1b1466a..8ad5725 100644 (file)
@@ -51,6 +51,8 @@ function gwvpmini_RepoMainPage()
 
 function gwvpmini_RepoMainPageBody()
 {
+       global $BASE_URL;
+       
        gwvpmini_GitCreateRepoForm();
        if(gwvpmini_isLoggedIn()) {
                $repos = gwvpmini_GetOwnedRepos($_SESSION["username"]);
@@ -62,7 +64,7 @@ function gwvpmini_RepoMainPageBody()
                        foreach($repos as $repo) {
                                $name = $repo["name"];
                                $desc = $repo["desc"];
-                               echo "<tr><td>$name</td><td>$desc</td>";
+                               echo "<tr><td><a href=\"$BASE_URL/view/$name\">$name</a></td><td>$desc</td>";
                                echo "<td>";\r
                                $repo_base = gwvpmini_getConfigVal("repodir");\r
                                $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2>&1";\r
@@ -90,6 +92,9 @@ function gwvpmini_GitLogProvider()
        *\r
        * Or... should we instead just list every repo?\r
        */
+       
+       global $BASE_URL;
+       
        echo "<h2>Repo Activity</h2>";
        if(gwvpmini_isLoggedIn()) {\r
                $repos = gwvpmini_GetOwnedRepos($_SESSION["username"]);
@@ -101,7 +106,7 @@ function gwvpmini_GitLogProvider()
                        foreach($repos as $repo) {
                                $name = $repo["name"];
                                $desc = $repo["desc"];
-                               echo "<tr><td>$name</td><td>$desc</td>";
+                               echo "<tr><td><a href=\"$BASE_URL/view/$name\">$name</a></td><td>$desc</td>";
                                echo "<td>";
                                $repo_base = gwvpmini_getConfigVal("repodir");
                                $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2>&1";
diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php
new file mode 100644 (file)
index 0000000..54c5328
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+global $HOME_PAGE_PROVIDERS;
+
+
+$CALL_ME_FUNCTIONS["repoview"] = "gwvpmini_RepoViewCallMe";
+
+
+
+function gwvpmini_RepoViewCallMe()
+{
+       global $repo_view_call;
+       
+       error_log("in admin callme");\r
+       if(isset($_REQUEST["q"])) {\r
+               $query = $_REQUEST["q"];\r
+               $qspl = explode("/", $query);\r
+               if(isset($qspl[0])) {\r
+                       if($qspl[0] == "view") {\r
+                               if(isset($qspl[1])) {
+                                       $repo_view_call = $qspl[1];
+                                       return "gwvpmini_RepoViewPage";\r
+                               } else return false;\r
+                       } else return false;\r
+               }\r
+               else return false;\r
+       }\r
+\r
+       return false;\r
+       
+       
+}
+
+function gwvpmini_RepoViewPage()\r
+{
+       global $repo_view_call, $MENU_ITEMS, $BASE_URL;\r
+       \r
+       $MENU_ITEMS["40thisrepo"]["text"] = "$repo_view_call";\r
+       $MENU_ITEMS["40thisrepo"]["link"] = "$BASE_URL/view/$repo_view_call";\r
+       \r
+       gwvpmini_goMainPage("gwvpmini_RepoViewPageBody");\r
+}
+
+function gwvpmini_RepoViewPageBody()
+{
+       global $repo_view_call, $MENU_ITEMS;\r
+
+       
+       echo "In repoview call for $repo_view_call";
+}
+\r
+
+?>
\ No newline at end of file