Shout: Fix bug that deleted other menu actions inadvertently
authorBen Klang <ben@alkaloid.net>
Fri, 26 Mar 2010 18:17:30 +0000 (14:17 -0400)
committerBen Klang <ben@alkaloid.net>
Fri, 26 Mar 2010 20:54:27 +0000 (16:54 -0400)
shout/lib/Driver/Sql.php

index 11748a2..93e55ae 100644 (file)
@@ -211,8 +211,11 @@ class Shout_Driver_Sql extends Shout_Driver
     public function saveMenuAction($account, $menu, $digit, $action, $args)
     {
         // Remove any existing action
-        $sql = 'DELETE FROM menu_entries WHERE digit = ?';
-        $values = array($digit);
+        $sql = 'DELETE FROM menu_entries WHERE menu_id = ' .
+               '(SELECT id FROM menus WHERE account_id = ' .
+               '(SELECT id FROM accounts WHERE code = ?) AND name = ?) ' .
+               'AND digit = ?';
+        $values = array($account, $menu, $digit);
         $msg = 'SQL query in Shout_Driver_Sql#saveMenuAction(): ' . $sql;
         Horde::logMessage($msg, 'DEBUG');
         $result = $this->_write_db->query($sql, $values);