Merge all comments and votes of deleted packages into another package if
the "Merge with" field is used. Duplicate votes (votes from a user who
already voted on the target package or voted on more than one of the
deleted packages) are discarded.

Signed-off-by: Lukas Fleischer <[email protected]>
---
 web/html/packages.php               |   16 ++++++++++++++--
 web/template/actions_form.php       |    2 ++
 web/template/pkg_search_results.php |    2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/web/html/packages.php b/web/html/packages.php
index 4a1fa88..4e68151 100644
--- a/web/html/packages.php
+++ b/web/html/packages.php
@@ -50,8 +50,20 @@ if (current_action("do_Flag")) {
        $output = pkg_vote($atype, $ids, False);
 } elseif (current_action("do_Delete")) {
        if (isset($_POST['confirm_Delete'])) {
-               $output = pkg_delete($atype, $ids);
-               unset($_GET['ID']);
+               if (!isset($_POST['merge_Into']) || 
empty($_POST['merge_Into'])) {
+                       $output = pkg_delete($atype, $ids, NULL);
+                       unset($_GET['ID']);
+               }
+               else {
+                       $mergepkgid = pkgid_from_name($_POST['merge_Into']);
+                       if ($mergepkgid) {
+                               $output = pkg_delete($atype, $ids, $mergepkgid);
+                               unset($_GET['ID']);
+                       }
+                       else {
+                               $output = __("Cannot find package to merge 
votes and comments into.");
+                       }
+               }
        }
        else {
                $output = __("The selected packages have not been deleted, 
check the confirmation checkbox.");
diff --git a/web/template/actions_form.php b/web/template/actions_form.php
index 058002f..68d83d7 100644
--- a/web/template/actions_form.php
+++ b/web/template/actions_form.php
@@ -54,6 +54,8 @@
                if ($atype == "Trusted User" || $atype == "Developer") {
                        echo "<input type='submit' class='button' 
name='do_Delete'";
                        echo " value='".__("Delete Packages")."' />\n";
+                       echo "<label for='merge_Into'>".__("Merge 
into")."</label>\n";
+                       echo "<input type='text' id='merge_Into' 
name='merge_Into' /> ";
                        echo "<input type='checkbox' name='confirm_Delete' 
value='1' /> ";
                        echo __("Confirm")."\n";
                }
diff --git a/web/template/pkg_search_results.php 
b/web/template/pkg_search_results.php
index d32b6c4..e576e6e 100644
--- a/web/template/pkg_search_results.php
+++ b/web/template/pkg_search_results.php
@@ -110,6 +110,8 @@ for ($i = 0; $row = mysql_fetch_assoc($result); $i++) {
                                                        <option 
value='do_UnNotify'><?php print __("UnNotify") ?></option>
                                                </select>
                                                <?php if ($atype == "Trusted 
User" || $atype == "Developer"): ?>
+                                                       <label 
for='merge_Into'><?php print __("Merge into") ?></label>
+                                                       <input type='text' 
id='merge_Into' name='merge_Into' />
                                                        <input type='checkbox' 
name='confirm_Delete' value='1' /> <?php print __("Confirm") ?>
                                                <?php endif; ?>
                                                <input type='submit' 
class='button' style='width: 80px' value='<?php print __("Go") ?>' />
-- 
1.7.6

Reply via email to