You are here

function classified_requirements in Classified Ads 7.3

Same name and namespace in other branches
  1. 6.3 classified.install \classified_requirements()

Implements hook_requirements().

File

./classified.install, line 123
Install file for the Classified Ads module.

Code

function classified_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if (module_exists('ed_classified')) {
    $requirements['ed_classified'] = array(
      'title' => $t('Classified is incompatible with ed_classified'),
      'value' => $t('Module conflict'),
      'description' => $t('The "Classified" module is a fork/rewrite of ed_classified and is incompatible with it.'),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  if (!module_exists('statistics')) {
    $requirements['statistics'] = array(
      'title' => $t('Classified is enhanced by Statistics'),
      'value' => NULL,
      'description' => $t('The "Classified" module can only provide its "popular" block if statistics.module is enabled'),
      'severity' => REQUIREMENT_INFO,
    );
  }
  elseif (variable_get('statistics_count_content_views', 0) == 0) {
    $requirements['statistics'] = array(
      'title' => $t('Classified "popular ads" block needs content views counted'),
      'value' => NULL,
      'description' => $t('The "Popular Ads" block can only provide valida data if content views are counted. <a href="!link">Enable "Count content views"</a>.', array(
        '!link' => url('admin/config/system/statistics'),
      )),
      'severity' => REQUIREMENT_INFO,
    );
  }
  if ($phase == 'runtime') {
    $vid = _classified_get('vid');
    $vocabulary = taxonomy_vocabulary_load($vid);
    switch ($vocabulary->hierarchy) {
      case 0:
        $requirements['hierarchy'] = array(
          'title' => $t('Classified Ads vocabulary'),
          'value' => $t('No hierarchy'),
          'description' => $t('All ad categories are at the same level. In most cases, you should set up a hierarchy of terms to classify ads.'),
          'severity' => REQUIREMENT_WARNING,
        );
        break;
      case 1:

        // All OK: nothing to add.
        $requirements['hierarchy'] = array(
          'title' => $t('Classified Ads vocabulary'),
          'value' => $t('The terms in the Classified Ads vocabulary are set up in a tree hierarchy.'),
          'severity' => REQUIREMENT_OK,
        );
        break;
      default:
        $requirements['hierarchy'] = array(
          'title' => $t('Classified Ads vocabulary'),
          'value' => $t('Maximum parents per term: @count', array(
            '@count' => $vocabulary->hierarchy,
          )),
          'description' => $t('The Classified Ads module does not support non-tree term hierarchies. Make sure each term has at most one parent.'),
          'severity' => REQUIREMENT_ERROR,
        );
        break;
    }
  }
  return $requirements;
}