activity logs... oh fun
[gwvp-mini.git] / gwvpmini / gwvpmini_db.php
index b94b4ca..972746e 100644 (file)
@@ -424,7 +424,24 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc)
        // this looks like null, <repoid>, <read|visible|write>, user:<uid>|group:<gid>|authed|anon\r
        // where authed = any authenticated user, anon = everyone (logged in, not logged in, etc)\r
        // read|visible|write = can clone from repo|can see repo exists and see description but not clone from it|can push to repo\r
-       // TODO: is this sufficient? i have to think about it\r
+       // TODO: is this sufficient? i have to think about it
+       
+       
+       // type for now will only be "git"
+       // date is obvious
+       // desc is a desction of the activity
+       // link is of the form "repo,reponame,repoid:user,username,useremail,userid" so it
+       // can be attached simply
+       // viewby is a simple list of uid's that should be able to see it... "r" for all registered
+       // "a" for everyone
+       $activitysql = '
+       CREATE TABLE "activity" (
+               "activity_type" TEXT,
+               "activity_date" TEXT,
+               "activity_desc" TEXT,
+               "activity_link" TEXT,
+               "activity_viewby" TEXT
+       )';\r
 \r
        $configsql = '\r
        CREATE TABLE "config" (\r
@@ -443,7 +460,8 @@ function gwvpmini_dbCreateSQLiteStructure($dbloc)
        $DB_CONNECTION->query($initialuser_admin);
        $DB_CONNECTION->query($initialuser_user);
        $DB_CONNECTION->query($reposql);\r
-       $DB_CONNECTION->query($configsql);\r
+       $DB_CONNECTION->query($configsql);
+       $DB_CONNECTION->query($activitysql);\r
 }
 
 function gwvpmini_getConfigVal($confname)\r
@@ -717,7 +735,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 +744,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
 }