Permalink
Browse files

MDL-37085 fixed mess with code overwriting cm_info properties

In case when groupmode is forced by the course we should take it from the
course and not overwrite cm_info::groupmode externally
  • Loading branch information...
1 parent 7e29340 commit 5c016ab30d8bab6ffd2c6ab06bb02cce83fe8bb7 @marinaglancy marinaglancy committed Dec 13, 2012
View
11 blocks/site_main_menu/block_site_main_menu.php
@@ -65,9 +65,6 @@ function get_content() {
$modinfo = get_fast_modinfo($course);
$section = $modinfo->get_section_info(0);
- $groupbuttons = $course->groupmode;
- $groupbuttonslink = (!$course->groupmodeforce);
-
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
@@ -90,14 +87,6 @@ function get_content() {
continue;
}
if (!$ismoving) {
- if ($groupbuttons) {
- if (! $mod->groupmodelink = $groupbuttonslink) {
- $mod->groupmode = $course->groupmode;
- }
-
- } else {
- $mod->groupmode = false;
- }
$editbuttons = '<div class="buttons">'.make_editing_buttons($mod, true, true).'</div>';
} else {
$editbuttons = '';
View
11 blocks/social_activities/block_social_activities.php
@@ -67,9 +67,6 @@ function get_content() {
$modinfo = get_fast_modinfo($course);
$section = $modinfo->get_section_info(0);
- $groupbuttons = $course->groupmode;
- $groupbuttonslink = (!$course->groupmodeforce);
-
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
@@ -92,14 +89,6 @@ function get_content() {
continue;
}
if (!$ismoving) {
- if ($groupbuttons) {
- if (! $mod->groupmodelink = $groupbuttonslink) {
- $mod->groupmode = $course->groupmode;
- }
-
- } else {
- $mod->groupmode = false;
- }
$editbuttons = '<br />'.make_editing_buttons($mod, true, true);
} else {
$editbuttons = '';
View
39 course/lib.php
@@ -1339,17 +1339,13 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
static $initialised;
- static $groupbuttons;
- static $groupbuttonslink;
static $isediting;
static $ismoving;
static $movingpix;
static $strmovefull;
static $strunreadpostsone;
if (!isset($initialised)) {
- $groupbuttons = ($course->groupmode or (!$course->groupmodeforce));
- $groupbuttonslink = (!$course->groupmodeforce);
$isediting = $PAGE->user_is_editing();
$ismoving = $isediting && ismoving($course->id);
if ($ismoving) {
@@ -1504,13 +1500,13 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
// If specified, display extra content after link.
- if ($content) {
- $contentpart = html_writer::tag('div', $content, array('class' =>
- trim('contentafterlink ' . $textclasses)));
- }
- } else {
- // No link, so display only content.
- $contentpart = html_writer::tag('div', $accesstext . $content, array('class' => $textclasses));
+ if ($content) {
+ $contentpart = html_writer::tag('div', $content, array('class' =>
+ trim('contentafterlink ' . $textclasses)));
+ }
+ } else {
+ // No link, so display only content.
+ $contentpart = html_writer::tag('div', $accesstext . $content, array('class' => $textclasses));
}
// Module can put text after the link (e.g. forum unread)
@@ -1530,14 +1526,6 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
if ($isediting) {
- if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
- if (! $mod->groupmodelink = $groupbuttonslink) {
- $mod->groupmode = $course->groupmode;
- }
-
- } else {
- $mod->groupmode = false;
- }
echo make_editing_buttons($mod, $absolute, true, $mod->indent, $sectionreturn);
echo $mod->get_after_edit_icons();
}
@@ -3074,14 +3062,19 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
}
// groupmode
- if ($hasmanageactivities and $mod->groupmode !== false) {
- if ($mod->groupmode == SEPARATEGROUPS) {
+ if ($hasmanageactivities and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
+ if ($mod->coursegroupmodeforce) {
+ $modgroupmode = $mod->coursegroupmode;
+ } else {
+ $modgroupmode = $mod->groupmode;
+ }
+ if ($modgroupmode == SEPARATEGROUPS) {
$groupmode = NOGROUPS;
$grouptitle = $str->groupsseparate;
$forcedgrouptitle = $str->forcedgroupsseparate;
$actionname = 'groupsseparate';
$groupimage = 't/groups';
- } else if ($mod->groupmode == VISIBLEGROUPS) {
+ } else if ($modgroupmode == VISIBLEGROUPS) {
$groupmode = SEPARATEGROUPS;
$grouptitle = $str->groupsvisible;
$forcedgrouptitle = $str->forcedgroupsvisible;
@@ -3094,7 +3087,7 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) {
$actionname = 'groupsnone';
$groupimage = 't/groupn';
}
- if ($mod->groupmodelink) {
+ if (!$mod->coursegroupmodeforce) {
$actions[$actionname] = new action_link(
new moodle_url($baseurl, array('id' => $mod->id, 'groupmode' => $groupmode)),
new pix_icon($groupimage, $grouptitle, 'moodle', array('class' => 'iconsmall', 'title' => '')),
View
18 lib/modinfolib.php
@@ -501,6 +501,22 @@ class cm_info extends stdClass {
public $groupmembersonly;
/**
+ * Indicates whether the course containing the module has forced the groupmode
+ * This means that cm_info::$groupmode should be ignored and cm_info::$coursegroupmode be
+ * used instead
+ * @var bool
+ */
+ public $coursegroupmodeforce;
+
+ /**
+ * Group mode (one of the constants NONE, SEPARATEGROUPS, or VISIBLEGROUPS) - from
+ * course table - as specified for the course containing the module
+ * Effective only if cm_info::$coursegroupmodeforce is set
+ * @var int
+ */
+ public $coursegroupmode;
+
+ /**
* Indent level on course page (0 = no indent) - from course_modules table
* @var int
*/
@@ -1063,6 +1079,8 @@ public function __construct(course_modinfo $modinfo, $course, $mod, $info) {
$this->groupmode = isset($mod->groupmode) ? $mod->groupmode : 0;
$this->groupingid = isset($mod->groupingid) ? $mod->groupingid : 0;
$this->groupmembersonly = isset($mod->groupmembersonly) ? $mod->groupmembersonly : 0;
+ $this->coursegroupmodeforce = $course->groupmodeforce;
+ $this->coursegroupmode = $course->groupmode;
$this->indent = isset($mod->indent) ? $mod->indent : 0;
$this->extra = isset($mod->extra) ? $mod->extra : '';
$this->extraclasses = isset($mod->extraclasses) ? $mod->extraclasses : '';

0 comments on commit 5c016ab

Please sign in to comment.