You are here

function hosting_site_update_6201 in Hosting 7.3

Same name and namespace in other branches
  1. 6.2 site/hosting_site.install \hosting_site_update_6201()
  2. 7.4 site/hosting_site.install \hosting_site_update_6201()

Implements hook_update_N().

Fix permissions for renamed tasks

We re-named 'login_reset' tasks to 'login-reset' and 'backup_delete' to 'backup-delete' and so we need to fix any roles using those permissions.

File

site/hosting_site.install, line 347
Define database schema and update functions for the hosting_site module.

Code

function hosting_site_update_6201() {
  $ret = array();
  $replacements = array(
    'create backup_delete task' => 'create backup-delete task',
    'create login_reset task' => 'create login-reset task',
  );

  // Process all the roles.
  $roles = db_query('SELECT rid, perm FROM {permission}');
  while ($role = db_fetch_object($roles)) {
    $perms = explode(', ', $role->perm);
    $perms = str_replace(array_keys($replacements), array_values($replacements), $perms);
    db_query("UPDATE {permission} SET perm = '%s' where rid = %d", implode(', ', $perms), $role->rid);
  }
  return $ret;
}