Added user view page, updated repo view page, added ocmmit logs
authorPaul J R <me@pjr.cc>
Wed, 19 Sep 2012 01:04:07 +0000 (11:04 +1000)
committerPaul J R <me@pjr.cc>
Wed, 19 Sep 2012 01:04:07 +0000 (11:04 +1000)
gwvpmini/gwvpmini.php
gwvpmini/gwvpmini_admin.php
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_view.php
gwvpmini/gwvpmini_web.php
www/index.php

index 696ef0f..8c510b6 100644 (file)
@@ -8,6 +8,7 @@ require_once("gwvpmini_gitrepo.php");
 require_once("gwvpmini_search.php");
 require_once("gwvpmini_gitbackend.php");
 require_once("gwvpmini_view.php");
+require_once("gwvpmini_user.php");
 if(gwvpmini_isLoggedIn()) if(gwvpmini_isUserAdmin()) {
        require_once("gwvpmini_admin.php");
 }
index fcd6fa2..55eae57 100644 (file)
@@ -80,7 +80,7 @@ function gwvpmini_AdminMainPageBody()
                $rn = $val["name"];
                $ds = $val["desc"];
                $ow = $val["owner"];
-               echo "<tr><td>$rn</td><td>$ds</td><td>$ow</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 "<tr><td><a href=\"$BASE_URL/view/$rn\">$rn</a></td><td>$ds</td><td>$ow</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>";
 }\r
index 4408014..3f63804 100644 (file)
@@ -290,6 +290,23 @@ function gwvpmini_GetUserId($username)
        return $retval;
 }
 
+function gwvpmini_GetUserNameFromEmail($email)\r
+{\r
+       $conn = gwvpmini_ConnectDB();\r
+\r
+       $sql = "select user_username from users where user_email='$email'";\r
+\r
+       error_log("username sql $sql");\r
+\r
+       $res = $conn->query($sql);\r
+\r
+       $retval = false;\r
+       foreach($res as $row) {\r
+               $retval = $row[0];\r
+       }\r
+\r
+       return $retval;\r
+}
 function gwvpmini_GetOwnedRepos($username)\r
 {
        /*
index 54c5328..96ee359 100644 (file)
@@ -42,10 +42,53 @@ function gwvpmini_RepoViewPage()
 
 function gwvpmini_RepoViewPageBody()
 {
-       global $repo_view_call, $MENU_ITEMS;\r
+       global $repo_view_call, $MENU_ITEMS, $BASE_URL;
+       
+       $repo_base = gwvpmini_getConfigVal("repodir");\r
 
+       if($_SERVER["SERVER_PORT"] == 443) $proto="https://";
+       else $proto = "http://";
+       $sname = $_SERVER["SERVER_NAME"];
+       
+       echo "<br><h2>$repo_view_call by owner</h2>";
+       echo "<b>Desc</b><br>";
+       echo "<textarea rows=1 cols=100>git clone $proto$sname$BASE_URL/git/$repo_view_call.git</textarea><br>";
+       //echo "command: git log --git-dir=$repo_base/$repo_view_call.git --pretty=format:\"%H\" -10";
+       $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%H\" -10", "r");
+       $commitids = array();
+       $i = 0;
+       if($rs) {
+               while(!feof($rs)) {
+                       $flin = fgets($rs);
+                       if($flin !== false) {
+                               $commitids[$i] = trim($flin);
+                               $i++;
+                       }
+               }
+               fclose($rs);
+       } else {
+               echo "No commit logs yet<br>";
+               $commitids = false;
+       }
+       
+       if($commitids != false) {
+               echo "<hr>Commits<br>";
+               echo "<table border=\"1\">";
+               echo "<tr><th>Committed By</th><th>Date</th><th>Commit Log Entry</th></tr>";
+               foreach($commitids as $ids) {
+                       $rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%at%n%ce%n%s\" $ids -1", "r");
+                       if($rs) {
+                               $flin1 = trim(fgets($rs));
+                               $flin2 = gwvpmini_emailToUserLink(trim(fgets($rs)));
+                               while(!feof($rs)) {
+                                       $flin3 = fread($rs, 8192);
+                               }
+                       }
+                       echo "<tr><td>$flin2</td><td>$flin1</td><td>$flin3</td></tr>";
+               }
+               echo "</table>";
+       }
        
-       echo "In repoview call for $repo_view_call";
 }
 \r
 
index b158226..f6b6665 100644 (file)
@@ -110,7 +110,7 @@ function gwvpmini_goMainPage($bodyFunction = null)
        
        echo "</tr>";
        
-       echo "<tr><td>";
+       echo "<tr><td colspan=\"2\">";
        if($bodyFunction == null) {
                gwvpmini_BodyBuilder();
        } else {
@@ -227,6 +227,19 @@ function gwvpmini_TailBuilder()
        echo "<font size=\"-1\"><i>Copyright 2011, PJR - licensed under GPL</i></font>";
 }
 
+function gwvpmini_emailToUserLink($email)
+{
+       global $BASE_URL;
+       
+       $username = gwvpmini_GetUserNameFromEmail($username);
+       
+       if($username !== false) {
+               return "<a href=\"$BASE_URL/user/$username\">$username</a>";
+       } else {
+               return "Uknown";
+       }
+}
+
 function gwvpmini_fourZeroThree()
 {
        error_log("403 called");
index 412c49e..61e77b2 100644 (file)
@@ -29,11 +29,11 @@ if(!gwvpmini_DBExists($db_name)) {
 
 gwvpmini_goWeb();
 
-/*
+
 echo "<pre>";
 print_r($_SERVER);
 print_r($_REQUEST);
 print_r($_SESSION);
 echo "</pre>";
-*/
+
 ?>
\ No newline at end of file