mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Change behaviour of package functions to accept normal arrays
Package functions use a normal array of pkgids now and packages.php has been changed to accomodate for it Signed-off-by: Callan Barrett <wizzomafizzo@gmail.com> Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
parent
fb1c41c6c6
commit
cde524e175
2 changed files with 17 additions and 20 deletions
|
@ -25,10 +25,12 @@ if (isset($_COOKIE["AURSID"])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Grab the list of Package IDs to be operated on
|
# Grab the list of Package IDs to be operated on
|
||||||
#
|
$ids = array();
|
||||||
# TODO: Convert this to a normal array of IDs to operate on and convert the
|
if (isset($_POST['IDs'])) {
|
||||||
# functions to use this format
|
foreach ($_POST['IDs'] as $id => $i) {
|
||||||
isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array();
|
$ids[] = $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
html_header($title);
|
html_header($title);
|
||||||
|
|
||||||
|
|
|
@ -988,8 +988,7 @@ function pkg_search_page($SID="") {
|
||||||
* Flag and un-flag packages out-of-date
|
* Flag and un-flag packages out-of-date
|
||||||
*
|
*
|
||||||
* @param string $atype Account type, output of account_from_sid
|
* @param string $atype Account type, output of account_from_sid
|
||||||
* @param array $ids Array of package IDs to flag/unflag, formatted as
|
* @param array $ids Array of package IDs to flag/unflag
|
||||||
* $package_id => $useless_crap
|
|
||||||
* @param boolean $action True flags out-of-date, false un-flags. Flags by
|
* @param boolean $action True flags out-of-date, false un-flags. Flags by
|
||||||
* default
|
* default
|
||||||
*
|
*
|
||||||
|
@ -1012,7 +1011,7 @@ function pkg_flag ($atype, $ids, $action = True) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
if (!is_numeric($pid)) {
|
if (!is_numeric($pid)) {
|
||||||
if ($action) {
|
if ($action) {
|
||||||
return __("You did not select any packages to flag.");
|
return __("You did not select any packages to flag.");
|
||||||
|
@ -1025,7 +1024,7 @@ function pkg_flag ($atype, $ids, $action = True) {
|
||||||
$dbh = db_connect();
|
$dbh = db_connect();
|
||||||
|
|
||||||
$first = 1;
|
$first = 1;
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
$first = 0;
|
$first = 0;
|
||||||
$flag = $pid;
|
$flag = $pid;
|
||||||
|
@ -1073,8 +1072,7 @@ function pkg_flag ($atype, $ids, $action = True) {
|
||||||
* Delete packages
|
* Delete packages
|
||||||
*
|
*
|
||||||
* @param string $atype Account type, output of account_from_sid
|
* @param string $atype Account type, output of account_from_sid
|
||||||
* @param array $ids Array of package IDs to delete, formatted as
|
* @param array $ids Array of package IDs to delete
|
||||||
* $package_id => $useless_crap
|
|
||||||
*
|
*
|
||||||
* @return string Translated error or success message
|
* @return string Translated error or success message
|
||||||
*/
|
*/
|
||||||
|
@ -1094,7 +1092,7 @@ function pkg_delete ($atype, $ids) {
|
||||||
# Delete the packages in $ids array
|
# Delete the packages in $ids array
|
||||||
#
|
#
|
||||||
$first = 1;
|
$first = 1;
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
$first = 0;
|
$first = 0;
|
||||||
$delete = $pid;
|
$delete = $pid;
|
||||||
|
@ -1155,8 +1153,7 @@ function pkg_delete ($atype, $ids) {
|
||||||
* Adopt or disown packages
|
* Adopt or disown packages
|
||||||
*
|
*
|
||||||
* @param string $atype Account type, output of account_from_sid
|
* @param string $atype Account type, output of account_from_sid
|
||||||
* @param array $ids Array of package IDs to adopt/disown, formatted as
|
* @param array $ids Array of package IDs to adopt/disown
|
||||||
* $package_id => $whatever
|
|
||||||
* @param boolean $action Adopts if true, disowns if false. Adopts by default
|
* @param boolean $action Adopts if true, disowns if false. Adopts by default
|
||||||
*
|
*
|
||||||
* @return string Translated error or success message
|
* @return string Translated error or success message
|
||||||
|
@ -1181,7 +1178,7 @@ function pkg_adopt ($atype, $ids, $action = True) {
|
||||||
$dbh = db_connect();
|
$dbh = db_connect();
|
||||||
|
|
||||||
$first = 1;
|
$first = 1;
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
$first = 0;
|
$first = 0;
|
||||||
$pkg = $pid;
|
$pkg = $pid;
|
||||||
|
@ -1223,8 +1220,7 @@ function pkg_adopt ($atype, $ids, $action = True) {
|
||||||
* Vote and un-vote for packages
|
* Vote and un-vote for packages
|
||||||
*
|
*
|
||||||
* @param string $atype Account type, output of account_from_sid
|
* @param string $atype Account type, output of account_from_sid
|
||||||
* @param array $ids Array of package IDs to vote/un-vote, formatted as
|
* @param array $ids Array of package IDs to vote/un-vote
|
||||||
* $package_id => $useless
|
|
||||||
* @param boolean $action Votes if true, un-votes if false. Votes by default
|
* @param boolean $action Votes if true, un-votes if false. Votes by default
|
||||||
*
|
*
|
||||||
* @return string Translated error or success message
|
* @return string Translated error or success message
|
||||||
|
@ -1251,7 +1247,7 @@ function pkg_vote ($atype, $ids, $action = True) {
|
||||||
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
$uid = uid_from_sid($_COOKIE["AURSID"]);
|
||||||
|
|
||||||
$first = 1;
|
$first = 1;
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
if ($action) {
|
if ($action) {
|
||||||
$check = !isset($my_votes[$pid]);
|
$check = !isset($my_votes[$pid]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1310,8 +1306,7 @@ function pkg_vote ($atype, $ids, $action = True) {
|
||||||
* Toggle notification of packages
|
* Toggle notification of packages
|
||||||
*
|
*
|
||||||
* @param string $atype Account type, output of account_from_sid
|
* @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, formatted as $package_id
|
||||||
*
|
|
||||||
* @return string Translated error or success message
|
* @return string Translated error or success message
|
||||||
*/
|
*/
|
||||||
function pkg_notify ($atype, $ids, $action = True) {
|
function pkg_notify ($atype, $ids, $action = True) {
|
||||||
|
@ -1333,7 +1328,7 @@ function pkg_notify ($atype, $ids, $action = True) {
|
||||||
|
|
||||||
# There currently shouldn't be multiple requests here, but the
|
# There currently shouldn't be multiple requests here, but the
|
||||||
# format in which it's sent requires this.
|
# format in which it's sent requires this.
|
||||||
foreach ($ids as $pid => $v) {
|
foreach ($ids as $pid) {
|
||||||
$q = "SELECT Name FROM Packages WHERE ID = $pid";
|
$q = "SELECT Name FROM Packages WHERE ID = $pid";
|
||||||
$pkgname = mysql_result(db_query($q, $dbh), 0);
|
$pkgname = mysql_result(db_query($q, $dbh), 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue