From 22228c14262a4c2227f9c0ddedffee7356bf615a Mon Sep 17 00:00:00 2001 From: Paul J R Date: Wed, 19 Sep 2012 09:24:45 +1000 Subject: [PATCH] user add/remove --- gwvpmini/gwvpmini.php | 1 + gwvpmini/gwvpmini_admin.php | 60 +++++++++++++++++++++++++++++++++++++++- gwvpmini/gwvpmini_gitrepo.php | 9 +++++- gwvpmini/gwvpmini_view.php | 52 +++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 gwvpmini/gwvpmini_view.php diff --git a/gwvpmini/gwvpmini.php b/gwvpmini/gwvpmini.php index e17cd84..696ef0f 100644 --- a/gwvpmini/gwvpmini.php +++ b/gwvpmini/gwvpmini.php @@ -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"); } diff --git a/gwvpmini/gwvpmini_admin.php b/gwvpmini/gwvpmini_admin.php index f1ad347..fcd6fa2 100644 --- a/gwvpmini/gwvpmini_admin.php +++ b/gwvpmini/gwvpmini_admin.php @@ -16,8 +16,8 @@ function gwvpmini_AdminCallMe() if(isset($qspl[0])) { if($qspl[0] == "admin") { if(isset($qspl[1])) { - if($qspl[1] == "create") { - return "gwvpmini_RepoCreate"; + if($qspl[1] == "user") { + return "gwvpmini_AdminUserCreate"; } } else { error_log("i got here, where next?"); @@ -41,6 +41,7 @@ function gwvpmini_AdminMainPageBody() global $BASE_URL; $totalusers = gwvpmini_GetNUsers(); + echo "
"; echo "

Users - $totalusers

"; echo ""; echo ""; @@ -53,6 +54,22 @@ function gwvpmini_AdminMainPageBody() echo ""; } echo "
UsernameEmail AddressFull NameDescriptionControl
$un$em$fn$dsRemove Disable
"; + echo "
"; + echo "

Create User

"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
Username
Password
Confirm Password
Full Name
Description
Email
Confirm Email
Admin?
"; + echo "
"; + echo "
"; $totalrepos = gwvpmini_GetNRepos(); echo "

Repo's - $totalrepos

"; @@ -68,4 +85,43 @@ function gwvpmini_AdminMainPageBody() echo ""; } + +function gwvpmini_AdminUserCreate() +{ + global $BASE_URL; + + $name = $_REQUEST["username"]; + $pass1 = $_REQUEST["password"]; + $pass2 = $_REQUEST["confpassword"]; + $fname = $_REQUEST["fullname"]; + $desc = $_REQUEST["desc"]; + $email1 = $_REQUEST["email"]; + $email2 = $_REQUEST["confemail"]; + if(isset($_REQUEST["isadmin"])) $level = 1; + else $level = 0; + + $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 diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index 1b1466a..8ad5725 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -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 "$name$desc"; + echo "$name$desc"; echo ""; $repo_base = gwvpmini_getConfigVal("repodir"); $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2>&1"; @@ -90,6 +92,9 @@ function gwvpmini_GitLogProvider() * * Or... should we instead just list every repo? */ + + global $BASE_URL; + echo "

Repo Activity

"; if(gwvpmini_isLoggedIn()) { $repos = gwvpmini_GetOwnedRepos($_SESSION["username"]); @@ -101,7 +106,7 @@ function gwvpmini_GitLogProvider() foreach($repos as $repo) { $name = $repo["name"]; $desc = $repo["desc"]; - echo "$name$desc"; + echo "$name$desc"; echo ""; $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 index 0000000..54c5328 --- /dev/null +++ b/gwvpmini/gwvpmini_view.php @@ -0,0 +1,52 @@ + \ No newline at end of file -- 1.7.0.4