getTriggers($db, $table);
echo RteList::get('trigger', $items);
/**
* Display a link for adding a new trigger,
* if the user has the necessary privileges
*/
echo Footer::triggers();
} // end self::main()
/**
* Handles editor requests for adding or editing an item
*
* @return void
*/
public static function handleEditor()
{
global $_REQUEST, $_POST, $errors, $db, $table;
if (! empty($_POST['editor_process_add'])
|| ! empty($_POST['editor_process_edit'])
) {
$sql_query = '';
$item_query = self::getQueryFromRequest();
if (! count($errors)) { // set by PhpMyAdmin\Rte\Routines::getQueryFromRequest()
// Execute the created query
if (! empty($_POST['editor_process_edit'])) {
// Backup the old trigger, in case something goes wrong
$trigger = self::getDataFromName($_POST['item_original_name']);
$create_item = $trigger['create'];
$drop_item = $trigger['drop'] . ';';
$result = $GLOBALS['dbi']->tryQuery($drop_item);
if (! $result) {
$errors[] = sprintf(
__('The following query has failed: "%s"'),
htmlspecialchars($drop_item)
)
. '
'
. __('MySQL said: ') . $GLOBALS['dbi']->getError();
} 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();
// 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 = General::checkResult(
$result,
__(
'Sorry, we failed to restore the dropped trigger.'
),
$create_item,
$errors
);
} else {
$message = Message::success(
__('Trigger %1$s has been modified.')
);
$message->addParam(
Util::backquote($_POST['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();
} else {
$message = Message::success(
__('Trigger %1$s has been created.')
);
$message->addParam(
Util::backquote($_POST['item_name'])
);
$sql_query = $item_query;
}
}
}
if (count($errors)) {
$message = Message::error(
''
. __(
'One or more errors have occurred while processing your request:'
)
. ''
);
$message->addHtml('