minor typo fix
authorPaul J R <me@pjr.cc>
Sat, 22 Sep 2012 00:50:25 +0000 (10:50 +1000)
committerPaul J R <me@pjr.cc>
Sat, 22 Sep 2012 00:50:25 +0000 (10:50 +1000)
gwvpmini/gwvpmini_db.php
gwvpmini/gwvpmini_view.php

index b74a334..17bbb0a 100644 (file)
@@ -261,6 +261,19 @@ function gwvpmini_DisableUser($uid)
        $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
index b47c152..942ce73 100644 (file)
@@ -36,6 +36,9 @@ function gwvpmini_RepoViewCallMe()
                        if($qspl[0] == "reporemovecontribs") {
                                return "gwvpmini_RemoveRepoContributor";
                        }
+                       if($qspl[0] == "repoupdatedesc") {
+                               return "gwvpmini_RepoUpdateDescription";
+                       }
                        return false;\r
                }\r
                else return false;\r
@@ -73,6 +76,8 @@ function gwvpmini_RepoViewPageBody()
        
        $owner = gwvpmini_GetRepoOwnerDetailsFromName($repo_view_call);
        $desc = gwvpmini_GetRepoDescFromName($repo_view_call);
+       $editdesc = preg_replace("/\<br\>/", "\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 "<textarea rows=1 cols=".strlen($cloneurl).">$cloneurl</textarea><br>";
@@ -106,9 +111,12 @@ function gwvpmini_RepoViewPageBody()
        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
                
                
 
@@ -169,6 +177,7 @@ function gwvpmini_RepoViewPageBody()
                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");
@@ -491,6 +500,52 @@ function gwvpmini_RemoveRepoReader()
        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