From cab8690d4b0c0f5ea72b6ba4c30c8f6bbc0d3ceb Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 14 Jun 2009 16:34:34 +0000 Subject: [PATCH] MDL-19331 Changes is table name/comments now flag xmldb as changed --- .../edit_table_save/edit_table_save.class.php | 80 ++++++++++++------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php index e69e740373..f86710d9d8 100644 --- a/admin/xmldb/actions/edit_table_save/edit_table_save.class.php +++ b/admin/xmldb/actions/edit_table_save/edit_table_save.class.php @@ -1,32 +1,33 @@ -. + +/** + * @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 changes in table name and/or comments + * + * @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 edit_table_save extends XMLDBAction { /** @@ -78,6 +79,8 @@ class edit_table_save extends XMLDBAction { $comment = required_param('comment', PARAM_CLEAN); $comment = $comment; + $dbdir =& $XMLDB->dbdirs[$dirpath]; + $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); $table =& $structure->getTable($tableparam); @@ -127,10 +130,27 @@ class edit_table_save extends XMLDBAction { $next->setPrevious($name); $next->setChanged(true); } + /// Table has changed + $table->setChanged(true); } /// Set comment - $table->setComment($comment); + if ($table->getComment() != $comment) { + $table->setComment($comment); + /// Table has changed + $table->setChanged(true); + } + + /// Recalculate the hash + $structure->calculateHash(true); + + /// If the hash has changed from the original one, change the version + /// and mark the structure as changed + $origstructure =& $dbdir->xml_file->getStructure(); + if ($structure->getHash() != $origstructure->getHash()) { + $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); + $structure->setChanged(true); + } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { -- 2.39.5