sesskey_protected = false; // This action doesn't need sesskey protection /// Get needed strings $this->loadStrings(array( 'load' => 'xmldb', 'create' => 'xmldb', 'edit' => 'xmldb', 'save' => 'xmldb', 'revert' => 'xmldb', 'unload' => 'xmldb', 'delete' => 'xmldb', 'reservedwords' => 'xmldb', 'test' => 'xmldb', 'gotolastused' => 'xmldb', 'checkindexes' => 'xmldb', 'checkbigints' => '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, $SESSION; /// Get lastused $o = ''; if (isset($SESSION->lastused)) { if ($lastused = $SESSION->lastused) { /// Print link $o .= '

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

'; } } else { $lastused = NULL; } /// Calculate the buttons $b = '

'; /// The reserved_words button $b .= ' [' . $this->str['reservedwords'] . ']'; /// The test button $b .= ' [' . $this->str['test'] . ']'; /// The check indexes button $b .= ' [' . $this->str['checkindexes'] . ']'; /// The check bigints button (only for MySQL and PostgreSQL) MDL-11038a if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') { $b .= ' [' . $this->str['checkbigints'] . ']'; } $b .= '

'; /// Send buttons to output $o .= $b; /// Do the job /// Get the list of DB directories $result = $this->launch('get_db_directories'); /// Display list of DB directories if everything is ok if ($result && !empty($XMLDB->dbdirs)) { $o .= ''; $row = 0; foreach ($XMLDB->dbdirs as $key => $dbdir) { /// Detect if this is the lastused dir $hithis = false; if (str_replace($CFG->dirroot, '', $key) == $lastused) { $hithis = true; } $elementtext = str_replace($CFG->dirroot . '/', '', $key); /// Calculate the dbdir has_changed field if needed if (!isset($dbdir->has_changed) && isset($dbdir->xml_loaded)) { $dbdir->xml_changed = false; if (isset($XMLDB->editeddirs[$key])) { $editeddir =& $XMLDB->editeddirs[$key]; if (isset($editeddir->xml_file)) { $structure =& $editeddir->xml_file->getStructure(); if ($structure->hasChanged()) { $dbdir->xml_changed = true; $editeddir->xml_changed = true; } } } } /// Calculate the buttons $b = ' '; /// if the file, exist, XML is viewable if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml')) { $elementtext = '' . $elementtext . ''; } else { $elementtext = $elementtext . ''; } /// include the higlight if ($hithis) { $o .= ''; } else { $o .= ''; } $row = ($row + 1) % 2; /// show errors if they exist if (isset($dbdir->xml_file)) { if ($structure =& $dbdir->xml_file->getStructure()) { if ($errors = $structure->getAllErrors()) { if ($hithis) { $o .= ''; } else { $o .= ''; } } } } } $o .= '
'; /// The create button if ($dbdir->path_exists && !file_exists($key . '/install.xml') && is_writeable($key)) { $b .= '[' . $this->str['create'] . ']'; } else { $b .= '[' . $this->str['create'] . ']'; } $b .= ''; /// The load button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['load'] . ']'; } else { $b .= '[' . $this->str['load'] . ']'; } $b .= ''; /// The edit button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_readable($key) && !empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['edit'] . ']'; } else { $b .= '[' . $this->str['edit'] . ']'; } $b .= ''; /// The save button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_writeable($key . '/install.xml') && is_writeable($key) && !empty($dbdir->xml_loaded) && !empty($dbdir->xml_changed)) { $b .= '[' . $this->str['save'] . ']'; /// Check if the file has been manually edited while being modified in the editor if ($dbdir->filemtime != filemtime($key . '/install.xml')) { /// File manually modified. Add to errors. if ($structure =& $dbdir->xml_file->getStructure()) { $structure->errormsg = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes'; } } } else { $b .= '[' . $this->str['save'] . ']'; } $b .= ''; /// The revert button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_writeable($key) && !empty($dbdir->xml_loaded) && !empty($dbdir->xml_changed)) { $b .= '[' . $this->str['revert'] . ']'; } else { $b .= '[' . $this->str['revert'] . ']'; } $b .= ''; /// The unload button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && !empty($dbdir->xml_loaded) && empty($dbdir->xml_changed)) { $b .= '[' . $this->str['unload'] . ']'; } else { $b .= '[' . $this->str['unload'] . ']'; } $b .= ''; /// The delete button if ($dbdir->path_exists && file_exists($key . '/install.xml') && is_readable($key . '/install.xml') && is_writeable($key) && empty($dbdir->xml_loaded)) { $b .= '[' . $this->str['delete'] . ']'; } else { $b .= '[' . $this->str['delete'] . ']'; } $b .= '
' . $elementtext . $b . '
' . $elementtext . $b . '
' . implode (', ', $errors) . '
' . implode (', ', $errors) . '
'; /// Set the output $this->output = $o; } /// Finally, return result return $result; } } ?>