perm; foreach ($permissions as $perm) { if (strpos($role->perm, $perm) === FALSE) { $added_perms .= ", $perm"; } } if ($added_perms != $role->perm) { // some perms added db_query("UPDATE {permission} SET perm='%s' WHERE rid=%d", $added_perms, $role->rid); } } } /** * Rename permissions. Core doesn't support apostrophes so strip these out and * capitalise the permission name for readibility. * Example: "access 'I can edit' tab" is transformed to "access I Can Edit tab". * See [#566290], [#572804]. */ function module_grants_update_6207() { $ret = array(); // permission.perm column contains a comma-separated string of permissions $result = db_query("SELECT rid,perm FROM {permission} WHERE perm LIKE '%access \'%\' tab%'"); while ($permissions = db_fetch_object($result)) { // See http://www.php.net/manual/en/function.preg-replace-callback.php // Note: using create_function() as PHP 5.2 does not support closures (anonymous functions) $sanitized_permissions = preg_replace_callback("/access \'([A-Z a-z]+)\' tab/", create_function('$matches', 'return "access ". ucwords($matches[1]) ." tab";'), $permissions->perm); $ret[] = update_sql("UPDATE {permission} SET perm='". db_escape_string($sanitized_permissions) ."' WHERE rid=$permissions->rid"); } return $ret; }