]> git.mjollnir.org Git - moodle.git/commitdiff
Now the editor detects if the xml file has been locally modified
authorstronk7 <stronk7>
Sun, 25 Feb 2007 20:20:35 +0000 (20:20 +0000)
committerstronk7 <stronk7>
Sun, 25 Feb 2007 20:20:35 +0000 (20:20 +0000)
since loading it. Second part of MDL-8264

Merged from MOODLE_18_STABLE

admin/xmldb/actions/load_xml_file/load_xml_file.class.php
admin/xmldb/actions/main_view/main_view.class.php

index eb56ad7d87c8545616af5db316e1835f93607b42..3b5f88d2b97207012a980ada5f885c5cadde5817 100644 (file)
@@ -95,6 +95,9 @@ class load_xml_file extends XMLDBAction {
                 $loaded = $xmldb_file->loadXMLStructure();
                 if ($loaded && $xmldb_file->isLoaded()) {
                     $dbdir->xml_loaded = true;
+                    if (!empty($dbdir->filemtime)) {
+                        $dbdir->filemtime = filemtime($dbdir->path . '/install.xml'); 
+                    }
                 }
                 $dbdir->xml_file = $xmldb_file;
             } else {
index 5a9115d5573bf738e7e22246d347bcd46b4e2b70..b290d722cb85bf4d3e16a60877489e8f9dc3bd8b 100644 (file)
@@ -157,6 +157,13 @@ class main_view extends XMLDBAction {
                     !empty($dbdir->xml_loaded) &&
                     !empty($dbdir->xml_changed)) {
                     $b .= '<a href="index.php?action=save_xml_file&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
+                /// Check if the file has been manually edited while being modified in the editor
+                    if ($dbdir->filemtime != filemtime($key . '/install.xml')) {
+                    /// File manually modified. Add to errors.
+                        if ($structure =& $dbdir->xml_file->getStructure()) {
+                            $structure->errormsg = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes';
+                        }
+                    }
                 } else {
                     $b .= '[' . $this->str['save'] . ']';
                 }