Permalink
Browse files

Merge remote branch 'origin/master' into rubric

Conflicts:
	lib/db/install.xml
	lib/db/upgrade.php
	version.php
  • Loading branch information...
2 parents afc766a + 9086337 commit e8004aadc8e426f628a840d1ce396cb4be80b745 @mudrd8mz mudrd8mz committed Oct 7, 2011
Showing 2,376 changed files with 347,058 additions and 345,188 deletions.
@@ -126,14 +126,14 @@ function getTitle() {
* array parameter
*/
function loadStrings($strings) {
- /// Load some commonly used strings
+ // Load some commonly used strings
if (get_string_manager()->string_exists($this->title, 'tool_xmldb')) {
$this->str['title'] = get_string($this->title, 'tool_xmldb');
} else {
$this->str['title'] = $this->title;
}
- /// Now process the $strings array loading it in the $str atribute
+ // Now process the $strings array loading it in the $str atribute
if ($strings) {
foreach ($strings as $key => $module) {
$this->str[$key] = get_string($key, $module);
@@ -149,19 +149,19 @@ function invoke() {
global $SESSION;
- /// Sesskey protection
+ // Sesskey protection
if ($this->sesskey_protected) {
require_sesskey();
}
- /// If we are used any dir, save it in the lastused session object
- /// Some actions can use it to perform positioning
+ // If we are used any dir, save it in the lastused session object
+ // Some actions can use it to perform positioning
if ($lastused = optional_param ('dir', NULL, PARAM_PATH)) {
$SESSION->lastused = $lastused;
}
$this->postaction = optional_param ('postaction', NULL, PARAM_ALPHAEXT);
- /// Avoid being recursive
+ // Avoid being recursive
if ($this->title == $this->postaction) {
$this->postaction = NULL;
}
@@ -174,12 +174,12 @@ function launch($action) {
global $CFG;
- /// Get the action path and invoke it
+ // 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
+ // Load and invoke the proper action
$result = false;
if (file_exists($actionpath) && is_readable($actionpath)) {
require_once($actionpath);
@@ -218,16 +218,16 @@ function upgrade_savepoint_php($structure) {
$path = $structure->getPath();
- /// Trim "db" from path
+ // Trim "db" from path
$path = dirname($path);
- /// Get pluginname, plugindir and plugintype
+ // Get pluginname, plugindir and plugintype
$pluginname = basename($path);
- if ($path == 'lib') { /// exception for lib (not proper plugin)
+ if ($path == 'lib') { // exception for lib (not proper plugin)
$plugindir = 'lib';
$plugintype = 'lib';
- } else { /// rest of plugins
- //TODO: this is not nice and may fail, plugintype should be passed around somehow instead
+ } else { // rest of plugins
+ // TODO: this is not nice and may fail, plugintype should be passed around somehow instead
$plugintypes = get_plugin_types(false);
$plugindir = dirname($path);
$plugindir = str_replace('\\', '/', $plugindir);
@@ -237,22 +237,22 @@ function upgrade_savepoint_php($structure) {
$result = '';
switch ($plugintype ) {
- case 'lib': /// has own savepoint function
+ case 'lib': // has own savepoint function
$result = XMLDB_LINEFEED .
' // Main savepoint reached' . XMLDB_LINEFEED .
' upgrade_main_savepoint(true, XXXXXXXXXX);' . XMLDB_LINEFEED;
break;
- case 'mod': /// has own savepoint function
+ case 'mod': // has own savepoint function
$result = XMLDB_LINEFEED .
' // ' . $pluginname . ' savepoint reached' . XMLDB_LINEFEED .
' upgrade_mod_savepoint(true, XXXXXXXXXX, ' . "'$pluginname'" . ');' . XMLDB_LINEFEED;
break;
- case 'block': /// has own savepoint function
+ case 'block': // has own savepoint function
$result = XMLDB_LINEFEED .
' // ' . $pluginname . ' savepoint reached' . XMLDB_LINEFEED .
' upgrade_block_savepoint(true, XXXXXXXXXX, ' . "'$pluginname'" . ');' . XMLDB_LINEFEED;
break;
- default: /// rest of plugins
+ default: // rest of plugins
$result = XMLDB_LINEFEED .
' // ' . $pluginname . ' savepoint reached' . XMLDB_LINEFEED .
' upgrade_plugin_savepoint(true, XXXXXXXXXX, ' . "'$plugintype'" . ', ' . "'$pluginname'" . ');' . XMLDB_LINEFEED;
@@ -43,11 +43,11 @@
function init() {
parent::init();
- /// Set own core attributes
+ // Set own core attributes
- /// Set own custom attributes
+ // Set own custom attributes
- /// Get needed strings
+ // Get needed strings
$this->loadStrings(array(
$this->introstr => 'tool_xmldb',
'ok' => '',
@@ -73,24 +73,24 @@ function invoke() {
$result = true;
- /// Set own core attributes
+ // Set own core attributes
$this->does_generate = ACTION_GENERATE_HTML;
- /// These are always here
+ // These are always here
global $CFG, $XMLDB, $DB, $OUTPUT;
- /// And we nedd some ddl suff
+ // And we nedd some ddl suff
$dbman = $DB->get_manager();
- /// Here we'll acummulate all the wrong fields found
+ // Here we'll acummulate all the wrong fields found
$problemsfound = array();
- /// Do the job, setting $result as needed
+ // Do the job, setting $result as needed
- /// Get the confirmed to decide what to do
+ // Get the confirmed to decide what to do
$confirmed = optional_param('confirmed', false, PARAM_BOOL);
- /// If not confirmed, show confirmation box
+ // If not confirmed, show confirmation box
if (!$confirmed) {
$o = '<table class="generalbox" border="0" cellpadding="5" cellspacing="0" id="notice">';
$o.= ' <tr><td class="generalboxcontent">';
@@ -110,59 +110,59 @@ function invoke() {
$this->output = $o;
} else {
- /// The back to edit table button
+ // The back to edit table button
$b = ' <p class="centerpara buttons">';
$b .= '<a href="index.php">[' . $this->str['back'] . ']</a>';
$b .= '</p>';
- /// Iterate over $XMLDB->dbdirs, loading their XML data to memory
+ // Iterate over $XMLDB->dbdirs, loading their XML data to memory
if ($XMLDB->dbdirs) {
$dbdirs =& $XMLDB->dbdirs;
$o='<ul>';
foreach ($dbdirs as $dbdir) {
- /// Only if the directory exists
+ // Only if the directory exists
if (!$dbdir->path_exists) {
continue;
}
- /// Load the XML file
+ // Load the XML file
$xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
- /// Only if the file exists
+ // Only if the file exists
if (!$xmldb_file->fileExists()) {
continue;
}
- /// Load the XML contents to structure
+ // Load the XML contents to structure
$loaded = $xmldb_file->loadXMLStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
echo $OUTPUT->notification('Errors found in XMLDB file: '. $dbdir->path . '/install.xml');
continue;
}
- /// Arriving here, everything is ok, get the XMLDB structure
+ // Arriving here, everything is ok, get the XMLDB structure
$structure = $xmldb_file->getStructure();
$o.=' <li>' . str_replace($CFG->dirroot . '/', '', $dbdir->path . '/install.xml');
- /// Getting tables
+ // Getting tables
if ($xmldb_tables = $structure->getTables()) {
$o.=' <ul>';
- /// Foreach table, process its fields
+ // Foreach table, process its fields
foreach ($xmldb_tables as $xmldb_table) {
- /// Skip table if not exists
+ // Skip table if not exists
if (!$dbman->table_exists($xmldb_table)) {
continue;
}
- /// Fetch metadata from physical DB. All the columns info.
+ // Fetch metadata from physical DB. All the columns info.
if (!$metacolumns = $DB->get_columns($xmldb_table->getName())) {
- //// Skip table if no metacolumns is available for it
+ // / Skip table if no metacolumns is available for it
continue;
}
- /// Table processing starts here
+ // Table processing starts here
$o.=' <li>' . $xmldb_table->getName();
- /// Do the specific check.
+ // Do the specific check.
list($output, $newproblems) = $this->check_table($xmldb_table, $metacolumns);
$o.=$output;
$problemsfound = array_merge($problemsfound, $newproblems);
$o.=' </li>';
- /// Give the script some more time (resetting to current if exists)
+ // Give the script some more time (resetting to current if exists)
if ($currenttl = @ini_get('max_execution_time')) {
@ini_set('max_execution_time',$currenttl);
}
@@ -174,19 +174,19 @@ function invoke() {
$o.='</ul>';
}
- /// Create a report of the problems found.
+ // Create a report of the problems found.
$r = $this->display_results($problemsfound);
- /// Combine the various bits of output.
+ // Combine the various bits of output.
$this->output = $b . $r . $o;
}
- /// Launch postaction if exists (leave this here!)
+ // Launch postaction if exists (leave this here!)
if ($this->getPostAction() && $result) {
return $this->launch($this->getPostAction());
}
- /// Return ok if arrived here
+ // Return ok if arrived here
return $result;
}
@@ -44,19 +44,19 @@ function init() {
$this->introstr = 'confirmcheckbigints';
parent::init();
- /// Set own core attributes
+ // Set own core attributes
- /// Set own custom attributes
+ // Set own custom attributes
- /// Get needed strings
+ // Get needed strings
$this->loadStrings(array(
'wrongints' => 'tool_xmldb',
'nowrongintsfound' => 'tool_xmldb',
'yeswrongintsfound' => 'tool_xmldb',
'mysqlextracheckbigints' => 'tool_xmldb',
));
- /// Correct fields must be type bigint for MySQL and int8 for PostgreSQL
+ // Correct fields must be type bigint for MySQL and int8 for PostgreSQL
$this->dbfamily = $DB->get_dbfamily();
switch ($this->dbfamily) {
case 'mysql':
@@ -74,26 +74,26 @@ protected function check_table(xmldb_table $xmldb_table, array $metacolumns) {
$o = '';
$wrong_fields = array();
- /// Get and process XMLDB fields
+ // Get and process XMLDB fields
if ($xmldb_fields = $xmldb_table->getFields()) {
$o.=' <ul>';
foreach ($xmldb_fields as $xmldb_field) {
- /// If the field isn't integer(10), skip
+ // If the field isn't integer(10), skip
if ($xmldb_field->getType() != XMLDB_TYPE_INTEGER || $xmldb_field->getLength() != 10) {
continue;
}
- /// If the metadata for that column doesn't exist, skip
+ // If the metadata for that column doesn't exist, skip
if (!isset($metacolumns[$xmldb_field->getName()])) {
continue;
}
- /// To variable for better handling
+ // To variable for better handling
$metacolumn = $metacolumns[$xmldb_field->getName()];
- /// Going to check this field in DB
+ // Going to check this field in DB
$o.=' <li>' . $this->str['field'] . ': ' . $xmldb_field->getName() . ' ';
- /// Detect if the physical field is wrong and, under mysql, check for incorrect signed fields too
+ // Detect if the physical field is wrong and, under mysql, check for incorrect signed fields too
if ($metacolumn->type != $this->correct_type || ($this->dbfamily == 'mysql' && $xmldb_field->getUnsigned() && !$metacolumn->unsigned)) {
$o.='<font color="red">' . $this->str['wrong'] . '</font>';
- /// Add the wrong field to the list
+ // Add the wrong field to the list
$obj = new stdClass();
$obj->table = $xmldb_table;
$obj->field = $xmldb_field;
@@ -121,41 +121,41 @@ protected function display_results(array $wrong_fields) {
$r.= ' </td></tr>';
$r.= ' <tr><td class="generalboxcontent">';
- /// If we have found wrong integers inform about them
+ // If we have found wrong integers inform about them
if (count($wrong_fields)) {
$r.= ' <p class="centerpara">' . $this->str['yeswrongintsfound'] . '</p>';
$r.= ' <ul>';
foreach ($wrong_fields as $obj) {
$xmldb_table = $obj->table;
$xmldb_field = $obj->field;
- /// MySQL directly supports this
+ // MySQL directly supports this
// TODO: move this hack to generators!!
if ($this->dbfamily == 'mysql') {
$sqlarr = $dbman->generator->getAlterFieldSQL($xmldb_table, $xmldb_field);
- /// PostgreSQL (XMLDB implementation) is a bit, er... imperfect.
+ // PostgreSQL (XMLDB implementation) is a bit, er... imperfect.
} else if ($this->dbfamily == 'postgres') {
$sqlarr = array('ALTER TABLE ' . $DB->get_prefix() . $xmldb_table->getName() .
' ALTER COLUMN ' . $xmldb_field->getName() . ' TYPE BIGINT;');
}
$r.= ' <li>' . $this->str['table'] . ': ' . $xmldb_table->getName() . '. ' .
$this->str['field'] . ': ' . $xmldb_field->getName() . '</li>';
- /// Add to output if we have sentences
+ // Add to output if we have sentences
if ($sqlarr) {
$sqlarr = $dbman->generator->getEndedStatements($sqlarr);
$s.= '<code>' . str_replace("\n", '<br />', implode('<br />', $sqlarr)). '</code><br />';
}
}
$r.= ' </ul>';
- /// Add the SQL statements (all together)
+ // Add the SQL statements (all together)
$r.= '<hr />' . $s;
} else {
$r.= ' <p class="centerpara">' . $this->str['nowrongintsfound'] . '</p>';
}
$r.= ' </td></tr>';
$r.= ' <tr><td class="generalboxcontent">';
- /// Add the complete log message
+ // Add the complete log message
$r.= ' <p class="centerpara">' . $this->str['completelogbelow'] . '</p>';
$r.= ' </td></tr>';
$r.= '</table>';
Oops, something went wrong. Retry.

0 comments on commit e8004aa

Please sign in to comment.