diff options
author | Callan Barrett <wizzomafizzo@gmail.com> | 2008-10-04 19:46:31 +0200 |
---|---|---|
committer | Loui Chang <louipc.ist@gmail.com> | 2008-10-15 01:36:04 +0200 |
commit | 8f5882e68deec6a8780653ae537aea7aa02283c3 (patch) | |
tree | 314c0c15b11f5b245c7f32ba1de5e9b5fce7e10b /web/html | |
parent | 2ce36384da97946bc6fe324a8c32a99c9b2d7873 (diff) | |
download | aur-8f5882e68deec6a8780653ae537aea7aa02283c3.tar.gz aur-8f5882e68deec6a8780653ae537aea7aa02283c3.tar.xz |
Convert package flagging to a function
Signed-off-by: Callan Barrett <wizzomafizzo@gmail.com>
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web/html')
-rw-r--r-- | web/html/packages.php | 101 |
1 files changed, 6 insertions, 95 deletions
diff --git a/web/html/packages.php b/web/html/packages.php index 4cfe9c48..317583fc 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -37,106 +37,17 @@ if (isset($_COOKIE["AURSID"])) { # grab the list of Package IDs to be operated on # isset($_POST["IDs"]) ? $ids = $_POST["IDs"] : $ids = array(); -#isset($_REQUEST["All_IDs"]) ? -# $all_ids = explode(":", $_REQUEST["All_IDs"]) : -# $all_ids = array(); - # determine what button the visitor clicked # if ($_POST['action'] == "do_Flag" || isset($_POST['do_Flag'])) { - if (!$atype) { - print __("You must be logged in before you can flag packages."); - print "<br />\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $flag = $pid; - } else { - $flag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 1 "; - $q.= "WHERE ID IN (" . $flag . ")"; - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been flagged out-of-date."); - print "</p>\n"; - - # notification by tardo. - $f_name = username_from_sid($_COOKIE['AURSID']); - $f_email = email_from_sid($_COOKIE['AURSID']); - $f_uid = uid_from_sid($_COOKIE['AURSID']); - $q = "SELECT Packages.Name, Users.Email, Packages.ID "; - $q.= "FROM Packages, Users "; - $q.= "WHERE Packages.ID IN (" . $flag .") "; - $q.= "AND Users.ID = Packages.MaintainerUID "; - $q.= "AND Users.ID != " . $f_uid; - $result = db_query($q, $dbh); - if (mysql_num_rows($result)) { - while ($row = mysql_fetch_assoc($result)) { - # construct email - $body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . ". You may view your package at:\nhttp://aur.archlinux.org/packages.php?do_Details=1&ID=" . $row['ID']; - $body = wordwrap($body, 70); - $headers = "To: ".$row['Email']."\nReply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n"; - @mail(' ', "AUR Out-of-date Notification for ".$row['Name'], $body, $headers); - } - } - - } else { - print "<p>\n"; - print __("You did not select any packages to flag."); - print "</p>\n"; - } - } - + print "<p>"; + print pkg_flag($atype, $ids, True); + print "</p>"; } elseif ($_POST['action'] == "do_UnFlag" || isset($_POST['do_UnFlag'])) { - if (!$atype) { - print __("You must be logged in before you can unflag packages."); - print "<br />\n"; - - } else { - - if (!empty($ids)) { - $dbh = db_connect(); - - # Un-Flag the packages in $ids array - # - $first = 1; - while (list($pid, $v) = each($ids)) { - if ($first) { - $first = 0; - $unflag = $pid; - } else { - $unflag .= ", ".$pid; - } - } - $q = "UPDATE Packages SET OutOfDate = 0 "; - $q.= "WHERE ID IN (" . $unflag . ")"; - db_query($q, $dbh); - - print "<p>\n"; - print __("The selected packages have been unflagged."); - print "</p>\n"; - } else { - print "<p>\n"; - print __("You did not select any packages to unflag."); - print "</p>\n"; - } - - - } - + print "<p>"; + print pkg_flag($atype, $ids, False); + print "</p>"; } elseif ($_POST['action'] == "do_Disown" || isset($_POST['do_Disown'])) { if (!$atype) { print __("You must be logged in before you can disown packages."); |