From 8159ff6c52a5e770947a316d68f56f0d4cfd871d Mon Sep 17 00:00:00 2001 From: xzilla Date: Sat, 12 Feb 2011 17:47:03 -0500 Subject: [PATCH] Fix bug where enable/disable trigger option would be set incorrectly for multiple triggers. Based on pull request / commit https://github.com/DeyV/phppgadmin/commit/312e8fa3938dd28b4c0cdfe3040c821c6af7b8d5 --- triggers.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/triggers.php b/triggers.php index 9aa8c87c..7f586cb2 100644 --- a/triggers.php +++ b/triggers.php @@ -261,12 +261,23 @@ global $data, $misc, $database; global $lang; - function tgPre(&$rowdata) { - global $data, $lang; + function tgPre(&$rowdata,$actions) { + global $data; // Nasty hack to support pre-7.4 PostgreSQL $rowdata->fields['+tgdef'] = $rowdata->fields['tgdef'] !== null ? $rowdata->fields['tgdef'] : $data->getTriggerDef($rowdata->fields); + + + // toggle enable/disable trigger per trigger + if( ! $data->phpBool( $rowdata->fields["tgenabled"] ) ) { + unset( $actions['disable'] ); + } + else{ + unset( $actions['enable'] ); + } + + return $actions; } $misc->printTrail('table'); @@ -312,19 +323,16 @@ ), ); if($data->hasDisableTriggers()) { - if(!$data->phpBool($triggers->fields["tgenabled"])) { $actions['enable'] = array( 'title' => $lang['strenable'], 'url' => "triggers.php?action=confirm_enable&{$misc->href}&table=".urlencode($_REQUEST['table'])."&", 'vars' => array('trigger' => 'tgname'), ); - } else { $actions['disable'] = array( 'title' => $lang['strdisable'], 'url' => "triggers.php?action=confirm_disable&{$misc->href}&table=".urlencode($_REQUEST['table'])."&", 'vars' => array('trigger' => 'tgname'), ); - } } $misc->printTable($triggers, $columns, $actions, $lang['strnotriggers'], 'tgPre'); -- 2.39.5