MDL-9176 xmldb editor - enable the possibility to avoid unload after save (default)

This commit is contained in:
stronk7
2009-05-28 23:20:53 +00:00
parent c1b8eeda68
commit 4f237e248b
@@ -1,31 +1,38 @@
<?php // $Id$
<?php
///////////////////////////////////////////////////////////////////////////
// //
// 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 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/>.
/// This class will save one edited xml file
/**
* @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());