* @return string
*/
public function get_description() {
- return "The user with the id '$this->userid' viewed the capability overview report.";
+ return "The user with id '$this->userid' viewed the capability overview report.";
}
/**
u.mnethostid = ?
AND l.id > ?
AND l.course IS NOT NULL
- ORDER by l.id ASC
- LIMIT 500";
+ ORDER by l.id ASC";
- $mnethostlogs = $DB->get_records_sql($mnethostlogssql, array($mnethostid, $mnet_request->response['last log id']));
+ $mnethostlogs = $DB->get_records_sql($mnethostlogssql, array($mnethostid, $mnet_request->response['last log id']), 0, 500);
if ($mnethostlogs == false) {
continue;
// Set up button text and icon.
var suffix = individual ? '_individual' : '_all';
var setHidden = function() {
- icon.set('src', iconBase + '/t/show');
+ icon.set('src', iconBase + '/i/show');
icon.set('alt', M.str.availability['hidden' + suffix]);
this.span.set('title', M.str.availability['hidden' + suffix] + ' \u2022 ' +
M.str.availability.show_verb);
};
var setShown = function() {
- icon.set('src', iconBase + '/t/hide');
+ icon.set('src', iconBase + '/i/hide');
icon.set('alt', M.str.availability['shown' + suffix]);
this.span.set('title', M.str.availability['shown' + suffix] + ' \u2022 ' +
M.str.availability.hide_verb);
if (empty($this->config->glossary)) {
$this->content = new stdClass();
- $this->content->text = get_string('notyetconfigured','block_glossary_random');
+ if ($this->user_can_edit()) {
+ $this->content->text = get_string('notyetconfigured','block_glossary_random');
+ } else {
+ $this->content->text = '';
+ }
$this->content->footer = '';
return $this->content;
}
$this->instance_config_commit();
$this->content = new stdClass();
- $this->content->text = get_string('notyetconfigured','block_glossary_random');
+ if ($this->user_can_edit()) {
+ $this->content->text = get_string('notyetconfigured','block_glossary_random');
+ } else {
+ $this->content->text = '';
+ }
$this->content->footer = '';
return $this->content;
}
* @todo MDL-36050 improve capability check on stick blocks, so we can check user capability before sending images.
*/
function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
- global $DB, $CFG;
+ global $DB, $CFG, $USER;
if ($context->contextlevel != CONTEXT_BLOCK) {
send_file_not_found();
if (!$category->visible) {
require_capability('moodle/category:viewhiddencategories', $parentcontext);
}
+ } else if ($parentcontext->contextlevel === CONTEXT_USER && $parentcontext->instanceid != $USER->id) {
+ // The block is in the context of a user, it is only visible to the user who it belongs to.
+ send_file_not_found();
}
- // At this point there is no way to check SYSTEM or USER context, so ignoring it.
+ // At this point there is no way to check SYSTEM context, so ignoring it.
}
if ($filearea !== 'content') {
* The forms custom definitions.
*/
protected function configuration_definition() {
+ global $OUTPUT;
$form = $this->_form;
+ if (!class_exists('MongoClient')) {
+ $form->addElement('html', $OUTPUT->notification(get_string('pleaseupgrademongo', 'cachestore_mongodb')));
+ }
+
$form->addElement('text', 'server', get_string('server', 'cachestore_mongodb'), array('size' => 72));
$form->addHelpButton('server', 'server', 'cachestore_mongodb');
$form->addRule('server', get_string('required'), 'required');
$string['extendedmode_help'] = 'If enabled full key sets will be used when working with the plugin. This isn\'t used internally yet but would allow you to easily search and investigate the MongoDB plugin manually if you so choose. Turning this on will add an small overhead so should only be done if you require it.';
$string['password'] = 'Password';
$string['password_help'] = 'The password of the user being used for the connection.';
+$string['pleaseupgrademongo'] = 'You are using an old version of the PHP Mongo extension (< 1.3). Support for old versions of the Mongo extension will be dropped in the future. Please consider upgrading.';
$string['pluginname'] = 'MongoDB';
$string['replicaset'] = 'Replica set';
$string['replicaset_help'] = 'The name of the replica set to connect to. If this is given the master will be determined by using the ismaster database command on the seeds, so the driver may end up connecting to a server that was not even listed.';
$string['usesafe'] = 'Use safe';
$string['usesafe_help'] = 'If enabled the usesafe option will be used during insert, get, and remove operations. If you\'ve specified a replica set this will be forced on anyway.';
$string['usesafevalue'] = 'Use safe value';
-$string['usesafevalue_help'] = 'You can choose to provide a specific value for use safe. This will determine the number of servers that operations must be completed on before they are deemed to have been completed.';
\ No newline at end of file
+$string['usesafevalue_help'] = 'You can choose to provide a specific value for use safe. This will determine the number of servers that operations must be completed on before they are deemed to have been completed.';
*/
protected $isready = false;
+ /**
+ * Set to true if the Mongo extension is < version 1.3.
+ * If this is the case we must use the legacy Mongo class instead of MongoClient.
+ * Mongo is backwards compatible, although obviously deprecated.
+ * @var bool
+ */
+ protected $legacymongo = false;
+
/**
* Constructs a new instance of the Mongo store.
*
$this->extendedmode = $configuration['extendedmode'];
}
+ // Test if the MongoClient class exists, if not we need to switch to legacy classes.
+ $this->legacymongo = (!class_exists('MongoClient'));
+
+ // MongoClient from Mongo 1.3 onwards. Mongo for earlier versions.
+ $class = ($this->legacymongo) ? 'Mongo' : 'MongoClient';
try {
- $this->connection = new Mongo($this->server, $this->options);
+ $this->connection = new $class($this->server, $this->options);
$this->isready = true;
} catch (MongoConnectionException $e) {
// We only want to catch MongoConnectionExceptions here.
* @return bool
*/
public static function are_requirements_met() {
- return class_exists('Mongo');
+ return class_exists('MongoClient') || class_exists('Mongo');
}
/**
$this->database = $this->connection->selectDB($this->databasename);
$this->definitionhash = $definition->generate_definition_hash();
$this->collection = $this->database->selectCollection($this->definitionhash);
- $this->collection->ensureIndex(array('key' => 1), array(
- 'safe' => $this->usesafe,
- 'name' => 'idx_key'
- ));
+
+ $options = array('name' => 'idx_key');
+ if ($this->legacymongo) {
+ $options['safe'] = $this->usesafe;
+ } else {
+ $options['w'] = $this->usesafe ? 1 : 0;
+ }
+ $this->collection->ensureIndex(array('key' => 1), $options);
}
/**
$record = $key;
}
$record['data'] = serialize($data);
- $options = array(
- 'upsert' => true,
- 'safe' => $this->usesafe,
- 'w' => $this->usesafe ? 1 : 0
- );
+ $options = array('upsert' => true);
+ if ($this->legacymongo) {
+ $options['safe'] = $this->usesafe;
+ } else {
+ $options['w'] = $this->usesafe ? 1 : 0;
+ }
$this->delete($key);
$result = $this->collection->insert($record, $options);
if ($result === true) {
} else {
$criteria = $key;
}
- $options = array(
- 'justOne' => false,
- 'safe' => $this->usesafe,
- 'w' => $this->usesafe ? 1 : 0
- );
+ $options = array('justOne' => false);
+ if ($this->legacymongo) {
+ $options['safe'] = $this->usesafe;
+ } else {
+ $options['w'] = $this->usesafe ? 1 : 0;
+ }
$result = $this->collection->remove($criteria, $options);
if ($result === true) {
$connection = $this->connection;
} else {
try {
- $connection = new Mongo($this->server, $this->options);
+ // MongoClient from Mongo 1.3 onwards. Mongo for earlier versions.
+ $class = ($this->legacymongo) ? 'Mongo' : 'MongoClient';
+ $connection = new $class($this->server, $this->options);
} catch (MongoConnectionException $e) {
// We only want to catch MongoConnectionExceptions here.
// If the server cannot be connected to we cannot clean it.
// is changed, maybe someone has completed it now)
$mform->getElement('completionunlocked')->setValue(1);
} else {
- // Has the element been unlocked?
- if ($mform->exportValue('unlockcompletion')) {
+ // Has the element been unlocked, either by the button being pressed
+ // in this request, or the field already being set from a previous one?
+ if ($mform->exportValue('unlockcompletion') ||
+ $mform->exportValue('completionunlocked')) {
// Yes, add in warning text and set the hidden variable
$mform->insertElementBefore(
$mform->createElement('static', 'completedunlocked',
} else {
// Default to no user.
$mform->addElement('hidden', 'user', 0);
+ $mform->setType('user', PARAM_INT);
+ $mform->setConstant('user', 0);
}
$options = array(''=>get_string('allactivities'));
$this->assertEquals($course->id, $event->courseid);
$this->assertEquals($coursecontext->id, $event->contextid);
$this->assertEquals($section->section, $event->other['sectionnum']);
- $expecteddesc = "The user with the id '{$event->userid}' updated the section with the number '{$event->other['sectionnum']}' for the course with the id '{$event->courseid}'";
+ $expecteddesc = "The user with id '{$event->userid}' updated section number '{$event->other['sectionnum']}' for the course with id '{$event->courseid}'";
$this->assertEquals($expecteddesc, $event->get_description());
$url = new moodle_url('/course/editsection.php', array('id' => $event->objectid));
$this->assertEquals($url, $event->get_url());
redirect("$CFG->wwwroot/");
}
+if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', context_course::instance($course->id))) {
+ print_error('coursehidden');
+}
+
$PAGE->set_course($course);
$PAGE->set_pagelayout('course');
$PAGE->set_url('/enrol/index.php', array('id'=>$course->id));
$string['httpurl_help'] = 'Full URL to MathJax library. Used when the page is loaded via http.';
$string['httpsurl'] = 'HTTPS MathJax URL';
$string['httpsurl_help'] = 'Full URL to MathJax library. Used when the page is loaded via https (secure). ';
-$string['texfiltercompatibility'] = 'Tex filter compatibility';
-$string['texfiltercompatibility_help'] = 'The MathJax filter can be used as a replacement for the Tex filter.
+$string['texfiltercompatibility'] = 'TeX filter compatibility';
+$string['texfiltercompatibility_help'] = 'The MathJax filter can be used as a replacement for the TeX notation filter.
-To support all the delimiters supported by the Tex filter MathJax will be configured to display all equations "inline" with the tex.';
+To support all the delimiters supported by the TeX notation filter, MathJax will be configured to display all equations "inline" with the text.';
$string['localinstall'] = 'Local MathJax installation';
-$string['localinstall_help'] = 'The default MathJAX configuration uses the CDN version of MathJAX, but MathJAX can be installed locally if required.
+$string['localinstall_help'] = 'The default MathJax configuration uses the CDN version of MathJax, but MathJax can be installed locally if required.
-Some reasons this might be useful are to save on bandwidth - or because of local proxy restrictions.
+This can be useful to save on bandwidth or because of local proxy restrictions.
-To use a local installation of MathJAX, first download the full MathJax library from http://www.mathjax.org/. Then install it on a web server. Finally update the MathJax filter settings httpurl and/or httpsurl to point to the local MathJax.js url.';
+To use a local installation of MathJax, first download the full MathJax library from http://www.mathjax.org/. Then install it on a web server. Finally update the MathJax filter settings httpurl and/or httpsurl to point to the local MathJax.js URL.';
$string['mathjaxsettings'] = 'MathJax configuration';
-$string['mathjaxsettings_desc'] = 'The default MathJAX configuration should be appropriate for most users, but MathJax is highly configurable and any of the standard MathJax configuration options can be added here.';
+$string['mathjaxsettings_desc'] = 'The default MathJax configuration should be appropriate for most users, but MathJax is highly