// array of all valid fields for validation
$STD_FIELDS = array('id', 'firstname', 'lastname', 'username', 'email',
'city', 'country', 'lang', 'timezone', 'mailformat',
- 'maildisplay', 'maildigest', 'htmleditor', 'ajax', 'autosubscribe',
+ 'maildisplay', 'maildigest', 'htmleditor', 'autosubscribe',
'institution', 'department', 'idnumber', 'skype',
'msn', 'aim', 'yahoo', 'icq', 'phone1', 'phone2', 'address',
'url', 'description', 'descriptionformat', 'password',
$mform->setType('htmleditor', PARAM_INT);
}
- if (empty($CFG->enableajax)) {
- $mform->addElement('static', 'ajax', get_string('ajaxuse'), get_string('ajaxno'));
- } else {
- $choices = array( 0 => get_string('ajaxno'), 1 => get_string('ajaxyes'));
- $mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
- $mform->setDefault('ajax', 1);
- }
- $mform->setAdvanced('ajax');
-
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
$mform->setType('city', PARAM_MULTILANG);
if (empty($CFG->defaultcity)) {
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Main xmldb action class. It implements all the basic
* functionalities to be shared by each action.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 XMLDBAction {
- var $does_generate; //Type of value returned by the invoke method
- //ACTION_GENERATE_HTML have contents to show
- //set by each specialized invoke
+ /** @var bool Type of value returned by the invoke method, ACTION_GENERATE_HTML have contents to show, set by each specialized invoke*/
+ protected $does_generate;
- var $title; //Title of the Action (class name, by default)
- //set by parent init automatically
+ /** @var string Title of the Action (class name, by default), set by parent init automatically*/
+ protected $title;
- var $str; //Strings used by the action
- //set by each specialized init, calling loadStrings
+ /** @var string Strings used by the action set by each specialized init, calling loadStrings*/
+ protected $str;
- var $output; //Output of the action
- //set by each specialized invoke, get with getOutput
+ /** @var string Output of the action, set by each specialized invoke, get with getOutput*/
+ protected $output;
- var $errormsg; //Last Error produced. Check when any invoke returns false
- //get with getError
+ /** @var string Last Error produced. Check when any invoke returns false, get with getError*/
+ protected $errormsg;
- var $postaction; //Action to execute at the end of the invoke script
+ /** @var string Action to execute at the end of the invoke script*/
+ protected $postaction;
- var $sesskey_protected; // Actions must be protected by sesskey mechanism
+ /** @var bool Actions must be protected by sesskey mechanism*/
+ protected $sesskey_protected;
/**
- * Constructor to keep PHP5 happy
+ * Constructor
*/
function __construct() {
$this->init();
}
/**
- * returns the type of output of the file
+ * Returns the type of output of the file
+ * @return bool
*/
function getDoesGenerate() {
return $this->does_generate;
/**
* getError method, returns the last error string.
* Used if the invoke() methods returns false
+ * @return string
*/
function getError() {
return $this->errormsg;
/**
* getOutput method, returns the output generated by the action.
* Used after execution of the invoke() methods if they return true
+ * @return string
*/
function getOutput() {
return $this->output;
/**
* getPostAction method, returns the action to launch after executing
* another one
+ * @return string
*/
function getPostAction() {
return $this->postaction;
/**
* getTitle method returns the title of the action (that is part
* of the $str array attribute
+ * @return string
*/
function getTitle() {
return $this->str['title'];
/**
* loadStrings method, loads the required strings specified in the
* array parameter
+ * @params array $strings
*/
function loadStrings($strings) {
// Load some commonly used strings
/**
* launch method, used to easily call invoke methods between actions
+ * @param string $action
+ * @return mixed
*/
function launch($action) {
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2008 onwards Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* This is a base class for the various actions that interate over all the
* tables and check some aspect of their definition.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2008 onwards Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class XMLDBCheckAction extends XMLDBAction {
/**
- * This string is displayed with a yes/no choice before the report is run.
+ * @var string This string is displayed with a yes/no choice before the report is run.
* You must set this to the name of a lang string in xmldb.php before calling init.
*/
protected $introstr = '';
// Iterate over $XMLDB->dbdirs, loading their XML data to memory
if ($XMLDB->dbdirs) {
- $dbdirs =& $XMLDB->dbdirs;
+ $dbdirs = $XMLDB->dbdirs;
$o='<ul>';
foreach ($dbdirs as $dbdir) {
// Only if the directory exists
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* reporting about the ones not physically implemented as BIGINTs
* and providing one SQL script to fix all them. MDL-11038
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* match those specified in the xml specs
* and providing one SQL script to fix all them.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Each 0 in that column will violate the foreign key, but we ignore them.
* If you want a strict check performed, then add &strict=1 to the URL.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* with the physical DB implementation, reporting about all the missing
* indexes to be created to be 100% ok.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package xmldb-editor
+ * @package tool_xmldb
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* them by changing to cross-db (CHAR) length semantics.
* See MDL-29322 for more details.
*
- * @package xmldb-editor
+ * @package tool_xmldb
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 delete completely one field
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the edited dir
if (!empty($XMLDB->editeddirs)) {
if (isset($XMLDB->editeddirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $editeddir =& $XMLDB->editeddirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $editeddir = $XMLDB->editeddirs[$dirpath];
if ($editeddir) {
- $structure =& $editeddir->xml_file->getStructure();
+ $structure = $editeddir->xml_file->getStructure();
// Move adjacent fields prev and next attributes
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $fields =& $table->getFields();
- $field =& $table->getField($fieldparam);
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $fields = $table->getFields();
+ $field = $table->getField($fieldparam);
if ($field->getPrevious()) {
- $prev =& $table->getField($field->getPrevious());
+ $prev = $table->getField($field->getPrevious());
$prev->setNext($field->getNext());
}
if ($field->getNext()) {
- $next =& $table->getField($field->getNext());
+ $next = $table->getField($field->getNext());
$next->setPrevious($field->getPrevious());
}
// Remove the field
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 delete completely one index
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the edited dir
if (!empty($XMLDB->editeddirs)) {
if (isset($XMLDB->editeddirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $editeddir =& $XMLDB->editeddirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $editeddir = $XMLDB->editeddirs[$dirpath];
if ($editeddir) {
- $structure =& $editeddir->xml_file->getStructure();
+ $structure = $editeddir->xml_file->getStructure();
// Move adjacent indexes prev and next attributes
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $indexes =& $table->getIndexes();
- $index =& $table->getIndex($indexparam);
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $indexes = $table->getIndexes();
+ $index = $table->getIndex($indexparam);
if ($index->getPrevious()) {
- $prev =& $table->getIndex($index->getPrevious());
+ $prev = $table->getIndex($index->getPrevious());
$prev->setNext($index->getNext());
}
if ($index->getNext()) {
- $next =& $table->getIndex($index->getNext());
+ $next = $table->getIndex($index->getNext());
$next->setPrevious($index->getPrevious());
}
// Remove the index
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 delete completely one key
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the edited dir
if (!empty($XMLDB->editeddirs)) {
if (isset($XMLDB->editeddirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $editeddir =& $XMLDB->editeddirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $editeddir = $XMLDB->editeddirs[$dirpath];
if ($editeddir) {
- $structure =& $editeddir->xml_file->getStructure();
+ $structure = $editeddir->xml_file->getStructure();
// Move adjacent keys prev and next attributes
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $keys =& $table->getKeys();
- $key =& $table->getKey($keyparam);
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $keys = $table->getKeys();
+ $key = $table->getKey($keyparam);
if ($key->getPrevious()) {
- $prev =& $table->getKey($key->getPrevious());
+ $prev = $table->getKey($key->getPrevious());
$prev->setNext($key->getNext());
}
if ($key->getNext()) {
- $next =& $table->getKey($key->getNext());
+ $next = $table->getKey($key->getNext());
$next->setPrevious($key->getPrevious());
}
// Remove the key
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 delete completely one table
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the edited dir
if (!empty($XMLDB->editeddirs)) {
if (isset($XMLDB->editeddirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $editeddir =& $XMLDB->editeddirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $editeddir = $XMLDB->editeddirs[$dirpath];
if ($editeddir) {
- $structure =& $editeddir->xml_file->getStructure();
+ $structure = $editeddir->xml_file->getStructure();
// Remove the table
$structure->deleteTable($tableparam);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 delete completely one XML file
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the original dir and delete the xml file
if (!empty($XMLDB->dbdirs)) {
if (isset($XMLDB->dbdirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
if ($dbdir) {
@unlink($dirpath . '/install.xml');
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 provide the interface for all the edit field actions
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// Fetch request data
$tableparam = required_param('table', PARAM_CLEAN);
- if (!$table =& $structure->getTable($tableparam)) {
+ if (!$table = $structure->getTable($tableparam)) {
$this->errormsg = 'Wrong table specified: ' . $tableparam;
return false;
}
$fieldparam = required_param('field', PARAM_CLEAN);
- if (!$field =& $table->getField($fieldparam)) {
+ if (!$field = $table->getField($fieldparam)) {
// Arriving here from a name change, looking for the new field name
$fieldparam = required_param('name', PARAM_CLEAN);
- $field =& $table->getField($fieldparam);
+ $field = $table->getField($fieldparam);
}
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $origstructure =& $dbdir->xml_file->getStructure();
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $origstructure = $dbdir->xml_file->getStructure();
$o = ''; // Output starts
XMLDB_TYPE_CHAR => $field->getXMLDBTypeName(XMLDB_TYPE_CHAR),
XMLDB_TYPE_TEXT => $field->getXMLDBTypeName(XMLDB_TYPE_TEXT),
XMLDB_TYPE_BINARY => $field->getXMLDBTypeName(XMLDB_TYPE_BINARY));
- // If current field isnt float, delete such column type to avoid its creation from the interface
+ // If current field isn't float, delete such column type to avoid its creation from the interface
// Note that float fields are supported completely but it's possible than in a next future
- // we delete them completely from Moodle DB, using, exlusively, number(x,y) types
+ // we delete them completely from Moodle DB, using, exclusively, number(x,y) types
if ($field->getType() != XMLDB_TYPE_FLOAT) {
unset ($typeoptions[XMLDB_TYPE_FLOAT]);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 verifies all the data introduced when editing a field for correctness,
* performing changes / displaying errors depending of the results.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$default = optional_param('default', NULL, PARAM_PATH);
$default = trim($default);
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
- $table =& $structure->getTable($tableparam);
- $field =& $table->getField($fieldparam);
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
+ $table = $structure->getTable($tableparam);
+ $field = $table->getField($fieldparam);
$oldhash = $field->getHash();
$errors = array(); // To store all the errors found
if ($fieldparam != $name) {
$field->setName($name);
if ($field->getPrevious()) {
- $prev =& $table->getField($field->getPrevious());
+ $prev = $table->getField($field->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($field->getNext()) {
- $next =& $table->getField($field->getNext());
+ $next = $table->getField($field->getNext());
$next->setPrevious($name);
$next->setChanged(true);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 provide the interface for all the edit index actions
*
- * @package xmldb-editor
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// Fetch request data
$tableparam = required_param('table', PARAM_CLEAN);
- if (!$table =& $structure->getTable($tableparam)) {
+ if (!$table = $structure->getTable($tableparam)) {
$this->errormsg = 'Wrong table specified: ' . $tableparam;
return false;
}
$indexparam = required_param('index', PARAM_CLEAN);
- if (!$index =& $table->getIndex($indexparam)) {
+ if (!$index = $table->getIndex($indexparam)) {
// Arriving here from a name change, looking for the new key name
$indexparam = required_param('name', PARAM_CLEAN);
- $index =& $table->getIndex($indexparam);
+ $index = $table->getIndex($indexparam);
}
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $origstructure =& $dbdir->xml_file->getStructure();
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $origstructure = $dbdir->xml_file->getStructure();
// Add the main form
$o = '<form id="form" action="index.php" method="post">';
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 verifies all the data introduced when editing an index for correctness,
* performing changes / displaying errors depending of the results.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$fields = required_param('fields', PARAM_CLEAN);
$fields = str_replace(' ', '', trim(strtolower($fields)));
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
- $table =& $structure->getTable($tableparam);
- $index =& $table->getIndex($indexparam);
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
+ $table = $structure->getTable($tableparam);
+ $index = $table->getIndex($indexparam);
$oldhash = $index->getHash();
$errors = array(); // To store all the errors found
if ($indexparam != $name) {
$index->setName($name);
if ($index->getPrevious()) {
- $prev =& $table->getIndex($index->getPrevious());
+ $prev = $table->getIndex($index->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($index->getNext()) {
- $next =& $table->getIndex($index->getNext());
+ $next = $table->getIndex($index->getNext());
$next->setPrevious($name);
$next->setChanged(true);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 provide the interface for all the edit key actions
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// Fetch request data
$tableparam = required_param('table', PARAM_CLEAN);
- if (!$table =& $structure->getTable($tableparam)) {
+ if (!$table = $structure->getTable($tableparam)) {
$this->errormsg = 'Wrong table specified: ' . $tableparam;
return false;
}
$keyparam = required_param('key', PARAM_CLEAN);
- if (!$key =& $table->getKey($keyparam)) {
+ if (!$key = $table->getKey($keyparam)) {
// Arriving here from a name change, looking for the new key name
$keyparam = required_param('name', PARAM_CLEAN);
- $key =& $table->getKey($keyparam);
+ $key = $table->getKey($keyparam);
}
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $origstructure =& $dbdir->xml_file->getStructure();
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $origstructure = $dbdir->xml_file->getStructure();
// Add the main form
$o = '<form id="form" action="index.php" method="post">';
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 verifies all the data introduced when editing a key for correctness,
* performing changes / displaying errors depending of the results.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$reffields = str_replace(' ', '', trim(strtolower($reffields)));
}
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
- $table =& $structure->getTable($tableparam);
- $key =& $table->getKey($keyparam);
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
+ $table = $structure->getTable($tableparam);
+ $key = $table->getKey($keyparam);
$oldhash = $key->getHash();
$errors = array(); // To store all the errors found
// Continue if we aren't under errors
if (empty($errors)) {
// If there is one name change, do it, changing the prev and next
- // atributes of the adjacent fields
+ // attributes of the adjacent fields
if ($keyparam != $name) {
$key->setName($name);
if ($key->getPrevious()) {
- $prev =& $table->getKey($key->getPrevious());
+ $prev = $table->getKey($key->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($key->getNext()) {
- $next =& $table->getKey($key->getNext());
+ $next = $table->getKey($key->getNext());
$next->setPrevious($name);
$next->setChanged(true);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* can be invoked, plus links to PHP code generator, view SQL, rearrange
* elements and so on.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = required_param('table', PARAM_CLEAN);
- if (!$table =& $structure->getTable($tableparam)) {
+ if (!$table = $structure->getTable($tableparam)) {
// Arriving here from a name change, looking for the new table name
$tableparam = required_param('name', PARAM_CLEAN);
- $table =& $structure->getTable($tableparam);
+ $table = $structure->getTable($tableparam);
}
- $dbdir =& $XMLDB->dbdirs[$dirpath];
- $origstructure =& $dbdir->xml_file->getStructure();
+ $dbdir = $XMLDB->dbdirs[$dirpath];
+ $origstructure = $dbdir->xml_file->getStructure();
// Add the main form
$o = '<form id="form" action="index.php" method="post">';
$table->deleteIndex('changeme');
// Add the fields list
- $fields =& $table->getFields();
+ $fields = $table->getFields();
if (!empty($fields)) {
$o .= '<h3 class="main">' . $this->str['fields'] . '</h3>';
$o .= '<table id="listfields" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';
$o .= '</table>';
}
// Add the keys list
- $keys =& $table->getKeys();
+ $keys = $table->getKeys();
if (!empty($keys)) {
$o .= '<h3 class="main">' . $this->str['keys'] . '</h3>';
$o .= '<table id="listkeys" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';
$o .= '</table>';
}
// Add the indexes list
- $indexes =& $table->getIndexes();
+ $indexes = $table->getIndexes();
if (!empty($indexes)) {
$o .= '<h3 class="main">' . $this->str['indexes'] . '</h3>';
$o .= '<table id="listindexes" border="0" cellpadding="5" cellspacing="1" class="boxaligncenter flexible">';
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 save changes in table name and/or comments
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$comment = required_param('comment', PARAM_CLEAN);
$comment = $comment;
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
- $table =& $structure->getTable($tableparam);
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
+ $table = $structure->getTable($tableparam);
$errors = array(); // To store all the errors found
if ($tableparam != $name) {
$table->setName($name);
if ($table->getPrevious()) {
- $prev =& $structure->getTable($table->getPrevious());
+ $prev = $structure->getTable($table->getPrevious());
$prev->setNext($name);
$prev->setChanged(true);
}
if ($table->getNext()) {
- $next =& $structure->getTable($table->getNext());
+ $next = $structure->getTable($table->getNext());
$next->setPrevious($name);
$next->setChanged(true);
}
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Main page to start editing one XML file. From here it's possible to access
* to tables edition plus PHP code generation and other utilities
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
if ($dbdir) {
// Only if the directory exists and it has been loaded
if (!$dbdir->path_exists || !$dbdir->xml_loaded) {
$XMLDB->editeddirs[$dirpath] = unserialize(serialize($dbdir));
}
// Get it
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
// Add the main form
$o = '<form id="form" action="index.php" method="post">';
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 save the changes performed to the comment of one file
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$comment = $comment;
// Set comment and recalculate hash
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
$structure->setComment($comment);
$structure->calculateHash(true);
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origdir =& $XMLDB->dbdirs[$dirpath];
- $origstructure =& $origdir->xml_file->getStructure();
+ $origdir = $XMLDB->dbdirs[$dirpath];
+ $origstructure = $origdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* This class will produce the documentation for all the XMLDB files in the server,
* via XSL, performing the output in HTML format.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 produce XSL documentation for the loaded XML file
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 will check all the db directories existing under the
* current Moodle installation, sending them to the SESSION->dbdirs array
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 load one XML file to memory if necessary
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
if ($dbdir) {
// Set some defaults
$dbdir->xml_exists = false;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 load every XML file to memory if necessary
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Iterate over $XMLDB->dbdirs, loading their XML data to memory
if ($XMLDB->dbdirs) {
- $dbdirs =& $XMLDB->dbdirs;
+ $dbdirs = $XMLDB->dbdirs;
foreach ($dbdirs as $dbdir) {
// Set some defaults
$dbdir->xml_exists = false;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* From here, files can be created, edited, saved and deleted, plus some
* extra utilities like displaying docs, xml info and performing various consistency tests
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
'checkbigints' => 'tool_xmldb',
'checkoraclesemantics' => 'tool_xmldb',
'doc' => 'tool_xmldb',
+ 'filemodifiedoutfromeditor' => 'tool_xmldb',
'viewxml' => 'tool_xmldb',
'pendingchangescannotbesavedreload' => 'tool_xmldb'
));
if (!isset($dbdir->has_changed) && isset($dbdir->xml_loaded)) {
$dbdir->xml_changed = false;
if (isset($XMLDB->editeddirs[$key])) {
- $editeddir =& $XMLDB->editeddirs[$key];
+ $editeddir = $XMLDB->editeddirs[$key];
if (isset($editeddir->xml_file)) {
- $structure =& $editeddir->xml_file->getStructure();
+ $structure = $editeddir->xml_file->getStructure();
if ($structure->hasChanged()) {
$dbdir->xml_changed = true;
$editeddir->xml_changed = true;
$b .= '<a href="index.php?action=save_xml_file&sesskey=' . sesskey() . '&dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&time=' . time() . '&postaction=main_view#lastused">[' . $this->str['save'] . ']</a>';
// 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';
- }
+ // File manually modified. Add to action error, will be displayed inline.
+ $this->errormsg = $this->str['filemodifiedoutfromeditor'];
}
} else {
$b .= '[' . $this->str['save'] . ']';
$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 ($structure = $dbdir->xml_file->getStructure()) {
+ $errors = !empty($this->errormsg) ? array($this->errormsg) : array();
+ $structureerrors = $structure->getAllErrors();
+ if ($structureerrors) {
+ $errors = array_merge($errors, $structureerrors);
+ }
+ if (!empty($errors)) {
if ($hithis) {
$o .= '<tr class="highlight"><td class="error cell" colspan="10">' . implode (', ', $errors) . '</td></tr>';
} else {
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 will move one field up/down
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$prev = NULL;
$tableparam = required_param('table', PARAM_CLEAN);
$fieldparam = required_param('field', PARAM_CLEAN);
$direction = required_param('direction', PARAM_ALPHA);
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $fields =& $table->getFields();
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $fields = $table->getFields();
if ($direction == 'down') {
- $field =& $table->getField($fieldparam);
- $swap =& $table->getField($field->getNext());
+ $field = $table->getField($fieldparam);
+ $swap = $table->getField($field->getNext());
} else {
- $swap =& $table->getField($fieldparam);
- $field =& $table->getField($swap->getPrevious());
+ $swap = $table->getField($fieldparam);
+ $field = $table->getField($swap->getPrevious());
}
// Change the field before the pair
if ($field->getPrevious()) {
- $prev =& $table->getField($field->getPrevious());
+ $prev = $table->getField($field->getPrevious());
$prev->setNext($swap->getName());
$swap->setPrevious($prev->getName());
$prev->setChanged(true);
}
// Change the field after the pair
if ($swap->getNext()) {
- $next =& $table->getField($swap->getNext());
+ $next = $table->getField($swap->getNext());
$next->setPrevious($field->getName());
$field->setNext($next->getName());
$next->setChanged(true);
$table->setChanged(true);
// Reorder the fields
- $table->orderFields($fields);
+ $table->orderFields();
// Recalculate the hash
$structure->calculateHash(true);
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 will move one index up/down
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$prev = NULL;
$tableparam = required_param('table', PARAM_CLEAN);
$indexparam = required_param('index', PARAM_CLEAN);
$direction = required_param('direction', PARAM_ALPHA);
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $indexes =& $table->getIndexes();
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $indexes = $table->getIndexes();
if ($direction == 'down') {
- $index =& $table->getIndex($indexparam);
- $swap =& $table->getIndex($index->getNext());
+ $index = $table->getIndex($indexparam);
+ $swap = $table->getIndex($index->getNext());
} else {
- $swap =& $table->getIndex($indexparam);
- $index =& $table->getIndex($swap->getPrevious());
+ $swap = $table->getIndex($indexparam);
+ $index = $table->getIndex($swap->getPrevious());
}
// Change the index before the pair
if ($index->getPrevious()) {
- $prev =& $table->getIndex($index->getPrevious());
+ $prev = $table->getIndex($index->getPrevious());
$prev->setNext($swap->getName());
$swap->setPrevious($prev->getName());
$prev->setChanged(true);
}
// Change the field after the pair
if ($swap->getNext()) {
- $next =& $table->getIndex($swap->getNext());
+ $next = $table->getIndex($swap->getNext());
$next->setPrevious($index->getName());
$index->setNext($next->getName());
$next->setChanged(true);
$table->setChanged(true);
// Reorder the indexes
- $table->orderIndexes($indexes);
+ $table->orderIndexes();
// Recalculate the hash
$structure->calculateHash(true);
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 will move one key up/down
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$prev = NULL;
$tableparam = required_param('table', PARAM_CLEAN);
$keyparam = required_param('key', PARAM_CLEAN);
$direction = required_param('direction', PARAM_ALPHA);
- $tables =& $structure->getTables();
- $table =& $structure->getTable($tableparam);
- $keys =& $table->getKeys();
+ $tables = $structure->getTables();
+ $table = $structure->getTable($tableparam);
+ $keys = $table->getKeys();
if ($direction == 'down') {
- $key =& $table->getKey($keyparam);
- $swap =& $table->getKey($key->getNext());
+ $key = $table->getKey($keyparam);
+ $swap = $table->getKey($key->getNext());
} else {
- $swap =& $table->getKey($keyparam);
- $key =& $table->getKey($swap->getPrevious());
+ $swap = $table->getKey($keyparam);
+ $key = $table->getKey($swap->getPrevious());
}
// Change the key before the pair
if ($key->getPrevious()) {
- $prev =& $table->getKey($key->getPrevious());
+ $prev = $table->getKey($key->getPrevious());
$prev->setNext($swap->getName());
$swap->setPrevious($prev->getName());
$prev->setChanged(true);
}
// Change the key after the pair
if ($swap->getNext()) {
- $next =& $table->getKey($swap->getNext());
+ $next = $table->getKey($swap->getNext());
$next->setPrevious($key->getName());
$key->setNext($next->getName());
$next->setChanged(true);
$table->setChanged(true);
// Reorder the keys
- $table->orderKeys($keys);
+ $table->orderKeys();
// Recalculate the hash
$structure->calculateHash(true);
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 will move table up/down
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$prev = NULL;
$next = NULL;
$tableparam = required_param('table', PARAM_CLEAN);
$direction = required_param('direction', PARAM_ALPHA);
- $tables =& $structure->getTables();
+ $tables = $structure->getTables();
if ($direction == 'down') {
- $table =& $structure->getTable($tableparam);
- $swap =& $structure->getTable($table->getNext());
+ $table = $structure->getTable($tableparam);
+ $swap = $structure->getTable($table->getNext());
} else {
- $swap =& $structure->getTable($tableparam);
- $table =& $structure->getTable($swap->getPrevious());
+ $swap = $structure->getTable($tableparam);
+ $table = $structure->getTable($swap->getPrevious());
}
// Change the table before the pair
if ($table->getPrevious()) {
- $prev =& $structure->getTable($table->getPrevious());
+ $prev = $structure->getTable($table->getPrevious());
$prev->setNext($swap->getName());
$swap->setPrevious($prev->getName());
$prev->setChanged(true);
}
// Change the table after the pair
if ($swap->getNext()) {
- $next =& $structure->getTable($swap->getNext());
+ $next = $structure->getTable($swap->getNext());
$next->setPrevious($table->getName());
$table->setNext($next->getName());
$next->setChanged(true);
$table->setChanged(true);
// Reorder the structure
- $structure->orderTables($tables);
- // Send tables back to structure (the order above break refs)
- $structure->setTables($tables);
+ $structure->orderTables();
+
// Recalculate the hash
$structure->calculateHash(true);
// If the hash has changed from the original one, change the version
// and mark the structure as changed
- $origstructure =& $dbdir->xml_file->getStructure();
+ $origstructure = $dbdir->xml_file->getStructure();
if ($structure->getHash() != $origstructure->getHash()) {
$structure->setVersion(userdate(time(), '%Y%m%d', 99, false));
$structure->setChanged(true);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 create a new default field to be edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = required_param('table', PARAM_CLEAN);
- $table =& $structure->getTable($tableparam);
+ $table = $structure->getTable($tableparam);
// If the changeme field exists, just get it and continue
$changeme_exists = false;
- if ($fields =& $table->getFields()) {
- if ($field =& $table->getField('changeme')) {
+ if ($fields = $table->getFields()) {
+ if ($field = $table->getField('changeme')) {
$changeme_exists = true;
}
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 create a new default index to be edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = required_param('table', PARAM_CLEAN);
- $table =& $structure->getTable($tableparam);
+ $table = $structure->getTable($tableparam);
// If the changeme index exists, just get it and continue
$changeme_exists = false;
- if ($indexes =& $table->getIndexes()) {
- if ($index =& $table->getIndex('changeme')) {
+ if ($indexes = $table->getIndexes()) {
+ if ($index = $table->getIndex('changeme')) {
$changeme_exists = true;
}
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 create a new default key to be edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = required_param('table', PARAM_CLEAN);
- $table =& $structure->getTable($tableparam);
+ $table = $structure->getTable($tableparam);
// If the changeme key exists, just get it and continue
$changeme_exists = false;
- if ($keys =& $table->getKeys()) {
- if ($key =& $table->getKey('changeme')) {
+ if ($keys = $table->getKeys()) {
+ if ($key = $table->getKey('changeme')) {
$changeme_exists = true;
}
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 create a new default table to be edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// If the changeme table exists, just get it and continue
$changeme_exists = false;
- if ($tables =& $structure->getTables()) {
- if ($table =& $structure->getTable('changeme')) {
+ if ($tables = $structure->getTables()) {
+ if ($table = $structure->getTable('changeme')) {
$changeme_exists = true;
}
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 ask and retrofit all the information from one
* mysql table present in the Moodle DB to one xmldb_table structure
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = optional_param('table', NULL, PARAM_CLEAN);
}
// Get list of after tables
$aftertables = array();
- if ($tables =& $structure->getTables()) {
+ if ($tables = $structure->getTables()) {
foreach ($tables as $aftertable) {
$aftertables[$aftertable->getName()] = $aftertable->getName();
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 revert changes (delete the editeddb)
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the original dir and delete some elements
if (!empty($XMLDB->dbdirs)) {
if (isset($XMLDB->dbdirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
if ($dbdir) {
unset($dbdir->xml_changed);
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* is going to continue (unload=false). Else (default) the
* file is unloaded once saved.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the edited dir
if (!empty($XMLDB->editeddirs)) {
if (isset($XMLDB->editeddirs[$dirpath])) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
+ $editeddir = $XMLDB->editeddirs[$dirpath];
}
}
// Copy the edited dir over the original one
if (!empty($XMLDB->dbdirs)) {
if (isset($XMLDB->dbdirs[$dirpath])) {
$XMLDB->dbdirs[$dirpath] = unserialize(serialize($editeddir));
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
}
}
- // Chech for perms
+ // Check for perms
if (!is_writeable($dirpath . '/install.xml')) {
$this->errormsg = $this->str['filenotwriteable'] . '(' . $dirpath . '/install.xml)';
return false;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// ADD YOUR CODE HERE
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 unload one loaded file completely
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the original dir and delete some elements
if (!empty($XMLDB->dbdirs)) {
if (isset($XMLDB->dbdirs[$dirpath])) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
if ($dbdir) {
unset($dbdir->xml_file);
unset($dbdir->xml_loaded);
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display the XML for one field being edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if ($select == 'original') {
if (!empty($XMLDB->dbdirs)) {
- $base =& $XMLDB->dbdirs[$dirpath];
+ $base = $XMLDB->dbdirs[$dirpath];
}
} else if ($select == 'edited') {
if (!empty($XMLDB->editeddirs)) {
- $base =& $XMLDB->editeddirs[$dirpath];
+ $base = $XMLDB->editeddirs[$dirpath];
}
} else {
$this->errormsg = 'Cannot access to ' . $select . ' info';
// Get the structure
if ($result) {
- if (!$structure =& $base->xml_file->getStructure()) {
+ if (!$structure = $base->xml_file->getStructure()) {
$this->errormsg = 'Error retrieving ' . $select . ' structure';
$result = false;
}
}
// Get the tables
if ($result) {
- if (!$tables =& $structure->getTables()) {
+ if (!$tables = $structure->getTables()) {
$this->errormsg = 'Error retrieving ' . $select . ' tables';
$result = false;
}
}
// Get the fields
if ($result) {
- if (!$fields =& $t->getFields()) {
+ if (!$fields = $t->getFields()) {
$this->errormsg = 'Error retrieving ' . $select . ' fields';
$result = false;
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display the XML for one index being edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if ($select == 'original') {
if (!empty($XMLDB->dbdirs)) {
- $base =& $XMLDB->dbdirs[$dirpath];
+ $base = $XMLDB->dbdirs[$dirpath];
}
} else if ($select == 'edited') {
if (!empty($XMLDB->editeddirs)) {
- $base =& $XMLDB->editeddirs[$dirpath];
+ $base = $XMLDB->editeddirs[$dirpath];
}
} else {
$this->errormsg = 'Cannot access to ' . $select . ' info';
// Get the structure
if ($result) {
- if (!$structure =& $base->xml_file->getStructure()) {
+ if (!$structure = $base->xml_file->getStructure()) {
$this->errormsg = 'Error retrieving ' . $select . ' structure';
$result = false;
}
}
// Get the tables
if ($result) {
- if (!$tables =& $structure->getTables()) {
+ if (!$tables = $structure->getTables()) {
$this->errormsg = 'Error retrieving ' . $select . ' tables';
$result = false;
}
}
// Get the table
- if ($result && !$t =& $structure->getTable($table)) {
+ if ($result && !$t = $structure->getTable($table)) {
$this->errormsg = 'Error retrieving ' . $table . ' table';
$result = false;
}
// Get the indexes
if ($result) {
- if (!$indexes =& $t->getIndexes()) {
+ if (!$indexes = $t->getIndexes()) {
$this->errormsg = 'Error retrieving ' . $select . ' indexes';
$result = false;
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display the XML for one key being edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if ($select == 'original') {
if (!empty($XMLDB->dbdirs)) {
- $base =& $XMLDB->dbdirs[$dirpath];
+ $base = $XMLDB->dbdirs[$dirpath];
}
} else if ($select == 'edited') {
if (!empty($XMLDB->editeddirs)) {
- $base =& $XMLDB->editeddirs[$dirpath];
+ $base = $XMLDB->editeddirs[$dirpath];
}
} else {
$this->errormsg = 'Cannot access to ' . $select . ' info';
// Get the structure
if ($result) {
- if (!$structure =& $base->xml_file->getStructure()) {
+ if (!$structure = $base->xml_file->getStructure()) {
$this->errormsg = 'Error retrieving ' . $select . ' structure';
$result = false;
}
}
// Get the tables
if ($result) {
- if (!$tables =& $structure->getTables()) {
+ if (!$tables = $structure->getTables()) {
$this->errormsg = 'Error retrieving ' . $select . ' tables';
$result = false;
}
}
// Get the table
- if ($result && !$t =& $structure->getTable($table)) {
+ if ($result && !$t = $structure->getTable($table)) {
$this->errormsg = 'Error retrieving ' . $table . ' table';
$result = false;
}
// Get the keys
if ($result) {
- if (!$keys =& $t->getKeys()) {
+ if (!$keys = $t->getKeys()) {
$this->errormsg = 'Error retrieving ' . $select . ' keys';
$result = false;
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* http://docs.moodle.org/en/Database_reserved_words
* Also, it introspects te DB looking for such words and informing about
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 PHP needed (upgrade block) to perform
* the desired DDL action with the specified table
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
- $tables =& $structure->getTables();
+ $tables = $structure->getTables();
$table = reset($tables);
$defaulttable = null;
if ($table) {
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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
* the entire XMLDB file
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// The back to edit table button
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display the XML for one structure
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if ($select == 'original') {
if (!empty($XMLDB->dbdirs)) {
- $base =& $XMLDB->dbdirs[$dirpath];
+ $base = $XMLDB->dbdirs[$dirpath];
}
} else if ($select == 'edited') {
if (!empty($XMLDB->editeddirs)) {
- $base =& $XMLDB->editeddirs[$dirpath];
+ $base = $XMLDB->editeddirs[$dirpath];
}
} else {
$this->errormsg = 'Cannot access to ' . $select . ' info';
// Get the structure
if ($result) {
- if (!$structure =& $base->xml_file->getStructure()) {
+ if (!$structure = $base->xml_file->getStructure()) {
$this->errormsg = 'Error retrieving ' . $select . ' structure';
$result = false;
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 PHP needed (upgrade block) to perform
* the desired DDL action with the specified field/key/index
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
$tableparam = required_param('table', PARAM_PATH);
- $table =& $structure->getTable($tableparam);
+ $table = $structure->getTable($tableparam);
$fields = $table->getFields();
$field = reset($fields);
$defaultfieldkeyindex = null;
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
- $dbdir =& $XMLDB->dbdirs[$dirpath];
+ $dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
if (!empty($XMLDB->editeddirs)) {
- $editeddir =& $XMLDB->editeddirs[$dirpath];
- $structure =& $editeddir->xml_file->getStructure();
+ $editeddir = $XMLDB->editeddirs[$dirpath];
+ $structure = $editeddir->xml_file->getStructure();
}
// Get parameters
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display the XML for one table being edited
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the correct dir
if ($select == 'original') {
if (!empty($XMLDB->dbdirs)) {
- $base =& $XMLDB->dbdirs[$dirpath];
+ $base = $XMLDB->dbdirs[$dirpath];
}
} else if ($select == 'edited') {
if (!empty($XMLDB->editeddirs)) {
- $base =& $XMLDB->editeddirs[$dirpath];
+ $base = $XMLDB->editeddirs[$dirpath];
}
} else {
$this->errormsg = 'Cannot access to ' . $select . ' info';
// Get the structure
if ($result) {
- if (!$structure =& $base->xml_file->getStructure()) {
+ if (!$structure = $base->xml_file->getStructure()) {
$this->errormsg = 'Error retrieving ' . $select . ' structure';
$result = false;
}
}
// Get the tables
if ($result) {
- if (!$tables =& $structure->getTables()) {
+ if (!$tables = $structure->getTables()) {
$this->errormsg = 'Error retrieving ' . $select . ' tables';
$result = false;
}
}
// Get the table
- if ($result && !$t =& $structure->getTable($table)) {
+ if ($result && !$t = $structure->getTable($table)) {
$this->errormsg = 'Error retrieving ' . $table . ' table';
$result = false;
}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * @package tool
- * @subpackage xmldb
+ * @package tool_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 display one XML file
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
* Invoke method, every class will have its own
* returns true/false on completion, setting both
* errormsg and output as necessary
+ * @return mixed
*/
function invoke() {
parent::invoke();
* This is the main script for the complete XMLDB interface. From here
* all the actions supported will be launched.
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com,
* (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
- require('../../../config.php');
- require_once($CFG->libdir.'/adminlib.php');
- require_once($CFG->libdir.'/ddllib.php');
- // Add required XMLDB action classes
- require_once('actions/XMLDBAction.class.php');
- require_once('actions/XMLDBCheckAction.class.php');
-
-
- admin_externalpage_setup('toolxmld');
-
- // Add other used libraries
- require_once($CFG->libdir . '/xmlize.php');
-
- // Handle session data
- global $XMLDB;
-
- // State is stored in session - we have to serialise it because the classes are not loaded when creating session
- if (!isset($SESSION->xmldb)) {
- $XMLDB = new stdClass;
- } else {
- $XMLDB = unserialize($SESSION->xmldb);
- }
-
- // Some previous checks
- $site = get_site();
-
- require_login();
- require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
-
- // Body of the script, based on action, we delegate the work
- $action = optional_param ('action', 'main_view', PARAM_ALPHAEXT);
-
- // Get the action path and invoke it
- $actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions";
- $actionclass = $action . '.class.php';
- $actionpath = "$actionsroot/$action/$actionclass";
-
- // Load and invoke the proper action
- if (file_exists($actionpath) && is_readable($actionpath)) {
- require_once($actionpath);
- if ($xmldb_action = new $action) {
- // Invoke it
- $result = $xmldb_action->invoke();
- // store the result in session
- $SESSION->xmldb = serialize($XMLDB);
-
- if ($result) {
- // Based on getDoesGenerate()
- switch ($xmldb_action->getDoesGenerate()) {
- case ACTION_GENERATE_HTML:
-
- $action = optional_param('action', '', PARAM_ALPHAEXT);
- $postaction = optional_param('postaction', '', PARAM_ALPHAEXT);
- // If the js exists, load it
- if ($action) {
- $script = $CFG->admin . '/tool/xmldb/actions/' . $action . '/' . $action . '.js';
+require('../../../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/ddllib.php');
+// Add required XMLDB action classes
+require_once('actions/XMLDBAction.class.php');
+require_once('actions/XMLDBCheckAction.class.php');
+
+
+admin_externalpage_setup('toolxmld');
+
+// Add other used libraries
+require_once($CFG->libdir . '/xmlize.php');
+
+// Handle session data
+global $XMLDB;
+
+// State is stored in session - we have to serialise it because the classes are not loaded when creating session
+if (!isset($SESSION->xmldb)) {
+ $XMLDB = new stdClass;
+} else {
+ $XMLDB = unserialize($SESSION->xmldb);
+}
+
+// Some previous checks
+$site = get_site();
+
+require_login();
+require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
+
+// Body of the script, based on action, we delegate the work
+$action = optional_param ('action', 'main_view', PARAM_ALPHAEXT);
+
+// Get the action path and invoke it
+$actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions";
+$actionclass = $action . '.class.php';
+$actionpath = "$actionsroot/$action/$actionclass";
+
+// Load and invoke the proper action
+if (file_exists($actionpath) && is_readable($actionpath)) {
+ require_once($actionpath);
+ if ($xmldb_action = new $action) {
+ // Invoke it
+ $result = $xmldb_action->invoke();
+ // store the result in session
+ $SESSION->xmldb = serialize($XMLDB);
+
+ if ($result) {
+ // Based on getDoesGenerate()
+ switch ($xmldb_action->getDoesGenerate()) {
+ case ACTION_GENERATE_HTML:
+
+ $action = optional_param('action', '', PARAM_ALPHAEXT);
+ $postaction = optional_param('postaction', '', PARAM_ALPHAEXT);
+ // If the js exists, load it
+ if ($action) {
+ $script = $CFG->admin . '/tool/xmldb/actions/' . $action . '/' . $action . '.js';
+ $file = $CFG->dirroot . '/' . $script;
+ if (file_exists($file) && is_readable($file)) {
+ $PAGE->requires->js('/'.$script);
+ } else if ($postaction) {
+ // Try to load the postaction javascript if exists
+ $script = $CFG->admin . '/tool/xmldb/actions/' . $postaction . '/' . $postaction . '.js';
$file = $CFG->dirroot . '/' . $script;
if (file_exists($file) && is_readable($file)) {
$PAGE->requires->js('/'.$script);
- } else if ($postaction) {
- // Try to load the postaction javascript if exists
- $script = $CFG->admin . '/tool/xmldb/actions/' . $postaction . '/' . $postaction . '.js';
- $file = $CFG->dirroot . '/' . $script;
- if (file_exists($file) && is_readable($file)) {
- $PAGE->requires->js('/'.$script);
- }
}
}
-
- // Go with standard admin header
- echo $OUTPUT->header();
- echo $OUTPUT->heading($xmldb_action->getTitle());
- echo $xmldb_action->getOutput();
- echo $OUTPUT->footer();
- break;
- case ACTION_GENERATE_XML:
- header('Content-type: application/xhtml+xml; charset=utf-8');
- echo $xmldb_action->getOutput();
- break;
- }
- } else {
- // TODO: need more detailed error info
- print_error('xmldberror');
+ }
+
+ // Go with standard admin header
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading($xmldb_action->getTitle());
+ echo $xmldb_action->getOutput();
+ echo $OUTPUT->footer();
+ break;
+ case ACTION_GENERATE_XML:
+ header('Content-type: application/xhtml+xml; charset=utf-8');
+ echo $xmldb_action->getOutput();
+ break;
}
} else {
- $a = new stdClass();
- $a->action = $action;
- $a->actionclass = $actionclass;
- print_error('cannotinstantiateclass', 'tool_xmldb', '', $a);
+ // TODO: need more detailed error info
+ print_error('xmldberror');
}
} else {
- print_error('invalidaction');
+ $a = new stdClass();
+ $a->action = $action;
+ $a->actionclass = $actionclass;
+ print_error('cannotinstantiateclass', 'tool_xmldb', '', $a);
}
+} else {
+ print_error('invalidaction');
+}
- if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {
- if (debugging()) {
- // print_object($XMLDB);
- }
+if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {
+ if (debugging()) {
+ // print_object($XMLDB);
}
+}
/**
* Strings for component 'tool_xmldb', language 'en', branch 'MOODLE_22_STABLE'
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['fieldsnotintable'] = 'Field doesn\'t exist in table';
$string['fieldsusedinindex'] = 'This field is used as index';
$string['fieldsusedinkey'] = 'This field is used as key.';
+$string['filemodifiedoutfromeditor'] = 'Warning: File locally modified while using the XMLDB Editor. Saving will overwrite local changes.';
$string['filenotwriteable'] = 'File not writeable';
$string['fkviolationdetails'] = 'Foreign key {$a->keyname} on table {$a->tablename} is violated by {$a->numviolations} out of {$a->numrows} rows.';
$string['floatincorrectdecimals'] = 'Incorrect number of decimals for float field';
/**
* Link to xmldb editor
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Plugin version info
*
- * @package tool
- * @subpackage xmldb
+ * @package tool_xmldb
* @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$array_index++;
if ($item->nodeName == "item") {
+ $identifierref = '';
+ if ($item->hasAttribute('identifierref')) {
+ $identifierref = $item->getAttribute('identifierref');
+ }
- $identifierref = $xpath->query('@identifierref', $item);
- $identifierref = !empty($identifierref->item(0)->nodeValue) ? $identifierref->item(0)->nodeValue : '';
-
- $title = $xpath->query('imscc:title', $item);
- $title = !empty($title->item(0)->nodeValue) ? $title->item(0)->nodeValue : '';
+ $title = '';
+ $titles = $xpath->query('imscc:title', $item);
+ if ($titles->length > 0) {
+ $title = $titles->item(0)->nodeValue;
+ }
$cc_type = $this->get_item_cc_type($identifierref);
$moodle_type = $this->convert_to_moodle_type($cc_type);
+ //Fix the label issue - MDL-33523
+ if (empty($identifierref) && empty($title)) {
+ $moodle_type = TYPE_UNKNOWN;
+ }
}
elseif ($item->nodeName == "resource") {
if (!empty($labels) && ($labels->length > 0)) {
$tname = 'course_files';
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
- $rfpath = 'folder.gif';
+ $rfpath = 'files.gif';
$fpath = $dpath . DIRECTORY_SEPARATOR . $rfpath;
if (!file_exists($dpath)) {
mkdir($dpath);
}
//copy the folder.gif file
- $folder_gif = "{$CFG->dirroot}/pix/f/folder.gif";
+ $folder_gif = "{$CFG->dirroot}/pix/i/files.gif";
copy($folder_gif, $fpath);
$all_files[] = $rfpath;
}
if (!empty($labels) && ($labels->length > 0)) {
$tname = 'course_files';
$dpath = cc2moodle::$path_to_manifest_folder . DIRECTORY_SEPARATOR . $tname;
- $rfpath = 'folder.gif';
- $fpath = $dpath . DIRECTORY_SEPARATOR . 'folder.gif';
+ $rfpath = 'files.gif';
+ $fpath = $dpath . DIRECTORY_SEPARATOR . 'files.gif';
if (!file_exists($dpath)) {
mkdir($dpath);
}
//copy the folder.gif file
- $folder_gif = "{$CFG->dirroot}/pix/f/folder.gif";
+ $folder_gif = "{$CFG->dirroot}/pix/i/files.gif";
copy($folder_gif, $fpath);
$all_files[] = $rfpath;
}
'[#date_now#]');
$title = isset($instance['title']) && !empty($instance['title']) ? $instance['title'] : 'Untitled';
- $content = "<img src=\"$@FILEPHP@$$@SLASH@$"."folder.gif\" alt=\"Folder\" title=\"{$title}\" /> {$title}";
+ $content = "<img src=\"$@FILEPHP@$$@SLASH@$"."files.gif\" alt=\"Folder\" title=\"{$title}\" /> {$title}";
$replace_values = array($instance['instance'],
self::safexml($title),
self::safexml($content),
'lang', 'theme', 'timezone', 'firstaccess',
'lastaccess', 'lastlogin', 'currentlogin',
'mailformat', 'maildigest', 'maildisplay', 'htmleditor',
- 'ajax', 'autosubscribe', 'trackforums', 'timecreated',
+ 'autosubscribe', 'trackforums', 'timecreated',
'timemodified', 'trustbitmask', 'screenreader');
// Then, the fields potentially needing anonymization
require_once($CFG->dirroot .'/blog/lib.php');
require_once($CFG->dirroot .'/blog/locallib.php');
+ if (empty($this->config)) {
+ $this->config = new stdClass();
+ }
+
if (empty($this->config->recentbloginterval)) {
$this->config->recentbloginterval = 8400;
}
// require the libs and do the work
require_once($CFG->dirroot .'/blog/lib.php');
+ if (empty($this->config)) {
+ $this->config = new stdClass();
+ }
+
if (empty($this->config->timewithin)) {
$this->config->timewithin = BLOCK_BLOG_TAGS_DEFAULTTIMEWITHIN;
}
/// Give the options for what to do.
$mform->addElement('select', 'fulldelete', get_string('whattodo'), $options);
if (count($options) == 1) {
+ $optionkeys = array_keys($options);
+ $option = reset($optionkeys);
$mform->hardFreeze('fulldelete');
- $mform->setConstant('fulldelete', reset(array_keys($options)));
+ $mform->setConstant('fulldelete', $option);
}
if ($displaylist) {
}
}
- // Adjust destination to reflect the actual section
- $moveup = false;
- if ($section > $destination) {
- $destination++;
- $moveup = true;
- }
-
// If we move the highlighted section itself, then just highlight the destination.
// Adjust the higlighted section location if we move something over it either direction.
if ($section == $course->marker) {
course_set_marker($course->id, $destination);
- } elseif ($moveup && $section > $course->marker && $course->marker >= $destination) {
+ } elseif ($section > $course->marker && $course->marker >= $destination) {
course_set_marker($course->id, $course->marker+1);
- } elseif (!$moveup && $section < $course->marker && $course->marker <= $destination) {
+ } elseif ($section < $course->marker && $course->marker <= $destination) {
course_set_marker($course->id, $course->marker-1);
}
$this->assertFalse($neworder);
}
- public function test_move_section() {
+ public function test_move_section_down() {
global $DB;
$this->resetAfterTest(true);
}
ksort($oldsections);
+ // Test move section down..
move_section_to($course, 2, 4);
$sections = array();
foreach ($DB->get_records('course_sections', array('course'=>$course->id)) as $section) {
$this->assertEquals($oldsections[6], $sections[6]);
}
+ public function test_move_section_up() {
+ global $DB;
+ $this->resetAfterTest(true);
+
+ $this->getDataGenerator()->create_course(array('numsections'=>5), array('createsections'=>true));
+ $course = $this->getDataGenerator()->create_course(array('numsections'=>10), array('createsections'=>true));
+ $oldsections = array();
+ foreach ($DB->get_records('course_sections', array('course'=>$course->id)) as $section) {
+ $oldsections[$section->section] = $section->id;
+ }
+ ksort($oldsections);
+
+ // Test move section up..
+ move_section_to($course, 6, 4);
+ $sections = array();
+ foreach ($DB->get_records('course_sections', array('course'=>$course->id)) as $section) {
+ $sections[$section->section] = $section->id;
+ }
+ ksort($sections);
+
+ $this->assertEquals($oldsections[0], $sections[0]);
+ $this->assertEquals($oldsections[1], $sections[1]);
+ $this->assertEquals($oldsections[2], $sections[2]);
+ $this->assertEquals($oldsections[3], $sections[3]);
+ $this->assertEquals($oldsections[4], $sections[5]);
+ $this->assertEquals($oldsections[5], $sections[6]);
+ $this->assertEquals($oldsections[6], $sections[4]);
+ }
+
+ public function test_move_section_marker() {
+ global $DB;
+ $this->resetAfterTest(true);
+
+ $this->getDataGenerator()->create_course(array('numsections'=>5), array('createsections'=>true));
+ $course = $this->getDataGenerator()->create_course(array('numsections'=>10), array('createsections'=>true));
+
+ // Set course marker to the section we are going to move..
+ course_set_marker($course->id, 2);
+ // Verify that the course marker is set correctly.
+ $course = $DB->get_record('course', array('id' => $course->id));
+ $this->assertEquals(2, $course->marker);
+
+ // Test move the marked section down..
+ move_section_to($course, 2, 4);
+
+ // Verify that the coruse marker has been moved along with the section..
+ $course = $DB->get_record('course', array('id' => $course->id));
+ $this->assertEquals(4, $course->marker);
+
+ // Test move the marked section up..
+ move_section_to($course, 4, 3);
+
+ // Verify that the course marker has been moved along with the section..
+ $course = $DB->get_record('course', array('id' => $course->id));
+ $this->assertEquals(3, $course->marker);
+
+ // Test moving a non-marked section above the marked section..
+ move_section_to($course, 4, 2);
+
+ // Verify that the course marker has been moved down to accomodate..
+ $course = $DB->get_record('course', array('id' => $course->id));
+ $this->assertEquals(4, $course->marker);
+
+ // Test moving a non-marked section below the marked section..
+ move_section_to($course, 3, 6);
+
+ // Verify that the course marker has been up to accomodate..
+ $course = $DB->get_record('course', array('id' => $course->id));
+ $this->assertEquals(3, $course->marker);
+ }
+
public function test_get_course_display_name_for_list() {
global $CFG;
$this->resetAfterTest(true);
},
_setup_for_section : function(section, sectionid) {
var chooserspan = section.one(CSS.SECTIONMODCHOOSER);
+ if (!chooserspan) {
+ return;
+ }
var chooserlink = Y.Node.create("<a href='#' />");
chooserspan.get('children').each(function(node) {
chooserlink.appendChild(node);
$rv = '
<div class="filemanager fp-mkdir-dlg">
<div class="fp-mkdir-dlg-text">'.get_string('newfoldername','repository').'<br/><input type="text" /></div>
- <a class="{!}fp-dlg-butcreate fp-panel-button" href="#">'.get_string('makeafolder').'</a>
- <a class="{!}fp-dlg-butcancel fp-panel-button" href="#">'.get_string('cancel').'</a>
+ <button class="{!}fp-dlg-butcreate">'.get_string('makeafolder').'</button>
+ <button class="{!}fp-dlg-butcancel">'.get_string('cancel').'</button>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
<p>'.get_string('loading', 'repository').'</p>
</div>
<form>
- <div><a class="{!}fp-file-download fp-panel-button" href="#">'.get_string('download').'</a>
- <a class="{!}fp-file-delete fp-panel-button" href="#">'.get_string('delete').'</a>
- <a class="{!}fp-file-setmain fp-panel-button" href="#">'.get_string('setmainfile', 'repository').'</a>
- <a class="{!}fp-file-zip fp-panel-button" href="#">'.get_string('zip', 'editor').'</a>
- <a class="{!}fp-file-unzip fp-panel-button" href="#">'.get_string('unzip').'</a>
- </div>
+ <button class="{!}fp-file-download">'.get_string('download').'</button>
+ <button class="{!}fp-file-delete">'.get_string('delete').'</button>
+ <button class="{!}fp-file-setmain">'.get_string('setmainfile', 'repository').'</button>
+ <button class="{!}fp-file-zip">'.get_string('zip', 'editor').'</button>
+ <button class="{!}fp-file-unzip">'.get_string('unzip').'</button>
<div class="fp-hr"></div>
<table>
<tr class="{!}fp-saveas"><td class="mdl-right"><label>'.get_string('name', 'moodle').'</label>:</td>
<tr class="{!}fp-reflist"><td class="mdl-right"><label>'.get_string('referenceslist', 'repository').'</label>:</td>
<td class="mdl-left"><p class="{!}fp-refcount"></p><span class="fp-reflistloading">'.$icon_progress.' '.$strloading.'</span><ul class="fp-value"></ul></td></tr>
</table>
+ <div class="fp-select-buttons">
+ <button class="{!}fp-file-update">'.get_string('update', 'moodle').'</button>
+ <button class="{!}fp-file-cancel">'.get_string('cancel').'</button>
+ </div>
</form>
- <p class="{!}fp-thumbnail"></p>
- <form>
- <p class="fp-select-update">
- <a class="{!}fp-file-update" href="#"><span>'.get_string('update', 'moodle').'</span></a>
- <a class="{!}fp-file-cancel" href="#"><span>'.get_string('cancel').'</span></a>
- </p>
- </form>
- <div class="fp-fileinfo">
- <div class="{!}fp-datemodified">'.get_string('lastmodified', 'moodle').': <span class="fp-value"></span></div>
- <div class="{!}fp-datecreated">'.get_string('datecreated', 'repository').': <span class="fp-value"></span></div>
- <div class="{!}fp-size">'.get_string('size', 'repository').': <span class="fp-value"></span></div>
- <div class="{!}fp-dimensions">'.get_string('dimensions', 'repository').': <span class="fp-value"></span></div>
+ <div class="fp-info">
+ <div class="fp-hr"></div>
+ <p class="{!}fp-thumbnail"></p>
+ <div class="fp-fileinfo">
+ <div class="{!}fp-datemodified">'.get_string('lastmodified', 'moodle').': <span class="fp-value"></span></div>
+ <div class="{!}fp-datecreated">'.get_string('datecreated', 'repository').': <span class="fp-value"></span></div>
+ <div class="{!}fp-size">'.get_string('size', 'repository').': <span class="fp-value"></span></div>
+ <div class="{!}fp-dimensions">'.get_string('dimensions', 'repository').': <span class="fp-value"></span></div>
+ </div>
</div>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
$rv = '
<div class="filemanager fp-dlg">
<div class="{!}fp-dlg-text"></div>
- <a class="{!}fp-dlg-butconfirm fp-panel-button" href="#">'.get_string('ok').'</a>
- <a class="{!}fp-dlg-butcancel fp-panel-button" href="#">'.get_string('cancel').'</a>
+ <button class="{!}fp-dlg-butconfirm">'.get_string('delete').'</button>
+ <button class="{!}fp-dlg-butcancel">'.get_string('cancel').'</button>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
private function fp_js_template_iconfilename() {
$rv = '
<a class="fp-file" href="#" >
- <div class="{!}fp-thumbnail"></div>
+ <div style="position:relative;">
+ <div class="{!}fp-thumbnail"></div>
+ <div class="fp-reficons1"></div>
+ <div class="fp-reficons2"></div>
+ </div>
<div class="fp-filename-field">
<p class="{!}fp-filename"></p>
</div>
<p>'.get_string('loading', 'repository').'</p>
</div>
<form>
- <div>
- <a class="{!}fp-select-confirm fp-panel-button" href="#">'.get_string('getfile', 'repository').'</a>
- <a class="{!}fp-select-cancel fp-panel-button" href="#">'.get_string('cancel').'</a>
- </div>
- <div class="fp-hr"></div>
<table>
<tr class="{!}fp-linktype-2">
<td></td>
<td class="mdl-right"><label>'.get_string('chooselicense', 'repository').'</label>:</td>
<td class="mdl-left"><select></select></td></tr>
</table>
+ <div class="fp-select-buttons">
+ <button class="{!}fp-select-confirm">'.get_string('getfile', 'repository').'</button>
+ <button class="{!}fp-select-cancel">'.get_string('cancel').'</button>
+ </div>
</form>
- <p class="{!}fp-thumbnail"></p>
- <div class="fp-fileinfo">
- <div class="{!}fp-datemodified">'.get_string('lastmodified', 'moodle').': <span class="fp-value"></span></div>
- <div class="{!}fp-datecreated">'.get_string('datecreated', 'repository').': <span class="fp-value"></span></div>
- <div class="{!}fp-size">'.get_string('size', 'repository').': <span class="fp-value"></span></div>
- <div class="{!}fp-license">'.get_string('license', 'moodle').': <span class="fp-value"></span></div>
- <div class="{!}fp-author">'.get_string('author', 'repository').': <span class="fp-value"></span></div>
- <div class="{!}fp-dimensions">'.get_string('dimensions', 'repository').': <span class="fp-value"></span></div>
- </div>
+ <div class="fp-info">
+ <div class="fp-hr"></div>
+ <p class="{!}fp-thumbnail"></p>
+ <div class="fp-fileinfo">
+ <div class="{!}fp-datemodified">'.get_string('lastmodified', 'moodle').': <span class="fp-value"></span></div>
+ <div class="{!}fp-datecreated">'.get_string('datecreated', 'repository').': <span class="fp-value"></span></div>
+ <div class="{!}fp-size">'.get_string('size', 'repository').': <span class="fp-value"></span></div>
+ <div class="{!}fp-license">'.get_string('license', 'moodle').': <span class="fp-value"></span></div>
+ <div class="{!}fp-author">'.get_string('author', 'repository').': <span class="fp-value"></span></div>
+ <div class="{!}fp-dimensions">'.get_string('dimensions', 'repository').': <span class="fp-value"></span></div>
+ </div>
+ <div>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
$rv = '
<div class="file-picker fp-msg">
<p class="{!}fp-msg-text"></p>
- <a class="{!}fp-msg-butok fp-panel-button" href="#">'.get_string('ok').'</a>
+ <button class="{!}fp-msg-butok">'.get_string('ok').'</button>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
* Must have one top element, CSS for this element must define width and height of the window;
*
* content of element with class 'fp-dlg-text' will be replaced with dialog text;
- * elements with classes 'fp-dlg-butoverwrite', 'fp-dlg-butrename' and 'fp-dlg-butcancel' will
+ * elements with classes 'fp-dlg-butoverwrite', 'fp-dlg-butrename',
+ * 'fp-dlg-butoverwriteall', 'fp-dlg-butrenameall' and 'fp-dlg-butcancel' will
* hold onclick events;
*
* content of element with class 'fp-dlg-butrename' will be substituted with appropriate string
*/
private function fp_js_template_processexistingfile() {
$rv = '
+<div class="file-picker fp-dlg">
+ <p class="{!}fp-dlg-text"></p>
+ <div class="fp-dlg-buttons">
+ <button class="{!}fp-dlg-butoverwrite">'.get_string('overwrite', 'repository').'</button>
+ <button class="{!}fp-dlg-butrename"></button>
+ <button class="{!}fp-dlg-butcancel">'.get_string('cancel').'</button>
+ </div>
+</div>';
+ return preg_replace('/\{\!\}/', '', $rv);
+ }
+
+ /**
+ * FilePicker JS template for popup dialogue window asking for action when file with the same name already exists (multiple-file version).
+ *
+ * Must have one top element, CSS for this element must define width and height of the window;
+ *
+ * content of element with class 'fp-dlg-text' will be replaced with dialog text;
+ * elements with classes 'fp-dlg-butoverwrite', 'fp-dlg-butrename' and 'fp-dlg-butcancel' will
+ * hold onclick events;
+ *
+ * content of element with class 'fp-dlg-butrename' will be substituted with appropriate string
+ * (Note that it may have long text)
+ *
+ * @return string
+ */
+ private function fp_js_template_processexistingfilemultiple() {
+ $rv = '
<div class="file-picker fp-dlg">
<p class="{!}fp-dlg-text"></p>
<a class="{!}fp-dlg-butoverwrite fp-panel-button" href="#">'.get_string('overwrite', 'repository').'</a>
<a class="{!}fp-dlg-butcancel fp-panel-button" href="#">'.get_string('cancel').'</a>
<a class="{!}fp-dlg-butrename fp-panel-button" href="#"></a>
+ <br/>
+ <a class="{!}fp-dlg-butoverwriteall fp-panel-button" href="#">'.get_string('overwriteall', 'repository').'</a>
+ <a class="{!}fp-dlg-butrenameall fp-panel-button" href="#">'.get_string('renameall', 'repository').'</a>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
$string['advancedsettings'] = 'Advanced settings';
$string['again'] = 'again';
$string['aimid'] = 'AIM ID';
-$string['ajaxno'] = 'No: use basic web features';
$string['ajaxuse'] = 'AJAX and Javascript';
-$string['ajaxyes'] = 'Yes: use advanced web features';
$string['all'] = 'All';
$string['allactions'] = 'All actions';
$string['allactivities'] = 'All activities';
$string['failedloginattemptsall'] = '{$a->attempts} failed logins for {$a->accounts} accounts';
$string['feedback'] = 'Feedback';
$string['file'] = 'File';
+$string['fileexists'] = 'There is already a file called {$a}';
$string['filemissing'] = '{$a} is missing';
$string['filetoolarge'] = 'is too large to upload';
$string['files'] = 'Files';
$string['uploadextension'] = 'File upload stopped by extension';
$string['uploadfailednotrecovering'] = 'Your file upload has failed because there was a problem with one of the files, {$a->name}.<br /> Here is a log of the problems:<br />{$a->problem}<br />Not recovering.';
$string['uploadfilelog'] = 'Upload log for file {$a}';
-$string['uploadformlimit'] = 'Uploaded file exceeded the maximum size limit set by the form';
+$string['uploadformlimit'] = 'Uploaded file {$a} exceeded the maximum size limit set by the form';
$string['uploadlabel'] = 'Title:';
$string['uploadnewfile'] = 'Upload new file';
$string['uploadnofilefound'] = 'No file was found - are you sure you selected one to upload?';
$string['operation'] = 'Operation';
$string['on'] = 'Enabled and visible';
$string['overwrite'] = 'Overwrite';
+$string['overwriteall'] = 'Overwrite all';
$string['personalrepositories'] = 'Available repository instances';
$string['plugin'] = 'Repository plug-ins';
$string['pluginerror'] = 'Errors in repository plugin.';
$string['refresh'] = 'Refresh';
$string['refreshnonjsfilepicker'] = 'Please close this window and refresh non-javascript file picker';
$string['removed'] = 'Repository removed';
+$string['renameall'] = 'Rename all';
$string['renameto'] = 'Rename to "{$a}"';
$string['repositories'] = 'Repositories';
$string['repository'] = 'Repository';
* @return bool
*/
function ajaxenabled(array $browsers = null) {
- global $CFG, $USER;
+ global $CFG;
if (!empty($browsers)) {
$valid = false;
return false;
}
- if (!empty($CFG->enableajax) && (!empty($USER->ajax) || !isloggedin())) {
+ if (!empty($CFG->enableajax)) {
return true;
} else {
return false;
}
-}
\ No newline at end of file
+}
* Uses the array of user agents to test ajax_lib::ajaxenabled
*/
function test_ajaxenabled() {
- global $CFG, $USER;
+ global $CFG;
$this->resetAfterTest(true);
$CFG->enableajax = 1;
- $USER->ajax = 1;
// Should be true
$_SERVER['HTTP_USER_AGENT'] = $this->user_agents['Firefox']['2.0']['Windows XP'];
/** @var string */
public $auth_token = '';
/** @var string */
- private $_box_api_url = 'http://box.net/api/1.0/rest';
- private $_box_api_upload_url = 'http://upload.box.net/api/1.0/upload';
+ private $_box_api_url = 'https://www.box.com/api/1.0/rest';
+ private $_box_api_upload_url = 'http://upload.box.com/api/1.0/upload';
+ private $_box_api_download_url = 'http://www.box.com/api/1.0/download';
+ private $_box_api_auth_url = 'http://www.box.com/api/1.0/auth';
private $_error_code = '';
private $_error_msg = '';
/** @var bool */
function makeRequest($method, $params = array()) {
$this->_clearErrors();
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
+ $c->setopt(array('CURLOPT_FOLLOWLOCATION'=>1));
try {
if ($method == 'upload'){
$request = $this->_box_api_upload_url.'/'.
'__login'=>1
);
try {
- $ret = $c->post('http://www.box.net/api/1.0/auth/'.$ticket, $param);
+ $ret = $c->post($this->_box_api_auth_url.'/'.$ticket, $param);
} catch (moodle_exception $e) {
$this->setError(0, 'connection time-out or invalid url');
return false;
$params['onelevel'] = 1;
$params['params[]'] = 'nozip';
$c = new curl(array('debug'=>$this->debug, 'cache'=>true, 'module_cache'=>'repository'));
+ $c->setopt(array('CURLOPT_FOLLOWLOCATION'=>1));
try {
$args = array();
$xml = $c->get($this->_box_api_url, $params);
foreach($o->folder as $z){
$tmp = array('title'=>(string)$z->attributes()->name,
'size'=>0, 'date'=>userdate(time()),
- 'thumbnail'=>'http://www.box.net/img/small_folder_icon.gif',
+ 'thumbnail'=>'https://www.box.com/img/small_folder_icon.gif',
'path'=>array('name'=>(string)$z->attributes()->name, 'path'=>(int)$z->attributes()->id));
$tmp['children'] = array();
$this->buildtree($z, $tmp['children']);
foreach($val as $file){
$thumbnail = (string)$file->attributes()->thumbnail;
if (!preg_match('#^(?:http://)?([^/]+)#i', $thumbnail)) {
- $thumbnail = 'http://www.box.net'.$thumbnail;
+ $thumbnail = 'http://www.box.com'.$thumbnail;
}
$tmp = array('title'=>(string)$file->attributes()->file_name,
'size'=>display_size((int)$file->attributes()->size),
'thumbnail'=>$thumbnail,
'date'=>userdate((int)$file->attributes()->updated),
- 'source'=>'http://box.net/api/1.0/download/'
+ 'source'=> $this->_box_api_download_url .'/'
.$this->auth_token.'/'.(string)$file->attributes()->id,
'url'=>(string)$file->attributes()->shared_link);
$tree[] = $tmp;
if (preg_match('#^(?:http://)?([^/]+)#i', $a['attributes']['THUMBNAIL'])) {
@$ret_array['thumbnail'][$i] = $a['attributes']['THUMBNAIL'];
} else {
- @$ret_array['thumbnail'][$i] = 'http://www.box.net'.$a['attributes']['THUMBNAIL'];
+ @$ret_array['thumbnail'][$i] = 'http://www.box.com'.$a['attributes']['THUMBNAIL'];
}
$entry_count++;
}
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20120531" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20120618" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="mailformat" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="descriptionformat" NEXT="maildigest"/>
<FIELD NAME="maildigest" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="mailformat" NEXT="maildisplay"/>
<FIELD NAME="maildisplay" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="2" SEQUENCE="false" PREVIOUS="maildigest" NEXT="htmleditor"/>
- <FIELD NAME="htmleditor" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="maildisplay" NEXT="ajax"/>
- <FIELD NAME="ajax" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="htmleditor" NEXT="autosubscribe"/>
- <FIELD NAME="autosubscribe" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="ajax" NEXT="trackforums"/>
+ <FIELD NAME="htmleditor" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="maildisplay" NEXT="autosubscribe"/>
+ <FIELD NAME="autosubscribe" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="htmleditor" NEXT="trackforums"/>
<FIELD NAME="trackforums" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="autosubscribe" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="trackforums" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="trustbitmask"/>
</KEYS>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
upgrade_main_savepoint(true, 2012060600.04);
}
+ if ($oldversion < 2012061800.01) {
+
+ // Define field screenreader to be dropped from user
+ $table = new xmldb_table('user');
+ $field = new xmldb_field('ajax');
+
+ // Conditionally launch drop field screenreader
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->drop_field($table, $field);
+ }
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2012061800.01);
+ }
+
+
return true;
}
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
/**
* Database manager instance is responsible for all database structure modifications.
*
- * @package core
- * @category ddl
- * @subpackage ddl
+ * @package core_ddl
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* 2008 Petr Skoda http://skodak.org
*
* It is using db specific generators to find out the correct SQL syntax to do that.
*
- * @package core
- * @category ddl
- * @subpackage ddl
+ * @package core_ddl
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* 2008 Petr Skoda http://skodak.org
*/
class database_manager {
- /** @var moodle_database A moodle_database driver speific instance.*/
+ /** @var moodle_database A moodle_database driver specific instance.*/
protected $mdb;
+
/** @var sql_generator A driver specific SQL generator instance. Public because XMLDB editor needs to access it.*/
public $generator;
* @param sql_generator $generator A driver specific SQL generator instance.
*/
public function __construct($mdb, $generator) {
- global $CFG;
-
$this->mdb = $mdb;
$this->generator = $generator;
}
/**
* Given one xmldb_table, check if it exists in DB (true/false).
*
- * @param mixed $table The table to be searched (string name or xmldb_table instance).
- * @return bool true/false True is a table exists, false otherwise.
+ * @param string|xmldb_table $table The table to be searched (string name or xmldb_table instance).
+ * @return bool True is a table exists, false otherwise.
*/
public function table_exists($table) {
if (!is_string($table) and !($table instanceof xmldb_table)) {
/**
* Given one xmldb_field, check if it exists in DB (true/false).
*
- * @param mixed $table The table to be searched (string name or xmldb_table instance).
- * @param mixed $field The field to be searched for (string name or xmldb_field instance).
+ * @param string|xmldb_table $table The table to be searched (string name or xmldb_table instance).
+ * @param string|xmldb_field $field The field to be searched for (string name or xmldb_field instance).
* @return boolean true is exists false otherwise.
* @throws ddl_table_missing_exception
*/
public function field_exists($table, $field) {
- /// Calculate the name of the table
+ // Calculate the name of the table
if (is_string($table)) {
$tablename = $table;
} else {
$tablename = $table->getName();
}
- /// Check the table exists
+ // Check the table exists
if (!$this->table_exists($table)) {
throw new ddl_table_missing_exception($tablename);
}
if (is_string($field)) {
$fieldname = $field;
} else {
- /// Calculate the name of the table
+ // Calculate the name of the table
$fieldname = $field->getName();
}
- /// Get list of fields in table
+ // Get list of fields in table
$columns = $this->mdb->get_columns($tablename);
$exists = array_key_exists($fieldname, $columns);
* @throws ddl_table_missing_exception Thrown when table is not found.
*/
public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index) {
- /// Calculate the name of the table
+ // Calculate the name of the table
$tablename = $xmldb_table->getName();
- /// Check the table exists
+ // Check the table exists
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($tablename);
}
- /// Extract index columns
+ // Extract index columns
$indcolumns = $xmldb_index->getFields();
- /// Get list of indexes in table
+ // Get list of indexes in table
$indexes = $this->mdb->get_indexes($tablename);
- /// Iterate over them looking for columns coincidence
+ // Iterate over them looking for columns coincidence
foreach ($indexes as $indexname => $index) {
$columns = $index['columns'];
- /// Check if index matchs queried index
+ // Check if index matches queried index
$diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
- /// If no diferences, we have find the index
+ // If no differences, we have find the index
if (empty($diferences)) {
return $indexname;
}
}
- /// Arriving here, index not found
+ // Arriving here, index not found
return false;
}
$keycolumns = $xmldb_key->getFields();
- /// Get list of keys in table
- /// first primaries (we aren't going to use this now, because the MetaPrimaryKeys is awful)
- ///TODO: To implement when we advance in relational integrity
- /// then uniques (note that Moodle, for now, shouldn't have any UNIQUE KEY for now, but unique indexes)
- ///TODO: To implement when we advance in relational integrity (note that AdoDB hasn't any MetaXXX for this.
- /// then foreign (note that Moodle, for now, shouldn't have any FOREIGN KEY for now, but indexes)
- ///TODO: To implement when we advance in relational integrity (note that AdoDB has one MetaForeignKeys()
- ///but it's far from perfect.
- /// TODO: To create the proper functions inside each generator to retrieve all the needed KEY info (name
- /// columns, reftable and refcolumns
-
- /// So all we do is to return the official name of the requested key without any confirmation!)
- /// One exception, hardcoded primary constraint names
+ // Get list of keys in table
+ // first primaries (we aren't going to use this now, because the MetaPrimaryKeys is awful)
+ //TODO: To implement when we advance in relational integrity
+ // then uniques (note that Moodle, for now, shouldn't have any UNIQUE KEY for now, but unique indexes)
+ //TODO: To implement when we advance in relational integrity (note that AdoDB hasn't any MetaXXX for this.
+ // then foreign (note that Moodle, for now, shouldn't have any FOREIGN KEY for now, but indexes)
+ //TODO: To implement when we advance in relational integrity (note that AdoDB has one MetaForeignKeys()
+ //but it's far from perfect.
+ // TODO: To create the proper functions inside each generator to retrieve all the needed KEY info (name
+ // columns, reftable and refcolumns
+
+ // So all we do is to return the official name of the requested key without any confirmation!)
+ // One exception, hardcoded primary constraint names
if ($this->generator->primary_key_name && $xmldb_key->getType() == XMLDB_KEY_PRIMARY) {
return $this->generator->primary_key_name;
} else {
- /// Calculate the name suffix
+ // Calculate the name suffix
switch ($xmldb_key->getType()) {
case XMLDB_KEY_PRIMARY:
$suffix = 'pk';
$suffix = 'fk';
break;
}
- /// And simply, return the official name
+ // And simply, return the official name
return $this->generator->getNameForObject($xmldb_table->getName(), implode(', ', $xmldb_key->getFields()), $suffix);
}
}
$structure = $xmldb_file->getStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
- /// Show info about the error if we can find it
+ // Show info about the error if we can find it
if ($structure) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
* @return void
*/
public function drop_table(xmldb_table $xmldb_table) {
- /// Check table exists
+ // Check table exists
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
$loaded = $xmldb_file->loadXMLStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
- /// Show info about the error if we can find it
- if ($structure =& $xmldb_file->getStructure()) {
+ // Show info about the error if we can find it
+ if ($structure = $xmldb_file->getStructure()) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
}
* @return void
*/
public function create_table(xmldb_table $xmldb_table) {
- /// Check table doesn't exist
+ // Check table doesn't exist
if ($this->table_exists($xmldb_table)) {
throw new ddl_exception('ddltablealreadyexists', $xmldb_table->getName());
}
* @return void
*/
public function rename_table(xmldb_table $xmldb_table, $newname) {
- /// Check newname isn't empty
+ // Check newname isn't empty
if (!$newname) {
throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty');
}
$check = new xmldb_table($newname);
- /// Check table already renamed
+ // Check table already renamed
if (!$this->table_exists($xmldb_table)) {
if ($this->table_exists($check)) {
throw new ddl_exception('ddlunknownerror', null, 'table probably already renamed');
}
}
- /// Check new table doesn't exist
+ // Check new table doesn't exist
if ($this->table_exists($check)) {
throw new ddl_exception('ddltablealreadyexists', $xmldb_table->getName(), 'can not rename table');
}
$this->execute_sql_arr($sqlarr);
}
-
/**
* This function will add the field to the table passed as arguments
*
* @return void
*/
public function add_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
- /// Check the field doesn't exist
+ // Check the field doesn't exist
if ($this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlfieldalreadyexists', $xmldb_field->getName());
}
- /// If NOT NULL and no default given (we ask the generator about the
- /// *real* default that will be used) check the table is empty
+ // If NOT NULL and no default given (we ask the generator about the
+ // *real* default that will be used) check the table is empty
if ($xmldb_field->getNotNull() && $this->generator->getDefaultValue($xmldb_field) === NULL && $this->mdb->count_records($xmldb_table->getName())) {
throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' cannot be added. Not null fields added to non empty tables require default value. Create skipped');
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check the field exists
+ // Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
- /// Check for dependencies in the DB before performing any action
+ // Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getDropFieldSQL($xmldb_table, $xmldb_field)) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check the field exists
+ // Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
- /// Check for dependencies in the DB before performing any action
+ // Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getAlterFieldSQL($xmldb_table, $xmldb_field)) {
* @return void
*/
public function change_field_precision(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
- /// Just a wrapper over change_field_type. Does exactly the same processing
+ // Just a wrapper over change_field_type. Does exactly the same processing
$this->change_field_type($xmldb_table, $xmldb_field);
}
* @return void
*/
public function change_field_notnull(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
- /// Just a wrapper over change_field_type. Does exactly the same processing
+ // Just a wrapper over change_field_type. Does exactly the same processing
$this->change_field_type($xmldb_table, $xmldb_field);
}
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check the field exists
+ // Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
- /// Check for dependencies in the DB before performing any action
+ // Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getModifyDefaultSQL($xmldb_table, $xmldb_field)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check the field exists
+ // Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
- /// Check we have included full field specs
+ // Check we have included full field specs
if (!$xmldb_field->getType()) {
throw new ddl_exception('ddlunknownerror', null,
'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' must contain full specs. Rename skipped');
}
- /// Check field isn't id. Renaming over that field is not allowed
+ // Check field isn't id. Renaming over that field is not allowed
if ($xmldb_field->getName() == 'id') {
throw new ddl_exception('ddlunknownerror', null,
'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
*/
private function check_field_dependencies(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
- /// Check the table exists
+ // Check the table exists
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check the field exists
+ // Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
- /// Check the field isn't in use by any index in the table
+ // Check the field isn't in use by any index in the table
if ($indexes = $this->mdb->get_indexes($xmldb_table->getName(), false)) {
foreach ($indexes as $indexname => $index) {
$columns = $index['columns'];
public function rename_key(xmldb_table $xmldb_table, xmldb_key $xmldb_key, $newname) {
debugging('rename_key() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER);
- /// Check newname isn't empty
+ // Check newname isn't empty
if (!$newname) {
throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty');
}
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check index doesn't exist
+ // Check index doesn't exist
if ($this->index_exists($xmldb_table, $xmldb_intex)) {
throw new ddl_exception('ddlunknownerror', null,
'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() .
throw new ddl_table_missing_exception($xmldb_table->getName());
}
- /// Check index exists
+ // Check index exists
if (!$this->index_exists($xmldb_table, $xmldb_intex)) {
throw new ddl_exception('ddlunknownerror', null,
'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() .
public function rename_index($xmldb_table, $xmldb_intex, $newname) {
debugging('rename_index() is one experimental feature. You must not use it in production!', DEBUG_DEVELOPER);
- /// Check newname isn't empty
+ // Check newname isn't empty
if (!$newname) {
throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty');
}
- /// Check index exists
+ // Check index exists
if (!$this->index_exists($xmldb_table, $xmldb_intex)) {
throw new ddl_exception('ddlunknownerror', null,
'Index ' . $xmldb_table->getName() . '->' . $xmldb_intex->getName() .
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-
/**
* MSSQL specific SQL code generator.
*
- * @package core
- * @subpackage ddl_generator
+ * @package core_ddl
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
* 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
require_once($CFG->libdir.'/ddl/sql_generator.php');
-/// This class generate SQL code to be used against MSSQL
-/// It extends XMLDBgenerator so everything can be
-/// overridden as needed to generate correct SQL.
-
+/**
+ * This class generate SQL code to be used against MSSQL
+ * It extends XMLDBgenerator so everything can be
+ * overridden as needed to generate correct SQL.
+ *
+ * @package core_ddl
+ * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
+ * 2001-3001 Eloy Lafuente (stronk7) http://contiento.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class mssql_sql_generator extends sql_generator {
-/// Only set values that are different from the defaults present in XMLDBgenerator
+ // Only set values that are different from the defaults present in XMLDBgenerator
- public $statement_end = "\ngo"; // String to be automatically added at the end of each statement
+ /** @var string To be automatically added at the end of each statement. */
+ public $statement_end = "\ngo";
- public $number_type = 'DECIMAL'; // Proper type for NUMBER(x) in this DB
+ /** @var string Proper type for NUMBER(x) in this DB. */
+ public $number_type = 'DECIMAL';
- public $default_for_char = ''; // To define the default to set for NOT NULLs CHARs without default (null=do nothing)
+ /** @var string To define the default to set for NOT NULLs CHARs without default (null=do nothing).*/
+ public $default_for_char = '';
- public $specify_nulls = true; //To force the generator if NULL clauses must be specified. It shouldn't be necessary
- //but some mssql drivers require them or everything is created as NOT NULL :-(
+ /**
+ * @var bool To force the generator if NULL clauses must be specified. It shouldn't be necessary.
+ * note: some mssql drivers require them or everything is created as NOT NULL :-(
+ */
+ public $specify_nulls = true;
+
+ /** @var bool True if the generator needs to add extra code to generate the sequence fields.*/
+ public $sequence_extra_code = false;
+
+ /** @var string The particular name for inline sequences in this generator.*/
+ public $sequence_name = 'IDENTITY(1,1)';
- public $sequence_extra_code = false; //Does the generator need to add extra code to generate the sequence fields
- public $sequence_name = 'IDENTITY(1,1)'; //Particular name for inline sequences in this generator
- public $sequence_only = false; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name variable
+ /** @var bool To avoid outputting the rest of the field specs, leaving only the name and the sequence_name returned.*/
+ public $sequence_only = false;
- public $add_table_comments = false; // Does the generator need to add code for table comments
+ /** @var bool True if the generator needs to add code for table comments.*/
+ public $add_table_comments = false;
- public $concat_character = '+'; //Characters to be used as concatenation operator. If not defined
- //MySQL CONCAT function will be use
+ /** @var string Characters to be used as concatenation operator.*/
+ public $concat_character = '+';
- public $rename_table_sql = "sp_rename 'OLDNAME', 'NEWNAME'"; //SQL sentence to rename one table, both
- //OLDNAME and NEWNAME are dynamically replaced
+ /** @var string SQL sentence to rename one table, both 'OLDNAME' and 'NEWNAME' keywords are dynamically replaced.*/
+ public $rename_table_sql = "sp_rename 'OLDNAME', 'NEWNAME'";
+ /** @var string SQL sentence to rename one column where 'TABLENAME', 'OLDFIELDNAME' and 'NEWFIELDNAME' keywords are dynamically replaced.*/
public $rename_column_sql = "sp_rename 'TABLENAME.OLDFIELDNAME', 'NEWFIELDNAME', 'COLUMN'";
- ///TABLENAME, OLDFIELDNAME and NEWFIELDNAME are dyanmically replaced
- public $drop_index_sql = 'DROP INDEX TABLENAME.INDEXNAME'; //SQL sentence to drop one index
- //TABLENAME, INDEXNAME are dynamically replaced
+ /** @var string SQL sentence to drop one index where 'TABLENAME', 'INDEXNAME' keywords are dynamically replaced.*/
+ public $drop_index_sql = 'DROP INDEX TABLENAME.INDEXNAME';
- public $rename_index_sql = "sp_rename 'TABLENAME.OLDINDEXNAME', 'NEWINDEXNAME', 'INDEX'"; //SQL sentence to rename one index
- //TABLENAME, OLDINDEXNAME, NEWINDEXNAME are dynamically replaced
+ /** @var string SQL sentence to rename one index where 'TABLENAME', 'OLDINDEXNAME' and 'NEWINDEXNAME' are dynamically replaced.*/
+ public $rename_index_sql = "sp_rename 'TABLENAME.OLDINDEXNAME', 'NEWINDEXNAME', 'INDEX'";
- public $rename_key_sql = null; //SQL sentence to rename one key
- //TABLENAME, OLDKEYNAME, NEWKEYNAME are dynamically replaced
+ /** @var string SQL sentence to rename one key 'TABLENAME', 'OLDKEYNAME' and 'NEWKEYNAME' are dynamically replaced.*/
+ public $rename_key_sql = null;
/**
* Reset a sequence to the id field of a table.
- * @param string $table name of table or xmldb_table object
- * @return array sql commands to execute
+ *
+ * @param xmldb_table|string $table name of table or the table object.
+ * @return array of sql statements
*/
public function getResetSequenceSQL($table) {
* @return string the correct name of the table
*/
public function getTableName(xmldb_table $xmldb_table, $quoted=true) {
- /// Get the name, supporting special mssql names for temp tables
+ // Get the name, supporting special mssql names for temp tables
if ($this->temptables->is_temptable($xmldb_table->getName())) {
$tablename = $this->temptables->get_correct_name($xmldb_table->getName());
} else {
$tablename = $this->prefix . $xmldb_table->getName();
}
- /// Apply quotes optionally
+ // Apply quotes optionally
if ($quoted) {
$tablename = $this->getEncQuoted($tablename);
}
return $tablename;
}
-
/**
* Given one correct xmldb_table, returns the SQL statements
- * to create temporary table (inside one array)
+ * to create temporary table (inside one array).
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @return array of sql statements
*/
public function getCreateTempTableSQL($xmldb_table) {
$this->temptables->add_temptable($xmldb_table->getName());
}
/**
- * Given one XMLDB Type, lenght and decimals, returns the DB proper SQL type
+ * Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
+ *
+ * @param int $xmldb_type The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
+ * @param int $xmldb_length The length of that data type.
+ * @param int $xmldb_decimals The decimal places of precision of the data type.
+ * @return string The DB defined data type.
*/
public function getTypeSQL($xmldb_type, $xmldb_length=null, $xmldb_decimals=null) {
case XMLDB_TYPE_NUMBER:
$dbtype = $this->number_type;
if (!empty($xmldb_length)) {
- /// 38 is the max allowed
+ // 38 is the max allowed
if ($xmldb_length > 38) {
$xmldb_length = 38;
}
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table.
* MSSQL overwrites the standard sentence because it needs to do some extra work dropping the default and
* check constraints
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @return array The SQL statement for dropping a field from the table.
*/
public function getDropFieldSQL($xmldb_table, $xmldb_field) {
$results = array();
- /// Get the quoted name of the table and field
+ // Get the quoted name of the table and field
$tablename = $this->getTableName($xmldb_table);
$fieldname = $this->getEncQuoted($xmldb_field->getName());
- /// Look for any default constraint in this field and drop it
+ // Look for any default constraint in this field and drop it
if ($defaultname = $this->getDefaultConstraintName($xmldb_table, $xmldb_field)) {
$results[] = 'ALTER TABLE ' . $tablename . ' DROP CONSTRAINT ' . $defaultname;
}
- /// Build the standard alter table drop column
+ // Build the standard alter table drop column
$results[] = 'ALTER TABLE ' . $tablename . ' DROP COLUMN ' . $fieldname;
return $results;
/**
* Given one correct xmldb_field and the new name, returns the SQL statements
- * to rename it (inside one array)
+ * to rename it (inside one array).
+ *
* MSSQL is special, so we overload the function here. It needs to
* drop the constraints BEFORE renaming the field
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to get the renamed field from.
+ * @param string $newname The new name to rename the field to.
+ * @return array The SQL statements for renaming the field.
*/
public function getRenameFieldSQL($xmldb_table, $xmldb_field, $newname) {
$results = array(); //Array where all the sentences will be stored
- /// Although this is checked in database_manager::rename_field() - double check
- /// that we aren't trying to rename one "id" field. Although it could be
- /// implemented (if adding the necessary code to rename sequences, defaults,
- /// triggers... and so on under each getRenameFieldExtraSQL() function, it's
- /// better to forbid it, mainly because this field is the default PK and
- /// in the future, a lot of FKs can be pointing here. So, this field, more
- /// or less, must be considered immutable!
+ // Although this is checked in database_manager::rename_field() - double check
+ // that we aren't trying to rename one "id" field. Although it could be
+ // implemented (if adding the necessary code to rename sequences, defaults,
+ // triggers... and so on under each getRenameFieldExtraSQL() function, it's
+ // better to forbid it, mainly because this field is the default PK and
+ // in the future, a lot of FKs can be pointing here. So, this field, more
+ // or less, must be considered immutable!
if ($xmldb_field->getName() == 'id') {
return array();
}
- /// Call to standard (parent) getRenameFieldSQL() function
+ // Call to standard (parent) getRenameFieldSQL() function
$results = array_merge($results, parent::getRenameFieldSQL($xmldb_table, $xmldb_field, $newname));
return $results;
}
/**
- * Returns the code (array of statements) needed to execute extra statements on table rename
+ * Returns the code (array of statements) needed to execute extra statements on table rename.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param string $newname The new name for the table.
+ * @return array Array of extra SQL statements to rename a table.
*/
public function getRenameTableExtraSQL($xmldb_table, $newname) {
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to create the SQL from.
+ * @param string $skip_type_clause The type clause on alter columns, NULL by default.
+ * @param string $skip_default_clause The default clause on alter columns, NULL by default.
+ * @param string $skip_notnull_clause The null/notnull clause on alter columns, NULL by default.
+ * @return string The field altering SQL statement.
*/
public function getAlterFieldSQL($xmldb_table, $xmldb_field, $skip_type_clause = NULL, $skip_default_clause = NULL, $skip_notnull_clause = NULL) {
- $results = array(); /// To store all the needed SQL commands
+ $results = array(); // To store all the needed SQL commands
- /// Get the quoted name of the table and field
+ // Get the quoted name of the table and field
$tablename = $xmldb_table->getName();
$fieldname = $xmldb_field->getName();
- /// Take a look to field metadata
+ // Take a look to field metadata
$meta = $this->mdb->get_columns($tablename);
$metac = $meta[$fieldname];
$oldmetatype = $metac->meta_type;
$typechanged = true; //By default, assume that the column type has changed
$lengthchanged = true; //By default, assume that the column length has changed
- /// Detect if we are changing the type of the column
+ // Detect if we are changing the type of the column
if (($xmldb_field->getType() == XMLDB_TYPE_INTEGER && $oldmetatype == 'I') ||
($xmldb_field->getType() == XMLDB_TYPE_NUMBER && $oldmetatype == 'N') ||
($xmldb_field->getType() == XMLDB_TYPE_FLOAT && $oldmetatype == 'F') ||
$typechanged = false;
}
- /// If the new field (and old) specs are for integer, let's be a bit more specific differentiating
- /// types of integers. Else, some combinations can cause things like MDL-21868
+ // If the new field (and old) specs are for integer, let's be a bit more specific differentiating
+ // types of integers. Else, some combinations can cause things like MDL-21868
if ($xmldb_field->getType() == XMLDB_TYPE_INTEGER && $oldmetatype == 'I') {
if ($xmldb_field->getLength() > 9) { // Convert our new lenghts to detailed meta types
$newmssqlinttype = 'I8';
}
}
- /// Detect if we are changing the length of the column, not always necessary to drop defaults
- /// if only the length changes, but it's safe to do it always
+ // Detect if we are changing the length of the column, not always necessary to drop defaults
+ // if only the length changes, but it's safe to do it always
if ($xmldb_field->getLength() == $oldlength) {
$lengthchanged = false;
}
- /// If type or length have changed drop the default if exists
+ // If type or length have changed drop the default if exists
if ($typechanged || $lengthchanged) {
$results = $this->getDropDefaultSQL($xmldb_table, $xmldb_field);
}
- /// Some changes of type require multiple alter statements, because mssql lacks direct implicit cast between such types
- /// Here it is the matrix: http://msdn.microsoft.com/en-us/library/ms187928(SQL.90).aspx
- /// Going to store such intermediate alters in array of objects, storing all the info needed
+ // Some changes of type require multiple alter statements, because mssql lacks direct implicit cast between such types
+ // Here it is the matrix: http://msdn.microsoft.com/en-us/library/ms187928(SQL.90).aspx
+ // Going to store such intermediate alters in array of objects, storing all the info needed
$multiple_alter_stmt = array();
$targettype = $xmldb_field->getType();
$multiple_alter_stmt[0]->length = 255;
}
- /// Just prevent default clauses in this type of sentences for mssql and launch the parent one
+ // Just prevent default clauses in this type of sentences for mssql and launch the parent one
if (empty($multiple_alter_stmt)) { // Direct implicit conversion allowed, launch it
$results = array_merge($results, parent::getAlterFieldSQL($xmldb_table, $xmldb_field, NULL, true, NULL));
$results = array_merge($results, parent::getAlterFieldSQL($xmldb_table, $xmldb_field, NULL, true, NULL));
}
- /// Finally, process the default clause to add it back if necessary
+ // Finally, process the default clause to add it back if necessary
if ($typechanged || $lengthchanged) {
$results = array_merge($results, $this->getCreateDefaultSQL($xmldb_table, $xmldb_field));
}
- /// Return results
+ // Return results
return $results;
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table.
+ *
+ * @param xmldb_table $xmldb_table The table related to $xmldb_field.
+ * @param xmldb_field $xmldb_field The instance of xmldb_field to get the modified default value from.
+ * @return array The SQL statement for modifying the default value.
*/
public function getModifyDefaultSQL($xmldb_table, $xmldb_field) {
- /// MSSQL is a bit special with default constraints because it implements them as external constraints so
- /// normal ALTER TABLE ALTER COLUMN don't work to change defaults. Because this, we have this method overloaded here
+ // MSSQL is a bit special with default constraints because it implements them as external constraints so
+ // normal ALTER TABLE ALTER COLUMN don't work to change defaults. Because this, we have this method overloaded here
$results = array();
- /// Decide if we are going to create/modify or to drop the default
+ // Decide if we are going to create/modify or to drop the default
if ($xmldb_field->getDefault() === null) {
$results = $this->getDropDefaultSQL($xmldb_table, $xmldb_field); //Drop but, under some circumstances, re-enable
$default_clause = $this->getDefaultClause($xmldb_field);
}
/**
- * Given one xmldb_table and one xmldb_field, return the SQL statements needed to create its default
+ * Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
* (usually invoked from getModifyDefaultSQL()
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ * @return array Array of SQL statements to create a field's default.
*/
public function getCreateDefaultSQL($xmldb_table, $xmldb_field) {
- /// MSSQL is a bit special and it requires the corresponding DEFAULT CONSTRAINT to be dropped
+ // MSSQL is a bit special and it requires the corresponding DEFAULT CONSTRAINT to be dropped
$results = array();
- /// Get the quoted name of the table and field
+ // Get the quoted name of the table and field
$tablename = $this->getTableName($xmldb_table);
$fieldname = $this->getEncQuoted($xmldb_field->getName());
- /// Now, check if, with the current field attributes, we have to build one default
+ // Now, check if, with the current field attributes, we have to build one default
$default_clause = $this->getDefaultClause($xmldb_field);
if ($default_clause) {
- /// We need to build the default (Moodle) default, so do it
+ // We need to build the default (Moodle) default, so do it
$sql = 'ALTER TABLE ' . $tablename . ' ADD' . $default_clause . ' FOR ' . $fieldname;
$results[] = $sql;
}
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
* (usually invoked from getModifyDefaultSQL()
+ *
+ * Note that this method may be dropped in future.
+ *
+ * @param xmldb_table $xmldb_table The xmldb_table object instance.
+ * @param xmldb_field $xmldb_field The xmldb_field object instance.
+ * @return array Array of SQL statements to create a field's default.
+ *
+ * @todo MDL-31147 Moodle 2.1 - Drop getDropDefaultSQL()
*/
public function getDropDefaultSQL($xmldb_table, $xmldb_field) {
- /// MSSQL is a bit special and it requires the corresponding DEFAULT CONSTRAINT to be dropped
+ // MSSQL is a bit special and it requires the corresponding DEFAULT CONSTRAINT to be dropped
$results =