Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'origin/master' into rubric

Conflicts:
	lib/db/upgrade.php
	version.php
  • Loading branch information...
commit d6d341d09bce44dc9c3ffc9c76889bbba8eed208 2 parents 9e3d352 + 735de1c
@mudrd8mz mudrd8mz authored
Showing with 9,517 additions and 12,713 deletions.
  1. +2 −2 admin/cli/install_database.php
  2. +1 −1  admin/renderer.php
  3. +0 −4 admin/settings/development.php
  4. +5 −5 admin/tool/unittest/other/pdflibtestpage.php
  5. +0 −15 blocks/search/README.txt
  6. +0 −73 blocks/search/block_search.php
  7. +0 −10 blocks/search/db/install.php
  8. +0 −30 blocks/search/db/install.xml
  9. +0 −94 blocks/search/db/upgrade.php
  10. +0 −57 blocks/search/lang/en/block_search.php
  11. +0 −123 blocks/search/settings.php
  12. +1 −1  calendar/lib.php
  13. +5 −5 calendar/renderer.php
  14. +6 −4 calendar/set.php
  15. +1 −0  enrol/index.php
  16. +2 −2 enrol/manual/lib.php
  17. +1 −0  enrol/self/lang/en/enrol_self.php
  18. +0 −9 enrol/self/lib.php
  19. +23 −3 enrol/self/locallib.php
  20. +1 −1  enrol/self/version.php
  21. +40 −0 filter/data/db/install.php
  22. +129 −0 filter/data/filter.php
  23. +12 −3 blocks/search/version.php → filter/data/lang/en/filter_data.php
  24. +8 −22 blocks/search/db/upgradelib.php → filter/data/version.php
  25. +40 −0 filter/glossary/db/install.php
  26. +226 −0 filter/glossary/filter.php
  27. +7 −7 question/format/qti_two/lang/en/qformat_qti_two.php → filter/glossary/lang/en/filter_glossary.php
  28. +1 −0  filter/glossary/styles.css
  29. +32 −0 filter/glossary/version.php
  30. +7 −7 {mod → filter}/glossary/yui/autolinker/autolinker.js
  31. +1 −1  group/clientlib.js
  32. +2 −1  install/lang/en/install.php
  33. +2 −0  install/lang/et/admin.php
  34. +2 −1  install/lang/fr/install.php
  35. +0 −2  lang/en/admin.php
  36. +1 −0  lang/en/question.php
  37. +105 −43 lib/accesslib.php
  38. +31 −0 lib/db/upgrade.php
  39. +9 −8 lib/enrollib.php
  40. +6 −0 lib/filterlib.php
  41. +1 −1  lib/javascript-static.js
  42. +1 −0  lib/moodlelib.php
  43. +0 −1  lib/mp3player/index.html
  44. BIN  lib/mp3player/mp3player.fla.zip
  45. BIN  lib/mp3player/mp3player.swf
  46. +0 −87 lib/mp3player/readme.txt
  47. +6 −9 lib/navigationlib.php
  48. +17 −0 lib/pdflib.php
  49. +3 −3 lib/pluginlib.php
  50. +4 −0 lib/resourcelib.php
  51. +0 −458 lib/smarty/COPYING.lib
  52. +0 −393 lib/smarty/Config_File.class.php
  53. +0 −1,961 lib/smarty/Smarty.class.php
  54. +0 −2,365 lib/smarty/Smarty_Compiler.class.php
  55. +0 −157 lib/smarty/debug.tpl
  56. +0 −67 lib/smarty/internals/core.assemble_plugin_filepath.php
  57. +0 −43 lib/smarty/internals/core.assign_smarty_interface.php
  58. +0 −79 lib/smarty/internals/core.create_dir_structure.php
  59. +0 −61 lib/smarty/internals/core.display_debug_console.php
  60. +0 −44 lib/smarty/internals/core.get_include_path.php
  61. +0 −23 lib/smarty/internals/core.get_microtime.php
  62. +0 −80 lib/smarty/internals/core.get_php_resource.php
  63. +0 −59 lib/smarty/internals/core.is_secure.php
  64. +0 −47 lib/smarty/internals/core.is_trusted.php
  65. +0 −125 lib/smarty/internals/core.load_plugins.php
  66. +0 −74 lib/smarty/internals/core.load_resource_plugin.php
  67. +0 −71 lib/smarty/internals/core.process_cached_inserts.php
  68. +0 −37 lib/smarty/internals/core.process_compiled_include.php
  69. +0 −101 lib/smarty/internals/core.read_cache_file.php
  70. +0 −71 lib/smarty/internals/core.rm_auto.php
  71. +0 −54 lib/smarty/internals/core.rmdir.php
  72. +0 −71 lib/smarty/internals/core.run_insert_handler.php
  73. +0 −50 lib/smarty/internals/core.smarty_include_php.php
  74. +0 −96 lib/smarty/internals/core.write_cache_file.php
  75. +0 −91 lib/smarty/internals/core.write_compiled_include.php
  76. +0 −35 lib/smarty/internals/core.write_compiled_resource.php
  77. +0 −54 lib/smarty/internals/core.write_file.php
  78. +0 −103 lib/smarty/plugins/block.textformat.php
  79. +0 −40 lib/smarty/plugins/compiler.assign.php
  80. +0 −40 lib/smarty/plugins/function.assign_debug_info.php
  81. +0 −142 lib/smarty/plugins/function.config_load.php
  82. +0 −80 lib/smarty/plugins/function.counter.php
  83. +0 −102 lib/smarty/plugins/function.cycle.php
  84. +0 −35 lib/smarty/plugins/function.debug.php
  85. +0 −49 lib/smarty/plugins/function.eval.php
  86. +0 −221 lib/smarty/plugins/function.fetch.php
  87. +0 −143 lib/smarty/plugins/function.html_checkboxes.php
  88. +0 −142 lib/smarty/plugins/function.html_image.php
  89. +0 −122 lib/smarty/plugins/function.html_options.php
  90. +0 −156 lib/smarty/plugins/function.html_radios.php
  91. +0 −331 lib/smarty/plugins/function.html_select_date.php
  92. +0 −194 lib/smarty/plugins/function.html_select_time.php
  93. +0 −177 lib/smarty/plugins/function.html_table.php
  94. +0 −165 lib/smarty/plugins/function.mailto.php
  95. +0 −85 lib/smarty/plugins/function.math.php
  96. +0 −119 lib/smarty/plugins/function.popup.php
  97. +0 −40 lib/smarty/plugins/function.popup_init.php
  98. +0 −43 lib/smarty/plugins/modifier.capitalize.php
  99. +0 −33 lib/smarty/plugins/modifier.cat.php
  100. +0 −32 lib/smarty/plugins/modifier.count_characters.php
  101. +0 −29 lib/smarty/plugins/modifier.count_paragraphs.php
  102. +0 −29 lib/smarty/plugins/modifier.count_sentences.php
  103. +0 −33 lib/smarty/plugins/modifier.count_words.php
  104. +0 −58 lib/smarty/plugins/modifier.date_format.php
  105. +0 −90 lib/smarty/plugins/modifier.debug_print_var.php
  106. +0 −32 lib/smarty/plugins/modifier.default.php
  107. +0 −93 lib/smarty/plugins/modifier.escape.php
  108. +0 −28 lib/smarty/plugins/modifier.indent.php
  109. +0 −26 lib/smarty/plugins/modifier.lower.php
  110. +0 −35 lib/smarty/plugins/modifier.nl2br.php
  111. +0 −48 lib/smarty/plugins/modifier.regex_replace.php
  112. +0 −30 lib/smarty/plugins/modifier.replace.php
  113. +0 −30 lib/smarty/plugins/modifier.spacify.php
  114. +0 −29 lib/smarty/plugins/modifier.string_format.php
  115. +0 −33 lib/smarty/plugins/modifier.strip.php
  116. +0 −32 lib/smarty/plugins/modifier.strip_tags.php
  117. +0 −50 lib/smarty/plugins/modifier.truncate.php
  118. +0 −26 lib/smarty/plugins/modifier.upper.php
  119. +0 −29 lib/smarty/plugins/modifier.wordwrap.php
  120. +0 −75 lib/smarty/plugins/outputfilter.trimwhitespace.php
  121. +0 −31 lib/smarty/plugins/shared.escape_special_chars.php
  122. +0 −46 lib/smarty/plugins/shared.make_timestamp.php
  123. +0 −6 lib/smarty/readme_moodle.txt
  124. +275 −68 lib/tcpdf/2dbarcodes.php
  125. +1,177 −117 lib/tcpdf/CHANGELOG.TXT
  126. +838 −482 lib/tcpdf/LICENSE.TXT
  127. +61 −57 lib/tcpdf/README.TXT
  128. +620 −310 lib/tcpdf/barcodes.php
  129. +55 −47 lib/tcpdf/config/tcpdf_config.php
  130. +1,148 −0 lib/tcpdf/datamatrix.php
  131. +880 −0 lib/tcpdf/encodings_maps.php
  132. +1,769 −0 lib/tcpdf/fonts/arialunicid0.php
  133. +9 −30 lib/tcpdf/fonts/courier.php
  134. +12 −0 lib/tcpdf/fonts/courierb.php
  135. +12 −0 lib/tcpdf/fonts/courierbi.php
  136. +12 −0 lib/tcpdf/fonts/courieri.php
  137. +28 −1 lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/AUTHORS
  138. 0  lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/COPYING
  139. +57 −4 lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/CREDITS
  140. +1,802 −2 lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/ChangeLog
  141. +1 −1  lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/INSTALL
  142. +2 −2 lib/tcpdf/fonts/{freefont-20090104 → freefont-20100919}/README
  143. BIN  lib/tcpdf/fonts/freemono.ctg.z
  144. +6 −339 lib/tcpdf/fonts/freemono.php
  145. BIN  lib/tcpdf/fonts/freemono.z
  146. BIN  lib/tcpdf/fonts/freemonob.ctg.z
  147. +6 −195 lib/tcpdf/fonts/freemonob.php
  148. BIN  lib/tcpdf/fonts/freemonob.z
  149. BIN  lib/tcpdf/fonts/freemonobi.ctg.z
  150. +6 −144 lib/tcpdf/fonts/freemonobi.php
  151. BIN  lib/tcpdf/fonts/freemonobi.z
  152. BIN  lib/tcpdf/fonts/freemonoi.ctg.z
