From: Paul J R Date: Mon, 24 Sep 2012 00:27:19 +0000 (+1000) Subject: its awesome, to be awesome. X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=a0e234c191ea3c1427355eaa596d1e71b730e34a;p=gwvp-mini.git its awesome, to be awesome. --- diff --git a/bin/gwvpminicmdtool.php b/bin/gwvpminicmdtool.php index 83bfd06..1b53265 100644 --- a/bin/gwvpminicmdtool.php +++ b/bin/gwvpminicmdtool.php @@ -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; -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 \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"; + //echo "got from prereceive ".$argv[2].", ".$argv[3].", ".$argv[4]."\n"; - passthru("git rev-list --reverse ".$argv[3]." --not --all "); + //passthru("git rev-list --reverse ".$argv[3]." --not --all "); } ?> \ No newline at end of file diff --git a/gwvpmini/gwvpmini_admin.php b/gwvpmini/gwvpmini_admin.php index 2bdef07..af007c1 100644 --- a/gwvpmini/gwvpmini_admin.php +++ b/gwvpmini/gwvpmini_admin.php @@ -9,18 +9,6 @@ if($IS_WEB_REQUEST) { } - $reg = gwvpmini_getConfigVal("gravatarenabled"); - - $use_gravatar = false; - if($reg == null) { - gwvpmini_setConfigVal("gravatarenabled", "1"); - } else if($reg == 1) { - $use_gravatar = true; - } else { - $use_gravatar = false; - } - - global $use_gravatar; } function gwvpmini_AdminCallMe() diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index 972746e..884f496 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -315,7 +315,8 @@ function gwvpmini_ConnectDB() global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION; // first check if $DB_CONNECTION IS live - //error_log("in connection $db_type, $db_name"); + //error_log("in connection $db_type, $db_name"); + $db_url = false; if($DB_CONNECTION != false) return $DB_CONNECTION; @@ -330,7 +331,7 @@ function gwvpmini_ConnectDB() } // and here we go with pdo. - //error_log("attmpting to open db, $db_type:$db_url"); + error_log("attmpting to open db, $db_type:$db_url"); try { $DB_CONNECTION = new PDO("$db_type:$db_url"); } catch(PDOException $exep) { @@ -386,6 +387,59 @@ function gwvpmini_AddUser($username, $password, $fullname, $email, $desc, $level return $retval; } +function gwvpmini_GetActivityLog($nentries = 100) +{ + $conn = gwvpmini_ConnectDB(); + + $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"; + + $sql = "insert into 'activity' values ( null, '$type', '".time()."', '$userid', '$repoid', '$commitid', '$commitlog', '$visibleto')"; + + error_log("SQL IS $sql"); + + $res = $conn->query($sql); + if(!$res) return -1; + return true; +} function gwvpmini_dbCreateSQLiteStructure($dbloc) { @@ -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 )'; $configsql = ' diff --git a/gwvpmini/gwvpmini_gitbackend.php b/gwvpmini/gwvpmini_gitbackend.php index 8b4c1c2..04cb5ae 100644 --- a/gwvpmini/gwvpmini_gitbackend.php +++ b/gwvpmini/gwvpmini_gitbackend.php @@ -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"]; diff --git a/gwvpmini/gwvpmini_gitrepo.php b/gwvpmini/gwvpmini_gitrepo.php index 1da83b9..502210e 100644 --- a/gwvpmini/gwvpmini_gitrepo.php +++ b/gwvpmini/gwvpmini_gitrepo.php @@ -169,6 +169,15 @@ function gwvpmini_GitLogProvider() echo ""; } } + + $logs = gwvpmini_GetActivityLog(); + if($logs !== null) { + echo "

Global Log

"; + foreach($logs as $ents) { + echo ""; + } + echo "
".$ents["type"]."".$ents["commitid"]."
"; + } } function gwvpmini_GitCreateRepoForm() diff --git a/gwvpmini/gwvpmini_user.php b/gwvpmini/gwvpmini_user.php index 4b1cd47..462d2a5 100644 --- a/gwvpmini/gwvpmini_user.php +++ b/gwvpmini/gwvpmini_user.php @@ -1,6 +1,20 @@ ".$dets["fullname"]."
"; + echo gwvpmini_HtmlGravatar($dets["email"],80); } ?> \ No newline at end of file diff --git a/gwvpmini/gwvpmini_web.php b/gwvpmini/gwvpmini_web.php index 6d45c4a..4f83206 100644 --- a/gwvpmini/gwvpmini_web.php +++ b/gwvpmini/gwvpmini_web.php @@ -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";