From 755b11a472bc4309d48af8f444deb0b6348cdc10 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Sat, 22 Sep 2012 10:50:25 +1000 Subject: [PATCH] minor typo fix --- gwvpmini/gwvpmini_db.php | 13 +++++++++ gwvpmini/gwvpmini_view.php | 59 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/gwvpmini/gwvpmini_db.php b/gwvpmini/gwvpmini_db.php index b74a334..17bbb0a 100644 --- a/gwvpmini/gwvpmini_db.php +++ b/gwvpmini/gwvpmini_db.php @@ -261,6 +261,19 @@ function gwvpmini_DisableUser($uid) $sql = "update users set user_status=1 where user_id='$uid'"; return $conn->query($sql); +} + +function gwvpmini_UpdateRepoDescription($rid, $desc) +{ + $conn = gwvpmini_ConnectDB(); + + // remove any tag elements + $newdesc_r = preg_replace("/[\<\>\;]+/", "", $desc); + $newdesc = preg_replace("/\n/", "
", $newdesc_r); + + $sql = "update repos set repos_description='$newdesc' where repos_id='$rid'"; + + return $conn->query($sql); } function gwvpmini_EnableUser($uid) diff --git a/gwvpmini/gwvpmini_view.php b/gwvpmini/gwvpmini_view.php index b47c152..942ce73 100644 --- a/gwvpmini/gwvpmini_view.php +++ b/gwvpmini/gwvpmini_view.php @@ -36,6 +36,9 @@ function gwvpmini_RepoViewCallMe() if($qspl[0] == "reporemovecontribs") { return "gwvpmini_RemoveRepoContributor"; } + if($qspl[0] == "repoupdatedesc") { + return "gwvpmini_RepoUpdateDescription"; + } return false; } else return false; @@ -73,6 +76,8 @@ function gwvpmini_RepoViewPageBody() $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call); $desc = gwvpmini_GetRepoDescFromName($repo_view_call); + $editdesc = preg_replace("/\/", "\n", $desc); + $owner_name = $owner["username"]; @@ -97,7 +102,7 @@ function gwvpmini_RepoViewPageBody() 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 "
"; @@ -106,9 +111,12 @@ function gwvpmini_RepoViewPageBody() else $owner_extra = ""; echo "

".get_gravatar($owner["email"], 30, 'mm', 'g', true)."$repo_view_call - $owner_name$owner_extra

"; - echo "$desc
"; + if(!$owner_view) echo "$desc
"; if($owner_view) { + echo "
"; + echo "

Description


"; + echo "
"; @@ -169,6 +177,7 @@ function gwvpmini_RepoViewPageBody() echo " "; echo "
"; echo ""; + } //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"); @@ -491,6 +500,52 @@ function gwvpmini_RemoveRepoReader() header("Location: $BASE_URL/view/$repo_view_call"); return; +} + +function gwvpmini_RepoUpdateDescription() +{ + global $BASE_URL, $repo_view_call; + + if(isset($_REQUEST["q"])) { + $query = $_REQUEST["q"]; + $qspl = explode("/", $query); + error_log("PLOOP:qview".print_r($qspl, true)); + } + + if(isset($qspl[1])) $repo_view_call = $qspl[1]; + else { + error_log("PLOOP: no repo name"); + // TODO: btw, this makes no sense + header("Location: $BASE_URL/view/$repo_view_call"); + return; + } + + + $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call); + $desc = gwvpmini_GetRepoDescFromName($repo_view_call); + + $owner_name = $owner["username"]; + + $owner_view = false; + if(isset($_SESSION["id"])) { + if($owner["id"] == $_SESSION["id"]) { + $owner_view = true; + } + } + if(!$owner_view) { + gwvpmini_SendMessage("error", "failure updating description for repo"); + error_log("PLOOP: attempt to update from non-owner"); + header("Location: $BASE_URL/view/$repo_view_call"); + return; + } + + $rid = gwvpmini_GetRepoId($repo_view_call); + + gwvpmini_UpdateRepoDescription($rid, $_REQUEST["desc"]); + + gwvpmini_SendMessage("info", "Repo description updated"); + header("Location: $BASE_URL/view/$repo_view_call"); + return; } ?> \ No newline at end of file -- 1.7.0.4