MDL-26647 (1) 'extrauserselectorfields' -> 'showuseridentity', add capability

This change:
- Renames the existing setting 'extrauserselectorfields' to 'showuseridentity'
  in preparation for using it in more places. (Upgrade change, new version.)
- Adds a new capability moodle/site:viewuseridentity, now required in order
  to see the extra fields; if you don't have the capability, you don't see them
- Slightly improves the display of extra fields in user selector list; it used
  to be like 'sam marshall, 01234567, email@address' and is now
  'sam marshall [01234567, email@address]' ie the fields are in square
  brackets
- Turns feature on for the group selector - the feature was enabled for other
  user selectors but not for the group selector. Tim did the disable code, he
  thinks this may be to do with more people having access to group selector -
  probably not a problem now it is controlled by capability.
This commit is contained in:
sam marshall 2011-04-13 14:28:23 +01:00
parent 38e9a1cc79
commit 5c60a847f5
10 changed files with 77 additions and 21 deletions

View file

@ -996,13 +996,14 @@ abstract class role_assign_user_selector_base extends user_selector_base {
*/
public function __construct($name, $options) {
global $CFG;
parent::__construct($name, $options);
$this->roleid = $options['roleid'];
if (isset($options['context'])) {
$this->context = $options['context'];
} else {
$this->context = get_context_instance_by_id($options['contextid']);
}
$options['accesscontext'] = $this->context;
parent::__construct($name, $options);
$this->roleid = $options['roleid'];
require_once($CFG->dirroot . '/group/lib.php');
}

View file

@ -123,9 +123,24 @@ if ($hassiteconfig
'mycourses' => get_string('mycourses'),
'groups' => get_string('groups'))));
$temp->add(new admin_setting_configmulticheckbox('extrauserselectorfields',
get_string('extrauserselectorfields', 'admin'), get_string('configextrauserselectorfields', 'admin'), array('email' => '1'),
array('email' => get_string('email'), 'idnumber' => get_string('idnumber'), 'username' => get_string('username'), )));
// Select fields to display as part of user identity (only to those
// with moodle/site:viewuseridentity).
// Options include fields from the user table that might be helpful to
// distinguish when adding or listing users ('I want to add the John
// Smith from Science faculty').
// Username is not included as an option because in some sites, it might
// be a security problem to reveal usernames even to trusted staff.
// Custom user profile fields are not currently supported.
$temp->add(new admin_setting_configmulticheckbox('showuseridentity',
get_string('showuseridentity', 'admin'),
get_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
'idnumber' => get_string('idnumber'),
'email' => get_string('email'),
'phone1' => get_string('phone'),
'phone2' => get_string('phone2'),
'department' => get_string('department'),
'institution' => get_string('institution'),
)));
$temp->add(new admin_setting_configcheckbox('enablegravatar', get_string('enablegravatar', 'admin'), get_string('enablegravatar_help', 'admin'), 0));
}