mod-data MDL-25671 disable editor in data list template editor will not save the...
authorDongsheng Cai <dongsheng@moodle.com>
Wed, 2 Feb 2011 07:46:11 +0000 (15:46 +0800)
committerDongsheng Cai <dongsheng@moodle.com>
Wed, 2 Feb 2011 14:17:15 +0000 (22:17 +0800)
mod/data/templates.php

index 90cf012..9a1ee1e 100755 (executable)
@@ -29,7 +29,8 @@ require_once('lib.php');
 $id    = optional_param('id', 0, PARAM_INT);  // course module id
 $d     = optional_param('d', 0, PARAM_INT);   // database id
 $mode  = optional_param('mode', 'singletemplate', PARAM_ALPHA);
 $id    = optional_param('id', 0, PARAM_INT);  // course module id
 $d     = optional_param('d', 0, PARAM_INT);   // database id
 $mode  = optional_param('mode', 'singletemplate', PARAM_ALPHA);
-$disableeditor  = optional_param('switcheditor', false, PARAM_ALPHA);
+$disableeditor = optional_param('switcheditor', false, PARAM_RAW);
+$enableeditor = optional_param('useeditor', false, PARAM_RAW);
 
 $url = new moodle_url('/mod/data/templates.php');
 if ($mode !== 'singletemplate') {
 
 $url = new moodle_url('/mod/data/templates.php');
 if ($mode !== 'singletemplate') {
@@ -130,10 +131,13 @@ if (($mytemplate = data_submitted()) && confirm_sesskey()) {
 
         // Check for multiple tags, only need to check for add template.
         if ($mode != 'addtemplate' or data_tags_check($data->id, $newtemplate->{$mode})) {
 
         // Check for multiple tags, only need to check for add template.
         if ($mode != 'addtemplate' or data_tags_check($data->id, $newtemplate->{$mode})) {
-            $DB->update_record('data', $newtemplate);
-            echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess');
+            // if disableeditor or enableeditor buttons click, don't save instance
+            if (empty($disableeditor) && empty($enableeditor)) {
+                $DB->update_record('data', $newtemplate);
+                echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess');
+                add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&amp;d=$data->id", $data->id, $cm->id);
+            }
         }
         }
-        add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&amp;d=$data->id", $data->id, $cm->id);
     }
 } else {
     echo '<div class="littleintro" style="text-align:center">'.get_string('header'.$mode,'data').'</div>';
     }
 } else {
     echo '<div class="littleintro" style="text-align:center">'.get_string('header'.$mode,'data').'</div>';