You are here

public function CampaignMonitor::getLibraryPath in Campaign Monitor 7

Tries to find the path of the Campaign Monitor API library path.

If the library is not found an error message is set and FALSE is returned.

Return value

string|bool Either a string containing the library path or FALSE if the library is not found.

2 calls to CampaignMonitor::getLibraryPath()
CampaignMonitor::libraryLoad in lib/campaignmonitor.class.inc
Helper function that loads the part of the API.
CampaignMonitor::__construct in lib/campaignmonitor.class.inc
Private class constructor.

File

lib/campaignmonitor.class.inc, line 175
Implementation of the CampaignMonitor class.

Class

CampaignMonitor
Implementation of the CampaignMonitor class.

Code

public function getLibraryPath() {
  if (!$this->libraryPath) {
    $setting = variable_get('campaignmonitor_general', []);

    // Uses library module to detect the library.
    if (module_exists('libraries')) {
      $libraries = libraries_get_libraries();
      if (isset($libraries['campaignmonitor'])) {
        $this->libraryPath = $libraries['campaignmonitor'];
      }
    }

    // If the library was not found, try to use the defined path.
    if (!$this->libraryPath) {
      if (isset($setting['library_path']) && !empty($setting['library_path'])) {

        // User has defined the library path.
        if (file_exists($setting['library_path'])) {
          $this->libraryPath = $setting['library_path'];
        }
      }
    }
  }
  if (!$this->libraryPath) {
    drupal_set_message(t('The Campaign Monitor PHP integration library was not detected, please see the README for information about installing the library.'), 'error', FALSE);
  }
  return $this->libraryPath;
}