Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…3_STABLE
  • Loading branch information...
commit 49042e1c8c55fde8284a22352c26817a07a39db7 2 parents 0302aca + f017aa4
Dan Poltawski authored January 22, 2013
17  course/lib.php
@@ -3156,13 +3156,16 @@ function moveto_module($mod, $section, $beforemod=NULL) {
3156 3156
 
3157 3157
 /// Update module itself if necessary
3158 3158
 
3159  
-    if ($mod->section != $section->id) {
3160  
-        $mod->section = $section->id;
3161  
-        $DB->update_record("course_modules", $mod);
3162  
-        // if moving to a hidden section then hide module
3163  
-        if (!$section->visible) {
3164  
-            set_coursemodule_visible($mod->id, 0);
3165  
-        }
  3159
+    // If moving to a hidden section then hide module.
  3160
+    if (!$section->visible && $mod->visible) {
  3161
+        // Set this in the object because it is sent as a response to ajax calls.
  3162
+        set_coursemodule_visible($mod->id, 0, true);
  3163
+        $mod->visible = 0;
  3164
+    }
  3165
+    if ($section->visible && !$mod->visible) {
  3166
+        set_coursemodule_visible($mod->id, 1, true);
  3167
+        // Set this in the object because it is sent as a response to ajax calls.
  3168
+        $mod->visible = $mod->visibleold;
3166 3169
     }
3167 3170
 
3168 3171
 /// Add the module into the new section
1  course/modedit.php
@@ -481,6 +481,7 @@
481 481
         // make sure visibility is set correctly (in particular in calendar)
482 482
         // note: allow them to set it even without moodle/course:activityvisibility
483 483
         set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
  484
+        $DB->set_field('course_modules', 'visibleold', 1, array('id' => $fromform->coursemodule));
484 485
 
485 486
         if (isset($fromform->cmidnumber)) { //label
486 487
             // set cm idnumber - uniqueness is already verified by form validation
1  course/rest.php
@@ -138,6 +138,7 @@
138 138
                         }
139 139
 
140 140
                         moveto_module($cm, $section, $beforemod);
  141
+                        echo json_encode(array('visible' => $cm->visible));
141 142
                         break;
142 143
                     case 'gettitle':
143 144
                         require_capability('moodle/course:manageactivities', $modcontext);
3  course/yui/dragdrop/dragdrop.js
@@ -385,6 +385,9 @@ YUI.add('moodle-course-dragdrop', function(Y) {
385 385
                         spinner.show();
386 386
                     },
387 387
                     success: function(tid, response) {
  388
+                        var responsetext = Y.JSON.parse(response.responseText);
  389
+                        var params = {element: dragnode, visible: responsetext.visible};
  390
+                        M.course.coursebase.invoke_function('set_visibility_resource_ui', params);
388 391
                         this.unlock_drag_handle(drag, CSS.EDITINGMOVE);
389 392
                         window.setTimeout(function(e) {
390 393
                             spinner.hide();
20  course/yui/toolboxes/toolboxes.js
@@ -591,6 +591,26 @@ YUI.add('moodle-course-toolboxes', function(Y) {
591 591
                 }
592 592
             }, this);
593 593
             listenevents.push(thisevent);
  594
+        },
  595
+        /**
  596
+         * Set the visibility of the current resource (identified by the element)
  597
+         * to match the hidden parameter (this is not a toggle).
  598
+         * Only changes the visibility in the browser (no ajax update).
  599
+         * @param args An object with 'element' being the A node containing the resource
  600
+         *             and 'visible' being the state that the visiblity should be set to.
  601
+         * @return void
  602
+         */
  603
+        set_visibility_resource_ui: function(args) {
  604
+            var element = args.element;
  605
+            var shouldbevisible = args.visible;
  606
+            var buttonnode = element.one(CSS.SHOW);
  607
+            var visible = (buttonnode === null);
  608
+            if (visible) {
  609
+                buttonnode = element.one(CSS.HIDE);
  610
+            }
  611
+            if (visible != shouldbevisible) {
  612
+                this.toggle_hide_resource_ui(buttonnode);
  613
+            }
594 614
         }
595 615
     }, {
596 616
         NAME : 'course-resource-toolbox',

0 notes on commit 49042e1

Please sign in to comment.
Something went wrong with that request. Please try again.