$oldversion = "$CFG->release ($CFG->version)";
$newversion = "$release ($version)";
+if (!moodle_needs_upgrading()) {
+ cli_error(get_string('cliupgradenoneed', 'core_admin', $newversion), 0);
+}
+
// Test environment first.
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
if (!$envstatus) {
</PHP_EXTENSION>
<PHP_EXTENSION name="json" level="required">
</PHP_EXTENSION>
+ <PHP_EXTENSION name="hash" level="required"/>
</PHP_EXTENSIONS>
<PHP_SETTINGS>
<PHP_SETTING name="memory_limit" value="40M" level="required">
}
}
- // at this stage there can be only one admin - users may change username, so do not rely on that
- $adminuser = get_complete_user_data('id', $CFG->siteadmins);
+ // at this stage there can be only one admin unless more were added by install - users may change username, so do not rely on that
+ $adminuser = get_complete_user_data('id', reset(explode(',', $CFG->siteadmins)));
if ($adminuser->password === 'adminsetuppending') {
// prevent installation hijacking
$usernames = explode(',', $form->username);
foreach ($usernames as $username) {
- $username = trim(moodle_strtolower($username));
+ $username = trim(textlib::strtolower($username));
if (!empty($username)) {
if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
if ($form->accessctrl == 'allow') {
$shortname = optional_param('shortname', null, PARAM_RAW);
if (!is_null($shortname)) {
$this->role->shortname = $shortname;
- $this->role->shortname = textlib_get_instance()->specialtoascii($this->role->shortname);
- $this->role->shortname = moodle_strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
+ $this->role->shortname = textlib::specialtoascii($this->role->shortname);
+ $this->role->shortname = textlib::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
if (empty($this->role->shortname)) {
$this->errors['shortname'] = get_string('errorbadroleshortname', 'role');
}
echo '</form>';
}
-$PAGE->requires->yui_module('moodle-core-formslib',
- 'M.core.init_formslib',
+$PAGE->requires->yui_module('moodle-core-formchangechecker',
+ 'M.core_formchangechecker.init',
array(array(
'formid' => 'adminsettings'
))
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_users', new lang_string('generalusers','backup'), new lang_string('configgeneralusers','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_anonymize', new lang_string('generalanonymize','backup'), new lang_string('configgeneralanonymize','backup'), array('value'=>0, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), array('value'=>1, 'locked'=>0)));
- $temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_user_files', new lang_string('generaluserfiles','backup'), new lang_string('configgeneraluserfiles','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
$temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), ''));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
- $temp->add(new admin_setting_configcheckbox('backup/backup_auto_user_files', new lang_string('generaluserfiles', 'backup'), new lang_string('configgeneraluserfiles','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="admin/tool/customlang/db" VERSION="20110925" COMMENT="XMLDB file for Moodle admin/tool/customlang"
+<XMLDB PATH="admin/tool/customlang/db" VERSION="20120122" COMMENT="XMLDB file for Moodle admin/tool/customlang"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="tool_customlang" COMMENT="Contains the working checkout of all strings and their customization" NEXT="tool_customlang_components">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="lang"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="lang"/>
<FIELD NAME="lang" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The code of the language this string belongs to. Like en, cs or es" PREVIOUS="id" NEXT="componentid"/>
- <FIELD NAME="componentid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the component" PREVIOUS="lang" NEXT="stringid"/>
+ <FIELD NAME="componentid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The id of the component" PREVIOUS="lang" NEXT="stringid"/>
<FIELD NAME="stringid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The identifier of the string" PREVIOUS="componentid" NEXT="original"/>
<FIELD NAME="original" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false" COMMENT="English original of the string" PREVIOUS="stringid" NEXT="master"/>
<FIELD NAME="master" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Master translation of the string as is distributed in the official lang pack, null if not translated" PREVIOUS="original" NEXT="local"/>
<FIELD NAME="local" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Local customization of the string, null if not customized" PREVIOUS="master" NEXT="timemodified"/>
- <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The timestamp of when the original or master was recently modified" PREVIOUS="local" NEXT="timecustomized"/>
- <FIELD NAME="timecustomized" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The timestamp of when the value of the local translation was recently modified, null if not customized yet" PREVIOUS="timemodified" NEXT="outdated"/>
- <FIELD NAME="outdated" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Either the English original or the master translation changed and the customization may be outdated" PREVIOUS="timecustomized" NEXT="modified"/>
- <FIELD NAME="modified" TYPE="int" LENGTH="3" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Has the string been modified via the translator?" PREVIOUS="outdated"/>
+ <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The timestamp of when the original or master was recently modified" PREVIOUS="local" NEXT="timecustomized"/>
+ <FIELD NAME="timecustomized" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The timestamp of when the value of the local translation was recently modified, null if not customized yet" PREVIOUS="timemodified" NEXT="outdated"/>
+ <FIELD NAME="outdated" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Either the English original or the master translation changed and the customization may be outdated" PREVIOUS="timecustomized" NEXT="modified"/>
+ <FIELD NAME="modified" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Has the string been modified via the translator?" PREVIOUS="outdated"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_component"/>
</TABLE>
<TABLE NAME="tool_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack" PREVIOUS="tool_customlang">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown" PREVIOUS="name"/>
</FIELDS>
print_error('csvfewcolumns', 'error', $returnurl);
}
- $textlib = textlib_get_instance(); // profile fields may contain unicode chars
-
// test columns
$processed = array();
foreach ($columns as $key=>$unused) {
$field = $columns[$key];
- $lcfield = $textlib->strtolower($field);
+ $lcfield = textlib::strtolower($field);
if (in_array($field, $stdfields) or in_array($lcfield, $stdfields)) {
// standard fields are only lowercase
$newfield = $lcfield;
* Internal callback function.
*/
function uu_process_template_callback($username, $firstname, $lastname, $block) {
- $textlib = textlib_get_instance();
-
switch ($block[3]) {
case 'u':
$repl = $username;
switch ($block[1]) {
case '+':
- $repl = $textlib->strtoupper($repl);
+ $repl = textlib::strtoupper($repl);
break;
case '-':
- $repl = $textlib->strtolower($repl);
+ $repl = textlib::strtolower($repl);
break;
case '~':
- $repl = $textlib->strtotitle($repl);
+ $repl = textlib::strtotitle($repl);
break;
}
if (!empty($block[2])) {
- $repl = $textlib->substr($repl, 0 , $block[2]);
+ $repl = textlib::substr($repl, 0 , $block[2]);
}
return $repl;
$mform->setDefault('delimiter_name', 'comma');
}
- $textlib = textlib_get_instance();
- $choices = $textlib->get_encodings();
+ $choices = textlib::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
/**
* reporting about the ones not physically implemented as BIGINTs
- * and providing one SQL script to fix all them. Also, under MySQL,
- * it performs one check of signed bigints. MDL-11038
+ * and providing one SQL script to fix all them. MDL-11038
*
* @package tool
* @subpackage xmldb
'wrongints' => 'tool_xmldb',
'nowrongintsfound' => 'tool_xmldb',
'yeswrongintsfound' => 'tool_xmldb',
- 'mysqlextracheckbigints' => 'tool_xmldb',
));
// Correct fields must be type bigint for MySQL and int8 for PostgreSQL
$metacolumn = $metacolumns[$xmldb_field->getName()];
// Going to check this field in DB
$o.=' <li>' . $this->str['field'] . ': ' . $xmldb_field->getName() . ' ';
- // Detect if the physical field is wrong and, under mysql, check for incorrect signed fields too
- if ($metacolumn->type != $this->correct_type || ($this->dbfamily == 'mysql' && $xmldb_field->getUnsigned() && !$metacolumn->unsigned)) {
+ // Detect if the physical field is wrong
+ if ($metacolumn->type != $this->correct_type) {
$o.='<font color="red">' . $this->str['wrong'] . '</font>';
// Add the wrong field to the list
$obj = new stdClass();
$c.= ' <TABLES>' . "\n";
$c.= ' <TABLE NAME="' . $xmltable . '" COMMENT="Default comment for ' . $xmltable .', please edit me">' . "\n";
$c.= ' <FIELDS>' . "\n";
- $c.= ' <FIELD NAME="id" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" SEQUENCE="true" />' . "\n";
+ $c.= ' <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />' . "\n";
$c.= ' </FIELDS>' . "\n";
$c.= ' <KEYS>' . "\n";
$c.= ' <KEY NAME="primary" TYPE="primary" FIELDS="id" />' . "\n";
// xmldb_field Decimals
$o.= ' <tr valign="top"><td><label for="decimals" accesskey="d">Decimals:</label></td>';
$o.= ' <td colspan="2"><input name="decimals" type="text" size="6" maxlength="6" id="decimals" value="' . s($field->getDecimals()) . '" /><span id="decimalstip"></span></td></tr>';
- // xmldb_field Unsigned
- $unsignedoptions = array (0 => 'signed', 1 => 'unsigned');
- $select = html_writer::select($unsignedoptions, 'unsigned', $field->getUnsigned(), false);
- $o.= ' <tr valign="top"><td><label for="menuunsigned" accesskey="u">Unsigned:</label></td>';
- $o.= ' <td colspan="2">' . $select . '</td></tr>';
// xmldb_field NotNull
$notnulloptions = array (0 => 'null', 'not null');
$select = html_writer::select($notnulloptions, 'notnull', $field->getNotNull(), false);
var typeField = document.getElementById('menutype');
var lengthField = document.getElementById('length');
var decimalsField = document.getElementById('decimals');
- var unsignedField = document.getElementById('menuunsigned');
var notnullField = document.getElementById('menunotnull');
var sequenceField = document.getElementById('menusequence');
var defaultField = document.getElementById('default');
// Initially, enable everything
decimalsField.disabled = false;
- unsignedField.disabled = false;
notnullField.disabled = false;
sequenceField.disabled = false;
defaultField.disabled = false;
// Based on sequence, disable some items
if (sequenceField.value == '1') {
- unsignedField.disabled = true;
- unsignedField.value = '1';
notnullField.disabled = true;
notnullField.value = '1';
defaultField.disabled = true;
case '2': // XMLDB_TYPE_NUMBER
lengthTip.innerHTML = ' 1...20';
decimalsTip.innerHTML = ' 0...length or empty';
- unsignedField.disabled = true;
- unsignedField.value = '0';
break;
case '3': // XMLDB_TYPE_FLOAT
lengthTip.innerHTML = ' 1...20 or empty';
decimalsTip.innerHTML = ' 0...length or empty';
- unsignedField.disabled = true;
- unsignedField.value = '0';
break;
case '4': // XMLDB_TYPE_CHAR
lengthTip.innerHTML = ' 1...1333'; // Hardcoded, yes!
decimalsTip.innerHTML = '';
decimalsField.disabled = true;
decimalsField.value = '';
- unsignedField.disabled = true;
- unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
break;
decimalsTip.innerHTML = '';
decimalsField.disabled = true;
decimalsField.value = '';
- unsignedField.disabled = true;
- unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
defaultField.disabled = true;
decimalsTip.innerHTML = '';
decimalsField.disabled = true;
decimalsField.value = '';
- unsignedField.disabled = true;
- unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
defaultField.disabled = true;
decimalsTip.innerHTML = '';
decimalsField.disabled = true;
decimalsField.value = '';
- unsignedField.disabled = true;
- unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
defaultField.disabled = true;
$type = required_param('type', PARAM_INT);
$length = strtolower(optional_param('length', NULL, PARAM_ALPHANUM));
$decimals = optional_param('decimals', NULL, PARAM_INT);
- $unsigned = optional_param('unsigned', false, PARAM_BOOL);
$notnull = optional_param('notnull', false, PARAM_BOOL);
$sequence = optional_param('sequence', false, PARAM_BOOL);
$default = optional_param('default', NULL, PARAM_PATH);
// Perform some automatic assumptions
if ($sequence) {
- $unsigned = true;
$notnull = true;
$default = NULL;
}
$tempfield->setType($type);
$tempfield->setLength($length);
$tempfield->setDecimals($decimals);
- $tempfield->setUnsigned($unsigned);
$tempfield->setNotNull($notnull);
$tempfield->setSequence($sequence);
$tempfield->setDefault($default);
$field->setType($type);
$field->setLength($length);
$field->setDecimals($decimals);
- $field->setUnsigned($unsigned);
$field->setNotNull($notnull);
$field->setSequence($sequence);
$field->setDefault($default);
<td class="cell c1" style="white-space: nowrap;">
<xsl:value-of select="@TYPE"/>
(<xsl:value-of select="@LENGTH"/><xsl:if test="@DECIMALS">, <xsl:value-of select="@DECIMALS"/></xsl:if>)
- <xsl:if test="@UNSIGNED='true'">unsigned </xsl:if>
<xsl:if test="@NOTNULL='true'">not null </xsl:if>
<xsl:if test="@DEFAULT">
<xsl:choose>
$field->setType(XMLDB_TYPE_INTEGER);
$field->setLength(10);
$field->setNotNull(true);
- $field->setUnsigned(true);
$field->setSequence(true);
$field->setLoaded(true);
$field->setChanged(true);
$optionspacer . 'rename_field',
$optionspacer . 'change_field_type',
$optionspacer . 'change_field_precision',
- $optionspacer . 'change_field_unsigned',
$optionspacer . 'change_field_notnull',
$optionspacer . 'change_field_default',
$optionspacer . 'drop_enum_from_field', // TODO: Moodle 2.1 - Drop drop_enum_from_field
$o.= $this->str['mustselectonefield'];
}
break;
- case 'change_field_unsigned':
- if ($fieldkeyindexinitial == 'f') { //Only if we have got one field
- $o.= s($this->change_field_unsigned_php($structure, $tableparam, $fieldkeyindexparam));
- } else {
- $o.= $this->str['mustselectonefield'];
- }
- break;
case 'change_field_notnull':
if ($fieldkeyindexinitial == 'f') { // Only if we have got one field
$o.= s($this->change_field_notnull_php($structure, $tableparam, $fieldkeyindexparam));
return $result;
}
- /**
- * This function will generate all the PHP code needed to
- * change the unsigned/signed of one field using XMLDB objects and functions
- *
- * @param xmldb_structure structure object containing all the info
- * @param string table table name
- * @param string field field name to change unsigned/signed
- */
- function change_field_unsigned_php($structure, $table, $field) {
-
- $result = '';
- // Validate if we can do it
- if (!$table = $structure->getTable($table)) {
- return false;
- }
- if (!$field = $table->getField($field)) {
- return false;
- }
- if ($table->getAllErrors()) {
- return false;
- }
-
- // Calculate the unsigned tip text
- $unsigned = $field->getUnsigned() ? 'unsigned' : 'signed';
-
- // Add the standard PHP header
- $result .= XMLDB_PHP_HEADER;
-
- // Add contents
- $result .= XMLDB_LINEFEED;
- $result .= ' // Changing sign of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $unsigned . XMLDB_LINEFEED;
- $result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
- $result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
-
- // Launch the proper DDL
- $result .= XMLDB_LINEFEED;
- $result .= ' // Launch change of sign for field ' . $field->getName() . XMLDB_LINEFEED;
- $result .= ' $dbman->change_field_unsigned($table, $field);' . XMLDB_LINEFEED;
-
- // Add the proper upgrade_xxxx_savepoint call
- $result .= $this->upgrade_savepoint_php ($structure);
-
- // Add standard PHP footer
- $result .= XMLDB_PHP_FOOTER;
-
- return $result;
- }
-
/**
* This function will generate all the PHP code needed to
* change the nullability of one field using XMLDB objects and functions
$string['mustselectonefield'] = 'You must select one field to see field related actions!';
$string['mustselectoneindex'] = 'You must select one index to see index related actions!';
$string['mustselectonekey'] = 'You must select one key to see key related actions!';
-$string['mysqlextracheckbigints'] = 'Under MySQL it also looks for incorrectly signed bigints, generating the required SQL to be executed in order to fix all them.';
$string['newfield'] = 'New field';
$string['newindex'] = 'New index';
$string['newkey'] = 'New key';
*/
function user_login ($username, $password) {
$this->connectCAS();
- return phpCAS::isAuthenticated() && (trim(moodle_strtolower(phpCAS::getUser())) == $username);
+ return phpCAS::isAuthenticated() && (trim(textlib::strtolower(phpCAS::getUser())) == $username);
}
/**
set_config('host_url', trim($config->host_url), $this->pluginconfig);
set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
set_config('contexts', trim($config->contexts), $this->pluginconfig);
- set_config('user_type', moodle_strtolower(trim($config->user_type)), $this->pluginconfig);
- set_config('user_attribute', moodle_strtolower(trim($config->user_attribute)), $this->pluginconfig);
+ set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
+ set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
set_config('search_sub', $config->search_sub, $this->pluginconfig);
set_config('opt_deref', $config->opt_deref, $this->pluginconfig);
set_config('bind_dn', trim($config->bind_dn), $this->pluginconfig);
set_config('bind_pw', $config->bind_pw, $this->pluginconfig);
set_config('ldap_version', $config->ldap_version, $this->pluginconfig);
set_config('objectclass', trim($config->objectclass), $this->pluginconfig);
- set_config('memberattribute', moodle_strtolower(trim($config->memberattribute)), $this->pluginconfig);
+ set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig);
set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig);
set_config('attrcreators', trim($config->attrcreators), $this->pluginconfig);
set_config('groupecreators', trim($config->groupecreators), $this->pluginconfig);
return false;
}
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
// Test for group creator
if (!empty($this->config->groupecreators)) {
return false;
}
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
- $extpassword = $textlib->convert($password, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+ $extpassword = textlib::convert($password, 'utf-8', $this->config->ldapencoding);
// Before we connect to LDAP, check if this is an AD SSO login
// if we succeed in this block, we'll return success early.
* @return mixed array with no magic quotes or false on error
*/
function get_userinfo($username) {
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
$ldapconnection = $this->ldap_connect();
if(!($user_dn = $this->ldap_find_userdn($ldapconnection, $extusername))) {
continue; // wrong data mapping!
}
if (is_array($entry[$value])) {
- $newval = $textlib->convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
+ $newval = textlib::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
} else {
- $newval = $textlib->convert($entry[$value], $this->config->ldapencoding, 'utf-8');
+ $newval = textlib::convert($entry[$value], $this->config->ldapencoding, 'utf-8');
}
if (!empty($newval)) { // favour ldap entries that are set
$ldapval = $newval;
* @param string $username
*/
function user_exists($username) {
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
// Returns true if given username exists on ldap
$users = $this->ldap_get_userlist('('.$this->config->user_attribute.'='.ldap_filter_addslashes($extusername).')');
* @param mixed $plainpass Plaintext password
*/
function user_create($userobject, $plainpass) {
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($userobject->username, 'utf-8', $this->config->ldapencoding);
- $extpassword = $textlib->convert($plainpass, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($userobject->username, 'utf-8', $this->config->ldapencoding);
+ $extpassword = textlib::convert($plainpass, 'utf-8', $this->config->ldapencoding);
switch ($this->config->passtype) {
case 'md5':
}
foreach ($values as $value) {
if (!empty($userobject->$key) ) {
- $newuser[$value] = $textlib->convert($userobject->$key, 'utf-8', $this->config->ldapencoding);
+ $newuser[$value] = textlib::convert($userobject->$key, 'utf-8', $this->config->ldapencoding);
}
}
}
function password_expire($username) {
$result = 0;
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
$ldapconnection = $this->ldap_connect();
$user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
print_string('connectingldap', 'auth_ldap');
$ldapconnection = $this->ldap_connect();
- $textlib = textlib_get_instance();
$dbman = $DB->get_manager();
/// Define table user to be created
if ($entry = @ldap_first_entry($ldapconnection, $ldap_result)) {
do {
$value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute);
- $value = $textlib->convert($value[0], $this->config->ldapencoding, 'utf-8');
+ $value = textlib::convert($value[0], $this->config->ldapencoding, 'utf-8');
$this->ldap_bulk_insert($value);
} while ($entry = ldap_next_entry($ldapconnection, $entry));
}
$user->mnethostid = $CFG->mnet_localhost_id;
// get_userinfo_asobj() might have replaced $user->username with the value
// from the LDAP server (which can be mixed-case). Make sure it's lowercase
- $user->username = trim(moodle_strtolower($user->username));
+ $user->username = trim(textlib::strtolower($user->username));
if (empty($user->lang)) {
$user->lang = $CFG->lang;
}
global $CFG, $DB;
// Just in case check text case
- $username = trim(moodle_strtolower($username));
+ $username = trim(textlib::strtolower($username));
// Get the current user record
$user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id));
function ldap_bulk_insert($username) {
global $DB, $CFG;
- $username = moodle_strtolower($username); // usernames are __always__ lowercase.
+ $username = textlib::strtolower($username); // usernames are __always__ lowercase.
$DB->insert_record_raw('tmp_extuser', array('username'=>$username,
'mnethostid'=>$CFG->mnet_localhost_id), false, true);
echo '.';
* @return boolean result
*/
function user_activate($username) {
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
$ldapconnection = $this->ldap_connect();
return null;
}
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
$ldapconnection = $this->ldap_connect();
return true;
}
- $textlib = textlib_get_instance();
- $extoldusername = $textlib->convert($olduser->username, 'utf-8', $this->config->ldapencoding);
+ $extoldusername = textlib::convert($olduser->username, 'utf-8', $this->config->ldapencoding);
$ldapconnection = $this->ldap_connect();
$ambiguous = false;
}
- $nuvalue = $textlib->convert($newuser->$key, 'utf-8', $this->config->ldapencoding);
+ $nuvalue = textlib::convert($newuser->$key, 'utf-8', $this->config->ldapencoding);
empty($nuvalue) ? $nuvalue = array() : $nuvalue;
- $ouvalue = $textlib->convert($olduser->$key, 'utf-8', $this->config->ldapencoding);
+ $ouvalue = textlib::convert($olduser->$key, 'utf-8', $this->config->ldapencoding);
foreach ($ldapkeys as $ldapkey) {
$ldapkey = $ldapkey;
$result = false;
$username = $user->username;
- $textlib = textlib_get_instance();
- $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
- $extpassword = $textlib->convert($newpassword, 'utf-8', $this->config->ldapencoding);
+ $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+ $extpassword = textlib::convert($newpassword, 'utf-8', $this->config->ldapencoding);
switch ($this->config->passtype) {
case 'md5':
$moodleattributes = array();
foreach ($this->userfields as $field) {
if (!empty($this->config->{"field_map_$field"})) {
- $moodleattributes[$field] = moodle_strtolower(trim($this->config->{"field_map_$field"}));
+ $moodleattributes[$field] = textlib::strtolower(trim($this->config->{"field_map_$field"}));
if (preg_match('/,/', $moodleattributes[$field])) {
$moodleattributes[$field] = explode(',', $moodleattributes[$field]); // split ?
}
}
}
- $moodleattributes['username'] = moodle_strtolower(trim($this->config->user_attribute));
+ $moodleattributes['username'] = textlib::strtolower(trim($this->config->user_attribute));
return $moodleattributes;
}
$users = ldap_get_entries_moodle($ldapconnection, $ldap_result);
// Add found users to list
- $textlib = textlib_get_instance();
for ($i = 0; $i < count($users); $i++) {
- $extuser = $textlib->convert($users[$i][$this->config->user_attribute][0],
+ $extuser = textlib::convert($users[$i][$this->config->user_attribute][0],
$this->config->ldapencoding, 'utf-8');
array_push($fresult, $extuser);
}
// (according to my reading of RFC-1945, RFC-2616 and RFC-2617 and
// my local tests), so we need to convert the REMOTE_USER value
// (i.e., what we got from the HTTP WWW-Authenticate header) into UTF-8
- $textlib = textlib_get_instance();
- $username = $textlib->convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8');
+ $username = textlib::convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8');
switch ($this->config->ntlmsso_type) {
case 'ntlm':
return false; // Should never happen!
}
- $username = moodle_strtolower($username); // Compatibility hack
+ $username = textlib::strtolower($username); // Compatibility hack
set_cache_flag($this->pluginconfig.'/ntlmsess', $sesskey, $username, AUTH_NTLMTIMEOUT);
return true;
}
set_config('host_url', trim($config->host_url), $this->pluginconfig);
set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
set_config('contexts', trim($config->contexts), $this->pluginconfig);
- set_config('user_type', moodle_strtolower(trim($config->user_type)), $this->pluginconfig);
- set_config('user_attribute', moodle_strtolower(trim($config->user_attribute)), $this->pluginconfig);
+ set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
+ set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
set_config('search_sub', $config->search_sub, $this->pluginconfig);
set_config('opt_deref', $config->opt_deref, $this->pluginconfig);
set_config('preventpassindb', $config->preventpassindb, $this->pluginconfig);
set_config('bind_pw', $config->bind_pw, $this->pluginconfig);
set_config('ldap_version', $config->ldap_version, $this->pluginconfig);
set_config('objectclass', trim($config->objectclass), $this->pluginconfig);
- set_config('memberattribute', moodle_strtolower(trim($config->memberattribute)), $this->pluginconfig);
+ set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig);
set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig);
set_config('creators', trim($config->creators), $this->pluginconfig);
set_config('create_context', trim($config->create_context), $this->pluginconfig);
set_config('expiration', $config->expiration, $this->pluginconfig);
set_config('expiration_warning', trim($config->expiration_warning), $this->pluginconfig);
- set_config('expireattr', moodle_strtolower(trim($config->expireattr)), $this->pluginconfig);
+ set_config('expireattr', textlib::strtolower(trim($config->expireattr)), $this->pluginconfig);
set_config('gracelogins', $config->gracelogins, $this->pluginconfig);
- set_config('graceattr', moodle_strtolower(trim($config->graceattr)), $this->pluginconfig);
+ set_config('graceattr', textlib::strtolower(trim($config->graceattr)), $this->pluginconfig);
set_config('auth_user_create', $config->auth_user_create, $this->pluginconfig);
set_config('forcechangepassword', $config->forcechangepassword, $this->pluginconfig);
set_config('stdchangepassword', $config->stdchangepassword, $this->pluginconfig);
'users' => 0, // @todo how to detect this from moodle.xml?
'anonymize' => 0,
'role_assignments' => 0,
- 'user_files' => 0,
'activities' => 1,
'blocks' => 1,
'filters' => 0,
// replay the upgrade step 2010080901 - updating question image
if (!empty($data['image'])) {
- $textlib = textlib_get_instance();
- if ($textlib->substr($textlib->strtolower($data['image']), 0, 7) == 'http://') {
+ if (textlib::substr(textlib::strtolower($data['image']), 0, 7) == 'http://') {
// it is a link, appending to existing question text
$data['questiontext'] .= ' <img src="' . $data['image'] . '" />';
/** @var string the root of the converter temp directory */
protected $basepath;
- /** @var textlib instance used during the migration */
- protected $textlib;
-
/** @var array of file ids that were migrated by this instance */
protected $fileids = array();
$this->userid = $userid;
// set other useful bits
$this->basepath = $converter->get_tempdir_path();
- $this->textlib = textlib_get_instance();
}
/**
}
$filepath = clean_param($filepath, PARAM_PATH);
- if ($this->textlib->strlen($filepath) > 255) {
+ if (textlib::strlen($filepath) > 255) {
throw new moodle1_convert_exception('file_path_longer_than_255_chars');
}
// done in a single pass
$this->add_step(new backup_annotate_all_question_files('question_files'));
- // Annotate all the user files (conditionally) (private, profile and icon files)
+ // Annotate all the user files (conditionally) (profile and icon files)
// Because each user has its own context, we need a separate/specialised step here
// This step also ensures that the contexts for all the users exist, so next
// step can be safely executed (join between users and contexts)
$this->add_setting($roleassignments);
$users->add_dependency($roleassignments);
- // Define user_files (dependent of users and anonymize)
- $userfiles = new backup_user_files_setting('user_files', base_setting::IS_BOOLEAN, true);
- $userfiles->set_ui(new backup_setting_ui_checkbox($userfiles, get_string('rootsettinguserfiles', 'backup')));
- $this->add_setting($userfiles);
- $users->add_dependency($userfiles);
- $anonymize->add_dependency($userfiles, setting_dependency::DISABLED_TRUE);
-
// Define activities
$activities = new backup_activities_setting('activities', base_setting::IS_BOOLEAN, true);
$activities->set_ui(new backup_setting_ui_checkbox($activities, get_string('rootsettingactivities', 'backup')));
*/
class backup_anonymize_setting extends root_backup_setting {}
-/**
- * root setting to control if backup will include
- * user files or no (images, local storage), depends of @backup_users_setting
- * exactly in the same way than @backup_anonymize_setting so we extend from it
- */
-class backup_user_files_setting extends backup_anonymize_setting {}
-
/**
* root setting to control if backup will include
* role assignments or no (any level), depends of @backup_users_setting
// List of fileareas we are going to annotate
$fileareas = array('profile', 'icon');
- if ($this->get_setting_value('user_files')) { // private files only if enabled in settings
- $fileareas[] = 'private';
- }
-
// Fetch all annotated (final) users
$rs = $DB->get_recordset('backup_ids_temp', array(
'backupid' => $this->get_backupid(), 'itemname' => 'userfinal'));
$this->add_setting($roleassignments);
$users->add_dependency($roleassignments);
- // Define user_files (dependent of users)
- $defaultvalue = false; // Safer default
- $changeable = false;
- if (isset($rootsettings['user_files']) && $rootsettings['user_files']) { // Only enabled when available
- $defaultvalue = true;
- $changeable = true;
- }
- $userfiles = new restore_user_files_setting('user_files', base_setting::IS_BOOLEAN, $defaultvalue);
- $userfiles->set_ui(new backup_setting_ui_checkbox($userfiles, get_string('rootsettinguserfiles', 'backup')));
- $userfiles->get_ui()->set_changeable($changeable);
- $this->add_setting($userfiles);
- $users->add_dependency($userfiles);
-
// Define activitites
$defaultvalue = false; // Safer default
$changeable = false;
// Define the task contextid (the course one)
$this->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
- // Executed conditionally if restoring to new course or deleting or if overwrite_conf setting is enabled
- if ($this->get_target() == backup::TARGET_NEW_COURSE || $this->get_target() == backup::TARGET_CURRENT_DELETING ||
- $this->get_target() == backup::TARGET_EXISTING_DELETING || $this->get_setting_value('overwrite_conf') == true) {
- $this->add_step(new restore_section_structure_step('course_info', 'section.xml'));
- }
+ // We always try to restore as much info from sections as possible, no matter of the type
+ // of restore (new, existing, deleting, import...). MDL-27764
+ $this->add_step(new restore_section_structure_step('course_info', 'section.xml'));
// At the end, mark it as built
$this->built = true;
*/
class restore_role_assignments_setting extends root_backup_setting {}
-/**
- * root setting to control if restore will create
- * user files or no (images, local storage), depends of @restore_users_setting
- * exactly in the same way than @restore_role_assignments_setting so we extend from it
- */
-class restore_user_files_setting extends restore_role_assignments_setting {}
-
/**
* root setting to control if restore will create activities
* A lot of other settings (_included at activity levels)
protected function define_execution() {
- restore_dbops::create_included_users($this->get_basepath(), $this->get_restoreid(), $this->get_setting_value('user_files'), $this->task->get_userid());
+ restore_dbops::create_included_users($this->get_basepath(), $this->get_restoreid(), $this->task->get_userid());
}
}
//Process contacts
if ($contactcount) {
if (!defined('RESTORE_SILENTLY')) {
- echo '<li>'.moodle_strtolower(get_string('contacts','message')).'</li>';
+ echo '<li>'.textlib::strtolower(get_string('contacts','message')).'</li>';
}
$counter = 0;
while ($counter < $contactcount) {
'backup_general_users' => 'users',
'backup_general_anonymize' => 'anonymize',
'backup_general_role_assignments' => 'role_assignments',
- 'backup_general_user_files' => 'user_files',
'backup_general_activities' => 'activities',
'backup_general_blocks' => 'blocks',
'backup_general_filters' => 'filters',
global $DB;
// Calculate backup word
- $backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
+ $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
$backupword = trim(clean_filename($backupword), '_');
$shortname = '';
break;
}
$shortname = str_replace(' ', '_', $shortname);
- $shortname = moodle_strtolower(trim(clean_filename($shortname), '_'));
+ $shortname = textlib::strtolower(trim(clean_filename($shortname), '_'));
}
$name = empty($shortname) ? $id : $shortname;
// Calculate date
$backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
$date = userdate(time(), $backupdateformat, 99, false);
- $date = moodle_strtolower(trim(clean_filename($date), '_'));
+ $date = textlib::strtolower(trim(clean_filename($date), '_'));
// Calculate info
$info = '';
* ready to be created. Also, annotate their newids
* once created for later reference
*/
- public static function create_included_users($basepath, $restoreid, $userfiles, $userid) {
+ public static function create_included_users($basepath, $restoreid, $userid) {
global $CFG, $DB;
$authcache = array(); // Cache to get some bits from authentication plugins
// Create user files in pool (profile, icon, private) by context
restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'profile', $recuser->parentitemid, $userid);
- if ($userfiles) { // private files only if enabled in settings
- restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'private', $recuser->parentitemid, $userid);
- }
-
}
}
$rs->close();
$settings = array(
'users' => 'backup_auto_users',
'role_assignments' => 'backup_auto_role_assignments',
- 'user_files' => 'backup_auto_user_files',
'activities' => 'backup_auto_activities',
'blocks' => 'backup_auto_blocks',
'filters' => 'backup_auto_filters',
$storage = $config->backup_auto_storage;
$dir = $config->backup_auto_destination;
- $backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
+ $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
$backupword = trim(clean_filename($backupword), '_');
if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
$html .= html_writer::start_tag('div', array('class'=>'backup-section settings-section'));
$html .= $this->output->heading(get_string('backupsettings', 'backup'), 2, array('class'=>'header'));
foreach ($details->root_settings as $label=>$value) {
- if ($label == 'filename') continue;
+ if ($label == 'filename' or $label == 'user_files') {
+ continue;
+ }
$html .= $this->backup_detail_pair(get_string('rootsetting'.str_replace('_','',$label), 'backup'), $value?$yestick:$notick);
}
$html .= html_writer::end_tag('div');
$output = html_writer::start_tag('div', array('class' => 'import-course-search'));
if ($component->get_count() === 0) {
$output .= $this->output->notification(get_string('nomatchingcourses', 'backup'));
+
+ $output .= html_writer::start_tag('div', array('class'=>'ics-search'));
+ $output .= html_writer::empty_tag('input', array('type'=>'text', 'name'=>restore_course_search::$VAR_SEARCH, 'value'=>$component->get_search()));
+ $output .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'searchcourses', 'value'=>get_string('search')));
+ $output .= html_writer::end_tag('div');
+
$output .= html_writer::end_tag('div');
return $output;
}
$this->totalcount = 0;
$contextlevel = $this->get_itemcontextlevel();
list($sql, $params) = $this->get_searchsql();
- $resultset = $DB->get_recordset_sql($sql, $params, 0, 250);
- foreach ($resultset as $result) {
- context_instance_preload($result);
- $context = get_context_instance($contextlevel, $result->id);
- if (count($this->requiredcapabilities) > 0) {
- foreach ($this->requiredcapabilities as $cap) {
- if (!has_capability($cap['capability'], $context, $cap['user'])) {
- continue 2;
+ $blocksz = 5000;
+ $offs = 0;
+ // Get total number, to avoid some incorrect iterations
+ $countsql = preg_replace('/ORDER BY.*/', '', $sql);
+ $totalcourses = $DB->count_records_sql("SELECT COUNT(*) FROM ($countsql) sel", $params);
+ // User to be checked is always the same (usually null, get it form first element)
+ $firstcap = reset($this->requiredcapabilities);
+ $userid = isset($firstcap['user']) ? $firstcap['user'] : null;
+ // Extract caps to check, this saves us a bunch of iterations
+ $requiredcaps = array();
+ foreach ($this->requiredcapabilities as $cap) {
+ $requiredcaps[] = $cap['capability'];
+ }
+ // Iterate while we have records and haven't reached MAXRESULTS
+ while ($totalcourses > $offs and $this->totalcount < self::$MAXRESULTS) {
+ $resultset = $DB->get_records_sql($sql, $params, $offs, $blocksz);
+ foreach ($resultset as $result) {
+ context_instance_preload($result);
+ $context = get_context_instance($contextlevel, $result->id);
+ if (count($requiredcaps) > 0) {
+ if (!has_all_capabilities($requiredcaps, $context, $userid)) {
+ continue;
}
}
+ $this->results[$result->id] = $result;
+ $this->totalcount++;
+ if ($this->totalcount >= self::$MAXRESULTS) {
+ break;
+ }
}
- $this->results[$result->id] = $result;
- $this->totalcount++;
- if ($this->totalcount >= self::$MAXRESULTS) {
- break;
- }
+ $offs += $blocksz;
}
return $this->totalcount;
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/community/db" VERSION="20100428" COMMENT="XMLDB file for Moodle blocks/community"
+<XMLDB PATH="blocks/community/db" VERSION="20120122" COMMENT="XMLDB file for Moodle blocks/community"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_community" COMMENT="Community block">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
- <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="coursename"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="coursename"/>
<FIELD NAME="coursename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid" NEXT="coursedescription"/>
<FIELD NAME="coursedescription" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" PREVIOUS="coursename" NEXT="courseurl"/>
<FIELD NAME="courseurl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="coursedescription" NEXT="imageurl"/>
* @param int $long The length to trim text to
* @param int $short The length to trim shorttext to
* @param bool $recurse Recurse all children
- * @param textlib|null $textlib
*/
- public function trim(navigation_node $node, $mode=1, $long=50, $short=25, $recurse=true, $textlib=null) {
- if ($textlib == null) {
- $textlib = textlib_get_instance();
- }
+ public function trim(navigation_node $node, $mode=1, $long=50, $short=25, $recurse=true) {
switch ($mode) {
case self::TRIM_RIGHT :
- if ($textlib->strlen($node->text)>($long+3)) {
+ if (textlib::strlen($node->text)>($long+3)) {
// Truncate the text to $long characters
- $node->text = $this->trim_right($textlib, $node->text, $long);
+ $node->text = $this->trim_right($node->text, $long);
}
- if (is_string($node->shorttext) && $textlib->strlen($node->shorttext)>($short+3)) {
+ if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
// Truncate the shorttext
- $node->shorttext = $this->trim_right($textlib, $node->shorttext, $short);
+ $node->shorttext = $this->trim_right($node->shorttext, $short);
}
break;
case self::TRIM_LEFT :
- if ($textlib->strlen($node->text)>($long+3)) {
+ if (textlib::strlen($node->text)>($long+3)) {
// Truncate the text to $long characters
- $node->text = $this->trim_left($textlib, $node->text, $long);
+ $node->text = $this->trim_left($node->text, $long);
}
- if (is_string($node->shorttext) && $textlib->strlen($node->shorttext)>($short+3)) {
+ if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
// Truncate the shorttext
- $node->shorttext = $this->trim_left($textlib, $node->shorttext, $short);
+ $node->shorttext = $this->trim_left($node->shorttext, $short);
}
break;
case self::TRIM_CENTER :
- if ($textlib->strlen($node->text)>($long+3)) {
+ if (textlib::strlen($node->text)>($long+3)) {
// Truncate the text to $long characters
- $node->text = $this->trim_center($textlib, $node->text, $long);
+ $node->text = $this->trim_center($node->text, $long);
}
- if (is_string($node->shorttext) && $textlib->strlen($node->shorttext)>($short+3)) {
+ if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
// Truncate the shorttext
- $node->shorttext = $this->trim_center($textlib, $node->shorttext, $short);
+ $node->shorttext = $this->trim_center($node->shorttext, $short);
}
break;
}
if ($recurse && $node->children->count()) {
foreach ($node->children as &$child) {
- $this->trim($child, $mode, $long, $short, true, $textlib);
+ $this->trim($child, $mode, $long, $short, true);
}
}
}
/**
* Truncate a string from the left
- * @param textlib $textlib
* @param string $string The string to truncate
* @param int $length The length to truncate to
* @return string The truncated string
*/
- protected function trim_left($textlib, $string, $length) {
- return '...'.$textlib->substr($string, $textlib->strlen($string)-$length, $length);
+ protected function trim_left($string, $length) {
+ return '...'.textlib::substr($string, textlib::strlen($string)-$length, $length);
}
/**
* Truncate a string from the right
- * @param textlib $textlib
* @param string $string The string to truncate
* @param int $length The length to truncate to
* @return string The truncated string
*/
- protected function trim_right($textlib, $string, $length) {
- return $textlib->substr($string, 0, $length).'...';
+ protected function trim_right($string, $length) {
+ return textlib::substr($string, 0, $length).'...';
}
/**
* Truncate a string in the center
- * @param textlib $textlib
* @param string $string The string to truncate
* @param int $length The length to truncate to
* @return string The truncated string
*/
- protected function trim_center($textlib, $string, $length) {
+ protected function trim_center($string, $length) {
$trimlength = ceil($length/2);
- $start = $textlib->substr($string, 0, $trimlength);
- $end = $textlib->substr($string, $textlib->strlen($string)-$trimlength);
+ $start = textlib::substr($string, 0, $trimlength);
+ $end = textlib::substr($string, textlib::strlen($string)-$trimlength);
$string = $start.'...'.$end;
return $string;
}
*/
function format_title($title,$max=64) {
- // Loading the textlib singleton instance. We are going to need it.
- $textlib = textlib_get_instance();
-
- if ($textlib->strlen($title) <= $max) {
+ if (textlib::strlen($title) <= $max) {
return s($title);
} else {
- return s($textlib->substr($title,0,$max-3).'...');
+ return s(textlib::substr($title,0,$max-3).'...');
}
}
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/rss_client/db" VERSION="20060912" COMMENT="XMLDB file for Moodle rss_client block"
+<XMLDB PATH="blocks/rss_client/db" VERSION="20120122" COMMENT="XMLDB file for Moodle rss_client block"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_rss_client" COMMENT="Remote news feed information. Contains the news feed id, the userid of the user who added the feed, the title of the feed itself and a description of the feed contents along with the url used to access the remote feed. Preferredtitle is a field for future use - intended to allow for custom titles rather than those found in the feed">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="userid"/>
- <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="title"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="title"/>
<FIELD NAME="title" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="userid" NEXT="preferredtitle"/>
<FIELD NAME="preferredtitle" TYPE="char" LENGTH="64" NOTNULL="true" SEQUENCE="false" PREVIOUS="title" NEXT="description"/>
<FIELD NAME="description" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="preferredtitle" NEXT="shared"/>
- <FIELD NAME="shared" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="url"/>
+ <FIELD NAME="shared" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="description" NEXT="url"/>
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="shared"/>
</FIELDS>
<KEYS>
$rssfile = new moodle_simplepie_file($externalblog->url);
$filetest = new SimplePie_Locator($rssfile);
- $textlib = textlib_get_instance(); // Going to use textlib services
-
if (!$filetest->is_feed($rssfile)) {
$externalblog->failedlastsync = 1;
$DB->update_record('blog_external', $externalblog);
$newentry->subject = clean_param($entry->get_title(), PARAM_TEXT);
// Observe 128 max chars in DB
// TODO: +1 to raise this to 255
- if ($textlib->strlen($newentry->subject) > 128) {
- $newentry->subject = $textlib->substr($newentry->subject, 0, 125) . '...';
+ if (textlib::strlen($newentry->subject) > 128) {
+ $newentry->subject = textlib::substr($newentry->subject, 0, 125) . '...';
}
$newentry->summary = $entry->get_description();
$oldesttimestamp = $timestamp;
}
- $textlib = textlib_get_instance();
- if ($textlib->strlen($newentry->uniquehash) > 255) {
+ if (textlib::strlen($newentry->uniquehash) > 255) {
// The URL for this item is too long for the field. Rather than add
// the entry without the link we will skip straight over it.
// RSS spec says recommended length 500, we use 255.
*/
function cohort_update_cohort($cohort) {
global $DB;
- if (isset($cohort->component) and empty($cohort->component)) {
- $cohort->component = NULL;
+ if (property_exists($cohort, 'component') and empty($cohort->component)) {
+ // prevent NULLs
+ $cohort->component = '';
}
$cohort->timemodified = time();
$DB->update_record('cohort', $cohort);
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
$course->marker = $marker;
- $DB->set_field("course", "marker", $marker, array("id"=>$course->id));
+ course_set_marker($course->id, $marker);
}
$streditsummary = get_string('editsummary');
// If $log->url has been trimmed short by the db size restriction
// code in add_to_log, keep a note so we don't add a link to a broken url
- $tl=textlib_get_instance();
- $brokenurl=($tl->strlen($log->url)==100 && $tl->substr($log->url,97)=='...');
+ $brokenurl=(textlib::strlen($log->url)==100 && textlib::substr($log->url,97)=='...');
$row = array();
if ($course->id == SITEID) {
return $display;
}
+/**
+ * Set highlighted section. Only one section can be highlighted at the time.
+ *
+ * @param int $courseid course id
+ * @param int $marker highlight section with this number, 0 means remove higlightin
+ * @return void
+ */
+function course_set_marker($courseid, $marker) {
+ global $DB;
+ $DB->set_field("course", "marker", $marker, array('id' => $courseid));
+}
+
/**
* For a given course section, marks it visible or hidden,
* and does the same for every activity in that section
$initialised = true;
}
- $tl = textlib_get_instance();
-
$modinfo = get_fast_modinfo($course);
$completioninfo = new completion_info($course);
// Avoid unnecessary duplication: if e.g. a forum name already
// includes the word forum (or Forum, etc) then it is unhelpful
// to include that in the accessible description that is added.
- if (false !== strpos($tl->strtolower($instancename),
- $tl->strtolower($altname))) {
+ if (false !== strpos(textlib::strtolower($instancename),
+ textlib::strtolower($altname))) {
$altname = '';
}
// File type after name, for alphabetic lists (screen reader).
/**
* Moves a section up or down by 1. CANNOT BE USED DIRECTLY BY AJAX!
*
- * @param object $course
- * @param int $section
+ * @param object $course course object
+ * @param int $section Section number (not id!!!)
* @param int $move (-1 or 1)
+ * @return boolean true if section moved successfully
*/
function move_section($course, $section, $move) {
/// Moves a whole course section up and down within the course
$DB->set_field("course_sections", "section", $sectiondest, array("id"=>$sectionrecord->id));
$DB->set_field("course_sections", "section", $section, array("id"=>$sectiondestrecord->id));
+ // Update highlighting if the move affects highlighted section
+ if ($course->marker == $section) {
+ course_set_marker($course->id, $sectiondest);
+ } elseif ($course->marker == $sectiondest) {
+ course_set_marker($course->id, $section);
+ }
+
// if the focus is on the section that is being moved, then move the focus along
if (course_get_display($course->id) == $section) {
course_set_display($course->id, $sectiondest);
$PAGE->set_title("$course->shortname: $strrecentactivity");
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
-echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo", 3);
+echo $OUTPUT->heading(format_string($course->fullname) . ": $userinfo", 2);
$mform->display();
$modfullname = $modnames[$cm->modname];
$image = "<img src=\"" . $OUTPUT->pix_url('icon', $cm->modname) . "\" class=\"icon\" alt=\"$modfullname\" />";
- echo "<h4>$image $modfullname".
- " <a href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id\" $linkformat>$name</a></h4>";
+ echo "<h3>$image $modfullname".
+ " <a href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id\" $linkformat>$name</a></h3>";
}
} else {
} else {
- echo '<h4><center>' . get_string('norecentactivity') . '</center></h2>';
+ echo '<h3><center>' . get_string('norecentactivity') . '</center></h3>';
}
require_login($course);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:update', $coursecontext);
- $newcourse = new stdClass();
- $newcourse->id = $course->id;
- $newcourse->marker = $value;
- $DB->update_record('course', $newcourse);
+ course_set_marker($course->id, $value);
break;
}
break;
if (!empty($section)) {
if (!empty($move) and confirm_sesskey()) {
- if (!move_section($course, $section, $move)) {
+ if (move_section($course, $section, $move)) {
+ if ($course->id == SITEID) {
+ redirect($CFG->wwwroot . '/?redirect=0');
+ } else {
+ redirect($PAGE->url);
+ }
+ } else {
echo $OUTPUT->notification('An error occurred while moving a section');
}
- // Clear the navigation cache at this point so that the affects
- // are seen immediately on the navigation.
- $PAGE->navigation->clear_cache();
}
}
}
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="enrol/authorize/db" VERSION="20100812" COMMENT="XMLDB file for Moodle enrol/authorize"
+<XMLDB PATH="enrol/authorize/db" VERSION="20120122" COMMENT="XMLDB file for Moodle enrol/authorize"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="enrol_authorize" COMMENT="Holds all known information about authorize.net transactions" NEXT="enrol_authorize_refunds">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="paymentmethod"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="paymentmethod"/>
<FIELD NAME="paymentmethod" TYPE="char" LENGTH="6" NOTNULL="true" DEFAULT="cc" SEQUENCE="false" PREVIOUS="id" NEXT="refundinfo"/>
- <FIELD NAME="refundinfo" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="paymentmethod" NEXT="ccname"/>
+ <FIELD NAME="refundinfo" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="paymentmethod" NEXT="ccname"/>
<FIELD NAME="ccname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="refundinfo" NEXT="courseid"/>
- <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="ccname" NEXT="instanceid"/>
- <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="userid"/>
- <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="instanceid" NEXT="transid"/>
- <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="status"/>
- <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="transid" NEXT="timecreated"/>
- <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="status" NEXT="settletime"/>
- <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="amount"/>
+ <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="ccname" NEXT="instanceid"/>
+ <FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="instanceid" NEXT="transid"/>
+ <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="userid" NEXT="status"/>
+ <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="transid" NEXT="timecreated"/>
+ <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="status" NEXT="settletime"/>
+ <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="amount"/>
<FIELD NAME="amount" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="settletime" NEXT="currency"/>
<FIELD NAME="currency" TYPE="char" LENGTH="3" NOTNULL="true" DEFAULT="USD" SEQUENCE="false" PREVIOUS="amount"/>
</FIELDS>
</TABLE>
<TABLE NAME="enrol_authorize_refunds" COMMENT="Authorize.net refunds" PREVIOUS="enrol_authorize">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="orderid"/>
- <FIELD NAME="orderid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="status"/>
- <FIELD NAME="status" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="orderid" NEXT="amount"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="orderid"/>
+ <FIELD NAME="orderid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="status"/>
+ <FIELD NAME="status" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="orderid" NEXT="amount"/>
<FIELD NAME="amount" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" PREVIOUS="status" NEXT="transid"/>
- <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="amount" NEXT="settletime"/>
- <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="transid"/>
+ <FIELD NAME="transid" TYPE="int" LENGTH="20" NOTNULL="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="amount" NEXT="settletime"/>
+ <FIELD NAME="settletime" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="transid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="orderid"/>
defined('MOODLE_INTERNAL') || die();
+$capabilities = array(
+ /* This is used only when sync suspends users instead of full unenrolment */
+ 'enrol/database:unenrol' => array(
+
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'archetypes' => array(
+ 'manager' => CAP_ALLOW,
+ )
+ ),
+);
+
+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['database:unenrol'] = 'Unenrol suspended users';
$string['dbencoding'] = 'Database encoding';
$string['dbhost'] = 'Database host';
$string['dbhost_desc'] = 'Type database server IP address or host name';
return false;
}
+ /**
+ * Does this plugin allow manual unenrolment of a specific user?
+ * Yes, but only if user suspended...
+ *
+ * @param stdClass $instance course enrol instance
+ * @param stdClass $ue record from user_enrolments table
+ *
+ * @return bool - true means user with 'enrol/xxx:unenrol' may unenrol this user, false means nobody may touch this user enrolment
+ */
+ public function allow_unenrol_user(stdClass $instance, stdClass $ue) {
+ if ($ue->status == ENROL_USER_SUSPENDED) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Gets an array of the user enrolment actions
+ *
+ * @param course_enrolment_manager $manager
+ * @param stdClass $ue A user enrolment object
+ * @return array An array of user_enrolment_actions
+ */
+ public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) {
+ $actions = array();
+ $context = $manager->get_context();
+ $instance = $ue->enrolmentinstance;
+ $params = $manager->get_moodlepage()->url->params();
+ $params['ue'] = $ue->id;
+ if ($this->allow_unenrol_user($instance, $ue) && has_capability('enrol/meta:unenrol', $context)) {
+ $url = new moodle_url('/enrol/unenroluser.php', $params);
+ $actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id));
+ }
+ return $actions;
+ }
+
/**
* Forces synchronisation of user enrolments with external database,
* does not create new courses.
}
return $text;
} else {
- return textlib_get_instance()->convert($text, 'utf-8', $dbenc);
+ return textlib::convert($text, 'utf-8', $dbenc);
}
}
}
return $text;
} else {
- return textlib_get_instance()->convert($text, $dbenc, 'utf-8');
+ return textlib::convert($text, $dbenc, 'utf-8');
}
}
}
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2011112900; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2011112900; // Requires this Moodle version
+$plugin->version = 2012022700; // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires = 2012022300; // Requires this Moodle version
$plugin->component = 'enrol_database'; // Full name of the plugin (used for&n