You are here

function textimage_uninstall in Textimage 7.3

Same name and namespace in other branches
  1. 8.4 textimage.install \textimage_uninstall()
  2. 8.3 textimage.install \textimage_uninstall()
  3. 5.2 textimage.install \textimage_uninstall()
  4. 5 textimage.install \textimage_uninstall()
  5. 6.2 textimage.install \textimage_uninstall()
  6. 7.2 textimage.install \textimage_uninstall()

Implements hook_uninstall().

File

./textimage.install, line 181
Textimage - Installation scripts.

Code

function textimage_uninstall() {

  // Delete the textimage directory from each registered wrapper.
  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
  foreach ($wrappers as $wrapper => $wrapper_data) {
    file_unmanaged_delete_recursive($wrapper . '://textimage');
  }

  // Remove database fields required by Textimage.
  $table_fields = _textimage_define_table_fields();
  foreach ($table_fields as $table_name => $fields) {
    foreach ($fields as $field_name => $field) {
      if (db_field_exists($table_name, $field_name)) {
        db_drop_field($table_name, $field_name);
      }
    }
  }

  // Remove all variables whose name begins with 'textimage'.
  $res = db_select('variable', 'v')
    ->fields('v')
    ->condition('name', 'textimage%', 'LIKE')
    ->execute();
  if ($res) {
    foreach ($res as $row) {
      variable_del($row->name);
      drupal_set_message(t('Variable %var has been deleted.', array(
        '%var' => $row->name,
      )));
    }
  }
}