diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-04-13 15:15:07 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-04-13 15:15:07 +0000 |
commit | e68cb68c1564aa0fd30c976104b2c3350d0507ca (patch) | |
tree | 5d21015edf39f467cfc40c42c4845cddfec35e06 | |
parent | 06fe6cae2d7cf5ed663c3d1225206113f3b5824f (diff) | |
download | brdo-e68cb68c1564aa0fd30c976104b2c3350d0507ca.tar.gz brdo-e68cb68c1564aa0fd30c976104b2c3350d0507ca.tar.bz2 |
- Patch #598862 by andypost: user role names cannot be translated.
-rw-r--r-- | modules/user/user.install | 1 | ||||
-rw-r--r-- | modules/user/user.module | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/modules/user/user.install b/modules/user/user.install index 6af67b9b1..ea30a1eb9 100644 --- a/modules/user/user.install +++ b/modules/user/user.install @@ -97,6 +97,7 @@ function user_schema() { 'not null' => TRUE, 'default' => '', 'description' => 'Unique role name.', + 'translatable' => TRUE, ), 'weight' => array( 'type' => 'int', diff --git a/modules/user/user.module b/modules/user/user.module index 9ebd469a1..463dfa5bc 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2505,12 +2505,16 @@ function user_mail_tokens(&$replacements, $data, $options) { * value. */ function user_roles($membersonly = FALSE, $permission = NULL) { + $query = db_select('role', 'r'); + $query->addTag('translatable'); + $query->fields('r', array('rid', 'name')); + $query->orderBy('weight'); + $query->orderBy('name'); if (!empty($permission)) { - $result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE p.permission = :permission ORDER BY r.weight, r.name", array(':permission' => $permission)); - } - else { - $result = db_query('SELECT rid, name FROM {role} ORDER BY weight, name'); + $query->innerJoin('role_permission', 'p', 'r.rid = p.rid'); + $query->condition('p.permission', $permission); } + $result = $query->execute(); $roles = array(); foreach ($result as $role) { |