loadStrings(array( 'confirmcheckindexes' => 'xmldb', 'ok' => '', 'missing' => 'xmldb', 'table' => 'xmldb', 'key' => 'xmldb', 'index' => 'xmldb', 'searchresults' => 'xmldb', 'missingindexes' => 'xmldb', 'completelogbelow' => 'xmldb', 'nomissingindexesfound' => 'xmldb', 'yesmissingindexesfound' => 'xmldb', 'yes' => '', 'no' => '', 'back' => '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; /// And we nedd some ddl suff require_once ($CFG->libdir . '/ddllib.php'); /// Here we'll acummulate all the missing indexes found $missing_indexes = array(); /// Do the job, setting $result as needed /// Get the confirmed to decide what to do $confirmed = optional_param('confirmed', false, PARAM_BOOL); /// If not confirmed, show confirmation box if (!$confirmed) { $o = ''; $o.= ' '; $o.= '
'; $o.= '

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

'; $o.= ' '; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $o.= '
'; $this->output = $o; } else { /// The back to edit table button $b = '

'; $b .= '[' . $this->str['back'] . ']'; $b .= '

'; /// Iterate over $XMLDB->dbdirs, loading their XML data to memory if ($XMLDB->dbdirs) { $dbdirs =& $XMLDB->dbdirs; $o=''; } /// We have finished, let's show the results of the search $s = ''; $r = ''; $r.= ' '; $r.= ' '; $r.= ' '; $r.= '
'; $r.= '

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

'; $r.= '

' . $this->str['missingindexes'] . ': ' . count($missing_indexes) . '

'; $r.= '
'; /// If we have found missing indexes inform about them if (count($missing_indexes)) { $r.= '

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

'; $r.= '
    '; foreach ($missing_indexes as $obj) { $xmldb_table = $obj->table; $xmldb_index = $obj->index; $sqlarr = $xmldb_table->getAddIndexSQL($CFG->dbtype, $CFG->prefix, $xmldb_index, true); $r.= '
  • ' . $this->str['table'] . ': ' . $xmldb_table->getName() . '. ' . $this->str['index'] . ': ' . $xmldb_index->readableInfo() . '
  • '; $s.= '' . str_replace("\n", '
    ', implode('
    ', $sqlarr)) . '

    '; } $r.= '
'; /// Add the SQL statements (all together) $r.= '
' . $s; } else { $r.= '

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

'; } $r.= '
'; /// Add the complete log message $r.= '

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

'; $r.= '
'; $this->output = $b . $r . $o; } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; } } ?>