add list of repos a user can commit to
authorPaul J R <me@pjr.cc>
Sat, 22 Sep 2012 21:12:19 +0000 (07:12 +1000)
committerPaul J R <me@pjr.cc>
Sat, 22 Sep 2012 21:12:19 +0000 (07:12 +1000)
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_gitbackend.php
gwvpmini/gwvpmini_gitrepo.php
gwvpmini/gwvpmini_view.php

index b94b4ca..97437b5 100644 (file)
@@ -717,7 +717,7 @@ function gwvpmini_GetContributedRepos($username)
 \r
 \r
        $uid = gwvpmini_GetUserId($username);\r
-       $sql = "select repos_id,repos_description,repos_perms,repos_owernid,repos_status from repos";\r
+       $sql = "select repos_id,repos_description,repos_perms,repos_owner,repos_status,repos_name from repos";\r
        $res = $conn->query($sql);\r
        if($username == "") return false;\r
 \r
@@ -726,16 +726,24 @@ function gwvpmini_GetContributedRepos($username)
        $i = 0;\r
        foreach($res as $row) {
                $perms = unserialize(base64_decode($row["repos_perms"]));
+               error_log("CONTRIB: $uid for ".$row["repos_id"]." - ".print_r($perms,true));
                if(isset($perms["$uid"])) if($perms["$uid"] > 1) {
                        $rids[$i]["id"] = $row["repos_id"];
                        $rids[$i]["desc"] = $row["repos_description"];
-                       $rids[$i]["ownerid"] = $row["repos_ownerid"];
+                       $rids[$i]["owner"] = $row["repos_owner"];
                        $rids[$i]["status"] = $row["repos_status"];
+                       $rids[$i]["name"] = $row["repos_name"];
                        $i++;
                }
+       }
+       $retval = $rids;
+       
+       if($i == 0) {
+               error_log("CONTRIBREPOS: no repos found?");
+               return false;
        }\r
 \r
-       error_log(print_r($retval, true));\r
+       error_log("CONTRIBREPOS: ".print_r($retval, true));\r
        return $retval;\r
 }
 
index bea736d..c3975e6 100644 (file)
@@ -138,8 +138,11 @@ function gwvpmini_gitBackendInterface()
        // if its a write, we push for authentication
        
        //if($write) {
-               gwvpmini_callGitBackend($person, $repo);
-               return;
+       if(!$person) {
+               $person = "anonymous";
+       }
+       gwvpmini_callGitBackend($person, $repo);
+       return;
        //}
 
        // if we made it this far, we a read and we have permissions to do so, just search the file from the repo
index 3ea498c..d8e0d32 100644 (file)
@@ -54,7 +54,6 @@ function gwvpmini_RepoMainPageBody()
        global $BASE_URL;
        
        if(gwvpmini_isLoggedIn()) {
-               gwvpmini_GitCreateRepoForm();
                $repos = gwvpmini_GetOwnedRepos($_SESSION["username"]);
                if(!$repos) {
                        echo "You currently own no repos<br>";  
@@ -64,6 +63,8 @@ function gwvpmini_RepoMainPageBody()
                        foreach($repos as $repo) {
                                $name = $repo["name"];
                                $desc = $repo["desc"];
+                               $repo_base = gwvpmini_getConfigVal("repodir");
+                               $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2> /dev/null";
                                echo "<tr><td><a href=\"$BASE_URL/view/$name\">$name</a></td><td>$desc</td>";
                                echo "<td>";\r
                                error_log("CMD: $cmd");
@@ -82,6 +83,40 @@ function gwvpmini_RepoMainPageBody()
                        }
                        echo "</table>";
                }
+               gwvpmini_GitCreateRepoForm();\r
+               
+               
+               $contreps = gwvpmini_GetContributedRepos($_SESSION["username"]);
+               
+               if($contreps !== false) {
+                       echo "<h2>Repos you contribute to</h2>";
+                       echo "<table border=\"1\"><tr><th>Repo Name</th><th>Owner</th><th>Repo Description</th><th>Last Log</th></tr>";
+                       foreach($contreps as $repo) {
+                               $name = $repo["name"];\r
+                               $desc = $repo["desc"];
+                               $repo_base = gwvpmini_getConfigVal("repodir");\r
+                               $cmd = "git --git-dir=\"$repo_base/$name.git\" log -1 2> /dev/null";
+                               error_log("CMD: $cmd");
+                               //system("$cmd");
+                               $fls = popen($cmd, "r");
+                               $tks = "";
+                               if($fls !== false) while(!feof($fls)) {
+                                       $tks .= fread($fls,1024);
+                               }
+                               
+                               if($tks == "") {
+                                       $lastlog = "No Log Info Yet";
+                               } else $lastlog = $tks;
+                               
+                               $owner = gwvpmini_getUser(null, null, $repo["owner"]);
+                               $repname = "<a href=\"$BASE_URL/view/$name\">$name</a>";
+                               $repown = get_gravatar($owner["email"], 30, 'mm', 'g', true)."<br><a href=\"$BASE_URL/user/".$owner["username"]."\">".$owner["username"]."</a>";
+                               
+                               
+                               echo "<tr><td>$repname</td><td>$repown</td><td>$desc</td><td>$lastlog</td></tr>";
+                       }
+                       echo "</table>";
+               }
        }
        return true;
 }
index 942ce73..126f5e4 100644 (file)
@@ -78,6 +78,7 @@ function gwvpmini_RepoViewPageBody()
        $desc = gwvpmini_GetRepoDescFromName($repo_view_call);
        $editdesc = preg_replace("/\<br\>/", "\n", $desc);
        
+       $rid = gwvpmini_GetRepoId($repo_view_call);
        
        $owner_name = $owner["username"];