Commit e68cb68c authored by Dries's avatar Dries

- Patch #598862 by andypost: user role names cannot be translated.

parent 06fe6cae
......@@ -97,6 +97,7 @@ function user_schema() {
'not null' => TRUE,
'default' => '',
'description' => 'Unique role name.',
'translatable' => TRUE,
),
'weight' => array(
'type' => 'int',
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment