function tripal_custom_tables_action
1.x custom_tables.inc | tripal_custom_tables_action($op, $table_id, $redirect = FALSE) |
Does the specified action for the specified custom table
Parameters
$op: The action to be taken. Currenly only delete is available
$table_id: The unique ID of the custom table for the action to be performed on
$redirect: TRUE/FALSE depending on whether you want to redirect the user to admin/tripal/custom_tables
Related topics
1 string reference to 'tripal_custom_tables_action'
- tripal_core_menu in tripal_core/
tripal_core.module - Implements hook_menu(). Defines all menu items needed by Tripal Core
File
- tripal_core/
includes/ custom_tables.inc, line 338 - Contains functions for creating, editing and deleting custom tables on the Tripal website.
Code
function tripal_custom_tables_action($op, $table_id, $redirect = FALSE) {
global $user;
$args = array("$table_id");
if (!$table_id) {
return '';
}
// get this table details
$sql = "SELECT * FROM {tripal_custom_tables} WHERE table_id = %d";
$custom_table = db_fetch_object(db_query($sql, $table_id));
if ($op == 'delete') {
// remove the entry from the tripal_custom tables table
$sql = "DELETE FROM {tripal_custom_tables} " .
"WHERE table_id = $table_id";
db_query($sql);
// drop the table from chado if it exists
if (db_table_exists($custom_table->table_name)) {
$success = chado_query("DROP TABLE %s", $custom_table->table_name);
if ($success) {
drupal_set_message(t("Custom Table '%name' dropped", array('%name' => $custom_table->table_name)));
}
}
}
// Redirect the user
if ($redirect) {
drupal_goto("admin/tripal/custom_tables");
}
}