Skip to content

Commit

Permalink
Merge branch 'w25_MDL-32003_m23_dbcleanup' of git://github.com/skodak…
Browse files Browse the repository at this point in the history
…/moodle
  • Loading branch information
stronk7 committed Jun 20, 2012
2 parents f7dc4a5 + d8bf2a1 commit cb17282
Show file tree
Hide file tree
Showing 101 changed files with 2,602 additions and 2,212 deletions.
45 changes: 26 additions & 19 deletions admin/tool/xmldb/actions/XMLDBAction.class.php
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -27,35 +26,35 @@
* 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();
Expand All @@ -76,7 +75,8 @@ function 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;
Expand All @@ -85,6 +85,7 @@ function getDoesGenerate() {
/**
* getError method, returns the last error string.
* Used if the invoke() methods returns false
* @return string
*/
function getError() {
return $this->errormsg;
Expand All @@ -93,6 +94,7 @@ function getError() {
/**
* 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;
Expand All @@ -101,6 +103,7 @@ function getOutput() {
/**
* getPostAction method, returns the action to launch after executing
* another one
* @return string
*/
function getPostAction() {
return $this->postaction;
Expand All @@ -109,6 +112,7 @@ function getPostAction() {
/**
* getTitle method returns the title of the action (that is part
* of the $str array attribute
* @return string
*/
function getTitle() {
return $this->str['title'];
Expand All @@ -117,6 +121,7 @@ function getTitle() {
/**
* loadStrings method, loads the required strings specified in the
* array parameter
* @params array $strings
*/
function loadStrings($strings) {
// Load some commonly used strings
Expand Down Expand Up @@ -162,6 +167,8 @@ function invoke() {

/**
* launch method, used to easily call invoke methods between actions
* @param string $action
* @return mixed
*/
function launch($action) {

Expand Down
10 changes: 4 additions & 6 deletions admin/tool/xmldb/actions/XMLDBCheckAction.class.php
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -25,14 +24,13 @@
* 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 = '';
Expand Down Expand Up @@ -117,7 +115,7 @@ function invoke() {

// 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
Expand Down
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -25,8 +24,7 @@
* 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
*/
Expand Down
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -26,8 +25,7 @@
* 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
*/
Expand Down
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -30,8 +29,7 @@
* 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
*/
Expand Down
Expand Up @@ -15,8 +15,7 @@
// 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
*/
Expand All @@ -26,8 +25,7 @@
* 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
*/
Expand Down
Expand Up @@ -16,7 +16,7 @@
// 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
*/
Expand All @@ -28,7 +28,7 @@
* 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
*/
Expand Down
Expand Up @@ -15,15 +15,13 @@
// 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
*/
Expand Down
26 changes: 12 additions & 14 deletions admin/tool/xmldb/actions/delete_field/delete_field.class.php
Expand Up @@ -15,17 +15,15 @@
// 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
*/
Expand Down Expand Up @@ -96,21 +94,21 @@ function invoke() {
// 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
Expand All @@ -121,7 +119,7 @@ function invoke() {

// 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);
Expand Down
26 changes: 12 additions & 14 deletions admin/tool/xmldb/actions/delete_index/delete_index.class.php
Expand Up @@ -15,17 +15,15 @@
// 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
*/
Expand Down Expand Up @@ -96,21 +94,21 @@ function invoke() {
// 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
Expand All @@ -121,7 +119,7 @@ function invoke() {

// 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);
Expand Down

0 comments on commit cb17282

Please sign in to comment.