--- web/html/packages.php | 2 ++ web/lib/pkgfuncs.inc | 29 +++++++++++++++++++++++++++++ web/template/pkg_details.php | 17 ++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index abc6637..9077ce2 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -64,6 +64,8 @@ if (current_action("do_Flag")) { $output = pkg_delete_comment($atype); } elseif (current_action("do_ChangeCategory")) { $output = pkg_change_category($atype); +} elseif (current_action("do_ChangeName")) { + $output = pkg_change_name($atype); } html_header($title); diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 2024aeb..c2ca9bc 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -999,3 +999,32 @@ function pkg_change_category($atype) { return __("You are not allowed to change this package category."); } } + +/** + * Change package name + * + * @param string $atype Account type, output of account_from_sid + * @return string Translated error or success message + */ + + function pkg_change_name($atype) { + if (!$atype) { + return __("You must be logged in before you can edit package information."); + } + + if (isset($_GET["ID"])) { + $pid = $_GET["ID"]; + } else { + return __("Missing package ID."); + } + + $newname=$_POST['newname']; + + $dbh = db_connect(); + $q = "UPDATE Packages "; + $q.= "SET Name='".mysql_real_escape_string($newname)."' "; + $q.= "WHERE ID=".intval($pid); + db_query($q,$dbh); + return __("Package updated."); +} + diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 0658063..0442a07 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -66,7 +66,22 @@ $out_of_date_time = ($row["OutOfDateTS"] == 0) ? $msg : gmdate("r", intval($row[ <div class="pgboxbody"> <p> - <span class='f2'><?php echo htmlspecialchars($row['Name']) . ' ' . htmlspecialchars($row['Version']) ?></span><br /> + <span class='f2'> + <?php + if (($atype == "Developer" or $atype == "Trusted User")) { + $edit_name = "<form method='post' action='packages.php?ID=".$pkgid."'>\n"; + $edit_name.= "<input type='hidden' name='action' value='do_ChangeName' />"; + $edit_name.= "<input type='text' name='newname' value='".$row['Name']."' />"; + $edit_name.= htmlspecialchars($row['Version']).' '; + $edit_name.= "<input type='submit' value='Change Name' />"; + $edit_name.= "</form>"; + echo $edit_name; + } + else { + echo htmlspecialchars($row['Name']).' ' . htmlspecialchars($row['Version']); + } + ?> + </span><br /> <span class='f3'><a href="<?php echo htmlspecialchars($row['URL'], ENT_QUOTES) . '">' . $row['URL'] ?></a></span><br /> <span class='f3'><?php echo htmlspecialchars($row['Description'], ENT_QUOTES); ?></span> </p> -- 1.7.5.2