You are here

function node_gallery_requirements in Node Gallery 6.3

Same name and namespace in other branches
  1. 6.2 node_gallery.install \node_gallery_requirements()

Implementation of hook_requirements().

Parameters

$phase The phase in which hook_requirements is run: install or runtime.:

File

./node_gallery.install, line 255
Install, update and uninstall functions for the node_gallery module.

Code

function node_gallery_requirements($phase) {

  // @todo: the rest of this .install file should use $t = get_t()
  $t = get_t();
  $requirements['node_gallery'] = array();
  if (module_exists('node_images')) {
    $requirements['node_gallery'][] = array(
      'title' => 'Node Gallery',
      'value' => 'Node Images module installed',
      'description' => $t('The Node Images module is installed, and it conflicts with Node Gallery.  Please disable it via the <a href="!link">modules page</a>.', array(
        '!link' => url('admin/build/modules'),
      )),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  $lb2dir = drupal_get_path('module', 'node_gallery') . '/contrib/node_gallery_lightbox2';
  if (module_exists('node_gallery_lightbox2') || is_dir($lb2dir)) {
    $requirements['node_gallery'][] = array(
      'title' => 'Node Gallery',
      'value' => 'Node Gallery Lightbox2 module installed',
      'description' => $t('The Node Gallery Lightbox2 module is available, and it has been removed with the release of Node Gallery version 3.  Please <a href="!link">follow the directions given on Drupal.org</a> regarding module upgrading.', array(
        '!link' => 'http://drupal.org/node/250790',
      )),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  switch ($phase) {
    case 'runtime':
      if (module_exists('og')) {
        $modules = module_list();
        $ng_last = FALSE;
        while ($module = array_shift($modules)) {
          if ($module == 'node_gallery') {
            break;
          }
          elseif ($module == 'og') {
            $ng_last = TRUE;
            break;
          }
        }
        if (!$ng_last) {
          $requirements['node_gallery'][] = array(
            'title' => 'Node Gallery',
            'value' => 'Node Gallery has a lighter weight than OG',
            'description' => $t('Many of the breadcrumb features in Node Gallery when used with OG depend on Node Gallery having a module weight greater than OG.  If you are using Node Gallery content types as standard group posts in OG, the breadcrumbs on image node pages may not look right.  To fix them, please <a href="!link">adjust the module weights</a> so that this message no longer appears.', array(
              '!link' => 'http://drupal.org/node/110238',
            )),
            'severity' => REQUIREMENT_INFO,
          );
        }
      }
      if (module_exists('imageapi') && !module_exists('imageapi_gd') && !module_exists('imageapi_imagemagick')) {
        $requirements['node_gallery'][] = array(
          'title' => 'Node Gallery',
          'value' => 'Image toolkit not installed',
          'description' => $t('Image API requires that an image toolkit be enabled before it will work! Please enable an image toolkit on the <a href="!link">modules page</a>.', array(
            '!link' => url('admin/build/modules'),
          )),
          'severity' => REQUIREMENT_ERROR,
        );
      }
      break;
    default:
      break;
  }
  return $requirements['node_gallery'];
}