Skip to content

Commit

Permalink
add multi drop for views and fix a small bug I introduced in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ioguix committed Dec 15, 2007
1 parent b5d8109 commit 2e9a661
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lang/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -394,6 +394,7 @@
$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';
Expand Down
3 changes: 2 additions & 1 deletion lang/recoded/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -394,6 +394,7 @@
$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';
Expand Down
4 changes: 2 additions & 2 deletions schemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,7 +214,7 @@ function doDrop($confirm) {
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();
}
Expand Down
66 changes: 56 additions & 10 deletions views.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -129,15 +129,32 @@ function doDrop($confirm) {
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()) {
Expand All @@ -148,13 +165,37 @@ function doDrop($confirm) {
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']);
}

}
Expand Down Expand Up @@ -565,6 +606,10 @@ function doDefault($msg = '') {
);

$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;",
Expand All @@ -587,6 +632,7 @@ function doDefault($msg = '') {
'title' => $lang['strdrop'],
'url' => "views.php?action=confirm_drop&amp;{$misc->href}&amp;",
'vars' => array('view' => 'relname'),
'multiaction' => 'confirm_drop',
),
);

Expand Down

0 comments on commit 2e9a661

Please sign in to comment.