You are here

function swiftmailer_validate_library in Swift Mailer 7

Validates whether the Swift Mailer library is available at the provided path.

Parameters

string $path: The path to the base directory of the Swift Mailer library

Return value

mixed The provided path exluding leading and trailing slashes if the Swift Mailer library is available at the provided path, and otherwise FALSE.

6 calls to swiftmailer_validate_library()
swiftmailer_admin_default_form in includes/pages/swiftmailer_admin_default.inc
Form builder; the default form.
swiftmailer_admin_default_form_submit in includes/pages/swiftmailer_admin_default.inc
Form submission handler for swiftmailer_admin_default_form().
swiftmailer_admin_default_form_validate in includes/pages/swiftmailer_admin_default.inc
Form validation handler for swiftmailer_admin_default_form().
swiftmailer_admin_messages_form in includes/pages/swiftmailer_admin_messages.inc
Form builder; the messages form.
swiftmailer_admin_test_form in includes/pages/swiftmailer_admin_test.inc
Form builder; the messages form.

... See full list

File

includes/helpers/utilities.inc, line 17
This file contains general utility functions.

Code

function swiftmailer_validate_library($path) {

  // Remove leading slashes.
  while (drupal_substr($path, 0, 1) === '/') {
    $path = drupal_substr($path, 1);
  }

  // Remove trailing slashes.
  while (drupal_substr($path, -1) === '/') {
    $path = drupal_substr($path, 0, -1);
  }

  // Get the real path of the 'swift_required.php' file.
  $real_path = DRUPAL_ROOT . '/' . $path . '/lib/swift_required.php';

  // Returns whether the 'swift_required.php' file could be found.
  if (file_exists($real_path)) {
    return $path;
  }
  else {
    return FALSE;
  }
}