its awesome, to be awesome.
authorPaul J R <me@pjr.cc>
Mon, 24 Sep 2012 00:27:19 +0000 (10:27 +1000)
committerPaul J R <me@pjr.cc>
Mon, 24 Sep 2012 00:27:19 +0000 (10:27 +1000)
bin/gwvpminicmdtool.php
gwvpmini/gwvpmini_admin.php
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_gitbackend.php
gwvpmini/gwvpmini_gitrepo.php
gwvpmini/gwvpmini_user.php
gwvpmini/gwvpmini_web.php

index 83bfd06..1b53265 100644 (file)
@@ -6,11 +6,11 @@ $BASE_URL = "/";
 global $WEB_ROOT_FS, $BASE_URL, $IS_WEB_REQUEST, $data_directory, $db_type, $db_name, $db_username, $db_password, $IS_WEB_REQUEST, $cmd_line_tool;
 $IS_WEB_REQUEST = false;\r
 
-if(file_exists("../www/config.php")) require_once("../www/config.php");
+if(file_exists("$WEB_ROOT_FS/../www/config.php")) require_once("$WEB_ROOT_FS/../www/config.php");
 else if(file_exists("/etc/gwvpmini/config.php")) require_once("/etc/gwvpmini/config.php");
 else $noconfig = true;
 
-if(file_exists("../gwvpmini/gwvpmini.php")) require_once("../gwvpmini/gwvpmini.php");
+if(file_exists("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php")) require_once("$WEB_ROOT_FS/../gwvpmini/gwvpmini.php");
 else if(file_exists("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php")) require_once("/usr/share/gwvpmini/lib/gwvpmini/gwvpmini.php");
 
 if(isset($argv["1"])) {
@@ -37,18 +37,30 @@ function gwvpcmdtool_Usage()
        echo "\tupdatehook <user> <ref> <firstupdate> <lastupdate>\n";
 }
 
+
+// update will log things like branch and tag creations
 function gwvpcmdtool_UpdateHook()
 {
        global $argv;
-       echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
+       //echo "got ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";
+       if(preg_match("/^000000+$/", $argv[3])) {
+               // createion of tag or branch
+               $vals = explode("/", $argv[2]);
+               $type = "unknowncreate";
+               if($vals == "heads") $type = "branchcreate";
+               if($vals == "tags") $type = "tagcreate";
+               gwvpmini_AddActivityLog("$type", "1", "1", $argv[4], "somelogs");
+       }
+       //gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
 }
 
+// pre-receive logs all commit info
 function gwvpcmdtool_PreReceive()
 {
        global $argv;
 
-       echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
+       //echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n";\r
        
-       passthru("git rev-list --reverse ".$argv[3]." --not --all ");
+       //passthru("git rev-list --reverse ".$argv[3]." --not --all ");
 }
 ?>
\ No newline at end of file
index 2bdef07..af007c1 100644 (file)
@@ -9,18 +9,6 @@ if($IS_WEB_REQUEST) {
        }
        
        
-       $reg = gwvpmini_getConfigVal("gravatarenabled");
-       
-       $use_gravatar = false;\r
-       if($reg == null) {\r
-               gwvpmini_setConfigVal("gravatarenabled", "1");\r
-       } else if($reg == 1) {\r
-               $use_gravatar = true;\r
-       } else {\r
-               $use_gravatar = false;\r
-       }\r
-       \r
-       global $use_gravatar;
 }
 
 function gwvpmini_AdminCallMe()\r
index 972746e..884f496 100644 (file)
@@ -315,7 +315,8 @@ function gwvpmini_ConnectDB()
        global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION;\r
 \r
        // first check if $DB_CONNECTION IS live\r
-       //error_log("in connection $db_type, $db_name");\r
+       //error_log("in connection $db_type, $db_name");
+       $db_url = false;\r
 \r
        if($DB_CONNECTION != false) return $DB_CONNECTION;\r
 \r
@@ -330,7 +331,7 @@ function gwvpmini_ConnectDB()
        }\r
 \r
        // and here we go with pdo.\r
