X-Git-Url: http://git.pjr.cc/?p=gwvp-mini.git;a=blobdiff_plain;f=gwvpmini%2Fgwvpmini_db.php;fp=gwvpmini%2Fgwvpmini_db.php;h=fc6babc401a213e4427a59df645012bf274b8b07;hp=88c7ee206bf87a723b88d3f44cd3cf2926ea3dfa;hb=3849628899cd35b87f8908f240e09e1075176db4;hpb=7c855df8f42cc8508f556068a707c9258cd40e43 diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index 88c7ee2..fc6babc 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -546,7 +546,16 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc) "repos_status" TEXT, "repos_origin" TEXT, UNIQUE(repos_name) - )'; + )'; + + $msgsql = ' + CREATE TABLE "messages" ( + "msgs_id" INTEGER PRIMARY KEY AUTOINCREMENT, + "msgs_type" TEXT, + "msgs_data" TEXT, + "msgs_to_id" TEXT + )'; + // this looks like null, , , user:|group:|authed|anon // where authed = any authenticated user, anon = everyone (logged in, not logged in, etc) @@ -591,7 +600,8 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc) $DB_CONNECTION->query($initialuser_user); $DB_CONNECTION->query($reposql); $DB_CONNECTION->query($configsql); - $DB_CONNECTION->query($activitysql); + $DB_CONNECTION->query($activitysql); + $DB_CONNECTION->query($msgsql); } function gwvpmini_getConfigVal($confname) @@ -695,6 +705,59 @@ function gwvpmini_GetRepoDescFromName($reponame) return $retval; } + +function gwvpmini_SendMessageByDb($type, $data, $forid) +{ + $conn = gwvpmini_ConnectDB(); + + $sql = "insert into messages values (null, '$type', '$data', '$forid')"; + + return $conn->query($sql); +} + +function gwvpmini_GetMessagesForId($uid) +{ + /* + * $msgsql = ' + CREATE TABLE "messages" ( + "msgs_id" INTEGER PRIMARY KEY AUTOINCREMENT, + "msgs_type" TEXT, + "msgs_data" TEXT, + "msgs_to_id" TEXT, + )'; + + */ + $conn = gwvpmini_ConnectDB(); + + $sql = "select * from messages where msgs_to_id='$uid'"; + // error_log("desc for name sql: $sql"); + + $res = $conn->query($sql); + + error_log("request message for uid, $uid with sql $sql"); + + $i = 0; + if(!$res) return 0; + foreach($res as $row) { + $retval[$i]["id"] = $row["msgs_id"]; + $retval[$i]["type"] = $row["msgs_type"]; + $retval[$i]["data"] = $row["msgs_data"]; + $i++; + } + + + return $retval; + +} + +function gwvpmini_DeleteMessagesById($mid) +{ + $conn = gwvpmini_ConnectDB(); + + $sql = "delete from messages where msgs_id='$mid'"; + + return $conn->query($sql); +} function gwvpmini_GetRepoOwnerDetailsFromName($reponame) { @@ -848,7 +911,7 @@ function gwvpmini_GetOwnedRepos($username) // error_log(print_r($row, true)); } - // error_log(print_r($retval, true)); + error_log(print_r($retval, true)); return $retval; }