mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'w28_MDL-8249_m24_roletranslations' of git://github.com/skodak/moodle
Conflicts: lib/db/upgrade.php version.php
This commit is contained in:
commit
e1980f8bb9
37 changed files with 631 additions and 422 deletions
|
@ -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>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2530,32 +2530,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) {
|
||||
|
@ -2564,12 +2558,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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue