Delete tickets with queues
authorBen Klang <ben@alkaloid.net>
Wed, 3 Nov 2010 18:17:02 +0000 (14:17 -0400)
committerBen Klang <ben@alkaloid.net>
Wed, 3 Nov 2010 18:18:16 +0000 (14:18 -0400)
whups/lib/Driver/sql.php
whups/lib/Forms/Admin/Queue.php

index 4fed623..33327a3 100644 (file)
@@ -1453,6 +1453,26 @@ class Whups_Driver_sql extends Whups_Driver {
      */
     function deleteQueue($queueId)
     {
+        // Clean up the tickets associated with the queue.
+        $query = 'SELECT ticket_id FROM whups_tickets WHERE queue_id = ?';
+        $values = array($queueId);
+        Horde::logMessage(sprintf('Whups_Driver_sql::deleteQueue: query="%s"; values=%s"', $query, implode(',', $values)), 'DEBUG');
+
+        $result = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
+        if (is_a($result, 'PEAR_Error')) {
+            Horde::logMessage($result, 'ERR');
+            return $result;
+        }
+
+        foreach ($result as $ticket) {
+          $info['id'] = $ticket['ticket_id'];
+          $this->deleteTicket($info);
+        }
+
+        // Now remove all references to the queue itself
+        // Note that whups_tickets could be in this list below, but there
+        // should never be tickets left for the queue at this point
+        // because they were all deleted above.
         $tables = array('whups_queues_users',
                         'whups_types_queues',
                         'whups_versions',
index e844d86..fdbb168 100644 (file)
@@ -171,7 +171,7 @@ class DeleteQueueForm extends Horde_Form {
 
         $yesno = array(array(0 => _("No"), 1 => _("Yes")));
         $this->addVariable(
-            _("Really delete this queue? This may cause data problems!"),
+            _("Really delete this queue? This will also delete all associated tickets and their comments. This can not be undone!"),
             'yesno', 'enum', true, false, null, $yesno);
     }