mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-8249 localise standard role names and descriptions if empty
This commit is contained in:
parent
2cbdaa77ea
commit
c52551dc3c
@ -256,19 +256,14 @@ class permissions_table extends capability_table_base {
|
||||
* @param string $contextname print_context_name($context) - to save recomputing.
|
||||
*/
|
||||
public function __construct($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles) {
|
||||
global $DB;
|
||||
|
||||
parent::__construct($context, 'permissions');
|
||||
$this->contextname = $contextname;
|
||||
$this->allowoverrides = $allowoverrides;
|
||||
$this->allowsafeoverrides = $allowsafeoverrides;
|
||||
$this->overridableroles = $overridableroles;
|
||||
|
||||
$roles = $DB->get_records('role', null, 'sortorder DESC');
|
||||
foreach ($roles as $roleid=>$role) {
|
||||
$roles[$roleid] = $role->name;
|
||||
}
|
||||
$this->roles = role_fix_names($roles, $context);
|
||||
$roles = get_all_roles($context);
|
||||
$this->roles = role_fix_names(array_reverse($roles, true), $context, ROLENAME_ALIAS, true);
|
||||
|
||||
}
|
||||
|
||||
@ -593,18 +588,6 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
global $DB;
|
||||
$this->errors = array();
|
||||
|
||||
// Role name.
|
||||
$name = optional_param('name', null, PARAM_MULTILANG);
|
||||
if (!is_null($name)) {
|
||||
$this->role->name = $name;
|
||||
if (html_is_blank($this->role->name)) {
|
||||
$this->errors['name'] = get_string('errorbadrolename', 'role');
|
||||
}
|
||||
}
|
||||
if ($DB->record_exists_select('role', 'name = ? and id <> ?', array($this->role->name, $this->roleid))) {
|
||||
$this->errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
|
||||
// Role short name. We clean this in a special way. We want to end up
|
||||
// with only lowercase safe ASCII characters.
|
||||
$shortname = optional_param('shortname', null, PARAM_RAW);
|
||||
@ -620,6 +603,20 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
$this->errors['shortname'] = get_string('errorexistsroleshortname', 'role');
|
||||
}
|
||||
|
||||
// Role name.
|
||||
$name = optional_param('name', null, PARAM_MULTILANG);
|
||||
if (!is_null($name)) {
|
||||
$this->role->name = $name;
|
||||
// Hack: short names of standard roles are equal to archetypes, empty name means localised via lang packs.
|
||||
$archetypes = get_role_archetypes();
|
||||
if (!isset($archetypes[$shortname]) and html_is_blank($this->role->name)) {
|
||||
$this->errors['name'] = get_string('errorbadrolename', 'role');
|
||||
}
|
||||
}
|
||||
if ($this->role->name !== '' and $DB->record_exists_select('role', 'name = ? and id <> ?', array($this->role->name, $this->roleid))) {
|
||||
$this->errors['name'] = get_string('errorexistsrolename', 'role');
|
||||
}
|
||||
|
||||
// Description.
|
||||
$description = optional_param('description', null, PARAM_RAW);
|
||||
if (!is_null($description)) {
|
||||
@ -779,9 +776,9 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
global $OUTPUT;
|
||||
// Extra fields at the top of the page.
|
||||
echo '<div class="topfields clearfix">';
|
||||
$this->print_field('name', get_string('rolefullname', 'role'), $this->get_name_field('name'));
|
||||
$this->print_field('shortname', get_string('roleshortname', 'role'), $this->get_shortname_field('shortname'));
|
||||
$this->print_field('edit-description', get_string('description'), $this->get_description_field('description'));
|
||||
$this->print_field('shortname', get_string('roleshortname', 'role').' '.$OUTPUT->help_icon('roleshortname', 'role'), $this->get_shortname_field('shortname'));
|
||||
$this->print_field('name', get_string('customrolename', 'role').' '.$OUTPUT->help_icon('customrolename', 'role'), $this->get_name_field('name'));
|
||||
$this->print_field('edit-description', get_string('customroledescription', 'role').' '.$OUTPUT->help_icon('customroledescription', 'role'), $this->get_description_field('description'));
|
||||
$this->print_field('menuarchetype', get_string('archetype', 'role').' '.$OUTPUT->help_icon('archetype', 'role'), $this->get_archetype_field('archetype'));
|
||||
$this->print_field('', get_string('maybeassignedin', 'role'), $this->get_assignable_levels_control());
|
||||
echo "</div>";
|
||||
@ -862,7 +859,7 @@ class view_role_definition_table extends define_role_table_advanced {
|
||||
}
|
||||
|
||||
protected function get_name_field($id) {
|
||||
return strip_tags(format_string($this->role->name));
|
||||
return role_get_name($this->role);
|
||||
}
|
||||
|
||||
protected function get_shortname_field($id) {
|
||||
@ -870,7 +867,7 @@ class view_role_definition_table extends define_role_table_advanced {
|
||||
}
|
||||
|
||||
protected function get_description_field($id) {
|
||||
return format_text($this->role->description, FORMAT_HTML);
|
||||
return role_get_description($this->role);
|
||||
}
|
||||
|
||||
protected function get_archetype_field($id) {
|
||||
@ -1273,8 +1270,7 @@ abstract class role_allow_role_page {
|
||||
*/
|
||||
protected function load_required_roles() {
|
||||
/// Get all roles
|
||||
$this->roles = get_all_roles();
|
||||
role_fix_names($this->roles, get_context_instance(CONTEXT_SYSTEM), ROLENAME_ORIGINAL);
|
||||
$this->roles = role_fix_names(get_all_roles(), get_context_instance(CONTEXT_SYSTEM), ROLENAME_ORIGINAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,8 +53,7 @@
|
||||
admin_externalpage_setup('defineroles');
|
||||
|
||||
/// Get some basic data we are going to need.
|
||||
$roles = get_all_roles();
|
||||
role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL);
|
||||
$roles = role_fix_names(get_all_roles(), $systemcontext, ROLENAME_ORIGINAL);
|
||||
|
||||
$undeletableroles = array();
|
||||
$undeletableroles[$CFG->notloggedinroleid] = 1;
|
||||
@ -214,7 +213,7 @@
|
||||
/// Basic data.
|
||||
$row = array(
|
||||
'<a href="' . $defineurl . '?action=view&roleid=' . $role->id . '">' . $role->localname . '</a>',
|
||||
format_text($role->description, FORMAT_HTML),
|
||||
role_get_description($role),
|
||||
s($role->shortname),
|
||||
'',
|
||||
);
|
||||
|
@ -68,14 +68,11 @@ if ($course->id != $SITE->id || $userid != $USER->id) {
|
||||
/// Now get the role assignments for this user.
|
||||
$sql = "SELECT
|
||||
ra.id, ra.userid, ra.contextid, ra.roleid, ra.component, ra.itemid,
|
||||
c.path,
|
||||
r.name AS rolename,
|
||||
COALESCE(rn.name, r.name) AS localname
|
||||
c.path
|
||||
FROM
|
||||
{role_assignments} ra
|
||||
JOIN {context} c ON ra.contextid = c.id
|
||||
JOIN {role} r ON ra.roleid = r.id
|
||||
LEFT JOIN {role_names} rn ON rn.roleid = ra.roleid AND rn.contextid = ra.contextid
|
||||
WHERE
|
||||
ra.userid = ?
|
||||
"./*AND ra.active = 1*/"
|
||||
@ -83,6 +80,8 @@ $sql = "SELECT
|
||||
contextlevel DESC, contextid ASC, r.sortorder ASC";
|
||||
$roleassignments = $DB->get_records_sql($sql, array($user->id));
|
||||
|
||||
$allroles = role_fix_names(get_all_roles());
|
||||
|
||||
/// In order to display a nice tree of contexts, we need to get all the
|
||||
/// ancestors of all the contexts in the query we just did.
|
||||
$requiredcontexts = array();
|
||||
@ -142,14 +141,14 @@ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
if (!$roleassignments) {
|
||||
echo '<p>', get_string('noroleassignments', 'role'), '</p>';
|
||||
} else {
|
||||
print_report_tree($systemcontext->id, $contexts, $systemcontext, $fullname);
|
||||
print_report_tree($systemcontext->id, $contexts, $systemcontext, $fullname, $allroles);
|
||||
}
|
||||
|
||||
/// End of page.
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
|
||||
function print_report_tree($contextid, $contexts, $systemcontext, $fullname, $allroles) {
|
||||
global $CFG, $OUTPUT;
|
||||
|
||||
// Only compute lang strings, etc once.
|
||||
@ -170,15 +169,13 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
|
||||
|
||||
// If there are any role assignments here, print them.
|
||||
foreach ($contexts[$contextid]->roleassignments as $ra) {
|
||||
$role = $allroles[$ra->roleid];
|
||||
|
||||
$value = $ra->contextid . ',' . $ra->roleid;
|
||||
$inputid = 'unassign' . $value;
|
||||
|
||||
echo '<p>';
|
||||
if ($ra->rolename == $ra->localname) {
|
||||
echo strip_tags(format_string($ra->localname));
|
||||
} else {
|
||||
echo strip_tags(format_string($ra->localname . ' (' . $ra->rolename . ')'));
|
||||
}
|
||||
echo $role->localname;
|
||||
if (has_capability('moodle/role:assign', $context)) {
|
||||
$raurl = $assignurl . '?contextid=' . $ra->contextid . '&roleid=' .
|
||||
$ra->roleid . '&removeselect[]=' . $ra->userid;
|
||||
@ -210,7 +207,7 @@ function print_report_tree($contextid, $contexts, $systemcontext, $fullname) {
|
||||
echo '<ul>';
|
||||
foreach ($contexts[$contextid]->children as $childcontextid) {
|
||||
echo '<li>';
|
||||
print_report_tree($childcontextid, $contexts, $systemcontext, $fullname);
|
||||
print_report_tree($childcontextid, $contexts, $systemcontext, $fullname, $allroles);
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
|
@ -54,9 +54,10 @@ if (!during_initial_install()) { //do not use during installation
|
||||
// front page default role
|
||||
$options = array(0=>new lang_string('none')); // roles to choose from
|
||||
$defaultfrontpageroleid = 0;
|
||||
foreach (get_all_roles() as $role) {
|
||||
$roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
|
||||
foreach ($roles as $role) {
|
||||
if (empty($role->archetype) or $role->archetype === 'guest' or $role->archetype === 'frontpage' or $role->archetype === 'student') {
|
||||
$options[$role->id] = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
$options[$role->id] = $role->localname;
|
||||
if ($role->archetype === 'frontpage') {
|
||||
$defaultfrontpageroleid = $role->id;
|
||||
}
|
||||
|
@ -45,8 +45,9 @@ if ($hassiteconfig
|
||||
$defaultuserid = null;
|
||||
$defaultguestid = null;
|
||||
|
||||
foreach (get_all_roles() as $role) {
|
||||
$rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
$roles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT);
|
||||
foreach ($roles as $role) {
|
||||
$rolename = $role->localname;
|
||||
switch ($role->archetype) {
|
||||
case 'manager':
|
||||
$creatornewroles[$role->id] = $rolename;
|
||||
|
@ -38,7 +38,7 @@ $roleids = optional_param_array('roles', array('0'), PARAM_INTEGER);
|
||||
|
||||
// Clean the passed in list of role ids. If 'All' selected as an option, or
|
||||
// if none were selected, do all roles.
|
||||
$allroles = get_all_roles();
|
||||
$allroles = role_fix_names(get_all_roles());
|
||||
$cleanedroleids = array();
|
||||
foreach ($roleids as $roleid) {
|
||||
if ($roleid == 0) {
|
||||
@ -73,7 +73,7 @@ foreach ($allcapabilities as $cap) {
|
||||
// Prepare the list of roles to choose from
|
||||
$rolechoices = array('0' => get_string('all'));
|
||||
foreach ($allroles as $role) {
|
||||
$rolechoices[$role->id] = $role->name;
|
||||
$rolechoices[$role->id] = $role->localname;
|
||||
}
|
||||
if (count($cleanedroleids) == count($allroles)) {
|
||||
// Select 'All', rather than each role individually.
|
||||
@ -162,7 +162,7 @@ if ($capability) {
|
||||
if (count($cleanedroleids) != count($allroles)) {
|
||||
$rolenames = array();
|
||||
foreach ($cleanedroleids as $roleid) {
|
||||
$rolenames[] = $allroles[$roleid]->name;
|
||||
$rolenames[] = $allroles[$roleid]->localname;
|
||||
}
|
||||
echo '<p>', get_string('forroles', 'tool_capability', implode(', ', $rolenames)), '</p>';
|
||||
}
|
||||
@ -207,7 +207,7 @@ function print_report_tree($contextid, $contexts, $allroles) {
|
||||
foreach ($allroles as $role) {
|
||||
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
|
||||
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
|
||||
echo '<tr class="r' . ($rowcounter % 2) . '"><th class="cell">', $role->name,
|
||||
echo '<tr class="r' . ($rowcounter % 2) . '"><th class="cell">', $role->localname,
|
||||
'</th><td class="cell">' . $strpermissions[$permission] . '</td></tr>';
|
||||
$rowcounter++;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ if (!$problems) {
|
||||
$data = array();
|
||||
foreach ($problems as $problem) {
|
||||
$levelname = get_contextlevel_name($problem->contextlevel);
|
||||
$rolename = format_string($roles[$problem->roleid]->name);
|
||||
$rolename = role_get_name($roles[$problem->roleid]);
|
||||
//TODO: show list of users if count low
|
||||
$count = $problem->racount;
|
||||
$edit = array();
|
||||
|
@ -347,7 +347,6 @@ abstract class restore_dbops {
|
||||
|
||||
// Gather various information about roles
|
||||
$coursectx = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$allroles = $DB->get_records('role');
|
||||
$assignablerolesshortname = get_assignable_roles($coursectx, ROLENAME_SHORT, false, $userid);
|
||||
|
||||
// Note: under 1.9 we had one function restore_samerole() that performed one complete
|
||||
|
@ -69,6 +69,12 @@ if (!empty($course)) {
|
||||
$editoroptions['context'] = $coursecontext;
|
||||
$course = file_prepare_standard_editor($course, 'summary', $editoroptions, $coursecontext, 'course', 'summary', 0);
|
||||
|
||||
// Inject current aliases
|
||||
$aliases = $DB->get_records('role_names', array('contextid'=>$coursecontext->id));
|
||||
foreach($aliases as $alias) {
|
||||
$course->{'role_'.$alias->roleid} = $alias->name;
|
||||
}
|
||||
|
||||
} else {
|
||||
//editor should respect category context if course context is not set.
|
||||
$editoroptions['context'] = $catcontext;
|
||||
|
@ -268,15 +268,10 @@ class course_edit_form extends moodleform {
|
||||
$mform->addHelpButton('rolerenaming', 'rolerenaming');
|
||||
|
||||
if ($roles = get_all_roles()) {
|
||||
if ($coursecontext) {
|
||||
$roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW);
|
||||
}
|
||||
$roles = role_fix_names($roles, null, ROLENAME_ORIGINAL);
|
||||
$assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE);
|
||||
foreach ($roles as $role) {
|
||||
$mform->addElement('text', 'role_'.$role->id, get_string('yourwordforx', '', $role->name));
|
||||
if (isset($role->localname)) {
|
||||
$mform->setDefault('role_'.$role->id, $role->localname);
|
||||
}
|
||||
$mform->addElement('text', 'role_'.$role->id, get_string('yourwordforx', '', $role->localname));
|
||||
$mform->setType('role_'.$role->id, PARAM_TEXT);
|
||||
if (!in_array($role->id, $assignableroles)) {
|
||||
$mform->setAdvanced('role_'.$role->id);
|
||||
|
@ -59,12 +59,15 @@
|
||||
if (!empty($CFG->coursecontact)) {
|
||||
$coursecontactroles = explode(',', $CFG->coursecontact);
|
||||
foreach ($coursecontactroles as $roleid) {
|
||||
$role = $DB->get_record('role', array('id'=>$roleid));
|
||||
$roleid = (int) $roleid;
|
||||
if ($users = get_role_users($roleid, $context, true)) {
|
||||
foreach ($users as $teacher) {
|
||||
$role = new stdClass();
|
||||
$role->id = $teacher->roleid;
|
||||
$role->name = $teacher->rolename;
|
||||
$role->shortname = $teacher->roleshortname;
|
||||
$role->coursealias = $teacher->rolecoursealias;
|
||||
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
|
||||
$namesarray[] = format_string(role_get_name($role, $context)).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$namesarray[] = role_get_name($role, $context).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$teacher->id.'&course='.SITEID.'">'.$fullname.'</a>';
|
||||
}
|
||||
}
|
||||
|
@ -2529,32 +2529,26 @@ function print_course($course, $highlightterms = '') {
|
||||
/// first find all roles that are supposed to be displayed
|
||||
if (!empty($CFG->coursecontact)) {
|
||||
$managerroles = explode(',', $CFG->coursecontact);
|
||||
$namesarray = array();
|
||||
$rusers = array();
|
||||
|
||||
if (!isset($course->managers)) {
|
||||
$rusers = get_role_users($managerroles, $context, true,
|
||||
'ra.id AS raid, u.id, u.username, u.firstname, u.lastname,
|
||||
r.name AS rolename, r.sortorder, r.id AS roleid',
|
||||
'ra.id AS raid, u.id, u.username, u.firstname, u.lastname, rn.name AS rolecoursealias,
|
||||
r.name AS rolename, r.sortorder, r.id AS roleid, r.shortname AS roleshortname',
|
||||
'r.sortorder ASC, u.lastname ASC');
|
||||
} else {
|
||||
// use the managers array if we have it for perf reasosn
|
||||
// populate the datastructure like output of get_role_users();
|
||||
foreach ($course->managers as $manager) {
|
||||
$u = new stdClass();
|
||||
$u = $manager->user;
|
||||
$u->roleid = $manager->roleid;
|
||||
$u->rolename = $manager->rolename;
|
||||
|
||||
$rusers[] = $u;
|
||||
$user = clone($manager->user);
|
||||
$user->roleid = $manager->roleid;
|
||||
$user->rolename = $manager->rolename;
|
||||
$user->roleshortname = $manager->roleshortname;
|
||||
$user->rolecoursealias = $manager->rolecoursealias;
|
||||
$rusers[$user->id] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
/// Rename some of the role names if needed
|
||||
if (isset($context)) {
|
||||
$aliasnames = $DB->get_records('role_names', array('contextid'=>$context->id), '', 'roleid,contextid,name');
|
||||
}
|
||||
|
||||
$namesarray = array();
|
||||
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
|
||||
foreach ($rusers as $ra) {
|
||||
@ -2563,12 +2557,15 @@ function print_course($course, $highlightterms = '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($aliasnames[$ra->roleid])) {
|
||||
$ra->rolename = $aliasnames[$ra->roleid]->name;
|
||||
}
|
||||
$role = new stdClass();
|
||||
$role->id = $ra->roleid;
|
||||
$role->name = $ra->rolename;
|
||||
$role->shortname = $ra->roleshortname;
|
||||
$role->coursealias = $ra->rolecoursealias;
|
||||
$rolename = role_get_name($role, $context, ROLENAME_ALIAS);
|
||||
|
||||
$fullname = fullname($ra, $canviewfullnames);
|
||||
$namesarray[$ra->id] = format_string($ra->rolename).': '.
|
||||
$namesarray[$ra->id] = $rolename.': '.
|
||||
html_writer::link(new moodle_url('/user/view.php', array('id'=>$ra->id, 'course'=>SITEID)), $fullname);
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ if ($ADMIN->fulltree) {
|
||||
if (!during_initial_install()) {
|
||||
$settings->add(new admin_setting_heading('enrol_flatfile_mapping', get_string('mapping', 'enrol_flatfile'), ''));
|
||||
|
||||
$roles = $DB->get_records('role', null, '', 'id, name, shortname');
|
||||
$roles = role_fix_names(get_all_roles());
|
||||
|
||||
foreach ($roles as $id => $record) {
|
||||
$settings->add(new admin_setting_configtext('enrol_flatfile/map_'.$id, format_string($record->name), '', format_string($record->shortname)));
|
||||
foreach ($roles as $id => $role) {
|
||||
$settings->add(new admin_setting_configtext('enrol_flatfile/map_'.$id, $role->localname, '', $role->shortname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ class admin_setting_ldap_rolemapping extends admin_setting {
|
||||
* @return mixed null if null, else an array
|
||||
*/
|
||||
public function get_setting() {
|
||||
$roles = get_all_roles();
|
||||
$roles = role_fix_names(get_all_roles());
|
||||
$result = array();
|
||||
foreach ($roles as $role) {
|
||||
$contexts = $this->config_read('contexts_role'.$role->id);
|
||||
$memberattribute = $this->config_read('memberattribute_role'.$role->id);
|
||||
$result[] = array('id' => $role->id,
|
||||
'name' => $role->name,
|
||||
'name' => $role->localname,
|
||||
'contexts' => $contexts,
|
||||
'memberattribute' => $memberattribute);
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ class course_enrolment_manager {
|
||||
*/
|
||||
public function get_all_roles() {
|
||||
if ($this->_roles === null) {
|
||||
$this->_roles = role_fix_names(get_all_roles(), $this->context);
|
||||
$this->_roles = role_fix_names(get_all_roles($this->context), $this->context);
|
||||
}
|
||||
return $this->_roles;
|
||||
}
|
||||
|
@ -31,11 +31,7 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_heading('enrol_meta_settings', '', get_string('pluginname_desc', 'enrol_meta')));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
$allroles = array();
|
||||
foreach (get_all_roles() as $role) {
|
||||
$rolename = strip_tags(format_string($role->name)) . ' ('. $role->shortname . ')';
|
||||
$allroles[$role->id] = $rolename;
|
||||
}
|
||||
$allroles = role_fix_names(get_all_roles(), null, ROLENAME_ORIGINALANDSHORT, true);
|
||||
$settings->add(new admin_setting_configmultiselect('enrol_meta/nosyncroleids', get_string('nosyncroleids', 'enrol_meta'), get_string('nosyncroleids_desc', 'enrol_meta'), array(), $allroles));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_meta/syncall', get_string('syncall', 'enrol_meta'), get_string('syncall_desc', 'enrol_meta'), 1));
|
||||
|
@ -161,19 +161,18 @@ class enrol_self_edit_form extends moodleform {
|
||||
* Gets a list of roles that this user can assign for the course as the default for self-enrolment
|
||||
*
|
||||
* @param context $context the context.
|
||||
* @param integer $defaultrole the id of the role that is set as the default for self-enrolement
|
||||
* @param integer $defaultrole the id of the role that is set as the default for self-enrolment
|
||||
* @return array index is the role id, value is the role name
|
||||
*/
|
||||
function extend_assignable_roles($context, $defaultrole) {
|
||||
global $DB;
|
||||
$roles = get_assignable_roles($context);
|
||||
$sql = "SELECT r.id, r.name
|
||||
FROM {role} r
|
||||
WHERE r.id = $defaultrole";
|
||||
$results = $DB->get_record_sql($sql);
|
||||
if (isset($results->name)) {
|
||||
$roles[$results->id] = $results->name;
|
||||
|
||||
$roles = get_assignable_roles($context, ROLENAME_BOTH);
|
||||
if (!isset($roles[$defaultrole])) {
|
||||
if ($role = $DB->get_record('role', array('id'=>$defaultrole))) {
|
||||
$roles[$defaultrole] = role_get_name($role, $context, ROLENAME_BOTH);
|
||||
}
|
||||
}
|
||||
return $roles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,13 +55,8 @@ $strautocreategroups = get_string('autocreategroups', 'group');
|
||||
$preview = '';
|
||||
$error = '';
|
||||
|
||||
/// Get applicable roles
|
||||
$rolenames = array();
|
||||
if ($roles = get_profile_roles($context)) {
|
||||
foreach ($roles as $role) {
|
||||
$rolenames[$role->id] = strip_tags(role_get_name($role, $context)); // Used in menus etc later on
|
||||
}
|
||||
}
|
||||
/// Get applicable roles - used in menus etc later on
|
||||
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
|
||||
|
||||
/// Create the form
|
||||
$editform = new autogroup_form(null, array('roles' => $rolenames));
|
||||
|
@ -695,8 +695,7 @@ function groups_get_members_by_role($groupid, $courseid, $fields='u.*',
|
||||
$extrawheretest = ' AND ' . $extrawheretest;
|
||||
}
|
||||
|
||||
$sql = "SELECT r.id AS roleid, r.shortname AS roleshortname, r.name AS rolename,
|
||||
u.id AS userid, $fields
|
||||
$sql = "SELECT r.id AS roleid, u.id AS userid, $fields
|
||||
FROM {groups_members} gm
|
||||
JOIN {user} u ON u.id = gm.userid
|
||||
LEFT JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid ".get_related_contexts_string($context).")
|
||||
@ -726,8 +725,7 @@ function groups_calculate_role_people($rs, $context) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$roles = $DB->get_records_menu('role', null, 'name', 'id, name');
|
||||
$aliasnames = role_fix_names($roles, $context);
|
||||
$allroles = role_fix_names(get_all_roles($context), $context);
|
||||
|
||||
// Array of all involved roles
|
||||
$roles = array();
|
||||
@ -753,15 +751,12 @@ function groups_calculate_role_people($rs, $context) {
|
||||
// If user has a role...
|
||||
if (!is_null($rec->roleid)) {
|
||||
// Create information about role if this is a new one
|
||||
if (!array_key_exists($rec->roleid,$roles)) {
|
||||
if (!array_key_exists($rec->roleid, $roles)) {
|
||||
$role = $allroles[$rec->roleid];
|
||||
$roledata = new stdClass();
|
||||
$roledata->id = $rec->roleid;
|
||||
$roledata->shortname = $rec->roleshortname;
|
||||
if (array_key_exists($rec->roleid, $aliasnames)) {
|
||||
$roledata->name = $aliasnames[$rec->roleid];
|
||||
} else {
|
||||
$roledata->name = $rec->rolename;
|
||||
}
|
||||
$roledata->id = $role->id;
|
||||
$roledata->shortname = $role->shortname;
|
||||
$roledata->name = $role->localname;
|
||||
$roledata->users = array();
|
||||
$roles[$roledata->id] = $roledata;
|
||||
}
|
||||
|
@ -147,6 +147,10 @@ $string['createrolebycopying'] = 'Create a new role by copying {$a}';
|
||||
$string['createthisrole'] = 'Create this role';
|
||||
$string['currentcontext'] = 'Current context';
|
||||
$string['currentrole'] = 'Current role';
|
||||
$string['customroledescription'] = 'Custom description';
|
||||
$string['customroledescription_help'] = 'Descriptions of standard roles are localised automatically if the custom description is empty.';
|
||||
$string['customrolename'] = 'Custom full name';
|
||||
$string['customrolename_help'] = 'Names of standard roles are localised automatically if the custom name is empty. You must provide full name for all custom roles.';
|
||||
$string['defaultrole'] = 'Default role';
|
||||
$string['defaultx'] = 'Default: {$a}';
|
||||
$string['defineroles'] = 'Define roles';
|
||||
@ -312,6 +316,7 @@ $string['roles_link'] = 'roles';
|
||||
$string['role:safeoverride'] = 'Override safe permissions for others';
|
||||
$string['roleselect'] = 'Select role';
|
||||
$string['roleshortname'] = 'Short name';
|
||||
$string['roleshortname_help'] = 'Role short name is a low level role identifier, only ASCII alphanumeric characters are allowed. Do not change short names of standard roles.';
|
||||
$string['role:switchroles'] = 'Switch to other roles';
|
||||
$string['roletoassign'] = 'Role to assign';
|
||||
$string['roletooverride'] = 'Role to override';
|
||||
|
@ -168,9 +168,9 @@ define('RISK_SPAM', 0x0010);
|
||||
/** capability allows mass delete of data belonging to other users - see {@link http://docs.moodle.org/dev/Hardening_new_Roles_system} */
|
||||
define('RISK_DATALOSS', 0x0020);
|
||||
|
||||
/** rolename displays - the name as defined in the role definition */
|
||||
/** rolename displays - the name as defined in the role definition, localised if name empty */
|
||||
define('ROLENAME_ORIGINAL', 0);
|
||||
/** rolename displays - the name as defined by a role alias */
|
||||
/** rolename displays - the name as defined by a role alias at the course level, falls back to ROLENAME_ORIGINAL if alias not present */
|
||||
define('ROLENAME_ALIAS', 1);
|
||||
/** rolename displays - Both, like this: Role alias (Original) */
|
||||
define('ROLENAME_BOTH', 2);
|
||||
@ -2840,8 +2840,15 @@ function get_profile_roles(context $context) {
|
||||
list($contextlist, $cparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'p');
|
||||
$params = array_merge($params, $cparams);
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder, rn.name AS coursealias
|
||||
FROM {role_assignments} ra, {role} r
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
WHERE r.id = ra.roleid
|
||||
AND ra.contextid $contextlist
|
||||
AND r.id $rallowed
|
||||
@ -2859,10 +2866,17 @@ function get_profile_roles(context $context) {
|
||||
function get_roles_used_in_context(context $context) {
|
||||
global $DB;
|
||||
|
||||
list($contextlist, $params) = $DB->get_in_or_equal($context->get_parent_context_ids(true));
|
||||
list($contextlist, $params) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'cl');
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder, rn.name AS coursealias
|
||||
FROM {role_assignments} ra, {role} r
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
WHERE r.id = ra.roleid
|
||||
AND ra.contextid $contextlist
|
||||
ORDER BY r.sortorder ASC";
|
||||
@ -2900,8 +2914,15 @@ function get_user_roles_in_course($userid, $courseid) {
|
||||
list($contextlist, $cparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'p');
|
||||
$params = array_merge($params, $cparams);
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT r.id, r.name, r.shortname, r.sortorder, rn.name AS coursealias
|
||||
FROM {role_assignments} ra, {role} r
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
WHERE r.id = ra.roleid
|
||||
AND ra.contextid $contextlist
|
||||
AND r.id $rallowed
|
||||
@ -2912,11 +2933,7 @@ function get_user_roles_in_course($userid, $courseid) {
|
||||
$rolestring = '';
|
||||
|
||||
if ($roles = $DB->get_records_sql($sql, $params)) {
|
||||
foreach ($roles as $userrole) {
|
||||
$rolenames[$userrole->id] = $userrole->name;
|
||||
}
|
||||
|
||||
$rolenames = role_fix_names($rolenames, $context); // Substitute aliases
|
||||
$rolenames = role_fix_names($roles, $context, ROLENAME_ALIAS, true); // Substitute aliases
|
||||
|
||||
foreach ($rolenames as $roleid => $rolename) {
|
||||
$rolenames[$roleid] = '<a href="'.$CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&roleid='.$roleid.'">'.$rolename.'</a>';
|
||||
@ -2958,11 +2975,26 @@ function user_can_assign(context $context, $targetroleid) {
|
||||
/**
|
||||
* Returns all site roles in correct sort order.
|
||||
*
|
||||
* @return array
|
||||
* @param context $context optional context for course role name aliases
|
||||
* @return array of role records with optional coursealias property
|
||||
*/
|
||||
function get_all_roles() {
|
||||
function get_all_roles(context $context = null) {
|
||||
global $DB;
|
||||
return $DB->get_records('role', null, 'sortorder ASC');
|
||||
|
||||
if (!$context or !$coursecontext = $context->get_course_context(false)) {
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
if ($coursecontext) {
|
||||
$sql = "SELECT r.*, rn.name AS coursealias
|
||||
FROM {role} r
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
ORDER BY r.sortorder ASC";
|
||||
return $DB->get_records_sql($sql, array('coursecontext'=>$coursecontext->id));
|
||||
|
||||
} else {
|
||||
return $DB->get_records('role', array(), 'sortorder ASC');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3098,14 +3130,8 @@ function get_assignable_roles(context $context, $rolenamedisplay = ROLENAME_ALIA
|
||||
}
|
||||
}
|
||||
|
||||
$parents = $context->get_parent_context_ids(true);
|
||||
$contexts = implode(',' , $parents);
|
||||
|
||||
$params = array();
|
||||
$extrafields = '';
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT or $rolenamedisplay == ROLENAME_SHORT) {
|
||||
$extrafields .= ', r.shortname';
|
||||
}
|
||||
|
||||
if ($withusercounts) {
|
||||
$extrafields = ', (SELECT count(u.id)
|
||||
@ -3119,6 +3145,8 @@ function get_assignable_roles(context $context, $rolenamedisplay = ROLENAME_ALIA
|
||||
// show all roles allowed in this context to admins
|
||||
$assignrestriction = "";
|
||||
} else {
|
||||
$parents = $context->get_parent_context_ids(true);
|
||||
$contexts = implode(',' , $parents);
|
||||
$assignrestriction = "JOIN (SELECT DISTINCT raa.allowassign AS id
|
||||
FROM {role_allow_assign} raa
|
||||
JOIN {role_assignments} ra ON ra.roleid = raa.roleid
|
||||
@ -3127,28 +3155,22 @@ function get_assignable_roles(context $context, $rolenamedisplay = ROLENAME_ALIA
|
||||
$params['userid'] = $userid;
|
||||
}
|
||||
$params['contextlevel'] = $context->contextlevel;
|
||||
$sql = "SELECT r.id, r.name $extrafields
|
||||
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0; // no course aliases
|
||||
$coursecontext = null;
|
||||
}
|
||||
$sql = "SELECT r.id, r.name, r.shortname, rn.name AS coursealias $extrafields
|
||||
FROM {role} r
|
||||
$assignrestriction
|
||||
JOIN {role_context_levels} rcl ON r.id = rcl.roleid
|
||||
WHERE rcl.contextlevel = :contextlevel
|
||||
JOIN {role_context_levels} rcl ON (rcl.contextlevel = :contextlevel AND r.id = rcl.roleid)
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
ORDER BY r.sortorder ASC";
|
||||
$roles = $DB->get_records_sql($sql, $params);
|
||||
|
||||
$rolenames = array();
|
||||
foreach ($roles as $role) {
|
||||
if ($rolenamedisplay == ROLENAME_SHORT) {
|
||||
$rolenames[$role->id] = $role->shortname;
|
||||
continue;
|
||||
}
|
||||
$rolenames[$role->id] = $role->name;
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) {
|
||||
$rolenames[$role->id] .= ' (' . $role->shortname . ')';
|
||||
}
|
||||
}
|
||||
if ($rolenamedisplay != ROLENAME_ORIGINALANDSHORT and $rolenamedisplay != ROLENAME_SHORT) {
|
||||
$rolenames = role_fix_names($rolenames, $context, $rolenamedisplay);
|
||||
}
|
||||
$rolenames = role_fix_names($roles, $coursecontext, $rolenamedisplay, true);
|
||||
|
||||
if (!$withusercounts) {
|
||||
return $rolenames;
|
||||
@ -3192,17 +3214,25 @@ function get_switchable_roles(context $context) {
|
||||
$params['userid'] = $USER->id;
|
||||
}
|
||||
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0; // no course aliases
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
$query = "
|
||||
SELECT r.id, r.name
|
||||
SELECT r.id, r.name, r.shortname, rn.name AS coursealias
|
||||
FROM (SELECT DISTINCT rc.roleid
|
||||
FROM {role_capabilities} rc
|
||||
$extrajoins
|
||||
$extrawhere) idlist
|
||||
JOIN {role} r ON r.id = idlist.roleid
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
ORDER BY r.sortorder";
|
||||
$roles = $DB->get_records_sql($query, $params);
|
||||
|
||||
$rolenames = $DB->get_records_sql_menu($query, $params);
|
||||
return role_fix_names($rolenames, $context, ROLENAME_ALIAS);
|
||||
return role_fix_names($roles, $context, ROLENAME_ALIAS, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3232,9 +3262,6 @@ function get_overridable_roles(context $context, $rolenamedisplay = ROLENAME_ALI
|
||||
|
||||
$params = array();
|
||||
$extrafields = '';
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) {
|
||||
$extrafields .= ', ro.shortname';
|
||||
}
|
||||
|
||||
$params['userid'] = $USER->id;
|
||||
if ($withcounts) {
|
||||
@ -3243,16 +3270,24 @@ function get_overridable_roles(context $context, $rolenamedisplay = ROLENAME_ALI
|
||||
$params['conid'] = $context->id;
|
||||
}
|
||||
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0; // no course aliases
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
if (is_siteadmin()) {
|
||||
// show all roles to admins
|
||||
$roles = $DB->get_records_sql("
|
||||
SELECT ro.id, ro.name$extrafields
|
||||
SELECT ro.id, ro.name, ro.shortname, rn.name AS coursealias $extrafields
|
||||
FROM {role} ro
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = ro.id)
|
||||
ORDER BY ro.sortorder ASC", $params);
|
||||
|
||||
} else {
|
||||
$roles = $DB->get_records_sql("
|
||||
SELECT ro.id, ro.name$extrafields
|
||||
SELECT ro.id, ro.name, ro.shortname, rn.name AS coursealias $extrafields
|
||||
FROM {role} ro
|
||||
JOIN (SELECT DISTINCT r.id
|
||||
FROM {role} r
|
||||
@ -3260,23 +3295,15 @@ function get_overridable_roles(context $context, $rolenamedisplay = ROLENAME_ALI
|
||||
JOIN {role_assignments} ra ON rao.roleid = ra.roleid
|
||||
WHERE ra.userid = :userid AND ra.contextid IN ($contexts)
|
||||
) inline_view ON ro.id = inline_view.id
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = ro.id)
|
||||
ORDER BY ro.sortorder ASC", $params);
|
||||
}
|
||||
|
||||
$rolenames = array();
|
||||
foreach ($roles as $role) {
|
||||
$rolenames[$role->id] = $role->name;
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) {
|
||||
$rolenames[$role->id] .= ' (' . $role->shortname . ')';
|
||||
}
|
||||
}
|
||||
if ($rolenamedisplay != ROLENAME_ORIGINALANDSHORT) {
|
||||
$rolenames = role_fix_names($rolenames, $context, $rolenamedisplay);
|
||||
}
|
||||
$rolenames = role_fix_names($roles, $context, $rolenamedisplay, true);
|
||||
|
||||
if (!$withcounts) {
|
||||
return $rolenames;
|
||||
}
|
||||
}
|
||||
|
||||
$rolecounts = array();
|
||||
$nameswithcounts = array();
|
||||
@ -3300,22 +3327,31 @@ function get_default_enrol_roles(context $context, $addroleid = null) {
|
||||
global $DB;
|
||||
|
||||
$params = array('contextlevel'=>CONTEXT_COURSE);
|
||||
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0; // no course names
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
if ($addroleid) {
|
||||
$addrole = "OR r.id = :addroleid";
|
||||
$params['addroleid'] = $addroleid;
|
||||
} else {
|
||||
$addrole = "";
|
||||
}
|
||||
$sql = "SELECT r.id, r.name
|
||||
|
||||
$sql = "SELECT r.id, r.name, r.shortname, rn.name AS coursealias
|
||||
FROM {role} r
|
||||
LEFT JOIN {role_context_levels} rcl ON (rcl.roleid = r.id AND rcl.contextlevel = :contextlevel)
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
WHERE rcl.id IS NOT NULL $addrole
|
||||
ORDER BY sortorder DESC";
|
||||
|
||||
$roles = $DB->get_records_sql_menu($sql, $params);
|
||||
$roles = role_fix_names($roles, $context, ROLENAME_BOTH);
|
||||
$roles = $DB->get_records_sql($sql, $params);
|
||||
|
||||
return $roles;
|
||||
return role_fix_names($roles, $context, ROLENAME_BOTH, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3776,7 +3812,8 @@ function get_role_users($roleid, context $context, $parent = false, $fields = ''
|
||||
$fields = 'u.id, u.confirmed, u.username, u.firstname, u.lastname, '.
|
||||
'u.maildisplay, u.mailformat, u.maildigest, u.email, u.emailstop, u.city, '.
|
||||
'u.country, u.picture, u.idnumber, u.department, u.institution, '.
|
||||
'u.lang, u.timezone, u.lastaccess, u.mnethostid, r.name AS rolename, r.sortorder';
|
||||
'u.lang, u.timezone, u.lastaccess, u.mnethostid, r.name AS rolename, r.sortorder, '.
|
||||
'r.shortname AS roleshortname, rn.name AS rolecoursealias';
|
||||
}
|
||||
|
||||
$parentcontexts = '';
|
||||
@ -3789,23 +3826,29 @@ function get_role_users($roleid, context $context, $parent = false, $fields = ''
|
||||
}
|
||||
|
||||
if ($roleid) {
|
||||
list($rids, $params) = $DB->get_in_or_equal($roleid, SQL_PARAMS_QM);
|
||||
list($rids, $params) = $DB->get_in_or_equal($roleid, SQL_PARAMS_NAMED, 'r');
|
||||
$roleselect = "AND ra.roleid $rids";
|
||||
} else {
|
||||
$params = array();
|
||||
$roleselect = '';
|
||||
}
|
||||
|
||||
if ($coursecontext = $context->get_course_context(false)) {
|
||||
$params['coursecontext'] = $coursecontext->id;
|
||||
} else {
|
||||
$params['coursecontext'] = 0;
|
||||
}
|
||||
|
||||
if ($group) {
|
||||
$groupjoin = "JOIN {groups_members} gm ON gm.userid = u.id";
|
||||
$groupselect = " AND gm.groupid = ? ";
|
||||
$params[] = $group;
|
||||
$groupselect = " AND gm.groupid = :groupid ";
|
||||
$params['groupid'] = $group;
|
||||
} else {
|
||||
$groupjoin = '';
|
||||
$groupselect = '';
|
||||
}
|
||||
|
||||
array_unshift($params, $context->id);
|
||||
$params['contextid'] = $context->id;
|
||||
|
||||
if ($extrawheretest) {
|
||||
$extrawheretest = ' AND ' . $extrawheretest;
|
||||
@ -3816,8 +3859,9 @@ function get_role_users($roleid, context $context, $parent = false, $fields = ''
|
||||
FROM {role_assignments} ra
|
||||
JOIN {user} u ON u.id = ra.userid
|
||||
JOIN {role} r ON ra.roleid = r.id
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = :coursecontext AND rn.roleid = r.id)
|
||||
$groupjoin
|
||||
WHERE (ra.contextid = ? $parentcontexts)
|
||||
WHERE (ra.contextid = :contextid $parentcontexts)
|
||||
$roleselect
|
||||
$groupselect
|
||||
$extrawheretest
|
||||
@ -4123,75 +4167,175 @@ function user_has_role_assignment($userid, $roleid, $contextid = 0) {
|
||||
* Get role name or alias if exists and format the text.
|
||||
*
|
||||
* @param stdClass $role role object
|
||||
* @param context_course $coursecontext
|
||||
* @return string name of role in course context
|
||||
* - optional 'coursealias' property should be included for performance reasons if course context used
|
||||
* - description property is not required here
|
||||
* @param context|bool $context empty means system context
|
||||
* @param int $rolenamedisplay type of role name
|
||||
* @return string localised role name or course role name alias
|
||||
*/
|
||||
function role_get_name($role, context_course $coursecontext) {
|
||||
function role_get_name(stdClass $role, $context = null, $rolenamedisplay = ROLENAME_ALIAS) {
|
||||
global $DB;
|
||||
|
||||
if ($r = $DB->get_record('role_names', array('roleid'=>$role->id, 'contextid'=>$coursecontext->id))) {
|
||||
return strip_tags(format_string($r->name));
|
||||
if ($rolenamedisplay == ROLENAME_SHORT) {
|
||||
return $role->shortname;
|
||||
}
|
||||
|
||||
if (!$context or !$coursecontext = $context->get_course_context(false)) {
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
if ($coursecontext and !property_exists($role, 'coursealias') and ($rolenamedisplay == ROLENAME_ALIAS or $rolenamedisplay == ROLENAME_BOTH or $rolenamedisplay == ROLENAME_ALIAS_RAW)) {
|
||||
$role = clone($role); // Do not modify parameters.
|
||||
if ($r = $DB->get_record('role_names', array('roleid'=>$role->id, 'contextid'=>$coursecontext->id))) {
|
||||
$role->coursealias = $r->name;
|
||||
} else {
|
||||
$role->coursealias = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rolenamedisplay == ROLENAME_ALIAS_RAW) {
|
||||
if ($coursecontext) {
|
||||
return $role->coursealias;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (trim($role->name) !== '') {
|
||||
// For filtering always use context where was the thing defined - system for roles here.
|
||||
$original = format_string($role->name, true, array('context'=>context_system::instance()));
|
||||
|
||||
} else {
|
||||
return strip_tags(format_string($role->name));
|
||||
// Empty role->name means we want to see localised role name based on shortname,
|
||||
// only default roles are supposed to be localised.
|
||||
switch ($role->shortname) {
|
||||
case 'manager': $original = get_string('manager', 'role'); break;
|
||||
case 'coursecreator': $original = get_string('coursecreators'); break;
|
||||
case 'editingteacher': $original = get_string('defaultcourseteacher'); break;
|
||||
case 'teacher': $original = get_string('noneditingteacher'); break;
|
||||
case 'student': $original = get_string('defaultcoursestudent'); break;
|
||||
case 'guest': $original = get_string('guest'); break;
|
||||
case 'user': $original = get_string('authenticateduser'); break;
|
||||
case 'frontpage': $original = get_string('frontpageuser', 'role'); break;
|
||||
// We should not get here, the role UI should require the name for custom roles!
|
||||
default: $original = $role->shortname; break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINAL) {
|
||||
return $original;
|
||||
}
|
||||
|
||||
if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) {
|
||||
return "$original ($role->shortname)";
|
||||
}
|
||||
|
||||
if ($rolenamedisplay == ROLENAME_ALIAS) {
|
||||
if ($coursecontext and trim($role->coursealias) !== '') {
|
||||
return format_string($role->coursealias, true, array('context'=>$coursecontext));
|
||||
} else {
|
||||
return $original;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rolenamedisplay == ROLENAME_BOTH) {
|
||||
if ($coursecontext and trim($role->coursealias) !== '') {
|
||||
return format_string($role->coursealias, true, array('context'=>$coursecontext)) . " ($original)";
|
||||
} else {
|
||||
return $original;
|
||||
}
|
||||
}
|
||||
|
||||
throw new coding_exception('Invalid $rolenamedisplay parameter specified in role_get_name()');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localised role description if available.
|
||||
* If the name is empty it tries to find the default role name using
|
||||
* hardcoded list of default role names or other methods in the future.
|
||||
*
|
||||
* @param stdClass $role
|
||||
* @return string localised role name
|
||||
*/
|
||||
function role_get_description(stdClass $role) {
|
||||
if (!html_is_blank($role->description)) {
|
||||
return format_text($role->description, FORMAT_HTML, array('context'=>context_system::instance()));
|
||||
}
|
||||
|
||||
switch ($role->shortname) {
|
||||
case 'manager': return get_string('managerdescription', 'role');
|
||||
case 'coursecreator': return get_string('coursecreatorsdescription');
|
||||
case 'editingteacher': return get_string('defaultcourseteacherdescription');
|
||||
case 'teacher': return get_string('noneditingteacherdescription');
|
||||
case 'student': return get_string('defaultcoursestudentdescription');
|
||||
case 'guest': return get_string('guestdescription');
|
||||
case 'user': return get_string('authenticateduserdescription');
|
||||
case 'frontpage': return get_string('frontpageuserdescription', 'role');
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare list of roles for display, apply aliases and format text
|
||||
*
|
||||
* @param array $roleoptions array roleid => rolename or roleid => roleobject
|
||||
* @param context $context a context
|
||||
* @param array $roleoptions array roleid => roleobject (with optional coursealias), strings are accepted for backwards compatibility only
|
||||
* @param context|bool $context a context
|
||||
* @param int $rolenamedisplay
|
||||
* @param bool $returnmenu null means keep the same format as $roleoptions, true means id=>localname, false means id=>rolerecord
|
||||
* @return array Array of context-specific role names, or role objects with a ->localname field added.
|
||||
*/
|
||||
function role_fix_names($roleoptions, context $context, $rolenamedisplay = ROLENAME_ALIAS) {
|
||||
function role_fix_names($roleoptions, $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) {
|
||||
global $DB;
|
||||
|
||||
// Make sure we have a course context.
|
||||
$coursecontext = $context->get_course_context(false);
|
||||
if (empty($roleoptions)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Make sure we are working with an array roleid => name. Normally we
|
||||
// want to use the unlocalised name if the localised one is not present.
|
||||
$newnames = array();
|
||||
foreach ($roleoptions as $rid => $roleorname) {
|
||||
if ($rolenamedisplay != ROLENAME_ALIAS_RAW) {
|
||||
if (is_object($roleorname)) {
|
||||
$newnames[$rid] = $roleorname->name;
|
||||
} else {
|
||||
$newnames[$rid] = $roleorname;
|
||||
}
|
||||
} else {
|
||||
$newnames[$rid] = '';
|
||||
if (!$context or !$coursecontext = $context->get_course_context(false)) {
|
||||
$coursecontext = null;
|
||||
}
|
||||
|
||||
// We usually need all role columns...
|
||||
$first = reset($roleoptions);
|
||||
if ($returnmenu === null) {
|
||||
$returnmenu = !is_object($first);
|
||||
}
|
||||
|
||||
if (!is_object($first) or !property_exists($first, 'shortname')) {
|
||||
$allroles = get_all_roles($context);
|
||||
foreach ($roleoptions as $rid => $unused) {
|
||||
$roleoptions[$rid] = $allroles[$rid];
|
||||
}
|
||||
}
|
||||
|
||||
// If necessary, get the localised names.
|
||||
if ($rolenamedisplay != ROLENAME_ORIGINAL && !empty($coursecontext->id)) {
|
||||
// The get the relevant renames, and use them.
|
||||
$aliasnames = $DB->get_records('role_names', array('contextid'=>$coursecontext->id));
|
||||
foreach ($aliasnames as $alias) {
|
||||
if (isset($newnames[$alias->roleid])) {
|
||||
if ($rolenamedisplay == ROLENAME_ALIAS || $rolenamedisplay == ROLENAME_ALIAS_RAW) {
|
||||
$newnames[$alias->roleid] = $alias->name;
|
||||
} else if ($rolenamedisplay == ROLENAME_BOTH) {
|
||||
$newnames[$alias->roleid] = $alias->name . ' (' . $roleoptions[$alias->roleid] . ')';
|
||||
// Inject coursealias if necessary.
|
||||
if ($coursecontext and ($rolenamedisplay == ROLENAME_ALIAS_RAW or $rolenamedisplay == ROLENAME_ALIAS or $rolenamedisplay == ROLENAME_BOTH)) {
|
||||
$first = reset($roleoptions);
|
||||
if (!property_exists($first, 'coursealias')) {
|
||||
$aliasnames = $DB->get_records('role_names', array('contextid'=>$coursecontext->id));
|
||||
foreach ($aliasnames as $alias) {
|
||||
if (isset($roleoptions[$alias->roleid])) {
|
||||
$roleoptions[$alias->roleid]->coursealias = $alias->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, apply format_string and put the result in the right place.
|
||||
foreach ($roleoptions as $rid => $roleorname) {
|
||||
if ($rolenamedisplay != ROLENAME_ALIAS_RAW) {
|
||||
$newnames[$rid] = strip_tags(format_string($newnames[$rid]));
|
||||
}
|
||||
if (is_object($roleorname)) {
|
||||
$roleoptions[$rid]->localname = $newnames[$rid];
|
||||
} else {
|
||||
$roleoptions[$rid] = $newnames[$rid];
|
||||
}
|
||||
// Add localname property.
|
||||
foreach ($roleoptions as $rid => $role) {
|
||||
$roleoptions[$rid]->localname = role_get_name($role, $coursecontext, $rolenamedisplay);
|
||||
}
|
||||
return $roleoptions;
|
||||
|
||||
if (!$returnmenu) {
|
||||
return $roleoptions;
|
||||
}
|
||||
|
||||
$menu = array();
|
||||
foreach ($roleoptions as $rid => $role) {
|
||||
$menu[$rid] = $role->localname;
|
||||
}
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4404,19 +4548,14 @@ function get_role_names_with_caps_in_context($context, $capabilities) {
|
||||
global $DB;
|
||||
|
||||
$rolesthatcanrate = get_roles_with_caps_in_context($context, $capabilities);
|
||||
$allroles = $DB->get_records('role', null, 'sortorder DESC');
|
||||
|
||||
$allroles = array();
|
||||
$roles = $DB->get_records('role', null, 'sortorder DESC');
|
||||
foreach ($roles as $roleid=>$role) {
|
||||
$allroles[$roleid] = $role->name;
|
||||
}
|
||||
|
||||
$rolenames = array();
|
||||
$roles = array();
|
||||
foreach ($rolesthatcanrate as $r) {
|
||||
$rolenames[$r] = $allroles[$r];
|
||||
$roles[$r] = $allroles[$r];
|
||||
}
|
||||
$rolenames = role_fix_names($rolenames, $context);
|
||||
return $rolenames;
|
||||
|
||||
return role_fix_names($roles, $context, ROLENAME_ALIAS, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3880,10 +3880,7 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox {
|
||||
return true;
|
||||
}
|
||||
if ($roles = get_all_roles()) {
|
||||
$this->choices = array();
|
||||
foreach($roles as $role) {
|
||||
$this->choices[$role->id] = format_string($role->name);
|
||||
}
|
||||
$this->choices = role_fix_names($roles, null, ROLENAME_ORIGINAL, true);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -652,12 +652,13 @@ function get_courses_wmanagers($categoryid=0, $sort="c.sortorder ASC", $fields=a
|
||||
*
|
||||
*/
|
||||
$sql = "SELECT ctx.path, ctx.instanceid, ctx.contextlevel,
|
||||
r.id AS roleid, r.name as rolename,
|
||||
u.id AS userid, u.firstname, u.lastname
|
||||
r.id AS roleid, r.name AS rolename, r.shortname AS roleshortname,
|
||||
rn.name AS rolecoursealias, u.id AS userid, u.firstname, u.lastname
|
||||
FROM {role_assignments} ra
|
||||
JOIN {context} ctx ON ra.contextid = ctx.id
|
||||
JOIN {user} u ON ra.userid = u.id
|
||||
JOIN {role} r ON ra.roleid = r.id
|
||||
LEFT JOIN {role_names} rn ON (rn.contextid = ctx.id AND rn.roleid = r.id)
|
||||
LEFT OUTER JOIN {course} c
|
||||
ON (ctx.instanceid=c.id AND ctx.contextlevel=".CONTEXT_COURSE.")
|
||||
WHERE ( c.id IS NOT NULL";
|
||||
|
@ -1008,9 +1008,9 @@
|
||||
<TABLE NAME="role" COMMENT="moodle roles" PREVIOUS="post" NEXT="context">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="shortname"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" COMMENT="Empty names are automatically localised" NEXT="shortname"/>
|
||||
<FIELD NAME="shortname" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="description"/>
|
||||
<FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="shortname" NEXT="sortorder"/>
|
||||
<FIELD NAME="description" TYPE="text" NOTNULL="true" SEQUENCE="false" PREVIOUS="shortname" COMMENT="Empty descriptions may be automatically localised" NEXT="sortorder"/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="archetype"/>
|
||||
<FIELD NAME="archetype" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" COMMENT="Role archetype is used during install and role reset, marks admin role and helps in site settings" PREVIOUS="sortorder"/>
|
||||
</FIELDS>
|
||||
@ -1018,9 +1018,8 @@
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="sortorder" UNIQUE="true" FIELDS="sortorder" NEXT="name"/>
|
||||
<INDEX NAME="name" UNIQUE="true" FIELDS="name" COMMENT="Enforces the constraint that role names should be unique." PREVIOUS="sortorder" NEXT="shortname"/>
|
||||
<INDEX NAME="shortname" UNIQUE="true" FIELDS="shortname" COMMENT="Enforces the constraint that role shortnames must be unique." PREVIOUS="name"/>
|
||||
<INDEX NAME="sortorder" UNIQUE="true" FIELDS="sortorder" NEXT="shortname"/>
|
||||
<INDEX NAME="shortname" UNIQUE="true" FIELDS="shortname" COMMENT="Enforces the constraint that role shortnames must be unique." PREVIOUS="sortorder"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="context" COMMENT="one of these must be set" PREVIOUS="role" NEXT="context_temp">
|
||||
@ -2847,4 +2846,4 @@
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
|
@ -899,6 +899,21 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2012062500.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2012062500.04) {
|
||||
|
||||
// Define index name (unique) to be dropped form role
|
||||
$table = new xmldb_table('role');
|
||||
$index = new xmldb_index('name', XMLDB_INDEX_UNIQUE, array('name'));
|
||||
|
||||
// Conditionally launch drop index name
|
||||
if ($dbman->index_exists($table, $index)) {
|
||||
$dbman->drop_index($table, $index);
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2012062500.04);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -624,6 +624,10 @@ class accesslib_testcase extends advanced_testcase {
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_all_roles() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$allroles = get_all_roles();
|
||||
$this->assertEquals('array', gettype($allroles));
|
||||
$this->assertCount(8, $allroles); // there are 8 roles is standard install
|
||||
@ -636,6 +640,33 @@ class accesslib_testcase extends advanced_testcase {
|
||||
foreach($allroles as $roleid => $role) {
|
||||
$this->assertEquals($role->id, $roleid);
|
||||
}
|
||||
|
||||
$teacher = $DB->get_record('role', array('shortname'=>'teacher'), '*', MUST_EXIST);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$otherid = create_role('Other role', 'other', 'Some other role', '');
|
||||
$teacherename = (object)array('roleid'=>$teacher->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $teacherename);
|
||||
$otherrename = (object)array('roleid'=>$otherid, 'name'=>'Ostatní', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $otherrename);
|
||||
$renames = $DB->get_records_menu('role_names', array('contextid'=>$coursecontext->id), '', 'roleid,name');
|
||||
|
||||
$allroles = get_all_roles($coursecontext);
|
||||
$this->assertEquals('array', gettype($allroles));
|
||||
$this->assertCount(9, $allroles);
|
||||
$role = reset($allroles);
|
||||
$role = (array)$role;
|
||||
|
||||
$this->assertEquals(array('id', 'name', 'shortname', 'description', 'sortorder', 'archetype', 'coursealias'), array_keys($role), '', 0, 10, true);
|
||||
|
||||
foreach($allroles as $roleid => $role) {
|
||||
$this->assertEquals($role->id, $roleid);
|
||||
if (isset($renames[$roleid])) {
|
||||
$this->assertSame($renames[$roleid], $role->coursealias);
|
||||
} else {
|
||||
$this->assertSame(null, $role->coursealias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -680,19 +711,43 @@ class accesslib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$teacher = $DB->get_record('role', array('shortname'=>'teacher'), '*', MUST_EXIST);
|
||||
$allroles = $DB->get_records('role');
|
||||
$teacher = $DB->get_record('role', array('shortname'=>'teacher'), '*', MUST_EXIST);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
$otherid = create_role('Other role', 'other', 'Some other role', '');
|
||||
$teacherename = (object)array('roleid'=>$teacher->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $teacherename);
|
||||
$otherrename = (object)array('roleid'=>$otherid, 'name'=>'Ostatní', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $otherrename);
|
||||
$renames = $DB->get_records_menu('role_names', array('contextid'=>$coursecontext->id), '', 'roleid,name');
|
||||
|
||||
foreach ($allroles as $role) {
|
||||
$this->assertNotEmpty(role_get_name($role, $coursecontext));
|
||||
if ($role->id == $teacher->id) {
|
||||
$this->assertSame($teacherename->name, role_get_name($role, $coursecontext));
|
||||
// Get localised name from lang pack.
|
||||
$this->assertSame('', $role->name);
|
||||
$name = role_get_name($role, null, ROLENAME_ORIGINAL);
|
||||
$this->assertNotEmpty($name);
|
||||
$this->assertNotEquals($role->shortname, $name);
|
||||
|
||||
if (isset($renames[$role->id])) {
|
||||
$this->assertSame($renames[$role->id], role_get_name($role, $coursecontext));
|
||||
$this->assertSame($renames[$role->id], role_get_name($role, $coursecontext, ROLENAME_ALIAS));
|
||||
$this->assertSame($renames[$role->id], role_get_name($role, $coursecontext, ROLENAME_ALIAS_RAW));
|
||||
$this->assertSame("{$renames[$role->id]} ($name)", role_get_name($role, $coursecontext, ROLENAME_BOTH));
|
||||
} else {
|
||||
$this->assertSame($name, role_get_name($role, $coursecontext));
|
||||
$this->assertSame($name, role_get_name($role, $coursecontext, ROLENAME_ALIAS));
|
||||
$this->assertSame(null, role_get_name($role, $coursecontext, ROLENAME_ALIAS_RAW));
|
||||
$this->assertSame($name, role_get_name($role, $coursecontext, ROLENAME_BOTH));
|
||||
}
|
||||
$this->assertSame($name, role_get_name($role));
|
||||
$this->assertSame($name, role_get_name($role, $coursecontext, ROLENAME_ORIGINAL));
|
||||
$this->assertSame($name, role_get_name($role, null, ROLENAME_ORIGINAL));
|
||||
$this->assertSame($role->shortname, role_get_name($role, $coursecontext, ROLENAME_SHORT));
|
||||
$this->assertSame($role->shortname, role_get_name($role, null, ROLENAME_SHORT));
|
||||
$this->assertSame("$name ($role->shortname)", role_get_name($role, $coursecontext, ROLENAME_ORIGINALANDSHORT));
|
||||
$this->assertSame("$name ($role->shortname)", role_get_name($role, null, ROLENAME_ORIGINALANDSHORT));
|
||||
$this->assertSame(null, role_get_name($role, null, ROLENAME_ALIAS_RAW));
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,99 +788,22 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$rolenames[$role->id] = $role->name;
|
||||
}
|
||||
|
||||
/* TODO: unsupported! MDL-8249
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_SHORT);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $roles[$rolename->id];
|
||||
$this->assertSame($role->shortname, $rolename->localname);
|
||||
}
|
||||
*/
|
||||
|
||||
/* TODO: unsupported! MDL-8249
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_ORIGINALANDSHORT);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $roles[$rolename->id];
|
||||
$this->assertSame("$role->name ($role->shortname)", $rolename->localname);
|
||||
}
|
||||
*/
|
||||
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_ORIGINAL);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $roles[$roleid];
|
||||
$name = role_get_name($role, $frontcontext);
|
||||
$this->assertSame($name, $rolename->localname);
|
||||
}
|
||||
$fixed = role_fix_names($rolenames, $coursecontext, ROLENAME_ORIGINAL);
|
||||
$this->assertCount(count($rolenames), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$role = $roles[$roleid];
|
||||
$name = role_get_name($role, $frontcontext);
|
||||
$this->assertSame($name, $rolename);
|
||||
}
|
||||
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $roles[$roleid];
|
||||
$this->assertSame(role_get_name($role, $coursecontext), $rolename->localname);
|
||||
}
|
||||
$fixed = role_fix_names($rolenames, $coursecontext, ROLENAME_ALIAS);
|
||||
$this->assertCount(count($rolenames), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$role = $roles[$roleid];
|
||||
$this->assertSame(role_get_name($role, $coursecontext), $rolename);
|
||||
}
|
||||
|
||||
/* TODO: buggy! MDL-8249
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_BOTH);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $roles[$roleid];
|
||||
$name = role_get_name($role, $frontcontext);
|
||||
if (isset($renames[$roleid])) {
|
||||
$this->assertSame("$renames[$roleid] ($name)", $rolename->localname);
|
||||
} else {
|
||||
$this->assertSame(role_get_name($role, $coursecontext), $rolename->localname);
|
||||
$alltypes = array(ROLENAME_ALIAS, ROLENAME_ALIAS_RAW, ROLENAME_BOTH, ROLENAME_ORIGINAL, ROLENAME_ORIGINALANDSHORT, ROLENAME_SHORT);
|
||||
foreach ($alltypes as $type) {
|
||||
$fixed = role_fix_names($roles, $coursecontext, $type);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
$role = $allroles[$roleid];
|
||||
$name = role_get_name($role, $coursecontext, $type);
|
||||
$this->assertSame($name, $rolename->localname);
|
||||
}
|
||||
}
|
||||
*/
|
||||
$fixed = role_fix_names($rolenames, $coursecontext, ROLENAME_BOTH);
|
||||
$this->assertCount(count($rolenames), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$role = $roles[$roleid];
|
||||
if (isset($renames[$roleid])) {
|
||||
$name = role_get_name($role, $frontcontext);
|
||||
$this->assertSame("$renames[$roleid] ($name)", $rolename);
|
||||
} else {
|
||||
$this->assertSame(role_get_name($role, $coursecontext), $rolename);
|
||||
}
|
||||
}
|
||||
|
||||
$fixed = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS_RAW);
|
||||
$this->assertCount(count($roles), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$this->assertInstanceOf('stdClass', $rolename);
|
||||
if (isset($renames[$roleid])) {
|
||||
$this->assertSame($renames[$roleid], $rolename->localname);
|
||||
} else {
|
||||
$this->assertSame('', $rolename->localname);
|
||||
}
|
||||
}
|
||||
$fixed = role_fix_names($rolenames, $coursecontext, ROLENAME_ALIAS_RAW);
|
||||
$this->assertCount(count($rolenames), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
if (isset($renames[$roleid])) {
|
||||
$this->assertSame($renames[$roleid], $rolename);
|
||||
} else {
|
||||
$this->assertSame('', $rolename);
|
||||
$fixed = role_fix_names($rolenames, $coursecontext, $type);
|
||||
$this->assertCount(count($rolenames), $fixed);
|
||||
foreach($fixed as $roleid=>$rolename) {
|
||||
$role = $allroles[$roleid];
|
||||
$name = role_get_name($role, $coursecontext, $type);
|
||||
$this->assertSame($name, $rolename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -965,10 +943,6 @@ class accesslib_testcase extends advanced_testcase {
|
||||
}
|
||||
$alltypes = array(ROLENAME_ALIAS, ROLENAME_ALIAS_RAW, ROLENAME_BOTH, ROLENAME_ORIGINAL, ROLENAME_ORIGINALANDSHORT, ROLENAME_SHORT);
|
||||
foreach ($alltypes as $type) {
|
||||
if ($type == ROLENAME_SHORT or $type == ROLENAME_ORIGINALANDSHORT or $type == ROLENAME_BOTH) {
|
||||
// TODO: skip for now, remove after role_fix_names() is fixed and supports all types MDL-8249
|
||||
continue;
|
||||
}
|
||||
$rolenames = role_fix_names($allroles, $coursecontext, $type);
|
||||
$roles = get_assignable_roles($coursecontext, $type, false, $admin);
|
||||
foreach ($roles as $roleid=>$rolename) {
|
||||
@ -977,17 +951,19 @@ class accesslib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
// Verify counts.
|
||||
//TODO: test all types - ROLENAME_SHORT is borked here for example MDL-8249
|
||||
$roles = get_assignable_roles($coursecontext, ROLENAME_ALIAS, false, $admin);
|
||||
list($rolenames, $rolecounts, $nameswithcounts) = get_assignable_roles($coursecontext, ROLENAME_ALIAS, true, $admin);
|
||||
$this->assertEquals($roles, $rolenames);
|
||||
foreach ($rolenames as $roleid=>$name) {
|
||||
if ($roleid == $teacherrole->id or $roleid == $studentrole->id) {
|
||||
$this->assertEquals(1, $rolecounts[$roleid]);
|
||||
} else {
|
||||
$this->assertEquals(0, $rolecounts[$roleid]);
|
||||
$alltypes = array(ROLENAME_ALIAS, ROLENAME_ALIAS_RAW, ROLENAME_BOTH, ROLENAME_ORIGINAL, ROLENAME_ORIGINALANDSHORT, ROLENAME_SHORT);
|
||||
foreach ($alltypes as $type) {
|
||||
$roles = get_assignable_roles($coursecontext, $type, false, $admin);
|
||||
list($rolenames, $rolecounts, $nameswithcounts) = get_assignable_roles($coursecontext, $type, true, $admin);
|
||||
$this->assertEquals($roles, $rolenames);
|
||||
foreach ($rolenames as $roleid=>$name) {
|
||||
if ($roleid == $teacherrole->id or $roleid == $studentrole->id) {
|
||||
$this->assertEquals(1, $rolecounts[$roleid]);
|
||||
} else {
|
||||
$this->assertEquals(0, $rolecounts[$roleid]);
|
||||
}
|
||||
$this->assertEquals("$name ($rolecounts[$roleid])", $nameswithcounts[$roleid]);
|
||||
}
|
||||
$this->assertEquals("$name ($rolecounts[$roleid])", $nameswithcounts[$roleid]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,12 +1019,7 @@ class accesslib_testcase extends advanced_testcase {
|
||||
|
||||
if (isset($roles[$roleid])) {
|
||||
$coursecontext = $context->get_course_context(false);
|
||||
if ($coursecontext) {
|
||||
$this->assertEquals(role_get_name($role, $coursecontext), $roles[$roleid]);
|
||||
} else {
|
||||
// TODO: switch to role_get_name() once it supports all contexts and rolename types MDL-8249
|
||||
$this->assertEquals($role->name, $roles[$roleid]);
|
||||
}
|
||||
$this->assertEquals(role_get_name($role, $coursecontext), $roles[$roleid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1114,8 +1085,7 @@ class accesslib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
if (isset($roles[$roleid])) {
|
||||
//TODO: ROLENAME_SHORT borked! MDL-8249
|
||||
//$this->assertEquals($role->shortname, $roles[$roleid]);
|
||||
$this->assertEquals($role->shortname, $roles[$roleid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1129,10 +1099,6 @@ class accesslib_testcase extends advanced_testcase {
|
||||
|
||||
$alltypes = array(ROLENAME_ALIAS, ROLENAME_ALIAS_RAW, ROLENAME_BOTH, ROLENAME_ORIGINAL, ROLENAME_ORIGINALANDSHORT, ROLENAME_SHORT);
|
||||
foreach ($alltypes as $type) {
|
||||
if ($type == ROLENAME_SHORT or $type == ROLENAME_ORIGINALANDSHORT or $type == ROLENAME_BOTH) {
|
||||
// TODO: skip for now, remove after role_fix_names() is fixed and supports all types MDL-8249
|
||||
continue;
|
||||
}
|
||||
$rolenames = role_fix_names($allroles, $coursecontext, $type);
|
||||
$roles = get_overridable_roles($coursecontext, $type, false);
|
||||
foreach ($roles as $roleid=>$rolename) {
|
||||
@ -1229,8 +1195,6 @@ class accesslib_testcase extends advanced_testcase {
|
||||
$id2 = create_role('New student role', 'student2', 'New student description', 'student');
|
||||
set_role_contextlevels($id2, array(CONTEXT_COURSE));
|
||||
|
||||
//TODO: add role name alias MDL-8249
|
||||
|
||||
$allroles = get_all_roles();
|
||||
$expected = array($id2=>$allroles[$id2]);
|
||||
|
||||
@ -1253,6 +1217,126 @@ class accesslib_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting of role users.
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_role_users() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$otherid = create_role('Other role', 'other', 'Some other role', '');
|
||||
$teacherrename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $teacherrename);
|
||||
$otherrename = (object)array('roleid'=>$otherid, 'name'=>'Ostatní', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $otherrename);
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
role_assign($teacherrole->id, $user1->id, $coursecontext->id);
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
role_assign($teacherrole->id, $user2->id, $systemcontext->id);
|
||||
|
||||
$users = get_role_users($teacherrole->id, $coursecontext);
|
||||
$this->assertCount(1, $users);
|
||||
$user = reset($users);
|
||||
$userid = key($users);
|
||||
$this->assertEquals($userid, $user->id);
|
||||
$this->assertEquals($teacherrole->id, $user->roleid);
|
||||
$this->assertEquals($teacherrole->name, $user->rolename);
|
||||
$this->assertEquals($teacherrole->shortname, $user->roleshortname);
|
||||
$this->assertEquals($teacherrename->name, $user->rolecoursealias);
|
||||
|
||||
$users = get_role_users($teacherrole->id, $coursecontext, true);
|
||||
$this->assertCount(2, $users);
|
||||
|
||||
$users = get_role_users($teacherrole->id, $coursecontext, false, 'u.id, u.email, u.idnumber', 'u.idnumber', null, 1, 0, 10, 'u.deleted = 0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test used role query.
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_roles_used_in_context() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$systemcontext = context_system::instance();
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$otherid = create_role('Other role', 'other', 'Some other role', '');
|
||||
$teacherrename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $teacherrename);
|
||||
$otherrename = (object)array('roleid'=>$otherid, 'name'=>'Ostatní', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $otherrename);
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
role_assign($teacherrole->id, $user1->id, $coursecontext->id);
|
||||
|
||||
$roles = get_roles_used_in_context($coursecontext);
|
||||
$this->assertCount(1, $roles);
|
||||
$role = reset($roles);
|
||||
$roleid = key($roles);
|
||||
$this->assertEquals($roleid, $role->id);
|
||||
$this->assertEquals($teacherrole->id, $role->id);
|
||||
$this->assertEquals($teacherrole->name, $role->name);
|
||||
$this->assertEquals($teacherrole->shortname, $role->shortname);
|
||||
$this->assertEquals($teacherrole->sortorder, $role->sortorder);
|
||||
$this->assertEquals($teacherrename->name, $role->coursealias);
|
||||
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
role_assign($teacherrole->id, $user2->id, $systemcontext->id);
|
||||
role_assign($otherid, $user2->id, $systemcontext->id);
|
||||
|
||||
$roles = get_roles_used_in_context($systemcontext);
|
||||
$this->assertCount(2, $roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test roles used in course.
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_user_roles_in_course() {
|
||||
global $DB, $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$teacherrole = $DB->get_record('role', array('shortname'=>'editingteacher'), '*', MUST_EXIST);
|
||||
$studentrole = $DB->get_record('role', array('shortname'=>'student'), '*', MUST_EXIST);
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$teacherrename = (object)array('roleid'=>$teacherrole->id, 'name'=>'Učitel', 'contextid'=>$coursecontext->id);
|
||||
$DB->insert_record('role_names', $teacherrename);
|
||||
|
||||
$roleids = explode(',', $CFG->profileroles); // should include teacher and student in new installs
|
||||
$this->assertTrue(in_array($teacherrole->id, $roleids));
|
||||
$this->assertTrue(in_array($studentrole->id, $roleids));
|
||||
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
role_assign($teacherrole->id, $user1->id, $coursecontext->id);
|
||||
role_assign($studentrole->id, $user1->id, $coursecontext->id);
|
||||
$user2 = $this->getDataGenerator()->create_user();
|
||||
role_assign($studentrole->id, $user2->id, $coursecontext->id);
|
||||
$user3 = $this->getDataGenerator()->create_user();
|
||||
|
||||
$roles = get_user_roles_in_course($user1->id, $course->id);
|
||||
$this->assertEquals(1, preg_match_all('/,/', $roles));
|
||||
$this->assertTrue(strpos($roles, role_get_name($teacherrole, $coursecontext)) !== false);
|
||||
|
||||
$roles = get_user_roles_in_course($user2->id, $course->id);
|
||||
$this->assertEquals(0, preg_match_all('/,/', $roles));
|
||||
$this->assertTrue(strpos($roles, role_get_name($studentrole, $coursecontext)) !== false);
|
||||
|
||||
$roles = get_user_roles_in_course($user3->id, $course->id);
|
||||
$this->assertSame('', $roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test has_capability(), has_any_capability() and has_all_capabilities().
|
||||
*/
|
||||
|
@ -438,10 +438,10 @@ function url_get_variable_options($config) {
|
||||
);
|
||||
|
||||
if ($config->rolesinparams) {
|
||||
$roles = get_all_roles();
|
||||
$roles = role_fix_names(get_all_roles());
|
||||
$roleoptions = array();
|
||||
foreach ($roles as $role) {
|
||||
$roleoptions['course'.$role->shortname] = get_string('yourwordforx', '', $role->name);
|
||||
$roleoptions['course'.$role->shortname] = get_string('yourwordforx', '', $role->localname);
|
||||
}
|
||||
$options[get_string('roles')] = $roleoptions;
|
||||
}
|
||||
@ -509,9 +509,8 @@ function url_get_variable_values($url, $cm, $course, $config) {
|
||||
|
||||
//hmm, this is pretty fragile and slow, why do we need it here??
|
||||
if ($config->rolesinparams) {
|
||||
$roles = get_all_roles();
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
|
||||
$roles = role_fix_names(get_all_roles($coursecontext), $coursecontext, ROLENAME_ALIAS);
|
||||
foreach ($roles as $role) {
|
||||
$values['course'.$role->shortname] = $role->localname;
|
||||
}
|
||||
|
@ -137,19 +137,11 @@ if (strtotime('-1 year',$now) >= $minlog) {
|
||||
$timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
|
||||
}
|
||||
|
||||
$roleoptions = array();
|
||||
// TODO: we need a new list of roles that are visible here
|
||||
if ($roles = get_roles_used_in_context($context)) {
|
||||
foreach ($roles as $r) {
|
||||
$roleoptions[$r->id] = $r->name;
|
||||
}
|
||||
}
|
||||
$roles = get_roles_used_in_context($context);
|
||||
$guestrole = get_guest_role();
|
||||
if (empty($roleoptions[$guestrole->id])) {
|
||||
$roleoptions[$guestrole->id] = $guestrole->name;
|
||||
}
|
||||
|
||||
$roleoptions = role_fix_names($roleoptions, $context);
|
||||
$roles[$guestrole->id] = $guestrole;
|
||||
$roleoptions = role_fix_names($roles, $context, ROLENAME_ALIAS, true);
|
||||
|
||||
// print first controls.
|
||||
echo '<form class="participationselectform" action="index.php" method="get"><div>'."\n".
|
||||
|
@ -836,6 +836,7 @@ function report_security_check_riskbackup($detailed=false) {
|
||||
if ($systemroles) {
|
||||
$links = array();
|
||||
foreach ($systemroles as $role) {
|
||||
$role->name = role_get_name($role);
|
||||
$role->url = "$CFG->wwwroot/$CFG->admin/roles/manage.php?action=edit&roleid=$role->id";
|
||||
$links[] = '<li>'.get_string('check_riskbackup_editrole', 'report_security', $role).'</li>';
|
||||
}
|
||||
@ -848,10 +849,9 @@ function report_security_check_riskbackup($detailed=false) {
|
||||
if ($overriddenroles) {
|
||||
$links = array();
|
||||
foreach ($overriddenroles as $role) {
|
||||
$role->name = $role->localname;
|
||||
$context = get_context_instance_by_id($role->contextid);
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
$role->name = role_get_name($role, $context);
|
||||
}
|
||||
$role->name = role_get_name($role, $context, ROLENAME_BOTH);
|
||||
$role->contextname = print_context_name($context);
|
||||
$role->url = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$role->contextid&roleid=$role->id";
|
||||
$links[] = '<li>'.get_string('check_riskbackup_editoverride', 'report_security', $role).'</li>';
|
||||
|
@ -125,11 +125,7 @@ if (empty($param->crosstab)) {
|
||||
$times = array();
|
||||
$roles = array();
|
||||
$missedlines = array();
|
||||
$rolenames = get_all_roles();
|
||||
foreach ($rolenames as $r) {
|
||||
$rolenames[$r->id] = $r->name;
|
||||
}
|
||||
$rolenames = role_fix_names($rolenames, get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
$rolenames = role_fix_names(get_all_roles($coursecontext), $coursecontext, ROLENAME_ALIAS, true);
|
||||
foreach ($stats as $stat) {
|
||||
$data[$stat->roleid][$stat->timeend] = $stat->line1;
|
||||
if (!empty($stat->zerofixed)) {
|
||||
|
@ -244,11 +244,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
|
||||
$roles = array();
|
||||
$times = array();
|
||||
$missedlines = array();
|
||||
$rolenames = get_all_roles();
|
||||
foreach ($rolenames as $r) {
|
||||
$rolenames[$r->id] = $r->name;
|
||||
}
|
||||
$rolenames = role_fix_names($rolenames, get_context_instance(CONTEXT_COURSE, $course->id));
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
$rolenames = role_fix_names(get_all_roles($coursecontext), $coursecontext, ROLENAME_ALIAS, true);
|
||||
foreach ($stats as $stat) {
|
||||
if (!empty($stat->zerofixed)) {
|
||||
$missedlines[] = $stat->timeend;
|
||||
|
@ -64,22 +64,13 @@
|
||||
|
||||
$rolenamesurl = new moodle_url("$CFG->wwwroot/user/index.php?contextid=$context->id&sifirst=&silast=");
|
||||
|
||||
$allroles = get_all_roles();
|
||||
$roles = get_profile_roles($context);
|
||||
$allrolenames = array();
|
||||
$rolenames = role_fix_names(get_profile_roles($context), $context, ROLENAME_ALIAS, true);
|
||||
if ($isfrontpage) {
|
||||
$rolenames = array(0=>get_string('allsiteusers', 'role'));
|
||||
} else {
|
||||
$rolenames = array(0=>get_string('allparticipants'));
|
||||
}
|
||||
|
||||
foreach ($allroles as $role) {
|
||||
$allrolenames[$role->id] = strip_tags(role_get_name($role, $context)); // Used in menus etc later on
|
||||
if (isset($roles[$role->id])) {
|
||||
$rolenames[$role->id] = $allrolenames[$role->id];
|
||||
}
|
||||
}
|
||||
|
||||
// make sure other roles may not be selected by any means
|
||||
if (empty($rolenames[$roleid])) {
|
||||
print_error('noparticipants');
|
||||
|
@ -822,7 +822,7 @@ class group_non_members_selector extends groups_user_selector_base {
|
||||
|
||||
// Build the SQL
|
||||
list($enrolsql, $enrolparams) = get_enrolled_sql($context);
|
||||
$fields = "SELECT r.id AS roleid, r.shortname AS roleshortname, r.name AS rolename, u.id AS userid,
|
||||
$fields = "SELECT r.id AS roleid, u.id AS userid,
|
||||
" . $this->required_fields_sql('u') . ",
|
||||
(SELECT count(igm.groupid)
|
||||
FROM {groups_members} igm
|
||||
|
@ -30,7 +30,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$version = 2012062500.03; // YYYYMMDD = weekly release date of this DEV branch
|
||||
$version = 2012062500.04; // YYYYMMDD = weekly release date of this DEV branch
|
||||
// RR = release increments - 00 in DEV branches
|
||||
// .XX = incremental changes
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user