[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/schema/ -> schema.install (source)

   1  <?php
   2  
   3  /**
   4   * Implementation of hook_requirements().
   5   * Checks installation requirements and do status reporting.
   6   * @param phase 'install': ignored (no installation requirements)
   7   *              'runtime': status reporting for database
   8   * @return A keyed array of requirements
   9   * @see schema_compare_schemas()
  10   */
  11  function schema_requirements($phase) {
  12    $reqs = array();
  13    $t = get_t();
  14    if ($phase == 'runtime' && variable_get('schema_status_report', TRUE)) {
  15      $schema = drupal_get_schema(NULL, TRUE);
  16      $info = schema_compare_schemas($schema);
  17      // make sure these are defined in increasing-severity order
  18      $checks = array(
  19        'same' => array(REQUIREMENT_OK, 'Consistent', '@count modules with matching tables'),
  20        'extra' => array(REQUIREMENT_OK, 'Extra tables', '@count extra tables'),
  21        'warn' => array(REQUIREMENT_WARNING, 'Warning', '@count warnings'),
  22        'missing' => array(REQUIREMENT_ERROR, 'Inconsistent', '@count module with missing tables'),
  23        'different' => array(REQUIREMENT_ERROR, 'Inconsistent', '@count module with mis-matching tables'),
  24        );
  25  
  26      $notes = array();
  27      $severity = REQUIREMENT_OK;
  28      foreach ($checks as $key => $data) {
  29        if (!empty($info[$key])) {
  30          $severity = $data[0];
  31          $status = $data[1];
  32          $notes[] = $t($data[2], array('@count' => count($info[$key])));
  33        }
  34      }
  35      $desc = ''; // if there is only one note, it is for 'same'
  36      if (count($notes) > 1) {
  37        $desc = $t('The Schema comparison report shows: ') . theme('item_list', $notes);
  38      }
  39      if ($severity != REQUIREMENT_OK) {
  40        $sys_reqs = system_requirements($phase);
  41        if ($sys_reqs['update']['severity'] != REQUIREMENT_OK) {
  42          $desc .= $t('You should follow the instructions under <strong>@title</strong> now or run the <a href="@compare">database schema comparison report</a> for more details.', array('@title' => $sys_reqs['update']['title'], '@compare' => url('admin/build/schema/compare')));
  43        } else {
  44          $desc .= $t('The <a href="@compare">database schema comparison report</a> provides more details.', array('@compare' => url('admin/build/schema/compare')));
  45        }
  46      }
  47      $reqs['schema'] = array(
  48        'title' => $t('Database schema'),
  49        'value' => $status,
  50        'severity' => $severity,
  51        'description' => $desc,
  52        );
  53    }
  54  
  55    return $reqs;
  56  }
  57  
  58  /**
  59   * Implementation of hook_uninstall(),
  60   */
  61  function schema_uninstall() {
  62    variable_del('schema_status_report');
  63    variable_del('schema_suppress_type_warnings');
  64  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7