add multi drop for views and fix a small bug I introduced in schema
authorioguix <ioguix>
Sat, 15 Dec 2007 22:57:43 +0000 (22:57 +0000)
committerioguix <ioguix>
Sat, 15 Dec 2007 22:57:43 +0000 (22:57 +0000)
lang/english.php
lang/recoded/english.php
schemas.php
views.php

index 57f074991c6a135a2f90b1892ff3e5d9518b7c4d..bad7930df020085a0bfd7bdfe85c64f8415d28bf 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.225 2007/12/15 22:21:54 ioguix Exp $
+        * $Id: english.php,v 1.226 2007/12/15 22:57:43 ioguix Exp $
         */
 
        // Language and character set
        $lang['strerrordupfields'] = 'Error on duplicate fields';
        $lang['strviewaltered'] = 'View altered.';
        $lang['strviewalteredbad'] = 'View alteration failed.';
+       $lang['strspecifyviewtodrop'] = 'You must specify at least one view to drop';
 
        // Sequences
        $lang['strsequence'] = 'Sequence';
index 209e7fa8106c5da7db494b818d249d001dbb506b..e4b68522f6b3de6f57dbe15618b6c96cb27ab613 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.176 2007/12/15 22:21:54 ioguix Exp $
+        * $Id: english.php,v 1.177 2007/12/15 22:57:43 ioguix Exp $
         */
 
        // Language and character set
        $lang['strerrordupfields'] = 'Error on duplicate fields';
        $lang['strviewaltered'] = 'View altered.';
        $lang['strviewalteredbad'] = 'View alteration failed.';
+       $lang['strspecifyviewtodrop'] = 'You must specify at least one view to drop';
 
        // Sequences
        $lang['strsequence'] = 'Sequence';
index af7c64af64f6af01ea59e01f8218ef844cf18398..77d6063517bcd0966e5d12f4cfb36ea2e99aed38 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas in a database
         *
-        * $Id: schemas.php,v 1.21 2007/12/15 21:46:44 ioguix Exp $
+        * $Id: schemas.php,v 1.22 2007/12/15 22:57:43 ioguix Exp $
         */
 
        // Include application functions
                global $data, $misc;
                global $lang, $_reload_browser;
 
-               if (empty($_REQUEST['schema']) && empty($_REQUEST['ma'])) {
+               if (empty($_REQUEST['nsp']) && empty($_REQUEST['ma'])) {
                        doDefault($lang['strspecifyschematodrop']);
                        exit();
                }
index 17fe3b6d08539436545323c486b49ddd5e7831dc..091dea02778c4d128678b0a9aad879063c23e4ab 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.74 2007/09/13 13:41:01 ioguix Exp $
+        * $Id: views.php,v 1.75 2007/12/15 22:57:43 ioguix Exp $
         */
 
        // Include application functions
                global $data, $misc;
                global $lang, $_reload_browser;
 
+               if (empty($_REQUEST['view']) && empty($_REQUEST['ma'])) {
+                       doDefault($lang['strspecifyviewtodrop']);
+                       exit();
+               }
+
                if ($confirm) { 
                        $misc->printTrail('view');
                        $misc->printTitle($lang['strdrop'],'pg.view.drop');
                        
-                       echo "<p>", sprintf($lang['strconfdropview'], $misc->printVal($_REQUEST['view'])), "</p>\n";
-                       
                        echo "<form action=\"views.php\" method=\"post\">\n";
+                       
+                       //If multi drop
+                       if (isset($_REQUEST['ma'])) {
+                               foreach($_REQUEST['ma'] as $v) {
+                                       $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES));
+                                       echo "<p>", sprintf($lang['strconfdropview'], $misc->printVal($a['view'])), "</p>\n";
+                                       echo '<input type="hidden" name="view[]" value="', htmlspecialchars($a['view']), "\" />\n";
+                               }
+                       }
+                       else {
+                               echo "<p>", sprintf($lang['strconfdropview'], $misc->printVal($_REQUEST['view'])), "</p>\n";
+                               echo "<input type=\"hidden\" name=\"view\" value=\"", htmlspecialchars($_REQUEST['view']), "\" />\n";
+                       }
+                       
                        echo "<input type=\"hidden\" name=\"action\" value=\"drop\" />\n";
-                       echo "<input type=\"hidden\" name=\"view\" value=\"", htmlspecialchars($_REQUEST['view']), "\" />\n";
+                       
                        echo $misc->form;
                        // Show cascade drop option if supportd
                        if ($data->hasDropBehavior()) {
                        echo "</form>\n";
                }
                else {
-                       $status = $data->dropView($_POST['view'], isset($_POST['cascade']));
-                       if ($status == 0) {
-                               $_reload_browser = true;
-                               doDefault($lang['strviewdropped']);
+                       if (is_array($_POST['view'])) {
+                               $msg='';
+                               $status = $data->beginTransaction();
+                               if ($status == 0) {
+                                       foreach($_POST['view'] as $s) {
+                                               $status = $data->dropView($s, isset($_POST['cascade']));
+                                               if ($status == 0)
+                                                       $msg.= sprintf('%s: %s<br />', htmlentities($s), $lang['strviewdropped']);
+                                               else {
+                                                       $data->endTransaction();
+                                                       doDefault(sprintf('%s%s: %s<br />', $msg, htmlentities($s), $lang['strviewdroppedbad']));
+                                                       return;
+                                               }
+                                       }
+                               }
+                               if($data->endTransaction() == 0) {
+                                       // Everything went fine, back to the Default page....
+                                       $_reload_browser = true;
+                                       doDefault($msg);
+                               }
+                               else doDefault($lang['strviewdroppedbad']);
+                       }
+                       else{
+                               $status = $data->dropView($_POST['view'], isset($_POST['cascade']));
+                               if ($status == 0) {
+                                       $_reload_browser = true;
+                                       doDefault($lang['strviewdropped']);
+                               }
+                               else
+                                       doDefault($lang['strviewdroppedbad']);
                        }
-                       else
-                               doDefault($lang['strviewdroppedbad']);
                }
                
        }
                );
                
                $actions = array(
+                       'multiactions' => array(
+                               'keycols' => array('view' => 'relname'),
+                               'url' => 'views.php',
+                       ),
                        'browse' => array(
                                'title' => $lang['strbrowse'],
                                'url'   => "display.php?{$misc->href}&amp;subject=view&amp;return_url=".urlencode("views.php?{$misc->href}")."&amp;return_desc=".urlencode($lang['strback'])."&amp;",
                                'title' => $lang['strdrop'],
                                'url'   => "views.php?action=confirm_drop&amp;{$misc->href}&amp;",
                                'vars'  => array('view' => 'relname'),
+                               'multiaction' => 'confirm_drop',
                        ),
                );