You are here

function patterns_revert in Patterns 5

Menu callback to undo a patterns update changes

1 string reference to 'patterns_revert'
patterns_menu in ./patterns.module
Implementation of hook_menu().

File

./patterns.module, line 347
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_revert($pid) {
  if ($name = db_result(db_query('SELECT name FROM {patterns} WHERE pid = "%d"', $pid))) {
    $path = file_create_path(variable_get('patterns_save_xml', 'patterns') . '/enabled/' . $name . '.xml');
    $new = db_result(db_query('SELECT file FROM {patterns} WHERE pid = "%d"'));
  }
  else {
    drupal_set_message(t('The pattern you specified does not exist.'), 'error');
    drupal_goto('admin/build/patterns');
  }
  if (file_exists($path)) {
    if (file_move($path, $new, FILE_EXISTS_REPLACE)) {
      drupal_set_message(t('This pattern was reverted to the state it was at when it was enabled.'));
      drupal_goto();
    }
  }
  else {
    drupal_set_message(t('The patterns enabled-state was not saved properly, therefore it cannot be reverted.'), 'error');
  }
  drupal_goto('admin/build/patterns');
}