-       //error_log("attmpting to open db, $db_type:$db_url");\r
+       error_log("attmpting to open db, $db_type:$db_url");\r
        try {\r
                $DB_CONNECTION = new PDO("$db_type:$db_url");\r
        } catch(PDOException $exep) {\r
@@ -386,6 +387,59 @@ function gwvpmini_AddUser($username, $password, $fullname, $email, $desc, $level
        return $retval;
 }\r
 
+function gwvpmini_GetActivityLog($nentries = 100)
+{
+       $conn = gwvpmini_ConnectDB();\r
+       
+       $sql = "select * from activity order by activity_date desc limit 100";
+
+       $res = $conn->query($sql);
+       
+       $logs = null;
+       $i = 0;
+       foreach($res as $row) {
+               $logs[$i]["type"] = $row["activity_type"];
+               $logs[$i]["date"] = $row["activity_date"];
+               $logs[$i]["userid"] = $row["activity_user"];
+               $logs[$i]["repoid"] = $row["activity_repo"];
+               $logs[$i]["commitid"] = $row["activity_commitid"];
+               $logs[$i]["commitlog"] = $row["activity_commitlog"];
+               $logs[$i]["visibleto"] = $row["activity_visibleto"];
+               $i++;
+       }
+       
+       return $logs;
+}
+
+function gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog)
+{
+       /*
+        *      CREATE TABLE "activity" (
+               "activity_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+               "activity_type" TEXT,
+               "activity_date" TEXT,
+               "activity_user" TEXT,
+               "activity_repo" TEXT,
+               "activity_commitid" TEXT,
+               "activity_commitlog" TEXT,
+               "activity_visibleto" TEXT
+       )';
+
+        */
+       
+       $conn = gwvpmini_ConnectDB();
+       
+       // TODO: implement visibility
+       $visibleto = "a";\r
+       \r
+       $sql = "insert into 'activity' values ( null, '$type', '".time()."', '$userid', '$repoid', '$commitid', '$commitlog', '$visibleto')";
+       
+       error_log("SQL IS $sql");\r
+       \r
+       $res = $conn->query($sql);\r
+       if(!$res) return -1;
+       return true;
+}
 
 function gwvpmini_dbCreateSQLiteStructure($dbloc)\r
 {\r
@@ -436,11 +490,14 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc)
        // "a" for everyone
        $activitysql = '
        CREATE TABLE "activity" (
+               "activity_id" INTEGER PRIMARY KEY AUTOINCREMENT,
                "activity_type" TEXT,
                "activity_date" TEXT,
-               "activity_desc" TEXT,
-               "activity_link" TEXT,
-               "activity_viewby" TEXT
+               "activity_user" TEXT,
+               "activity_repo" TEXT,
+               "activity_commitid" TEXT,
+               "activity_commitlog" TEXT,
+               "activity_visibleto" TEXT
        )';\r
 \r
        $configsql = '\r
index 8b4c1c2..04cb5ae 100644 (file)
@@ -269,7 +269,7 @@ function gwvpmini_callGitBackend($username, $repo)
                $procenv["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"];
                $procenv["AUTH_TYPE"] = "Basic";
                
-               error_log("PROCENV: ".print_r($procenv,true));
+               //error_log("PROCENV: ".print_r($procenv,true));
                
                if(isset($_SERVER["CONTENT_TYPE"])) { 
                        $procenv["CONTENT_TYPE"] = $_SERVER["CONTENT_TYPE"];
index 1da83b9..502210e 100644 (file)
@@ -169,6 +169,15 @@ function gwvpmini_GitLogProvider()
                        echo "</table>";
                }\r
        }
+       
+       $logs = gwvpmini_GetActivityLog();
+       if($logs !== null) {
+               echo "<h2>Global Log</h2><table>";
+               foreach($logs as $ents) {
+                       echo "<tr><td>".$ents["type"]."</td><td>".$ents["commitid"]."</td></tr>";
+               }
+               echo "</table>";
+       }
 }
 
 function gwvpmini_GitCreateRepoForm()
index 4b1cd47..462d2a5 100644 (file)
@@ -1,6 +1,20 @@
 <?php
 $CALL_ME_FUNCTIONS["userview"] = "gwvpmini_UserViewCallMe";
 
+if($IS_WEB_REQUEST) {
+       $reg = gwvpmini_getConfigVal("gravatarenabled");\r
+       \r
+       $use_gravatar = false;\r
+       if($reg == null) {\r
+               gwvpmini_setConfigVal("gravatarenabled", "1");\r
+       } else if($reg == 1) {\r
+               $use_gravatar = true;\r
+       } else {\r
+               $use_gravatar = false;\r
+       }\r
+       \r
+       global $use_gravatar;
+}\r
 
 
 function gwvpmini_UserViewCallMe()
@@ -45,7 +59,12 @@ function gwvpmini_UserViewPageBody()
 {
        global $user_view_call;
        
-       echo "Want to see $user_view_call eh?";
+       
+       $dets = gwvpmini_getUser($user_view_call);
+       error_log("show view of user with $user_view_call: ". print_r($dets, true));\r
+
+       echo "<h2>".$dets["fullname"]."</h2><br>";
+       echo gwvpmini_HtmlGravatar($dets["email"],80);
 }
 
 ?>
\ No newline at end of file
index 6d45c4a..4f83206 100644 (file)
@@ -270,6 +270,11 @@ function gwvpmini_HtmlGravatar($email, $size, $htmlappend="")
        
        global $use_gravatar;
        
+       if($use_gravatar) {
+               error_log("call to gravatar with yes");
+       } else {
+               error_log("call to gravatar with no");
+       }
        
        if($use_gravatar == false) return "";
        return get_gravatar( $email, $size, 'mm', 'g', true)."$htmlappend";