From: stronk7 Date: Thu, 28 May 2009 23:48:39 +0000 (+0000) Subject: MDL-9176 xmldb editor - now it's possible to save from edit table page X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c97b24bf735885906973f88102078f403c119c90;p=moodle.git MDL-9176 xmldb editor - now it's possible to save from edit table page --- diff --git a/admin/xmldb/actions/edit_table/edit_table.class.php b/admin/xmldb/actions/edit_table/edit_table.class.php index 7de3de9c73..e912fb3654 100644 --- a/admin/xmldb/actions/edit_table/edit_table.class.php +++ b/admin/xmldb/actions/edit_table/edit_table.class.php @@ -61,7 +61,10 @@ class edit_table extends XMLDBAction { 'delete' => 'xmldb', 'reserved' => 'xmldb', 'back' => 'xmldb', - 'viewxml' => 'xmldb' + 'viewxml' => 'xmldb', + 'pendingchanges' => 'xmldb', + 'pendingchangescannotbesaved' => 'xmldb', + 'save' => 'xmldb' )); } @@ -92,6 +95,12 @@ class edit_table extends XMLDBAction { } else { return false; } + /// Check if the dir exists and copy it from dbdirs + /// (because we need straight load in case of saving from here) + if (!isset($XMLDB->editeddirs[$dirpath])) { + $XMLDB->editeddirs[$dirpath] = unserialize(serialize($dbdir)); + } + if (!empty($XMLDB->editeddirs)) { $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); @@ -126,6 +135,17 @@ class edit_table extends XMLDBAction { $o.= '  '; $o.= ' '; $o.= ''; + /// Calculate the pending changes / save message + $e = ''; + $cansavenow = false; + if ($structure->hasChanged()) { + if (!is_writeable($dirpath . '/install.xml') || !is_writeable($dirpath)) { + $e .= '

' . $this->str['pendingchangescannotbesaved'] . '

'; + } else { + $e .= '

' . $this->str['pendingchanges'] . '

'; + $cansavenow = true; + } + } /// Calculate the buttons $b = '

'; /// The view original XML button @@ -146,16 +166,21 @@ class edit_table extends XMLDBAction { $b .= ' [' . $this->str['newkey'] . ']'; /// The new index button $b .= ' [' . $this->str['newindex'] . ']'; - /// The back to edit xml file button - $b .= ' [' . $this->str['back'] . ']'; $b .= '

'; + $b .= '

'; /// The view sql code button $b .= '[' .$this->str['viewsqlcode'] . ']'; /// The view php code button $b .= ' [' . $this->str['viewphpcode'] . ']'; + /// The save button (if possible) + if ($cansavenow) { + $b .= ' [' . $this->str['save'] . ']'; + } + /// The back to edit xml file button + $b .= ' [' . $this->str['back'] . ']'; $b .= '

'; - $o .= $b; + $o .= $e . $b; require_once("$CFG->libdir/ddl/sql_generator.php"); $reserved_words = sql_generator::getAllReservedWords();