You are here

function backup_migrate_destination_filesource::check_libs in Backup and Migrate 6.3

Same name and namespace in other branches
  1. 8.3 includes/sources.filesource.inc \backup_migrate_destination_filesource::check_libs()
  2. 7.3 includes/sources.filesource.inc \backup_migrate_destination_filesource::check_libs()

Check that the required libraries are installed.

4 calls to backup_migrate_destination_filesource::check_libs()
backup_migrate_destination_filesource::_backup_to_file_php in includes/sources.filesource.inc
Backup from this source.
backup_migrate_destination_filesource::_restore_from_file_php in includes/sources.filesource.inc
Restore to this source.
backup_migrate_files_destination_archivesource::_backup_to_file_php in includes/sources.archivesource.inc
Backup from this source.
backup_migrate_files_destination_archivesource::_restore_from_file_php in includes/sources.archivesource.inc
Restore to this source.

File

includes/sources.filesource.inc, line 268
A destination type for saving locally to the server.

Class

backup_migrate_destination_filesource
A destination type for saving locally to the server.

Code

function check_libs() {
  $result = true;

  // Extend inlcude path with path to this module's includes directory.
  $includes_directory = './' . drupal_get_path('module', 'backup_migrate_files') . '/includes';
  $include_path_old = set_include_path($includes_directory . ';' . get_include_path());

  // Check if PEAR.php is present in a non-fatal way and error gracefully if it isn't.
  include_once 'PEAR.php';
  if (!class_exists('PEAR')) {
    _backup_migrate_message('PEAR is not installed correctly. See the README.txt file in the backup_migrate_files module directory for help.', array(), 'error');
    $result = false;
  }

  // Check if Tar.php is present in a non-fatal way and error gracefully if it isn't.
  if ($result) {

    // Try to get version in this module's includes directory first, but prevent warning texts being output.
    if (file_exists($includes_directory . '/Tar.php')) {
      include_once $includes_directory . '/Tar.php';
    }
    if (!class_exists('Archive_Tar')) {

      // Try to get via PEAR directory structure.
      include_once 'Archive/Tar.php';
      if (!class_exists('Archive_Tar')) {
        _backup_migrate_message('Archive_Tar is not installed correctly. See the README.txt file in the backup_migrate_files module directory for help.', array(), 'error');
        $result = false;
      }
    }
  }

  // Restore include path.
  set_include_path($include_path_old);
  return $result;
}