From 3a0a3d7a6cbb661640872c9c813bdf58056ecfa0 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Tue, 26 May 2009 18:47:02 +0000 Subject: [PATCH] MDL-19058 xmldb editor & enums - inform about ENUM info detected in all the loaded files, suggesting different options depending of active/inactive ENUMs found --- .../actions/main_view/main_view.class.php | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/admin/xmldb/actions/main_view/main_view.class.php b/admin/xmldb/actions/main_view/main_view.class.php index b1b595eee3..9f5cbdc644 100644 --- a/admin/xmldb/actions/main_view/main_view.class.php +++ b/admin/xmldb/actions/main_view/main_view.class.php @@ -246,9 +246,43 @@ class main_view extends XMLDBAction { if ($structure =& $dbdir->xml_file->getStructure()) { if ($errors = $structure->getAllErrors()) { if ($hithis) { - $o .= '' . implode (', ', $errors) . ''; + $o .= '' . implode (', ', $errors) . ''; } else { - $o .= '' . implode (', ', $errors) . ''; + $o .= '' . implode (', ', $errors) . ''; + } + } + } + } + /// TODO: Drop this check in Moodle 2.1 + /// Intercept loaded structure here and look for ENUM fields + if (isset($dbdir->xml_file)) { + if ($structure =& $dbdir->xml_file->getStructure()) { + if ($tables = $structure->getTables()) { + foreach ($tables as $table) { + if ($fields = $table->getFields()) { + foreach ($fields as $field) { + if (!empty($field->hasenums)) { + if ($hithis) { + $o .= ''; + } else { + $o .= ''; + } + $o .= 'Table ' . $table->getName() . ', field ' . $field->getName() . ' has ENUM info'; + if (!empty($field->hasenumsenabled)) { + $o .= ' that seems to be active (true). ENUMs support has been dropped in Moodle 2.0, ' . + ' the XMLDB Editor will delete any ENUM reference next time you save this file' . + ' and you MUST provide one upgrade block in your code to drop them from DB. See' . + ' ' . + ' Moodle Docs for more info and examples.'; + } else { + $o .= ' that seem to be inactive (false). ENUMs support has been dropped in Moodle 2.0,' . + ' the XMLDB Editor will, simply, delete any ENUM reference next time you save this file.' . + ' No further action is necessary.'; + } + $o .= ''; + } + } + } } } } -- 2.39.5