summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorDan Vratil <vratil@progdansoft.com>2010-11-21 02:59:07 -0500
committerLoui Chang <louipc.ist@gmail.com>2010-11-21 03:37:17 -0500
commit57a5cbfd88b2b91722ce0bf6911b416d051dde65 (patch)
treec7a8175ec8c90ef6610aabce02af4d291ea74d14 /web/lib
parent01fc2024cb48a68710065ceaae070f35aa69825d (diff)
downloadaurweb-57a5cbfd88b2b91722ce0bf6911b416d051dde65.tar.xz
Auto redirect from confirmation screens.
Finally move comment deletion and category editing into functions and remove pkgedit.php Signed-off-by: Loui Chang <louipc.ist@gmail.com> -Fix indentation -Fix variable naming conflict $id vs $cid
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc86
1 files changed, 86 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 0f45124..c701348 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -984,3 +984,89 @@ function pkg_notify ($atype, $ids, $action = True) {
return $output;
}
+
+
+/**
+ * Delete comment
+ *
+ * @param string $atype Account type, output of account_from_sid
+ * @return string Translated error or success message
+ */
+function pkg_delete_comment($atype) {
+ if (!$atype) {
+ return __("You must be logged before you can edit package information.");
+ }
+
+ # Get ID of comment to be removed
+ if (isset($_POST["comment_id"])) {
+ $comment_id = $_POST["comment_id"];
+ } else {
+ return __("Missing comment ID.");
+ }
+
+ $uid = uid_from_sid($_COOKIE["AURSID"]);
+ if (canDeleteComment($comment_id, $atype, $uid)) {
+
+ $dbh = db_connect();
+ $q = "UPDATE PackageComments ";
+ $q.= "SET DelUsersID = ".$uid." ";
+ $q.= "WHERE ID = ".intval($comment_id);
+ db_query($q, $dbh);
+ return __("Comment has been deleted.");
+ } else {
+ return __("You are not allowed to delete this comment.");
+ }
+}
+
+/**
+ * Change package category
+ *
+ * @param string $atype Account type, output of account_from_sid
+ * @return string Translated error or success message
+ */
+function pkg_change_category($atype) {
+ if (!$atype) {
+ return __("You must be logged before you can edit package information.");
+ }
+
+ # Get ID of the new category
+ if (isset($_POST["category_id"])) {
+ $category_id = $_POST["category_id"];
+ } else {
+ return __("Missing category ID.");
+ }
+
+ $catArray = pkgCategories();
+ if (!array_key_exists($category_id, $catArray)) {
+ return __("Invalid category ID.");
+ }
+
+ if (isset($_GET["ID"])) {
+ $pid = $_GET["ID"];
+ } else {
+ return __("Missing package ID.");
+ }
+
+ # Verify package ownership and location
+ $dbh = db_connect();
+ $q = "SELECT Packages.MaintainerUID,";
+ $q.= "PackageLocations.Location ";
+ $q.= "FROM Packages ";
+ $q.= "LEFT JOIN PackageLocations ON Packages.LocationID = PackageLocations.ID ";
+ $q.= "WHERE Packages.ID = ".$pid;
+ $result = db_query($q, $dbh);
+ echo mysql_error();
+ $pkg = mysql_fetch_assoc($result);
+
+ $uid = uid_from_sid($_COOKIE["AURSID"]);
+ if ($pkg["Location"] == "unsupported" and ($uid == $pkg["MaintainerUID"] or
+ ($atype == "Developer" or $atype == "Trusted User"))) {
+ $q = "UPDATE Packages ";
+ $q.= "SET CategoryID = ".intval($category_id)." ";
+ $q.= "WHERE ID = ".intval($pid);
+ db_query($q, $dbh);
+ return __("Package category changed.");
+ } else {
+ return __("You are not allowed to change this package category.");
+ }
+}