You are here

function gotwo_update_5100 in Go - url redirects 6

Same name and namespace in other branches
  1. 5 gotwo.install \gotwo_update_5100()

Update the permissions table, to reflect changes to hook_perm.

File

./gotwo.install, line 82
Installation script for the gotwo.module

Code

function gotwo_update_5100() {
  $ret = array();
  $res = db_query('SELECT rid, perm FROM {permission}');
  $perms = array();
  while ($p = db_fetch_object($res)) {
    $perm = $p->perm;
    $perm = preg_replace('/Administrative Settings/', 'administer gotwo', $perm);
    $perm = preg_replace('/view entry list/', 'view gotwo entries', $perm);
    $perm = preg_replace('/edit entries/', 'edit gotwo entries', $perm);
    $perms[$p->rid] = $perm;
  }
  foreach ($perms as $key => $value) {
    db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $value, $key);
  }
  return $ret;
}