diff --git a/db_events.php b/db_events.php
index 606b5d22fe..e13935fc68 100644
--- a/db_events.php
+++ b/db_events.php
@@ -11,11 +11,6 @@
*/
require_once 'libraries/common.inc.php';
-/**
- * Include all other files
- */
-require_once 'libraries/rte/rte_events.lib.php';
-
/**
* Do the magic
*/
diff --git a/libraries/classes/Rte/Events.php b/libraries/classes/Rte/Events.php
new file mode 100644
index 0000000000..b88ce3a9f5
--- /dev/null
+++ b/libraries/classes/Rte/Events.php
@@ -0,0 +1,622 @@
+ array('ENABLE',
+ 'DISABLE',
+ 'DISABLE ON SLAVE'),
+ 'display' => array('ENABLED',
+ 'DISABLED',
+ 'SLAVESIDE_DISABLED')
+ );
+ $event_type = array('RECURRING',
+ 'ONE TIME');
+ $event_interval = array('YEAR',
+ 'QUARTER',
+ 'MONTH',
+ 'DAY',
+ 'HOUR',
+ 'MINUTE',
+ 'WEEK',
+ 'SECOND',
+ 'YEAR_MONTH',
+ 'DAY_HOUR',
+ 'DAY_MINUTE',
+ 'DAY_SECOND',
+ 'HOUR_MINUTE',
+ 'HOUR_SECOND',
+ 'MINUTE_SECOND');
+ }
+
+ /**
+ * Main function for the events functionality
+ *
+ * @return void
+ */
+ public static function main()
+ {
+ global $db;
+
+ self::setGlobals();
+ /**
+ * Process all requests
+ */
+ self::handleEditor();
+ PMA_EVN_handleExport();
+ /**
+ * Display a list of available events
+ */
+ $items = $GLOBALS['dbi']->getEvents($db);
+ echo PMA_RTE_getList('event', $items);
+ /**
+ * Display a link for adding a new event, if
+ * the user has the privileges and a link to
+ * toggle the state of the event scheduler.
+ */
+ echo PMA_EVN_getFooterLinks();
+ } // end self::main()
+
+ /**
+ * Handles editor requests for adding or editing an item
+ *
+ * @return void
+ */
+ public static function handleEditor()
+ {
+ global $_REQUEST, $_POST, $errors, $db;
+
+ if (! empty($_REQUEST['editor_process_add'])
+ || ! empty($_REQUEST['editor_process_edit'])
+ ) {
+ $sql_query = '';
+
+ $item_query = self::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 = $GLOBALS['dbi']->getDefinition(
+ $db,
+ 'EVENT',
+ $_REQUEST['item_original_name']
+ );
+ $drop_item = "DROP EVENT "
+ . Util::backquote($_REQUEST['item_original_name'])
+ . ";\n";
+ $result = $GLOBALS['dbi']->tryQuery($drop_item);
+ if (! $result) {
+ $errors[] = sprintf(
+ __('The following query has failed: "%s"'),
+ htmlspecialchars($drop_item)
+ )
+ . '
'
+ . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
+ } else {
+ $result = $GLOBALS['dbi']->tryQuery($item_query);
+ if (! $result) {
+ $errors[] = sprintf(
+ __('The following query has failed: "%s"'),
+ htmlspecialchars($item_query)
+ )
+ . '
'
+ . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
+ // We dropped the old item, but were unable to create
+ // the new one. Try to restore the backup query
+ $result = $GLOBALS['dbi']->tryQuery($create_item);
+ $errors = checkResult(
+ $result,
+ __(
+ 'Sorry, we failed to restore the dropped event.'
+ ),
+ $create_item,
+ $errors
+ );
+ } else {
+ $message = Message::success(
+ __('Event %1$s has been modified.')
+ );
+ $message->addParam(
+ Util::backquote($_REQUEST['item_name'])
+ );
+ $sql_query = $drop_item . $item_query;
+ }
+ }
+ } else {
+ // 'Add a new item' mode
+ $result = $GLOBALS['dbi']->tryQuery($item_query);
+ if (! $result) {
+ $errors[] = sprintf(
+ __('The following query has failed: "%s"'),
+ htmlspecialchars($item_query)
+ )
+ . '
'
+ . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
+ } else {
+ $message = Message::success(
+ __('Event %1$s has been created.')
+ );
+ $message->addParam(
+ Util::backquote($_REQUEST['item_name'])
+ );
+ $sql_query = $item_query;
+ }
+ }
+ }
+
+ if (count($errors)) {
+ $message = Message::error(
+ ''
+ . __(
+ 'One or more errors have occurred while processing your request:'
+ )
+ . ''
+ );
+ $message->addHtml('