I've added code which prevents user from submiting 2 roles with the same name.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

breyten’s picture

Status: Needs review » Needs work

+1 on feature (I think it's always useful to have these kind of checks -- will probably save us bug reports in the future;), but -1 on the patch. It's not necessary to call db_fetch_object to just get a role id. You can change it to this:
$rid = db_result(db_query("SELECT rid FROM {role} WHERE name = '%s'", $edit['name']);
and then simply
if ($rid) {
.
.
.

kuba.zygmunt’s picture

Status: Needs work » Needs review
FileSize
1.57 KB

Ok, I've changed code. I hope that this code will be good enough. ;)

Uwe Hermann’s picture

Status: Needs review » Reviewed & tested by the community

+1. Patch applies and works as expected.

Dries’s picture

Any reason you can't use the same code twice? I like the first approach better; avoids an object being created.

Dries’s picture

Status: Reviewed & tested by the community » Needs work
Jaza’s picture

Version: x.y.z » 4.7.x-dev
Status: Needs work » Closed (fixed)

Patch no longer needed: uniqueness of role names is enforced in HEAD in the user_admin_role_validate() function.