You are here

function resource_enable in D7 Media 6

File

resource/resource.install, line 12

Code

function resource_enable() {
  $path = file_directory_path();
  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
    $scheme = 'public:';
  }
  else {
    $scheme = 'private:';
  }

  //db_query('INSERT INTO {file_backup} SELECT * FROM {files}');

  //db_query('DELETE FROM {files}');
  db_query("\n    INSERT INTO {resource} (rid, uid, name, url, mimetype, size, status, timestamp)\n       SELECT\n          fid, uid, filename, REPLACE(filepath, '%s', '%s'), filemime, filesize, status, timestamp\n       FROM {files}\n  ", $path, $scheme);
}