You are here

function gmap_macro_builder_update_6100 in GMap Module 6

Same name and namespace in other branches
  1. 6.2 gmap_macro_builder.install \gmap_macro_builder_update_6100()
  2. 7.2 gmap_macro_builder.install \gmap_macro_builder_update_6100()
  3. 7 gmap_macro_builder.install \gmap_macro_builder_update_6100()

Rename 'create macro' permission.

File

./gmap_macro_builder.install, line 11
Install / update routines for gmap_macro_builder.

Code

function gmap_macro_builder_update_6100() {
  $ret = array();
  $result = db_query('SELECT pid, perm FROM {permission}');
  while ($row = db_fetch_object($result)) {

    // We leave "create macro" in for now just in case someone else already had that permission.
    // It should get removed automatically the next time an admin tweaks the permissions.
    $permissions = explode(', ', $row->perm);
    if (in_array('create macro', $permissions) && !in_array('create gmap macro', $permissions)) {
      $permissions[] = 'create gmap macro';
    }
    $permissions = implode(', ', $permissions);
    db_query("UPDATE {permission} SET perm = '%s' WHERE pid = %d", $permissions, $row->pid);
  }
  return $ret;
}