Sorry, we could not display the entire diff because too many files (428) changed.
View
4 admin/cli/install_database.php
@@ -46,8 +46,8 @@
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
--adminpass=PASSWORD Password for the moodle admin account.
--agree-license Indicates agreement with software license.
---fullname Name of the site
---shortname Name of the site
+--fullname=STRING Name of the site
+--shortname=STRING Name of the site
-h, --help Print out this help
Example:
View
2  admin/renderer.php
@@ -598,7 +598,7 @@ protected function required_column(plugin_information $plugin, plugin_manager $p
if (is_null($otherplugin)) {
$ok = false;
}
- if ($requiredversion != ANY_VERSION and $otherplugin->versiondb < $requiredversion) {
+ if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
$ok = false;
}
View
4 admin/settings/development.php
@@ -7,11 +7,7 @@
// Experimental settings page
$ADMIN->add('development', new admin_category('experimental', get_string('experimental','admin')));
- require_once($CFG->dirroot .'/search/lib.php');
$temp = new admin_settingpage('experimentalsettings', get_string('experimentalsettings', 'admin'));
- $englobalsearch = new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0);
- $englobalsearch->set_updatedcallback('search_updatedcallback');
- $temp->add($englobalsearch);
//TODO: Re-enable cc-import once re-implemented in 2.0.x
//$temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0));
$temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
View
10 admin/tool/unittest/other/pdflibtestpage.php
@@ -82,7 +82,7 @@ public function _getfontpath() {
$c = '<h3>General information</h3>';
$c .= 'Moodle release: ' . $CFG->release . '<br />';
- $c .= 'PDF producer: ' . PDF_PRODUCER . '<br />';
+ $c .= 'PDF producer: TCPDF ' . $doc->getTCPDFVersion() . ' (http://www.tcpdf.org) <br />';
$c .= 'Font of this test page: ' . $fontfamily . '<br />';
$c .= '<h3>Current settings</h3>';
@@ -105,10 +105,10 @@ public function _getfontpath() {
$c .= '<h3>Installed languages and their alphabets</h3>';
$languages = array();
$langdirs = get_list_of_plugins('lang', '', $CFG->dataroot);
- array_unshift($langdirs, 'Moodle core English');
+ array_unshift($langdirs, 'en');
foreach ($langdirs as $langdir) {
- if ('Moodle core English' == $langdir) {
- $langconfig = $CFG->dirroot . '/lang/en_utf8/langconfig.php';
+ if ('en' == $langdir) {
+ $langconfig = $CFG->dirroot . '/lang/en/langconfig.php';
} else {
$langconfig = $CFG->dataroot . '/lang/' . $langdir . '/langconfig.php';
}
@@ -124,7 +124,7 @@ public function _getfontpath() {
$c .= '<dl>';
foreach ($languages as $langcode => $language) {
$c .= '<dt>' . $language->langname . ' (' . $langcode . ')</dt>';
- $c .= '<dd>' . $language->alphabet . '</dd>';
+ $c .= '<dd>"' . $language->alphabet . '"</dd>';
}
$c .= '</dl>';
View
15 blocks/search/README.txt
@@ -1,15 +0,0 @@
-This block is a revamping of the Google Summer Of Code Project (2006) on Global Search engine
-for Moodle. New block version is completed and internationalized according to Moodle multilengual support.
-
-This block instanciates a startup database model for the search engine.
-
-## Installing
-
-You need installing the following elements in order the global search to be available :
-
-1. The global search bloc (this block)
-2. update the /search root package from CVS
-3. The antiword libraries
-4. The xpdf libraries
-
-Both last libraries are provided as a patch called "global_search_libraries" in the contrib section.
View
73 blocks/search/block_search.php
@@ -1,73 +0,0 @@
-<?php
-
-/** This is the global search shortcut block - a single query can be entered, and
- * the user will be redirected to the query page where they can enter more
- * advanced queries, and view the results of their search. When searching from
- * this block, the broadest possible selection of documents is searched.
- *
- * @package search
- * @subpackage search block
- * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
- * @date: 2006 06 25
- */
-
-class block_search extends block_base {
-
- function init() {
- $this->title = get_string('pluginname', 'block_search');
- } //init
-
- // only one instance of this block is required
- function instance_allow_multiple() {
- return false;
- } //instance_allow_multiple
-
- // label and button values can be set in admin
- function has_config() {
- return true;
- } //has_config
-
- function get_content() {
- global $CFG;
-
- if (empty($CFG->enableglobalsearch)) {
- return '';
- }
-
- //cache block contents
- if ($this->content !== NULL) {
- return $this->content;
- } //if
-
- $this->content = new stdClass;
-
- //basic search form
- $this->content->text =
- '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
- . '<label for="block_search_q">' . get_string('searchmoodle', 'block_search') . '</label>'
- . '<input id="block_search_q" type="text" name="query_string" />'
- . '<input id="block_instance_id" type="hidden" name="block_instanceid" value="' . $this->instance->id . '"/>'
- . '<input type="submit" value="' . s(get_string('go', 'block_search')) . '" />'
- . '</div></form>';
-
- //no footer, thanks
- $this->content->footer = '';
-
- return $this->content;
- } //get_content
-
- function specialisation() {
- //empty!
- } //specialisation
-
- /**
- * wraps up to search engine cron
- */
- function cron(){
- global $CFG;
-
- include($CFG->dirroot.'/search/cron.php');
- }
-
- } //block_search
-
View
10 blocks/search/db/install.php
@@ -1,10 +0,0 @@
-<?php
-
-function xmldb_block_search_install() {
- global $DB;
-
- // Disable this block by default as its experimental.
- $DB->set_field('block', 'visible', 0, array('name'=>'search'));
-
-}
-
View
30 blocks/search/db/install.xml
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/search/db" VERSION="20101012" COMMENT="XMLDB file for Moodle search engine"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
->
- <TABLES>
- <TABLE NAME="block_search_documents" COMMENT="table to store search index backups">
- <FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="docid"/>
- <FIELD NAME="docid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="doctype"/>
- <FIELD NAME="doctype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="none" SEQUENCE="false" PREVIOUS="docid" NEXT="itemtype"/>
- <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="standard" SEQUENCE="false" PREVIOUS="doctype" NEXT="title"/>
- <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="itemtype" NEXT="url"/>
- <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="title" NEXT="docdate"/>
- <FIELD NAME="docdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="url" NEXT="updated"/>
- <FIELD NAME="updated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="docdate" NEXT="courseid"/>
- <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="updated" NEXT="groupid"/>
- <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid"/>
- </FIELDS>
- <KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" />
- </KEYS>
- <INDEXES>
- <INDEX NAME="mdl_search_docid" UNIQUE="false" FIELDS="docid" NEXT="mdl_search_doctype"/>
- <INDEX NAME="mdl_search_doctype" UNIQUE="false" FIELDS="doctype" PREVIOUS="mdl_search_docid" NEXT="mdl_search_itemtype"/>
- <INDEX NAME="mdl_search_itemtype" UNIQUE="false" FIELDS="itemtype" PREVIOUS="mdl_search_doctype"/>
- </INDEXES>
- </TABLE>
- </TABLES>
-</XMLDB>
View
94 blocks/search/db/upgrade.php
@@ -1,94 +0,0 @@
-<?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/>.
-
-/**
- * Keeps track of upgrades to the global search block
- *
- * @package blocks
- * @subpackage search
- * @copyright 2010 Aparup Banerjee <aparup@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-function xmldb_block_search_upgrade($oldversion) {
- global $CFG, $DB;
-
- require('upgradelib.php');
- $result = TRUE;
- $dbman = $DB->get_manager();
-
- if ($oldversion < 2010101800) {
- // See MDL-24374
- // Changing type of field docdate on table block_search_documents to int
- // Changing type of field updated on table block_search_documents to int
- $table = new xmldb_table('block_search_documents');
-
- $field_docdate_new = new xmldb_field('docdate_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'docdate');
- $field_updated_new = new xmldb_field('updated_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'updated');
- $field_docdate_old = new xmldb_field('docdate');
- $field_updated_old = new xmldb_field('updated');
-
- // Conditionally launch add temporary fields
- if (!$dbman->field_exists($table, $field_docdate_new)) {
- $dbman->add_field($table, $field_docdate_new);
- }
- if (!$dbman->field_exists($table, $field_updated_new)) {
- $dbman->add_field($table, $field_updated_new);
- }
-
- $sql = "SELECT id, docdate, updated FROM {block_search_documents}";
- $search_documents = $DB->get_records_sql($sql);
- if ($search_documents) {
- foreach ($search_documents as $sd) {
- $sd->docdate_new = convert_datetime_upgrade($sd->docdate);
- $sd->updated_new = convert_datetime_upgrade($sd->updated);
- $DB->update_record('block_search_documents', $sd);
- }
- }
- // Conditionally launch drop the old fields
- if ($dbman->field_exists($table, $field_docdate_old)) {
- $dbman->drop_field($table, $field_docdate_old);
- }
- if ($dbman->field_exists($table, $field_updated_old)) {
- $dbman->drop_field($table, $field_updated_old);
- }
-
- //rename the new fields to the original field names.
- $dbman->rename_field($table, $field_docdate_new, 'docdate');
- $dbman->rename_field($table, $field_updated_new, 'updated');
-
- // search savepoint reached
- upgrade_block_savepoint(true, 2010101800, 'search');
- }
-
- if ($oldversion < 2010110900) {
- unset_config('block_search_text');
- unset_config('block_search_button');
- upgrade_block_savepoint(true, 2010110900, 'search');
- }
-
- if ($oldversion < 2010111100) {
- // set block to hidden if global search is disabled.
- if ($CFG->enableglobalsearch != 1) {
- $DB->set_field('block', 'visible', 0, array('name'=>'search')); // Hide block
- }
- upgrade_block_savepoint(true, 2010111100, 'search');
- }
- return $result;
-}
View
57 blocks/search/lang/en/block_search.php
@@ -1,57 +0,0 @@
-<?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/>.
-
-/**
- * Strings for component 'block_search', language 'en', branch 'MOODLE_20_STABLE'
- *
- * @package block_search
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-$string['blockssearchswitches'] = 'Indexer activation for blocks';
-$string['bytes'] = 'bytes (0 stands for no limits)';
-$string['configenablefileindexing'] = 'Enable file indexing';
-$string['configfiletypes'] = 'File types handled';
-$string['configlimitindexbody'] = 'Indexed body size limitation';
-$string['configpdftotextcmd'] = 'Path to command pdftotext';
-$string['configtypetotxtcmd'] = 'Converter\'s command line';
-$string['configtypetotxtenv'] = 'Environment define for converter';
-$string['configwordtotextcmd'] = 'Path to command doctotext';
-$string['configwordtotextenv'] = 'Environment setting for the MSWord converter';
-$string['cmdtoconverttotextfor'] = 'Command to convert {$a} to text';
-$string['enablefileindexing'] = 'Turn on indexing of different file types';
-$string['enableindexinginmodule'] = 'Allow indexing of the {$a} module';
-$string['enableindexinginblock'] = 'Allow indexing of the {$a} block';
-$string['envforcmdtotextfor'] = 'Environment for {$a} conversion command to text';
-$string['go'] = 'Go!';
-$string['handlingfor'] = 'Extra handling for';
-$string['indexbodylimit'] = 'The limit of indexing the body';
-$string['listoffiletypes'] = 'The list of file types handled';
-$string['modulessearchswitches'] = 'Indexer activation for modules';
-$string['nosearchableblocks'] = 'No searchable blocks';
-$string['nosearchablemodules'] = 'No searchable modules';
-$string['pdfhandling'] = 'Acrobat PDF handling';
-$string['pdftotextcmd'] = 'Command to convert PDF to text';
-$string['pluginname'] = 'Global search';
-$string['searchdiscovery'] = 'Searchable items discovery';
-$string['searchmoodle'] = 'Search Moodle';
-$string['usemoodleroot'] = 'Use moodle root for external converters';
-$string['usemoodlerootdescription'] = 'Use moodle root for external converters';
-$string['wordhandling'] = 'Microsoft Word handling';
-$string['wordtotextcmd'] = 'Command to convert Microsoft Word to text';
-$string['wordtotextenv'] = 'Environment setup for Microsoft Word to text converter';
View
123 blocks/search/settings.php
@@ -1,123 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-if ($ADMIN->fulltree) {
-
- //Enable file indexing (y/n)
- $settings->add(new admin_setting_configcheckbox('block_search_enable_file_indexing', get_string('configenablefileindexing', 'block_search'),
- get_string('enablefileindexing', 'block_search'), 0, 1, 0));
-
- //file types
- $defaultfiletypes = 'PDF,TXT,HTML,PPT,XML,DOC,HTM';
- $settings->add(new admin_setting_configtext('block_search_filetypes', get_string('configfiletypes', 'block_search'),
- get_string('listoffiletypes', 'block_search'), $defaultfiletypes, PARAM_TEXT));
-
- // usemoodleroot
- $settings->add(new admin_setting_configcheckbox('block_search_usemoodleroot', get_string('usemoodleroot', 'block_search'),
- get_string('usemoodlerootdescription', 'block_search'), 1, 1, 0));
-
- //limit_index_body
- $settings->add(new admin_setting_configtext('block_search_limit_index_body', get_string('configlimitindexbody', 'block_search'),
- get_string('indexbodylimit', 'block_search'), '', PARAM_INT));
-
- //setup default paths for following configs.
- if ($CFG->ostype == 'WINDOWS') {
- $default_pdf_to_text_cmd = "lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q";
- $default_word_to_text_cmd = "lib/antiword/win32/antiword/antiword.exe ";
- $default_word_to_text_env = "HOME={$CFG->dirroot}\\lib\\antiword\\win32";
- } else {
- $default_pdf_to_text_cmd = "lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q";
- $default_word_to_text_cmd = "lib/antiword/linux/usr/bin/antiword";
- $default_word_to_text_env = "ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword";
- }
-
- //pdf_to_text_cmd
- $settings->add(new admin_setting_configtext('block_search_pdf_to_text_cmd', get_string('configpdftotextcmd', 'block_search'),
- get_string('pdftotextcmd', 'block_search'), $default_pdf_to_text_cmd, PARAM_RAW, 60));
-
- //word_to_text_cmd
- $settings->add(new admin_setting_configtext('block_search_word_to_text_cmd', get_string('configwordtotextcmd', 'block_search'),
- get_string('wordtotextcmd', 'block_search'), $default_word_to_text_cmd, PARAM_RAW, 60));
-
- //word_to_text_env
- $settings->add(new admin_setting_configtext('block_search_word_to_text_env', get_string('configwordtotextenv', 'block_search'),
- get_string('wordtotextenv', 'block_search'), $default_word_to_text_env, PARAM_RAW, 60));
-
-
- // modules activations
- if (isset($CFG->block_search_filetypes)) {
- $types = explode(',', $CFG->block_search_filetypes);
- } else {
- $types = explode(',', $defaultfiletypes);
- }
-
- if (!empty($types)) {
- foreach($types as $type) {
- $utype = strtoupper($type);
- $type = strtolower($type);
- $type = trim($type);
- if (preg_match("/\\b$type\\b/i", $defaultfiletypes)) continue;
-
- //header
- $propname = 'block_search_'.$type.'_to_text';
- $settings->add(new admin_setting_heading($propname, get_string('handlingfor', 'block_search').' '.$utype , ''));
-
- //word_to_text_cmd
- $propname = 'block_search_'.$type.'_to_text_cmd';
- $settings->add(new admin_setting_configtext($propname, get_string('configtypetotxtcmd', 'block_search'),
- get_string('cmdtoconverttotextfor', 'block_search', $type), '', PARAM_PATH, 60));
-
- //word_to_text_env
- $propname = 'block_search_'.$type.'_to_text_env';
- $settings->add(new admin_setting_configtext($propname, get_string('configtypetotxtenv', 'block_search'),
- get_string('envforcmdtotextfor', 'block_search', $type), '', PARAM_PATH, 60));
-
- }
- }
-
- require_once($CFG->dirroot.'/search/lib.php' );
- $searchnames = search_collect_searchables(true, false);
- list($searchable_list, $params) = $DB->get_in_or_equal($searchnames);
-
- //header
- $propname = 'block_search_'.$type.'_to_text';
- $settings->add(new admin_setting_heading($propname, get_string('searchdiscovery', 'block_search') , ''));
-
- $found_searchable_modules = 0;
- if ($modules = $DB->get_records_select('modules', "name $searchable_list", $params, 'name', 'id,name')){
- foreach($modules as $module){
- $keyname = 'search_in_'.$module->name;
- $settings->add(new admin_setting_configcheckbox($keyname, get_string('modulename', $module->name),
- get_string('enableindexinginmodule', 'block_search', $module->name), 1, 1, 0));
- $found_searchable_modules = 1;
- }
- }
-
- if (!$found_searchable_modules) {
- //header
- $propname = 'block_search_nosearchablemodules';
- $settings->add(new admin_setting_heading($propname, get_string('nosearchablemodules', 'block_search') , ''));
- }
-
- //header
- $propname = 'block_search_searchswitches';
- $settings->add(new admin_setting_heading($propname, get_string('blockssearchswitches', 'block_search') , ''));
-
- $found_searchable_blocks = 0;
- if ($blocks = $DB->get_records_select('block', "name $searchable_list", $params, 'name', 'id,name')){
- foreach($blocks as $block){
- $keyname = 'search_in_'.$block->name;
- $settings->add(new admin_setting_configcheckbox($keyname, get_string('pluginname', 'block_'.$block->name),
- get_string('enableindexinginblock', 'block_search', $block->name), 1, 1, 0));
- $found_searchable_blocks = 1;
- }
- }
- if (!$found_searchable_blocks) {
- //header
- $propname = 'block_search_nosearchableblocks';
- $settings->add(new admin_setting_heading($propname, get_string('nosearchableblocks', 'block_search') , ''));
- }
-
-}
-
View
2  calendar/lib.php
@@ -842,7 +842,7 @@ function calendar_filter_controls(moodle_url $returnurl) {
$id = optional_param( 'id',0,PARAM_INT );
- $seturl = new moodle_url('/calendar/set.php', array('return' => $returnurl));
+ $seturl = new moodle_url('/calendar/set.php', array('return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
$content = '<table>';
$content .= '<tr>';
View
10 calendar/renderer.php
@@ -580,7 +580,7 @@ protected function filter_selection_table(calendar_information $calendar, moodle
$output .= html_writer::start_tag('tr');
// Global events
- $link = new moodle_url(CALENDAR_URL.'set.php', array('var' => 'showglobal', 'return' => $returnurl));
+ $link = new moodle_url(CALENDAR_URL.'set.php', array('var' => 'showglobal', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
if (calendar_show_event_type(CALENDAR_EVENT_GLOBAL)) {
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_global', 'style'=>'width:8px;'));
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('globalevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -590,7 +590,7 @@ protected function filter_selection_table(calendar_information $calendar, moodle
}
// Course events
- $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showcourses', 'return' => $returnurl));
+ $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showcourses', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
if (calendar_show_event_type(CALENDAR_EVENT_COURSE)) {
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_course', 'style'=>'width:8px;'));
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('courseevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -603,7 +603,7 @@ protected function filter_selection_table(calendar_information $calendar, moodle
if(isloggedin() && !isguestuser()) {
$output .= html_writer::start_tag('tr');
// Group events
- $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showgroups', 'return' => $returnurl));
+ $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showgroups', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
if (calendar_show_event_type(CALENDAR_EVENT_GROUP)) {
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_group', 'style'=>'width:8px;'));
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -612,7 +612,7 @@ protected function filter_selection_table(calendar_information $calendar, moodle
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
}
// User events
- $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showuser', 'return' => $returnurl));
+ $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showuser', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
if (calendar_show_event_type(CALENDAR_EVENT_USER)) {
$output .= html_writer::tag('td', '', array('class'=>'calendar_event_user', 'style'=>'width:8px;'));
$output .= html_writer::tag('td', html_writer::tag('strong', get_string('userevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -701,7 +701,7 @@ protected function course_filter_selector(moodle_url $returnurl, $label=null) {
} else {
$selected = '';
}
- $select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => $returnurl, 'var' => 'setcourse')), 'id', $courseoptions, $selected, null);
+ $select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => base64_encode($returnurl->out(false)), 'var' => 'setcourse', 'sesskey'=>sesskey())), 'id', $courseoptions, $selected, null);
$select->class = 'cal_courses_flt';
if ($label !== null) {
$select->label = $label;
View
10 calendar/set.php
@@ -41,12 +41,14 @@
require_once('../config.php');
require_once($CFG->dirroot.'/calendar/lib.php');
-$return = required_param('return', PARAM_URL);
+require_sesskey();
+
$var = required_param('var', PARAM_ALPHA);
+$return = clean_param(base64_decode(required_param('return', PARAM_RAW)), PARAM_URL);
-$url = new moodle_url('/calendar/set.php', array('return'=>$return,'var'=>$var));
+$url = new moodle_url('/calendar/set.php', array('return'=>base64_encode($return),'var'=>$var, 'sesskey'=>sesskey()));
$PAGE->set_url($url);
-$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
+$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
switch($var) {
case 'showgroups':
@@ -63,4 +65,4 @@
break;
}
-redirect($return);
+redirect($return);
View
1  enrol/index.php
@@ -82,6 +82,7 @@
$PAGE->navbar->add(get_string('enrolmentoptions','enrol'));
echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('enrolmentoptions','enrol'));
//TODO: find if future enrolments present and display some info
View
4 enrol/manual/lib.php
@@ -209,10 +209,10 @@ public function get_manual_enrol_button(course_enrolment_manager $manager) {
$startdateoptions = array();
$timeformat = get_string('strftimedatefullshort');
if ($startdate > 0) {
- $today = time();
- $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
$startdateoptions[2] = get_string('coursestart') . ' (' . userdate($startdate, $timeformat) . ')';
}
+ $today = time();
+ $today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
$startdateoptions[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
$modules = array('moodle-enrol_manual-quickenrolment', 'moodle-enrol_manual-quickenrolment-skin');
View
1  enrol/self/lang/en/enrol_self.php
@@ -47,6 +47,7 @@
$string['maxenrolled'] = 'Max enrolled users';
$string['maxenrolled_help'] = 'Specifies the maximum number of users that can self enrol. 0 means no limit.';
$string['maxenrolledreached'] = 'Maximum number of users allowed to self-enrol was already reached.';
+$string['nopassword'] = 'No enrolment key required.';
$string['password'] = 'Enrolment key';
$string['password_help'] = 'An enrolment key enables access to the course to be restricted to only those who know the key.
View
9 enrol/self/lib.php
@@ -189,15 +189,6 @@ public function enrol_page_hook(stdClass $instance) {
return null;
}
- if ($instance->customint3 > 0) {
- // max enrol limit specified
- $count = $DB->count_records('user_enrolments', array('enrolid'=>$instance->id));
- if ($count >= $instance->customint3) {
- // bad luck, no more self enrolments here
- return $OUTPUT->notification(get_string('maxenrolledreached', 'enrol_self'));
- }
- }
-
require_once("$CFG->dirroot/enrol/self/locallib.php");
require_once("$CFG->dirroot/group/lib.php");
View
26 enrol/self/locallib.php
@@ -30,6 +30,7 @@
class enrol_self_enrol_form extends moodleform {
protected $instance;
+ protected $toomany = false;
/**
* Overriding this function to get unique form id for multiple self enrolments
@@ -42,19 +43,33 @@ protected function get_form_identifier() {
}
public function definition() {
+ global $DB;
+
$mform = $this->_form;
$instance = $this->_customdata;
$this->instance = $instance;
$plugin = enrol_get_plugin('self');
+ $heading = $plugin->get_instance_name($instance);
+ $mform->addElement('header', 'selfheader', $heading);
+
+ if ($instance->customint3 > 0) {
+ // max enrol limit specified
+ $count = $DB->count_records('user_enrolments', array('enrolid'=>$instance->id));
+ if ($count >= $instance->customint3) {
+ // bad luck, no more self enrolments here
+ $this->toomany = true;
+ $mform->addElement('static', 'notice', '', get_string('maxenrolledreached', 'enrol_self'));
+ return;
+ }
+ }
+
if ($instance->password) {
- $heading = $plugin->get_instance_name($instance);
- $mform->addElement('header', 'selfheader', $heading);
//change the id of self enrolment key input as there can be multiple self enrolment methods
$mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_self'),
array('id' => $instance->id."_enrolpassword"));
} else {
- // nothing?
+ $mform->addElement('static', 'nokey', '', get_string('nopassword', 'enrol_self'));
}
$this->add_action_buttons(false, get_string('enrolme', 'enrol_self'));
@@ -74,6 +89,11 @@ public function validation($data, $files) {
$errors = parent::validation($data, $files);
$instance = $this->instance;
+ if ($this->toomany) {
+ $errors['notice'] = get_string('error');
+ return $errors;
+ }
+
if ($instance->password) {
if ($data['enrolpassword'] !== $instance->password) {
if ($instance->customint1) {
View
2  enrol/self/version.php
@@ -26,5 +26,5 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2010090501;
+$plugin->version = 2010090502;
$plugin->cron = 180;
View
40 filter/data/db/install.php
@@ -0,0 +1,40 @@
+<?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/>.
+
+/**
+ * Database activity filter post install hook
+ *
+ * @package filter
+ * @subpackage data
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+function xmldb_filter_data_install() {
+ global $DB;
+
+ // If the legacy mod/data filter is installed we need to:
+ // 1- Delete new filter (filter_active and filter_config) information, in order to
+ // 2- Usurpate the identity of the legacy filter by moving all its
+ // information to filter/data
+ // If the legacy mod/data filter was not installed, no action is needed
+ if ($DB->record_exists('filter_active', array('filter' => 'mod/data'))) {
+ $DB->delete_records('filter_active', array('filter' => 'filter/data'));
+ $DB->set_field('filter_active', 'filter', 'filter/data', array('filter' => 'mod/data'));
+ }
+}
View
129 filter/data/filter.php
@@ -0,0 +1,129 @@
+<?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/>.
+
+/**
+ * This filter provides automatic linking to database activity entries
+ * when found inside every Moodle text.
+ *
+ * @package filter
+ * @subpackage data
+ * @copyright 2006 Vy-Shane Sin Fat
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Database activity filtering
+ */
+class filter_data extends moodle_text_filter {
+
+ public function filter($text, array $options = array()) {
+ global $CFG, $DB;
+
+ // Trivial-cache - keyed on $cachedcontextid
+ static $cachedcontextid;
+ static $contentlist;
+
+ static $nothingtodo;
+
+ // Try to get current course
+ if (!$courseid = get_courseid_from_context($this->context)) {
+ $courseid = 0;
+ }
+
+ // Initialise/invalidate our trivial cache if dealing with a different context
+ if (!isset($cachedcontextid) || $cachedcontextid !== $this->context->id) {
+ $cachedcontextid = $this->context->id;
+ $contentlist = array();
+ $nothingtodo = false;
+ }
+
+ if ($nothingtodo === true) {
+ return $text;
+ }
+
+ // Create a list of all the resources to search for. It may be cached already.
+ if (empty($contentlist)) {
+ $coursestosearch = $courseid ? array($courseid) : array(); // Add courseid if found
+ if (get_site()->id != $courseid) { // Add siteid if was not courseid
+ $coursestosearch[] = get_site()->id;
+ }
+ // We look for text field contents only if have autolink enabled (param1)
+ list ($coursesql, $params) = $DB->get_in_or_equal($coursestosearch);
+ $sql = 'SELECT dc.id AS contentid, dr.id AS recordid, dc.content AS content, d.id AS dataid
+ FROM {data} d
+ JOIN {data_fields} df ON df.dataid = d.id
+ JOIN {data_records} dr ON dr.dataid = d.id
+ JOIN {data_content} dc ON dc.fieldid = df.id AND dc.recordid = dr.id
+ WHERE d.course ' . $coursesql . '
+ AND df.type = \'text\'
+ AND ' . $DB->sql_compare_text('df.param1', 1) . ' = 1';
+
+ if (!$contents = $DB->get_records_sql($sql, $params)) {
+ $nothingtodo = true;
+ return $text;
+ }
+
+ foreach ($contents as $key => $content) {
+ // Trim empty or unlinkable concepts
+ $currentcontent = trim(strip_tags($content->content));
+ if (empty($currentcontent)) {
+ unset($contents[$key]);
+ continue;
+ } else {
+ $contents[$key]->content = $currentcontent;
+ }
+
+ // Rule out any small integers. See bug 1446
+ $currentint = intval($currentcontent);
+ if ($currentint && (strval($currentint) == $currentcontent) && $currentint < 1000) {
+ unset($contents[$key]);
+ }
+ }
+
+ if (empty($contents)) {
+ $nothingtodo = true;
+ return $text;
+ }
+
+ usort($contents, 'filter_data::sort_entries_by_length');
+
+ foreach ($contents as $content) {
+ $href_tag_begin = '<a class="data autolink dataid'.$content->dataid.'" title="'.$content->content.'" '.
+ 'href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$content->dataid.
+ '&amp;rid='.$content->recordid.'">';
+ $contentlist[] = new filterobject($content->content, $href_tag_begin, '</a>', false, true);
+ }
+
+ $contentlist = filter_remove_duplicates($contentlist); // Clean dupes
+ }
+ return filter_phrases($text, $contentlist); // Look for all these links in the text
+ }
+
+ private static function sort_entries_by_length($content0, $content1) {
+ $len0 = strlen($content0->content);
+ $len1 = strlen($content1->content);
+
+ if ($len0 < $len1) {
+ return 1;
+ } else if ($len0 > $len1) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+}
View
15 blocks/search/version.php → filter/data/lang/en/filter_data.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -15,5 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
-$plugin->version = 2010111100;
-$plugin->cron = 1;
+/**
+ * Strings for filter_data
+ *
+ * @package filter
+ * @subpackage data
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$string['filtername'] = 'Database auto-linking';
View
30 blocks/search/db/upgradelib.php → filter/data/version.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -16,31 +15,18 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Global search block upgrade related helper functions
+ * Data activity filter version information
*
- * @package blocks
- * @subpackage search
- * @copyright 2010 Aparup Banerjee
+ * @package filter
+ * @subpackage data
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
-/*
-* Function to turn a mysql(datetime) or postgres(timestamp without timezone data) or any generic date string (YYYY-MM-DD HH:MM:SS)
-* read in from a database's date/time field (ie:valid) into a unix timestamp
-* @param str The string to be converted to timestamp
-* @return timestamp or 0
-*/
-
-function convert_datetime_upgrade($str) {
-
- $timestamp = strtotime($str);
- //process different failure returns due to different php versions
- if ($timestamp === false || $timestamp < 1) {
- return 0;
- } else {
- return $timestamp;
- }
-}
+$plugin->version = 2011102800;
+$plugin->requires = 2011102700; // Requires this Moodle version
+$plugin->component= 'filter_data';
+$plugin->dependencies = array('mod_data' => 2011102800);
View
40 filter/glossary/db/install.php
@@ -0,0 +1,40 @@
+<?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/>.
+
+/**
+ * Glossary filter post install hook
+ *
+ * @package filter
+ * @subpackage glossary
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+function xmldb_filter_glossary_install() {
+ global $DB;
+
+ // If the legacy mod/glossary filter is installed we need to:
+ // 1- Delete new filter (filter_active and filter_config) information, in order to
+ // 2- Usurpate the identity of the legacy filter by moving all its
+ // information to filter/glossary
+ // If the legacy mod/glossary filter was not installed, no action is needed
+ if ($DB->record_exists('filter_active', array('filter' => 'mod/glossary'))) {
+ $DB->delete_records('filter_active', array('filter' => 'filter/glossary'));
+ $DB->set_field('filter_active', 'filter', 'filter/glossary', array('filter' => 'mod/glossary'));
+ }
+}
View
226 filter/glossary/filter.php
@@ -0,0 +1,226 @@
+<?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/>.
+
+/**
+ * This filter provides automatic linking to
+ * glossary entries, aliases and categories when
+ * found inside every Moodle text
+ *
+ * @package filter
+ * @subpackage glossary
+ * @copyright 2004 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Glossary filtering
+ *
+ * TODO: erase the $GLOSSARY_EXCLUDECONCEPTS global => require format_text()
+ * to be able to pass arbitrary $options['filteroptions']['glossary'] to filter_text()
+ */
+class filter_glossary extends moodle_text_filter {
+
+ public function filter($text, array $options = array()) {
+ global $CFG, $DB, $GLOSSARY_EXCLUDECONCEPTS, $PAGE;
+
+ // Trivial-cache - keyed on $cachedcontextid
+ static $cachedcontextid;
+ static $conceptlist;
+
+ static $jsinitialised; // To control unique js init
+ static $nothingtodo; // To avoid processing if no glossaries / concepts are found
+
+ // Try to get current course
+ if (!$courseid = get_courseid_from_context($this->context)) {
+ $courseid = 0;
+ }
+
+ // Initialise/invalidate our trivial cache if dealing with a different context
+ if (!isset($cachedcontextid) || $cachedcontextid !== $this->context->id) {
+ $cachedcontextid = $this->context->id;
+ $conceptlist = array();
+ $nothingtodo = false;
+ }
+
+ if ($nothingtodo === true) {
+ return $text;
+ }
+
+ // Create a list of all the concepts to search for. It may be cached already.
+ if (empty($conceptlist)) {
+
+ // Find all the glossaries we need to examine
+ if (!$glossaries = $DB->get_records_sql_menu('
+ SELECT g.id, g.name
+ FROM {glossary} g, {course_modules} cm, {modules} m
+ WHERE m.name = \'glossary\'
+ AND cm.module = m.id
+ AND cm.visible = 1
+ AND g.id = cm.instance
+ AND g.usedynalink != 0
+ AND (g.course = ? OR g.globalglossary = 1)
+ ORDER BY g.globalglossary, g.id', array($courseid))) {
+ $nothingtodo = true;
+ return $text;
+ }
+
+ // Make a list of glossary IDs for searching
+ $glossarylist = implode(',', array_keys($glossaries));
+
+ // Pull out all the raw data from the database for entries, categories and aliases
+ $entries = $DB->get_records_select('glossary_entries',
+ 'glossaryid IN ('.$glossarylist.') AND usedynalink != 0 AND approved != 0 ', null, '',
+ 'id,glossaryid, concept, casesensitive, 0 AS category, fullmatch');
+
+ $categories = $DB->get_records_select('glossary_categories',
+ 'glossaryid IN ('.$glossarylist.') AND usedynalink != 0', null, '',
+ 'id,glossaryid,name AS concept, 1 AS casesensitive, 1 AS category, 1 AS fullmatch');
+
+ $aliases = $DB->get_records_sql('
+ SELECT ga.id, ge.id AS entryid, ge.glossaryid,
+ ga.alias AS concept, ge.concept AS originalconcept,
+ casesensitive, 0 AS category, fullmatch
+ FROM {glossary_alias} ga,
+ {glossary_entries} ge
+ WHERE ga.entryid = ge.id
+ AND ge.glossaryid IN ('.$glossarylist.')
+ AND ge.usedynalink != 0
+ AND ge.approved != 0', null);
+
+ // Combine them into one big list
+ $concepts = array();
+ if ($entries and $categories) {
+ $concepts = array_merge($entries, $categories);
+ } else if ($categories) {
+ $concepts = $categories;
+ } else if ($entries) {
+ $concepts = $entries;
+ }
+
+ if ($aliases) {
+ $concepts = array_merge($concepts, $aliases);
+ }
+
+ if (!empty($concepts)) {
+ foreach ($concepts as $key => $concept) {
+ // Trim empty or unlinkable concepts
+ $currentconcept = trim(strip_tags($concept->concept));
+ if (empty($currentconcept)) {
+ unset($concepts[$key]);
+ continue;
+ } else {
+ $concepts[$key]->concept = $currentconcept;
+ }
+
+ // Rule out any small integers. See bug 1446
+ $currentint = intval($currentconcept);
+ if ($currentint && (strval($currentint) == $currentconcept) && $currentint < 1000) {
+ unset($concepts[$key]);
+ }
+ }
+ }
+
+ if (empty($concepts)) {
+ $nothingtodo = true;
+ return $text;
+ }
+
+ usort($concepts, 'filter_glossary::sort_entries_by_length');
+
+ $strcategory = get_string('category', 'glossary');
+
+ // Loop through all the concepts, setting up our data structure for the filter
+ $conceptlist = array(); // We will store all the concepts here
+
+ foreach ($concepts as $concept) {
+ $glossaryname = str_replace(':', '-', $glossaries[$concept->glossaryid]);
+ if ($concept->category) { // Link to a category
+ // TODO: Fix this string usage
+ $title = strip_tags($glossaryname.': '.$strcategory.' '.$concept->concept);
+ $href_tag_begin = '<a class="glossary autolink category glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
+ 'href="'.$CFG->wwwroot.'/mod/glossary/view.php?g='.$concept->glossaryid.
+ '&amp;mode=cat&amp;hook='.$concept->id.'">';
+ } else { // Link to entry or alias
+ if (!empty($concept->originalconcept)) { // We are dealing with an alias (so show and point to original)
+ $title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->originalconcept));
+ $concept->id = $concept->entryid;
+ } else { // This is an entry
+ $title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
+ }
+ // hardcoding dictionary format in the URL rather than defaulting
+ // to the current glossary format which may not work in a popup.
+ // for example "entry list" means the popup would only contain
+ // a link that opens another popup.
+ $link = new moodle_url('/mod/glossary/showentry.php', array('courseid'=>$courseid, 'eid'=>$concept->id, 'displayformat'=>'dictionary'));
+ $attributes = array(
+ 'href' => $link,
+ 'title'=> $title,
+ 'class'=> 'glossary autolink concept glossaryid'.$concept->glossaryid);
+
+ // this flag is optionally set by resource_pluginfile()
+ // if processing an embedded file use target to prevent getting nested Moodles
+ if (isset($CFG->embeddedsoforcelinktarget) && $CFG->embeddedsoforcelinktarget) {
+ $attributes['target'] = '_top';
+ }
+
+ $href_tag_begin = html_writer::start_tag('a', $attributes);
+ }
+ $conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>',
+ $concept->casesensitive, $concept->fullmatch);
+ }
+
+ $conceptlist = filter_remove_duplicates($conceptlist);
+
+ if (empty($jsinitialised)) {
+ // Add a JavaScript event to open popup's here. This only ever need to be
+ // added once!
+ $PAGE->requires->yui_module(
+ 'moodle-filter_glossary-autolinker',
+ 'M.filter_glossary.init_filter_autolinking',
+ array(array('courseid' => $courseid)));
+ $jsinitialised = true;
+ }
+ }
+
+ if (!empty($GLOSSARY_EXCLUDECONCEPTS)) {
+ $reducedconceptlist=array();
+ foreach($conceptlist as $concept) {
+ if(!in_array($concept->phrase,$GLOSSARY_EXCLUDECONCEPTS)) {
+ $reducedconceptlist[]=$concept;
+ }
+ }
+ return filter_phrases($text, $reducedconceptlist);
+ }
+
+ return filter_phrases($text, $conceptlist); // Actually search for concepts!
+ }
+
+
+ private static function sort_entries_by_length($entry0, $entry1) {
+ $len0 = strlen($entry0->concept);
+ $len1 = strlen($entry1->concept);
+
+ if ($len0 < $len1) {
+ return 1;
+ } else if ($len0 > $len1) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+}
View
14 ...ormat/qti_two/lang/en/qformat_qti_two.php → filter/glossary/lang/en/filter_glossary.php
@@ -15,14 +15,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
- * Strings for component 'qformat_qti_two', language 'en', branch 'MOODLE_20_STABLE'
+ * Strings for filter_glossary
*
- * @package qformat
- * @subpackage qti_two
- * @copyright 2010 Helen Foster
+ * @package filter
+ * @subpackage glossary
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['qti_two'] = 'IMS QTI 2.0 format';
-$string['qti_two_help'] = 'This format enables questions to be exported in the standard IMS QTI format (version 2.0) via a zip file.';
-$string['qti_two_link'] = 'qformat/qti/two';
+defined('MOODLE_INTERNAL') || die();
+
+$string['filtername'] = 'Glossary auto-linking';
View
1  filter/glossary/styles.css
@@ -0,0 +1 @@
+#glossaryfilteroverlayprogress {position:fixed;top:50%;width:100%;text-align:center;}
View
32 filter/glossary/version.php
@@ -0,0 +1,32 @@
+<?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/>.
+
+/**
+ * Glossary filter version information
+ *
+ * @package filter
+ * @subpackage glossary
+ * @copyright 2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2011102800;
+$plugin->requires = 2011102700; // Requires this Moodle version
+$plugin->component= 'filter_glossary';
+
+$plugin->dependencies = array('mod_glossary' => 2011102800);
View
14 mod/glossary/yui/autolinker/autolinker.js → filter/glossary/yui/autolinker/autolinker.js
@@ -1,6 +1,6 @@
-YUI.add('moodle-mod_glossary-autolinker', function(Y) {
+YUI.add('moodle-filter_glossary-autolinker', function(Y) {
- var AUTOLINKERNAME = 'Glossary autolinker',
+ var AUTOLINKERNAME = 'Glossary filter autolinker',
URL = 'url',
POPUPNAME = 'name',
POPUPOPTIONS = 'options',
@@ -33,7 +33,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
//display a progress indicator
var title = '';
- var content = Y.Node.create('<div id="glossaryoverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
+ var content = Y.Node.create('<div id="glossaryfilteroverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
var o = new Y.Overlay({
headerContent : title,
bodyContent : content
@@ -61,7 +61,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
};
Y.io(fullurl, cfg);
- }, Y.one(document.body), 'a.glossary.autolink');
+ }, Y.one(document.body), 'a.glossary.autolink.concept');
},
display_callback : function(content) {
try {
@@ -126,9 +126,9 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
}
});
- M.mod_glossary = M.mod_glossary || {};
- M.mod_glossary.init_filter_autolinking = function(config) {
+ M.filter_glossary = M.filter_glossary || {};
+ M.filter_glossary.init_filter_autolinking = function(config) {
return new AUTOLINKER(config);
}
-}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
+}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
View
2  group/clientlib.js
@@ -183,7 +183,7 @@ var createLoaderImg = function (elClass, parentId, wwwRoot) {
}
var loadingImg = document.createElement("img");
- loadingImg.setAttribute("src", M.util.image_url('moodle', '/i/ajaxloader'));
+ loadingImg.setAttribute("src", M.util.image_url('/i/ajaxloader', 'moodle'));
loadingImg.setAttribute("class", elClass);
loadingImg.setAttribute("alt", "Loading");
loadingImg.setAttribute("id", "loaderImg");
View
3  install/lang/en/install.php
@@ -32,7 +32,8 @@
$string['availablelangs'] = 'List of available languages';
$string['chooselanguagehead'] = 'Choose a language';
$string['chooselanguagesub'] = 'Please choose a language for the installation. This language will also be used as the default language for the site, though it may be changed later.';
-$string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if you want to upgrade your site.';
+$string['clialreadyconfigured'] = 'File config.php already exists, please use admin/cli/install_database.php if you want to install this site.';
+$string['clialreadyinstalled'] = 'File config.php already exists, please use admin/cli/upgrade.php if you want to upgrade this site.';
$string['cliinstallheader'] = 'Moodle {$a} command line installation program';
$string['databasehost'] = 'Database host';
$string['databasename'] = 'Database name';
View
2  install/lang/et/admin.php
@@ -28,5 +28,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['clianswerno'] = 'ei';
+$string['cliansweryes'] = 'jah';
$string['environmentrequireinstall'] = 'on nõutud, et oleks installeeritud ja võimaldatud';
$string['environmentrequireversion'] = 'versioon {$a->needed} on nõutud, Sinul on jooksmas versioon {$a->current}';
View
3  install/lang/fr/install.php
@@ -32,7 +32,8 @@
$string['availablelangs'] = 'Liste des langues disponibles';
$string['chooselanguagehead'] = 'Choisissez une langue';
$string['chooselanguagesub'] = 'Veuillez choisir la langue d\'installation. Cette langue sera utilisée comme langue par défaut du site, que vous pourrez modifier ultérieurement.';
-$string['clialreadyinstalled'] = 'Le fichier config.php existe déjà. Veuillez utiliser admin/cli/upgrade.php si vous désirez mettre à jour votre site.';
+$string['clialreadyconfigured'] = 'Le fichier config.php existe déjà. Veuillez utiliser admin/cli/install_database.php si vous désirez mettre à jour ce site.';
+$string['clialreadyinstalled'] = 'Le fichier config.php existe déjà. Veuillez utiliser admin/cli/upgrade.php si vous désirez mettre à jour ce site.';
$string['cliinstallheader'] = 'Programme d\'installation de Moodle {$a} en ligne de commande';
$string['databasehost'] = 'Serveur de base de données';
$string['databasename'] = 'Nom de la base de données';
View
2  lang/en/admin.php
@@ -189,7 +189,6 @@
$string['configenablecalendarexport'] = 'Enable exporting or subscribing to calendars.';
$string['configenablecomments'] = 'Enable comments';
$string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
-$string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.';
$string['configenablegroupmembersonly'] = 'If enabled, access to activities can be restricted to group members only. This may result in an increased server load. In addition, gradebook categories must be set up in a certain way to ensure that activities are hidden from non-group members.';
$string['configenablemobilewebservice'] = 'Enable mobile service for the official Moodle app or other app requesting it. For more information, read the {$a}';
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
@@ -468,7 +467,6 @@
$string['enablecourseajax_desc'] = 'Allow AJAX when editing main course pages. Note that the course format and the theme must support AJAX editing and the user has to enable AJAX in their profiles, too.';
$string['enablecourserequests'] = 'Enable course requests';
$string['enabledevicedetection'] = 'Enable device detection';
-$string['enableglobalsearch'] = 'Enable global search';
$string['enablegravatar'] = 'Enable Gravatar';
$string['enablegravatar_help'] = 'When enabled Moodle will attempt to fetch a user profile picture from Gravatar if the user has not uploaded an image.';
$string['enablegroupmembersonly'] = 'Enable group members only';
View
1  lang/en/question.php
@@ -219,6 +219,7 @@
$string['nopermissionadd'] = 'You don\'t have permission to add questions here.';
$string['nopermissionmove'] = 'You don\'t have permission to move questions from here. You must save the question in this category or save it as a new question.';
$string['noprobs'] = 'No problems found in your question database.';
+$string['noquestionsinfile'] = 'There are no questions in the import file';
$string['notenoughanswers'] = 'This type of question requires at least {$a} answers';
$string['notenoughdatatoeditaquestion'] = 'Neither a question id, nor a category id and question type, was specified.';
$string['notenoughdatatomovequestions'] = 'You need to provide the question ids of questions you want to move.';
View
148 lib/accesslib.php
@@ -1969,31 +1969,70 @@ function is_enrolled(context $context, $user = null, $withcapability = '', $only
* of this function can_access_course and require_login. Doing so WILL break future
* versions.
*
- * @param context $context
- * @param stdClass|null $user
+ * @param stdClass $course record
+ * @param stdClass|int|null $user user record or id, current user if null
* @param string $withcapability Check for this capability as well.
* @param bool $onlyactive consider only active enrolments in enabled plugins and time restrictions
- * @param boolean $trustcache If set to false guest access will always be checked
- * against the enrolment plugins from the course, rather
- * than the cache generated by require_login.
* @return boolean Returns true if the user is able to access the course
*/
-function can_access_course(context $context, $user = null, $withcapability = '', $onlyactive = false, $trustcache = true) {
+function can_access_course(stdClass $course, $user = null, $withcapability = '', $onlyactive = false) {
global $DB, $USER;
- $coursecontext = $context->get_course_context();
- $courseid = $coursecontext->instanceid;
+ // this function originally accepted $coursecontext parameter
+ if ($course instanceof context) {
+ if ($course instanceof context_course) {
+ debugging('deprecated context parameter, please use $course record');
+ $coursecontext = $course;
+ $course = $DB->get_record('course', array('id'=>$coursecontext->instanceid));
+ } else {
+ debugging('Invalid context parameter, please use $course record');
+ return false;
+ }
+ } else {
+ $coursecontext = context_course::instance($course->id);
+ }
- // First check the obvious, is the user viewing or is the user enrolled.
- if (is_viewing($coursecontext, $user, $withcapability) || is_enrolled($coursecontext, $user, $withcapability, $onlyactive)) {
- // How easy was that!
+ if (!isset($USER->id)) {
+ // should never happen
+ $USER->id = 0;
+ }
+
+ // make sure there is a user specified
+ if ($user === null) {
+ $userid = $USER->id;
+ } else {
+ $userid = is_object($user) ? $user->id : $user;
+ }
+ unset($user);
+
+ if ($withcapability and !has_capability($withcapability, $coursecontext, $userid)) {
+ return false;
+ }
+
+ if ($userid == $USER->id) {
+ if (!empty($USER->access['rsw'][$coursecontext->path])) {
+ // the fact that somebody switched role means they can access the course no matter to what role they switched
+ return true;
+ }
+ }
+
+ if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext, $userid)) {
+ return false;
+ }
+
+ if (is_viewing($coursecontext, $userid)) {
return true;
}
- $access = false;
+ if ($userid != $USER->id) {
+ // for performance reasons we do not verify temporary guest access for other users, sorry...
+ return is_enrolled($coursecontext, $userid, '', $onlyactive);
+ }
+
+ // === from here we deal only with $USER ===
+
+ // verify our caches
if (!isset($USER->enrol)) {
- // Cache hasn't been generated yet so we can't trust it
- $trustcache = false;
/**
* These flags within the $USER object should NEVER be used outside of this
* function can_access_course and the function require_login.
@@ -2003,41 +2042,64 @@ function can_access_course(context $context, $user = null, $withcapability = '',
$USER->enrol['enrolled'] = array();
$USER->enrol['tempguest'] = array();
}
+ if (isset($USER->enrol['enrolled'][$course->id])) {
+ if ($USER->enrol['enrolled'][$course->id] == 0) {
+ return true;
+ } else if ($USER->enrol['enrolled'][$course->id] > time()) {
+ return true;
+ }
+ }
+ if (isset($USER->enrol['tempguest'][$course->id])) {
+ if ($USER->enrol['tempguest'][$course->id] == 0) {
+ return true;
+ } else if ($USER->enrol['tempguest'][$course->id] > time()) {
+ return true;
+ }
+ }
- // If we don't trust the cache we need to check with the courses enrolment
- // plugin instances to see if the user can access the course as a guest.
- if (!$trustcache) {
- // Ok, off to the database we go!
- $instances = $DB->get_records('enrol', array('courseid'=>$courseid, 'status'=>ENROL_INSTANCE_ENABLED), 'sortorder, id ASC');
- $enrols = enrol_get_plugins(true);
- foreach($instances as $instance) {
- if (!isset($enrols[$instance->enrol])) {
- continue;
- }
- $until = $enrols[$instance->enrol]->try_guestaccess($instance);
- if ($until !== false) {
- // Never use me anywhere but here and require_login
- $USER->enrol['tempguest'][$courseid] = $until;
- $access = true;
- break;
- }
+ if (is_enrolled($coursecontext, $USER, '', true)) {
+ // active participants may always access
+ // TODO: refactor this into some new function
+ $now = time();
+ $sql = "SELECT MAX(ue.timeend)
+ FROM {user_enrolments} ue
+ JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid)
+ JOIN {user} u ON u.id = ue.userid
+ WHERE ue.userid = :userid AND ue.status = :active AND e.status = :enabled AND u.deleted = 0
+ AND ue.timestart < :now1 AND (ue.timeend = 0 OR ue.timeend > :now2)";
+ $params = array('enabled'=>ENROL_INSTANCE_ENABLED, 'active'=>ENROL_USER_ACTIVE,
+ 'userid'=>$USER->id, 'courseid'=>$coursecontext->instanceid, 'now1'=>$now, 'now2'=>$now);
+ $until = $DB->get_field_sql($sql, $params);
+ if (!$until or $until > time() + ENROL_REQUIRE_LOGIN_CACHE_PERIOD) {
+ $until = time() + ENROL_REQUIRE_LOGIN_CACHE_PERIOD;
}
+
+ $USER->enrol['enrolled'][$course->id] = $until;
+
+ // remove traces of previous temp guest access
+ remove_temp_course_roles($coursecontext);
+
+ return true;
}
+ unset($USER->enrol['enrolled'][$course->id]);
- // If we don't already have access (from above) check the cache and see whether
- // there is record of it in there.
- if (!$access && isset($USER->enrol['tempguest'][$courseid])) {
- // Never use me anywhere but here and require_login
- if ($USER->enrol['tempguest'][$courseid] == 0) {
- $access = true;
- } else if ($USER->enrol['tempguest'][$courseid] > time()) {
- $access = true;
- } else {
- //expired
- unset($USER->enrol['tempguest'][$courseid]);
+ // if not enrolled try to gain temporary guest access
+ $instances = $DB->get_records('enrol', array('courseid'=>$course->id, 'status'=>ENROL_INSTANCE_ENABLED), 'sortorder, id ASC');
+ $enrols = enrol_get_plugins(true);
+ foreach($instances as $instance) {
+ if (!isset($enrols[$instance->enrol])) {
+ continue;
+ }
+ // Get a duration for the guestaccess, a timestamp in the future or false.
+ $until = $enrols[$instance->enrol]->try_guestaccess($instance);
+ if ($until !== false) {
+ $USER->enrol['tempguest'][$course->id] = $until;
+ return true;
}
}
- return $access;
+ unset($USER->enrol['tempguest'][$course->id]);
+
+ return false;
}
/**
View
31 lib/db/upgrade.php
@@ -6878,6 +6878,37 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011101900.02);
}
+ if ($oldversion < 2011102700.01) {
+ // purge everything related to abandoned experimental global search
+
+ // unset setting - this disables it in case user does not delete the dirs
+ unset_config('enableglobalsearch');
+
+ // Delete block, instances and db table
+ $table = new xmldb_table('block_search_documents');
+ if ($dbman->table_exists($table)) {
+ $instances = $DB->get_records('block_instances', array('blockname'=>'search'));
+ foreach($instances as $instance) {
+ context_helper::delete_instance(CONTEXT_BLOCK, $instance->id);
+ $DB->delete_records('block_positions', array('blockinstanceid' => $instance->id));
+ $DB->delete_records('block_instances', array('id' => $instance->id));
+ }
+ $DB->delete_records('block', array('name'=>'search'));
+
+ $dbman->drop_table($table);
+ }
+
+ // purge all settings used by the search block
+ $like = $DB->sql_like('name', '?', true, true, false, '|');
+ $params = array($DB->sql_like_escape('block_search_', '|') . '%', $DB->sql_like_escape('search_in_', '|') . '%');
+ $settings = $DB->get_records_select('config', "$like OR $like", $params);
+ foreach ($settings as $setting) {
+ unset_config($setting->name);
+ }
+
+ upgrade_main_savepoint(true, 2011102700.01);