2 global $HOME_PAGE_PROVIDERS;
\r
5 $HOME_PAGE_PROVIDERS["10activity"] = "gwvpmini_HomePageActivityLog";
\r
9 $reg = gwvpmini_getConfigVal("activityloglength");
\r
11 $activity_log_length = false;
\r
13 gwvpmini_setConfigVal("activityloglength", "100");
\r
14 } else if($reg == 1) {
\r
15 $activityloglength = true;
\r
17 $activityloglength = false;
\r
20 global $activity_log_length;
\r
24 // this will add a repo activity (a commit for eg)
25 // and auto populate the field in the activity
27 function gwvpmini_AddCommitActivityForRepo($reponame, $byusername, $commitid, $desc, $branch)
29 // gwvpmini_AddActivityLog($type, $userid, $repoid, $commitid, $commitlog, $visibleto="a")
30 $rid = gwvpmini_GetRepoId($reponame);
31 $uid = gwvpmini_GetUserId($byusername);
33 if($rid < 1 || $uid < 1) return false;
35 $vis = gwvpmini_GetVisibilityForRepo($rid);
37 gwvpmini_AddActivityLog("commit", $uid, $rid, "$branch:$commitid", $desc, $vis);
40 function gwvpmini_AddRefActivityForRepo($reponame, $byusername, $branchname, $acttype="branch")
42 $rid = gwvpmini_GetRepoId($reponame);
\r
43 $uid = gwvpmini_GetUserId($byusername);
\r
45 if($rid < 1 || $uid < 1) return false;
47 $vis = gwvpmini_GetVisibilityForRepo($rid);
49 gwvpmini_AddActivityLog("refs", $uid, $rid, "$acttype:$branchname", "", $vis);
52 function gwvpmini_GetVisibilityForRepo($repoid)
54 $perms = gwvpmini_GetRepoPerms($repoid);
55 $dets = gwvpmini_getRepo($repoid);
56 $oid = $dets["ownerid"];
58 if($perms["b"] == "a") return "a";
59 if($perms["b"] == "r") return "r";
62 foreach($perms as $key => $val) {
63 if($key!="b") $st .= "$key:";
68 // gets the activity log as it would be viewed by
69 // the user id of "$forid"
70 function gwvpmini_HomePageActivityLog()
75 if(isset($_SESSION["id"])) $id = $_SESSION["id"];
78 $ents = gwvpmini_GetActivityLog();
80 $ents = gwvpmini_GetActivityLog(20, $id);
84 echo "<table border=\"1\">";
85 if($ents != null) foreach($ents as $vals) {
87 * $ret[$nent]["type"] = $vals["activity_type"];
88 $ret[$nent]["date"] = $vals["activity_date"];
89 $ret[$nent]["userid"] = $vals["activity_user"];
90 $ret[$nent]["repoid"] = $vals["activity_repo"];
91 $ret[$nent]["commitid"] = $vals["activity_commitid"];
92 $ret[$nent]["commitlog"] = $vals["activitiy_commitlog"];
95 $type = $vals["type"];
96 //$rest = $vals["date"].", ".$vals["userid"].", ".$vals["repoid"].", ".$vals["commitid"].", ".$vals["commitlog"];
98 if($vals["type"] == "commit") {
99 $udets = gwvpmini_getUser(null, null, $vals["userid"]);
100 $rdets = gwvpmini_getRepo(null, null, $vals["repoid"]);
101 $reponame = $rdets["name"];
102 $uname = $udets["username"];
103 $fname = $udets["fullname"];
104 $br_spl = explode(":", $vals["commitid"]);
105 $branch = $br_spl[0];
107 $compressedcid = gwvpmini_CompressCommitId($cid);
108 $log = $vals["commitlog"];
109 $tdiff = gwvpmini_TimeDiffText($vals["date"]);
110 $col1 = "<font size=\"+1\"><a href=\"$BASE_URL/view/$reponame\">$reponame</a></font><br>".gwvpmini_HtmlGravatar($udets["email"], 30, "<br>")."<a href=\"$BASE_URL/user/$uname\">$uname</a>";
111 $col2 = $tdiff."<br>Commited change <b>$compressedcid</b><br><table border=\"1\"><tr><td bgcolor=\"#eeeeee\"><pre>$log</pre></td></tr></table><br>";
112 } else if($vals["type"] == "refs") {
113 $udets = gwvpmini_getUser(null, null, $vals["userid"]);
\r
114 $rdets = gwvpmini_getRepo(null, null, $vals["repoid"]);
\r
115 $reponame = $rdets["name"];
\r
116 $uname = $udets["username"];
\r
117 $fname = $udets["fullname"];
118 $tdiff = gwvpmini_TimeDiffText($vals["date"]);
119 $tp_spl = explode(":", $vals["commitid"]);
120 $col1 = "<font size=\"+1\"><a href=\"$BASE_URL/view/$reponame\">$reponame</a></font><br>".gwvpmini_HtmlGravatar($udets["email"], 30, "<br>")."<a href=\"$BASE_URL/user/$uname\">$uname</a>";
121 if($tp_spl[0] == "tagcreate") {
122 $colapp = "$tdiff<br>Created Tag <b>".$tp_spl[1]."</b>";
123 } else if($tp_spl[0] == "branchcreate") {
124 $colapp = "$tdiff<br>Created Branch <b>".$tp_spl[1]."</b>";
126 $colapp = "$tdiff<br>Performed some unknown action.";
132 echo "<tr><td>$col1</td><td>$col2</td></tr>";
137 function gwvpmini_TimeDiffText($time)
139 $tdiff = time() - $time;
141 if($tdiff < 10) return "Now";
142 if($tdiff < 60) return "$tdiff Seconds Ago";
143 if($tdiff < 3600) return "".(int)($tdiff/60)." Minutes Ago";
144 if($tdiff < 86400) return "".(int)($tdiff/3600)." Hours Ago";
145 if($tdiff < 2592000) {
146 return "".(int)($tdiff/86400)." Days Ago";
148 if($tdiff < 31536000) {
149 $months = (int)($tdiff/2592000);
150 $days = (int)(($tdiff%2592000)/86400);
152 $txt = "$months Month";
153 if($months > 1) $txt .= "s";
154 if($days > 0) $txt .= " and $days Day";
155 if($days > 1) $txt .= "s";
159 $years = (int)($tdiff/31536000);
160 $months = (int)(($tdiff%31536000)/2592000);
161 $txt = "$years Year";
162 if($years > 1) $txt .= "s";
163 if($months > 0) $txt .= " and $months Month";
164 if($months > 1) $txt .= "s";
166 return $txt." ago";
\r