From 7128d8fca2eda5253dcca067a393611f73eaf156 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 20 Jun 2012 01:26:06 +0200 Subject: [PATCH] MDL-32003 xmldb: Use action error for filemodified check instead of structure one (protected attr). --- .../xmldb/actions/main_view/main_view.class.php | 14 +++++++++----- admin/tool/xmldb/lang/en/tool_xmldb.php | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/admin/tool/xmldb/actions/main_view/main_view.class.php b/admin/tool/xmldb/actions/main_view/main_view.class.php index f0ecc7edd9a0f..9d4e00222e05e 100644 --- a/admin/tool/xmldb/actions/main_view/main_view.class.php +++ b/admin/tool/xmldb/actions/main_view/main_view.class.php @@ -58,6 +58,7 @@ function init() { 'checkbigints' => 'tool_xmldb', 'checkoraclesemantics' => 'tool_xmldb', 'doc' => 'tool_xmldb', + 'filemodifiedoutfromeditor' => 'tool_xmldb', 'viewxml' => 'tool_xmldb', 'pendingchangescannotbesavedreload' => 'tool_xmldb' )); @@ -194,10 +195,8 @@ function invoke() { $b .= '[' . $this->str['save'] . ']'; // 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'; - } + // File manually modified. Add to action error, will be displayed inline. + $this->errormsg = $this->str['filemodifiedoutfromeditor']; } } else { $b .= '[' . $this->str['save'] . ']'; @@ -266,7 +265,12 @@ function invoke() { // show errors if they exist if (isset($dbdir->xml_file)) { if ($structure = $dbdir->xml_file->getStructure()) { - if ($errors = $structure->getAllErrors()) { + $errors = !empty($this->errormsg) ? array($this->errormsg) : array(); + $structureerrors = $structure->getAllErrors(); + if ($structureerrors) { + $errors = array_merge($errors, $structureerrors); + } + if (!empty($errors)) { if ($hithis) { $o .= '' . implode (', ', $errors) . ''; } else { diff --git a/admin/tool/xmldb/lang/en/tool_xmldb.php b/admin/tool/xmldb/lang/en/tool_xmldb.php index 17392ec461232..7b384b23147b9 100644 --- a/admin/tool/xmldb/lang/en/tool_xmldb.php +++ b/admin/tool/xmldb/lang/en/tool_xmldb.php @@ -90,6 +90,7 @@ $string['fieldsnotintable'] = 'Field doesn\'t exist in table'; $string['fieldsusedinindex'] = 'This field is used as index'; $string['fieldsusedinkey'] = 'This field is used as key.'; +$string['filemodifiedoutfromeditor'] = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes.'; $string['filenotwriteable'] = 'File not writeable'; $string['fkviolationdetails'] = 'Foreign key {$a->keyname} on table {$a->tablename} is violated by {$a->numviolations} out of {$a->numrows} rows.'; $string['floatincorrectdecimals'] = 'Incorrect number of decimals for float field';