]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19058 xmldb editor & enums - inform about ENUM info detected in all
authorstronk7 <stronk7>
Tue, 26 May 2009 18:47:02 +0000 (18:47 +0000)
committerstronk7 <stronk7>
Tue, 26 May 2009 18:47:02 +0000 (18:47 +0000)
the loaded files, suggesting different options depending of active/inactive ENUMs found

admin/xmldb/actions/main_view/main_view.class.php

index b1b595eee332873b401cca21d660b43112bbeae5..9f5cbdc644c3dcee6c8718107a49aed8d1b999d4 100644 (file)
@@ -246,9 +246,43 @@ class main_view extends XMLDBAction {
                     if ($structure =& $dbdir->xml_file->getStructure()) {
                         if ($errors = $structure->getAllErrors()) {
                             if ($hithis) {
-                                $o .= '<tr class="highlight"><td class="error cell" colspan="8">' . implode (', ', $errors) . '</td></tr>';
+                                $o .= '<tr class="highlight"><td class="error cell" colspan="9">' . implode (', ', $errors) . '</td></tr>';
                             } else {
-                                $o .= '<tr class="r' . $row . '"><td class="error cell" colspan="8">' . implode (', ', $errors) . '</td></tr>';
+                                $o .= '<tr class="r' . $row . '"><td class="error cell" colspan="9">' . implode (', ', $errors) . '</td></tr>';
+                            }
+                        }
+                    }
+                }
+            /// 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 .= '<tr class="highlight"><td class="error cell" colspan="9">';
+                                            } else {
+                                                $o .= '<tr class="r' . $row . '"><td class="error cell" colspan="9">';
+                                            }
+                                            $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' .
+                                                      ' <a href="http://docs.moodle.org/en/Development:DB_layer_2.0_migration_docs#The_changes">' .
+                                                      ' Moodle Docs</a> 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 .= '</td></tr>';
+                                        }
+                                    }
+                                }
                             }
                         }
                     }