You are here

function translation_overview_update_6002 in Translation Overview 6.2

Store the manager information in permissions rather than our own variable.

File

./translation_overview.install, line 130

Code

function translation_overview_update_6002() {
  $ret = array();
  $changes = array();
  foreach (variable_get('translation_overview_management', array()) as $lang_code => $rids) {
    foreach (array_filter($rids) as $rid => $true) {
      $changes[$rid][] = 'manage ' . check_plain($lang_code) . ' translation overview priorities';
    }
  }
  foreach ($changes as $rid => $perms) {

    // Retrieve the currently set permissions.
    $existing_perms = array();
    $result = db_query("SELECT p.perm FROM {permission} p WHERE p.rid = %d ", $rid);
    if ($row = db_fetch_object($result)) {
      $perms = array_unique(array_merge($perms, explode(', ', $row->perm)));
      $ret[] = update_sql('DELETE FROM {permission} WHERE rid = ' . (int) $rid);
    }

    // Update the permissions.
    $ret[] = update_sql("INSERT INTO {permission} (rid, perm) VALUES (" . (int) $rid . ", '" . db_escape_string(implode(', ', $perms)) . "')");
  }
  variable_del('translation_overview_management');
  return $ret;
}