Permalink
Browse files

Merge branch 'MDL-37430-23' of github.com:damyon/moodle into MOODLE_2…

…3_STABLE
  • Loading branch information...
danpoltawski committed Jan 22, 2013
2 parents 0302aca + f017aa4 commit 49042e1c8c55fde8284a22352c26817a07a39db7
Showing with 35 additions and 7 deletions.
  1. +10 −7 course/lib.php
  2. +1 −0 course/modedit.php
  3. +1 −0 course/rest.php
  4. +3 −0 course/yui/dragdrop/dragdrop.js
  5. +20 −0 course/yui/toolboxes/toolboxes.js
View
@@ -3156,13 +3156,16 @@ function moveto_module($mod, $section, $beforemod=NULL) {
/// Update module itself if necessary
if ($mod->section != $section->id) {
$mod->section = $section->id;
$DB->update_record("course_modules", $mod);
// if moving to a hidden section then hide module
if (!$section->visible) {
set_coursemodule_visible($mod->id, 0);
}
// If moving to a hidden section then hide module.
if (!$section->visible && $mod->visible) {
// Set this in the object because it is sent as a response to ajax calls.
set_coursemodule_visible($mod->id, 0, true);
$mod->visible = 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
View
@@ -481,6 +481,7 @@
// make sure visibility is set correctly (in particular in calendar)
// note: allow them to set it even without moodle/course:activityvisibility
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
$DB->set_field('course_modules', 'visibleold', 1, array('id' => $fromform->coursemodule));
if (isset($fromform->cmidnumber)) { //label
// set cm idnumber - uniqueness is already verified by form validation
View
@@ -138,6 +138,7 @@
}
moveto_module($cm, $section, $beforemod);
echo json_encode(array('visible' => $cm->visible));
break;
case 'gettitle':
require_capability('moodle/course:manageactivities', $modcontext);
@@ -385,6 +385,9 @@ YUI.add('moodle-course-dragdrop', function(Y) {
spinner.show();
},
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);
window.setTimeout(function(e) {
spinner.hide();
@@ -591,6 +591,26 @@ YUI.add('moodle-course-toolboxes', function(Y) {
}
}, this);
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',

0 comments on commit 49042e1

Please sign in to comment.