You are here

function user_delete_backup in User Delete 6

Same name and namespace in other branches
  1. 5 user_delete.module \user_delete_backup()

Backup an user/node/comment object to the filesystem

1 call to user_delete_backup()
user_delete_submit in ./user_delete.module
Deal with the user/content after form submission
5 string references to 'user_delete_backup'
UserDeleteTest::testUserDeleteAdminInterface in ./user_delete.test
Check admin inteface has not changed and settings ar stored.
user_delete_form_alter in ./user_delete.module
Implementation of hook_form_alter().
user_delete_settings in ./user_delete.admin.inc
Administrative settings page
user_delete_submit in ./user_delete.module
Deal with the user/content after form submission
user_delete_uninstall in ./user_delete.install
Implementation of hook_uninstall().

File

./user_delete.module, line 241
User delete - Let users delete their own account.

Code

function user_delete_backup($account, $object = NULL) {

  // check for directory
  $dir = USER_DELETE_FILE_PATH;
  user_delete_file_check_directory($dir, TRUE);
  file_check_directory($dir, TRUE);
  $backup_dir = $dir . '/' . check_plain($account->name);
  user_delete_file_check_directory($backup_dir, TRUE);
  if (is_numeric($object->cid)) {
    $dest = $backup_dir . '/comments';
    user_delete_file_check_directory($dest, TRUE);
    $dest = $dest . '/comment-' . $object->cid . '.txt';
  }
  elseif (is_numeric($object->nid)) {
    $dest = $backup_dir . '/nodes';
    user_delete_file_check_directory($dest, TRUE);
    $dest = $dest . '/node-' . $object->nid . '.txt';
  }
  else {
    $dest = $backup_dir;
    $object = $account;
    user_delete_file_check_directory($dest, TRUE);
    $dest = $dest . '/user-' . $object->uid . '.txt';
  }
  $data = serialize((array) $object);
  file_save_data($data, $dest, FILE_EXISTS_REPLACE);
}