From 1a1ed3388655bbc4001022fd91f3f5ea3ad4d03a Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 7 Nov 2011 16:09:35 +1100 Subject: [PATCH] various repo admin bits starting to implement the repo permissions bit changed the way index.php finds its library --- TODO | 3 +++ gwvplib/gwvpauth.php | 2 ++ gwvplib/gwvpdatabase.php | 38 ++++++++++++++++++++++++++++++++++++++ gwvplib/gwvpgitcontrol.php | 21 +++++++++++++++++++++ gwvplib/gwvplib.php | 2 +- gwvplib/gwvprepoadmin.php | 25 +++++++++++++++++++++++++ www/index.php | 31 +++++++++++++++++++++++++++---- 7 files changed, 117 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 02f1b7a..59d6a0c 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,9 @@ TODO ==== +Im thinking about changing the name of my project to something like AGOW (all git over web) +TGOW (total) or something + My basic roadmap of the things I want to do with this project in the order I want to do them: Alpha Release diff --git a/gwvplib/gwvpauth.php b/gwvplib/gwvpauth.php index ad42b2b..5056c06 100644 --- a/gwvplib/gwvpauth.php +++ b/gwvplib/gwvpauth.php @@ -122,9 +122,11 @@ function gwvp_AuthHandleLogin() gwvp_SendMessage("error", "Login Failed"); header("Location: $BASE_URL"); } else { + $details = gwvp_getUser($user); $_SESSION["isloggedin"] = true; $_SESSION["username"] = "$user"; $_SESSION["fullname"] = $details["fullname"]; + $_SESSION["id"] = $details["id"]; if(gwvp_IsUserAdmin($details["email"])) { $_SESSION["usertype"] = "admin"; } else { diff --git a/gwvplib/gwvpdatabase.php b/gwvplib/gwvpdatabase.php index 172ffbb..8746f0f 100644 --- a/gwvplib/gwvpdatabase.php +++ b/gwvplib/gwvpdatabase.php @@ -285,6 +285,44 @@ function gwvp_getUser($username=null, $email=null, $id=null) } +function gwvp_getOwnedRepos($userid = null, $username = null) +{ + $conn = gwvp_ConnectDB(); + + if($username != null) { + $details = gwvp_getUser($username); + $uid = $details["id"]; + $sql = "select * from repos where repos_owner='$uid'"; + $res = $conn->query($sql); + error_log("sql: $sql"); + } else if($userid != null) { + $sql = "select * from repos where repos_owner='$userid'"; + $res = $conn->query($sql); + error_log("sql: $sql"); + } else return false; + + /* + * CREATE TABLE "repos" ( + "repos_id" INTEGER PRIMARY KEY AUTOINCREMENT, + "repos_name" TEXT, + "repos_description" TEXT, + "repos_owner" INTEGER + )'; + + */ + + $returns = false; + $rn = 0; + foreach($res as $u_res) { + $returns[$rn]["id"] = $u_res["repos_id"]; + $returns[$rn]["name"] = $u_res["repos_name"]; + $returns[$rn]["description"] = $u_res["repos_description"]; + $rn++; + } + + return $returns; +} + function gwvp_getUsers() { $conn = gwvp_ConnectDB(); diff --git a/gwvplib/gwvpgitcontrol.php b/gwvplib/gwvpgitcontrol.php index dddf0b2..18ddde5 100644 --- a/gwvplib/gwvpgitcontrol.php +++ b/gwvplib/gwvpgitcontrol.php @@ -27,6 +27,27 @@ function gwvp_repoPermissionCheck($repo, $user) return true; } +function gwvp_gitBackendInterface_new() +{ + // and this is where i re-code the git backend interface from scratch + global $repo_base, $BASE_URL; + + + $repo = ""; + $newloc = "/"; + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + $repo = $qspl[1]; + for($i=2; $i < count($qspl); $i++) { + $newloc .= "/".$qspl[$i]; + } + } + + +} + + function gwvp_gitBackendInterface() { global $repo_base, $BASE_URL; diff --git a/gwvplib/gwvplib.php b/gwvplib/gwvplib.php index 824e4c4..d70dc3f 100644 --- a/gwvplib/gwvplib.php +++ b/gwvplib/gwvplib.php @@ -17,7 +17,7 @@ require_once("gwvpemail.php"); require_once("gwvppluginloader.php"); // only enable this if you need it: -// require_once("gwvpdebug.php"); +require_once("gwvpdebug.php"); ?> \ No newline at end of file diff --git a/gwvplib/gwvprepoadmin.php b/gwvplib/gwvprepoadmin.php index 9ead6d3..665aeff 100644 --- a/gwvplib/gwvprepoadmin.php +++ b/gwvplib/gwvprepoadmin.php @@ -115,6 +115,25 @@ function gwvp_RepoAdminPageBody() echo "

Repo Management

"; echo "Create a Repo
"; + if(isset($_SESSION["isloggedin"])) { + echo "

Your Repo's

"; + $ownreps = gwvp_getOwnedRepos($_SESSION["id"]); + if($ownreps != false) { + echo ""; + echo ""; + foreach($ownreps as $repos) { + $mjay = print_r($repos, true); + error_log("snafu: $mjay"); + $reponame = $repos["name"]; + echo ""; + } + echo "
Repo Name
$reponame
"; + } else { + echo "You own no repositories"; + } + echo "
"; + } + // next we need a repo list - with perms checking - ug // i must also remember that the home page will also contain a list of repos and that this page is solely for maintance @@ -133,6 +152,12 @@ function gwvp_RepoAdminPageBody() return; } +// this funciton returns one of three things +function gwvp_resolvRepoPerms($userid, $repoid) +{ + +} + ?> \ No newline at end of file diff --git a/www/index.php b/www/index.php index 792b52a..7ec0950 100644 --- a/www/index.php +++ b/www/index.php @@ -9,10 +9,33 @@ $BASE_URL = dirname($_SERVER["PHP_SELF"]); global $WEB_ROOT_FS, $BASE_URL, $repo_base, $data_directory, $db_type, $db_name, $db_username, $db_password; -// add gwvplib as if it were a path in ../gwvplib -if(file_exists($lib_base)) { - $path = realpath($lib_base); - set_include_path(get_include_path().PATH_SEPARATOR.$path); +// the index will search for the base library depending on: +// if lib_base is set in config.php, it'll go there and nowhere else +// if lib_base is not set, it'll look for ../gwvplib, /usr/share/php/gwbplib and /usr/share/gwvp/gwvplib +if(isset($lib_base)) { + if(file_exists($lib_base."/gwvplib.php")) { + $path = realpath($lib_base); + set_include_path(get_include_path().PATH_SEPARATOR.$path); + } else { + echo "Problem: lib_base is set in the config.php file, but I cant find the actual library
"; + echo "I have to bail"; + return; + } +} else { + if(file_exists("../gwvplib/gwvplib.php")) { + $path = realpath("../gwvplib/"); + set_include_path(get_include_path().PATH_SEPARATOR.$path); + } else if(file_exists("/usr/share/php/gwvplib/gwvplib.php")) { + $path = realpath("/usr/share/php/gwvplib/"); + set_include_path(get_include_path().PATH_SEPARATOR.$path); + } else if(file_exists("/usr/share/gwvp/gwvplib/gwvplib.php")) { + $path = realpath("/usr/share/gwvp/gwvplib/"); + set_include_path(get_include_path().PATH_SEPARATOR.$path); + } else { + echo "Problem: lib_base is set in the config.php file, but I cant find the actual library
"; + echo "I have to bail"; + return; + } } require_once("gwvplib.php"); -- 1.7.0.4