MDL-20636 Merge vle/master into ouqe2
Conflicts: mod/quiz/locallib.php mod/quiz/report/overview/overview_table.php mod/quiz/report/overview/report.php mod/quiz/report/responses/report.php question/type/random/questiontype.php
This commit is contained in:
@@ -92,7 +92,7 @@ mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
// Run automated backups if required.
|
||||
require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php');
|
||||
require_once($CFG->dirroot.'/backup/util/helper/backup_cron_helper.class.php');
|
||||
backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATLY);
|
||||
backup_cron_automated_helper::run_automated_backup(backup_cron_automated_helper::RUN_IMMEDIATELY);
|
||||
|
||||
mtrace("Automated cron backups completed correctly");
|
||||
|
||||
|
||||
@@ -84,6 +84,33 @@ class registration_manager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the site secret for a given hub
|
||||
* site identifier is assigned to Mooch
|
||||
* each hub has a unique and personal site secret.
|
||||
* @param string $huburl
|
||||
* @return string site secret
|
||||
*/
|
||||
public function get_site_secret_for_hub($huburl) {
|
||||
global $DB;
|
||||
|
||||
$existingregistration = $DB->get_record('registration_hubs',
|
||||
array('huburl' => $huburl));
|
||||
|
||||
if (!empty($existingregistration)) {
|
||||
return $existingregistration->secret;
|
||||
}
|
||||
|
||||
if ($huburl == HUB_MOODLEORGHUBURL) {
|
||||
$siteidentifier = get_site_identifier();
|
||||
} else {
|
||||
$siteidentifier = random_string(32) . $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
|
||||
return $siteidentifier;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* When the site register on a hub, he must call this function
|
||||
* @param object $hub where the site is registered on
|
||||
|
||||
@@ -49,21 +49,6 @@ if (!confirm_sesskey()) {
|
||||
throw new moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
/* TO DO
|
||||
if DB config plugin table is not good for dealing with token reference and token confirmation
|
||||
=> create other DB table
|
||||
-----------------------------------------------------------------------------
|
||||
Local Type | Token | Local WS | Remote Type | Remote URL | Confirmed
|
||||
-----------------------------------------------------------------------------
|
||||
HUB 4er4e server HUB-DIRECTORY http...moodle.org Yes
|
||||
HUB 73j53 client HUB-DIRECTORY http...moodle.org Yes
|
||||
SITE dfsd7 server HUB http...hub Yes
|
||||
SITE fd8fd client HUB http...hub Yes
|
||||
HUB ds78s server SITE http...site.com Yes
|
||||
HUB-DIR. d7d8s server HUB http...hub Yes
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$registrationmanager = new registration_manager();
|
||||
|
||||
$registeredhub = $registrationmanager->get_registeredhub($huburl);
|
||||
@@ -132,7 +117,8 @@ if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
if (empty($unconfirmedhub)) {
|
||||
//we save the token into the communication table in order to have a reference
|
||||
$unconfirmedhub = new stdClass();
|
||||
$unconfirmedhub->token = get_site_identifier();
|
||||
$unconfirmedhub->token = $registrationmanager->get_site_secret_for_hub($huburl);
|
||||
$unconfirmedhub->secret = $unconfirmedhub->token;
|
||||
$unconfirmedhub->huburl = $huburl;
|
||||
$unconfirmedhub->hubname = $hubname;
|
||||
$unconfirmedhub->confirmed = 0;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* @package moodle
|
||||
* @subpackage registration
|
||||
* @author Jerome Mouneyrac <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* The administrator is redirect to this page from the hub to renew a registration
|
||||
* process because
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php');
|
||||
|
||||
$url = optional_param('url', '', PARAM_URL);
|
||||
$hubname = optional_param('hubname', '', PARAM_TEXT);
|
||||
$token = optional_param('token', '', PARAM_TEXT);
|
||||
|
||||
admin_externalpage_setup('registrationindex');
|
||||
|
||||
//check that we are waiting a confirmation from this hub, and check that the token is correct
|
||||
$registrationmanager = new registration_manager();
|
||||
$registeredhub = $registrationmanager->get_unconfirmedhub($url);
|
||||
if (!empty($registeredhub) and $registeredhub->token == $token) {
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
|
||||
$hublink = html_writer::tag('a', $hubname, array('href' => $url));
|
||||
|
||||
$registrationmanager->delete_registeredhub($url);
|
||||
|
||||
//Mooch case, need to recreate the siteidentifier
|
||||
if ($url == HUB_MOODLEORGHUBURL) {
|
||||
$CFG->siteidentifier = null;
|
||||
get_site_identifier();
|
||||
}
|
||||
|
||||
$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
|
||||
|
||||
$button = new single_button(new moodle_url('/admin/registration/index.php'),
|
||||
get_string('restartregistration', 'hub'));
|
||||
$button->class = 'restartregbutton';
|
||||
|
||||
echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button),
|
||||
array('class' => 'mdl-align'));
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
} else {
|
||||
throw new moodle_exception('wrongtoken', 'hub',
|
||||
$CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php');
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
admin_externalpage_setup('reportcourseoverview');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3);
|
||||
@@ -19,6 +16,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
admin_externalpage_setup('reportcourseoverview');
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$course = get_site();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$options[99] = get_string('timezonenotforced', 'admin');
|
||||
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
|
||||
$temp->add(new admin_settings_country_select('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('defaultcity', get_string('defaultcity', 'admin'), get_string('defaultcity_help', 'admin'), ''));
|
||||
|
||||
$temp->add(new admin_setting_heading('iplookup', get_string('iplookup', 'admin'), get_string('iplookupinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configfile('geoipfile', get_string('geoipfile', 'admin'), get_string('configgeoipfile', 'admin', $CFG->dataroot.'/geoip/'), $CFG->dataroot.'/geoip/GeoLiteCity.dat'));
|
||||
|
||||
@@ -266,5 +266,6 @@ $ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('adminregistration', get_string('registration','admin'), "$CFG->wwwroot/$CFG->admin/registration/index.php"));
|
||||
$ADMIN->add('root', new admin_externalpage('bloglevelupgrade', get_string('bloglevelupgrade', 'admin'), $CFG->wwwroot.'/'.$CFG->admin.'/blocklevelupgrade.php', 'moodle/site:config', true));
|
||||
|
||||
} // end of speedup
|
||||
|
||||
@@ -295,7 +295,13 @@ if ($formdata = $mform->is_cancelled()) {
|
||||
}
|
||||
if (isset($formdata->$field)) {
|
||||
// process templates
|
||||
$user->$field = process_template($formdata->$field, $user);
|
||||
if (is_array($formdata->$field)) {
|
||||
foreach ($formdata->$field as $k=>$v) {
|
||||
$user->$field[$k] = process_template($v, $user);
|
||||
}
|
||||
} else {
|
||||
$user->$field = process_template($formdata->$field, $user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,10 +206,18 @@ class admin_uploaduser_form2 extends moodleform {
|
||||
|
||||
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
|
||||
$mform->setType('city', PARAM_MULTILANG);
|
||||
$mform->setDefault('city', $templateuser->city);
|
||||
if (empty($CFG->defaultcity)) {
|
||||
$mform->setDefault('city', $templateuser->city);
|
||||
} else {
|
||||
$mform->setDefault('city', $CFG->defaultcity);
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
|
||||
$mform->setDefault('country', $templateuser->country);
|
||||
if (empty($CFG->country)) {
|
||||
$mform->setDefault('country', $templateuser->country);
|
||||
} else {
|
||||
$mform->setDefault('country', $CFG->country);
|
||||
}
|
||||
$mform->setAdvanced('country');
|
||||
|
||||
$choices = get_list_of_timezones();
|
||||
|
||||
@@ -30,7 +30,7 @@ if ($confirm and !empty($msg) and confirm_sesskey()) {
|
||||
//TODO we should probably support all text formats here or only FORMAT_MOODLE
|
||||
//For now bulk messaging is still using the html editor and its supplying html
|
||||
//so we have to use html format for it to be displayed correctly
|
||||
message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct');
|
||||
message_post_message($USER, $user, $msg, FORMAT_HTML);
|
||||
}
|
||||
$rs->close();
|
||||
redirect($return);
|
||||
|
||||
@@ -242,7 +242,7 @@ class auth_plugin_shibboleth extends auth_plugin_base {
|
||||
|
||||
// set to defaults if undefined
|
||||
if (!isset($config->auth_instructions) or empty($config->user_attribute)) {
|
||||
$config->auth_instructions = get_string('shibboleth_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/index.php');
|
||||
$config->auth_instructions = get_string('auth_shib_instructions', 'auth_shibboleth', $CFG->wwwroot.'/auth/shibboleth/index.php');
|
||||
}
|
||||
if (!isset ($config->user_attribute)) {
|
||||
$config->user_attribute = '';
|
||||
@@ -292,7 +292,7 @@ class auth_plugin_shibboleth extends auth_plugin_base {
|
||||
} else {
|
||||
// Check if integrated WAYF was enabled and is now turned off
|
||||
// If it was and only then, reset the Moodle alternate URL
|
||||
if ($this->config->alt_login == 'on'){
|
||||
if (isset($this->config->alt_login) and $this->config->alt_login == 'on'){
|
||||
set_config('alt_login', 'off', 'auth/shibboleth');
|
||||
set_config('alternateloginurl', '');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package moodlecore
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class extending standard backup_plugin in order to implement some
|
||||
* helper methods related with the course formats (format plugin)
|
||||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
abstract class backup_format_plugin extends backup_plugin {
|
||||
|
||||
protected $courseformat; // To store the format (course->format) of the instance
|
||||
|
||||
public function __construct($plugintype, $pluginname, $optigroup, $step) {
|
||||
|
||||
parent::__construct($plugintype, $pluginname, $optigroup, $step);
|
||||
|
||||
$this->courseformat = backup_plan_dbops::get_courseformat_from_courseid($this->task->get_courseid());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the condition encapsulated into sqlparam format
|
||||
* to get evaluated by value, not by path nor processor setting
|
||||
*/
|
||||
protected function get_format_condition() {
|
||||
return array('sqlparam' => $this->courseformat);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ require_once($CFG->dirroot . '/backup/moodle2/backup_default_block_task.class.ph
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_xml_transformer.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_settingslib.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_stepslib.php');
|
||||
|
||||
@@ -33,12 +33,16 @@ abstract class backup_plugin {
|
||||
protected $pluginname;
|
||||
protected $connectionpoint;
|
||||
protected $optigroup; // Optigroup, parent of all optigroup elements
|
||||
protected $step;
|
||||
protected $task;
|
||||
|
||||
public function __construct($plugintype, $pluginname, $optigroup) {
|
||||
public function __construct($plugintype, $pluginname, $optigroup, $step) {
|
||||
$this->plugintype = $plugintype;
|
||||
$this->pluginname = $pluginname;
|
||||
$this->optigroup = $optigroup;
|
||||
$this->optigroup = $optigroup;
|
||||
$this->connectionpoint = '';
|
||||
$this->step = $step;
|
||||
$this->task = $step->get_task();
|
||||
}
|
||||
|
||||
public function define_plugin_structure($connectionpoint) {
|
||||
@@ -52,6 +56,22 @@ abstract class backup_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
// backup_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Returns the value of one (task/plan) setting
|
||||
*/
|
||||
protected function get_setting_value($name) {
|
||||
if (is_null($this->task)) {
|
||||
throw new backup_step_exception('not_specified_backup_task');
|
||||
}
|
||||
return $this->task->get_setting_value($name);
|
||||
}
|
||||
|
||||
// end of backup_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Factory method that will return one backup_plugin_element (backup_optigroup_element)
|
||||
* with its name automatically calculated, based one the plugin being handled (type, name)
|
||||
|
||||
@@ -125,13 +125,21 @@ abstract class backup_activity_structure_step extends backup_structure_step {
|
||||
$backupfile = $subpluginsdir . '/backup/moodle2/' . $classname . '.class.php';
|
||||
if (file_exists($backupfile)) {
|
||||
require_once($backupfile);
|
||||
$backupsubplugin = new $classname($subplugintype, $name, $optigroup);
|
||||
$backupsubplugin = new $classname($subplugintype, $name, $optigroup, $this);
|
||||
// Add subplugin returned structure to optigroup
|
||||
$backupsubplugin->define_subplugin_structure($element->get_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* As far as activity backup steps are implementing backup_subplugin stuff, they need to
|
||||
* have the parent task available for wrapping purposes (get course/context....)
|
||||
*/
|
||||
public function get_task() {
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps any activity backup structure within the common 'activity' element
|
||||
* that will include common to all activities information like id, context...
|
||||
@@ -310,6 +318,9 @@ class backup_module_structure_step extends backup_structure_step {
|
||||
$availability = new backup_nested_element('availability', array('id'), array(
|
||||
'sourcecmid', 'requiredcompletion', 'gradeitemid', 'grademin', 'grademax'));
|
||||
|
||||
// attach format plugin structure to $module element, only one allowed
|
||||
$this->add_plugin_structure('format', $module, false);
|
||||
|
||||
// Define the tree
|
||||
$module->add_child($availinfo);
|
||||
$availinfo->add_child($availability);
|
||||
@@ -346,6 +357,9 @@ class backup_section_structure_step extends backup_structure_step {
|
||||
$section = new backup_nested_element('section', array('id'), array(
|
||||
'number', 'name', 'summary', 'summaryformat', 'sequence', 'visible'));
|
||||
|
||||
// attach format plugin structure to $section element, only one allowed
|
||||
$this->add_plugin_structure('format', $section, false);
|
||||
|
||||
// Define sources
|
||||
|
||||
$section->set_source_table('course_sections', array('id' => backup::VAR_SECTIONID));
|
||||
@@ -395,6 +409,9 @@ class backup_course_structure_step extends backup_structure_step {
|
||||
|
||||
$module = new backup_nested_element('module', array(), array('modulename'));
|
||||
|
||||
// attach format plugin structure to $course element, only one allowed
|
||||
$this->add_plugin_structure('format', $course, false);
|
||||
|
||||
// Build the tree
|
||||
|
||||
$course->add_child($category);
|
||||
|
||||
@@ -34,12 +34,16 @@ abstract class backup_subplugin {
|
||||
protected $subpluginname;
|
||||
protected $connectionpoint;
|
||||
protected $optigroup; // Optigroup, parent of all optigroup elements
|
||||
protected $step;
|
||||
protected $task;
|
||||
|
||||
public function __construct($subplugintype, $subpluginname, $optigroup) {
|
||||
public function __construct($subplugintype, $subpluginname, $optigroup, $step) {
|
||||
$this->subplugintype = $subplugintype;
|
||||
$this->subpluginname = $subpluginname;
|
||||
$this->optigroup = $optigroup;
|
||||
$this->connectionpoint = '';
|
||||
$this->step = $step;
|
||||
$this->task = $step->get_task();
|
||||
}
|
||||
|
||||
public function define_subplugin_structure($connectionpoint) {
|
||||
@@ -53,6 +57,22 @@ abstract class backup_subplugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
// backup_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Returns the value of one (task/plan) setting
|
||||
*/
|
||||
protected function get_setting_value($name) {
|
||||
if (is_null($this->task)) {
|
||||
throw new backup_step_exception('not_specified_backup_task');
|
||||
}
|
||||
return $this->task->get_setting_value($name);
|
||||
}
|
||||
|
||||
// end of backup_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Factory method that will return one backup_subplugin_element (backup_optigroup_element)
|
||||
* with its name automatically calculated, based one the subplugin being handled (type, name)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @package moodlecore
|
||||
* @subpackage backup-moodle2
|
||||
* @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class extending standard restore_plugin in order to implement some
|
||||
* helper methods related with the course formats (format plugin)
|
||||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
abstract class restore_format_plugin extends restore_plugin {
|
||||
// Love these classes. :-) Nothing special to customize here for now
|
||||
}
|
||||
@@ -33,8 +33,10 @@ require_once($CFG->dirroot . '/backup/moodle2/restore_block_task.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_default_block_task.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_settingslib.php');
|
||||
require_once($CFG->dirroot . '/backup/moodle2/restore_stepslib.php');
|
||||
|
||||
@@ -202,6 +202,18 @@ abstract class restore_plugin {
|
||||
return $this->step->apply_date_offset($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of one (task/plan) setting
|
||||
*/
|
||||
protected function get_setting_value($name) {
|
||||
if (is_null($this->task)) {
|
||||
throw new restore_step_exception('not_specified_restore_task');
|
||||
}
|
||||
return $this->task->get_setting_value($name);
|
||||
}
|
||||
|
||||
// end of restore_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Simple helper function that returns the name for the restore_path_element
|
||||
* It's not mandatory to use it but recommended ;-)
|
||||
|
||||
@@ -139,7 +139,7 @@ abstract class restore_qtype_plugin extends restore_plugin {
|
||||
$info->filequestionid = $oldquestionid;
|
||||
$info->dbquestionid = $newquestionid;
|
||||
$info->answer = $data->answertext;
|
||||
throw restore_step_exception('error_question_answers_missing_in_db', $info);
|
||||
throw new restore_step_exception('error_question_answers_missing_in_db', $info);
|
||||
}
|
||||
}
|
||||
// Create mapping (we'll use this intensively when restoring question_states. And also answerfeedback files)
|
||||
|
||||
@@ -32,12 +32,14 @@ class restore_section_task extends restore_task {
|
||||
|
||||
protected $info; // info related to section gathered from backup file
|
||||
protected $contextid; // course context id
|
||||
protected $sectionid; // new (target) id of the course section
|
||||
|
||||
/**
|
||||
* Constructor - instantiates one object of this class
|
||||
*/
|
||||
public function __construct($name, $info, $plan = null) {
|
||||
$this->info = $info;
|
||||
$this->sectionid = 0;
|
||||
parent::__construct($name, $plan);
|
||||
}
|
||||
|
||||
@@ -49,10 +51,18 @@ class restore_section_task extends restore_task {
|
||||
return $this->get_basepath() . '/sections/section_' . $this->info->sectionid;
|
||||
}
|
||||
|
||||
public function set_sectionid($sectionid) {
|
||||
$this->sectionid = $sectionid;
|
||||
}
|
||||
|
||||
public function get_contextid() {
|
||||
return $this->contextid;
|
||||
}
|
||||
|
||||
public function get_sectionid() {
|
||||
return $this->sectionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create all the steps that will be part of this task
|
||||
*/
|
||||
|
||||
@@ -660,8 +660,8 @@ class restore_groups_structure_step extends restore_structure_step {
|
||||
$params = array('courseid' => $this->get_courseid(), 'grname' => $data->name);
|
||||
if (!empty($data->description)) {
|
||||
$description_clause = ' AND ' .
|
||||
$DB->sql_compare_text('description') . ' = ' . $DB->sql_compare_text(':desc');
|
||||
$params['desc'] = $data->description;
|
||||
$DB->sql_compare_text('description') . ' = ' . $DB->sql_compare_text(':description');
|
||||
$params['description'] = $data->description;
|
||||
}
|
||||
if (!$groupdb = $DB->get_record_sql("SELECT *
|
||||
FROM {groups}
|
||||
@@ -708,8 +708,8 @@ class restore_groups_structure_step extends restore_structure_step {
|
||||
$params = array('courseid' => $this->get_courseid(), 'grname' => $data->name);
|
||||
if (!empty($data->description)) {
|
||||
$description_clause = ' AND ' .
|
||||
$DB->sql_compare_text('description') . ' = ' . $DB->sql_compare_text(':desc');
|
||||
$params['desc'] = $data->description;
|
||||
$DB->sql_compare_text('description') . ' = ' . $DB->sql_compare_text(':description');
|
||||
$params['description'] = $data->description;
|
||||
}
|
||||
if (!$groupingdb = $DB->get_record_sql("SELECT *
|
||||
FROM {groupings}
|
||||
@@ -920,7 +920,12 @@ class restore_process_categories_and_questions extends restore_execution_step {
|
||||
class restore_section_structure_step extends restore_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
return array(new restore_path_element('section', '/section'));
|
||||
$section = new restore_path_element('section', '/section');
|
||||
|
||||
// Apply for 'format' plugins optional paths at section level
|
||||
$this->add_plugin_structure('format', $section);
|
||||
|
||||
return array($section);
|
||||
}
|
||||
|
||||
public function process_section($data) {
|
||||
@@ -962,6 +967,10 @@ class restore_section_structure_step extends restore_structure_step {
|
||||
// Annotate the section mapping, with restorefiles option if needed
|
||||
$this->set_mapping('course_section', $oldid, $newitemid, $restorefiles);
|
||||
|
||||
// set the new course_section id in the task
|
||||
$this->task->set_sectionid($newitemid);
|
||||
|
||||
|
||||
// Commented out. We never modify course->numsections as far as that is used
|
||||
// by a lot of people to "hide" sections on purpose (so this remains as used to be in Moodle 1.x)
|
||||
// Note: We keep the code here, to know about and because of the possibility of making this
|
||||
@@ -991,12 +1000,15 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
$course = new restore_path_element('course', '/course', true); // Grouped
|
||||
$course = new restore_path_element('course', '/course');
|
||||
$category = new restore_path_element('category', '/course/category');
|
||||
$tag = new restore_path_element('tag', '/course/tags/tag');
|
||||
$allowed = new restore_path_element('allowed', '/course/allowed_modules/module');
|
||||
$allowed_module = new restore_path_element('allowed_module', '/course/allowed_modules/module');
|
||||
|
||||
return array($course, $category, $tag, $allowed);
|
||||
// Apply for 'format' plugins optional paths at course level
|
||||
$this->add_plugin_structure('format', $course);
|
||||
|
||||
return array($course, $category, $tag, $allowed_module);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1026,9 +1038,6 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
$data->shortname= $shortname;
|
||||
$data->idnumber = '';
|
||||
|
||||
// Category is set by UI when choosing the destination
|
||||
unset($data->category);
|
||||
|
||||
$data->startdate= $this->apply_date_offset($data->startdate);
|
||||
if ($data->defaultgroupingid) {
|
||||
$data->defaultgroupingid = $this->get_mappingid('grouping', $data->defaultgroupingid);
|
||||
@@ -1050,34 +1059,56 @@ class restore_course_structure_step extends restore_structure_step {
|
||||
// Course record ready, update it
|
||||
$DB->update_record('course', $data);
|
||||
|
||||
// Course tags
|
||||
if (!empty($CFG->usetags) && isset($coursetags)) { // if enabled in server and present in backup
|
||||
// Role name aliases
|
||||
restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
|
||||
}
|
||||
|
||||
public function process_category($data) {
|
||||
// Nothing to do with the category. UI sets it before restore starts
|
||||
}
|
||||
|
||||
public function process_tag($data) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
|
||||
if (!empty($CFG->usetags)) { // if enabled in server
|
||||
// TODO: This is highly inneficient. Each time we add one tag
|
||||
// we fetch all the existing because tag_set() deletes them
|
||||
// so everything must be reinserted on each call
|
||||
$tags = array();
|
||||
foreach ($coursetags as $coursetag) {
|
||||
$coursetag = (object)$coursetag;
|
||||
$tags[] = $coursetag->rawname;
|
||||
$existingtags = tag_get_tags('course', $this->get_courseid());
|
||||
// Re-add all the existitng tags
|
||||
foreach ($existingtags as $existingtag) {
|
||||
$tags[] = $existingtag->rawname;
|
||||
}
|
||||
// Add the one being restored
|
||||
$tags[] = $data->rawname;
|
||||
// Send all the tags back to the course
|
||||
tag_set('course', $this->get_courseid(), $tags);
|
||||
}
|
||||
// Course allowed modules
|
||||
if (!empty($data->restrictmodules) && !empty($coursemodules)) {
|
||||
}
|
||||
|
||||
public function process_allowed_module($data) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
|
||||
// only if enabled by admin setting
|
||||
if (!empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all') {
|
||||
$available = get_plugin_list('mod');
|
||||
foreach ($coursemodules as $coursemodule) {
|
||||
$mname = $coursemodule['modulename'];
|
||||
if (array_key_exists($mname, $available)) {
|
||||
if ($module = $DB->get_record('modules', array('name' => $mname, 'visible' => 1))) {
|
||||
$rec = new stdclass();
|
||||
$rec->course = $this->get_courseid();
|
||||
$rec->module = $module->id;
|
||||
if (!$DB->record_exists('course_allowed_modules', (array)$rec)) {
|
||||
$DB->insert_record('course_allowed_modules', $rec);
|
||||
}
|
||||
$mname = $data->modulename;
|
||||
if (array_key_exists($mname, $available)) {
|
||||
if ($module = $DB->get_record('modules', array('name' => $mname, 'visible' => 1))) {
|
||||
$rec = new stdclass();
|
||||
$rec->course = $this->get_courseid();
|
||||
$rec->module = $module->id;
|
||||
if (!$DB->record_exists('course_allowed_modules', (array)$rec)) {
|
||||
$DB->insert_record('course_allowed_modules', $rec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Role name aliases
|
||||
restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
|
||||
}
|
||||
|
||||
protected function after_execute() {
|
||||
@@ -1786,7 +1817,7 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
|
||||
$gradeitem = new grade_item($data);
|
||||
$gradeitem = new grade_item($data, false);
|
||||
$gradeitem->insert('restore');
|
||||
|
||||
//sortorder is automatically assigned when inserting. Re-instate the previous sortorder
|
||||
@@ -1809,7 +1840,7 @@ class restore_activity_grades_structure_step extends restore_structure_step {
|
||||
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
|
||||
$data->overridden = $this->apply_date_offset($data->overridden);
|
||||
|
||||
$grade = new grade_grade($data);
|
||||
$grade = new grade_grade($data, false);
|
||||
$grade->insert('restore');
|
||||
// no need to save any grade_grade mapping
|
||||
}
|
||||
@@ -1963,11 +1994,15 @@ class restore_module_structure_step extends restore_structure_step {
|
||||
|
||||
$paths = array();
|
||||
|
||||
$paths[] = new restore_path_element('module', '/module');
|
||||
$module = new restore_path_element('module', '/module');
|
||||
$paths[] = $module;
|
||||
if ($CFG->enableavailability) {
|
||||
$paths[] = new restore_path_element('availability', '/module/availability_info/availability');
|
||||
}
|
||||
|
||||
// Apply for 'format' plugins optional paths at module level
|
||||
$this->add_plugin_structure('format', $module);
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
@@ -2219,7 +2254,7 @@ class restore_create_categories_and_questions extends restore_structure_step {
|
||||
|
||||
// Check we have one mapping for this category
|
||||
if (!$mapping = $this->get_mapping('question_category', $oldid)) {
|
||||
return; // No mapping = this category doesn't need to be created/mapped
|
||||
return self::SKIP_ALL_CHILDREN; // No mapping = this category doesn't need to be created/mapped
|
||||
}
|
||||
|
||||
// Check we have to create the category (newitemid = 0)
|
||||
|
||||
@@ -151,6 +151,18 @@ abstract class restore_subplugin {
|
||||
return $this->step->apply_date_offset($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of one (task/plan) setting
|
||||
*/
|
||||
protected function get_setting_value($name) {
|
||||
if (is_null($this->task)) {
|
||||
throw new restore_step_exception('not_specified_restore_task');
|
||||
}
|
||||
return $this->task->get_setting_value($name);
|
||||
}
|
||||
|
||||
// end of restore_step/structure_step/task wrappers
|
||||
|
||||
/**
|
||||
* Simple helper function that returns the name for the restore_path_element
|
||||
* It's not mandatory to use it but recommended ;-)
|
||||
|
||||
@@ -119,6 +119,15 @@ abstract class backup_plan_dbops extends backup_dbops {
|
||||
return $sectionsarr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one course id, return its format in DB
|
||||
*/
|
||||
public static function get_courseformat_from_courseid($courseid) {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_field('course', 'format', array('id' => $courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the wwwroot of the $CFG->mnet_localhost_id host
|
||||
* caching it along the request
|
||||
@@ -138,34 +147,49 @@ abstract class backup_plan_dbops extends backup_dbops {
|
||||
* Returns the default backup filename, based in passed params.
|
||||
*
|
||||
* Default format is (see MDL-22145)
|
||||
* backup word - format - type - name - date - info . mbz
|
||||
* backup word - format - type - name - date - info . mbz
|
||||
* where name is variable (course shortname, section name/id, activity modulename + cmid)
|
||||
* and info can be (nu = no user info, an = anonymized)
|
||||
* and info can be (nu = no user info, an = anonymized). The last param $useidasname,
|
||||
* defaulting to false, allows to replace the course shortname by the course id (used
|
||||
* by automated backups, to avoid non-ascii chars in OS filesystem)
|
||||
*
|
||||
* @param string $format One of backup::FORMAT_
|
||||
* @param string $type One of backup::TYPE_
|
||||
* @param int $courseid/$sectionid/$cmid
|
||||
* @param bool $users Should be true is users were included in the backup
|
||||
* @param bool $anonymised Should be true is user information was anonymized.
|
||||
* @param bool $useidasname true to use id, false to use strings (default)
|
||||
* @return string The filename to use
|
||||
*/
|
||||
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised) {
|
||||
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised, $useidasname = false) {
|
||||
global $DB;
|
||||
|
||||
// Calculate backup word
|
||||
$backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
|
||||
$backupword = trim(clean_filename($backupword), '_');
|
||||
|
||||
// Calculate proper name element (based on type)
|
||||
switch ($type) {
|
||||
case backup::TYPE_1COURSE:
|
||||
$shortname = $DB->get_field('course', 'shortname', array('id' => $id));
|
||||
break;
|
||||
case backup::TYPE_1SECTION:
|
||||
if (!$shortname = $DB->get_field('course_sections', 'name', array('id' => $id))) {
|
||||
$shortname = $DB->get_field('course_sections', 'section', array('id' => $id));
|
||||
}
|
||||
break;
|
||||
case backup::TYPE_1ACTIVITY:
|
||||
$cm = get_coursemodule_from_id(null, $id);
|
||||
$shortname = $cm->modname . $id;
|
||||
break;
|
||||
$shortname = '';
|
||||
// Not $useidasname, lets calculate it, else $id will be used
|
||||
if (!$useidasname) {
|
||||
// Calculate proper name element (based on type)
|
||||
switch ($type) {
|
||||
case backup::TYPE_1COURSE:
|
||||
$shortname = $DB->get_field('course', 'shortname', array('id' => $id));
|
||||
break;
|
||||
case backup::TYPE_1SECTION:
|
||||
if (!$shortname = $DB->get_field('course_sections', 'name', array('id' => $id))) {
|
||||
$shortname = $DB->get_field('course_sections', 'section', array('id' => $id));
|
||||
}
|
||||
break;
|
||||
case backup::TYPE_1ACTIVITY:
|
||||
$cm = get_coursemodule_from_id(null, $id);
|
||||
$shortname = $cm->modname . $id;
|
||||
break;
|
||||
}
|
||||
$shortname = str_replace(' ', '_', $shortname);
|
||||
$shortname = moodle_strtolower(trim(clean_filename($shortname), '_'));
|
||||
}
|
||||
$shortname = str_replace(' ', '_', $shortname);
|
||||
$shortname = moodle_strtolower(trim(clean_filename($shortname), '_'));
|
||||
|
||||
$name = empty($shortname) ? $id : $shortname;
|
||||
|
||||
// Calculate date
|
||||
|
||||
@@ -49,8 +49,8 @@ abstract class backup_cron_automated_helper {
|
||||
|
||||
/** Run if required by the schedule set in config. Default. **/
|
||||
const RUN_ON_SCHEDULE = 0;
|
||||
/** Run immediatly. **/
|
||||
const RUN_IMMEDIATLY = 1;
|
||||
/** Run immediately. **/
|
||||
const RUN_IMMEDIATELY = 1;
|
||||
|
||||
const AUTO_BACKUP_DISABLED = 0;
|
||||
const AUTO_BACKUP_ENABLED = 1;
|
||||
@@ -75,7 +75,7 @@ abstract class backup_cron_automated_helper {
|
||||
return $state;
|
||||
} else if ($state === backup_cron_automated_helper::STATE_RUNNING) {
|
||||
mtrace('RUNNING');
|
||||
if ($rundirective == self::RUN_IMMEDIATLY) {
|
||||
if ($rundirective == self::RUN_IMMEDIATELY) {
|
||||
mtrace('automated backups are already. If this script is being run by cron this constitues an error. You will need to increase the time between executions within cron.');
|
||||
} else {
|
||||
mtrace("automated backup are already running. Execution delayed");
|
||||
@@ -130,12 +130,12 @@ abstract class backup_cron_automated_helper {
|
||||
$DB->update_record('backup_courses', $backupcourse);
|
||||
mtrace('Skipping unchanged course '.$course->fullname);
|
||||
$skipped = true;
|
||||
} else if (($backupcourse->nextstarttime >= 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATLY) {
|
||||
} else if (($backupcourse->nextstarttime >= 0 && $backupcourse->nextstarttime < $now) || $rundirective == self::RUN_IMMEDIATELY) {
|
||||
mtrace('Backing up '.$course->fullname, '...');
|
||||
|
||||
//We have to send a email because we have included at least one backup
|
||||
$emailpending = true;
|
||||
|
||||
|
||||
//Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error)
|
||||
if ($backupcourse->laststatus != 2) {
|
||||
//Set laststarttime
|
||||
@@ -270,7 +270,7 @@ abstract class backup_cron_automated_helper {
|
||||
$config = get_config('backup');
|
||||
$midnight = usergetmidnight($now, $timezone);
|
||||
$date = usergetdate($now, $timezone);
|
||||
|
||||
|
||||
//Get number of days (from today) to execute backups
|
||||
$automateddays = substr($config->backup_auto_weekdays,$date['wday']) . $config->backup_auto_weekdays;
|
||||
$daysfromtoday = strpos($automateddays, "1");
|
||||
@@ -335,7 +335,7 @@ abstract class backup_cron_automated_helper {
|
||||
$users = $bc->get_plan()->get_setting('users')->get_value();
|
||||
$anonymised = $bc->get_plan()->get_setting('anonymize')->get_value();
|
||||
$bc->get_plan()->get_setting('filename')->set_value(backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised));
|
||||
|
||||
|
||||
$bc->set_status(backup::STATUS_AWAITING);
|
||||
|
||||
$outcome = $bc->execute_plan();
|
||||
@@ -347,7 +347,7 @@ abstract class backup_cron_automated_helper {
|
||||
$dir = null;
|
||||
}
|
||||
if (!empty($dir) && $storage !== 0) {
|
||||
$filename = self::get_external_filename($course->id, $format, $type, $users, $anonymised);
|
||||
$filename = backup_plan_dbops::get_default_backup_filename($format, $type, $course->id, $users, $anonymised, true);
|
||||
$outcome = $file->copy_content_to($dir.'/'.$filename);
|
||||
if ($outcome && $storage === 1) {
|
||||
$file->delete();
|
||||
@@ -366,38 +366,6 @@ abstract class backup_cron_automated_helper {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the filename to use for the backup when it is being moved to an
|
||||
* external location.
|
||||
*
|
||||
* Note: we use the course id in the filename rather than the course shortname
|
||||
* because it may contain UTF-8 characters that could cause problems for the
|
||||
* recieving filesystem.
|
||||
*
|
||||
* @param int $courseid
|
||||
* @param string $format One of backup::FORMAT_
|
||||
* @param string $type One of backup::TYPE_
|
||||
* @param bool $users Should be true is users were included in the backup
|
||||
* @param bool $anonymised Should be true is user information was anonymized.
|
||||
* @return string The filename to use
|
||||
*/
|
||||
public static function get_external_filename($courseid, $format, $type, $users, $anonymised) {
|
||||
$backupword = str_replace(' ', '_', moodle_strtolower(get_string('backupfilename')));
|
||||
$backupword = trim(clean_filename($backupword), '_');
|
||||
// Calculate date
|
||||
$backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
|
||||
$date = userdate(time(), $backupdateformat, 99, false);
|
||||
$date = moodle_strtolower(trim(clean_filename($date), '_'));
|
||||
// Calculate info
|
||||
$info = '';
|
||||
if (!$users) {
|
||||
$info = 'nu';
|
||||
} else if ($anonymised) {
|
||||
$info = 'an';
|
||||
}
|
||||
return $backupword.'-'.$format.'-'.$type.'-'.$courseid.'-'.$date.'-'.$info.'.mbz';
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes deleted courses fromn the backup_courses table so that we don't
|
||||
* waste time backing them up.
|
||||
@@ -488,32 +456,39 @@ abstract class backup_cron_automated_helper {
|
||||
$filearea = 'automated';
|
||||
$itemid = 0;
|
||||
$files = array();
|
||||
// Store all the matching files into timemodified => stored_file array
|
||||
foreach ($fs->get_area_files($context->id, $component, $filearea, $itemid) as $file) {
|
||||
if (strpos($file->get_filename(), $backupword) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$files[$file->get_timemodified()] = $file;
|
||||
}
|
||||
arsort($files);
|
||||
if (count($files) <= $keep) {
|
||||
// There are less matching files than the desired number to keep
|
||||
// do there is nothing to clean up.
|
||||
return 0;
|
||||
}
|
||||
// Sort by keys descending (newer to older filemodified)
|
||||
krsort($files);
|
||||
$remove = array_splice($files, $keep);
|
||||
foreach ($remove as $file) {
|
||||
$file->delete();
|
||||
}
|
||||
//mtrace('Removed '.count($remove).' old backup file(s) from the data directory');
|
||||
//mtrace('Removed '.count($remove).' old backup file(s) from the automated filearea');
|
||||
}
|
||||
|
||||
// Clean up excess backups in the specified external directory
|
||||
if (!empty($dir) && ($storage == 1 || $storage == 2)) {
|
||||
// Calculate backup filename regex
|
||||
|
||||
// Calculate backup filename regex, ignoring the date/time/info parts that can be
|
||||
// variable, depending of languages, formats and automated backup settings
|
||||
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
|
||||
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';
|
||||
|
||||
$regex = '#^'.preg_quote($filename, '#').'(\d{8})\-(\d{4})\-[a-z]{2}\.mbz$#S';
|
||||
|
||||
// Store all the matching files into fullpath => timemodified array
|
||||
$files = array();
|
||||
foreach (scandir($dir) as $file) {
|
||||
if (preg_match($regex, $file, $matches)) {
|
||||
$files[$file] = $matches[1].$matches[2];
|
||||
$files[$file] = filemtime($dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
if (count($files) <= $keep) {
|
||||
@@ -521,14 +496,15 @@ abstract class backup_cron_automated_helper {
|
||||
// do there is nothing to clean up.
|
||||
return 0;
|
||||
}
|
||||
// Sort by values descending (newer to older filemodified)
|
||||
arsort($files);
|
||||
$remove = array_splice($files, $keep);
|
||||
foreach (array_keys($remove) as $file) {
|
||||
unlink($dir.'/'.$file);
|
||||
unlink($dir . '/' . $file);
|
||||
}
|
||||
//mtrace('Removed '.count($remove).' old backup file(s) from external directory');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,14 @@ abstract class backup_structure_step extends backup_step {
|
||||
$structure->destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* As far as backup structure steps are implementing backup_plugin stuff, they need to
|
||||
* have the parent task available for wrapping purposes (get course/context....)
|
||||
*/
|
||||
public function get_task() {
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
/**
|
||||
@@ -133,7 +141,7 @@ abstract class backup_structure_step extends backup_step {
|
||||
$backupfile = $plugindir . '/backup/moodle2/' . $classname . '.class.php';
|
||||
if (file_exists($backupfile)) {
|
||||
require_once($backupfile);
|
||||
$backupplugin = new $classname($plugintype, $name, $optigroup);
|
||||
$backupplugin = new $classname($plugintype, $name, $optigroup, $this);
|
||||
// Add plugin returned structure to optigroup
|
||||
$backupplugin->define_plugin_structure($element->get_name());
|
||||
}
|
||||
|
||||
@@ -38,6 +38,11 @@ abstract class restore_structure_step extends restore_step {
|
||||
protected $elementsoldid; // Array to store last oldid used on each element
|
||||
protected $elementsnewid; // Array to store last newid used on each element
|
||||
|
||||
protected $pathlock; // Path currently locking processing of children
|
||||
|
||||
const SKIP_ALL_CHILDREN = -991399; // To instruct the dispatcher about to ignore
|
||||
// all children below path processor returning it
|
||||
|
||||
/**
|
||||
* Constructor - instantiates one object of this class
|
||||
*/
|
||||
@@ -50,10 +55,11 @@ abstract class restore_structure_step extends restore_step {
|
||||
$this->pathelements = array();
|
||||
$this->elementsoldid = array();
|
||||
$this->elementsnewid = array();
|
||||
$this->pathlock = null;
|
||||
parent::__construct($name, $task);
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
final public function execute() {
|
||||
|
||||
if (!$this->execute_condition()) { // Check any condition to execute this
|
||||
return;
|
||||
@@ -106,18 +112,37 @@ abstract class restore_structure_step extends restore_step {
|
||||
* Receive one chunk of information form the xml parser processor and
|
||||
* dispatch it, following the naming rules
|
||||
*/
|
||||
public function process($data) {
|
||||
final public function process($data) {
|
||||
if (!array_key_exists($data['path'], $this->pathelements)) { // Incorrect path, must not happen
|
||||
throw new restore_step_exception('restore_structure_step_missing_path', $data['path']);
|
||||
}
|
||||
$element = $this->pathelements[$data['path']];
|
||||
$object = $element->get_processing_object();
|
||||
$method = $element->get_processing_method();
|
||||
$rdata = null;
|
||||
if (empty($object)) { // No processing object defined
|
||||
throw new restore_step_exception('restore_structure_step_missing_pobject', $object);
|
||||
}
|
||||
$rdata = $object->$method($data['tags']); // Dispatch to proper object/method
|
||||
if ($rdata !== null) { // If the method has returned any info, set element data to it
|
||||
// Release the lock if we aren't anymore within children of it
|
||||
if (!is_null($this->pathlock) and strpos($data['path'], $this->pathlock) === false) {
|
||||
$this->pathlock = null;
|
||||
}
|
||||
if (is_null($this->pathlock)) { // Only dispatch if there isn't any lock
|
||||
$rdata = $object->$method($data['tags']); // Dispatch to proper object/method
|
||||
}
|
||||
|
||||
// If the dispatched method returns SKIP_ALL_CHILDREN, we grab current path in order to
|
||||
// lock dispatching to any children
|
||||
if ($rdata === self::SKIP_ALL_CHILDREN) {
|
||||
// Check we haven't any previous lock
|
||||
if (!is_null($this->pathlock)) {
|
||||
throw new restore_step_exception('restore_structure_step_already_skipping', $data['path']);
|
||||
}
|
||||
// Set the lock
|
||||
$this->pathlock = $data['path'] . '/'; // Lock everything below current path
|
||||
|
||||
// Continue with normal processing of return values
|
||||
} else if ($rdata !== null) { // If the method has returned any info, set element data to it
|
||||
$element->set_data($rdata);
|
||||
} else { // Else, put the original parsed data
|
||||
$element->set_data($data);
|
||||
|
||||
@@ -94,6 +94,10 @@ abstract class base_nested_element extends base_final_element {
|
||||
}
|
||||
|
||||
protected function check_and_set_used($element) {
|
||||
// First of all, check the element being added doesn't conflict with own final elements
|
||||
if (array_key_exists($element->get_name(), $this->final_elements)) {
|
||||
throw new base_element_struct_exception('baseelementchildnameconflict', $element->get_name());
|
||||
}
|
||||
$grandparent = $this->get_grandoptigroupelement_or_grandparent();
|
||||
if ($existing = array_intersect($grandparent->get_used(), $element->get_used())) { // Check the element isn't being used already
|
||||
throw new base_element_struct_exception('baseelementexisting', implode($existing));
|
||||
|
||||
@@ -393,5 +393,16 @@ class base_nested_element_test extends UnitTestCase {
|
||||
$this->assertTrue($e instanceof base_element_parent_exception);
|
||||
}
|
||||
|
||||
// Add child element already used by own final elements
|
||||
$nested = new mock_base_nested_element('PARENT1', null, array('FINAL1', 'FINAL2'));
|
||||
$child = new mock_base_nested_element('FINAL2', null, array('FINAL3', 'FINAL4'));
|
||||
try {
|
||||
$nested->add_child($child);
|
||||
$this->fail("Expecting base_element_struct_exception exception, none occurred");
|
||||
} catch (Exception $e) {
|
||||
$this->assertTrue($e instanceof base_element_struct_exception);
|
||||
$this->assertEqual($e->errorcode, 'baseelementchildnameconflict');
|
||||
$this->assertEqual($e->a, 'FINAL2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +104,18 @@ abstract class simplified_parser_processor extends progressive_parser_processor
|
||||
$alltagswhitespace = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the path including the tag name matches another selected path
|
||||
// (registered or parent) delete it, another chunk will contain that info
|
||||
// (registered or parent) and is null or begins with linefeed, we know it's part
|
||||
// of another chunk, delete it, another chunk will contain that info
|
||||
if ($this->path_is_selected($path . '/' . $key) ||
|
||||
$this->path_is_selected_parent($path . '/' . $key)) {
|
||||
unset($data['tags'][$key]);
|
||||
continue;
|
||||
if (!isset($value['cdata']) || substr($value['cdata'], 0, 1) === "\n") {
|
||||
unset($data['tags'][$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to simple name => value array
|
||||
$data['tags'][$key] = isset($value['cdata']) ? $value['cdata'] : null;
|
||||
|
||||
|
||||
@@ -201,7 +201,12 @@ class progressive_parser {
|
||||
// Entering a new inner level, publish all the information available
|
||||
if ($this->level > $this->prevlevel) {
|
||||
if (!empty($this->currtag) && (!empty($this->currtag['attrs']) || !empty($this->currtag['cdata']))) {
|
||||
$this->topush['tags'][$this->currtag['name']] = $this->currtag;
|
||||
// We always add the last not-empty repetition. Empty ones are ignored.
|
||||
if (isset($this->topush['tags'][$this->currtag['name']]) && trim($this->currtag['cdata']) === '') {
|
||||
// Do nothing, the tag already exists and the repetition is empty
|
||||
} else {
|
||||
$this->topush['tags'][$this->currtag['name']] = $this->currtag;
|
||||
}
|
||||
}
|
||||
if (!empty($this->topush['tags'])) {
|
||||
$this->publish($this->topush);
|
||||
@@ -233,7 +238,12 @@ class progressive_parser {
|
||||
// Ending rencently started tag, add value to current tag
|
||||
if ($this->level == $this->prevlevel) {
|
||||
$this->currtag['cdata'] = $this->postprocess_cdata($this->accum);
|
||||
$this->topush['tags'][$this->currtag['name']] = $this->currtag;
|
||||
// We always add the last not-empty repetition. Empty ones are ignored.
|
||||
if (isset($this->topush['tags'][$this->currtag['name']]) && trim($this->currtag['cdata']) === '') {
|
||||
// Do nothing, the tag already exists and the repetition is empty
|
||||
} else {
|
||||
$this->topush['tags'][$this->currtag['name']] = $this->currtag;
|
||||
}
|
||||
$this->currtag = array();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,9 @@
|
||||
<name>4</name><!-- Only last will be processed. We don't allow repeated final tags in our parser -->
|
||||
<value>4</value>
|
||||
<value>5</value><!-- Only last will be processed. We don't allow repeated final tags in our parser -->
|
||||
<value>
|
||||
|
||||
</value><!-- If one tag already is set and the repeated is empty, the original value is kept -->
|
||||
</othertest>
|
||||
</glossary>
|
||||
</activity>
|
||||
|
||||
@@ -209,7 +209,7 @@ class block_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a block_contents oject representing the full contents of this block.
|
||||
* Return a block_contents object representing the full contents of this block.
|
||||
*
|
||||
* This internally calls ->get_content(), and then adds the editing controls etc.
|
||||
*
|
||||
@@ -217,7 +217,7 @@ class block_base {
|
||||
* {@link html_attributes()}, {@link formatted_contents()} or {@link get_content()},
|
||||
* {@link hide_header()}, {@link (get_edit_controls)}, etc.
|
||||
*
|
||||
* @return block_contents a represntation of the block, for rendering.
|
||||
* @return block_contents a representation of the block, for rendering.
|
||||
* @since Moodle 2.0.
|
||||
*/
|
||||
public function get_content_for_output($output) {
|
||||
@@ -243,10 +243,11 @@ class block_base {
|
||||
|
||||
if ($this->page->user_is_editing()) {
|
||||
$bc->controls = $this->page->blocks->edit_controls($this);
|
||||
}
|
||||
|
||||
if ($this->is_empty() && !$bc->controls) {
|
||||
return null;
|
||||
} else {
|
||||
// we must not use is_empty on hidden blocks
|
||||
if ($this->is_empty() && !$bc->controls) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($CFG->allowuserblockhiding) ||
|
||||
@@ -277,8 +278,8 @@ class block_base {
|
||||
*/
|
||||
protected function formatted_contents($output) {
|
||||
$this->get_content();
|
||||
$this->get_required_javascript();
|
||||
if (!empty($this->content->text)) {
|
||||
$this->get_required_javascript();
|
||||
return $this->content->text;
|
||||
} else {
|
||||
return '';
|
||||
@@ -620,7 +621,7 @@ class block_base {
|
||||
|
||||
/**
|
||||
* Can be overridden by the block to prevent the block from being dockable.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function instance_can_be_docked() {
|
||||
@@ -687,8 +688,8 @@ class block_list extends block_base {
|
||||
|
||||
protected function formatted_contents($output) {
|
||||
$this->get_content();
|
||||
$this->get_required_javascript();
|
||||
if (!empty($this->content->items)) {
|
||||
$this->get_required_javascript();
|
||||
return $output->list_block_contents($this->content->icons, $this->content->items);
|
||||
} else {
|
||||
return '';
|
||||
|
||||
@@ -110,7 +110,8 @@ class block_news_items extends block_base {
|
||||
} else {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
$this->content->footer .= '<br />'.rss_get_link($this->page->context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
|
||||
|
||||
$this->content->footer .= '<br />'.rss_get_link($context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class block_online_users extends block_base {
|
||||
|
||||
$userfields = user_picture::fields('u', array('username'));
|
||||
|
||||
if ($this->page->course->id == SITEID) { // Site-level
|
||||
if ($this->page->course->id == SITEID or $this->page->context->contextlevel < CONTEXT_COURSE) { // Site-level
|
||||
$sql = "SELECT $userfields, MAX(u.lastaccess) AS lastaccess
|
||||
FROM {user} u $groupmembers
|
||||
WHERE u.lastaccess > $timefrom
|
||||
|
||||
@@ -49,11 +49,12 @@ class block_rss_client_edit_form extends block_edit_form {
|
||||
}
|
||||
|
||||
$rssfeeds = $DB->get_records_sql_menu('
|
||||
SELECT id, CASE WHEN preferredtitle = ? THEN title ELSE preferredtitle END AS acutaltitle
|
||||
SELECT id,
|
||||
CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) .' ELSE preferredtitle END
|
||||
FROM {block_rss_client}
|
||||
WHERE userid = ? OR shared = 1
|
||||
ORDER BY acutaltitle',
|
||||
array($DB->sql_empty(), $USER->id));
|
||||
ORDER BY CASE WHEN preferredtitle = ? THEN ' . $DB->sql_compare_text('title', 64) . ' ELSE preferredtitle END ',
|
||||
array($DB->sql_empty(), $USER->id, $DB->sql_empty()));
|
||||
if ($rssfeeds) {
|
||||
$select = $mform->addElement('select', 'config_rssid', get_string('choosefeedlabel', 'block_rss_client'), $rssfeeds);
|
||||
$select->setMultiple(true);
|
||||
|
||||
+19
-5
@@ -150,6 +150,8 @@ function blog_sync_external_entries($externalblog) {
|
||||
$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);
|
||||
@@ -197,7 +199,13 @@ function blog_sync_external_entries($externalblog) {
|
||||
$newentry->uniquehash = $entry->get_permalink();
|
||||
$newentry->publishstate = 'site';
|
||||
$newentry->format = FORMAT_HTML;
|
||||
$newentry->subject = $entry->get_title();
|
||||
// Clean subject of html, just in case
|
||||
$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) . '...';
|
||||
}
|
||||
$newentry->summary = $entry->get_description();
|
||||
|
||||
//used to decide whether to insert or update
|
||||
@@ -253,10 +261,16 @@ function blog_sync_external_entries($externalblog) {
|
||||
}
|
||||
}
|
||||
|
||||
//Look at the posts we have in the database to check if any of them have been deleted from the feed.
|
||||
//Only checking posts within the time frame returned by the rss feed. Older items may have been deleted or
|
||||
//may just not be returned anymore. We cant tell the difference so we leave older posts alone.
|
||||
$dbposts = $DB->get_records_select('post', 'created > :ts', array('ts' => $oldesttimestamp), '', 'id, uniquehash');
|
||||
// Look at the posts we have in the database to check if any of them have been deleted from the feed.
|
||||
// Only checking posts within the time frame returned by the rss feed. Older items may have been deleted or
|
||||
// may just not be returned anymore. We can't tell the difference so we leave older posts alone.
|
||||
$sql = "SELECT id, uniquehash
|
||||
FROM {post}
|
||||
WHERE module = 'blog_external'
|
||||
AND " . $DB->sql_compare_text('content') . " = " . $DB->sql_compare_text(':blogid') . "
|
||||
AND created > :ts";
|
||||
$dbposts = $DB->get_records_sql($sql, array('blogid' => $externalblog->id, 'ts' => $oldesttimestamp));
|
||||
|
||||
$todelete = array();
|
||||
foreach($dbposts as $dbpost) {
|
||||
if ( !in_array($dbpost->uniquehash, $uniquehashes) ) {
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ function blog_rss_get_feed($context, $args) {
|
||||
$info = $SITE->fullname;
|
||||
break;
|
||||
case 'group':
|
||||
$group = groups_get_group($id, false);
|
||||
$group = groups_get_group($id);
|
||||
$info = $group->name; //TODO: $DB->get_field('groups', 'name', array('id'=>$id))
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -35,11 +35,7 @@ $topic = optional_param('topic', -1, PARAM_INT);
|
||||
if ($topic != -1) {
|
||||
$displaysection = course_set_display($course->id, $topic);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) {
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
$displaysection = course_get_display($course->id);
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
@@ -34,11 +34,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
if ($week != -1) {
|
||||
$displaysection = course_set_display($course->id, $week);
|
||||
} else {
|
||||
if (isset($USER->display[$course->id])) {
|
||||
$displaysection = $USER->display[$course->id];
|
||||
} else {
|
||||
$displaysection = course_set_display($course->id, 0);
|
||||
}
|
||||
$displaysection = course_get_display($course->id);
|
||||
}
|
||||
|
||||
$streditsummary = get_string('editsummary');
|
||||
|
||||
+58
-13
@@ -1239,26 +1239,71 @@ function get_all_sections($courseid) {
|
||||
return $coursesections[$courseid];
|
||||
}
|
||||
|
||||
function course_set_display($courseid, $display=0) {
|
||||
/**
|
||||
* Returns the course section to display or 0 meaning show all sections. Returns 0 for guests.
|
||||
* It also sets the $USER->display cache to array($courseid=>return value)
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @return int Course section to display, 0 means all
|
||||
*/
|
||||
function course_get_display($courseid) {
|
||||
global $USER, $DB;
|
||||
|
||||
if ($display == "all" or empty($display)) {
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
//do not get settings in db for guests
|
||||
return 0; //return the implicit setting
|
||||
}
|
||||
|
||||
if (!isset($USER->display[$courseid])) {
|
||||
if (!$display = $DB->get_field('course_display', 'display', array('userid' => $USER->id, 'course'=>$courseid))) {
|
||||
$display = 0; // all sections option is not stored in DB, this makes the table much smaller
|
||||
}
|
||||
//use display cache for one course only - we need to keep session small
|
||||
$USER->display = array($courseid => $display);
|
||||
}
|
||||
|
||||
return $USER->display[$courseid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Show one section only or all sections.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param mixed $display show only this section, 0 or 'all' means show all sections
|
||||
* @return int Course section to display, 0 means all
|
||||
*/
|
||||
function course_set_display($courseid, $display) {
|
||||
global $USER, $DB;
|
||||
|
||||
if ($display === 'all' or empty($display)) {
|
||||
$display = 0;
|
||||
}
|
||||
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
//do not store settings in db for guests
|
||||
} else if ($DB->record_exists("course_display", array("userid" => $USER->id, "course"=>$courseid))) {
|
||||
$DB->set_field("course_display", "display", $display, array("userid"=>$USER->id, "course"=>$courseid));
|
||||
} else {
|
||||
$record = new stdClass();
|
||||
$record->userid = $USER->id;
|
||||
$record->course = $courseid;
|
||||
$record->display = $display;
|
||||
$DB->insert_record("course_display", $record);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $USER->display[$courseid] = $display; // Note: = not ==
|
||||
if ($display == 0) {
|
||||
//show all, do not store anything in database
|
||||
$DB->delete_records('course_display', array('userid' => $USER->id, 'course' => $courseid));
|
||||
|
||||
} else {
|
||||
if ($DB->record_exists('course_display', array('userid' => $USER->id, 'course' => $courseid))) {
|
||||
$DB->set_field('course_display', 'display', $display, array('userid' => $USER->id, 'course' => $courseid));
|
||||
} else {
|
||||
$record = new stdClass();
|
||||
$record->userid = $USER->id;
|
||||
$record->course = $courseid;
|
||||
$record->display = $display;
|
||||
$DB->insert_record('course_display', $record);
|
||||
}
|
||||
}
|
||||
|
||||
//use display cache for one course only - we need to keep session small
|
||||
$USER->display = array($courseid => $display);
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2837,7 +2882,7 @@ function move_section($course, $section, $move) {
|
||||
$DB->set_field("course_sections", "section", $section, array("id"=>$sectiondestrecord->id));
|
||||
|
||||
// if the focus is on the section that is being moved, then move the focus along
|
||||
if (isset($USER->display[$course->id]) and ($USER->display[$course->id] == $section)) {
|
||||
if (course_get_display($course->id) == $section) {
|
||||
course_set_display($course->id, $sectiondest);
|
||||
}
|
||||
|
||||
@@ -2890,7 +2935,7 @@ function move_section_to($course, $section, $destination) {
|
||||
}
|
||||
|
||||
// if the focus is on the section that is being moved, then move the focus along
|
||||
if (isset($USER->display[$course->id]) and ($USER->display[$course->id] == $section)) {
|
||||
if (course_get_display($course->id) == $section) {
|
||||
course_set_display($course->id, $destination);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -474,7 +474,7 @@ if(!$csv) {
|
||||
|
||||
// Display icon
|
||||
$icon = $OUTPUT->pix_url('icon', $criterion->module);
|
||||
$iconlink = $CFG->wwwroot.'/mod/'.$criterion->module.'/view.php?id='.$activity->id;
|
||||
$iconlink = $CFG->wwwroot.'/mod/'.$criterion->module.'/view.php?id='.$criterion->moduleinstance;
|
||||
$icontitle = $activity->name;
|
||||
$iconalt = get_string('modulename', $criterion->module);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@
|
||||
echo $OUTPUT->notification('An error occurred while moving a section');
|
||||
}
|
||||
// Clear the navigation cache at this point so that the affects
|
||||
// are seen immediatly on the navigation.
|
||||
// are seen immediately on the navigation.
|
||||
$PAGE->navigation->clear_cache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ You have to accept or deny payments manually because of the admin hasn\'t enable
|
||||
|
||||
{$a->url}';
|
||||
$string['pendingorderssubject'] = 'WARNING: {$a->course}, {$a->pending} order(s) will expire within {$a->days} day(s).';
|
||||
$string['pluginname'] = 'Authorize.net';
|
||||
$string['pluginname'] = 'Authorize.Net';
|
||||
$string['reason11'] = 'A duplicate transaction has been submitted.';
|
||||
$string['reason13'] = 'The merchant Login ID is invalid or the account is inactive.';
|
||||
$string['reason16'] = 'The transaction was not found.';
|
||||
@@ -254,14 +254,13 @@ You may view your payment details or edit your profile:
|
||||
{$a->profileurl}';
|
||||
$string['youcantdo'] = 'You can\'t do this action: {$a->action}';
|
||||
$string['zipcode'] = 'Zip Code';
|
||||
$string['pluginname'] = 'Authorize';
|
||||
$string['cost'] = 'Cost';
|
||||
$string['currency'] = 'Currency';
|
||||
$string['enrolperiod'] = 'Enrolment period';
|
||||
$string['enrolstartdate'] = 'Start date';
|
||||
$string['enrolenddate'] = 'End date';
|
||||
$string['enrolenddaterror'] = 'Enrolment end date cannot be earlier than start date';
|
||||
$string['status'] = 'Allow Autorize.net enrolments';
|
||||
$string['status'] = 'Allow Autorize.Net enrolments';
|
||||
$string['nocost'] = 'There is no cost associated with enrolling in this course via Authorize.Net!';
|
||||
$string['firstnameoncard'] = 'Firstname on card';
|
||||
$string['lastnameoncard'] = 'Lastname on card';
|
||||
|
||||
@@ -263,16 +263,22 @@ function enrol_category_sync_full() {
|
||||
|
||||
// first of all add necessary enrol instances to all courses
|
||||
$parentcat = $DB->sql_concat("cat.path", "'/%'");
|
||||
$sql = "SELECT DISTINCT c.*
|
||||
// need whole course records to be used by add_instance(), use inner view (ci) to
|
||||
// get distinct records only.
|
||||
// TODO: Moodle 2.1. Improve enrol API to accept courseid / courserec
|
||||
$sql = "SELECT c.*
|
||||
FROM {course} c
|
||||
JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :courselevel)
|
||||
JOIN (SELECT DISTINCT cctx.path
|
||||
FROM {course_categories} cc
|
||||
JOIN {context} cctx ON (cctx.instanceid = cc.id AND cctx.contextlevel = :catlevel)
|
||||
JOIN {role_assignments} ra ON (ra.contextid = cctx.id AND ra.roleid $roleids)
|
||||
) cat ON (ctx.path LIKE $parentcat)
|
||||
LEFT JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'category')
|
||||
WHERE e.id IS NULL";
|
||||
JOIN (
|
||||
SELECT DISTINCT c.id
|
||||
FROM {course} c
|
||||
JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :courselevel)
|
||||
JOIN (SELECT DISTINCT cctx.path
|
||||
FROM {course_categories} cc
|
||||
JOIN {context} cctx ON (cctx.instanceid = cc.id AND cctx.contextlevel = :catlevel)
|
||||
JOIN {role_assignments} ra ON (ra.contextid = cctx.id AND ra.roleid $roleids)
|
||||
) cat ON (ctx.path LIKE $parentcat)
|
||||
LEFT JOIN {enrol} e ON (e.courseid = c.id AND e.enrol = 'category')
|
||||
WHERE e.id IS NULL) ci ON (c.id = ci.id)";
|
||||
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
foreach($rs as $course) {
|
||||
|
||||
@@ -108,6 +108,7 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configtext('enrol_database/newcoursecategory', get_string('newcoursecategory', 'enrol_database'), '', ''));
|
||||
|
||||
if (!during_initial_install()) {
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
$options = array();
|
||||
$parentlist = array();
|
||||
make_categories_list($options, $parentlist);
|
||||
|
||||
@@ -92,6 +92,7 @@ if ($ADMIN->fulltree) {
|
||||
$options = $yesno;
|
||||
$settings->add(new admin_setting_configselect('enrol_ldap/autocreate', get_string('autocreate_key', 'enrol_ldap'), get_string('autocreate', 'enrol_ldap'), 0, $options));
|
||||
if (!during_initial_install()) {
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
$parentlist = array();
|
||||
$options = array();
|
||||
make_categories_list($options, $parentlist);
|
||||
|
||||
+4
-1
@@ -632,12 +632,14 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
|
||||
$instances = $this->manager->get_enrolment_instances();
|
||||
$plugins = $this->manager->get_enrolment_plugins();
|
||||
$manuals = array();
|
||||
// print enrol link or selection
|
||||
$links = array();
|
||||
foreach($instances as $instance) {
|
||||
$plugin = $plugins[$instance->enrol];
|
||||
if ($link = $plugin->get_manual_enrol_link($instance)) {
|
||||
$links[$instance->id] = $link;
|
||||
$manuals[$instance->id] = $instance;
|
||||
}
|
||||
}
|
||||
if (!empty($links)) {
|
||||
@@ -671,6 +673,7 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
$startdateoptions[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
|
||||
|
||||
if ($count == 1) {
|
||||
$instance = reset($manuals);
|
||||
$page->requires->strings_for_js(array(
|
||||
'ajaxoneuserfound',
|
||||
'ajaxxusersfound',
|
||||
@@ -697,7 +700,7 @@ class course_enrolment_users_table extends course_enrolment_table {
|
||||
'ajaxurl'=>'/enrol/ajax.php',
|
||||
'url'=>$url->out(false),
|
||||
'optionsStartDate'=>$startdateoptions,
|
||||
'defaultRole'=>get_config('enrol_manual', 'roleid'));
|
||||
'defaultRole'=>$instance->roleid);
|
||||
$page->requires->yui_module($modules, $function, array($arguments));
|
||||
}
|
||||
return $control;
|
||||
|
||||
@@ -46,96 +46,101 @@ class filter_mediaplugin extends moodle_text_filter {
|
||||
// non string data can not be filtered anyway
|
||||
return $text;
|
||||
}
|
||||
if (stripos($text, '</a>') === false) {
|
||||
// performance shortcut - all regexes bellow end with the </a> tag,
|
||||
// if not present nothing can match
|
||||
return $text;
|
||||
}
|
||||
$newtext = $text; // fullclone is slow and not needed here
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_mp3)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.mp3)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.mp3)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_mp3_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_ogg)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.ogg)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.ogg)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_ogg_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_ogv)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.ogv)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.ogv)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_ogv_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_swf)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.swf)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_swf_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_flv)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.flv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_flv_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_mov)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.mov)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
|
||||
|
||||
$search = '/<a[^>]*?href="([^<]+\.mp4)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.mp4)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
|
||||
|
||||
$search = '/<a[^>]*?href="([^<]+\.m4v)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.m4v)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
|
||||
|
||||
$search = '/<a[^>]*?href="([^<]+\.m4a)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.m4a)(\?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_wmv)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.wmv)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_mpg)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.mpe?g)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_qt_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_avi)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.avi)(\?d=([\d]{1,3}%?)x([\d]{1,3}%?))?"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_wmp_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_ram)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.ram)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.ram)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_rpm)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.rpm)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.rpm)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_rm)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.rm)"[^>]*>.*?<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.rm)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_real_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_youtube)) {
|
||||
//see MDL-23903 for description of recent changes to this regex
|
||||
//$search = '/<a.*?href="([^<]*)youtube.com\/watch\?v=([^"]*)"[^>]*>(.*?)<\/a>/is';
|
||||
$search = '/<a[^>]*href="([^<]*?)youtube.com\/watch\?v=([^"]*)"[^>]*>(.*?)<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="(([^"]+youtube\.com)\/watch\?v=([A-Za-z0-9\-_]+))[^>]*>(.*?)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
|
||||
|
||||
$search = '/<a[^>]*href="([^<]*)youtube.com\/v\/([^"]*)"[^>]*>(.*?)<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="(([^"]+youtube\.com)\/v\/([A-Za-z0-9\-_]*))[^>]+>(.*?)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_callback', $newtext);
|
||||
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="((([^"]+)youtube\.com)\/view_play_list\?p=([^"]*))"[^>]*>(.*?)<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="((([^"]+)youtube\.com)\/view_play_list\?p=([A-Za-z0-9\-_]+))[^>]*>(.*?)<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_youtube_playlist_callback', $newtext);
|
||||
}
|
||||
|
||||
if (!empty($CFG->filter_mediaplugin_enable_img)) {
|
||||
$search = '/<a[^>]*?href="([^<]+\.jpg)"[^>]*>(.*?)<\/a>/is';
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.jpg)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
|
||||
$search = '/<a[^>]*?href="([^<]+\.png)"[^>]*>(.*?)<\/a>/is';
|
||||
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.png)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
|
||||
$search = '/<a[^>]*?href="([^<]+\.gif)"[^>]*>(.*?)<\/a>/is';
|
||||
|
||||
$search = '/<a(\s+[^>]+?)?\s+href="([^"]+\.gif)"[^>]*>.*?<\/a>/is';
|
||||
$newtext = preg_replace_callback($search, 'filter_mediaplugin_img_callback', $newtext);
|
||||
}
|
||||
|
||||
@@ -166,7 +171,7 @@ function filter_mediaplugin_mp3_callback($link) {
|
||||
$count++;
|
||||
$id = 'filter_mp3_'.time().$count; //we need something unique because it might be stored in text cache
|
||||
|
||||
$url = addslashes_js($link[1]);
|
||||
$url = addslashes_js($link[2]);
|
||||
|
||||
$playerpath = $CFG->wwwroot.'/filter/mediaplugin/mp3player.swf';
|
||||
$audioplayerpath = $CFG->wwwroot .'/filter/mediaplugin/flowplayer.audio.swf';
|
||||
@@ -215,7 +220,7 @@ function filter_mediaplugin_ogg_callback($link) {
|
||||
$count++;
|
||||
$id = 'filter_ogg_'.time().$count; //we need something unique because it might be stored in text cache
|
||||
|
||||
$url = addslashes_js($link[1]);
|
||||
$url = $link[2];
|
||||
$printlink = html_writer::link($url, get_string('oggaudio', 'filter_mediaplugin'));
|
||||
$unsupportedplugins = get_string('unsupportedplugins', 'filter_mediaplugin', $printlink);
|
||||
$output = <<<OET
|
||||
@@ -234,7 +239,7 @@ function filter_mediaplugin_ogv_callback($link) {
|
||||
$count++;
|
||||
$id = 'filter_ogv_'.time().$count; //we need something unique because it might be stored in text cache
|
||||
|
||||
$url = addslashes_js($link[1]);
|
||||
$url = $link[2];
|
||||
$printlink = html_writer::link($url, get_string('ogvvideo', 'filter_mediaplugin'));
|
||||
$unsupportedplugins = get_string('unsupportedplugins', 'filter_mediaplugin', $printlink);
|
||||
$output = <<<OET
|
||||
@@ -252,9 +257,9 @@ function filter_mediaplugin_swf_callback($link) {
|
||||
$count++;
|
||||
$id = 'filter_swf_'.time().$count; //we need something unique because it might be stored in text cache
|
||||
|
||||
$width = empty($link[3]) ? '400' : $link[3];
|
||||
$height = empty($link[4]) ? '300' : $link[4];
|
||||
$url = addslashes_js($link[1]);
|
||||
$width = empty($link[4]) ? '400' : $link[4];
|
||||
$height = empty($link[5]) ? '300' : $link[5];
|
||||
$url = $link[2];
|
||||
|
||||
$args = Array();
|
||||
$args['movie'] = $url;
|
||||
@@ -279,16 +284,17 @@ function filter_mediaplugin_flv_callback($link) {
|
||||
$count++;
|
||||
$id = 'filter_flv_'.time().$count; //we need something unique because it might be stored in text cache
|
||||
|
||||
$width = empty($link[3]) ? '480' : $link[3];
|
||||
$height = empty($link[4]) ? '360' : $link[4];
|
||||
$url = addslashes_js($link[1]);
|
||||
// note: in 1.9.x this used to be 480x360
|
||||
$width = empty($link[4]) ? '800' : $link[4];
|
||||
$height = empty($link[5]) ? '600' : $link[5];
|
||||
$url = addslashes_js($link[2]);
|
||||
|
||||
$playerpath = $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf';
|
||||
|
||||
$output = <<<EOT
|
||||
<span class="mediaplugin mediaplugin_flv" id="$id"></span>
|
||||
<noscript><div>
|
||||
<object width="800" height="600" id="undefined" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
|
||||
<object width="$width" height="$height" id="undefined" name="undefined" data="$playerpath" type="application/x-shockwave-flash">
|
||||
<param name="movie" value="$playerpath" />
|
||||
<param name="allowfullscreen" value="true" />
|
||||
<param name="allowscriptaccess" value="always" />
|
||||
@@ -305,7 +311,8 @@ EOT;
|
||||
}
|
||||
|
||||
function filter_mediaplugin_real_callback($link, $autostart=false) {
|
||||
$url = addslashes_js($link[1]);
|
||||
$url = $link[2];
|
||||
$jsurl = addslashes_js($link[2]);
|
||||
$mimetype = mimeinfo('type', $url);
|
||||
$autostart = $autostart ? 'true' : 'false';
|
||||
|
||||
@@ -315,19 +322,19 @@ function filter_mediaplugin_real_callback($link, $autostart=false) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
document.write(\'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="240" height="180">\\
|
||||
<param name="src" value="'.$url.'" />\\
|
||||
<param name="src" value="'.$jsurl.'" />\\
|
||||
<param name="autostart" value="'.$autostart.'" />\\
|
||||
<param name="controls" value="imagewindow" />\\
|
||||
<param name="console" value="video" />\\
|
||||
<param name="loop" value="true" />\\
|
||||
<embed src="'.$url.'" width="240" height="180" loop="true" type="'.$mimetype.'" controls="imagewindow" console="video" autostart="'.$autostart.'" />\\
|
||||
<embed src="'.$jsurl.'" width="240" height="180" loop="true" type="'.$mimetype.'" controls="imagewindow" console="video" autostart="'.$autostart.'" />\\
|
||||
</object><br />\\
|
||||
<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="240" height="30">\\
|
||||
<param name="src" value="'.$url.'" />\\
|
||||
<param name="src" value="'.$jsurl.'" />\\
|
||||
<param name="autostart" value="'.$autostart.'" />\\
|
||||
<param name="controls" value="ControlPanel" />\\
|
||||
<param name="console" value="video" />\\
|
||||
<embed src="'.$url.'" width="240" height="30" controls="ControlPanel" type="'.$mimetype.'" console="video" autostart="'.$autostart.'" />\\
|
||||
<embed src="'.$jsurl.'" width="240" height="30" controls="ControlPanel" type="'.$mimetype.'" console="video" autostart="'.$autostart.'" />\\
|
||||
</object>\');
|
||||
//]]>
|
||||
</script></span>';
|
||||
@@ -337,15 +344,15 @@ document.write(\'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" wi
|
||||
* Change links to Youtube into embedded Youtube videos
|
||||
*/
|
||||
function filter_mediaplugin_youtube_callback($link, $autostart=false) {
|
||||
$site = s($link[3]);
|
||||
$param = $link[4]; // video id
|
||||
$info = s(strip_tags($link[5]));
|
||||
|
||||
$site = addslashes_js($link[1]);
|
||||
$url = addslashes_js($link[2]);
|
||||
$info = addslashes_js(strip_tags($link[3]));//strip out html tags as they won't work in the title attribute
|
||||
|
||||
return '<object title="'.$info.'"
|
||||
class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash"
|
||||
data="'.$site.'youtube.com/v/'.$url.'&fs=1&rel=0" width="425" height="344">'.
|
||||
'<param name="movie" value="'.$site.'youtube.com/v/'.$url.'&fs=1&rel=0" />'.
|
||||
data="'.$site.'/v/'.$param.'&fs=1&rel=0" width="400" height="320">'.
|
||||
'<param name="movie" value="'.$site.'/v/'.$param.'&fs=1&rel=0" />'.
|
||||
'<param name="FlashVars" value="playerMode=embedded" />'.
|
||||
'<param name="wmode" value="transparent" />'.
|
||||
'<param name="allowFullScreen" value="true" />'.
|
||||
@@ -358,8 +365,8 @@ function filter_mediaplugin_youtube_callback($link, $autostart=false) {
|
||||
function filter_mediaplugin_youtube_playlist_callback($link, $autostart=false) {
|
||||
|
||||
$site = s($link[4]);
|
||||
$param = s($link[5]);
|
||||
$info = s($link[6]);
|
||||
$param = $link[5]; // playlist id
|
||||
$info = s(strip_tags($link[6]));
|
||||
|
||||
return '<object title="'.$info.'"
|
||||
class="mediaplugin mediaplugin_youtube" type="application/x-shockwave-flash"
|
||||
@@ -375,9 +382,8 @@ function filter_mediaplugin_youtube_playlist_callback($link, $autostart=false) {
|
||||
* Change links to images into embedded images
|
||||
*/
|
||||
function filter_mediaplugin_img_callback($link, $autostart=false) {
|
||||
$url = addslashes_js($link[1]);
|
||||
$info = addslashes_js($link[2]);
|
||||
|
||||
$url = $link[2];
|
||||
$info = s(strip_tags($link[2]));
|
||||
return '<img class="mediaplugin mediaplugin_img" alt="" title="'.$info.'" src="'.$url.'" />';
|
||||
}
|
||||
|
||||
@@ -385,13 +391,13 @@ function filter_mediaplugin_img_callback($link, $autostart=false) {
|
||||
* Embed video using window media player if available
|
||||
*/
|
||||
function filter_mediaplugin_wmp_callback($link, $autostart=false) {
|
||||
$url = $link[1];
|
||||
if (empty($link[3]) or empty($link[4])) {
|
||||
$url = $link[2];
|
||||
if (empty($link[4]) or empty($link[5])) {
|
||||
$mpsize = '';
|
||||
$size = 'width="300" height="260"';
|
||||
$autosize = 'true';
|
||||
} else {
|
||||
$size = 'width="'.$link[3].'" height="'.$link[4].'"';
|
||||
$size = 'width="'.$link[4].'" height="'.$link[5].'"';
|
||||
$mpsize = $size;
|
||||
$autosize = 'false';
|
||||
}
|
||||
@@ -428,11 +434,11 @@ function filter_mediaplugin_wmp_callback($link, $autostart=false) {
|
||||
}
|
||||
|
||||
function filter_mediaplugin_qt_callback($link, $autostart=false) {
|
||||
$url = $link[1];
|
||||
if (empty($link[3]) or empty($link[4])) {
|
||||
$url = $link[2];
|
||||
if (empty($link[4]) or empty($link[5])) {
|
||||
$size = 'width="440" height="315"';
|
||||
} else {
|
||||
$size = 'width="'.$link[3].'" height="'.$link[4].'"';
|
||||
$size = 'width="'.$link[4].'" height="'.$link[5].'"';
|
||||
}
|
||||
$mimetype = mimeinfo('type', $url);
|
||||
$autostart = $autostart ? 'true' : 'false';
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit test for the filter_mediaplugin
|
||||
*
|
||||
* @package filter
|
||||
* @subpackage Mediaplugin
|
||||
* @copyright 2011 Rossiani Wijaya <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/filter/mediaplugin/filter.php'); // Include the code to test
|
||||
|
||||
/**
|
||||
* Test cases for filter_mediaplugin class
|
||||
*/
|
||||
class filter_mediaplugin_test extends UnitTestCase {
|
||||
|
||||
function test_filter_mediaplugin_link() {
|
||||
global $CFG;
|
||||
|
||||
// we need to enable the plugins somehow
|
||||
$oldcfg = clone($CFG); // very, very ugly hack
|
||||
$CFG->filter_mediaplugin_enable_mp3 = 1;
|
||||
$CFG->filter_mediaplugin_enable_ogg = 1;
|
||||
$CFG->filter_mediaplugin_enable_ogv = 1;
|
||||
$CFG->filter_mediaplugin_enable_swf = 1;
|
||||
$CFG->filter_mediaplugin_enable_flv = 1;
|
||||
$CFG->filter_mediaplugin_enable_mov = 1;
|
||||
$CFG->filter_mediaplugin_enable_wmv = 1;
|
||||
$CFG->filter_mediaplugin_enable_mpg = 1;
|
||||
$CFG->filter_mediaplugin_enable_avi = 1;
|
||||
$CFG->filter_mediaplugin_enable_ram = 1;
|
||||
$CFG->filter_mediaplugin_enable_rpm = 1;
|
||||
$CFG->filter_mediaplugin_enable_rm = 1;
|
||||
$CFG->filter_mediaplugin_enable_youtube = 1;
|
||||
$CFG->filter_mediaplugin_enable_img = 1;
|
||||
|
||||
|
||||
$filterplugin = new filter_mediaplugin(null, array());
|
||||
|
||||
$validtexts = array (
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a href="http://moodle.org/testfile/test.ogg">test ogg</a>',
|
||||
'<a id="movie player" class="center" href="http://moodle.org/testfile/test.mpg">test mpg</a>',
|
||||
'<a href="http://moodle.org/testfile/test.ram">test</a>',
|
||||
'<a href="http://www.youtube.com/watch?v=JghQgA2HMX8" class="href=css">test file</a>',
|
||||
'<a class="youtube" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x100">test flv</a>',
|
||||
'<a class="hrefcss" href="http://www.youtube.com/watch?v=JghQgA2HMX8">test file</a>',
|
||||
'<a href="http://www.moodle.org/logo.jpg"><img src="http://moodle.org/test.jpg" /></a>',
|
||||
'<a href="http://www.moodle.org/logo.rpm">rpm file</a>',
|
||||
'<a class="content" href="http://moodle.org/testfile/test.avi">test mp3</a>',
|
||||
'<a id="audio" href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a href="http://www.youtube.com/watch?v=JghQgA2HMX8?d=200x200">youtube\'s</a>',
|
||||
'<a
|
||||
href="http://moodle.org/testfile/test.mp3">
|
||||
test mp3</a>',
|
||||
'<a class="content"
|
||||
|
||||
|
||||
href="http://moodle.org/testfile/test.avi">test mp3
|
||||
</a>',
|
||||
'<a href="http://www.youtube.com/watch?v=JghQgA2HMX8?d=200x200" >youtube\'s</a>'
|
||||
);
|
||||
|
||||
//test for valid link
|
||||
foreach ($validtexts as $text) {
|
||||
$msg = "Testing text: ". $text;
|
||||
$filter = $filterplugin->filter($text);
|
||||
$this->assertNotEqual($text, $filter, $msg);
|
||||
}
|
||||
|
||||
$invalidtexts = array(
|
||||
'<a class="_blanktarget">href="http://moodle.org/testfile/test.mp3"</a>',
|
||||
'<a>test test</a>',
|
||||
'<a >test test</a>',
|
||||
'<a >test test</a>',
|
||||
'<a >test test</a>',
|
||||
'<ahref="http://moodle.org/testfile/test.mp3">sample</a>',
|
||||
'<a href="" test></a>',
|
||||
'<a class="_blanktarget" href="http://moodle.org/testfile/test.flv?d=100x">test flv</a>',
|
||||
'<a href="http://www.moodle.com/path/to?#param=29">test</a>',
|
||||
'<a href="http://moodle.org/testfile/test.mp3">test mp3',
|
||||
'<a href="http://moodle.org/testfile/test.mp3"test</a>',
|
||||
'<a href="http://moodle.org/testfile/">test</a>',
|
||||
'<a href="http://www.moodle.org/path/to/test.flv#param2=1?d=100x100">test</a>',
|
||||
'<href="http://moodle.org/testfile/test.avi">test</a>',
|
||||
'<a ahref="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<abbr href="http://moodle.org/testfile/test.mp3">test mp3</abbr>',
|
||||
'<ahref="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<a class="content"href="http://moodle.org/testfile/test.mp3">test mp3</a>',
|
||||
'<aclass="content" href="http://moodle.org/testfile/test.mp3">test mp3</a>'
|
||||
);
|
||||
|
||||
//test for invalid link
|
||||
foreach ($invalidtexts as $text) {
|
||||
$msg = "Testing text: ". $text;
|
||||
$filter = $filterplugin->filter($text);
|
||||
$this->assertEqual($text, $filter, $msg);
|
||||
}
|
||||
|
||||
$CFG = $oldcfg; // very, very ugly hack
|
||||
}
|
||||
}
|
||||
+4
-6
@@ -39,15 +39,13 @@ $context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
|
||||
require_capability('moodle/course:managegroups', $context);
|
||||
|
||||
$strimportgroups = get_string("importgroups");
|
||||
$strimportgroups = get_string('importgroups', 'core_group');
|
||||
|
||||
/// Print the header
|
||||
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
$PAGE->navbar->add(get_string('import'), new moodle_url('/course/import.php', array('id'=>$course->id)));
|
||||
$PAGE->navbar->add($strimportgroups);
|
||||
|
||||
navigation_node::override_active_url(new moodle_url('/group/index.php', array('id' => $course->id)));
|
||||
$PAGE->set_title("$course->shortname: $strimportgroups");
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
$returnurl = new moodle_url('/group/index.php', array('id'=>$id));
|
||||
|
||||
@@ -188,6 +186,6 @@ if ($mform_post->is_cancelled()) {
|
||||
|
||||
/// Print the form
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($strimportgroups);
|
||||
echo $OUTPUT->heading_with_help($strimportgroups, 'importgroups', 'core_group');
|
||||
$mform_post ->display();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -23,7 +23,7 @@ class groups_import_form extends moodleform {
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
|
||||
$this->add_action_buttons(true, get_string('importgroups'));
|
||||
$this->add_action_buttons(true, get_string('importgroups', 'core_group'));
|
||||
|
||||
$this->set_data($data);
|
||||
}
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ echo '<p><input type="submit" name="act_showautocreategroupsform" id="showautocr
|
||||
. get_string('autocreategroups', 'group') . '" /></p>'."\n";
|
||||
|
||||
echo '<p><input type="submit" name="act_showimportgroups" id="showimportgroups" value="'
|
||||
. get_string('importgroups') . '" /></p>'."\n";
|
||||
. get_string('importgroups', 'core_group') . '" /></p>'."\n";
|
||||
|
||||
echo '</td>'."\n";
|
||||
echo '<td>'."\n";
|
||||
|
||||
+6
-6
@@ -306,7 +306,7 @@ if ($config->stage == INSTALL_DOWNLOADLANG) {
|
||||
$a = new stdClass();
|
||||
$a->parent = dirname($CFG->dataroot);
|
||||
$a->dataroot = $CFG->dataroot;
|
||||
if (!is_writable(dirname($CFG->dataroot))) {
|
||||
if (!is_writable($a->parent)) {
|
||||
$hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
|
||||
$config->stage = INSTALL_PATHS;
|
||||
} else {
|
||||
@@ -317,7 +317,7 @@ if ($config->stage == INSTALL_DOWNLOADLANG) {
|
||||
}
|
||||
|
||||
} else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
|
||||
$hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
|
||||
$hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
|
||||
$config->stage = INSTALL_PATHS;
|
||||
}
|
||||
|
||||
@@ -415,7 +415,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="30" class="forminput" />';
|
||||
echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
|
||||
@@ -552,15 +552,15 @@ if ($config->stage == INSTALL_PATHS) {
|
||||
|
||||
echo '<div class="userinput">';
|
||||
echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
|
||||
echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="45" class="forminput" />';
|
||||
echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
|
||||
echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="45"class="forminput" />';
|
||||
echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
|
||||
echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="45" class="forminput" />';
|
||||
echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
|
||||
if ($hint_dataroot !== '') {
|
||||
echo '<div class="hint">'.$hint_dataroot.'</div>';
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['clianswerno'] = 'No';
|
||||
$string['cliansweryes'] = 'Sí';
|
||||
$string['cliincorrectvalueerror'] = 'Error, valor incorrecte "{$a->value}" per a "{$a->option}"';
|
||||
$string['cliincorrectvalueretry'] = 'Valor incorrecte, si us plau, torneu-ho a provar.';
|
||||
$string['clitypevalue'] = 'Valor de tipus';
|
||||
@@ -35,5 +37,6 @@ $string['clitypevaluedefault'] = 'valor de tipus, premeu Intro per fer servir un
|
||||
$string['cliunknowoption'] = 'Opcions invàlides:
|
||||
{$a}
|
||||
L\'opció --help us orientarà.';
|
||||
$string['cliyesnoprompt'] = 'Escriu y (significa Sí) o n (significa No)';
|
||||
$string['environmentrequireinstall'] = 'es requereix instal·lar/habilitar';
|
||||
$string['environmentrequireversion'] = 'esteu executant la versió {$a->current} i es requereix la {$a->needed}';
|
||||
|
||||
@@ -62,8 +62,8 @@ $string['pathsroparentdataroot'] = 'Das Verzeichnis ({$a->parent}) ist schreibge
|
||||
$string['pathssubadmindir'] = 'Einige Webserver benutzen /admin als speziellen Link, um auf Einstellungsseiten oder Ähnliches zu verweisen. Unglücklicherweise kollidiert dies mit dem standardmäßigen Verzeichnis für die Moodle-Administration. Sie können dieses Problem beheben, indem Sie das Verzeichnis admin in Ihrer Moodle-Installation umbenennen und den neuen Namen hier eingeben (z.B. <em>moodleadmin</em>). Mit dieser Änderung werden alle Admin-Links korrigiert.';
|
||||
$string['pathssubdataroot'] = 'Sie benötigen einen Platz, wo Moodle hochgeladene Dateien abspeichern kann. Dieses Verzeichnis muss Lese- und Schreibrechte für das Nutzerkonto besitzen, mit dem Ihr Webservers läuft (üblicherweise \'nobody\', \'apache\' oder \'www\'). Außerdem sollte das Verzeichnis nicht direkt aus dem Internet erreichbar sein. Das Intallationsskript wird versuchen, ein solches Verzeichnis zu erstellen, falls es nicht existiert.</p>';
|
||||
$string['pathssubdirroot'] = 'Vollständiger Pfad der Moodle-Installation';
|
||||
$string['pathssubwwwroot'] = 'Vollständige Webadresse für den Zugriff auf Moodle. Es ist nicht möglich, auf Moodle über unterschiedliche Adressen zuzugreifen. Sollten Sie für Ihre Website mehrere öffentliche Adressen verwenden, so müssen Sie eine Adresse auswählen und für die übrigen Adressen dauerhafte Weiterleitungen einrichten.
|
||||
<p>Falls Ihre Website gleichzeitig im Intranet und im Internet erreichbar ist, so tragen Sie hier die öffentliche Adresse ein. Konfigurieren Sie den DNS-Eintrag des Servers so, dass für alle Intranet-Nutzer ebenfalls die öffentliche Adresse erreichbar ist.
|
||||
$string['pathssubwwwroot'] = 'Vollständige Webadresse für den Zugriff auf Moodle. Es ist nicht möglich, über unterschiedliche Adressen auf Moodle zuzugreifen. Sollte Ihre Website mehrere öffentliche Adressen verwenden, so müssen Sie eine Adresse festlegen und für die übrigen Adressen dauerhafte Weiterleitungen dorthin einrichten.
|
||||
<p>Falls Ihre Website gleichzeitig im Intranet und im Internet erreichbar ist, so tragen Sie die öffentliche Adresse ein. Konfigurieren Sie den DNS so, dass Moodle auch aus dem Intranet über die öffentliche Adresse erreichbar ist.
|
||||
<p>Führen Sie Ihre Moodle-Installation unbedingt mit der richtigen Adresse durch, weil es andernfalls zu Problemen kommen könnte.';
|
||||
$string['pathsunsecuredataroot'] = 'Der Speicherort des Verzeichnisses \'dataroot\' ist unsicher';
|
||||
$string['pathswrongadmindir'] = 'Das Admin-Verzeichnis existiert nicht';
|
||||
|
||||
+21
-17
@@ -35,33 +35,37 @@ $string['chooselanguagesub'] = 'Proszę wybrać język TYLKO do instalacji. Stro
|
||||
$string['databasehost'] = 'Host bazy danych';
|
||||
$string['databasename'] = 'Nazwa bazy danych';
|
||||
$string['dataroot'] = 'Katalog z danymi';
|
||||
$string['dbprefix'] = 'prefiksy tabel';
|
||||
$string['dbprefix'] = 'Prefiks tabel';
|
||||
$string['dirroot'] = 'Katalog Moodle';
|
||||
$string['environmenthead'] = 'Sprawdzam środowisko (ustawienia) ...';
|
||||
$string['installation'] = 'Instalacja';
|
||||
$string['langdownloaderror'] = 'Niestety język "{$a}" nie jest zainstalowany. Instalacja będzie przebiegać dalej po angielsku.';
|
||||
$string['memorylimithelp'] = 'Limit pamięci PHP dla Twojego serwera jest ustawiony obecnie na {$a}.</p>
|
||||
$string['langdownloaderror'] = 'Niestety język "{$a}" nie może zostać pobrany. Proces instalacji będzie kontynuowany w języku angielskim.';
|
||||
$string['memorylimithelp'] = '<p>Limit pamięci PHP dla Twojego serwera jest ustawiony obecnie na {$a}.</p>
|
||||
|
||||
<p> Może to stworzyć sytuację, w której Moodle będzie miał w przyszłości problemy z pamięcią, zwłaszcza jeśli masz udostępnionych wiele modułów i/lub wielu użytkowników.</p>
|
||||
|
||||
<p> Jeśli jest to możliwe, zalecamy ustawienie konfiguracji PHP z wyższym limitem, np. 40M.
|
||||
Istnieje kilka sposobów przeprowadzenia tej operacji, których możesz spróbować: </p>
|
||||
<p>Jeśli jest to możliwe, zalecamy ustawienie konfiguracji PHP z wyższym limitem, np. 40M.
|
||||
Istnieje kilka sposobów przeprowadzenia tej operacji, których możesz spróbować:</p>
|
||||
<ol>
|
||||
<li> Jeśli możesz przekompiluj PHP za pomocą <i>--enable-memory-limit</i>.
|
||||
Pozwoli to Moodle ustawić samoczynnie limit pamięci. </li>
|
||||
<li> Jeśli masz dostęp do swojego pliku php.ini, możesz w nim zmienić ustawienie <b>memory_limit</b> do wielkođci 40M. Jeśli nie posiadasz tego dostępu możesz poprosić swojego administratora aby zrobił to za Ciebie.</li>
|
||||
<li> Na niektórych serwerach PHP można stworzyć plik. htaccess w katalogu Moodle zawierający poniższą linię:
|
||||
<p><blockquote>php_value memory_limit 40M</blockquote></p>
|
||||
<p> jednakże na niektórych serwerach będzie uniemożliwiało to działanie <b> wszystkich </b> stron PHP (ujrzysz błędy na stronie), a więc będziesz zmuszony usunąć plik .htaccess. </p></li></ol>”';
|
||||
<li>Jeśli możesz przekompiluj PHP za pomocą <i>--enable-memory-limit</i>.
|
||||
Pozwoli to Moodle ustawić samoczynnie limit pamięci.</li>
|
||||
<li>Jeśli masz dostęp do pliku konfiguracyjnego php.ini, możesz w nim zmienić ustawienie <b>memory_limit</b> do wielkości np. 40M. W przypadku, gdy nie posiadasz dostępu możesz poprosić swojego administratora aby zrobił to za Ciebie.</li>
|
||||
<li>Na niektórych serwerach PHP można stworzyć plik. htaccess w katalogu Moodle zawierający poniższą linię:
|
||||
<blockquote><div>php_value memory_limit 40M</div></blockquote>
|
||||
<p>Jednakże na niektórych serwerach będzie uniemożliwiało to poprawne działanie <b>wszystkich</b> stron PHP (ujrzysz błędy na wyświetlanych stronach), wtedy będziesz musiał usunąć plik .htaccess.</p></li>
|
||||
</ol>';
|
||||
$string['pathsroparentdataroot'] = 'Nadrzędny katalog ({$a->parent}) jest tylko do odczytu. Katalog danych ({$a->dataroot}) nie może zostać utworzony przez instalator. ';
|
||||
$string['pathswrongadmindir'] = 'Katalog admin nie istnieje';
|
||||
$string['phpextension'] = '{$a} rozszerzenie PHP';
|
||||
$string['phpversion'] = 'Wersja PHP';
|
||||
$string['phpversionhelp'] = '<p> Moodle wymaga wersji PHP co najmniej 4.1.0. </p>
|
||||
$string['phpversionhelp'] = '<p>Moodle wymaga wersji PHP co najmniej 4.3.0 lub 5.1.0 (5.0.x posiada kilka znanych problemów).</p>
|
||||
<p>Obecnie jest uruchomiona wersja {$a}</p>
|
||||
<p> Musisz uaktualnić wersje PHP lub przenieść na host z nowszą wersją PHP!</p>';
|
||||
<p>Musisz uaktualnić wersję PHP lub przenieść na host z nowszą wersją PHP!<br />(W przypadku wersji 5.0.x możesz dokonać downgrade do wersji 4.4.x)</p>';
|
||||
$string['welcomep10'] = '{$a->installername} ({$a->installerversion})';
|
||||
$string['welcomep20'] = 'Widzisz tę stronę, ponieważ z powodzeniem zainstalowałeś i uruchomiłeś <strong>{$a->packname} {$a->packversion}</strong> na swoim komputerze.';
|
||||
$string['welcomep20'] = 'Widzisz tę stronę, ponieważ z powodzeniem zainstalowałeś i uruchomiłeś <strong>{$a->packname} {$a->packversion}</strong> na swoim komputerze.';
|
||||
$string['welcomep30'] = 'Ten instalator <strong>{$a->installername}</strong> zawiera aplikacje, by stworzyć środowisko, w którym będzie działać <strong>Moodle</strong>, czyli';
|
||||
$string['welcomep40'] = 'Pakiet zawiera<strong>Moodle {$a->moodlerelease} ({$a->moodleversion})</strong>.';
|
||||
$string['welcomep40'] = 'Pakiet zawiera <strong>Moodle {$a->moodlerelease} ({$a->moodleversion})</strong>.';
|
||||
$string['welcomep50'] = 'Wszystkie aplikacje w tym pakiecie maja własne, oddzielne licencje. Kompletny pakiet <strong>{$a->installername}</strong> jest <a href="http://www.opensource.org/docs/definition_plain.html">open source</a> i jest dystrybuowany na <a href="http://www.gnu.org/copyleft/gpl.html">GPL</a> licencji.';
|
||||
$string['welcomep60'] = 'Nastepujące strony przeprowadzą cię przez instalację Moodle na twoim komputerze. Możesz zaakceptować ustawienia domyślne lub, opcjonalnie, dostosować je do swoich potrzeb.';
|
||||
$string['welcomep70'] = 'Kliknij "Dalej" żeby kontynuować instalację Moodle';
|
||||
$string['welcomep60'] = 'Nastepujące strony przeprowadzą cię przez instalację <strong>Moodle</strong> na twoim komputerze. Możesz zaakceptować ustawienia domyślne, lub opcjonalnie, dostosować je do swoich potrzeb.';
|
||||
$string['welcomep70'] = 'Kliknij przycisk "Dalej" żeby kontynuować instalację <strong>Moodle</strong>.';
|
||||
$string['wwwroot'] = 'Adres w sieci';
|
||||
|
||||
@@ -33,12 +33,16 @@ $string['availablelangs'] = 'Pacotes de idioma disponíveis';
|
||||
$string['chooselanguagehead'] = 'Escolha um idioma';
|
||||
$string['chooselanguagesub'] = 'Escolha um idioma a ser usado durante a instalação. Após a instalação você pode definir o idioma principal do site e outros idiomas a serem utilizados pelos usuários.';
|
||||
$string['clialreadyinstalled'] = 'O arquivo config.php já existe, por favor use admin/cli/upgrade.php, se você quiser atualizar o seu site.';
|
||||
$string['cliinstallheader'] = 'Programa de instalação por linha de comando do Moodle {$a}';
|
||||
$string['databasehost'] = 'Host da Base de Dados.';
|
||||
$string['databasename'] = 'Nome da Base de Dados';
|
||||
$string['databasetypehead'] = 'Escolha o driver da base de dados';
|
||||
$string['dataroot'] = 'Diretório de Dados';
|
||||
$string['dbprefix'] = 'Prefixo das tabelas';
|
||||
$string['dirroot'] = 'Diretório Moodle';
|
||||
$string['environmenthead'] = 'Verificando o ambiente ...';
|
||||
$string['environmentsub2'] = 'Cada release do Moodle requer uma versão mínima do PHP e diversas extensões do PHP.
|
||||
A verificação completa do ambiente é feita antes de cada instalação e atualização.';
|
||||
$string['errorsinenvironment'] = 'Verificação do Ambiente falhou!';
|
||||
$string['installation'] = 'Instalação';
|
||||
$string['langdownloaderror'] = 'Infelizmente o idioma "{$a}" não foi instalado. A instalação vai continuar em Inglês.';
|
||||
@@ -55,16 +59,25 @@ Com esta operação Moodle será capaz de configurar o limite de memória sózin
|
||||
<p><blockquote>php_value memory_limit 40M</blockquote></p>
|
||||
<p>Alguns servidores não aceitam este procedimento e <b>todas</b> as páginas PHP do servidor ficam bloqueadas ou imprimem mensagens de erro. Neste caso será necessário excluir o arquivo .htaccess .</p>
|
||||
</li></ol>';
|
||||
$string['paths'] = 'Caminhos';
|
||||
$string['pathserrcreatedataroot'] = 'O Diretório de Dados ({&a->dataroot}) não pode ser criado pelo instalador.';
|
||||
$string['pathshead'] = 'Confirme os caminhos';
|
||||
$string['pathsrodataroot'] = 'O Diretório de Dados raiz não pode ser acessada para escrita.';
|
||||
$string['pathsroparentdataroot'] = 'O diretório pai ({$a->parent}) não pode ser escrito. O diretório de dados ({$a->dataroot)) não pode ser criado pelo instalador.';
|
||||
$string['pathssubadmindir'] = 'Alguns poucos webhosts usam /admin como um URL especial para acesso ao painel de controle ou outras coisas. Infelizmente isto conflita com a localizaçao padrão das páginas do administrador Moodle. Você pode corrigir isso renomeando a pasta admin na sua instalação, e colocando esse novo nome aqui. Por exemplo: <em>moodleadmin</em>. Isto irá corrigir os links das páginas do administrador Moodle.';
|
||||
$string['pathssubdataroot'] = 'Você precisa de um local onde o Moodle possa salvar arquivos enviados. Este diretório deve possuir permissões de leitura e escrita pelo usuário do servidor web
|
||||
(geralmente \'nobody\' ou \'apache \'), mas não deverá ser acessível diretamente através da web. O instalador irá tentar criá-lo se ele não existir.';
|
||||
$string['pathssubdirroot'] = 'Caminho completo do diretório para instalação do Moddle.';
|
||||
$string['pathssubwwwroot'] = 'Endereço web completo onde o Moodle será acessado.
|
||||
Não é possível acessar o Moodle usando múltiplos endereços. Se seu site tem múltiplos endereços públicos você deve configurar redirecionamentos permantentes em todos eles exceto esse. Se seu site é acessado tanto da Intranet como Internet, use o endereço público aqui e configure o DNS para que os usuários da Intranet possam usar o endereço público também. Se o endereço não estiver correto, por favo mude a URL no seu navegador para reiniciar a instalação com um valor diferente.';
|
||||
$string['pathsunsecuredataroot'] = 'A localização da pasta de dados não é segura.';
|
||||
$string['pathswrongadmindir'] = 'Diretório Admin não existe';
|
||||
$string['phpextension'] = 'Extensão PHP {$a}';
|
||||
$string['phpversion'] = 'Versão do PHP';
|
||||
$string['phpversionhelp'] = '<p>Moodle requer a versão 4.1.0 de PHP ou posterior.</p>
|
||||
<p>A sua versão é {$a}</p>
|
||||
<p>Atualize a versão do PHP!</p>';
|
||||
$string['phpversionhelp'] = '<p>Moodle requer a versão 4.3.0 de PHP ou posterior.</p>
|
||||
<p>A sua versão é a {$a}</p>
|
||||
<p>Atualize a versão do PHP!</p>
|
||||
(atenção, a versão 5.0.x tem muitos problemas - use a versão 5.1.0 ou a 4.4)';
|
||||
$string['welcomep10'] = '{$a->installername} ({$a->installerversion})';
|
||||
$string['welcomep20'] = 'Se você chegou nesta página, o pacote <strong>{$a->packname} {$a->packversion}</strong> foi instalado. Parabéns!';
|
||||
$string['welcomep30'] = 'Esta versão do <strong>{$a->installername}</strong> inclui as aplicações para a criação de um ambiente em que <strong>Moodle</strong> possa operar:';
|
||||
|
||||
@@ -30,8 +30,10 @@
|
||||
|
||||
$string['clianswerno'] = 'n';
|
||||
$string['cliansweryes'] = 'y';
|
||||
$string['cliincorrectvalueerror'] = 'Fel, värdet "{$a->value}" för "{$a->option}" är inte korrekt.';
|
||||
$string['cliincorrectvalueretry'] = 'Felaktigt värde, var snäll och försök igen';
|
||||
$string['clitypevalue'] = 'Värde för typ';
|
||||
$string['clitypevaluedefault'] = 'skriv in värdet, klicka på "Enter" om Du vill använda standardvärdet ({$a})';
|
||||
$string['cliunknowoption'] = 'Ej identifierade alternativ: {$a} Var snäll och använd alternativet Hjälp.';
|
||||
$string['cliyesnoprompt'] = 'skriv in y (betyder ja) eller n (betyder nej)';
|
||||
$string['environmentrequireinstall'] = 'är nödvändig att installera/aktivera';
|
||||
|
||||
+4
-2
@@ -27,11 +27,11 @@ $string['accessdenied'] = 'Access denied';
|
||||
$string['accounts'] = 'Accounts';
|
||||
$string['additionalhtml'] = 'Additional HTML';
|
||||
$string['additionalhtml_heading'] = 'Additional HTML to be added to every page.';
|
||||
$string['additionalhtml_desc'] = 'These settings allow you to specify HTML that you want added to every page. You can set HTML that will be added within the HEAD tag for the page, immediatly after the BODY tag has been opened, or immediatly before the body tag is closed.<br />Doing this allows you add custom headers or footers on every page, or add support for services like Google Analytics very easily and independent of your chosen theme.';
|
||||
$string['additionalhtml_desc'] = 'These settings allow you to specify HTML that you want added to every page. You can set HTML that will be added within the HEAD tag for the page, immediately after the BODY tag has been opened, or immediately before the body tag is closed.<br />Doing this allows you add custom headers or footers on every page, or add support for services like Google Analytics very easily and independent of your chosen theme.';
|
||||
$string['additionalhtmlhead'] = 'Within HEAD';
|
||||
$string['additionalhtmlhead_desc'] = 'Content here will be added to the bottom of the HEAD tag for every page.';
|
||||
$string['additionalhtmltopofbody'] = 'When BODY is opened';
|
||||
$string['additionalhtmltopofbody_desc'] = 'Content here will be added in to every page immediatly after the opening body tag.';
|
||||
$string['additionalhtmltopofbody_desc'] = 'Content here will be added in to every page immediately after the opening body tag.';
|
||||
$string['additionalhtmlfooter'] = 'Before BODY is closed';
|
||||
$string['additionalhtmlfooter_desc'] = 'Content here will be added in to every page right before the body tag is closed.';
|
||||
$string['adminseesall'] = 'Admins see all';
|
||||
@@ -429,6 +429,8 @@ $string['debugsmtp'] = 'Debug email sending';
|
||||
$string['debugstringids'] = 'Show origin of languages strings';
|
||||
$string['debugvalidators'] = 'Show validator links';
|
||||
$string['defaultallowedmodules'] = 'Default allowed modules';
|
||||
$string['defaultcity'] = 'Default city';
|
||||
$string['defaultcity_help'] = 'A city entered here will be the default city when creating new user accounts.';
|
||||
$string['defaulthomepage'] = 'Default home page for users';
|
||||
$string['defaultrequestcategory'] = 'Default category for course requests';
|
||||
$string['defaultsettinginfo'] = 'Default: {$a}';
|
||||
|
||||
@@ -34,7 +34,7 @@ $string['exportdata'] = 'Export data';
|
||||
$string['exportschemaexception'] = 'Current database structure does not match all install.xml files. <br /> {$a}';
|
||||
$string['checkingsourcetables'] = 'Checking source table structure';
|
||||
$string['importschemaexception'] = 'Current database structure does not match all install.xml files. <br /> {$a}';
|
||||
$string['importversionmismatchexception'] = 'Current version {$a->currentver} does match exported version {$a->schemaver}.';
|
||||
$string['importversionmismatchexception'] = 'Current version {$a->currentver} does not match exported version {$a->schemaver}.';
|
||||
$string['malformedxmlexception'] = 'Malformed XML found, can not continue.';
|
||||
$string['notargetconectexception'] = 'Can not connect target database, sorry.';
|
||||
$string['transferdata'] = 'Transfer data';
|
||||
|
||||
@@ -107,7 +107,6 @@ $string['field1030303']='Mining Engineering';
|
||||
$string['field1030305']='Materials Engineering';
|
||||
$string['field1030307']='Food Processing Technology';
|
||||
$string['field1030399']='Process and Resources Engineering (Other)';
|
||||
$string['field1030399']='Process and Resources Engineering (Other)';
|
||||
$string['field10305']='Automotive Engineering and Technology';
|
||||
$string['field1030501']='Automotive Engineering';
|
||||
$string['field1030503']='Vehicle Mechanics';
|
||||
|
||||
@@ -555,7 +555,6 @@ $string['showcalculations'] = 'Show calculations';
|
||||
$string['showcalculations_help'] = 'If enabled, when editing is turned on, a calculator icon is shown for each grade item and category, with tool tips over calculated items and a visual indicator that a column is calculated.';
|
||||
$string['showeyecons'] = 'Show show/hide icons';
|
||||
$string['showeyecons_help'] = 'If enabled, when editing is turned on, a show/hide icon is shown for each grade for controlling its visibility to the student.';
|
||||
$string['showfeedback'] = 'Show feedback';
|
||||
$string['showgroups'] = 'Show groups';
|
||||
$string['showhiddenitems'] = 'Show hidden items';
|
||||
$string['showhiddenitems_help'] = 'Whether hidden grade items are hidden entirely or if the names of hidden grade items are visible to students.
|
||||
|
||||
@@ -114,6 +114,15 @@ $string['groupsseparate'] = 'Separate groups';
|
||||
$string['groupsvisible'] = 'Visible groups';
|
||||
$string['grouptemplate'] = 'Group @';
|
||||
$string['hidepicture'] = 'Hide picture';
|
||||
$string['importgroups'] = 'Import groups';
|
||||
$string['importgroups_help'] = 'Groups may be imported via text file. The format of the file should be as follows:
|
||||
|
||||
* Each line of the file contains one record
|
||||
* Each record is a series of data separated by commas
|
||||
* The first record contains a list of fieldnames defining the format of the rest of the file
|
||||
* Required fieldname is groupname
|
||||
* Optional fieldnames are description, enrolmentkey, picture, hidepicture';
|
||||
$string['importgroups_link'] = 'group/import';
|
||||
$string['javascriptrequired'] = 'This page requires JavaScript to be enabled.';
|
||||
$string['members'] = 'Members per group';
|
||||
$string['membersofselectedgroup'] = 'Members of:';
|
||||
|
||||
+4
-3
@@ -105,7 +105,6 @@ $string['forceunregister'] = 'Yes, clean registration data';
|
||||
$string['forceunregisterconfirmation'] = 'Your site cannot reach {$a}. This hub could be temporarily down. Unless you are sure you want to continue to remove registration locally, please cancel and try again later.';
|
||||
$string['geolocation'] = 'Geolocation';
|
||||
$string['geolocation_help'] = 'In future we may provide location-based searching. If you want to specify the location for your course use a latitude/longitude value here (eg: -31.947884,115.871285). One way to find this is to use Google Maps.';
|
||||
$string['siteemail'] = 'Email address';
|
||||
$string['hub'] = 'Hub';
|
||||
$string['imageurl'] = 'Image URL';
|
||||
$string['imageurl_help'] = 'This image will be displayed on the hub. This image must be available from the hub at any moment. The image should have a maximum size of {$a->width} X {$a->height}';
|
||||
@@ -143,6 +142,7 @@ $string['participantnumberaverage'] = 'Average number of participants ({$a})';
|
||||
$string['postaladdress'] = 'Postal address';
|
||||
$string['postaladdress_help'] = 'Postal address of this site, or of the entity represented by this site.';
|
||||
$string['postsnumber'] = 'Number of posts ({$a})';
|
||||
$string['previousregistrationdeleted'] = 'The previous registration has been deleted from {$a}. You can restart the registration process. Thank you.';
|
||||
$string['prioritise'] = 'Prioritise';
|
||||
$string['privacy'] = 'Privacy';
|
||||
$string['privacy_help'] = 'The hub may want to display a list of registered sites. If it does then you can choose whether or not you want to appear on that list.';
|
||||
@@ -175,7 +175,9 @@ $string['registrationconfirmedon'] = 'You are now registered on the hub {$a}. Yo
|
||||
$string['registrationupdated'] = 'Registration has been updated.';
|
||||
$string['registrationupdatedfailed'] = 'Registration update failed.';
|
||||
$string['removefromhub'] = 'Remove from hub';
|
||||
$string['renewregistration'] = 'Renew registration';
|
||||
$string['resourcesnumber'] = 'Number of resources ({$a})';
|
||||
$string['restartregistration'] = 'Restart registration';
|
||||
$string['roleassignmentsnumber'] = 'Number of role assignments ({$a})';
|
||||
$string['screenshots'] = 'Screenshots';
|
||||
$string['screenshots_help'] = 'Any screenshots of the course will be displayed in search results.';
|
||||
@@ -207,7 +209,7 @@ $string['sitedesc_help'] = 'This description of your site may be shown in the si
|
||||
$string['sitegeolocation'] = 'Geolocation';
|
||||
$string['sitegeolocation_help'] = 'In future we may provide location-based searching in the hubs. If you want to specify the location for your site use a latitude/longitude value here (eg: -31.947884,115.871285). One way to find this is to use Google Maps.';
|
||||
$string['siteemail'] = 'Email address';
|
||||
$string['siteemail_help'] = 'You need to provide an email address so the admin can contact you if necessary. This will not be used for any other purpose.';
|
||||
$string['siteemail_help'] = 'You need to provide an email address so the hub administrator can contact you if necessary. This will not be used for any other purpose. It is recommended to enter a email address related to a position (example: [email protected]) and not directly to a person.';
|
||||
$string['sitelang'] = 'Language';
|
||||
$string['sitelang_help'] = 'Your site language will be displayed on the site listing.';
|
||||
$string['sitename'] = 'Name';
|
||||
@@ -241,7 +243,6 @@ $string['statistics'] = 'Statistics privacy';
|
||||
$string['status'] = 'Hub listing';
|
||||
$string['statuspublished'] = 'Listed';
|
||||
$string['statusunpublished'] = 'Not listed';
|
||||
$string['subject'] = 'Subject';
|
||||
$string['tags'] = 'Tags';
|
||||
$string['tags_help'] = 'Tags help to further categorise your course and help it to be found. Please use simple, meaningful words and separate them with a comma. Example: math, algebra, geometry';
|
||||
$string['trustme'] = 'Trust';
|
||||
|
||||
@@ -65,6 +65,8 @@ $string['loggedoff'] = 'Not online';
|
||||
$string['loggedoffdescription'] = 'When I\'m offline';
|
||||
$string['managecontacts'] = 'Manage my contacts';
|
||||
$string['mostrecent'] = 'Recent messages';
|
||||
$string['mostrecentconversations'] = 'Recent conversations';
|
||||
$string['mostrecentnotifications'] = 'Recent notifications';
|
||||
$string['mailsent'] = 'Your message was sent via email.';
|
||||
$string['maxmessages'] = 'Maximum number of messages to show in the discussion history';
|
||||
$string['message'] = 'Message';
|
||||
@@ -93,6 +95,7 @@ $string['private_config'] = 'Popup message window';
|
||||
$string['processortag'] = 'Destination';
|
||||
$string['providers_config'] = 'Configure notification methods for incoming messages';
|
||||
$string['providerstag'] = 'Source';
|
||||
$string['recent'] = 'Recent';
|
||||
$string['readmessages'] = '{$a} read messages';
|
||||
$string['removecontact'] = 'Remove contact';
|
||||
$string['savemysettings'] = 'Save my settings';
|
||||
|
||||
@@ -859,7 +859,6 @@ $string['importdata'] = 'Import course data';
|
||||
$string['importdataexported'] = 'Exported data from \'from\' course successfully.<br /> Continue to import into your \'to\' course.';
|
||||
$string['importdatafinished'] = 'Import complete! Continue to your course';
|
||||
$string['importdatafrom'] = 'Find a course to import data from:';
|
||||
$string['importgroups'] = 'Import groups';
|
||||
$string['inactive'] = 'Inactive';
|
||||
$string['include'] = 'Include';
|
||||
$string['includeallusers'] = 'Include all users';
|
||||
|
||||
+5
-1
@@ -2352,6 +2352,10 @@ function get_context_info_array($contextid) {
|
||||
* @return int|bool related course id or false
|
||||
*/
|
||||
function get_courseid_from_context($context) {
|
||||
if (empty($context->contextlevel)) {
|
||||
debugging('Invalid context object specified in get_courseid_from_context() call');
|
||||
return false;
|
||||
}
|
||||
if ($context->contextlevel == CONTEXT_COURSE) {
|
||||
return $context->instanceid;
|
||||
}
|
||||
@@ -2370,7 +2374,7 @@ function get_courseid_from_context($context) {
|
||||
if ($context->contextlevel == CONTEXT_BLOCK) {
|
||||
$parentcontexts = get_parent_contexts($context, false);
|
||||
$parent = reset($parentcontexts);
|
||||
return get_courseid_from_context($parent);
|
||||
return get_courseid_from_context(get_context_instance_by_id($parent));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+50
-6
@@ -739,7 +739,7 @@ interface parentable_part_of_admin_tree extends part_of_admin_tree {
|
||||
*/
|
||||
class admin_category implements parentable_part_of_admin_tree {
|
||||
|
||||
/** @var mixed An array of part_of_admin_tree objects that are this object's children */
|
||||
/** @var mixed An array of part_of_admin_tree objects that are this object's children */
|
||||
public $children;
|
||||
/** @var string An internal name for this category. Must be unique amongst ALL part_of_admin_tree objects */
|
||||
public $name;
|
||||
@@ -752,6 +752,9 @@ class admin_category implements parentable_part_of_admin_tree {
|
||||
/** @var mixed Either a string or an array or strings */
|
||||
public $visiblepath;
|
||||
|
||||
/** @var array fast lookup category cache, all categories of one tree point to one cache */
|
||||
protected $category_cache;
|
||||
|
||||
/**
|
||||
* Constructor for an empty admin category
|
||||
*
|
||||
@@ -775,6 +778,11 @@ class admin_category implements parentable_part_of_admin_tree {
|
||||
* defaults to false
|
||||
*/
|
||||
public function locate($name, $findpath=false) {
|
||||
if (is_array($this->category_cache) and !isset($this->category_cache[$this->name])) {
|
||||
// somebody much have purged the cache
|
||||
$this->category_cache[$this->name] = $this;
|
||||
}
|
||||
|
||||
if ($this->name == $name) {
|
||||
if ($findpath) {
|
||||
$this->visiblepath[] = $this->visiblename;
|
||||
@@ -783,6 +791,11 @@ class admin_category implements parentable_part_of_admin_tree {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// quick category lookup
|
||||
if (!$findpath and is_array($this->category_cache) and isset($this->category_cache[$name])) {
|
||||
return $this->category_cache[$name];
|
||||
}
|
||||
|
||||
$return = NULL;
|
||||
foreach($this->children as $childid=>$unused) {
|
||||
if ($return = $this->children[$childid]->locate($name, $findpath)) {
|
||||
@@ -831,11 +844,16 @@ class admin_category implements parentable_part_of_admin_tree {
|
||||
|
||||
foreach($this->children as $precedence => $child) {
|
||||
if ($child->name == $name) {
|
||||
// found it!
|
||||
// clear cache and delete self
|
||||
if (is_array($this->category_cache)) {
|
||||
while($this->category_cache) {
|
||||
// delete the cache, but keep the original array address
|
||||
array_pop($this->category_cache);
|
||||
}
|
||||
}
|
||||
unset($this->children[$precedence]);
|
||||
return true;
|
||||
}
|
||||
if ($this->children[$precedence]->prune($name)) {
|
||||
} else if ($this->children[$precedence]->prune($name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -862,6 +880,25 @@ class admin_category implements parentable_part_of_admin_tree {
|
||||
return false;
|
||||
}
|
||||
$parent->children[] = $something;
|
||||
if (is_array($this->category_cache) and ($something instanceof admin_category)) {
|
||||
if (isset($this->category_cache[$something->name])) {
|
||||
debugging('Duplicate admin catefory name: '.$something->name);
|
||||
} else {
|
||||
$this->category_cache[$something->name] = $something;
|
||||
$something->category_cache =& $this->category_cache;
|
||||
foreach ($something->children as $child) {
|
||||
// just in case somebody already added subcategories
|
||||
if ($child instanceof admin_category) {
|
||||
if (isset($this->category_cache[$child->name])) {
|
||||
debugging('Duplicate admin catefory name: '.$child->name);
|
||||
} else {
|
||||
$this->category_cache[$child->name] = $child;
|
||||
$child->category_cache =& $this->category_cache;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
@@ -938,6 +975,8 @@ class admin_root extends admin_category {
|
||||
$this->fulltree = $fulltree;
|
||||
$this->loaded = false;
|
||||
|
||||
$this->category_cache = array();
|
||||
|
||||
// load custom defaults if found
|
||||
$this->custom_defaults = null;
|
||||
$defaultsfile = "$CFG->dirroot/local/defaults.php";
|
||||
@@ -959,6 +998,11 @@ class admin_root extends admin_category {
|
||||
$this->children = array();
|
||||
$this->fulltree = ($requirefulltree || $this->fulltree);
|
||||
$this->loaded = false;
|
||||
//break circular dependencies - this helps PHP 5.2
|
||||
while($this->category_cache) {
|
||||
array_pop($this->category_cache);
|
||||
}
|
||||
$this->category_cache = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5436,7 +5480,7 @@ class admin_page_managefilters extends admin_externalpage {
|
||||
* This function must be called on each admin page before other code.
|
||||
*
|
||||
* @global moodle_page $PAGE
|
||||
*
|
||||
*
|
||||
* @param string $section name of page
|
||||
* @param string $extrabutton extra HTML that is added after the blocks editing on/off button.
|
||||
* @param array $extraurlparams an array paramname => paramvalue, or parameters that need to be
|
||||
@@ -5498,7 +5542,7 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
|
||||
$PAGE->set_cacheable(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Locate the current item on the navigation and make it active when found.
|
||||
$path = $extpage->path;
|
||||
$node = $PAGE->settingsnav;
|
||||
|
||||
+7
-5
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20110125" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20110209" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -50,8 +50,9 @@
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="type"/>
|
||||
<FIELD NAME="type" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" COMMENT="type: 0==info, 1==notice, 2==error" PREVIOUS="id" NEXT="plugin"/>
|
||||
<FIELD NAME="plugin" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" PREVIOUS="type" NEXT="version"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="plugin or main version if known" PREVIOUS="plugin" NEXT="info"/>
|
||||
<FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="version" NEXT="details"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="plugin or main version if known" PREVIOUS="plugin" NEXT="targetversion"/>
|
||||
<FIELD NAME="targetversion" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="version of plugin or core specified in version.php at the time of upgrade loggging" PREVIOUS="version" NEXT="info"/>
|
||||
<FIELD NAME="info" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="targetversion" NEXT="details"/>
|
||||
<FIELD NAME="details" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="info" NEXT="backtrace"/>
|
||||
<FIELD NAME="backtrace" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="details" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="backtrace" NEXT="timemodified"/>
|
||||
@@ -2623,10 +2624,11 @@
|
||||
<TABLE NAME="registration_hubs" COMMENT="hub where the site is registered on with their associated token" PREVIOUS="license" NEXT="backup_controllers">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="token"/>
|
||||
<FIELD NAME="token" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="hubname"/>
|
||||
<FIELD NAME="token" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="the token to communicate with the hub by web service" PREVIOUS="id" NEXT="hubname"/>
|
||||
<FIELD NAME="hubname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="token" NEXT="huburl"/>
|
||||
<FIELD NAME="huburl" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="hubname" NEXT="confirmed"/>
|
||||
<FIELD NAME="confirmed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="huburl"/>
|
||||
<FIELD NAME="confirmed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="huburl" NEXT="secret"/>
|
||||
<FIELD NAME="secret" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="the unique site identifier for this hub" PREVIOUS="confirmed"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
||||
+42
-3
@@ -74,6 +74,7 @@ function xmldb_main_upgrade($oldversion) {
|
||||
$table->add_field('type', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('version', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('targetversion', XMLDB_TYPE_CHAR, '100', null, null, null, null);
|
||||
$table->add_field('info', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('details', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
$table->add_field('backtrace', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
|
||||
@@ -4090,10 +4091,12 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
}
|
||||
|
||||
if ($oldversion < 2010061900.10) {
|
||||
// migrate existing setup of meta courses
|
||||
// migrate existing setup of meta courses, ignore records referencing invalid courses
|
||||
$sql = "INSERT INTO {enrol} (enrol, status, courseid, sortorder, customint1)
|
||||
SELECT 'meta', 0, parent_course, 5, child_course
|
||||
FROM {course_meta}";
|
||||
SELECT 'meta', 0, cm.parent_course, 5, cm.child_course
|
||||
FROM {course_meta} cm
|
||||
JOIN {course} p ON p.id = cm.parent_course
|
||||
JOIN {course} c ON c.id = cm.child_course";
|
||||
$DB->execute($sql);
|
||||
|
||||
upgrade_main_savepoint(true, 2010061900.10);
|
||||
@@ -6005,6 +6008,42 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
|
||||
upgrade_main_savepoint(true, 2011012501);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011020200.01) {
|
||||
|
||||
// Define field targetversion to be added to upgrade_log
|
||||
$table = new xmldb_table('upgrade_log');
|
||||
$field = new xmldb_field('targetversion', XMLDB_TYPE_CHAR, '100', null, null, null, null, 'version');
|
||||
|
||||
// Conditionally launch add field targetversion
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2011020200.01);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011020900.07) {
|
||||
$DB->delete_records('course_display', array('display' => 0));
|
||||
upgrade_main_savepoint(true, 2011020900.07);
|
||||
}
|
||||
|
||||
if ($oldversion < 2011020900.08) {
|
||||
// Define field secret to be added to registration_hubs
|
||||
$table = new xmldb_table('registration_hubs');
|
||||
$field = new xmldb_field('secret', XMLDB_TYPE_CHAR, '255', null, null, null,
|
||||
$CFG->siteidentifier, 'confirmed');
|
||||
|
||||
// Conditionally launch add field secret
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Main savepoint reached
|
||||
upgrade_main_savepoint(true, 2011020900.08);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -396,7 +396,10 @@ class oracle_sql_generator extends sql_generator {
|
||||
/// - drop the old column
|
||||
/// - rename the temp column to the original name
|
||||
if (($typechanged) || (($oldmetatype == 'N' || $oldmetatype == 'I') && ($precisionchanged || $decimalchanged))) {
|
||||
$tempcolname = $xmldb_field->getName() . '_alter_column_tmp';
|
||||
$tempcolname = $xmldb_field->getName() . '___tmp'; // Short tmp name, surely not conflicting ever
|
||||
if (strlen($tempcolname) > 30) { // Safeguard we don't excess the 30cc limit
|
||||
$tempcolname = 'ongoing_alter_column_tmp';
|
||||
}
|
||||
/// Prevent temp field to have both NULL/NOT NULL and DEFAULT constraints
|
||||
$skip_notnull_clause = true;
|
||||
$skip_default_clause = true;
|
||||
|
||||
@@ -56,6 +56,8 @@ class postgres_sql_generator extends sql_generator {
|
||||
public $rename_key_sql = null; //SQL sentence to rename one key (PostgreSQL doesn't support this!)
|
||||
//TABLENAME, OLDKEYNAME, NEWKEYNAME are dynamically replaced
|
||||
|
||||
protected $std_strings = null; // '' or \' quotes
|
||||
|
||||
/**
|
||||
* Reset a sequence to the id field of a table.
|
||||
* @param string $table name of table or xmldb_table object
|
||||
@@ -404,6 +406,24 @@ class postgres_sql_generator extends sql_generator {
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function addslashes($s) {
|
||||
// Postgres is gradually switching to ANSI quotes, we need to check what is expected
|
||||
if (!isset($this->std_strings)) {
|
||||
$this->std_strings = ($this->mdb->get_field_sql("select setting from pg_settings where name = 'standard_conforming_strings'") === 'on');
|
||||
}
|
||||
|
||||
if ($this->std_strings) {
|
||||
$s = str_replace("'", "''", $s);
|
||||
} else {
|
||||
// do not use php addslashes() because it depends on PHP quote settings!
|
||||
$s = str_replace('\\','\\\\',$s);
|
||||
$s = str_replace("\0","\\\0", $s);
|
||||
$s = str_replace("'", "\\'", $s);
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one xmldb_table returns one string with the sequence of the table
|
||||
* in the table (fetched from DB)
|
||||
|
||||
@@ -56,13 +56,23 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
throw new dml_exception('dbdriverproblem', $driverstatus);
|
||||
}
|
||||
|
||||
if (empty($this->dboptions['dbport'])) {
|
||||
$dbport = ini_get('mysqli.default_port');
|
||||
if (!empty($dboptions['dbsocket'])
|
||||
and (strpos($dboptions['dbsocket'], '/') !== false or strpos($dboptions['dbsocket'], '\\') !== false)) {
|
||||
$dbsocket = $dboptions['dbsocket'];
|
||||
} else {
|
||||
$dbport = (int)$this->dboptions['dbport'];
|
||||
$dbsocket = ini_get('mysqli.default_socket');
|
||||
}
|
||||
if (empty($dboptions['dbport'])) {
|
||||
$dbport = (int)ini_get('mysqli.default_port');
|
||||
} else {
|
||||
$dbport = (int)$dboptions['dbport'];
|
||||
}
|
||||
// verify ini.get does not return nonsense
|
||||
if (empty($dbport)) {
|
||||
$dbport = 3306;
|
||||
}
|
||||
ob_start();
|
||||
$conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport); /// Connect without db
|
||||
$conn = new mysqli($dbhost, $dbuser, $dbpass, '', $dbport, $dbsocket); /// Connect without db
|
||||
$dberr = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$errorno = @$conn->connect_errno;
|
||||
@@ -267,16 +277,21 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
|
||||
// dbsocket is used ONLY if host is NULL or 'localhost',
|
||||
// you can not disable it because it is always tried if dbhost is 'localhost'
|
||||
if (!empty($this->dboptions['dbsocket']) and strpos($this->dboptions['dbsocket'], '/') !== false) {
|
||||
if (!empty($this->dboptions['dbsocket'])
|
||||
and (strpos($this->dboptions['dbsocket'], '/') !== false or strpos($this->dboptions['dbsocket'], '\\') !== false)) {
|
||||
$dbsocket = $this->dboptions['dbsocket'];
|
||||
} else {
|
||||
$dbsocket = ini_get('mysqli.default_socket');
|
||||
}
|
||||
if (empty($this->dboptions['dbport'])) {
|
||||
$dbport = ini_get('mysqli.default_port');
|
||||
$dbport = (int)ini_get('mysqli.default_port');
|
||||
} else {
|
||||
$dbport = (int)$this->dboptions['dbport'];
|
||||
}
|
||||
// verify ini.get does not return nonsense
|
||||
if (empty($dbport)) {
|
||||
$dbport = 3306;
|
||||
}
|
||||
ob_start();
|
||||
$this->mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbsocket);
|
||||
$dberr = ob_get_contents();
|
||||
|
||||
@@ -3610,6 +3610,118 @@ class dml_test extends UnitTestCase {
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlnamed, array('content' => '2')));
|
||||
$this->assertEqual(1, count($records));
|
||||
}
|
||||
|
||||
public function test_limits_and_offsets() {
|
||||
$DB = $this->tdb;
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if (false) $DB = new moodle_database ();
|
||||
|
||||
$table = $this->get_test_table();
|
||||
$tablename = $table->getName();
|
||||
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('content', XMLDB_TYPE_TEXT, 'big', XMLDB_UNSIGNED, XMLDB_NOTNULL);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'a', 'content'=>'one')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'b', 'content'=>'two')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'c', 'content'=>'three')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'd', 'content'=>'four')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'e', 'content'=>'five')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'f', 'content'=>'six')));
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 4));
|
||||
$this->assertEqual(2, count($records));
|
||||
$this->assertEqual('e', reset($records)->name);
|
||||
$this->assertEqual('f', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertFalse($records = $DB->get_records_sql($sqlqm, null, 8));
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 0, 4));
|
||||
$this->assertEqual(4, count($records));
|
||||
$this->assertEqual('a', reset($records)->name);
|
||||
$this->assertEqual('d', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 0, 8));
|
||||
$this->assertEqual(6, count($records));
|
||||
$this->assertEqual('a', reset($records)->name);
|
||||
$this->assertEqual('f', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 1, 4));
|
||||
$this->assertEqual(4, count($records));
|
||||
$this->assertEqual('b', reset($records)->name);
|
||||
$this->assertEqual('e', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT *
|
||||
FROM {{$tablename}}";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 4, 4));
|
||||
$this->assertEqual(2, count($records));
|
||||
$this->assertEqual('e', reset($records)->name);
|
||||
$this->assertEqual('f', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT t.*, t.name AS test
|
||||
FROM {{$tablename}} t
|
||||
ORDER BY t.id ASC";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 4, 4));
|
||||
$this->assertEqual(2, count($records));
|
||||
$this->assertEqual('e', reset($records)->name);
|
||||
$this->assertEqual('f', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT DISTINCT t.name, t.name AS test
|
||||
FROM {{$tablename}} t
|
||||
ORDER BY t.name DESC";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 4, 4));
|
||||
$this->assertEqual(2, count($records));
|
||||
$this->assertEqual('b', reset($records)->name);
|
||||
$this->assertEqual('a', end($records)->name);
|
||||
|
||||
$sqlqm = "SELECT 1
|
||||
FROM {{$tablename}} t
|
||||
WHERE t.name = 'a'";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 0, 1));
|
||||
$this->assertEqual(1, count($records));
|
||||
|
||||
$sqlqm = "SELECT 'constant'
|
||||
FROM {{$tablename}} t
|
||||
WHERE t.name = 'a'";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 0, 8));
|
||||
$this->assertEqual(1, count($records));
|
||||
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'a', 'content'=>'one')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'b', 'content'=>'two')));
|
||||
$this->assertTrue($DB->insert_record($tablename, array('name' => 'c', 'content'=>'three')));
|
||||
|
||||
$sqlqm = "SELECT t.name, COUNT(DISTINCT t2.id) AS count, 'Test' AS teststring
|
||||
FROM {{$tablename}} t
|
||||
LEFT JOIN (
|
||||
SELECT t.id, t.name
|
||||
FROM {{$tablename}} t
|
||||
) t2 ON t2.name = t.name
|
||||
GROUP BY t.name
|
||||
ORDER BY t.name ASC";
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm));
|
||||
$this->assertEqual(6, count($records)); // a,b,c,d,e,f
|
||||
$this->assertEqual(2, reset($records)->count); // a has 2 records now
|
||||
$this->assertEqual(1, end($records)->count); // f has 1 record still
|
||||
|
||||
$this->assertTrue($records = $DB->get_records_sql($sqlqm, null, 0, 2));
|
||||
$this->assertEqual(2, count($records));
|
||||
$this->assertEqual(2, reset($records)->count);
|
||||
$this->assertEqual(2, end($records)->count);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -771,7 +771,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
* @return string sql
|
||||
*/
|
||||
private function limit_to_top_n($sql, $offset, $limit) {
|
||||
// If there is no limit we can return immediatly
|
||||
// If there is no limit we can return immediately
|
||||
if ($limit < 1 && $offset < 1) {
|
||||
return $sql;
|
||||
}
|
||||
@@ -797,23 +797,17 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
$firstcolumn = 'id'; // The default first column is id
|
||||
$orderby = ''; // The order by of the main query
|
||||
|
||||
// We need to find all the columns so that we can request JUST the desired
|
||||
// columns in the end transaction. We also need to do a couple of maintenance
|
||||
// tasks on the columns seeing as they are going to be wrapped in a
|
||||
// sub select.
|
||||
// We need to do a couple of maintenance tasks on the columns seeing as
|
||||
// they are going to be wrapped in a sub select.
|
||||
//
|
||||
// 1. Collect the first column to use for an order by if there isn't an
|
||||
// explicit order by within the query.
|
||||
// 2. Make we use the aliases for columns that have it because of next point.
|
||||
// 3. Strip off table aliases they will be incorrect outside of the immediate
|
||||
// sub select.
|
||||
// 4. Give all constant columns a proper alias, this is required because
|
||||
// 2. Give all constant columns a proper alias, this is required because
|
||||
// of the subselect.
|
||||
if (preg_match('#^(\s*SELECT\s+)(DISTINCT\s+)?(.*?)(\sFROM\s)#is', $sql, $columnmatches)) {
|
||||
// Make sure we have some columns
|
||||
if (!empty($columnmatches[3])) {
|
||||
$columns = explode(',', $columnmatches[3]);
|
||||
$columnnames = array();
|
||||
$firstcolumn = null;
|
||||
$constantcount = 0;
|
||||
foreach ($columns as $key=>$column) {
|
||||
@@ -822,7 +816,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
if (preg_match('#\sAS\s+(\w+)\s*$#si', $column, $matches)) {
|
||||
// Make sure we use the column alias if available.
|
||||
$column = $matches[1];
|
||||
} else if (preg_match("#^'[^']*'$#", $column)) {
|
||||
} else if (preg_match("#^('[^']*'|\d+)$#", $column)) {
|
||||
// Give constants an alias in the main query and use the
|
||||
// alias for the new outer queries.
|
||||
$constantcount++;
|
||||
@@ -834,16 +828,8 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
if ($firstcolumn === null) {
|
||||
$firstcolumn = $column;
|
||||
}
|
||||
|
||||
// Remove any table aliases from the column name for the outer
|
||||
// queries.
|
||||
if (preg_match('#^\w+\.(.*)$#s', $column, $matches)) {
|
||||
$column = $matches[1];
|
||||
}
|
||||
$columnnames[] = $column;
|
||||
}
|
||||
// Glue things back together
|
||||
$columnnames = join(', ', $columnnames);
|
||||
$columns = join(', ', $columns);
|
||||
// Switch out the fixed main columns (added constant aliases).
|
||||
$sql = str_replace($columnmatches[0], $columnmatches[1].$columnmatches[2].$columns.$columnmatches[4], $sql);
|
||||
@@ -867,10 +853,18 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
$orderby = 'id';
|
||||
}
|
||||
|
||||
// Now we need to build the queries up so that we collect a row count field and then sort on it.
|
||||
// To do this we need to nest the query twice. The first nesting selects all the rows from the
|
||||
// query and then proceeds to use OVER to generate a row number.
|
||||
// The second nesting we limit by selecting where rownumber between offset and limit
|
||||
// In both cases we will select the original query fields using q.* this is important
|
||||
// as there can be any number of crafty things going on. It does however mean that we
|
||||
// end up with the first field being sqlsrvrownumber however sqlsrv_native_moodle_recordset
|
||||
// strips that off during processing if it exists.
|
||||
// Build the inner outer query.
|
||||
$sql = "SELECT TOP $bigint ROW_NUMBER() OVER(ORDER BY $orderby) AS sqlsrvrownumber, $columnnames FROM ($sql) AS q";
|
||||
$sql = "SELECT TOP $bigint ROW_NUMBER() OVER(ORDER BY $orderby) AS sqlsrvrownumber, q.* FROM ($sql) AS q";
|
||||
// Build the outer most query.
|
||||
$sql = "SELECT $columnnames FROM ($sql) AS q WHERE q.sqlsrvrownumber > $offset AND q.sqlsrvrownumber <= $limit";
|
||||
$sql = "SELECT q.* FROM ($sql) AS q WHERE q.sqlsrvrownumber > $offset AND q.sqlsrvrownumber <= $limit";
|
||||
|
||||
// Return the now mangled query for use.
|
||||
return $sql;
|
||||
|
||||
@@ -44,6 +44,7 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
|
||||
private function fetch_next() {
|
||||
if ($row = sqlsrv_fetch_array($this->rsrc, SQLSRV_FETCH_ASSOC)) {
|
||||
unset($row['sqlsrvrownumber']);
|
||||
$row = array_change_key_case($row, CASE_LOWER);
|
||||
}
|
||||
return $row;
|
||||
|
||||
+18
-10
@@ -719,18 +719,26 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
|
||||
return null;
|
||||
}
|
||||
|
||||
// relink embedded files if text submitted - no absolute links allowed in database!
|
||||
if ($CFG->slasharguments) {
|
||||
$draftbase = "$CFG->wwwroot/draftfile.php/$usercontext->id/user/draft/$draftitemid/";
|
||||
} else {
|
||||
$draftbase = "$CFG->wwwroot/draftfile.php?file=/$usercontext->id/user/draft/$draftitemid/";
|
||||
}
|
||||
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
if ($forcehttps) {
|
||||
$draftbase = str_replace('http://', 'https://', $draftbase);
|
||||
$wwwroot = str_replace('http://', 'https://', $wwwroot);
|
||||
}
|
||||
|
||||
// relink embedded files if text submitted - no absolute links allowed in database!
|
||||
$text = str_ireplace("$wwwroot/draftfile.php/$usercontext->id/user/draft/$draftitemid/", '@@PLUGINFILE@@/', $text);
|
||||
|
||||
if (strpos($text, 'draftfile.php?file=') !== false) {
|
||||
$matches = array();
|
||||
preg_match_all("!$wwwroot/draftfile.php\?file=%2F{$usercontext->id}%2Fuser%2Fdraft%2F{$draftitemid}%2F[^'\",&<>|`\s:\\\\]+!iu", $text, $matches);
|
||||
if ($matches) {
|
||||
foreach ($matches[0] as $match) {
|
||||
$replace = str_ireplace('%2F', '/', $match);
|
||||
$text = str_replace($match, $replace, $text);
|
||||
}
|
||||
}
|
||||
$text = str_ireplace("$wwwroot/draftfile.php?file=/$usercontext->id/user/draft/$draftitemid/", '@@PLUGINFILE@@/', $text);
|
||||
}
|
||||
|
||||
$text = str_ireplace($draftbase, '@@PLUGINFILE@@/', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -1704,7 +1712,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
|
||||
$ranges = false;
|
||||
}
|
||||
if ($ranges) {
|
||||
$handle = fopen($filename, 'rb');
|
||||
$handle = fopen($path, 'rb');
|
||||
byteserving_send_file($handle, $mimetype, $ranges, $filesize);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -45,17 +45,17 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* contexturlname - the display text for contexturl
|
||||
*
|
||||
* @param object $eventdata information about the message (component, userfrom, userto, ...)
|
||||
* @return boolean success
|
||||
* @return int|false the ID of the new message or false if there was a problem with a processor
|
||||
*/
|
||||
function message_send($eventdata) {
|
||||
global $CFG, $DB;
|
||||
|
||||
//new message ID to return
|
||||
$messageid = false;
|
||||
|
||||
//TODO: we need to solve problems with database transactions here somehow, for now we just prevent transactions - sorry
|
||||
$DB->transactions_forbidden();
|
||||
|
||||
//flag we'll return indicating that all processors ran successfully
|
||||
$success = true;
|
||||
|
||||
if (is_int($eventdata->userto)) {
|
||||
mtrace('message_send() userto is a user ID when it should be a user object');
|
||||
$eventdata->userto = $DB->get_record('user', array('id' => $eventdata->useridto));
|
||||
@@ -130,10 +130,10 @@ function message_send($eventdata) {
|
||||
if ($processor=='none' && $savemessage->notification) {
|
||||
//if they have deselected all processors and its a notification mark it read. The user doesnt want to be bothered
|
||||
$savemessage->timeread = time();
|
||||
$DB->insert_record('message_read', $savemessage);
|
||||
$messageid = $DB->insert_record('message_read', $savemessage);
|
||||
} else { // Process the message
|
||||
// Store unread message just in case we can not send it
|
||||
$savemessage->id = $DB->insert_record('message', $savemessage);
|
||||
$messageid = $savemessage->id = $DB->insert_record('message', $savemessage);
|
||||
$eventdata->savedmessageid = $savemessage->id;
|
||||
|
||||
// Try to deliver the message to each processor
|
||||
@@ -151,12 +151,12 @@ function message_send($eventdata) {
|
||||
|
||||
if (!$pclass->send_message($eventdata)) {
|
||||
debugging('Error calling message processor '.$procname);
|
||||
$success = false;
|
||||
$messageid = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debugging('Error finding message processor '.$procname);
|
||||
$success = false;
|
||||
$messageid = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,16 +165,16 @@ function message_send($eventdata) {
|
||||
//unread. To prevent this mark the message read if messaging is disabled
|
||||
if (empty($CFG->messaging)) {
|
||||
require_once($CFG->dirroot.'/message/lib.php');
|
||||
message_mark_message_read($savemessage, time());
|
||||
$messageid = message_mark_message_read($savemessage, time());
|
||||
} else if ( $DB->count_records('message_working', array('unreadmessageid' => $savemessage->id)) == 0){
|
||||
//if there is no more processors that want to process this we can move message to message_read
|
||||
require_once($CFG->dirroot.'/message/lib.php');
|
||||
message_mark_message_read($savemessage, time(), true);
|
||||
$messageid = message_mark_message_read($savemessage, time(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
return $messageid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+25
-24
@@ -4,12 +4,13 @@
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* In 'debug' mode, Minify can combine files with no minification and
|
||||
* add comments to indicate line #s of the original files.
|
||||
*
|
||||
* To allow debugging, set this option to true and add "&debug=1" to
|
||||
* In 'debug' mode, Minify can combine files with no minification and
|
||||
* add comments to indicate line #s of the original files.
|
||||
*
|
||||
* To allow debugging, set this option to true and add "&debug=1" to
|
||||
* a URI. E.g. /min/?f=script1.js,script2.js&debug=1
|
||||
*/
|
||||
$min_allowDebugFlag = ($CFG->debug);
|
||||
@@ -20,7 +21,7 @@ $min_allowDebugFlag = ($CFG->debug);
|
||||
* Set to false for no error logging (Minify may be slightly faster).
|
||||
* @link http://www.firephp.org/
|
||||
*
|
||||
* If you want to use a custom error logger, set this to your logger
|
||||
* If you want to use a custom error logger, set this to your logger
|
||||
* instance. Your object should have a method log(string $message).
|
||||
*
|
||||
* @todo cache system does not have error logging yet.
|
||||
@@ -29,10 +30,10 @@ $min_errorLogger = false;
|
||||
|
||||
|
||||
/**
|
||||
* Allow use of the Minify URI Builder app. If you no longer need
|
||||
* Allow use of the Minify URI Builder app. If you no longer need
|
||||
* this, set to false.
|
||||
**/
|
||||
$min_enableBuilder = true;
|
||||
$min_enableBuilder = false;
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,11 +46,11 @@ $min_cachePath = $CFG->dataroot.'/temp';
|
||||
/**
|
||||
* Leave an empty string to use PHP's $_SERVER['DOCUMENT_ROOT'].
|
||||
*
|
||||
* On some servers, this value may be misconfigured or missing. If so, set this
|
||||
* On some servers, this value may be misconfigured or missing. If so, set this
|
||||
* to your full document root path with no trailing slash.
|
||||
* E.g. '/home/accountname/public_html' or 'c:\\xampp\\htdocs'
|
||||
*
|
||||
* If /min/ is directly inside your document root, just uncomment the
|
||||
* If /min/ is directly inside your document root, just uncomment the
|
||||
* second line. The third line might work on some Apache servers.
|
||||
*/
|
||||
$min_documentRoot = $CFG->dirroot.'/lib/minify';
|
||||
@@ -58,7 +59,7 @@ $min_documentRoot = $CFG->dirroot.'/lib/minify';
|
||||
|
||||
|
||||
/**
|
||||
* Cache file locking. Set to false if filesystem is NFS. On at least one
|
||||
* Cache file locking. Set to false if filesystem is NFS. On at least one
|
||||
* NFS system flock-ing attempts stalled PHP for 30 seconds!
|
||||
*/
|
||||
$min_cacheFileLocking = true;
|
||||
@@ -67,9 +68,9 @@ $min_cacheFileLocking = true;
|
||||
/**
|
||||
* Combining multiple CSS files can place @import declarations after rules, which
|
||||
* is invalid. Minify will attempt to detect when this happens and place a
|
||||
* warning comment at the top of the CSS output. To resolve this you can either
|
||||
* move the @imports within your CSS files, or enable this option, which will
|
||||
* move all @imports to the top of the output. Note that moving @imports could
|
||||
* warning comment at the top of the CSS output. To resolve this you can either
|
||||
* move the @imports within your CSS files, or enable this option, which will
|
||||
* move all @imports to the top of the output. Note that moving @imports could
|
||||
* affect CSS values (which is why this option is disabled by default).
|
||||
*/
|
||||
$min_serveOptions['bubbleCssImports'] = false;
|
||||
@@ -92,8 +93,8 @@ $min_serveOptions['maxAge'] = 1800;
|
||||
* particular directories below DOCUMENT_ROOT, set this here.
|
||||
* You will still need to include the directory in the
|
||||
* f or b GET parameters.
|
||||
*
|
||||
* // = shortcut for DOCUMENT_ROOT
|
||||
*
|
||||
* // = shortcut for DOCUMENT_ROOT
|
||||
*/
|
||||
//$min_serveOptions['minApp']['allowDirs'] = array('//js', '//css');
|
||||
|
||||
@@ -113,8 +114,8 @@ $min_serveOptions['minApp']['maxFiles'] = 10;
|
||||
* If you minify CSS files stored in symlink-ed directories, the URI rewriting
|
||||
* algorithm can fail. To prevent this, provide an array of link paths to
|
||||
* target paths, where the link paths are within the document root.
|
||||
*
|
||||
* Because paths need to be normalized for this to work, use "//" to substitute
|
||||
*
|
||||
* Because paths need to be normalized for this to work, use "//" to substitute
|
||||
* the doc root in the link paths (the array keys). E.g.:
|
||||
* <code>
|
||||
* array('//symlink' => '/real/target/path') // unix
|
||||
@@ -126,17 +127,17 @@ $min_symlinks = array();
|
||||
|
||||
/**
|
||||
* If you upload files from Windows to a non-Windows server, Windows may report
|
||||
* incorrect mtimes for the files. This may cause Minify to keep serving stale
|
||||
* incorrect mtimes for the files. This may cause Minify to keep serving stale
|
||||
* cache files when source file changes are made too frequently (e.g. more than
|
||||
* once an hour).
|
||||
*
|
||||
* Immediately after modifying and uploading a file, use the touch command to
|
||||
*
|
||||
* Immediately after modifying and uploading a file, use the touch command to
|
||||
* update the mtime on the server. If the mtime jumps ahead by a number of hours,
|
||||
* set this variable to that number. If the mtime moves back, this should not be
|
||||
* set this variable to that number. If the mtime moves back, this should not be
|
||||
* needed.
|
||||
*
|
||||
* In the Windows SFTP client WinSCP, there's an option that may fix this
|
||||
* issue without changing the variable below. Under login > environment,
|
||||
* In the Windows SFTP client WinSCP, there's an option that may fix this
|
||||
* issue without changing the variable below. Under login > environment,
|
||||
* select the option "Adjust remote timestamp with DST".
|
||||
* @link http://winscp.net/eng/docs/ui_login_environment#daylight_saving_time
|
||||
*/
|
||||
@@ -144,7 +145,7 @@ $min_uploaderHoursBehind = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Path to Minify's lib folder. If you happen to move it, change
|
||||
* Path to Minify's lib folder. If you happen to move it, change
|
||||
* this accordingly.
|
||||
*/
|
||||
$min_libPath = $CFG->libdir . '/minify/lib';
|
||||
|
||||
+14
-5
@@ -40,7 +40,7 @@ if (!defined('MAX_MODINFO_CACHE_SIZE')) {
|
||||
* This includes information about the course-modules and the sections on the course. It can also
|
||||
* include dynamic data that has been updated for the current user.
|
||||
*/
|
||||
class course_modinfo {
|
||||
class course_modinfo extends stdClass {
|
||||
// For convenience we store the course object here as it is needed in other parts of code
|
||||
private $course;
|
||||
|
||||
@@ -283,7 +283,7 @@ class course_modinfo {
|
||||
* data only using the supplied set functions. Setting the fields directly is not supported
|
||||
* and may cause problems later.
|
||||
*/
|
||||
class cm_info {
|
||||
class cm_info extends stdClass {
|
||||
/**
|
||||
* State: Only basic data from modinfo cache is available.
|
||||
*/
|
||||
@@ -489,6 +489,14 @@ class cm_info {
|
||||
*/
|
||||
public $uservisible;
|
||||
|
||||
/**
|
||||
* Module context - hacky shortcut
|
||||
* @deprecated
|
||||
* @var stdClass
|
||||
*/
|
||||
public $context;
|
||||
|
||||
|
||||
// New data available only via functions
|
||||
////////////////////////////////////////
|
||||
|
||||
@@ -706,7 +714,7 @@ class cm_info {
|
||||
*/
|
||||
public function set_no_view_link() {
|
||||
$this->check_not_view_only();
|
||||
$url = null;
|
||||
$this->url = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -791,6 +799,7 @@ class cm_info {
|
||||
$this->icon = isset($mod->icon) ? $mod->icon : '';
|
||||
$this->iconcomponent = isset($mod->iconcomponent) ? $mod->iconcomponent : '';
|
||||
$this->customdata = isset($mod->customdata) ? $mod->customdata : '';
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $mod->cm);
|
||||
$this->state = self::STATE_BASIC;
|
||||
|
||||
// This special case handles old label data. Labels used to use the 'name' field for
|
||||
@@ -897,8 +906,8 @@ class cm_info {
|
||||
} else if (!empty($CFG->enablegroupmembersonly) and !empty($this->groupmembersonly)
|
||||
and !has_capability('moodle/site:accessallgroups', $modcontext, $userid)) {
|
||||
// If the activity has 'group members only' and you don't have accessallgroups...
|
||||
$groups = $this->modinfo->get_groups();
|
||||
if (empty($this->groups[$this->groupingid])) {
|
||||
$groups = $this->modinfo->get_groups($this->groupingid);
|
||||
if (empty($groups)) {
|
||||
// ...and you don't belong to a group, then set it so you can't see/access it
|
||||
$this->uservisible = false;
|
||||
}
|
||||
|
||||
+12
-13
@@ -3784,12 +3784,6 @@ function get_complete_user_data($field, $value, $mnethostid = null) {
|
||||
|
||||
/// Get various settings and preferences
|
||||
|
||||
if ($displays = $DB->get_records('course_display', array('userid'=>$user->id))) {
|
||||
foreach ($displays as $display) {
|
||||
$user->display[$display->course] = $display->display;
|
||||
}
|
||||
}
|
||||
|
||||
// preload preference cache
|
||||
check_user_preferences_loaded($user);
|
||||
|
||||
@@ -3808,18 +3802,23 @@ function get_complete_user_data($field, $value, $mnethostid = null) {
|
||||
|
||||
// this is a special hack to speedup calendar display
|
||||
$user->groupmember = array();
|
||||
if ($groups = $DB->get_records_sql($sql, array($user->id))) {
|
||||
foreach ($groups as $group) {
|
||||
if (!array_key_exists($group->courseid, $user->groupmember)) {
|
||||
$user->groupmember[$group->courseid] = array();
|
||||
if (!isguestuser($user)) {
|
||||
if ($groups = $DB->get_records_sql($sql, array($user->id))) {
|
||||
foreach ($groups as $group) {
|
||||
if (!array_key_exists($group->courseid, $user->groupmember)) {
|
||||
$user->groupmember[$group->courseid] = array();
|
||||
}
|
||||
$user->groupmember[$group->courseid][$group->id] = $group->id;
|
||||
}
|
||||
$user->groupmember[$group->courseid][$group->id] = $group->id;
|
||||
}
|
||||
}
|
||||
|
||||
/// Add the custom profile fields to the user record
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
profile_load_custom_fields($user);
|
||||
$user->profile = array();
|
||||
if (!isguestuser($user)) {
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
profile_load_custom_fields($user);
|
||||
}
|
||||
|
||||
/// Rewrite some variables if necessary
|
||||
if (!empty($user->description)) {
|
||||
|
||||
+24
-31
@@ -1023,7 +1023,7 @@ class global_navigation extends navigation_node {
|
||||
$this->add_course_essentials($coursenode, $course);
|
||||
// Load the course sections into the page
|
||||
$sections = $this->load_course_sections($course, $coursenode);
|
||||
if ($course->id !== SITEID) {
|
||||
if ($course->id != SITEID) {
|
||||
// Find the section for the $CM associated with the page and collect
|
||||
// its section number.
|
||||
if (isset($cm->sectionnum)) {
|
||||
@@ -1105,7 +1105,7 @@ class global_navigation extends navigation_node {
|
||||
}
|
||||
// Load each extending user into the navigation.
|
||||
foreach ($this->extendforuser as $user) {
|
||||
if ($user->id !== $USER->id) {
|
||||
if ($user->id != $USER->id) {
|
||||
$this->load_for_user($user);
|
||||
}
|
||||
}
|
||||
@@ -1384,11 +1384,7 @@ class global_navigation extends navigation_node {
|
||||
|
||||
$viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
|
||||
|
||||
if (isloggedin() && !isguestuser()) {
|
||||
$activesection = $DB->get_field("course_display", "display", array("userid"=>$USER->id, "course"=>$course->id));
|
||||
} else {
|
||||
$activesection = null;
|
||||
}
|
||||
$activesection = course_get_display($course->id);
|
||||
|
||||
$namingfunction = 'callback_'.$courseformat.'_get_section_name';
|
||||
$namingfunctionexists = (function_exists($namingfunction));
|
||||
@@ -1418,7 +1414,7 @@ class global_navigation extends navigation_node {
|
||||
$sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
|
||||
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||
$sectionnode->hidden = (!$section->visible);
|
||||
if ($this->page->context->contextlevel != CONTEXT_MODULE && ($sectionnode->isactive || ($activesection != null && $section->section == $activesection))) {
|
||||
if ($this->page->context->contextlevel != CONTEXT_MODULE && ($sectionnode->isactive || ($activesection && $section->section == $activesection))) {
|
||||
$sectionnode->force_open();
|
||||
$this->load_section_activities($sectionnode, $section->section, $modinfo);
|
||||
}
|
||||
@@ -1510,7 +1506,7 @@ class global_navigation extends navigation_node {
|
||||
* * {@see forum_extend_navigation()}
|
||||
* * {@see workshop_extend_navigation()}
|
||||
*
|
||||
* @param stdClass $cm
|
||||
* @param cm_info|stdClass $cm
|
||||
* @param stdClass $course
|
||||
* @param navigation_node $activity
|
||||
* @return bool
|
||||
@@ -1518,6 +1514,12 @@ class global_navigation extends navigation_node {
|
||||
protected function load_activity($cm, stdClass $course, navigation_node $activity) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// make sure we have a $cm from get_fast_modinfo as this contains activity access details
|
||||
if (!($cm instanceof cm_info)) {
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$cm = $modinfo->get_cm($cm->id);
|
||||
}
|
||||
|
||||
$activity->make_active();
|
||||
$file = $CFG->dirroot.'/mod/'.$cm->modname.'/lib.php';
|
||||
$function = $cm->modname.'_extend_navigation';
|
||||
@@ -1563,7 +1565,7 @@ class global_navigation extends navigation_node {
|
||||
// Get the course set against the page, by default this will be the site
|
||||
$course = $this->page->course;
|
||||
$baseargs = array('id'=>$user->id);
|
||||
if ($course->id !== SITEID && (!$iscurrentuser || $forceforcontext)) {
|
||||
if ($course->id != SITEID && (!$iscurrentuser || $forceforcontext)) {
|
||||
if (array_key_exists($course->id, $this->mycourses)) {
|
||||
$coursenode = $this->mycourses[$course->id]->coursenode;
|
||||
} else {
|
||||
@@ -1851,9 +1853,15 @@ class global_navigation extends navigation_node {
|
||||
*/
|
||||
public function add_course(stdClass $course, $forcegeneric = false) {
|
||||
global $CFG;
|
||||
$canviewhidden = has_capability('moodle/course:viewhiddencourses', $this->page->context);
|
||||
if ($course->id !== SITEID && !$canviewhidden && !$course->visible) {
|
||||
return false;
|
||||
|
||||
if ($course->id != SITEID) {
|
||||
if (!$course->visible) {
|
||||
if (is_role_switched($course->id)) {
|
||||
// user has to be able to access course in order to switch, let's skip the visibility test here
|
||||
} else if (!has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$issite = ($course->id == SITEID);
|
||||
@@ -2239,8 +2247,9 @@ class global_navigation_for_ajax extends global_navigation {
|
||||
$this->load_section_activities($sections[$course->sectionnumber]->sectionnode, $course->sectionnumber, get_fast_modinfo($course));
|
||||
break;
|
||||
case self::TYPE_ACTIVITY :
|
||||
$cm = get_coursemodule_from_id(false, $this->instanceid, 0, false, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$cm = $modinfo->get_cm($this->instanceid);
|
||||
require_course_login($course, true, $cm);
|
||||
$this->page->set_context(get_context_instance(CONTEXT_MODULE, $cm->id));
|
||||
$coursenode = $this->load_course($course);
|
||||
@@ -2977,7 +2986,7 @@ class settings_navigation extends navigation_node {
|
||||
$availableroles = get_switchable_roles($coursecontext);
|
||||
if (is_array($availableroles)) {
|
||||
foreach ($availableroles as $key=>$role) {
|
||||
if ($assumedrole===(int)$key) {
|
||||
if ($assumedrole == (int)$key) {
|
||||
continue;
|
||||
}
|
||||
$roles[$key] = $role;
|
||||
@@ -3398,26 +3407,10 @@ class settings_navigation extends navigation_node {
|
||||
if (portfolio_instances(true, false)) {
|
||||
$portfolio = $usersetting->add(get_string('portfolios', 'portfolio'), null, self::TYPE_SETTING);
|
||||
|
||||
$config = optional_param('config', 0, PARAM_INT);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$url = new moodle_url('/user/portfolio.php', array('courseid'=>$course->id));
|
||||
if ($hide !== 0) {
|
||||
$url->param('hide', $hide);
|
||||
}
|
||||
if ($config !== 0) {
|
||||
$url->param('config', $config);
|
||||
}
|
||||
$portfolio->add(get_string('configure', 'portfolio'), $url, self::TYPE_SETTING);
|
||||
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$perpage = optional_param('perpage', 10, PARAM_INT);
|
||||
$url = new moodle_url('/user/portfoliologs.php', array('courseid'=>$course->id));
|
||||
if ($page !== 0) {
|
||||
$url->param('page', $page);
|
||||
}
|
||||
if ($perpage !== 0) {
|
||||
$url->param('perpage', $perpage);
|
||||
}
|
||||
$portfolio->add(get_string('logs', 'portfolio'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2409,12 +2409,12 @@ EOD;
|
||||
return '';
|
||||
}
|
||||
if ($item->action instanceof action_link) {
|
||||
//TODO: to be replaced with something else
|
||||
$link = $item->action;
|
||||
if ($item->hidden) {
|
||||
$link->add_class('dimmed');
|
||||
}
|
||||
$content = $this->output->render($link);
|
||||
$link->text = $content.$link->text; // add help icon
|
||||
$content = $this->render($link);
|
||||
} else if ($item->action instanceof moodle_url) {
|
||||
$attributes = array();
|
||||
if ($title !== '') {
|
||||
|
||||
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*
|
||||
* Typical usage would be
|
||||
* <pre>
|
||||
* $PAGE->requires->init_js_call('M.mod_forum.init_view');
|
||||
* $PAGE->requires->js_init_call('M.mod_forum.init_view');
|
||||
* </pre>
|
||||
*
|
||||
* It also supports obsoleted coding style withouth YUI3 modules.
|
||||
|
||||
+18
-12
@@ -102,9 +102,8 @@ class moodle_page {
|
||||
protected $_course = null;
|
||||
|
||||
/**
|
||||
* If this page belongs to a module, this is the row from the course_modules
|
||||
* table, as fetched by get_coursemodule_from_id or get_coursemodule_from_instance,
|
||||
* so the extra modname and name fields are present.
|
||||
* If this page belongs to a module, this is the cm_info module description object.
|
||||
* @var cm_info
|
||||
*/
|
||||
protected $_cm = null;
|
||||
|
||||
@@ -272,6 +271,7 @@ class moodle_page {
|
||||
* if this page is not within a module. This is a full cm object, as loaded
|
||||
* by get_coursemodule_from_id or get_coursemodule_from_instance,
|
||||
* so the extra modname and name fields are present.
|
||||
* @return cm_info
|
||||
*/
|
||||
protected function magic_get_cm() {
|
||||
return $this->_cm;
|
||||
@@ -775,7 +775,7 @@ class moodle_page {
|
||||
/**
|
||||
* The course module that this page belongs to (if it does belong to one).
|
||||
*
|
||||
* @param stdClass $cm a full cm object obtained from get_coursemodule_from_id or get_coursemodule_from_instance.
|
||||
* @param stdClass|cm_info $cm a record from course_modules table or cm_info from get_fast_modinfo().
|
||||
* @param stdClass $course
|
||||
* @param stdClass $module
|
||||
* @return void
|
||||
@@ -783,23 +783,29 @@ class moodle_page {
|
||||
public function set_cm($cm, $course = null, $module = null) {
|
||||
global $DB;
|
||||
|
||||
if (!isset($cm->name) || !isset($cm->modname) || !isset($cm->id)) {
|
||||
throw new coding_exception('The $cm you set on $PAGE must have been obtained with get_coursemodule_from_id or get_coursemodule_from_instance. That is, the ->name and -> modname fields must be present and correct.');
|
||||
}
|
||||
$this->_cm = $cm;
|
||||
$this->_cm->context = get_context_instance(CONTEXT_MODULE, $cm->id); // hacky shortcut
|
||||
if (!$this->_context) {
|
||||
$this->set_context($this->_cm->context);
|
||||
if (!isset($cm->id) || !isset($cm->course)) {
|
||||
throw new coding_exception('Invalid $cm parameter for $PAGE object, it has to be instance of cm_info or record from the course_modules table.');
|
||||
}
|
||||
|
||||
if (!$this->_course || $this->_course->id != $cm->course) {
|
||||
if (!$course) {
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
}
|
||||
if ($course->id != $cm->course) {
|
||||
throw new coding_exception('The course you passed to $PAGE->set_cm does not seem to correspond to the $cm.');
|
||||
throw new coding_exception('The course you passed to $PAGE->set_cm does not correspond to the $cm.');
|
||||
}
|
||||
$this->set_course($course);
|
||||
}
|
||||
|
||||
// make sure we have a $cm from get_fast_modinfo as this contains activity access details
|
||||
if (!($cm instanceof cm_info)) {
|
||||
$modinfo = get_fast_modinfo($this->_course);
|
||||
$cm = $modinfo->get_cm($cm->id);
|
||||
}
|
||||
$this->_cm = $cm;
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$this->set_context($context); // the content of page MUST match the cm, this prints warning if there is any problem
|
||||
|
||||
if ($module) {
|
||||
$this->set_activity_record($module);
|
||||
}
|
||||
|
||||
+2
-13
@@ -216,19 +216,8 @@ abstract class session_stub implements moodle_session {
|
||||
$user = null;
|
||||
|
||||
if (!empty($CFG->opentogoogle) and !NO_MOODLE_COOKIES) {
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
// allow web spiders in as guest users
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
||||
$user = guest_user();
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
|
||||
$user = guest_user();
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
|
||||
$user = guest_user();
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
|
||||
$user = guest_user();
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
|
||||
$user = guest_user();
|
||||
}
|
||||
if (is_web_crawler()) {
|
||||
$user = guest_user();
|
||||
}
|
||||
if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
|
||||
// automaticaly log in users coming from search engine results
|
||||
|
||||
+33
-7
@@ -721,15 +721,14 @@ function setup_get_remote_url() {
|
||||
list($rurl['host']) = explode(':', $_SERVER['HTTP_HOST']);
|
||||
$rurl['port'] = $_SERVER['SERVER_PORT'];
|
||||
$rurl['path'] = $_SERVER['SCRIPT_NAME']; // Script path without slash arguments
|
||||
$rurl['scheme'] = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off' or $_SERVER['HTTPS'] === 'Off' or $_SERVER['HTTPS'] === 'OFF') ? 'http' : 'https';
|
||||
|
||||
if (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
|
||||
//Apache server
|
||||
$rurl['scheme'] = empty($_SERVER['HTTPS']) ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) {
|
||||
//IIS - needs a lot of tweaking to make it work
|
||||
$rurl['scheme'] = ($_SERVER['HTTPS'] == 'off') ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
// NOTE: ignore PATH_INFO because it is incorrectly encoded using 8bit filesystem legacy encoding in IIS
|
||||
@@ -745,7 +744,6 @@ function setup_get_remote_url() {
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) {
|
||||
//lighttpd - not officially supported
|
||||
$rurl['scheme'] = empty($_SERVER['HTTPS']) ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI']; // TODO: verify this is always properly encoded
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) {
|
||||
@@ -753,22 +751,18 @@ function setup_get_remote_url() {
|
||||
if (!isset($_SERVER['SCRIPT_NAME'])) {
|
||||
die('Invalid server configuration detected, please try to add "fastcgi_param SCRIPT_NAME $fastcgi_script_name;" to the nginx server configuration.');
|
||||
}
|
||||
$rurl['scheme'] = empty($_SERVER['HTTPS']) ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI']; // TODO: verify this is always properly encoded
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'cherokee') !== false) {
|
||||
//cherokee - not officially supported
|
||||
$rurl['scheme'] = ($_SERVER['HTTPS'] == 'off') ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI']; // TODO: verify this is always properly encoded
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'zeus') !== false) {
|
||||
//zeus - not officially supported
|
||||
$rurl['scheme'] = ($_SERVER['HTTPS'] == 'off') ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI']; // TODO: verify this is always properly encoded
|
||||
|
||||
} else if (stripos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false) {
|
||||
//LiteSpeed - not officially supported
|
||||
$rurl['scheme'] = ($_SERVER['HTTPS'] == 'off') ? 'http' : 'https';
|
||||
$rurl['fullpath'] = $_SERVER['REQUEST_URI']; // TODO: verify this is always properly encoded
|
||||
|
||||
} else {
|
||||
@@ -1123,6 +1117,38 @@ function init_eaccelerator() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current user is a web crawler.
|
||||
*
|
||||
* This list can not be made complete, this is not a security
|
||||
* restriction, we make the list only to help these sites
|
||||
* especially when automatic guest login is disabled.
|
||||
*
|
||||
* If admin needs security they should enable forcelogin
|
||||
* and disable guest access!!
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_web_crawler() {
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false ) {
|
||||
return true;
|
||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'AltaVista') !== false ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class solves the problem of how to initialise $OUTPUT.
|
||||
|
||||
@@ -474,10 +474,11 @@ class textlib {
|
||||
*/
|
||||
function asort(array &$arr) {
|
||||
if (function_exists('collator_asort')) {
|
||||
$coll = collator_create(get_string('locale', 'langconfig'));
|
||||
collator_asort($coll, $arr);
|
||||
} else {
|
||||
asort($arr, SORT_LOCALE_STRING);
|
||||
if ($coll = collator_create(get_string('locale', 'langconfig'))) {
|
||||
collator_asort($coll, $arr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
asort($arr, SORT_LOCALE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
+52
-29
@@ -987,11 +987,8 @@ function upgrade_handle_exception($ex, $plugin = null) {
|
||||
/**
|
||||
* Adds log entry into upgrade_log table
|
||||
*
|
||||
* @global object
|
||||
* @global object
|
||||
* @global object
|
||||
* @param int $type UPGRADE_LOG_NORMAL, UPGRADE_LOG_NOTICE or UPGRADE_LOG_ERROR
|
||||
* @param string $plugin plugin or null if main
|
||||
* @param string $plugin frankenstyle component name
|
||||
* @param string $info short description text of log entry
|
||||
* @param string $details long problem description
|
||||
* @param string $backtrace string used for errors only
|
||||
@@ -1000,54 +997,80 @@ function upgrade_handle_exception($ex, $plugin = null) {
|
||||
function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
|
||||
global $DB, $USER, $CFG;
|
||||
|
||||
$plugin = ($plugin==='moodle') ? null : $plugin;
|
||||
if (empty($plugin)) {
|
||||
$plugin = 'core';
|
||||
}
|
||||
|
||||
list($plugintype, $pluginname) = normalize_component($plugin);
|
||||
$component = is_null($pluginname) ? $plugintype : $plugintype . '_' . $pluginname;
|
||||
|
||||
$backtrace = format_backtrace($backtrace, true);
|
||||
|
||||
$version = null;
|
||||
$currentversion = null;
|
||||
$targetversion = null;
|
||||
|
||||
//first try to find out current version number
|
||||
if (empty($plugin) or $plugin === 'moodle') {
|
||||
if ($plugintype === 'core') {
|
||||
//main
|
||||
$version = $CFG->version;
|
||||
$currentversion = $CFG->version;
|
||||
|
||||
} else if ($plugin === 'local') {
|
||||
//customisation
|
||||
$version = $CFG->local_version;
|
||||
$version = null;
|
||||
include("$CFG->dirroot/version.php");
|
||||
$targetversion = $version;
|
||||
|
||||
} else if (strpos($plugin, 'mod/') === 0) {
|
||||
} else if ($plugintype === 'mod') {
|
||||
try {
|
||||
$modname = substr($plugin, strlen('mod/'));
|
||||
$version = $DB->get_field('modules', 'version', array('name'=>$modname));
|
||||
$version = ($version === false) ? null : $version;
|
||||
$currentversion = $DB->get_field('modules', 'version', array('name'=>$pluginname));
|
||||
$currentversion = ($currentversion === false) ? null : $currentversion;
|
||||
} catch (Exception $ignored) {
|
||||
}
|
||||
$cd = get_component_directory($component);
|
||||
if (file_exists("$cd/version.php")) {
|
||||
$module = new stdClass();
|
||||
$module->version = null;
|
||||
include("$cd/version.php");
|
||||
$targetversion = $module->version;
|
||||
}
|
||||
|
||||
} else if (strpos($plugin, 'block/') === 0) {
|
||||
} else if ($plugintype === 'block') {
|
||||
try {
|
||||
$blockname = substr($plugin, strlen('block/'));
|
||||
if ($block = $DB->get_record('block', array('name'=>$blockname))) {
|
||||
$version = $block->version;
|
||||
if ($block = $DB->get_record('block', array('name'=>$pluginname))) {
|
||||
$currentversion = $block->version;
|
||||
}
|
||||
} catch (Exception $ignored) {
|
||||
}
|
||||
$cd = get_component_directory($component);
|
||||
if (file_exists("$cd/version.php")) {
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = null;
|
||||
include("$cd/version.php");
|
||||
$targetversion = $plugin->version;
|
||||
}
|
||||
|
||||
} else {
|
||||
$pluginversion = get_config(str_replace('/', '_', $plugin), 'version');
|
||||
$pluginversion = get_config($component, 'version');
|
||||
if (!empty($pluginversion)) {
|
||||
$version = $pluginversion;
|
||||
$currentversion = $pluginversion;
|
||||
}
|
||||
$cd = get_component_directory($component);
|
||||
if (file_exists("$cd/version.php")) {
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = null;
|
||||
include("$cd/version.php");
|
||||
$targetversion = $plugin->version;
|
||||
}
|
||||
}
|
||||
|
||||
$log = new stdClass();
|
||||
$log->type = $type;
|
||||
$log->plugin = $plugin;
|
||||
$log->version = $version;
|
||||
$log->info = $info;
|
||||
$log->details = $details;
|
||||
$log->backtrace = $backtrace;
|
||||
$log->userid = $USER->id;
|
||||
$log->timemodified = time();
|
||||
$log->type = $type;
|
||||
$log->plugin = $component;
|
||||
$log->version = $currentversion;
|
||||
$log->targetversion = $targetversion;
|
||||
$log->info = $info;
|
||||
$log->details = $details;
|
||||
$log->backtrace = $backtrace;
|
||||
$log->userid = $USER->id;
|
||||
$log->timemodified = time();
|
||||
try {
|
||||
$DB->insert_record('upgrade_log', $log);
|
||||
} catch (Exception $ignored) {
|
||||
|
||||
+4
-5
@@ -1966,7 +1966,7 @@ function get_separator() {
|
||||
* @return string|void If $return is false, returns nothing, otherwise returns a string of HTML.
|
||||
*/
|
||||
function print_collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false, $return = false) {
|
||||
$output = print_collapsible_region_start($classes, $id, $caption, $userpref, true, true);
|
||||
$output = print_collapsible_region_start($classes, $id, $caption, $userpref, $default, true);
|
||||
$output .= $contents;
|
||||
$output .= print_collapsible_region_end(true);
|
||||
|
||||
@@ -1982,21 +1982,20 @@ function print_collapsible_region($contents, $classes, $id, $caption, $userpref
|
||||
* be clicked to expand or collapse the region. If JavaScript is off, then the region
|
||||
* will always be expanded.
|
||||
*
|
||||
* @global object
|
||||
* @param string $classes class names added to the div that is output.
|
||||
* @param string $id id added to the div that is output. Must not be blank.
|
||||
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
||||
* @param boolean $userpref the name of the user preference that stores the user's preferred default state.
|
||||
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
||||
* (May be blank if you do not wish the state to be persisted.
|
||||
* @param boolean $default Initial collapsed state to use if the user_preference it not set.
|
||||
* @param boolean $return if true, return the HTML as a string, rather than printing it.
|
||||
* @return string|void if $return is false, returns nothing, otherwise returns a string of HTML.
|
||||
*/
|
||||
function print_collapsible_region_start($classes, $id, $caption, $userpref = false, $default = false, $return = false) {
|
||||
function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false) {
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
|
||||
// Work out the initial state.
|
||||
if (is_string($userpref)) {
|
||||
if (!empty($userpref) and is_string($userpref)) {
|
||||
user_preference_allow_ajax_update($userpref, PARAM_BOOL);
|
||||
$collapsed = get_user_preferences($userpref, $default);
|
||||
} else {
|
||||
|
||||
+17
-14
@@ -27,19 +27,29 @@
|
||||
require('../config.php');
|
||||
require_once('change_password_form.php');
|
||||
|
||||
$id = optional_param('id', SITEID, PARAM_INT); // current course
|
||||
$id = optional_param('id', SITEID, PARAM_INT); // current course
|
||||
$return = optional_param('return', 0, PARAM_BOOL); // redirect after password change
|
||||
|
||||
//HTTPS is required in this page when $CFG->loginhttps enabled
|
||||
$PAGE->https_required();
|
||||
|
||||
$uparams = array();
|
||||
if ($id != SITEID) {
|
||||
$uparams['id'] = $id;
|
||||
}
|
||||
$PAGE->set_url('/login/change_password.php', $uparams);
|
||||
$PAGE->set_url('/login/change_password.php', array('id'=>$id));
|
||||
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if ($return) {
|
||||
// this redirect prevents security warning because https can not POST to http pages
|
||||
if (empty($SESSION->wantsurl)
|
||||
or stripos(str_replace('https://', 'http://', $SESSION->wantsurl), str_replace('https://', 'http://', $CFG->wwwroot.'/login/change_password.php') === 0)) {
|
||||
$returnto = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id";
|
||||
} else {
|
||||
$returnto = $SESSION->wantsurl;
|
||||
}
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
redirect($returnto);
|
||||
}
|
||||
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
@@ -115,14 +125,7 @@ if ($mform->is_cancelled()) {
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($SESSION->wantsurl) or $SESSION->wantsurl == $CFG->httpswwwroot.'/login/change_password.php') {
|
||||
$returnto = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id";
|
||||
} else {
|
||||
$returnto = $SESSION->wantsurl;
|
||||
}
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
notice($strpasswordchanged, $returnto);
|
||||
notice($strpasswordchanged, new moodle_url($PAGE->url, array('return'=>1)));
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ if ($frm and isset($frm->username)) { // Login WITH
|
||||
$urltogo = $CFG->wwwroot.'/user/edit.php';
|
||||
// We don't delete $SESSION->wantsurl yet, so we get there later
|
||||
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
|
||||
} else if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0 or strpos($SESSION->wantsurl, str_replace('http://', 'https://', $CFG->wwwroot)) === 0)) {
|
||||
$urltogo = $SESSION->wantsurl; /// Because it's an address in this site
|
||||
unset($SESSION->wantsurl);
|
||||
|
||||
|
||||
@@ -79,6 +79,9 @@ class login_signup_form extends moodleform {
|
||||
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"');
|
||||
$mform->setType('city', PARAM_TEXT);
|
||||
$mform->addRule('city', get_string('missingcity'), 'required', null, 'server');
|
||||
if (!empty($CFG->defaultcity)) {
|
||||
$mform->setDefault('city', $CFG->defaultcity);
|
||||
}
|
||||
|
||||
$country = get_string_manager()->get_list_of_countries();
|
||||
$default_country[''] = get_string('selectacountry');
|
||||
|
||||
+49
-30
@@ -37,12 +37,22 @@ if (empty($CFG->messaging)) {
|
||||
print_error('disabled', 'message');
|
||||
}
|
||||
|
||||
//VIEW_PARAM is the preferred URL parameter but we'll still accept usergroup in case its referenced externally
|
||||
$usergroup = optional_param('usergroup', VIEW_UNREAD_MESSAGES, PARAM_ALPHANUMEXT);
|
||||
$viewing = optional_param(VIEW_PARAM, $usergroup, PARAM_ALPHANUMEXT);
|
||||
|
||||
$history = optional_param('history', MESSAGE_HISTORY_SHORT, PARAM_INT);
|
||||
$search = optional_param('search', '', PARAM_CLEAN); //TODO: use PARAM_RAW, but make sure we use s() and p() properly
|
||||
|
||||
$user1id = optional_param('user', $USER->id, PARAM_INT);
|
||||
$user2id = optional_param('id', 0, PARAM_INT);
|
||||
//the same param as 1.9 and the param we have been logging. Use this parameter.
|
||||
$user1id = optional_param(MESSAGE_USER1_PARAM, $USER->id, PARAM_INT);
|
||||
//2.0 shipped using this param. Retaining it only for compatibility. It should be removed.
|
||||
$user1id = optional_param('user', $user1id, PARAM_INT);
|
||||
|
||||
//the same param as 1.9 and the param we have been logging. Use this parameter.
|
||||
$user2id = optional_param(MESSAGE_USER2_PARAM, 0, PARAM_INT);
|
||||
//2.0 shipped using this param. Retaining it only for compatibility. It should be removed.
|
||||
$user2id = optional_param('id', $user2id, PARAM_INT);
|
||||
|
||||
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
||||
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
||||
@@ -61,13 +71,15 @@ if ($user2id !== 0) {
|
||||
$url->param('id', $user2id);
|
||||
}
|
||||
|
||||
if ($usergroup !== 0) {
|
||||
if ($user2id !== 0 && $usergroup==VIEW_SEARCH) {
|
||||
//if theyve searched and selected a user change the view back to contacts so the search button is displayed
|
||||
$usergroup = VIEW_CONTACTS;
|
||||
if ($user2id !== 0) {
|
||||
//Switch view back to contacts if:
|
||||
//1) theyve searched and selected a user
|
||||
//2) they've viewed recent messages or notifications and clicked through to a user
|
||||
if ($viewing == VIEW_SEARCH || $viewing == VIEW_SEARCH || $viewing == VIEW_RECENT_NOTIFICATIONS) {
|
||||
$viewing = VIEW_CONTACTS;
|
||||
}
|
||||
$url->param('usergroup', $usergroup);
|
||||
}
|
||||
$url->param('viewing', $viewing);
|
||||
|
||||
$PAGE->set_url($url);
|
||||
|
||||
@@ -80,8 +92,8 @@ $context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$user1 = null;
|
||||
$currentuser = true;
|
||||
$showcontactactionlinks = SHOW_ACTION_LINKS_IN_CONTACT_LIST;
|
||||
if ($user1id!=$USER->id) {
|
||||
$user1 = $DB->get_record('user', array('id'=>$user1id));
|
||||
if ($user1id != $USER->id) {
|
||||
$user1 = $DB->get_record('user', array('id' => $user1id));
|
||||
if (!$user1) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
@@ -94,7 +106,7 @@ unset($user1id);
|
||||
|
||||
$user2 = null;
|
||||
if (!empty($user2id)) {
|
||||
$user2 = $DB->get_record("user", array("id"=>$user2id));
|
||||
$user2 = $DB->get_record("user", array("id" => $user2id));
|
||||
if (!$user2) {
|
||||
print_error('invaliduserid');
|
||||
}
|
||||
@@ -102,7 +114,7 @@ if (!empty($user2id)) {
|
||||
unset($user2id);
|
||||
|
||||
//the current user isnt involved in this discussion at all
|
||||
if ($user1->id!=$USER->id && $user2->id!=$USER->id && !has_capability('moodle/site:readallmessages', $context)) {
|
||||
if ($user1->id != $USER->id && (!empty($user2) && $user2->id != $USER->id) && !has_capability('moodle/site:readallmessages', $context)) {
|
||||
print_error('accessdenied','admin');
|
||||
}
|
||||
|
||||
@@ -110,7 +122,7 @@ if ($user1->id!=$USER->id && $user2->id!=$USER->id && !has_capability('moodle/si
|
||||
if ($addcontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'add contact', 'index.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
||||
message_add_contact($addcontact);
|
||||
redirect($CFG->wwwroot . '/message/index.php?usergroup=contacts&id='.$addcontact);
|
||||
redirect($CFG->wwwroot . '/message/index.php?'.VIEW_PARAM.'=contacts&id='.$addcontact);
|
||||
}
|
||||
if ($removecontact and confirm_sesskey()) {
|
||||
add_to_log(SITEID, 'message', 'remove contact', 'index.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
||||
@@ -130,7 +142,7 @@ $messageerror = null;
|
||||
if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage', $context)) {
|
||||
|
||||
// Check that the user is not blocking us!!
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid'=>$user2->id, 'contactid'=>$user1->id))) {
|
||||
if ($contact = $DB->get_record('message_contacts', array('userid' => $user2->id, 'contactid' => $user1->id))) {
|
||||
if ($contact->blocked and !has_capability('moodle/site:readallmessages', $context)) {
|
||||
$messageerror = get_string('userisblockingyou', 'message');
|
||||
}
|
||||
@@ -156,9 +168,12 @@ if ($currentuser && !empty($user2) && has_capability('moodle/site:sendmessage',
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
$messageid = message_post_message($user1, $user2, $data->message, FORMAT_MOODLE, 'direct');
|
||||
$messageid = message_post_message($user1, $user2, $data->message, FORMAT_MOODLE);
|
||||
if (!empty($messageid)) {
|
||||
redirect($CFG->wwwroot . '/message/index.php?usergroup='.$usergroup.'&id='.$user2->id);
|
||||
//including the id of the user sending the message in the logged URL so the URL works for admins
|
||||
//note message ID may be misleading as the message may potentially get a different ID when moved from message to message_read
|
||||
add_to_log(SITEID, 'message', 'write', 'index.php?user='.$user1->id.'&id='.$user2->id.'&history=1#m'.$messageid, $user1->id);
|
||||
redirect($CFG->wwwroot . '/message/index.php?'.VIEW_PARAM.'='.$viewing.'&id='.$user2->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,16 +206,16 @@ if (!empty($user2)) {
|
||||
if ($countunread>0) {
|
||||
//mark the messages we're going to display as read
|
||||
message_mark_messages_read($user1->id, $user2->id);
|
||||
if($usergroup==VIEW_UNREAD_MESSAGES) {
|
||||
if($viewing == VIEW_UNREAD_MESSAGES) {
|
||||
$viewingnewmessages = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$countunreadtotal = message_count_unread_messages($user1);
|
||||
|
||||
if ($countunreadtotal==0 && $usergroup==VIEW_UNREAD_MESSAGES && empty($user2)) {
|
||||
if ($countunreadtotal == 0 && $viewing == VIEW_UNREAD_MESSAGES && empty($user2)) {
|
||||
//default to showing the search
|
||||
$usergroup = VIEW_SEARCH;
|
||||
$viewing = VIEW_SEARCH;
|
||||
}
|
||||
|
||||
$blockedusers = message_get_blocked_users($user1, $user2);
|
||||
@@ -208,18 +223,18 @@ $countblocked = count($blockedusers);
|
||||
|
||||
list($onlinecontacts, $offlinecontacts, $strangers) = message_get_contacts($user1, $user2);
|
||||
|
||||
message_print_contact_selector($countunreadtotal, $usergroup, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page);
|
||||
message_print_contact_selector($countunreadtotal, $viewing, $user1, $user2, $blockedusers, $onlinecontacts, $offlinecontacts, $strangers, $showcontactactionlinks, $page);
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'messagearea mdl-align'));
|
||||
echo html_writer::start_tag('div', array('class' => 'messagearea mdl-align'));
|
||||
if (!empty($user2)) {
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'mdl-left messagehistory'));
|
||||
echo html_writer::start_tag('div', array('class' => 'mdl-left messagehistory'));
|
||||
|
||||
$visible = 'visible';
|
||||
$hidden = 'hiddenelement'; //cant just use hidden as mform adds that class to its fieldset for something else
|
||||
|
||||
$recentlinkclass = $recentlabelclass = $historylinkclass = $historylabelclass = $visible;
|
||||
if ($history==MESSAGE_HISTORY_ALL) {
|
||||
if ($history == MESSAGE_HISTORY_ALL) {
|
||||
$displaycount = 0;
|
||||
|
||||
$recentlabelclass = $historylinkclass = $hidden;
|
||||
@@ -239,25 +254,25 @@ echo html_writer::start_tag('div', array('class'=>'messagearea mdl-align'));
|
||||
$recentlinkclass = $historylabelclass = $hidden;
|
||||
}
|
||||
|
||||
$messagehistorylink = html_writer::start_tag('div', array('class'=>'mdl-align messagehistorytype'));
|
||||
$messagehistorylink = html_writer::start_tag('div', array('class' => 'mdl-align messagehistorytype'));
|
||||
$messagehistorylink .= html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_ALL,
|
||||
get_string('messagehistoryfull','message'),
|
||||
array('class'=>$historylinkclass));
|
||||
array('class' => $historylinkclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$historylabelclass));
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class' => $historylabelclass));
|
||||
$messagehistorylink .= get_string('messagehistoryfull','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
$messagehistorylink .= ' | '.html_writer::link($PAGE->url->out(false).'&history='.MESSAGE_HISTORY_SHORT,
|
||||
get_string('mostrecent','message'),
|
||||
array('class'=>$recentlinkclass));
|
||||
array('class' => $recentlinkclass));
|
||||
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class'=>$recentlabelclass));
|
||||
$messagehistorylink .= html_writer::start_tag('span', array('class' => $recentlabelclass));
|
||||
$messagehistorylink .= get_string('mostrecent','message');
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
|
||||
if ($viewingnewmessages) {
|
||||
$messagehistorylink .= ' | '.html_writer::start_tag('span');//, array('class'=>$historyclass)
|
||||
$messagehistorylink .= ' | '.html_writer::start_tag('span');//, array('class' => $historyclass)
|
||||
$messagehistorylink .= get_string('unreadnewmessages','message',$displaycount);
|
||||
$messagehistorylink .= html_writer::end_tag('span');
|
||||
}
|
||||
@@ -269,7 +284,7 @@ echo html_writer::start_tag('div', array('class'=>'messagearea mdl-align'));
|
||||
|
||||
//send message form
|
||||
if ($currentuser && has_capability('moodle/site:sendmessage', $context)) {
|
||||
echo html_writer::start_tag('div', array('class'=>'mdl-align messagesend'));
|
||||
echo html_writer::start_tag('div', array('class' => 'mdl-align messagesend'));
|
||||
if (!empty($messageerror)) {
|
||||
echo $OUTPUT->heading($messageerror, 3);
|
||||
} else {
|
||||
@@ -283,8 +298,12 @@ echo html_writer::start_tag('div', array('class'=>'messagearea mdl-align'));
|
||||
}
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
} else if ($usergroup==VIEW_SEARCH) {
|
||||
} else if ($viewing == VIEW_SEARCH) {
|
||||
message_print_search($advancedsearch, $user1);
|
||||
} else if ($viewing == VIEW_RECENT_CONVERSATIONS) {
|
||||
message_print_recent_conversations($user1);
|
||||
} else if ($viewing == VIEW_RECENT_NOTIFICATIONS) {
|
||||
message_print_recent_notifications($user1);
|
||||
}
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
|
||||
+752
-298
File diff suppressed because it is too large
Load Diff
@@ -48,7 +48,7 @@ $PAGE->set_pagelayout('base');
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid, false)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
}
|
||||
$groupname = ': '.$group->name;
|
||||
|
||||
@@ -33,7 +33,7 @@ require_capability('mod/chat:chat', $context);
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid, false)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
}
|
||||
$groupname = ': '.$group->name;
|
||||
|
||||
@@ -33,7 +33,7 @@ if (isguestuser()) {
|
||||
/// Check to see if groups are being used here
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
if ($groupid = groups_get_activity_group($cm)) {
|
||||
if (!$group = groups_get_group($groupid, false)) {
|
||||
if (!$group = groups_get_group($groupid)) {
|
||||
print_error('invalidgroupid');
|
||||
}
|
||||
$groupname = ': '.$group->name;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user