You are here

function forum_access_update_6106 in Forum Access 6

Same name and namespace in other branches
  1. 7 forum_access.install \forum_access_update_6106()

Change our {acl} table records from 'name' to 'number'.

File

./forum_access.install, line 293
Install, update and uninstall functions for the forum_access module.

Code

function forum_access_update_6106() {
  $acl_version = db_result(db_query("SELECT schema_version FROM {system} WHERE type = 'module' AND name = 'acl'"));
  if ($acl_version < 6002) {
    $ret[] = array(
      'success' => FALSE,
      'query' => t('Please update the !ACL module (%version) to version !link or later first!', array(
        '!ACL' => l('ACL', 'http://drupal.org/project/acl'),
        '%version' => $acl_version,
        '!link' => l('6.x-1.3', 'http://drupal.org/node/1017698'),
      )),
    );
    $ret['#abort'] = array(
      'success' => FALSE,
      'query' => t('Some updates are still pending.<br/>Please re-run the update script.'),
    );
    return $ret;
  }
  switch ($GLOBALS['db_type']) {
    case 'pgsql':
      $ret[] = update_sql("UPDATE {acl} SET number = CAST(name AS INTEGER) WHERE module = 'forum_access' AND name IS NOT NULL");
      break;
    default:
      $ret[] = update_sql("UPDATE {acl} SET number = name WHERE module = 'forum_access' AND name IS NOT NULL");
  }
  if ($ret[0]['success']) {
    $ret[] = update_sql("UPDATE {acl} SET name = NULL WHERE module = 'forum_access' AND number IS NOT NULL");
  }
  return $ret;
}