. /** * @package tool * @subpackage xmldb * @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 show the SQL generated for the selected RDBMS for * one table * * @package tool * @subpackage xmldb * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class view_table_sql extends XMLDBAction { /** * Init method, every subclass will have its own */ function init() { parent::init(); // Set own custom attributes $this->sesskey_protected = false; // This action doesn't need sesskey protection // Get needed strings $this->loadStrings(array( 'selectdb' => 'tool_xmldb', 'back' => 'tool_xmldb' )); } /** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; // Set own core attributes $this->does_generate = ACTION_GENERATE_HTML; // These are always here global $CFG, $XMLDB, $DB; $dbman = $DB->get_manager(); // Do the job, setting result as needed // Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . $dirpath; // Get the correct dirs if (!empty($XMLDB->dbdirs)) { $dbdir =& $XMLDB->dbdirs[$dirpath]; } else { return false; } if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); } // Get parameters $tableparam = required_param('table', PARAM_PATH); if (!$table = $structure->getTable($tableparam)) { $this->errormsg = 'Wrong table specified: ' . $tableparam; return false; } // The back to edit table button $b = '
'; $o = $b; $o.= '