various repo admin bits
authorpaulr <me@pjr.cc>
Mon, 7 Nov 2011 05:09:35 +0000 (16:09 +1100)
committerpaulr <me@pjr.cc>
Mon, 7 Nov 2011 05:09:35 +0000 (16:09 +1100)
starting to implement the repo permissions bit
changed the way index.php finds its library

TODO
gwvplib/gwvpauth.php
gwvplib/gwvpdatabase.php
gwvplib/gwvpgitcontrol.php
gwvplib/gwvplib.php
gwvplib/gwvprepoadmin.php
www/index.php

diff --git a/TODO b/TODO
index 02f1b7a..59d6a0c 100644 (file)
--- 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
index ad42b2b..5056c06 100644 (file)
@@ -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 {
index 172ffbb..8746f0f 100644 (file)
@@ -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();
index dddf0b2..18ddde5 100644 (file)
@@ -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;
index 824e4c4..d70dc3f 100644 (file)
@@ -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
index 9ead6d3..665aeff 100644 (file)
@@ -115,6 +115,25 @@ function gwvp_RepoAdminPageBody()
        echo "<h2>Repo Management</h2>";
        echo "<a href=\"$BASE_URL/admin/repos/create\">Create a Repo</a><br>";
        
+       if(isset($_SESSION["isloggedin"])) {
+               echo "<h3>Your Repo's</h3>";
+               $ownreps = gwvp_getOwnedRepos($_SESSION["id"]);
+               if($ownreps != false) {
+                       echo "<table>";
+                       echo "<tr><th>Repo Name</th></tr>";
+                       foreach($ownreps as $repos) {
+                               $mjay = print_r($repos, true);
+                               error_log("snafu: $mjay");
+                               $reponame = $repos["name"];
+                               echo "<tr><td>$reponame</td></tr>";
+                       }
+                       echo "</table>";
+               } else {
+                       echo "You own no repositories";
+               }
+               echo "<hr>";
+       }
+       
        
        // 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
index 792b52a..7ec0950 100644 (file)
@@ -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<br>";
+               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<br>";
+               echo "I have to bail";
+               return;
+       }
 }
 
 require_once("gwvplib.php");