diff --git a/Documentation.html b/Documentation.html index 5b3da22006..192fec4d35 100644 --- a/Documentation.html +++ b/Documentation.html @@ -137,6 +137,8 @@ vim: expandtab ts=4 sw=4 sts=4 tw=78 FAQ 3.6)
  • support mysqli, the improved MySQL extension (see FAQ 1.17)
  • +
  • create, edit, call, export and drop stored procedures and functions
  • +
  • create, edit, export and drop events and triggers
  • communicate in 62 different languages
  • synchronize two databases residing on the same as well as remote servers @@ -5082,6 +5084,8 @@ Jakub Wilk, Thomas Michael Winningham, Vilius Zigmantas, "Manuzhai".
  • SSL (Secure Sockets Layer) - a cryptographic protocol which provides secure communication on the Internet.
  • +
  • Stored procedure + - a subroutine available to applications accessing a relational database system
  • SQL - Structured Query Language
  • table @@ -5093,6 +5097,9 @@ Jakub Wilk, Thomas Michael Winningham, Vilius Zigmantas, "Manuzhai". - a type of archive file format: the Tape ARchive format.
  • TCP (Transmission Control Protocol) - one of the core protocols of the Internet protocol suite.
  • +
  • trigger + - a procedural code that is automatically executed in response to + certain events on a particular table or view in a database
  • UFPDF - Unicode/UTF-8 extension for FPDF
  • URL (Uniform Resource Locator) diff --git a/db_events.php b/db_events.php new file mode 100644 index 0000000000..9577b4af80 --- /dev/null +++ b/db_events.php @@ -0,0 +1,41 @@ + diff --git a/db_routines.php b/db_routines.php new file mode 100644 index 0000000000..b5c17d88e8 --- /dev/null +++ b/db_routines.php @@ -0,0 +1,41 @@ + diff --git a/db_structure.php b/db_structure.php index ebc69154e4..898a92dfbd 100644 --- a/db_structure.php +++ b/db_structure.php @@ -58,14 +58,6 @@ $titles = PMA_buildActionTitles(); if ($num_tables == 0) { echo '

    ' . __('No tables found in database') . '

    ' . "\n"; - // Routines - require './libraries/db_routines.inc.php'; - - // Events - if (PMA_MYSQL_INT_VERSION > 50100) { - require './libraries/db_events.inc.php'; - } - if (empty($db_is_information_schema)) { require './libraries/display_create_table.lib.php'; } // end if (Create Table dialog) @@ -545,13 +537,6 @@ PMA_listNavigator($total_num_tables, $pos, $_url_params, 'db_structure.php', 'fr
    50100) { - require './libraries/db_events.inc.php'; -} /** * Work on the database diff --git a/db_triggers.php b/db_triggers.php new file mode 100644 index 0000000000..834332a750 --- /dev/null +++ b/db_triggers.php @@ -0,0 +1,41 @@ + diff --git a/js/db_events.js b/js/db_events.js new file mode 100644 index 0000000000..23e559999f --- /dev/null +++ b/js/db_events.js @@ -0,0 +1,67 @@ +$(document).ready(function() { + /** + * Ajax Event handler for 'Drop Event' + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] + */ + $('.drop_event_anchor').live('click', function(event) { + event.preventDefault(); + + /** + * @var curr_event_row Object reference to current event's row + */ + var $curr_event_row = $(this).parents('tr'); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = $curr_event_row.children('td').children('.drop_sql').text(); + + $(this).PMA_confirm(question, $(this).attr('href') , function(url) { + + PMA_ajaxShowMessage(PMA_messages['strDroppingEvent']); + + $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#result_query").remove(); + if ($('#event_list tr').length == 2) { + $('#event_list').remove(); + $('#no_events').show(); + } else { + $curr_event_row.hide("medium").remove(); + } + } + else { + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); + } + }) // end $.get() + }) // end $.PMA_confirm() + }) // end Drop Event + + /** + * Ajax Event handler for 'Export Event' + * + * @see $cfg['AjaxEnable'] + */ + $('.export_event_anchor').live('click', function(event) { + event.preventDefault(); + + /** + * @var button_options Object containing options for jQueryUI dialog buttons + */ + var button_options = {}; + button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();} + /** + * @var button_options The export SQL query to display to the user + */ + var query = $(this).parents('tr').find('.create_sql').html(); + + // show dialog + $('
    ').dialog({ + width: 450, + buttons: button_options + }).find('textarea').width('100%'); + }); // end Export Procedure +}, 'top.frame_content'); //end $(document).ready() for Drop Event diff --git a/js/db_routines.js b/js/db_routines.js new file mode 100644 index 0000000000..3fbd012e26 --- /dev/null +++ b/js/db_routines.js @@ -0,0 +1,67 @@ +$(document).ready(function() { + /** + * Ajax Event handler for 'Drop Procedure' + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] + */ + $('.drop_procedure_anchor').live('click', function(event) { + event.preventDefault(); + + /** + * @var curr_proc_row Object containing reference to the current procedure's row + */ + var $curr_proc_row = $(this).parents('tr'); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = $curr_proc_row.children('td').children('.drop_sql').text(); + + $(this).PMA_confirm(question, $(this).attr('href'), function(url) { + + PMA_ajaxShowMessage(PMA_messages['strDroppingProcedure']); + + $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#result_query").remove(); + if ($('#routine_list tr').length == 2) { + $('#routine_list').remove(); + $('#no_routines').show(); + } else { + $curr_proc_row.hide("medium").remove(); + } + } + else { + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); + } + }) // end $.get() + }) // end $.PMA_confirm() + }); // end Drop Procedure + + /** + * Ajax Event handler for 'Export Procedure' + * + * @see $cfg['AjaxEnable'] + */ + $('.export_procedure_anchor').live('click', function(event) { + event.preventDefault(); + + /** + * @var button_options Object containing options for jQueryUI dialog buttons + */ + var button_options = {}; + button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();} + /** + * @var button_options The export SQL query to display to the user + */ + var query = $(this).parents('tr').find('.create_sql').html(); + + // show dialog + $('
    ').dialog({ + width: 450, + buttons: button_options + }).find('textarea').width('100%'); + }); // end Export Procedure +}, 'top.frame_content'); //end $(document).ready() for Drop Procedure diff --git a/js/db_structure.js b/js/db_structure.js index 4affd75bd2..2693a0e11e 100644 --- a/js/db_structure.js +++ b/js/db_structure.js @@ -147,80 +147,6 @@ $(document).ready(function() { }); // end $.PMA_confirm() }); //end of Drop Table Ajax action - /** - * Ajax Event handler for 'Drop Event' - * - * @uses $.PMA_confirm() - * @uses PMA_ajaxShowMessage() - * @see $cfg['AjaxEnable'] - */ - $('.drop_event_anchor').live('click', function(event) { - event.preventDefault(); - - /** - * @var curr_event_row Object reference to current event's row - */ - var curr_event_row = $(this).parents('tr'); - /** - * @var curr_event_name String containing the name of {@link curr_event_row} - */ - var curr_event_name = $(curr_event_row).children('td:first').text(); - /** - * @var question String containing the question to be asked for confirmation - */ - var question = 'DROP EVENT ' + curr_event_name; - - $(this).PMA_confirm(question, $(this).attr('href') , function(url) { - - PMA_ajaxShowMessage(PMA_messages['strDroppingEvent']); - - $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { - if(data.success == true) { - PMA_ajaxShowMessage(data.message); - $(curr_event_row).hide("medium").remove(); - } - else { - PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); - } - }) // end $.get() - }) // end $.PMA_confirm() - }) //end Drop Event - - /** - * Ajax Event handler for 'Drop Procedure' - * - * @uses $.PMA_confirm() - * @uses PMA_ajaxShowMessage() - * @see $cfg['AjaxEnable'] - */ - $('.drop_procedure_anchor').live('click', function(event) { - event.preventDefault(); - - /** - * @var curr_proc_row Object containing reference to the current procedure's row - */ - var curr_proc_row = $(this).parents('tr'); - /** - * @var question String containing the question to be asked for confirmation - */ - var question = $(curr_proc_row).children('td').children('.drop_procedure_sql').val(); - - $(this).PMA_confirm(question, $(this).attr('href'), function(url) { - - PMA_ajaxShowMessage(PMA_messages['strDroppingProcedure']); - - $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { - if(data.success == true) { - PMA_ajaxShowMessage(data.message); - $(curr_event_row).hide("medium").remove(); - } - else { - PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); - } - }) // end $.get() - }) // end $.PMA_confirm() - }) //end Drop Procedure - /** * Ajax Event handler for 'Drop tracking' * diff --git a/js/display_triggers.js b/js/display_triggers.js new file mode 100644 index 0000000000..447f20a1f0 --- /dev/null +++ b/js/display_triggers.js @@ -0,0 +1,67 @@ +$(document).ready(function() { + /** + * Ajax Event handler for 'Drop Trigger' + * + * @uses $.PMA_confirm() + * @uses PMA_ajaxShowMessage() + * @see $cfg['AjaxEnable'] + */ + $(".drop_trigger_anchor").live('click', function(event) { + event.preventDefault(); + + /** + * @var curr_row Object reference to the current trigger's + */ + var $curr_trig_row = $(this).parents('tr'); + /** + * @var question String containing the question to be asked for confirmation + */ + var question = $curr_trig_row.children('td').children('.drop_sql').text(); + + $(this).PMA_confirm(question, $(this).attr('href'), function(url) { + + PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); + + $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#result_query").remove(); + if ($('#trigger_list tr').length == 2) { + $('#trigger_list').remove(); + $('#no_triggers').show(); + } else { + $curr_trig_row.hide("medium").remove(); + } + } + else { + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); + } + }) // end $.get() + }) // end $.PMA_confirm() + }) // end $().live() + + /** + * Ajax Event handler for 'Export Trigger' + * + * @see $cfg['AjaxEnable'] + */ + $('.export_trigger_anchor').live('click', function(event) { + event.preventDefault(); + + /** + * @var button_options Object containing options for jQueryUI dialog buttons + */ + var button_options = {}; + button_options[PMA_messages['strClose']] = function() {$(this).dialog("close").remove();} + /** + * @var button_options The export SQL query to display to the user + */ + var query = $(this).parents('tr').find('.create_sql').html(); + + // show dialog + $('
    ').dialog({ + width: 450, + buttons: button_options + }).find('textarea').width('100%'); + }); // end Export Procedure +}, 'top.frame_content'); //end $(document).ready() for Drop Trigger diff --git a/js/functions.js b/js/functions.js index a5118df9a2..ab4bd7083d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1601,46 +1601,6 @@ $(document).ready(function() { }, 'top.frame_content'); //end $(document).ready for 'Create Table' -/** - * Attach Ajax event handlers for Drop Trigger. Used on tbl_structure.php - * @see $cfg['AjaxEnable'] - */ -$(document).ready(function() { - - $(".drop_trigger_anchor").live('click', function(event) { - event.preventDefault(); - - $anchor = $(this); - /** - * @var curr_row Object reference to the current trigger's - */ - var $curr_row = $anchor.parents('tr'); - /** - * @var question String containing the question to be asked for confirmation - */ - var question = 'DROP TRIGGER IF EXISTS `' + $curr_row.children('td:first').text() + '`'; - - $anchor.PMA_confirm(question, $anchor.attr('href'), function(url) { - - PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); - $.get(url, {'is_js_confirmed': 1, 'ajax_request': true}, function(data) { - if(data.success == true) { - PMA_ajaxShowMessage(data.message); - $("#topmenucontainer") - .next('div') - .remove() - .end() - .after(data.sql_query); - $curr_row.hide("medium").remove(); - } - else { - PMA_ajaxShowMessage(data.error); - } - }) // end $.get() - }) // end $.PMA_confirm() - }) // end $().live() -}, 'top.frame_content'); //end $(document).ready() for Drop Trigger - /** * Attach Ajax event handlers for Drop Database. Moved here from db_structure.js * as it was also required on db_create.php diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e8e6b8a9d0..d75eb27b26 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -3021,6 +3021,8 @@ function PMA_buildActionTitles() { $titles['Empty'] = PMA_getIcon('b_empty.png', __('Empty'), true); $titles['NoEmpty'] = PMA_getIcon('bd_empty.png', __('Empty'), true); $titles['Edit'] = PMA_getIcon('b_edit.png', __('Edit'), true); + $titles['Export'] = PMA_getIcon('b_export.png', __('Export'), true); + $titles['Execute'] = PMA_getIcon('b_execute.png', __('Execute'), true); return $titles; } ?> diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 9735a8212b..43493ec9d1 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -1365,7 +1365,7 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null) } /** - * returns details about the TRIGGERs of a specific table + * returns details about the TRIGGERs for a specific table or database * * @uses PMA_DBI_fetch_result() * @param string $db db name @@ -1374,20 +1374,25 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null) * * @return array information about triggers (may be empty) */ -function PMA_DBI_get_triggers($db, $table, $delimiter = '//') +function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//') { $result = array(); - if (! $GLOBALS['cfg']['Server']['DisableIS']) { - // Note: in http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html - // their example uses WHERE TRIGGER_SCHEMA='dbname' so let's use this - // instead of WHERE EVENT_OBJECT_SCHEMA='dbname' - $triggers = PMA_DBI_fetch_result("SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION, ACTION_TIMING, ACTION_STATEMENT, EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA= '" . PMA_sqlAddslashes($db,true) . "' and EVENT_OBJECT_TABLE = '" . PMA_sqlAddslashes($table, true) . "';"); + // Note: in http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html + // their example uses WHERE TRIGGER_SCHEMA='dbname' so let's use this + // instead of WHERE EVENT_OBJECT_SCHEMA='dbname' + $query = "SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION, EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA= '" . PMA_sqlAddslashes($db,true) . "';"; + if (! empty($table)) { + $query .= " AND EVENT_OBJECT_TABLE = '" . PMA_sqlAddslashes($table, true) . "';"; + } } else { - $triggers = PMA_DBI_fetch_result("SHOW TRIGGERS FROM " . PMA_backquote(PMA_sqlAddslashes($db,true)) . " LIKE '" . PMA_sqlAddslashes($table, true) . "';"); + $query = "SHOW TRIGGERS FROM " . PMA_backquote(PMA_sqlAddslashes($db,true)); + if (! empty($table)) { + $query .= " LIKE '" . PMA_sqlAddslashes($table, true) . "';"; + } } - if ($triggers) { + if ($triggers = PMA_DBI_fetch_result($query)) { foreach ($triggers as $trigger) { if ($GLOBALS['cfg']['Server']['DisableIS']) { $trigger['TRIGGER_NAME'] = $trigger['Trigger']; @@ -1398,6 +1403,7 @@ function PMA_DBI_get_triggers($db, $table, $delimiter = '//') } $one_result = array(); $one_result['name'] = $trigger['TRIGGER_NAME']; + $one_result['table'] = $trigger['EVENT_OBJECT_TABLE']; $one_result['action_timing'] = $trigger['ACTION_TIMING']; $one_result['event_manipulation'] = $trigger['EVENT_MANIPULATION']; diff --git a/libraries/db_events.inc.php b/libraries/db_events.inc.php index 6e93299ac0..888286288f 100644 --- a/libraries/db_events.inc.php +++ b/libraries/db_events.inc.php @@ -10,52 +10,91 @@ if (! defined('PHPMYADMIN')) { $events = PMA_DBI_fetch_result('SELECT EVENT_NAME, EVENT_TYPE FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';'); -if ($events) { - PMA_generate_slider_effect('events', __('Events')); - echo '
    ' . "\n"; - echo ' ' . __('Events') . '' . "\n"; - echo ''; +$conditional_class_add = ''; +$conditional_class_drop = ''; +$conditional_class_export = ''; +if ($GLOBALS['cfg']['AjaxEnable']) { + $conditional_class_add = 'class="add_event_anchor"'; + $conditional_class_drop = 'class="drop_event_anchor"'; + $conditional_class_export = 'class="export_event_anchor"'; +} + +echo '
    ' . "\n"; +echo ' ' . __('Events') . '' . "\n"; +if (! $events) { + echo __('There are no events to display.'); +} else { + echo ''; + echo '
    '; echo sprintf(' + ', __('Name'), __('Type')); $ct=0; $delimiter = '//'; - if ($GLOBALS['cfg']['AjaxEnable']) { - $conditional_class = 'class="drop_event_anchor"'; - } else { - $conditional_class = ''; - } foreach ($events as $event) { // information_schema (at least in MySQL 5.1.22) does not return // the full CREATE EVENT statement in a way that could be useful for us // so we rely on PMA_DBI_get_definition() which uses SHOW CREATE EVENT - $definition = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']) . $delimiter . "\n" - . PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME']) - . "\n"; + $create_event = PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME']); + $definition = 'DROP EVENT IF EXISTS ' . PMA_backquote($event['EVENT_NAME']) + . $delimiter . "\n" . $create_event . "\n"; $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']); echo sprintf(' - + + ', ($ct%2 == 0) ? 'even' : 'odd', + $sqlDrop, $event['EVENT_NAME'], - ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&sql_query=' . urlencode($definition) . '&show_query=1&db_query_force=1&delimiter=' . urlencode($delimiter), $titles['Structure']) : ' ', - '' . $titles['Drop'] . '', + ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&sql_query=' . urlencode($definition) . '&show_query=1&db_query_force=1&delimiter=' . urlencode($delimiter), $titles['Edit']) : ' ', + $create_event, + '' . $titles['Export'] . '', + '' . $titles['Drop'] . '', $event['EVENT_TYPE']); $ct++; } echo '
    %s      %s
    %s%s %s%s %s %s
    '; - echo '
    ' . "\n"; - echo '' . "\n"; } +echo '' . "\n"; + +/** + * Display the state of the event scheduler + * and offer an option to toggle it. + */ +if (! empty($_GET['toggle_scheduler'])) { + $new_scheduler_state = $_GET['toggle_scheduler']; + if ($new_scheduler_state === 'ON' || $new_scheduler_state === 'OFF') { + PMA_DBI_query("SET GLOBAL event_scheduler='$new_scheduler_state'"); + } +} +$es_state = PMA_DBI_fetch_value("SHOW GLOBAL VARIABLES LIKE 'event_scheduler'", 0, 1); +if ($es_state === 'ON' || $es_state === 'OFF') { + $es_change = ($es_state == 'ON') ? 'OFF' : 'ON'; + echo '
    ' . "\n" . PMA_getIcon('b_events.png') . __('The event scheduler is ') . $es_state . ':' + . ' ' + . __('Turn') . " $es_change\n" + . '' . "\n" + . '
    ' . "\n"; +} + +/** + * Display the form for adding a new event + */ +echo '
    ' . "\n" + . ' ' . "\n" + . PMA_getIcon('b_event_add.png') . __('Add a new Event') . '' . "\n" + . '
    ' . "\n"; + ?> diff --git a/libraries/db_links.inc.php b/libraries/db_links.inc.php index 7eaf343a4e..8bbb6a9f57 100644 --- a/libraries/db_links.inc.php +++ b/libraries/db_links.inc.php @@ -93,6 +93,17 @@ if (! $db_is_information_schema) { $tab_privileges['text'] = __('Privileges'); $tab_privileges['icon'] = 's_rights.png'; } + $tab_routines['link'] = 'db_routines.php'; + $tab_routines['text'] = __('Routines'); + $tab_routines['icon'] = 'b_routines.png'; + + $tab_events['link'] = 'db_events.php'; + $tab_events['text'] = __('Events'); + $tab_events['icon'] = 'b_events.png'; + + $tab_triggers['link'] = 'db_triggers.php'; + $tab_triggers['text'] = __('Triggers'); + $tab_triggers['icon'] = 'b_triggers.png'; } /** @@ -110,6 +121,15 @@ if (! $db_is_information_schema) { if ($is_superuser) { $tabs[] =& $tab_privileges; } + if (PMA_MYSQL_INT_VERSION >= 50002) { + $tabs[] =& $tab_routines; + } + if (PMA_MYSQL_INT_VERSION >= 50106) { + $tabs[] =& $tab_events; + } + if (PMA_MYSQL_INT_VERSION >= 50002) { + $tabs[] =& $tab_triggers; + } } if (PMA_Tracker::isActive()) { $tabs[] =& $tab_tracking; diff --git a/libraries/db_routines.inc.php b/libraries/db_routines.inc.php index d6a5b07ac4..708bfdd5d5 100644 --- a/libraries/db_routines.inc.php +++ b/libraries/db_routines.inc.php @@ -18,17 +18,33 @@ if (! defined('PHPMYADMIN')) { exit; } +// $url_query .= '&goto=db_routines.php' . rawurlencode("?db=$db"); + $routines = PMA_DBI_fetch_result('SELECT SPECIFIC_NAME,ROUTINE_NAME,ROUTINE_TYPE,DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';'); -if ($routines) { - PMA_generate_slider_effect('routines', __('Routines')); - echo '
    ' . "\n"; - echo ' ' . __('Routines') . '' . "\n"; - echo ''; +$conditional_class_add = ''; +$conditional_class_drop = ''; +$conditional_class_export = ''; +if ($GLOBALS['cfg']['AjaxEnable']) { + $conditional_class_add = 'class="add_routine_anchor"'; + $conditional_class_drop = 'class="drop_procedure_anchor"'; + $conditional_class_export = 'class="export_procedure_anchor"'; +} + +echo '
    ' . "\n"; +echo ' ' . __('Routines') . '' . "\n"; + +if (! $routines) { + echo __('There are no routines to display.'); +} else { + echo ''; + echo '
    '; echo sprintf(' + + ', @@ -37,12 +53,6 @@ if ($routines) { __('Return type')); $ct=0; $delimiter = '//'; - if ($GLOBALS['cfg']['AjaxEnable']) { - $conditional_class = 'class="drop_procedure_anchor"'; - } else { - $conditional_class = ''; - } - foreach ($routines as $routine) { // information_schema (at least in MySQL 5.0.45) @@ -50,9 +60,9 @@ if ($routines) { // so we rely on PMA_DBI_get_definition() which // uses SHOW CREATE + $create_proc = PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']); $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n" - . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']) - . "\n"; + . $create_proc . "\n"; //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') { // $sqlUseProc = 'CALL ' . $routine['SPECIFIC_NAME'] . '()'; @@ -66,15 +76,16 @@ if ($routines) { a method for running the function*/ //} if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') { - $sqlDropProc = 'DROP PROCEDURE ' . PMA_backquote($routine['SPECIFIC_NAME']); + $sqlDropProc = 'DROP PROCEDURE IF EXISTS ' . PMA_backquote($routine['SPECIFIC_NAME']); } else { - $sqlDropProc = 'DROP FUNCTION ' . PMA_backquote($routine['SPECIFIC_NAME']); + $sqlDropProc = 'DROP FUNCTION IF EXISTS ' . PMA_backquote($routine['SPECIFIC_NAME']); } echo sprintf(' - + + ', @@ -82,13 +93,24 @@ if ($routines) { $sqlDropProc, $routine['ROUTINE_NAME'], ! empty($definition) ? PMA_linkOrButton('db_sql.php?' . $url_query . '&sql_query=' . urlencode($definition) . '&show_query=1&db_query_force=1&delimiter=' . urlencode($delimiter), $titles['Edit']) : ' ', - '' . $titles['Drop'] . '', + ! empty($definition) ? PMA_linkOrButton('#', $titles['Execute']) : ' ', + $create_proc, + '' . $titles['Export'] . '', + '' . $titles['Drop'] . '', $routine['ROUTINE_TYPE'], $routine['DTD_IDENTIFIER']); $ct++; } echo '
    %s       %s %s
    %s%s %s %s%s %s %s
    '; - echo '
    ' . "\n"; - echo '' . "\n"; } +echo '' . "\n"; + +/** + * Display the form for adding a new routine + */ +echo '
    ' . "\n" + . ' ' . "\n" + . PMA_getIcon('b_routine_add.png') . __('Add a new Routine') . '' . "\n" + . '
    ' . "\n"; + ?> diff --git a/libraries/display_triggers.inc.php b/libraries/display_triggers.inc.php new file mode 100644 index 0000000000..e1237d14d8 --- /dev/null +++ b/libraries/display_triggers.inc.php @@ -0,0 +1,87 @@ +' . "\n"; +echo ' ' . __('Triggers') . '' . "\n"; +if (! $triggers) { + echo __('There are no triggers to display.'); +} else { + echo ''; + echo '' . "\n"; + + // Print table header + echo "\n\n"; + if (empty($table)) { + // if we don't have a table name, we will be showing the per-database list. + // so we must specify which table each trigger belongs to + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + + $ct=0; + $delimiter = '//'; + // Print table contents + foreach ($triggers as $trigger) { + $drop_and_create = $trigger['drop'] . $delimiter . "\n" . $trigger['create'] . "\n"; + $row = ($ct%2 == 0) ? 'even' : 'odd'; + $editlink = PMA_linkOrButton('tbl_sql.php?' . $url_query . '&sql_query=' + . urlencode($drop_and_create) . '&show_query=1&delimiter=' . urlencode($delimiter), $titles['Edit']); + $exprlink = '' . $titles['Export'] . ''; + $droplink = '' . $titles['Drop'] . ''; + + echo "\n"; + echo "\n"; + if (empty($table)) { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + $ct++; + } + echo '
    " . __('Name') . "" . __('Table') . "   " . __('Time') . "" . __('Event') . "
    "; + echo "{$trigger['name']}"; + echo $trigger['table'] . "$editlink$exprlink$droplink{$trigger['action_timing']}{$trigger['event_manipulation']}
    '; +} +echo ''; + +/** + * Display the form for adding a new trigger + */ +if (! empty($table)) { + echo '
    ' . "\n" + . ' ' . "\n" + . PMA_getIcon('b_trigger_add.png') . __('Add a new Trigger') . '' . "\n" + . '
    ' . "\n"; +} + +?> diff --git a/libraries/tbl_links.inc.php b/libraries/tbl_links.inc.php index e31dd5305f..1a09a577ee 100644 --- a/libraries/tbl_links.inc.php +++ b/libraries/tbl_links.inc.php @@ -39,6 +39,13 @@ $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); */ require_once './libraries/header.inc.php'; +/** + * Ensure that $db_is_information_schema is not null + */ +if (! isset($db_is_information_schema)) { + $db_is_information_schema = false; +} + /** * Displays links */ @@ -61,7 +68,7 @@ $tabs['search']['icon'] = 'b_search.png'; $tabs['search']['text'] = __('Search'); $tabs['search']['link'] = 'tbl_select.php'; -if (! (isset($db_is_information_schema) && $db_is_information_schema)) { +if (!$db_is_information_schema) { $tabs['insert']['icon'] = 'b_insrow.png'; $tabs['insert']['link'] = 'tbl_change.php'; $tabs['insert']['text'] = __('Insert'); @@ -76,7 +83,7 @@ $tabs['export']['text'] = __('Export'); * Don't display "Import" and "Operations" * for views and information_schema */ -if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) { +if (! $tbl_is_view && !$db_is_information_schema) { $tabs['import']['icon'] = 'b_tblimport.png'; $tabs['import']['link'] = 'tbl_import.php'; $tabs['import']['text'] = __('Import'); @@ -90,13 +97,16 @@ if(PMA_Tracker::isActive()) { $tabs['tracking']['text'] = __('Tracking'); $tabs['tracking']['link'] = 'tbl_tracking.php'; } -if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) { +if (! $db_is_information_schema && PMA_MYSQL_INT_VERSION >= 50002) { + $tabs['triggers']['link'] = 'tbl_triggers.php'; + $tabs['triggers']['text'] = __('Triggers'); + $tabs['triggers']['icon'] = 'b_triggers.png'; } /** * Views support a limited number of operations */ -if ($tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) { +if ($tbl_is_view && !$db_is_information_schema) { $tabs['operation']['icon'] = 'b_tblops.png'; $tabs['operation']['link'] = 'view_operations.php'; $tabs['operation']['text'] = __('Operations'); diff --git a/libraries/tbl_triggers.lib.php b/libraries/tbl_triggers.lib.php deleted file mode 100644 index 0663ef4a99..0000000000 --- a/libraries/tbl_triggers.lib.php +++ /dev/null @@ -1,58 +0,0 @@ -' . "\n"; - echo '' . "\n"; - echo ' ' . "\n"; - echo sprintf(' - - - - - - ', - __('Name'), - __('Time'), - __('Event')); - $ct=0; - $delimiter = '//'; - if ($GLOBALS['cfg']['AjaxEnable']) { - $conditional_class = 'class="drop_trigger_anchor"'; - } else { - $conditional_class = ''; - } - - foreach ($triggers as $trigger) { - $drop_and_create = $trigger['drop'] . $delimiter . "\n" . $trigger['create'] . "\n"; - - echo sprintf(' - - - - - - ', - ($ct%2 == 0) ? 'even' : 'odd', - $trigger['name'], - PMA_linkOrButton('tbl_sql.php?' . $url_query . '&sql_query=' . urlencode($drop_and_create) . '&show_query=1&delimiter=' . urlencode($delimiter), $titles['Change']), - '' . $titles['Drop'] . '', - $trigger['action_timing'], - $trigger['event_manipulation']); - $ct++; - } - echo '
    ' . __('Triggers') . '
    %s  %s%s
    %s%s%s%s%s
    '; - echo '' . "\n"; -} -?> diff --git a/tbl_structure.php b/tbl_structure.php index 9878b9e263..d8597582ee 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -933,8 +933,6 @@ if ($cfg['ShowStats']) { } // END - Calc Table Space -require './libraries/tbl_triggers.lib.php'; - echo '
    ' . "\n"; /** diff --git a/tbl_triggers.php b/tbl_triggers.php new file mode 100644 index 0000000000..a35e99f7f5 --- /dev/null +++ b/tbl_triggers.php @@ -0,0 +1,40 @@ + diff --git a/themes/original/img/b_event_add.png b/themes/original/img/b_event_add.png new file mode 100644 index 0000000000..6940d74beb Binary files /dev/null and b/themes/original/img/b_event_add.png differ diff --git a/themes/original/img/b_events.png b/themes/original/img/b_events.png new file mode 100644 index 0000000000..4564284e39 Binary files /dev/null and b/themes/original/img/b_events.png differ diff --git a/themes/original/img/b_routine_add.png b/themes/original/img/b_routine_add.png new file mode 100644 index 0000000000..95b971948e Binary files /dev/null and b/themes/original/img/b_routine_add.png differ diff --git a/themes/original/img/b_routines.png b/themes/original/img/b_routines.png new file mode 100644 index 0000000000..428b0db73c Binary files /dev/null and b/themes/original/img/b_routines.png differ diff --git a/themes/original/img/b_trigger_add.png b/themes/original/img/b_trigger_add.png new file mode 100644 index 0000000000..5b91c5093d Binary files /dev/null and b/themes/original/img/b_trigger_add.png differ diff --git a/themes/original/img/b_triggers.png b/themes/original/img/b_triggers.png new file mode 100644 index 0000000000..e9025119c1 Binary files /dev/null and b/themes/original/img/b_triggers.png differ diff --git a/themes/pmahomme/img/b_event_add.png b/themes/pmahomme/img/b_event_add.png new file mode 100644 index 0000000000..6940d74beb Binary files /dev/null and b/themes/pmahomme/img/b_event_add.png differ diff --git a/themes/pmahomme/img/b_events.png b/themes/pmahomme/img/b_events.png new file mode 100644 index 0000000000..4564284e39 Binary files /dev/null and b/themes/pmahomme/img/b_events.png differ diff --git a/themes/pmahomme/img/b_execute.png b/themes/pmahomme/img/b_execute.png new file mode 100644 index 0000000000..7d39b2f408 Binary files /dev/null and b/themes/pmahomme/img/b_execute.png differ diff --git a/themes/pmahomme/img/b_routine_add.png b/themes/pmahomme/img/b_routine_add.png new file mode 100644 index 0000000000..95b971948e Binary files /dev/null and b/themes/pmahomme/img/b_routine_add.png differ diff --git a/themes/pmahomme/img/b_routines.png b/themes/pmahomme/img/b_routines.png new file mode 100644 index 0000000000..428b0db73c Binary files /dev/null and b/themes/pmahomme/img/b_routines.png differ diff --git a/themes/pmahomme/img/b_trigger_add.png b/themes/pmahomme/img/b_trigger_add.png new file mode 100644 index 0000000000..5b91c5093d Binary files /dev/null and b/themes/pmahomme/img/b_trigger_add.png differ diff --git a/themes/pmahomme/img/b_triggers.png b/themes/pmahomme/img/b_triggers.png new file mode 100644 index 0000000000..e9025119c1 Binary files /dev/null and b/themes/pmahomme/img/b_triggers.png differ