sesskey_protected = false; // This action doesn't need sesskey protection /// Get needed strings $this->loadStrings(array( 'selectaction' => 'xmldb', 'selectfieldkeyindex' => 'xmldb', 'view' => 'xmldb', 'table' => 'xmldb', 'selectonecommand' => 'xmldb', 'selectonefieldkeyindex' => 'xmldb', 'mustselectonefield' => 'xmldb', 'mustselectonekey' => 'xmldb', 'mustselectoneindex' => 'xmldb', '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; /// Do the job, setting result as needed /// Get the dir containing the file $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . stripslashes_safe($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(); } /// ADD YOUR CODE HERE $tableparam = required_param('table', PARAM_PATH); $table =& $structure->getTable($tableparam); $fields = $table->getFields(); $field = reset($fields); $defaultfieldkeyindex = null; if ($field) { $defaultfieldkeyindex = 'f#' . $field->getName(); } $keys = $table->getKeys(); $indexes = $table->getIndexes(); /// Get parameters $commandparam = optional_param('command', 'add_field', PARAM_PATH); $origfieldkeyindexparam = optional_param('fieldkeyindex', $defaultfieldkeyindex, PARAM_PATH); $fieldkeyindexparam = preg_replace('/[fki]#/i', '', $origfieldkeyindexparam); ///Strip the initials $fieldkeyindexinitial = substr($origfieldkeyindexparam, 0, 1); //To know what we have selected /// The back to edit xml button $b = '
'; $o = $b; /// The table currently being edited $o .= '