Commit 2e22d4bc authored by drumm's avatar drumm
Browse files

#58860 by edkwh. Proper validation for editing roles.

parent e21c0c65
...@@ -1900,17 +1900,38 @@ function user_admin_role() { ...@@ -1900,17 +1900,38 @@ function user_admin_role() {
form_set_error('name', t('You must specify a valid role name.')); form_set_error('name', t('You must specify a valid role name.'));
} }
} }
else if ($id) { if ($id) {
// Display the role form. // Display the edit role form.
$role = db_fetch_object(db_query('SELECT * FROM {role} WHERE rid = %d', $id)); $role = db_fetch_object(db_query('SELECT * FROM {role} WHERE rid = %d', $id));
$form['name'] = array('#type' => 'textfield', '#title' => t('Role name'), '#default_value' => $role->name, '#size' => 30, '#maxlength' => 64, '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".')); $form['name'] = array(
$form['submit'] = array('#type' => 'submit', '#value' => t('Save role')); '#type' => 'textfield',
$form['delete'] = array('#type' => 'submit', '#value' => t('Delete role')); '#title' => t('Role name'),
'#default_value' => $role->name,
return $form; '#size' => 30,
'#required' => TRUE,
'#maxlength' => 64,
'#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save role'),
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete role'),
);
}
else {
$form['name'] = array(
'#type' => 'textfield',
'#size' => 32,
'#maxlength' => 64,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Add role'),
);
} }
$form['name'] = array('#type' => 'textfield', '#size' => 32, '#maxlength' => 64);
$form['submit'] = array('#type' => 'submit', '#value' => t('Add role'));
return $form; return $form;
} }
......
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