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 e69e7403731..f86710d9d8d 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 @@ -. -/// This class will save the changes performed to the name and comment of -/// one table +/** + * @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) {