[drupal-devel] [feature] Unique roles feature patch

Dries drupal-devel at drupal.org
Mon Sep 19 18:45:21 UTC 2005


Issue status update for 
http://drupal.org/node/27958
Post a follow up: 
http://drupal.org/project/comments/add/27958

 Project:      Drupal
 Version:      cvs
 Component:    user.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  kubaZygmunt
 Updated by:   Dries
 Status:       patch (ready to be committed)

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




Dries



Previous comments:
------------------------------------------------------------------------

Mon, 01 Aug 2005 16:01:56 +0000 : kubaZygmunt

Attachment: http://drupal.org/files/issues/unique.roles.patch.txt (1.61 KB)

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




------------------------------------------------------------------------

Tue, 02 Aug 2005 14:24:40 +0000 : breyten

+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) {
.
.
.




------------------------------------------------------------------------

Wed, 03 Aug 2005 10:34:01 +0000 : kubaZygmunt

Attachment: http://drupal.org/files/issues/unique.roles.patch_0.txt (1.57 KB)

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




------------------------------------------------------------------------

Mon, 19 Sep 2005 02:01:15 +0000 : Uwe Hermann

+1. Patch applies and works as expected.







More information about the drupal-devel mailing list