This commit is contained in:
Yang Yang
2012-06-27 09:17:51 +12:00
1075 changed files with 9740 additions and 8066 deletions
+4 -20
View File
@@ -214,11 +214,7 @@
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="mysql" version="5.0.25" />
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
@@ -335,11 +331,7 @@
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="mysql" version="5.0.25" />
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
@@ -449,11 +441,7 @@
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="mysql" version="5.0.25" />
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
@@ -563,11 +551,7 @@
</FEEDBACK>
</UNICODE>
<DATABASE level="required">
<VENDOR name="mysql" version="5.0.25">
<FEEDBACK>
<ON_ERROR message="mysql416required" />
</FEEDBACK>
</VENDOR>
<VENDOR name="mysql" version="5.1.33" />
<VENDOR name="postgres" version="8.3" />
<VENDOR name="mssql" version="9.0" />
<VENDOR name="odbc_mssql" version="9.0" />
+4 -1
View File
@@ -14,7 +14,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', new lang_string('enablegroupmembersonly', 'admin'), new lang_string('configenablegroupmembersonly', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('dndallowtextandlinks', new lang_string('dndallowtextandlinks', 'admin'), new lang_string('configdndallowtextandlinks', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enablecssoptimiser', new lang_string('enablecssoptimiser','admin'), new lang_string('enablecssoptimiser_desc','admin'), 0));
// The CSS optimiser setting. When changed we need to reset the theme caches in order to ensure they are regenerated through the optimiser.
$enablecssoptimiser = new admin_setting_configcheckbox('enablecssoptimiser', new lang_string('enablecssoptimiser','admin'), new lang_string('enablecssoptimiser_desc','admin'), 0);
$enablecssoptimiser->set_updatedcallback('theme_reset_all_caches');
$temp->add($enablecssoptimiser);
$ADMIN->add('experimental', $temp);
+1 -1
View File
@@ -86,7 +86,7 @@ $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today),
// 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',
-9
View File
@@ -248,15 +248,6 @@ class admin_uploaduser_form2 extends moodleform {
$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)) {
+26 -19
View File
@@ -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
*/
@@ -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();
@@ -76,7 +75,8 @@ class XMLDBAction {
}
/**
* returns the type of output of the file
* Returns the type of output of the file
* @return bool
*/
function getDoesGenerate() {
return $this->does_generate;
@@ -85,6 +85,7 @@ class XMLDBAction {
/**
* getError method, returns the last error string.
* Used if the invoke() methods returns false
* @return string
*/
function getError() {
return $this->errormsg;
@@ -93,6 +94,7 @@ class XMLDBAction {
/**
* 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;
@@ -101,6 +103,7 @@ class XMLDBAction {
/**
* getPostAction method, returns the action to launch after executing
* another one
* @return string
*/
function getPostAction() {
return $this->postaction;
@@ -109,6 +112,7 @@ class XMLDBAction {
/**
* getTitle method returns the title of the action (that is part
* of the $str array attribute
* @return string
*/
function getTitle() {
return $this->str['title'];
@@ -117,6 +121,7 @@ class XMLDBAction {
/**
* loadStrings method, loads the required strings specified in the
* array parameter
* @params array $strings
*/
function loadStrings($strings) {
// Load some commonly used strings
@@ -162,6 +167,8 @@ class XMLDBAction {
/**
* launch method, used to easily call invoke methods between actions
* @param string $action
* @return mixed
*/
function launch($action) {
@@ -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
*/
@@ -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 = '';
@@ -117,7 +115,7 @@ abstract class XMLDBCheckAction extends XMLDBAction {
// 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
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -96,21 +94,21 @@ class delete_field extends XMLDBAction {
// 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
@@ -121,7 +119,7 @@ class delete_field extends XMLDBAction {
// 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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -96,21 +94,21 @@ class delete_index extends XMLDBAction {
// 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
@@ -121,7 +119,7 @@ class delete_index extends XMLDBAction {
// 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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -96,21 +94,21 @@ class delete_key extends XMLDBAction {
// 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
@@ -121,7 +119,7 @@ class delete_key extends XMLDBAction {
// 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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -95,10 +93,10 @@ class delete_table extends XMLDBAction {
// 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);
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -94,7 +92,7 @@ class delete_xml_file extends XMLDBAction {
// 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');
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -75,30 +73,30 @@ class edit_field extends XMLDBAction {
// 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
@@ -136,9 +134,9 @@ class edit_field extends XMLDBAction {
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]);
}
@@ -14,8 +14,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
*/
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -99,10 +97,10 @@ class edit_field_save extends XMLDBAction {
$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
@@ -225,12 +223,12 @@ class edit_field_save extends XMLDBAction {
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);
}
@@ -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
*/
@@ -24,7 +23,7 @@
/**
* 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
*/
@@ -73,30 +72,30 @@ class edit_index extends XMLDBAction {
// 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">';
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -93,10 +91,10 @@ class edit_index_save extends XMLDBAction {
$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
@@ -182,12 +180,12 @@ class edit_index_save extends XMLDBAction {
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);
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -74,30 +72,30 @@ class edit_key extends XMLDBAction {
// 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">';
@@ -14,8 +14,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
*/
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -106,10 +104,10 @@ class edit_key_save extends XMLDBAction {
$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
@@ -254,16 +252,16 @@ class edit_key_save extends XMLDBAction {
// 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);
}
@@ -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
*/
@@ -28,8 +27,7 @@
* 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
*/
@@ -93,7 +91,7 @@ class edit_table extends XMLDBAction {
// Get the correct dirs
if (!empty($XMLDB->dbdirs)) {
$dbdir =& $XMLDB->dbdirs[$dirpath];
$dbdir = $XMLDB->dbdirs[$dirpath];
} else {
return false;
}
@@ -104,19 +102,19 @@ class edit_table extends XMLDBAction {
}
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">';
@@ -193,7 +191,7 @@ class edit_table extends XMLDBAction {
$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">';
@@ -251,7 +249,7 @@ class edit_table extends XMLDBAction {
$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">';
@@ -304,7 +302,7 @@ class edit_table extends XMLDBAction {
$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">';
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -81,11 +79,11 @@ class edit_table_save extends XMLDBAction {
$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
@@ -120,12 +118,12 @@ class edit_table_save extends XMLDBAction {
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);
}
@@ -145,7 +143,7 @@ class edit_table_save extends XMLDBAction {
// 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);
@@ -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
*/
@@ -27,8 +26,7 @@
* 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
*/
@@ -90,7 +88,7 @@ class edit_xml_file extends XMLDBAction {
// 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) {
@@ -105,8 +103,8 @@ class edit_xml_file extends XMLDBAction {
$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">';
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -76,16 +74,16 @@ class edit_xml_file_save extends XMLDBAction {
$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);
@@ -15,8 +15,7 @@
// 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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -74,7 +72,7 @@ class load_xml_file extends XMLDBAction {
// 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;
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,7 +67,7 @@ class load_xml_files extends XMLDBAction {
// 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;
@@ -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
*/
@@ -27,8 +26,7 @@
* 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
*/
@@ -60,6 +58,7 @@ class main_view extends XMLDBAction {
'checkbigints' => 'tool_xmldb',
'checkoraclesemantics' => 'tool_xmldb',
'doc' => 'tool_xmldb',
'filemodifiedoutfromeditor' => 'tool_xmldb',
'viewxml' => 'tool_xmldb',
'pendingchangescannotbesavedreload' => 'tool_xmldb'
));
@@ -134,9 +133,9 @@ class main_view extends XMLDBAction {
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;
@@ -196,10 +195,8 @@ class main_view extends XMLDBAction {
$b .= '<a href="index.php?action=save_xml_file&amp;sesskey=' . sesskey() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $key)) . '&amp;time=' . time() . '&amp;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'] . ']';
@@ -267,8 +264,13 @@ class main_view extends XMLDBAction {
$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 {
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,13 +67,13 @@ class move_updown_field extends XMLDBAction {
// 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;
@@ -83,20 +81,20 @@ class move_updown_field extends XMLDBAction {
$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);
@@ -105,7 +103,7 @@ class move_updown_field extends XMLDBAction {
}
// 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);
@@ -124,14 +122,14 @@ class move_updown_field extends XMLDBAction {
$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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,13 +67,13 @@ class move_updown_index extends XMLDBAction {
// 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;
@@ -83,20 +81,20 @@ class move_updown_index extends XMLDBAction {
$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);
@@ -105,7 +103,7 @@ class move_updown_index extends XMLDBAction {
}
// 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);
@@ -124,14 +122,14 @@ class move_updown_index extends XMLDBAction {
$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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,13 +67,13 @@ class move_updown_key extends XMLDBAction {
// 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;
@@ -83,20 +81,20 @@ class move_updown_key extends XMLDBAction {
$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);
@@ -105,7 +103,7 @@ class move_updown_key extends XMLDBAction {
}
// 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);
@@ -124,14 +122,14 @@ class move_updown_key extends XMLDBAction {
$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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,31 +67,31 @@ class move_updown_table extends XMLDBAction {
// 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);
@@ -102,7 +100,7 @@ class move_updown_table extends XMLDBAction {
}
// 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);
@@ -117,15 +115,14 @@ class move_updown_table extends XMLDBAction {
$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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,23 +67,23 @@ class new_field extends XMLDBAction {
// 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;
}
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,23 +67,23 @@ class new_index extends XMLDBAction {
// 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;
}
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,23 +67,23 @@ class new_key extends XMLDBAction {
// 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;
}
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -69,19 +67,19 @@ class new_table extends XMLDBAction {
// 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;
}
}
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -72,13 +70,13 @@ class new_table_from_mysql extends XMLDBAction {
// 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);
@@ -98,7 +96,7 @@ class new_table_from_mysql extends XMLDBAction {
}
// Get list of after tables
$aftertables = array();
if ($tables =& $structure->getTables()) {
if ($tables = $structure->getTables()) {
foreach ($tables as $aftertable) {
$aftertables[$aftertable->getName()] = $aftertable->getName();
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -94,7 +92,7 @@ class revert_changes extends XMLDBAction {
// 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);
}
@@ -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
*/
@@ -29,8 +28,7 @@
* 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
*/
@@ -76,18 +74,18 @@ class save_xml_file extends XMLDBAction {
// 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;
@@ -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
*/
@@ -68,13 +66,13 @@ class template extends XMLDBAction {
// 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
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -71,7 +69,7 @@ class unload_xml_file extends XMLDBAction {
// 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);
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -75,11 +73,11 @@ class view_field_xml extends XMLDBAction {
// 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';
@@ -98,14 +96,14 @@ class view_field_xml extends XMLDBAction {
// 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;
}
@@ -117,7 +115,7 @@ class view_field_xml extends XMLDBAction {
}
// Get the fields
if ($result) {
if (!$fields =& $t->getFields()) {
if (!$fields = $t->getFields()) {
$this->errormsg = 'Error retrieving ' . $select . ' fields';
$result = false;
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -75,11 +73,11 @@ class view_index_xml extends XMLDBAction {
// 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';
@@ -98,26 +96,26 @@ class view_index_xml extends XMLDBAction {
// 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;
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -75,11 +73,11 @@ class view_key_xml extends XMLDBAction {
// 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';
@@ -98,26 +96,26 @@ class view_key_xml extends XMLDBAction {
// 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;
}
@@ -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
*/
@@ -27,8 +26,7 @@
* 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
*/
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -73,16 +71,16 @@ class view_structure_php extends XMLDBAction {
// 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) {
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -72,13 +70,13 @@ class view_structure_sql extends XMLDBAction {
// 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
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -73,11 +71,11 @@ class view_structure_xml extends XMLDBAction {
// 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';
@@ -96,7 +94,7 @@ class view_structure_xml extends XMLDBAction {
// 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;
}
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -79,18 +77,18 @@ class view_table_php extends XMLDBAction {
// 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;
@@ -14,8 +14,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
*/
@@ -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
*/
@@ -25,8 +24,7 @@
* 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
*/
@@ -72,13 +70,13 @@ class view_table_sql extends XMLDBAction {
// 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
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -74,11 +72,11 @@ class view_table_xml extends XMLDBAction {
// 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';
@@ -97,20 +95,20 @@ class view_table_xml extends XMLDBAction {
// 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;
}
@@ -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
*/
@@ -24,8 +23,7 @@
/**
* 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
*/
@@ -53,6 +51,7 @@ class view_xml extends XMLDBAction {
* 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();
+75 -76
View File
@@ -18,109 +18,108 @@
* 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');
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');
admin_externalpage_setup('toolxmld');
// Add other used libraries
require_once($CFG->libdir . '/xmlize.php');
// Add other used libraries
require_once($CFG->libdir . '/xmlize.php');
// Handle session data
global $XMLDB;
// 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);
}
// 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();
// Some previous checks
$site = get_site();
require_login();
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
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);
// 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";
// 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);
// 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:
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';
$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);
}
}
+2 -2
View File
@@ -17,8 +17,7 @@
/**
* 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
*/
@@ -91,6 +90,7 @@ $string['fields'] = 'Fields';
$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';
+1 -2
View File
@@ -17,8 +17,7 @@
/**
* 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
*/
+1 -2
View File
@@ -17,8 +17,7 @@
/**
* 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
*/
+13 -5
View File
@@ -620,15 +620,23 @@ class cc2moodle {
$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") {
+2 -2
View File
@@ -262,14 +262,14 @@ class entities {
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;
}
+3 -3
View File
@@ -62,13 +62,13 @@ class entities11 extends entities {
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;
}
+1 -1
View File
@@ -52,7 +52,7 @@ class cc_label extends entities {
'[#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),
+8 -7
View File
@@ -1069,7 +1069,7 @@ class backup_users_structure_step extends backup_structure_step {
'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
@@ -1404,7 +1404,8 @@ class backup_final_files_structure_step extends backup_structure_step {
'contenthash', 'contextid', 'component', 'filearea', 'itemid',
'filepath', 'filename', 'userid', 'filesize',
'mimetype', 'status', 'timecreated', 'timemodified',
'source', 'author', 'license', 'sortorder', 'reference', 'repositoryid'));
'source', 'author', 'license', 'sortorder',
'repositorytype', 'repositoryid', 'reference'));
// Build the tree
@@ -1412,12 +1413,12 @@ class backup_final_files_structure_step extends backup_structure_step {
// Define sources
$file->set_source_sql("SELECT f.*, r.repositoryid, r.reference
$file->set_source_sql("SELECT f.*, r.type AS repositorytype, fr.repositoryid, fr.reference
FROM {files} f
LEFT JOIN {files_reference} r
ON r.id = f.referencefileid
JOIN {backup_ids_temp} bi
ON f.id = bi.itemid
LEFT JOIN {files_reference} fr ON fr.id = f.referencefileid
LEFT JOIN {repository_instances} ri ON ri.id = fr.repositoryid
LEFT JOIN {repository} r ON r.id = ri.typeid
JOIN {backup_ids_temp} bi ON f.id = bi.itemid
WHERE bi.backupid = ?
AND bi.itemname = 'filefinal'", array(backup::VAR_BACKUPID));
+7 -1
View File
@@ -83,9 +83,15 @@ class restore_final_task extends restore_task {
// executing it to perform some final adjustments of information
// not available when the task was executed.
// This step is always the last one performing modifications on restored information
// Don't add any new step after it. Only cache rebuild and clean are allowed.
// Don't add any new step after it. Only aliases queue, cache rebuild and clean are allowed.
$this->add_step(new restore_execute_after_restore('executing_after_restore'));
// All files were sent to the filepool by now. We need to process
// the aliases yet as they were not actually created but stashed for us instead.
// We execute this step after executing_after_restore so that there can't be no
// more files sent to the filepool after this.
$this->add_step(new restore_process_file_aliases_queue('process_file_aliases_queue'));
// Rebuild course cache to see results, whoah!
$this->add_step(new restore_rebuild_course_cache('rebuild_course_cache'));
+327 -11
View File
@@ -591,22 +591,14 @@ class restore_load_included_files extends restore_structure_step {
}
/**
* Processing functions go here
* Process one <file> element from files.xml
*
* @param array $data one file record including repositoryid and reference
* @param array $data the element data
*/
public function process_file($data) {
$data = (object)$data; // handy
$isreference = !empty($data->repositoryid);
$issamesite = $this->task->is_samesite();
// If it's not samesite, we skip file refernces
if (!$issamesite && $isreference) {
return;
}
// load it if needed:
// - it it is one of the annotated inforef files (course/section/activity/block)
// - it is one "user", "group", "grouping", "grade", "question" or "qtype_xxxx" component file (that aren't sent to inforef ever)
@@ -617,7 +609,6 @@ class restore_load_included_files extends restore_structure_step {
$data->component == 'grouping' || $data->component == 'grade' ||
$data->component == 'question' || substr($data->component, 0, 5) == 'qtype');
if ($isfileref || $iscomponent) {
// Process files
restore_dbops::set_backup_files_record($this->get_restoreid(), $data);
}
}
@@ -3102,6 +3093,331 @@ class restore_create_question_files extends restore_execution_step {
}
}
/**
* Try to restore aliases and references to external files.
*
* The queue of these files was prepared for us in {@link restore_dbops::send_files_to_pool()}.
* We expect that all regular (non-alias) files have already been restored. Make sure
* there is no restore step executed after this one that would call send_files_to_pool() again.
*
* You may notice we have hardcoded support for Server files, Legacy course files
* and user Private files here at the moment. This could be eventually replaced with a set of
* callbacks in the future if needed.
*
* @copyright 2012 David Mudrak <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_process_file_aliases_queue extends restore_execution_step {
/** @var array internal cache for {@link choose_repository() */
private $cachereposbyid = array();
/** @var array internal cache for {@link choose_repository() */
private $cachereposbytype = array();
/**
* What to do when this step is executed.
*/
protected function define_execution() {
global $DB;
$this->log('processing file aliases queue', backup::LOG_INFO);
$fs = get_file_storage();
// Load the queue.
$rs = $DB->get_recordset('backup_ids_temp',
array('backupid' => $this->get_restoreid(), 'itemname' => 'file_aliases_queue'),
'', 'info');
// Iterate over aliases in the queue.
foreach ($rs as $record) {
$info = unserialize(base64_decode($record->info));
// Try to pick a repository instance that should serve the alias.
$repository = $this->choose_repository($info);
if (is_null($repository)) {
$this->notify_failure($info, 'unable to find a matching repository instance');
continue;
}
if ($info->oldfile->repositorytype === 'local' or $info->oldfile->repositorytype === 'coursefiles') {
// Aliases to Server files and Legacy course files may refer to a file
// contained in the backup file or to some existing file (if we are on the
// same site).
try {
$reference = file_storage::unpack_reference($info->oldfile->reference);
} catch (Exception $e) {
$this->notify_failure($info, 'invalid reference field format');
continue;
}
// Let's see if the referred source file was also included in the backup.
$candidates = $DB->get_recordset('backup_files_temp', array(
'backupid' => $this->get_restoreid(),
'contextid' => $reference['contextid'],
'component' => $reference['component'],
'filearea' => $reference['filearea'],
'itemid' => $reference['itemid'],
), '', 'info, newcontextid, newitemid');
$source = null;
foreach ($candidates as $candidate) {
$candidateinfo = unserialize(base64_decode($candidate->info));
if ($candidateinfo->filename === $reference['filename']
and $candidateinfo->filepath === $reference['filepath']
and !is_null($candidate->newcontextid)
and !is_null($candidate->newitemid) ) {
$source = $candidateinfo;
$source->contextid = $candidate->newcontextid;
$source->itemid = $candidate->newitemid;
break;
}
}
$candidates->close();
if ($source) {
// We have an alias that refers to another file also included in
// the backup. Let us change the reference field so that it refers
// to the restored copy of the original file.
$reference = file_storage::pack_reference($source);
// Send the new alias to the filepool.
$fs->create_file_from_reference($info->newfile, $repository->id, $reference);
$this->notify_success($info);
continue;
} else {
// This is a reference to some moodle file that was not contained in the backup
// file. If we are restoring to the same site, keep the reference untouched
// and restore the alias as is if the referenced file exists.
if ($this->task->is_samesite()) {
if ($fs->file_exists($reference['contextid'], $reference['component'], $reference['filearea'],
$reference['itemid'], $reference['filepath'], $reference['filename'])) {
$reference = file_storage::pack_reference($reference);
$fs->create_file_from_reference($info->newfile, $repository->id, $reference);
$this->notify_success($info);
continue;
} else {
$this->notify_failure($info, 'referenced file not found');
continue;
}
// If we are at other site, we can't restore this alias.
} else {
$this->notify_failure($info, 'referenced file not included');
continue;
}
}
} else if ($info->oldfile->repositorytype === 'user') {
if ($this->task->is_samesite()) {
// For aliases to user Private files at the same site, we have a chance to check
// if the referenced file still exists.
try {
$reference = file_storage::unpack_reference($info->oldfile->reference);
} catch (Exception $e) {
$this->notify_failure($info, 'invalid reference field format');
continue;
}
if ($fs->file_exists($reference['contextid'], $reference['component'], $reference['filearea'],
$reference['itemid'], $reference['filepath'], $reference['filename'])) {
$reference = file_storage::pack_reference($reference);
$fs->create_file_from_reference($info->newfile, $repository->id, $reference);
$this->notify_success($info);
continue;
} else {
$this->notify_failure($info, 'referenced file not found');
continue;
}
// If we are at other site, we can't restore this alias.
} else {
$this->notify_failure($info, 'restoring at another site');
continue;
}
} else {
// This is a reference to some external file such as in boxnet or dropbox.
// If we are restoring to the same site, keep the reference untouched and
// restore the alias as is.
if ($this->task->is_samesite()) {
$fs->create_file_from_reference($info->newfile, $repository->id, $info->oldfile->reference);
$this->notify_success($info);
continue;
// If we are at other site, we can't restore this alias.
} else {
$this->notify_failure($info, 'restoring at another site');
continue;
}
}
}
$rs->close();
}
/**
* Choose the repository instance that should handle the alias.
*
* At the same site, we can rely on repository instance id and we just
* check it still exists. On other site, try to find matching Server files or
* Legacy course files repository instance. Return null if no matching
* repository instance can be found.
*
* @param stdClass $info
* @return repository|null
*/
private function choose_repository(stdClass $info) {
global $DB, $CFG;
require_once($CFG->dirroot.'/repository/lib.php');
if ($this->task->is_samesite()) {
// We can rely on repository instance id.
if (array_key_exists($info->oldfile->repositoryid, $this->cachereposbyid)) {
return $this->cachereposbyid[$info->oldfile->repositoryid];
}
$this->log('looking for repository instance by id', backup::LOG_DEBUG, $info->oldfile->repositoryid, 1);
try {
$this->cachereposbyid[$info->oldfile->repositoryid] = repository::get_repository_by_id($info->oldfile->repositoryid, SYSCONTEXTID);
return $this->cachereposbyid[$info->oldfile->repositoryid];
} catch (Exception $e) {
$this->cachereposbyid[$info->oldfile->repositoryid] = null;
return null;
}
} else {
// We can rely on repository type only.
if (empty($info->oldfile->repositorytype)) {
return null;
}
if (array_key_exists($info->oldfile->repositorytype, $this->cachereposbytype)) {
return $this->cachereposbytype[$info->oldfile->repositorytype];
}
$this->log('looking for repository instance by type', backup::LOG_DEBUG, $info->oldfile->repositorytype, 1);
// Both Server files and Legacy course files repositories have a single
// instance at the system context to use. Let us try to find it.
if ($info->oldfile->repositorytype === 'local' or $info->oldfile->repositorytype === 'coursefiles') {
$sql = "SELECT ri.id
FROM {repository} r
JOIN {repository_instances} ri ON ri.typeid = r.id
WHERE r.type = ? AND ri.contextid = ?";
$ris = $DB->get_records_sql($sql, array($info->oldfile->repositorytype, SYSCONTEXTID));
if (empty($ris)) {
return null;
}
$repoids = array_keys($ris);
$repoid = reset($repoids);
try {
$this->cachereposbytype[$info->oldfile->repositorytype] = repository::get_repository_by_id($repoid, SYSCONTEXTID);
return $this->cachereposbytype[$info->oldfile->repositorytype];
} catch (Exception $e) {
$this->cachereposbytype[$info->oldfile->repositorytype] = null;
return null;
}
}
$this->cachereposbytype[$info->oldfile->repositorytype] = null;
return null;
}
}
/**
* Let the user know that the given alias was successfully restored
*
* @param stdClass $info
*/
private function notify_success(stdClass $info) {
$filedesc = $this->describe_alias($info);
$this->log('successfully restored alias', backup::LOG_DEBUG, $filedesc, 1);
}
/**
* Let the user know that the given alias can't be restored
*
* @param stdClass $info
* @param string $reason detailed reason to be logged
*/
private function notify_failure(stdClass $info, $reason = '') {
$filedesc = $this->describe_alias($info);
if ($reason) {
$reason = ' ('.$reason.')';
}
$this->log('unable to restore alias'.$reason, backup::LOG_WARNING, $filedesc, 1);
$this->add_result_item('file_aliases_restore_failures', $filedesc);
}
/**
* Return a human readable description of the alias file
*
* @param stdClass $info
* @return string
*/
private function describe_alias(stdClass $info) {
$filedesc = $this->expected_alias_location($info->newfile);
if (!is_null($info->oldfile->source)) {
$filedesc .= ' ('.$info->oldfile->source.')';
}
return $filedesc;
}
/**
* Return the expected location of a file
*
* Please note this may and may not work as a part of URL to pluginfile.php
* (depends on how the given component/filearea deals with the itemid).
*
* @param stdClass $filerecord
* @return string
*/
private function expected_alias_location($filerecord) {
$filedesc = '/'.$filerecord->contextid.'/'.$filerecord->component.'/'.$filerecord->filearea;
if (!is_null($filerecord->itemid)) {
$filedesc .= '/'.$filerecord->itemid;
}
$filedesc .= $filerecord->filepath.$filerecord->filename;
return $filedesc;
}
/**
* Append a value to the given resultset
*
* @param string $name name of the result containing a list of values
* @param mixed $value value to add as another item in that result
*/
private function add_result_item($name, $value) {
$results = $this->task->get_results();
if (isset($results[$name])) {
if (!is_array($results[$name])) {
throw new coding_exception('Unable to append a result item into a non-array structure.');
}
$current = $results[$name];
$current[] = $value;
$this->task->add_result(array($name => $current));
} else {
$this->task->add_result(array($name => array($value)));
}
}
}
/**
* Abstract structure step, to be used by all the activities using core questions stuff
* (like the quiz module), to support qtype plugins, states and sessions
+75 -31
View File
@@ -808,6 +808,17 @@ abstract class restore_dbops {
* Given one component/filearea/context and
* optionally one source itemname to match itemids
* put the corresponding files in the pool
*
* @param string $basepath the full path to the root of unzipped backup file
* @param string $restoreid the restore job's identification
* @param string $component
* @param string $filearea
* @param int $oldcontextid
* @param int $dfltuserid default $file->user if the old one can't be mapped
* @param string|null $itemname
* @param int|null $olditemid
* @param int|null $forcenewcontextid explicit value for the new contextid (skip mapping)
* @param bool $skipparentitemidctxmatch
*/
public static function send_files_to_pool($basepath, $restoreid, $component, $filearea, $oldcontextid, $dfltuserid, $itemname = null, $olditemid = null, $forcenewcontextid = null, $skipparentitemidctxmatch = false) {
global $DB;
@@ -839,17 +850,17 @@ abstract class restore_dbops {
// itemname = null, we are going to match only by context, no need to use itemid (all them are 0)
if ($itemname == null) {
$sql = 'SELECT contextid, component, filearea, itemid, itemid AS newitemid, info
$sql = "SELECT id AS bftid, contextid, component, filearea, itemid, itemid AS newitemid, info
FROM {backup_files_temp}
WHERE backupid = ?
AND contextid = ?
AND component = ?
AND filearea = ?';
AND filearea = ?";
$params = array($restoreid, $oldcontextid, $component, $filearea);
// itemname not null, going to join with backup_ids to perform the old-new mapping of itemids
} else {
$sql = "SELECT f.contextid, f.component, f.filearea, f.itemid, i.newitemid, f.info
$sql = "SELECT f.id AS bftid, f.contextid, f.component, f.filearea, f.itemid, i.newitemid, f.info
FROM {backup_files_temp} f
JOIN {backup_ids_temp} i ON i.backupid = f.backupid
$parentitemctxmatchsql
@@ -872,47 +883,80 @@ abstract class restore_dbops {
foreach ($rs as $rec) {
$file = (object)unserialize(base64_decode($rec->info));
$isreference = !empty($file->repositoryid);
// ignore root dirs (they are created automatically)
if ($file->filepath == '/' && $file->filename == '.') {
continue;
}
// set the best possible user
$mappeduser = self::get_backup_ids_record($restoreid, 'user', $file->userid);
$file->userid = !empty($mappeduser) ? $mappeduser->newitemid : $dfltuserid;
// dir found (and not root one), let's create if
$mappeduserid = !empty($mappeduser) ? $mappeduser->newitemid : $dfltuserid;
// dir found (and not root one), let's create it
if ($file->filename == '.') {
$fs->create_directory($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->userid);
$fs->create_directory($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $mappeduserid);
continue;
}
// arrived here, file found
// Find file in backup pool
$backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);
if (empty($file->repositoryid)) {
// this is a regular file, it must be present in the backup pool
$backuppath = $basepath . backup_file_manager::get_backup_content_file_location($file->contenthash);
if (!file_exists($backuppath) && !$isreference) {
throw new restore_dbops_exception('file_not_found_in_pool', $file);
}
if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) {
$file_record = array(
'contextid' => $newcontextid,
'component' => $component,
'filearea' => $filearea,
'itemid' => $rec->newitemid,
'filepath' => $file->filepath,
'filename' => $file->filename,
'timecreated' => $file->timecreated,
'timemodified'=> $file->timemodified,
'userid' => $file->userid,
'author' => $file->author,
'license' => $file->license,
'sortorder' => $file->sortorder);
if ($isreference) {
$fs->create_file_from_reference($file_record, $file->repositoryid, $file->reference);
} else {
if (!file_exists($backuppath)) {
throw new restore_dbops_exception('file_not_found_in_pool', $file);
}
// create the file in the filepool if it does not exist yet
if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) {
$file_record = array(
'contextid' => $newcontextid,
'component' => $component,
'filearea' => $filearea,
'itemid' => $rec->newitemid,
'filepath' => $file->filepath,
'filename' => $file->filename,
'timecreated' => $file->timecreated,
'timemodified'=> $file->timemodified,
'userid' => $mappeduserid,
'author' => $file->author,
'license' => $file->license,
'sortorder' => $file->sortorder
);
$fs->create_file_from_pathname($file_record, $backuppath);
}
// store the the new contextid and the new itemid in case we need to remap
// references to this file later
$DB->update_record('backup_files_temp', array(
'id' => $rec->bftid,
'newcontextid' => $newcontextid,
'newitemid' => $rec->newitemid), true);
} else {
// this is an alias - we can't create it yet so we stash it in a temp
// table and will let the final task to deal with it
if (!$fs->file_exists($newcontextid, $component, $filearea, $rec->newitemid, $file->filepath, $file->filename)) {
$info = new stdClass();
// oldfile holds the raw information stored in MBZ (including reference-related info)
$info->oldfile = $file;
// newfile holds the info for the new file_record with the context, user and itemid mapped
$info->newfile = (object)array(
'contextid' => $newcontextid,
'component' => $component,
'filearea' => $filearea,
'itemid' => $rec->newitemid,
'filepath' => $file->filepath,
'filename' => $file->filename,
'timecreated' => $file->timecreated,
'timemodified'=> $file->timemodified,
'userid' => $mappeduserid,
'author' => $file->author,
'license' => $file->license,
'sortorder' => $file->sortorder
);
restore_dbops::set_backup_ids_record($restoreid, 'file_aliases_queue', $file->id, 0, null, $info);
}
}
}
$rs->close();
+17
View File
@@ -75,10 +75,27 @@ abstract class base_plan implements checksumable, executable {
return $this->tasks;
}
/**
* Add the passed info to the plan results
*
* At the moment we expect an associative array structure to be merged into
* the current results. In the future, some sort of base_result class may
* be introduced.
*
* @param array $result associative array describing a result of a task/step
*/
public function add_result($result) {
if (!is_array($result)) {
throw new coding_exception('Associative array is expected as a parameter of add_result()');
}
$this->results = array_merge($this->results, $result);
}
/**
* Return the results collected via {@link self::add_result()} method
*
* @return array
*/
public function get_results() {
return $this->results;
}
+29 -1
View File
@@ -154,7 +154,7 @@ abstract class base_task implements checksumable, executable, loggable {
// If step returns array, it will be forwarded to plan
// (TODO: shouldn't be array but proper result object)
if (is_array($result) and !empty($result)) {
$this->plan->add_result($result);
$this->add_result($result);
}
}
// Mark as executed if any step has been executed
@@ -191,6 +191,34 @@ abstract class base_task implements checksumable, executable, loggable {
backup_general_helper::array_checksum_recursive($this->steps));
}
/**
* Add the given info to the current plan's results.
*
* @see base_plan::add_result()
* @param array $result associative array describing a result of a task/step
*/
public function add_result($result) {
if (!is_null($this->plan)) {
$this->plan->add_result($result);
} else {
debugging('Attempting to add a result of a task not binded with a plan', DEBUG_DEVELOPER);
}
}
/**
* Return the current plan's results
*
* @return array|null
*/
public function get_results() {
if (!is_null($this->plan)) {
return $this->plan->get_results();
} else {
debugging('Attempting to get results of a task not binded with a plan', DEBUG_DEVELOPER);
return null;
}
}
// Protected API starts here
/**
+14
View File
@@ -757,6 +757,20 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
public function display(core_backup_renderer $renderer) {
$html = '';
if (!empty($this->results['file_aliases_restore_failures'])) {
$html .= $renderer->box_start('generalbox filealiasesfailures');
$html .= $renderer->heading_with_help(get_string('filealiasesrestorefailures', 'core_backup'),
'filealiasesrestorefailures', 'core_backup');
$html .= $renderer->container(get_string('filealiasesrestorefailuresinfo', 'core_backup'));
$html .= $renderer->container_start('aliaseslist');
$html .= html_writer::start_tag('ul');
foreach ($this->results['file_aliases_restore_failures'] as $alias) {
$html .= html_writer::tag('li', s($alias));
}
$html .= html_writer::end_tag('ul');
$html .= $renderer->container_end();
$html .= $renderer->box_end();
}
$html .= $renderer->box_start();
$html .= $renderer->notification(get_string('restoreexecutionsuccess', 'backup'), 'notifysuccess');
$html .= $renderer->continue_button(new moodle_url('/course/view.php', array(
+4
View File
@@ -69,6 +69,10 @@ class block_blog_recent extends block_base {
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;
}
+4
View File
@@ -93,6 +93,10 @@ class block_blog_tags extends block_base {
// 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;
}
+3 -1
View File
@@ -102,8 +102,10 @@ class delete_category_form extends moodleform {
/// 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) {
+26 -2
View File
@@ -296,7 +296,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
$o.= $this->format_summary_text($section);
$o.= html_writer::end_tag('div');
$o.= $this->section_activity_summary($section, $mods);
$o.= $this->section_activity_summary($section, $course, $mods);
$o.= $this->section_availability_message($section);
@@ -310,16 +310,21 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
* Generate a summary of the activites in a section
*
* @param stdClass $section The course_section entry from DB
* @param stdClass $course the course record from DB
* @param array $mods course modules indexed by id (from get_all_mods)
* @return string HTML to output.
*/
private function section_activity_summary($section, $mods) {
private function section_activity_summary($section, $course, $mods) {
if (empty($section->sequence)) {
return '';
}
// Generate array with count of activities in this section:
$sectionmods = array();
$total = 0;
$complete = 0;
$cancomplete = isloggedin() && !isguestuser();
$completioninfo = new completion_info($course);
$modsequence = explode(',', $section->sequence);
foreach ($modsequence as $cmid) {
$thismod = $mods[$cmid];
@@ -336,6 +341,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
$sectionmods[$thismod->modname]['count'] = 1;
}
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
$total++;
$completiondata = $completioninfo->get_data($thismod, true);
if ($completiondata->completionstate == COMPLETION_COMPLETE) {
$complete++;
}
}
}
}
@@ -353,6 +365,18 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
$o.= html_writer::end_tag('span');
}
$o.= html_writer::end_tag('div');
// Output section completion data
if ($total > 0) {
$a = new stdClass;
$a->complete = $complete;
$a->total = $total;
$o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right'));
$o.= html_writer::tag('span', get_string('progresstotal', 'completion', $a), array('class' => 'activity-count'));
$o.= html_writer::end_tag('div');
}
return $o;
}
+2 -9
View File
@@ -3031,20 +3031,13 @@ function move_section_to($course, $section, $destination) {
}
}
// 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);
}
+73 -1
View File
@@ -66,7 +66,7 @@ class courselib_testcase extends advanced_testcase {
$this->assertFalse($neworder);
}
public function test_move_section() {
public function test_move_section_down() {
global $DB;
$this->resetAfterTest(true);
@@ -78,6 +78,7 @@ class courselib_testcase extends advanced_testcase {
}
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) {
@@ -94,6 +95,77 @@ class courselib_testcase extends advanced_testcase {
$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);
+3 -3
View File
@@ -91,7 +91,7 @@ YUI.add('moodle-course-dragdrop', function(Y) {
// Keep it inside the .course-content
constrain: '#'+CSS.PAGECONTENT,
stickY: true
});
}).plug(Y.Plugin.DDWinScroll);
}
}
}, this);
@@ -306,7 +306,7 @@ YUI.add('moodle-course-dragdrop', function(Y) {
}).plug(Y.Plugin.DDConstrained, {
// Keep it inside the .course-content
constrain: '#'+CSS.PAGECONTENT
});
}).plug(Y.Plugin.DDWinScroll);
}
}, this);
},
@@ -411,4 +411,4 @@ YUI.add('moodle-course-dragdrop', function(Y) {
M.course.init_section_dragdrop = function(params) {
new DRAGSECTION(params);
}
}, '@VERSION@', {requires:['base', 'node', 'io', 'dom', 'dd', 'moodle-core-dragdrop', 'moodle-enrol-notification', 'moodle-course-coursebase']});
}, '@VERSION@', {requires:['base', 'node', 'io', 'dom', 'dd', 'dd-scroll', 'moodle-core-dragdrop', 'moodle-enrol-notification', 'moodle-course-coursebase']});
+22 -14
View File
@@ -81,31 +81,30 @@ YUI.add('moodle-course-modchooser', function(Y) {
// Setup for site topics
Y.one(baseselector).all(CSS.SITETOPIC).each(function(section) {
// The site topic has a sectionid of 1
this._setup_for_section(section, 1);
}, this);
// Setup for the site menu
Y.one(baseselector).all(CSS.SITEMENU).each(function(section) {
// The site menu has a sectionid of 0
this._setup_for_section(section, 0);
this._setup_for_section(section);
}, this);
// Setup for standard course topics
Y.one(baseselector).all(CSS.SECTION).each(function(section) {
// Determine the sectionid for this section
var sectionid = section.get('id').replace('section-', '');
this._setup_for_section(section, sectionid);
this._setup_for_section(section);
}, this);
// Setup for the block site menu
Y.one(baseselector).all(CSS.SITEMENU).each(function(section) {
this._setup_for_section(section);
}, this);
},
_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);
});
chooserspan.insertBefore(chooserlink);
chooserlink.on('click', this.display_mod_chooser, this, sectionid);
chooserlink.on('click', this.display_mod_chooser, this);
},
/**
* Display the module chooser
@@ -114,9 +113,18 @@ YUI.add('moodle-course-modchooser', function(Y) {
* @param secitonid integer The ID of the section triggering the dialogue
* @return void
*/
display_mod_chooser : function (e, sectionid) {
display_mod_chooser : function (e) {
// Set the section for this version of the dialogue
this.sectionid = sectionid;
if (e.target.ancestor(CSS.SITETOPIC)) {
// The site topic has a sectionid of 1
this.sectionid = 1;
} else if (e.target.ancestor(CSS.SECTION)) {
var section = e.target.ancestor(CSS.SECTION);
this.sectionid = section.get('id').replace('section-', '');
} else if (e.target.ancestor(CSS.SITEMENU)) {
// The block site menu has a sectionid of 0
this.sectionid = 0;
}
this.display_chooser(e);
},
toggle_mod_chooser : function(e) {
+78 -41
View File
@@ -279,6 +279,8 @@ class core_files_renderer extends plugin_renderer_base {
<span class="fp-filename-icon">
<a href="#">
<span class="{!}fp-icon"></span>
<span class="fp-reficons1"></span>
<span class="fp-reficons2"></span>
<span class="{!}fp-filename"></span>
</a>
<a class="{!}fp-contextmenu" href="#" onclick="return false;">'.$this->pix_icon('i/menu', '▶').'</a>
@@ -303,8 +305,8 @@ class core_files_renderer extends plugin_renderer_base {
$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);
}
@@ -370,12 +372,11 @@ class core_files_renderer extends plugin_renderer_base {
<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>
@@ -391,19 +392,20 @@ class core_files_renderer extends plugin_renderer_base {
<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);
@@ -424,8 +426,8 @@ class core_files_renderer extends plugin_renderer_base {
$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('ok').'</button>
<button class="{!}fp-dlg-butcancel">'.get_string('cancel').'</button>
</div>';
return preg_replace('/\{\!\}/', '', $rv);
}
@@ -455,11 +457,9 @@ class core_files_renderer extends plugin_renderer_base {
$maxbytes = display_size($fm->options->maxbytes);
if (empty($options->maxfiles) || $options->maxfiles == -1) {
$maxsize = get_string('maxfilesize', 'moodle', $maxbytes);
//$string['maxfilesize'] = 'Maximum size for new files: {$a}';
} else {
$strparam = (object)array('size' => $maxbytes, 'attachments' => $options->maxfiles);
$maxsize = get_string('maxsizeandattachments', 'moodle', $strparam);
//$string['maxsizeandattachments'] = 'Maximum size for new files: {$a->size}, maximum attachments: {$a->attachments}';
}
// TODO MDL-32020 also should say about 'File types accepted'
return '<span>'. $maxsize. '</span>';
@@ -565,7 +565,11 @@ class core_files_renderer extends plugin_renderer_base {
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>
@@ -661,11 +665,6 @@ class core_files_renderer extends plugin_renderer_base {
<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>
@@ -686,16 +685,23 @@ class core_files_renderer extends plugin_renderer_base {
<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);
}
@@ -791,7 +797,7 @@ class core_files_renderer extends plugin_renderer_base {
$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);
}
@@ -802,6 +808,34 @@ class core_files_renderer extends plugin_renderer_base {
* 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',
* '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
* (Note that it may have long text)
*
* @return 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;
*
@@ -810,13 +844,16 @@ class core_files_renderer extends plugin_renderer_base {
*
* @return string
*/
private function fp_js_template_processexistingfile() {
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);
}
+1 -1
View File
@@ -410,7 +410,7 @@ if ($config->stage == INSTALL_DATABASE) {
$disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="30" class="forminput" />';
echo '</div>';
echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
+1 -1
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle 2.3dev installer
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was

Some files were not shown because too many files have changed in this diff Show More