mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
Merge branch 'wip-MDL-60515-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
58280ae0b8
11 changed files with 365 additions and 48 deletions
|
@ -109,6 +109,7 @@ class behat_partial_named_selector extends \Behat\Mink\Selector\PartialNamedSele
|
|||
'text' => 'text',
|
||||
'xpath_element' => 'xpath_element',
|
||||
'form_row' => 'form_row',
|
||||
'autocomplete_selection' => 'autocomplete_selection',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -178,6 +179,9 @@ XPATH
|
|||
XPATH
|
||||
, 'message_area_action' => <<<XPATH
|
||||
.//div[@data-region='messaging-area']/descendant::*[@data-action = %locator%]
|
||||
XPATH
|
||||
, 'autocomplete_selection' => <<<XPATH
|
||||
.//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'form-autocomplete-selection', ' '))]/span[@role='listitem'][contains(normalize-space(.), %locator%)]
|
||||
XPATH
|
||||
);
|
||||
|
||||
|
|
|
@ -2423,23 +2423,56 @@ function print_group_picture($group, $courseid, $large=false, $return=false, $li
|
|||
}
|
||||
}
|
||||
|
||||
$pictureurl = get_group_picture_url($group, $courseid, $large);
|
||||
|
||||
// If there is no picture, do nothing.
|
||||
if (!isset($pictureurl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$groupname = s($group->name);
|
||||
$pictureimage = html_writer::img($pictureurl, $groupname, ['title' => $groupname]);
|
||||
|
||||
$output = '';
|
||||
if ($link or has_capability('moodle/site:accessallgroups', $context)) {
|
||||
$linkurl = new moodle_url('/user/index.php', ['id' => $courseid, 'group' => $group->id]);
|
||||
$output .= html_writer::link($linkurl, $pictureimage);
|
||||
} else {
|
||||
$output .= $pictureimage;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the url to the group picture.
|
||||
*
|
||||
* @param stdClass $group A group object.
|
||||
* @param int $courseid The course ID for the group.
|
||||
* @param bool $large A large or small group picture? Default is small.
|
||||
* @return moodle_url Returns the url for the group picture.
|
||||
*/
|
||||
function get_group_picture_url($group, $courseid, $large = false) {
|
||||
global $CFG;
|
||||
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
// If there is no picture, do nothing.
|
||||
if (!$group->picture) {
|
||||
return '';
|
||||
return;
|
||||
}
|
||||
|
||||
// If picture is hidden, only show to those with course:managegroups.
|
||||
if ($group->hidepicture and !has_capability('moodle/course:managegroups', $context)) {
|
||||
return '';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($link or has_capability('moodle/site:accessallgroups', $context)) {
|
||||
$output = '<a href="'. $CFG->wwwroot .'/user/index.php?id='. $courseid .'&group='. $group->id .'">';
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
if ($large) {
|
||||
$file = 'f1';
|
||||
} else {
|
||||
|
@ -2448,18 +2481,7 @@ function print_group_picture($group, $courseid, $large=false, $return=false, $li
|
|||
|
||||
$grouppictureurl = moodle_url::make_pluginfile_url($context->id, 'group', 'icon', $group->id, '/', $file);
|
||||
$grouppictureurl->param('rev', $group->picture);
|
||||
$output .= '<img class="grouppicture" src="'.$grouppictureurl.'"'.
|
||||
' alt="'.s(get_string('group').' '.$group->name).'" title="'.s($group->name).'"/>';
|
||||
|
||||
if ($link or has_capability('moodle/site:accessallgroups', $context)) {
|
||||
$output .= '</a>';
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
} else {
|
||||
echo $output;
|
||||
}
|
||||
return $grouppictureurl;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue