Skip to content

Commit

Permalink
MDL-32003 xmldb: Use action error for filemodified check instead of s…
Browse files Browse the repository at this point in the history
…tructure one (protected attr).
  • Loading branch information
stronk7 committed Jun 20, 2012
1 parent cb17282 commit 7128d8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions admin/tool/xmldb/actions/main_view/main_view.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function init() {
'checkbigints' => 'tool_xmldb',
'checkoraclesemantics' => 'tool_xmldb',
'doc' => 'tool_xmldb',
'filemodifiedoutfromeditor' => 'tool_xmldb',
'viewxml' => 'tool_xmldb',
'pendingchangescannotbesavedreload' => 'tool_xmldb'
));
Expand Down Expand Up @@ -194,10 +195,8 @@ function invoke() {
$b .= '<a href="index.php?action=save_xml_file&amp;sesskey=' . sesskey() . '&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';
}
// File manually modified. Add to action error, will be displayed inline.
$this->errormsg = $this->str['filemodifiedoutfromeditor'];
}
} else {
$b .= '[' . $this->str['save'] . ']';
Expand Down Expand Up @@ -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 .= '<tr class="highlight"><td class="error cell" colspan="10">' . implode (', ', $errors) . '</td></tr>';
} else {
Expand Down
1 change: 1 addition & 0 deletions admin/tool/xmldb/lang/en/tool_xmldb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 7128d8f

Please sign in to comment.