]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20749 correct error output - key/index checkers fixed.
authorEloy Lafuente <stronk7@moodle.org>
Thu, 5 Nov 2009 13:58:22 +0000 (13:58 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Thu, 5 Nov 2009 13:58:22 +0000 (13:58 +0000)
admin/xmldb/actions/edit_index_save/edit_index_save.class.php
admin/xmldb/actions/edit_key_save/edit_key_save.class.php

index 8373f837a0dbaed7b4356ac0939130cfd8aff9ad..6bd89dff85e85672baa6eb849192924613e173fc 100644 (file)
@@ -1,31 +1,34 @@
 <?php
 
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards Martin Dougiamas     http://dougiamas.com  //
-//           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
-
-/// This class will save the changes performed to one index
-
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @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 verifies all the data introduced when editing an index for correctness,
+ * peforming changes / displaying errors depending of the results.
+ *
+ * @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_index_save extends XMLDBAction {
 
     /**
@@ -46,6 +49,7 @@ class edit_index_save extends XMLDBAction {
             'fieldsnotintable' => 'xmldb',
             'fieldsusedinkey' => 'xmldb',
             'fieldsusedinindex' => 'xmldb',
+            'back' => 'xmldb',
             'administration' => ''
         ));
     }
@@ -61,8 +65,8 @@ class edit_index_save extends XMLDBAction {
         $result = true;
 
     /// Set own core attributes
-        $this->does_generate = ACTION_NONE;
-        //$this->does_generate = ACTION_GENERATE_HTML;
+        //$this->does_generate = ACTION_NONE;
+        $this->does_generate = ACTION_GENERATE_HTML;
 
     /// These are always here
         global $CFG, $XMLDB;
@@ -163,16 +167,11 @@ class edit_index_save extends XMLDBAction {
             $tempindex->setUnique($unique);
             $tempindex->setFields($fieldsarr);
         /// Prepare the output
-            $site = get_site();
-            $PAGE->navbar->add($this->str['administration'], '../index.php');
-            $PAGE->navbar->add('XMLDB', 'index.php');
-            $PAGE->set_title("$site->shortname: XMLDB");
-            $PAGE->set_heading($site->fullname);
-            echo $OUTPUT->header();
-            notice ('<p>' .implode(', ', $errors) . '</p>
-                     <p>' . $tempindex->readableInfo() . '</p>',
-                    'index.php?action=edit_index&amp;index=' .$index->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
-            die; /// re-die :-P
+            $o = '<p>' .implode(', ', $errors) . '</p>
+                  <p>' . $tempindex->readableInfo() . '</p>';
+            $o.= '<a href="index.php?action=edit_index&amp;index=' .$index->getName() . '&amp;table=' . $table->getName() . 
+                 '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
+            $this->output = $o;
         }
 
     /// Continue if we aren't under errors
index 45664005e4eaa44ba69ca2553b8673f4d52b147c..3c8ee50e1bb4b1c4e2db274a999da5a1a10bf014 100644 (file)
@@ -1,31 +1,34 @@
 <?php
 
-///////////////////////////////////////////////////////////////////////////
-//                                                                       //
-// NOTICE OF COPYRIGHT                                                   //
-//                                                                       //
-// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
-//          http://moodle.com                                            //
-//                                                                       //
-// Copyright (C) 1999 onwards Martin Dougiamas     http://dougiamas.com  //
-//           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
-//                                                                       //
-// This program is free software; you can redistribute it and/or modify  //
-// it under the terms of the GNU General Public License as published by  //
-// the Free Software Foundation; either version 2 of the License, or     //
-// (at your option) any later version.                                   //
-//                                                                       //
-// This program is distributed in the hope that it will be useful,       //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
-// GNU General Public License for more details:                          //
-//                                                                       //
-//          http://www.gnu.org/copyleft/gpl.html                         //
-//                                                                       //
-///////////////////////////////////////////////////////////////////////////
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-/// This class will save the changes performed to one key
+/**
+ * @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 verifies all the data introduced when editing a key for correctness,
+ * peforming changes / displaying errors depending of the results.
+ *
+ * @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_key_save extends XMLDBAction {
 
     /**
@@ -52,6 +55,7 @@ class edit_key_save extends XMLDBAction {
             'nomasterprimaryuniquefound' => 'xmldb',
             'masterprimaryuniqueordernomatch' => 'xmldb',
             'primarykeyonlyallownotnullfields' => 'xmldb',
+            'back' => 'xmldb',
             'administration' => ''
         ));
     }
@@ -67,8 +71,8 @@ class edit_key_save extends XMLDBAction {
         $result = true;
 
     /// Set own core attributes
-        $this->does_generate = ACTION_NONE;
-        //$this->does_generate = ACTION_GENERATE_HTML;
+        //$this->does_generate = ACTION_NONE;
+        $this->does_generate = ACTION_GENERATE_HTML;
 
     /// These are always here
         global $CFG, $XMLDB;
@@ -239,17 +243,11 @@ class edit_key_save extends XMLDBAction {
                 $tempkey->setRefFields($reffieldsarr);
             }
         /// Prepare the output
-            $site = get_site();
-            $PAGE->navbar->add($this->str['administration'], '../index.php');
-            $PAGE->navbar->add('XMLDB', 'index.php');
-            $PAGE->set_title("$site->shortname: XMLDB");
-            $PAGE->set_heading($site->fullname);
-            echo $OUTPUT->header();
-
-            notice ('<p>' .implode(', ', $errors) . '</p>
-                     <p>' . $tempkey->readableInfo() . '</p>',
-                    'index.php?action=edit_key&amp;key=' .$key->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)));
-            die; /// re-die :-P
+            $o = '<p>' .implode(', ', $errors) . '</p>
+                  <p>' . $name . ': ' . $tempkey->readableInfo() . '</p>';
+            $o.= '<a href="index.php?action=edit_key&amp;key=' .$key->getName() . '&amp;table=' . $table->getName() .
+                 '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
+            $this->output = $o;
         }
 
     /// Continue if we aren't under errors