]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9176 xmldb editor - enable the possibility to avoid unload after save (default)
authorstronk7 <stronk7>
Thu, 28 May 2009 23:20:53 +0000 (23:20 +0000)
committerstronk7 <stronk7>
Thu, 28 May 2009 23:20:53 +0000 (23:20 +0000)
admin/xmldb/actions/save_xml_file/save_xml_file.class.php

index c42ad85b1f9e3b4b7811b7fba09ba52fb13ac83b..e8208eba3fccc62fc4fab5ea97be38b9b4d45409 100644 (file)
@@ -1,31 +1,38 @@
-<?php // $Id$
-
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards Martin Dougiamas        http://dougiamas.com  //
-//           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-/// This class will save one edited xml file
-
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @package   xmldb-editor
+ * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * This class will save one edited xml file
+ *
+ * This class will save the in-session xml structure to its
+ * corresponding xml file, optionally reloading it if editing
+ * is going to continue (unload=false). Else (default) the
+ * file is unloaded once saved.
+ *
+ * @package   xmldb-editor
+ * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 class save_xml_file extends XMLDBAction {
 
     /**
@@ -63,6 +70,7 @@ class save_xml_file extends XMLDBAction {
     /// Get the dir containing the file
         $dirpath = required_param('dir', PARAM_PATH);
         $dirpath = $CFG->dirroot . $dirpath;
+        $unload = optional_param('unload', true, PARAM_BOOL);
 
     /// Get the edited dir
         if (!empty($XMLDB->editeddirs)) {
@@ -101,6 +109,11 @@ class save_xml_file extends XMLDBAction {
             return false;
         }
 
+    /// If unload has been disabled, simulate it by reloading the file now
+        if (!$unload) {
+            $this->launch('load_xml_file');
+        }
+
     /// Launch postaction if exists (leave this here!)
         if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());