[aur-dev] [PATCH] Package functions use normal array of IDs

Callan Barrett wizzomafizzo at gmail.com
Sat Oct 4 17:13:21 EDT 2008


packages.php now converts array of IDs to a normal array and all package
functions have been changed to use the new array format

Signed-off-by: Callan Barrett <wizzomafizzo at gmail.com>
---
 web/html/packages.php |   10 ++++++----
 web/lib/pkgfuncs.inc  |   26 +++++++++++---------------
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/web/html/packages.php b/web/html/packages.php
index 9c611d8..3e56a49 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -25,10 +25,12 @@ if (isset($_COOKIE["AURSID"])) {
 }
 
 # Grab the list of Package IDs to be operated on
-#
-# TODO: Convert this to a normal array of IDs to operate on and convert the
-# functions to use this format
-isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array();
+$ids = array();
+if (isset($_POST['IDs'])) {
+	foreach ($_POST['IDs'] as $id => $i) {
+		$ids[] = $id;
+	}
+}
 
 html_header($title);
 
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 9941103..06171fa 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -989,8 +989,7 @@ function pkg_search_page($SID="") {
  * Flag and un-flag packages out-of-date
  *
  * @param string $atype Account type, output of account_from_sid
- * @param array $ids Array of package IDs to flag/unflag, formatted as
- * $package_id => $useless_crap
+ * @param array $ids Array of package IDs to flag/unflag
  * @param boolean $action True flags out-of-date, false un-flags. Flags by
  * default
  * 
@@ -1013,7 +1012,7 @@ function pkg_flag ($atype, $ids, $action = True) {
 		}
 	}
 
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		if (!is_numeric($pid)) { 
 			if ($action) {
 				return __("You did not select any packages to flag.");
@@ -1026,7 +1025,7 @@ function pkg_flag ($atype, $ids, $action = True) {
 	$dbh = db_connect();
 
 	$first = 1;
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		if ($first) {
 			$first = 0;
 			$flag = $pid;
@@ -1074,8 +1073,7 @@ function pkg_flag ($atype, $ids, $action = True) {
  * Delete packages
  * 
  * @param string $atype Account type, output of account_from_sid
- * @param array $ids Array of package IDs to delete, formatted as
- * $package_id => $useless_crap
+ * @param array $ids Array of package IDs to delete
  * 
  * @return string Translated error or success message
  */
@@ -1095,7 +1093,7 @@ function pkg_delete ($atype, $ids) {
 	# Delete the packages in $ids array
 	#
 	$first = 1;
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		if ($first) {
 			$first = 0;
 			$delete = $pid;
@@ -1156,8 +1154,7 @@ function pkg_delete ($atype, $ids) {
  * Adopt or disown packages
  * 
  * @param string $atype Account type, output of account_from_sid
- * @param array $ids Array of package IDs to adopt/disown, formatted as
- * $package_id => $whatever
+ * @param array $ids Array of package IDs to adopt/disown
  * @param boolean $action Adopts if true, disowns if false. Adopts by default
  * 
  * @return string Translated error or success message
@@ -1182,7 +1179,7 @@ function pkg_adopt ($atype, $ids, $action = True) {
 	$dbh = db_connect();
 
 	$first = 1;
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		if ($first) {
 			$first = 0;
 			$disown = $pid;
@@ -1224,8 +1221,7 @@ function pkg_adopt ($atype, $ids, $action = True) {
  * Vote and un-vote for packages
  * 
  * @param string $atype Account type, output of account_from_sid
- * @param array $ids Array of package IDs to vote/un-vote, formatted as
- * $package_id => $useless
+ * @param array $ids Array of package IDs to vote/un-vote
  * @param boolean $action Votes if true, un-votes if false. Votes by default
  * 
  * @return string Translated error or success message
@@ -1252,7 +1248,7 @@ function pkg_vote ($atype, $ids, $action = True) {
 	$uid = uid_from_sid($_COOKIE["AURSID"]);
 
 	$first = 1;
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		if ($action) {
 			$check = !isset($my_votes[$pid]);
 		} else {
@@ -1311,7 +1307,7 @@ function pkg_vote ($atype, $ids, $action = True) {
  * Toggle notification of packages
  * 
  * @param string $atype Account type, output of account_from_sid
- * @param array $ids Array of package IDs to toggle, formatted as $package_id => $crap
+ * @param array $ids Array of package IDs to toggle
  * 
  * @return string Translated error or success message
  */
@@ -1331,7 +1327,7 @@ function pkg_notify ($atype, $ids) {
 	# it's sent requires this
 	$list = array();
 	
-	foreach ($ids as $pid => $v) {
+	foreach ($ids as $pid) {
 		$q = "SELECT Name FROM Packages WHERE ID = " . $pid;
 		$pkgname = mysql_result(db_query($q, $dbh), 0);
 
-- 
1.6.0.2




More information about the aur-dev mailing list