$sql = "update users set user_status=1 where user_id='$uid'";\r
\r
return $conn->query($sql);\r
+}
+
+function gwvpmini_UpdateRepoDescription($rid, $desc)
+{
+ $conn = gwvpmini_ConnectDB();\r
+
+ // remove any tag elements
+ $newdesc_r = preg_replace("/[\<\>\;]+/", "", $desc);
+ $newdesc = preg_replace("/\n/", "<br>", $newdesc_r);
+
+ $sql = "update repos set repos_description='$newdesc' where repos_id='$rid'";
+
+ return $conn->query($sql);
}\r
\r
function gwvpmini_EnableUser($uid)\r
if($qspl[0] == "reporemovecontribs") {
return "gwvpmini_RemoveRepoContributor";
}
+ if($qspl[0] == "repoupdatedesc") {
+ return "gwvpmini_RepoUpdateDescription";
+ }
return false;\r
}\r
else return false;\r
$owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);
$desc = gwvpmini_GetRepoDescFromName($repo_view_call);
+ $editdesc = preg_replace("/\<br\>/", "\n", $desc);
+
$owner_name = $owner["username"];
error_log("STUFF:".print_r($owner,true));
- if($bperms != "a") $login = $_SESSION["username"]."@password:";
+ if($bperms != "a") $login = $_SESSION["username"].":password@";
else $login = "";
$cloneurl = "git clone $proto$login$sname$BASE_URL/git/$repo_view_call.git";
echo "<textarea rows=1 cols=".strlen($cloneurl).">$cloneurl</textarea><br>";
else $owner_extra = "";\r
echo "<h2>".get_gravatar($owner["email"], 30, 'mm', 'g', true)."$repo_view_call - $owner_name$owner_extra</h2>";
- echo "<b>$desc</b><br>";
+ if(!$owner_view) echo "<b>$desc</b><br>";
if($owner_view) {
+ echo "<form method=\"post\" action=\"$BASE_URL/repoupdatedesc/$repo_view_call\">";\r
+ echo "<h3>Description<h3><textarea name=\"desc\" cols=\"120\" rows=\"5\">$editdesc</textarea><br><input type=\"submit\" name=\"Update\" value=\"Update\">";\r
+ echo "</form><br>";\r
echo "<input type=\"text\" name=\"contribusername\"> <input type=\"submit\" name=\"Add\" value=\"Add\">";
echo "</form><br>";
echo "</td></tr></table>";
+
}
//echo "command: git log --git-dir=$repo_base/$repo_view_call.git --pretty=format:\"%H\" -10";
$rs = popen("git --git-dir=$repo_base/$repo_view_call.git log --pretty=format:\"%H\" -10", "r");
header("Location: $BASE_URL/view/$repo_view_call");\r
return;\r
\r
+}
+
+function gwvpmini_RepoUpdateDescription()
+{
+ global $BASE_URL, $repo_view_call;\r
+ \r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ error_log("PLOOP:qview".print_r($qspl, true));\r
+ }\r
+ \r
+ if(isset($qspl[1])) $repo_view_call = $qspl[1];\r
+ else {\r
+ error_log("PLOOP: no repo name");\r
+ // TODO: btw, this makes no sense\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ \r
+ $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);\r
+ $desc = gwvpmini_GetRepoDescFromName($repo_view_call);\r
+ \r
+ $owner_name = $owner["username"];\r
+ \r
+ $owner_view = false;\r
+ if(isset($_SESSION["id"])) {\r
+ if($owner["id"] == $_SESSION["id"]) {\r
+ $owner_view = true;\r
+ }\r
+ }\r
+ if(!$owner_view) {\r
+ gwvpmini_SendMessage("error", "failure updating description for repo");\r
+ error_log("PLOOP: attempt to update from non-owner");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;\r
+ }\r
+ \r
+ $rid = gwvpmini_GetRepoId($repo_view_call);\r
+ \r
+ gwvpmini_UpdateRepoDescription($rid, $_REQUEST["desc"]);
+ \r
+ gwvpmini_SendMessage("info", "Repo description updated");\r
+ header("Location: $BASE_URL/view/$repo_view_call");\r
+ return;
}\r
?>
\ No newline at end of file