Skip to content

Commit

Permalink
Merge branch 'MDL-37430-23' of github.com:damyon/moodle into MOODLE_2…
Browse files Browse the repository at this point in the history
…3_STABLE
  • Loading branch information
danpoltawski committed Jan 22, 2013
2 parents 0302aca + f017aa4 commit 49042e1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
17 changes: 10 additions & 7 deletions course/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3156,13 +3156,16 @@ function moveto_module($mod, $section, $beforemod=NULL) {


/// Update module itself if necessary /// Update module itself if necessary


if ($mod->section != $section->id) { // If moving to a hidden section then hide module.
$mod->section = $section->id; if (!$section->visible && $mod->visible) {
$DB->update_record("course_modules", $mod); // Set this in the object because it is sent as a response to ajax calls.
// if moving to a hidden section then hide module set_coursemodule_visible($mod->id, 0, true);
if (!$section->visible) { $mod->visible = 0;
set_coursemodule_visible($mod->id, 0); }
} if ($section->visible && !$mod->visible) {
set_coursemodule_visible($mod->id, 1, true);
// Set this in the object because it is sent as a response to ajax calls.
$mod->visible = $mod->visibleold;
} }


/// Add the module into the new section /// Add the module into the new section
Expand Down
1 change: 1 addition & 0 deletions course/modedit.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
// make sure visibility is set correctly (in particular in calendar) // make sure visibility is set correctly (in particular in calendar)
// note: allow them to set it even without moodle/course:activityvisibility // note: allow them to set it even without moodle/course:activityvisibility
set_coursemodule_visible($fromform->coursemodule, $fromform->visible); set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
$DB->set_field('course_modules', 'visibleold', 1, array('id' => $fromform->coursemodule));


if (isset($fromform->cmidnumber)) { //label if (isset($fromform->cmidnumber)) { //label
// set cm idnumber - uniqueness is already verified by form validation // set cm idnumber - uniqueness is already verified by form validation
Expand Down
1 change: 1 addition & 0 deletions course/rest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
} }


moveto_module($cm, $section, $beforemod); moveto_module($cm, $section, $beforemod);
echo json_encode(array('visible' => $cm->visible));
break; break;
case 'gettitle': case 'gettitle':
require_capability('moodle/course:manageactivities', $modcontext); require_capability('moodle/course:manageactivities', $modcontext);
Expand Down
3 changes: 3 additions & 0 deletions course/yui/dragdrop/dragdrop.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ YUI.add('moodle-course-dragdrop', function(Y) {
spinner.show(); spinner.show();
}, },
success: function(tid, response) { success: function(tid, response) {
var responsetext = Y.JSON.parse(response.responseText);
var params = {element: dragnode, visible: responsetext.visible};
M.course.coursebase.invoke_function('set_visibility_resource_ui', params);
this.unlock_drag_handle(drag, CSS.EDITINGMOVE); this.unlock_drag_handle(drag, CSS.EDITINGMOVE);
window.setTimeout(function(e) { window.setTimeout(function(e) {
spinner.hide(); spinner.hide();
Expand Down
20 changes: 20 additions & 0 deletions course/yui/toolboxes/toolboxes.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -591,6 +591,26 @@ YUI.add('moodle-course-toolboxes', function(Y) {
} }
}, this); }, this);
listenevents.push(thisevent); listenevents.push(thisevent);
},
/**
* Set the visibility of the current resource (identified by the element)
* to match the hidden parameter (this is not a toggle).
* Only changes the visibility in the browser (no ajax update).
* @param args An object with 'element' being the A node containing the resource
* and 'visible' being the state that the visiblity should be set to.
* @return void
*/
set_visibility_resource_ui: function(args) {
var element = args.element;
var shouldbevisible = args.visible;
var buttonnode = element.one(CSS.SHOW);
var visible = (buttonnode === null);
if (visible) {
buttonnode = element.one(CSS.HIDE);
}
if (visible != shouldbevisible) {
this.toggle_hide_resource_ui(buttonnode);
}
} }
}, { }, {
NAME : 'course-resource-toolbox', NAME : 'course-resource-toolbox',
Expand Down

0 comments on commit 49042e1

Please sign in to comment.