You are here

function ctools_export_crud_delete in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/export.inc \ctools_export_crud_delete()

Delete a single exportable object.

This only deletes from the database, which means that if an item is in code, then this is actually a revert.

Parameters

$table: The name of the table to use to retrieve $schema values. This table must have an 'export' section containing data or this function will fail.

$object: The fully populated object to delete, or the export key.

Related topics

2 calls to ctools_export_crud_delete()
ctools_export_ui::delete_page in plugins/export_ui/ctools_export_ui.class.php
Page callback to delete an exportable item.
ctools_export_ui::edit_wizard_finish in plugins/export_ui/ctools_export_ui.class.php
Wizard 'cancel' callback when using a wizard to edit an item.

File

includes/export.inc, line 177
Contains code to make it easier to have exportable objects.

Code

function ctools_export_crud_delete($table, $object) {
  $schema = ctools_export_get_schema($table);
  $export = $schema['export'];
  if (!empty($export['delete callback']) && function_exists($export['delete callback'])) {
    return $export['delete callback']($object);
  }
  else {

    // If we were sent an object, get the export key from it. Otherwise
    // assume we were sent the export key.
    $value = is_object($object) ? $object->{$export['key']} : $object;
    db_query("DELETE FROM {" . $table . "} WHERE " . $export['key'] . " = '%s'", $value);
  }
}