diff --git a/db_events.php b/db_events.php
index 3bd6a05b05..92454807ed 100644
--- a/db_events.php
+++ b/db_events.php
@@ -16,7 +16,9 @@ require_once './libraries/common.lib.php';
* Include JavaScript libraries
*/
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
+$GLOBALS['js_include'][] = 'jquery/timepicker.js';
$GLOBALS['js_include'][] = 'db_events.js';
+$GLOBALS['js_include'][] = 'db_routines.js'; // FIXME
/**
* Include all other files
diff --git a/js/db_routines.js b/js/db_routines.js
index 4491df9713..3d1812b01d 100644
--- a/js/db_routines.js
+++ b/js/db_routines.js
@@ -479,6 +479,16 @@ $(document).ready(function() {
$('.routine_return_row, .routine_direction_cell').toggle();
}); // end $.live()
+ /**
+ * Attach Ajax event handlers for the "Change event type" functionality.
+ *
+ * @see $cfg['AjaxEnable']
+ * TODO: merge with above
+ */
+ $('select[name=item_type]').live('change', function() {
+ $('.recurring_event_row, .onetime_event_row').toggle();
+ }); // end $.live()
+
/**
* Attach Ajax event handlers for the "Change parameter type" functionality.
*
diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php
index cf6046791d..d54805af7d 100644
--- a/libraries/rte/rte_events.lib.php
+++ b/libraries/rte/rte_events.lib.php
@@ -8,7 +8,7 @@ if (! defined('PHPMYADMIN')) {
}
/**
- * Main function for the routines functionality
+ * Main function for the events functionality
*/
function PMA_EVN_main()
{
@@ -18,10 +18,11 @@ function PMA_EVN_main()
* Here we define some data that will be used to create the list events
*/
$human_name = __('event');
- $columns = "`EVENT_NAME`, `EVENT_TYPE`";
+ $columns = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`";
$where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "'";
$items = PMA_DBI_fetch_result("SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where ORDER BY `EVENT_NAME` ASC;");
$cols = array(array('label' => __('Name'), 'colspan' => 1, 'field' => 'name'),
+ array('label' => __('Status'), 'colspan' => 1, 'field' => 'status'),
array('label' => __('Action'), 'colspan' => 3, 'field' => 'edit'),
array( 'field' => 'export'),
array( 'field' => 'drop'),
@@ -33,6 +34,7 @@ function PMA_EVN_main()
/**
* Process all requests
*/
+ PMA_EVN_handleEditor();
PMA_EVN_handleExport();
/**
* Display a list of available events
@@ -46,4 +48,449 @@ function PMA_EVN_main()
echo PMA_EVN_getFooterLinks();
} // end PMA_EVN_main()
+function PMA_EVN_handleEditor()
+{
+ global $_REQUEST, $_POST, $errors, $db, $table;
+
+ if (! empty($_REQUEST['editor_process_add']) || ! empty($_REQUEST['editor_process_edit'])) {
+ $sql_query = '';
+
+ $item_query = PMA_EVN_getQueryFromRequest();
+
+ if (! count($errors)) { // set by PMA_RTN_getQueryFromRequest()
+ // Execute the created query
+ if (! empty($_REQUEST['editor_process_edit'])) {
+ // Backup the old trigger, in case something goes wrong
+ $create_item = PMA_DBI_get_definition($db, 'EVENT', $_REQUEST['item_original_name']);
+ $drop_item = "DROP EVENT " . PMA_backquote($_REQUEST['item_original_name']) . ";\n";
+ $result = PMA_DBI_try_query($drop_item);
+ if (! $result) {
+ $errors[] = sprintf(__('The following query has failed: "%s"'), $drop_item) . '
'
+ . __('MySQL said: ') . PMA_DBI_getError(null);
+ } else {
+ $result = PMA_DBI_try_query($item_query);
+ if (! $result) {
+ $errors[] = sprintf(__('The following query has failed: "%s"'), $item_query) . '
'
+ . __('MySQL said: ') . PMA_DBI_getError(null);
+ // We dropped the old item, but were unable to create the new one
+ // Try to restore the backup query
+ $result = PMA_DBI_try_query($create_item);
+ if (! $result) {
+ // OMG, this is really bad! We dropped the query, failed to create a new one
+ // and now even the backup query does not execute!
+ // This should not happen, but we better handle this just in case.
+ $errors[] = __('Sorry, we failed to restore the dropped event.') . '
'
+ . __('The backed up query was:') . "\"$create_item\"" . '
'
+ . __('MySQL said: ') . PMA_DBI_getError(null);
+ }
+ } else {
+ $message = PMA_Message::success(__('Event %1$s has been modified.'));
+ $message->addParam(PMA_backquote($_REQUEST['item_name']));
+ $sql_query = $drop_item . $item_query;
+ }
+ }
+ } else {
+ // 'Add a new item' mode
+ $result = PMA_DBI_try_query($item_query);
+ if (! $result) {
+ $errors[] = sprintf(__('The following query has failed: "%s"'), $item_query) . '
'
+ . __('MySQL said: ') . PMA_DBI_getError(null);
+ } else {
+ $message = PMA_Message::success(__('Event %1$s has been created.'));
+ $message->addParam(PMA_backquote($_REQUEST['item_name']));
+ $sql_query = $item_query;
+ }
+ }
+ }
+
+ if (count($errors)) {
+ $message = PMA_Message::error(__('One or more errors have occured while processing your request:'));
+ $message->addString('