Merge branch 'MDL-43230-master' of git://github.com/ryanwyllie/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 18 Oct 2016 20:35:53 +0000 (22:35 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 18 Oct 2016 20:35:53 +0000 (22:35 +0200)
668 files changed:
.eslintignore
.eslintrc
.stylelintignore
.travis.yml
Gruntfile.js
admin/index.php
admin/renderer.php
admin/settings/security.php
admin/tool/behat/cli/init.php
admin/tool/behat/cli/util.php
admin/tool/behat/cli/util_single_run.php
admin/tool/behat/tests/behat/datetime_strings.feature [new file with mode: 0644]
admin/tool/behat/tests/behat/nasty_strings.feature
admin/tool/behat/tests/manager_util_test.php
admin/tool/mobile/autologin.php [new file with mode: 0644]
admin/tool/mobile/classes/api.php
admin/tool/mobile/classes/external.php
admin/tool/mobile/db/services.php
admin/tool/mobile/lang/en/tool_mobile.php
admin/tool/mobile/tests/api_test.php [new file with mode: 0644]
admin/tool/mobile/tests/externallib_test.php
admin/tool/mobile/version.php
admin/tool/monitor/tests/behat/subscription.feature
admin/tool/templatelibrary/classes/api.php
auth/upgrade.txt
backup/cc/cc2moodle.php
blocks/course_overview/tests/behat/block_course_overview.feature
blocks/login/block_login.php
blocks/messages/tests/behat/block_messages_course.feature
blocks/messages/tests/behat/block_messages_dashboard.feature
blocks/messages/tests/behat/block_messages_frontpage.feature
blocks/online_users/block_online_users.php
blocks/participants/tests/behat/block_participants_course.feature
blocks/settings/amd/build/settingsblock.min.js
blocks/settings/amd/src/settingsblock.js
blog/external_blog_edit_form.php
cache/classes/factory.php
cache/disabledlib.php
cache/locallib.php
cache/stores/apcu/lib.php
competency/classes/api.php
competency/tests/api_test.php
composer.json
composer.lock
course/format/lib.php
course/format/topics/styles.css
course/format/weeks/styles.css
course/lib.php
course/tests/behat/course_category_management_listing.feature
enrol/ajax.php
enrol/locallib.php
enrol/manual/yui/quickenrolment/quickenrolment.js
enrol/yui/otherusersmanager/otherusersmanager.js
enrol/yui/rolemanager/rolemanager.js
grade/edit/outcome/edit.php
grade/report/overview/classes/external.php [new file with mode: 0644]
grade/report/overview/db/services.php [new file with mode: 0644]
grade/report/overview/index.php
grade/report/overview/lib.php
grade/report/overview/tests/externallib_test.php [new file with mode: 0644]
grade/report/overview/version.php
grade/report/user/index.php
grade/report/user/lang/en/gradereport_user.php
grade/report/user/lib.php
grade/report/user/renderer.php
grade/report/user/styles.css
grade/report/user/tests/behat/user_view.feature [new file with mode: 0644]
grade/tests/behat/behat_grade.php
grade/tests/behat/grade_aggregation.feature
grade/tests/behat/grade_hidden_items.feature
install/lang/cs/install.php
install/lang/mis/langconfig.php
install/lang/ne/install.php [new file with mode: 0644]
install/lang/ne/moodle.php [new file with mode: 0644]
iplookup/tests/geoip_test.php
lang/en/admin.php
lang/en/error.php
lang/en/message.php
lang/en/moodle.php
lang/en/webservice.php
lib/accesslib.php
lib/adminlib.php
lib/adodb/adodb-active-record.inc.php
lib/adodb/adodb-active-recordx.inc.php
lib/adodb/adodb-csvlib.inc.php
lib/adodb/adodb-datadict.inc.php
lib/adodb/adodb-error.inc.php
lib/adodb/adodb-errorhandler.inc.php
lib/adodb/adodb-errorpear.inc.php
lib/adodb/adodb-exceptions.inc.php
lib/adodb/adodb-iterator.inc.php
lib/adodb/adodb-lib.inc.php
lib/adodb/adodb-memcache.lib.inc.php
lib/adodb/adodb-pager.inc.php
lib/adodb/adodb-pear.inc.php
lib/adodb/adodb-perf.inc.php
lib/adodb/adodb-php4.inc.php
lib/adodb/adodb-time.inc.php
lib/adodb/adodb-xmlschema.inc.php
lib/adodb/adodb-xmlschema03.inc.php
lib/adodb/adodb.inc.php
lib/adodb/datadict/datadict-access.inc.php
lib/adodb/datadict/datadict-db2.inc.php
lib/adodb/datadict/datadict-firebird.inc.php
lib/adodb/datadict/datadict-generic.inc.php
lib/adodb/datadict/datadict-ibase.inc.php
lib/adodb/datadict/datadict-informix.inc.php
lib/adodb/datadict/datadict-mssql.inc.php
lib/adodb/datadict/datadict-mssqlnative.inc.php
lib/adodb/datadict/datadict-mysql.inc.php
lib/adodb/datadict/datadict-oci8.inc.php
lib/adodb/datadict/datadict-postgres.inc.php
lib/adodb/datadict/datadict-sapdb.inc.php
lib/adodb/datadict/datadict-sqlite.inc.php
lib/adodb/datadict/datadict-sybase.inc.php
lib/adodb/drivers/adodb-access.inc.php
lib/adodb/drivers/adodb-ado.inc.php
lib/adodb/drivers/adodb-ado5.inc.php
lib/adodb/drivers/adodb-ado_access.inc.php
lib/adodb/drivers/adodb-ado_mssql.inc.php
lib/adodb/drivers/adodb-borland_ibase.inc.php
lib/adodb/drivers/adodb-csv.inc.php
lib/adodb/drivers/adodb-db2.inc.php
lib/adodb/drivers/adodb-db2oci.inc.php
lib/adodb/drivers/adodb-db2ora.inc.php
lib/adodb/drivers/adodb-fbsql.inc.php
lib/adodb/drivers/adodb-firebird.inc.php
lib/adodb/drivers/adodb-ibase.inc.php
lib/adodb/drivers/adodb-informix.inc.php
lib/adodb/drivers/adodb-informix72.inc.php
lib/adodb/drivers/adodb-ldap.inc.php
lib/adodb/drivers/adodb-mssql.inc.php
lib/adodb/drivers/adodb-mssqlnative.inc.php
lib/adodb/drivers/adodb-mssqlpo.inc.php
lib/adodb/drivers/adodb-mysql.inc.php
lib/adodb/drivers/adodb-mysqli.inc.php
lib/adodb/drivers/adodb-mysqlpo.inc.php
lib/adodb/drivers/adodb-mysqlt.inc.php
lib/adodb/drivers/adodb-netezza.inc.php
lib/adodb/drivers/adodb-oci8.inc.php
lib/adodb/drivers/adodb-oci805.inc.php
lib/adodb/drivers/adodb-oci8po.inc.php
lib/adodb/drivers/adodb-oci8quercus.inc.php
lib/adodb/drivers/adodb-odbc.inc.php
lib/adodb/drivers/adodb-odbc_db2.inc.php
lib/adodb/drivers/adodb-odbc_mssql.inc.php
lib/adodb/drivers/adodb-odbc_mssql2012.inc.php [new file with mode: 0644]
lib/adodb/drivers/adodb-odbc_oracle.inc.php
lib/adodb/drivers/adodb-odbtp.inc.php
lib/adodb/drivers/adodb-odbtp_unicode.inc.php
lib/adodb/drivers/adodb-oracle.inc.php
lib/adodb/drivers/adodb-pdo.inc.php
lib/adodb/drivers/adodb-pdo_mssql.inc.php
lib/adodb/drivers/adodb-pdo_mysql.inc.php
lib/adodb/drivers/adodb-pdo_oci.inc.php
lib/adodb/drivers/adodb-pdo_pgsql.inc.php
lib/adodb/drivers/adodb-pdo_sqlite.inc.php
lib/adodb/drivers/adodb-postgres.inc.php
lib/adodb/drivers/adodb-postgres64.inc.php
lib/adodb/drivers/adodb-postgres7.inc.php
lib/adodb/drivers/adodb-postgres8.inc.php
lib/adodb/drivers/adodb-postgres9.inc.php
lib/adodb/drivers/adodb-proxy.inc.php
lib/adodb/drivers/adodb-sapdb.inc.php
lib/adodb/drivers/adodb-sqlanywhere.inc.php
lib/adodb/drivers/adodb-sqlite.inc.php
lib/adodb/drivers/adodb-sqlite3.inc.php
lib/adodb/drivers/adodb-sqlitepo.inc.php
lib/adodb/drivers/adodb-sybase.inc.php
lib/adodb/drivers/adodb-sybase_ase.inc.php
lib/adodb/drivers/adodb-vfp.inc.php
lib/adodb/perf/perf-db2.inc.php
lib/adodb/perf/perf-informix.inc.php
lib/adodb/perf/perf-mssql.inc.php
lib/adodb/perf/perf-mssqlnative.inc.php
lib/adodb/perf/perf-mysql.inc.php
lib/adodb/perf/perf-oci8.inc.php
lib/adodb/perf/perf-postgres.inc.php
lib/adodb/pivottable.inc.php
lib/adodb/readme_moodle.txt
lib/adodb/rsfilter.inc.php
lib/adodb/toexport.inc.php
lib/adodb/tohtml.inc.php
lib/amd/build/auto_rows.min.js [new file with mode: 0644]
lib/amd/build/custom_interaction_events.min.js
lib/amd/build/modal.min.js
lib/amd/build/modal_confirm.min.js [new file with mode: 0644]
lib/amd/build/modal_events.min.js
lib/amd/build/modal_factory.min.js
lib/amd/build/popover_region_controller.min.js [new file with mode: 0644]
lib/amd/build/templates.min.js
lib/amd/build/url.min.js
lib/amd/src/auto_rows.js [new file with mode: 0644]
lib/amd/src/custom_interaction_events.js
lib/amd/src/modal.js
lib/amd/src/modal_confirm.js [new file with mode: 0644]
lib/amd/src/modal_events.js
lib/amd/src/modal_factory.js
lib/amd/src/popover_region_controller.js [new file with mode: 0644]
lib/amd/src/str.js
lib/amd/src/templates.js
lib/amd/src/url.js
lib/behat/classes/behat_config_util.php
lib/behat/classes/partial_named_selector.php
lib/behat/classes/util.php
lib/blocklib.php
lib/classes/component.php
lib/classes/minify.php
lib/classes/scss.php
lib/datalib.php
lib/db/install.xml
lib/db/services.php
lib/db/upgrade.php
lib/deprecatedlib.php
lib/enrollib.php
lib/externallib.php
lib/grade/grade_category.php
lib/grade/grade_grade.php
lib/htmlpurifier/HTMLPurifier.php
lib/htmlpurifier/HTMLPurifier.safe-includes.php
lib/htmlpurifier/HTMLPurifier/Arborize.php
lib/htmlpurifier/HTMLPurifier/AttrCollections.php
lib/htmlpurifier/HTMLPurifier/AttrDef/CSS.php
lib/htmlpurifier/HTMLPurifier/AttrDef/CSS/URI.php
lib/htmlpurifier/HTMLPurifier/AttrDef/HTML/ID.php
lib/htmlpurifier/HTMLPurifier/AttrDef/URI/Host.php
lib/htmlpurifier/HTMLPurifier/AttrTransform/ImgRequired.php
lib/htmlpurifier/HTMLPurifier/AttrTransform/TargetNoreferrer.php [new file with mode: 0644]
lib/htmlpurifier/HTMLPurifier/CSSDefinition.php
lib/htmlpurifier/HTMLPurifier/ChildDef/List.php
lib/htmlpurifier/HTMLPurifier/ChildDef/Table.php
lib/htmlpurifier/HTMLPurifier/Config.php
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema.ser
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt [new file with mode: 0644]
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt [new file with mode: 0644]
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt [new file with mode: 0644]
lib/htmlpurifier/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt
lib/htmlpurifier/HTMLPurifier/DefinitionCache.php
lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php
lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer/README [changed mode: 0644->0755]
lib/htmlpurifier/HTMLPurifier/HTMLModule/TargetNoreferrer.php [new file with mode: 0644]
lib/htmlpurifier/HTMLPurifier/HTMLModuleManager.php
lib/htmlpurifier/HTMLPurifier/Injector/Linkify.php
lib/htmlpurifier/HTMLPurifier/Injector/RemoveEmpty.php
lib/htmlpurifier/HTMLPurifier/Injector/SafeObject.php
lib/htmlpurifier/HTMLPurifier/Lexer.php
lib/htmlpurifier/HTMLPurifier/Printer/ConfigForm.php
lib/htmlpurifier/HTMLPurifier/URIScheme/data.php
lib/htmlpurifier/HTMLPurifier/URIScheme/tel.php [new file with mode: 0644]
lib/htmlpurifier/locallib.php
lib/htmlpurifier/readme_moodle.txt
lib/javascript-static.js
lib/javascript.php
lib/messagelib.php
lib/minify/LICENSE.txt [deleted file]
lib/minify/config.php [deleted file]
lib/minify/groupsConfig.php [deleted file]
lib/minify/lib/CSSmin.php [deleted file]
lib/minify/lib/DooDigestAuth.php [deleted file]
lib/minify/lib/FirePHP.php [deleted file]
lib/minify/lib/HTTP/ConditionalGet.php [deleted file]
lib/minify/lib/HTTP/Encoder.php [deleted file]
lib/minify/lib/JSMinPlus.php [deleted file]
lib/minify/lib/Minify.php [deleted file]
lib/minify/lib/Minify/Build.php [deleted file]
lib/minify/lib/Minify/CSS.php [deleted file]
lib/minify/lib/Minify/CSS/Compressor.php [deleted file]
lib/minify/lib/Minify/CSS/UriRewriter.php [deleted file]
lib/minify/lib/Minify/CSSmin.php [deleted file]
lib/minify/lib/Minify/Cache/APC.php [deleted file]
lib/minify/lib/Minify/Cache/File.php [deleted file]
lib/minify/lib/Minify/Cache/Memcache.php [deleted file]
lib/minify/lib/Minify/Cache/WinCache.php [deleted file]
lib/minify/lib/Minify/Cache/XCache.php [deleted file]
lib/minify/lib/Minify/Cache/ZendPlatform.php [deleted file]
lib/minify/lib/Minify/ClosureCompiler.php [deleted file]
lib/minify/lib/Minify/CommentPreserver.php [deleted file]
lib/minify/lib/Minify/Controller/Base.php [deleted file]
lib/minify/lib/Minify/Controller/Files.php [deleted file]
lib/minify/lib/Minify/Controller/Groups.php [deleted file]
lib/minify/lib/Minify/Controller/MinApp.php [deleted file]
lib/minify/lib/Minify/Controller/Page.php [deleted file]
lib/minify/lib/Minify/Controller/Version1.php [deleted file]
lib/minify/lib/Minify/DebugDetector.php [deleted file]
lib/minify/lib/Minify/HTML.php [deleted file]
lib/minify/lib/Minify/HTML/Helper.php [deleted file]
lib/minify/lib/Minify/ImportProcessor.php [deleted file]
lib/minify/lib/Minify/JS/ClosureCompiler.php [deleted file]
lib/minify/lib/Minify/Lines.php [deleted file]
lib/minify/lib/Minify/Loader.php [deleted file]
lib/minify/lib/Minify/Logger.php [deleted file]
lib/minify/lib/Minify/Packer.php [deleted file]
lib/minify/lib/Minify/Source.php [deleted file]
lib/minify/lib/Minify/YUI/CssCompressor.java [deleted file]
lib/minify/lib/Minify/YUI/CssCompressor.php [deleted file]
lib/minify/lib/Minify/YUICompressor.php [deleted file]
lib/minify/lib/MrClay/Cli.php [deleted file]
lib/minify/lib/MrClay/Cli/Arg.php [deleted file]
lib/minify/matthiasmullie-minify/data/js/keywords_after.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/data/js/keywords_before.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/data/js/keywords_reserved.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/data/js/operators.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/data/js/operators_after.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/data/js/operators_before.txt [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/CSS.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/Exception.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/Exceptions/BasicException.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/Exceptions/FileImportException.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/Exceptions/IOException.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/JS.php [new file with mode: 0644]
lib/minify/matthiasmullie-minify/src/Minify.php [new file with mode: 0644]
lib/minify/matthiasmullie-pathconverter/src/Converter.php [new file with mode: 0644]
lib/minify/readme_moodle.txt
lib/minify/utils.php [deleted file]
lib/moodlelib.php
lib/mustache/readme_moodle.txt
lib/myprofilelib.php
lib/navigationlib.php
lib/oauthlib.php
lib/outputcomponents.php
lib/outputlib.php
lib/outputrenderers.php
lib/pagelib.php
lib/pear/HTML/QuickForm.php
lib/templates/hover_tooltip.mustache [new file with mode: 0644]
lib/templates/modal.mustache
lib/templates/modal_confirm.mustache [new file with mode: 0644]
lib/templates/modal_save_cancel.mustache
lib/templates/popover_region.mustache [new file with mode: 0644]
lib/templates/progress_bar.mustache [new file with mode: 0644]
lib/templates/skip_links.mustache
lib/tests/behat/behat_hooks.php
lib/tests/behat/behat_transformations.php
lib/tests/minify_test.php
lib/tests/string_manager_standard_test.php
lib/thirdpartylibs.xml
lib/upgrade.txt
lib/upgradelib.php
lib/weblib.php
lib/xhprof/xhprof_moodle.php
login/change_password.php
login/change_password_form.php
login/token.php
message/ajax.php [deleted file]
message/amd/build/message_area.min.js [new file with mode: 0644]
message/amd/build/message_area_actions.min.js [new file with mode: 0644]
message/amd/build/message_area_contacts.min.js [new file with mode: 0644]
message/amd/build/message_area_events.min.js [new file with mode: 0644]
message/amd/build/message_area_messages.min.js [new file with mode: 0644]
message/amd/build/message_area_profile.min.js [new file with mode: 0644]
message/amd/build/message_area_search.min.js [new file with mode: 0644]
message/amd/build/message_area_tabs.min.js [new file with mode: 0644]
message/amd/build/message_notification_preference.min.js [new file with mode: 0644]
message/amd/build/message_preferences.min.js [new file with mode: 0644]
message/amd/build/message_repository.min.js [new file with mode: 0644]
message/amd/build/notification_preference.min.js [new file with mode: 0644]
message/amd/build/notification_processor.min.js [new file with mode: 0644]
message/amd/build/notification_processor_settings.min.js [new file with mode: 0644]
message/amd/build/preferences_notifications_list_controller.min.js [new file with mode: 0644]
message/amd/build/preferences_processor_form.min.js [new file with mode: 0644]
message/amd/build/toggle_contact_button.min.js [new file with mode: 0644]
message/amd/src/message_area.js [new file with mode: 0644]
message/amd/src/message_area_actions.js [new file with mode: 0644]
message/amd/src/message_area_contacts.js [new file with mode: 0644]
message/amd/src/message_area_events.js [new file with mode: 0644]
message/amd/src/message_area_messages.js [new file with mode: 0644]
message/amd/src/message_area_profile.js [new file with mode: 0644]
message/amd/src/message_area_search.js [new file with mode: 0644]
message/amd/src/message_area_tabs.js [new file with mode: 0644]
message/amd/src/message_notification_preference.js [new file with mode: 0644]
message/amd/src/message_preferences.js [new file with mode: 0644]
message/amd/src/message_repository.js [new file with mode: 0644]
message/amd/src/notification_preference.js [new file with mode: 0644]
message/amd/src/notification_processor.js [new file with mode: 0644]
message/amd/src/notification_processor_settings.js [new file with mode: 0644]
message/amd/src/preferences_notifications_list_controller.js [new file with mode: 0644]
message/amd/src/preferences_processor_form.js [new file with mode: 0644]
message/amd/src/toggle_contact_button.js [new file with mode: 0644]
message/bell.mp3 [deleted file]
message/bell.ogg [deleted file]
message/bell.wav [deleted file]
message/classes/api.php [new file with mode: 0644]
message/classes/helper.php [new file with mode: 0644]
message/classes/output/messagearea/contact.php [new file with mode: 0644]
message/classes/output/messagearea/contacts.php [new file with mode: 0644]
message/classes/output/messagearea/message.php [new file with mode: 0644]
message/classes/output/messagearea/message_area.php [new file with mode: 0644]
message/classes/output/messagearea/message_search_results.php [new file with mode: 0644]
message/classes/output/messagearea/messages.php [new file with mode: 0644]
message/classes/output/messagearea/profile.php [new file with mode: 0644]
message/classes/output/messagearea/user_search_results.php [new file with mode: 0644]
message/classes/output/preferences/message_notification_list.php [new file with mode: 0644]
message/classes/output/preferences/message_notification_list_component.php [moved from theme/boost/classes/admin_setting_scss_variables.php with 53% similarity]
message/classes/output/preferences/notification_list.php [new file with mode: 0644]
message/classes/output/preferences/notification_list_component.php [new file with mode: 0644]
message/classes/output/preferences/notification_list_processor.php [new file with mode: 0644]
message/classes/output/preferences/processor.php [new file with mode: 0644]
message/classes/output/processor.php [new file with mode: 0644]
message/classes/output/renderer.php [new file with mode: 0644]
message/edit.php
message/externallib.php
message/index.php
message/lib.php
message/module.js
message/notificationpreferences.php [new file with mode: 0644]
message/output/airnotifier/lang/en/message_airnotifier.php
message/output/email/message_output_email.php
message/output/jabber/lang/en/message_jabber.php
message/output/lib.php
message/output/popup/amd/build/message_popover_controller.min.js [new file with mode: 0644]
message/output/popup/amd/build/notification_area_content_area.min.js [new file with mode: 0644]
message/output/popup/amd/build/notification_area_control_area.min.js [new file with mode: 0644]
message/output/popup/amd/build/notification_area_events.min.js [new file with mode: 0644]
message/output/popup/amd/build/notification_popover_controller.min.js [new file with mode: 0644]
message/output/popup/amd/build/notification_repository.min.js [new file with mode: 0644]
message/output/popup/amd/src/message_popover_controller.js [new file with mode: 0644]
message/output/popup/amd/src/notification_area_content_area.js [new file with mode: 0644]
message/output/popup/amd/src/notification_area_control_area.js [new file with mode: 0644]
message/output/popup/amd/src/notification_area_events.js [moved from message/yui/src/messenger/js/constants.js with 62% similarity]
message/output/popup/amd/src/notification_popover_controller.js [new file with mode: 0644]
message/output/popup/amd/src/notification_repository.js [new file with mode: 0644]
message/output/popup/classes/api.php [new file with mode: 0644]
message/output/popup/classes/output/popup_notification.php [new file with mode: 0644]
message/output/popup/db/events.php [new file with mode: 0644]
message/output/popup/db/install.xml [new file with mode: 0644]
message/output/popup/db/services.php [new file with mode: 0644]
message/output/popup/db/upgrade.php
message/output/popup/externallib.php [new file with mode: 0644]
message/output/popup/lang/en/message_popup.php
message/output/popup/lib.php [new file with mode: 0644]
message/output/popup/message_output_popup.php
message/output/popup/notifications.php [new file with mode: 0644]
message/output/popup/templates/message_content_item.mustache [new file with mode: 0644]
message/output/popup/templates/message_popover.mustache [new file with mode: 0644]
message/output/popup/templates/notification_area.mustache [new file with mode: 0644]
message/output/popup/templates/notification_area_content_area_content.mustache [new file with mode: 0644]
message/output/popup/templates/notification_area_content_area_footer.mustache [new file with mode: 0644]
message/output/popup/templates/notification_area_content_area_header.mustache [new file with mode: 0644]
message/output/popup/templates/notification_content_item.mustache [new file with mode: 0644]
message/output/popup/templates/notification_popover.mustache [new file with mode: 0644]
message/output/popup/tests/api_test.php [new file with mode: 0644]
message/output/popup/tests/base.php [new file with mode: 0644]
message/output/popup/tests/behat/behat_message_popup.php [new file with mode: 0644]
message/output/popup/tests/behat/message_popover_preferences.feature [new file with mode: 0644]
message/output/popup/tests/behat/message_popover_unread.feature [new file with mode: 0644]
message/output/popup/tests/behat/notification_popover_preferences.feature [new file with mode: 0644]
message/output/popup/tests/behat/notification_popover_unread.feature [new file with mode: 0644]
message/output/popup/tests/externallib_test.php [new file with mode: 0644]
message/output/popup/version.php
message/renderer.php
message/search.html [deleted file]
message/search_advanced.html [deleted file]
message/send_form.php [deleted file]
message/settings.html [deleted file]
message/templates/add_contact_button.mustache [new file with mode: 0644]
message/templates/message_area.mustache [new file with mode: 0644]
message/templates/message_area_contact.mustache [new file with mode: 0644]
message/templates/message_area_contacts.mustache [new file with mode: 0644]
message/templates/message_area_contacts_area.mustache [new file with mode: 0644]
message/templates/message_area_message.mustache [new file with mode: 0644]
message/templates/message_area_message_search_results.mustache [new file with mode: 0644]
message/templates/message_area_messages.mustache [new file with mode: 0644]
message/templates/message_area_messages_area.mustache [new file with mode: 0644]
message/templates/message_area_profile.mustache [new file with mode: 0644]
message/templates/message_area_response.mustache [new file with mode: 0644]
message/templates/message_area_user_search_results.mustache [new file with mode: 0644]
message/templates/message_preferences.mustache [new file with mode: 0644]
message/templates/message_preferences_component.mustache [new file with mode: 0644]
message/templates/message_preferences_notification_processor.mustache [new file with mode: 0644]
message/templates/notification_preferences.mustache [new file with mode: 0644]
message/templates/notification_preferences_component.mustache [new file with mode: 0644]
message/templates/notification_preferences_component_notification.mustache [new file with mode: 0644]
message/templates/notification_preferences_processor.mustache [new file with mode: 0644]
message/templates/preferences_processor.mustache [new file with mode: 0644]
message/templates/remove_contact_button.mustache [new file with mode: 0644]
message/tests/api_test.php [new file with mode: 0644]
message/tests/behat/behat_message.php
message/tests/behat/block_noncontacts.feature [deleted file]
message/tests/behat/block_users.feature [deleted file]
message/tests/behat/delete_all_messages.feature [new file with mode: 0644]
message/tests/behat/delete_messages.feature
message/tests/behat/display_history.feature [deleted file]
message/tests/behat/manage_contacts.feature
message/tests/behat/message_participants.feature [deleted file]
message/tests/behat/recent_conversations.feature [deleted file]
message/tests/behat/reply_message.feature [new file with mode: 0644]
message/tests/behat/search_history.feature [deleted file]
message/tests/behat/search_messages.feature [new file with mode: 0644]
message/tests/behat/search_users.feature [new file with mode: 0644]
message/tests/behat/send_message.feature [deleted file]
message/tests/behat/view_messages.feature [new file with mode: 0644]
message/tests/events_test.php
message/tests/externallib_test.php
message/tests/messagelib_test.php
message/upgrade.txt
message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-debug.js [deleted file]
message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-min.js [deleted file]
message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger.js [deleted file]
message/yui/build/moodle-core_message-toolbox/moodle-core_message-toolbox-debug.js [deleted file]
message/yui/build/moodle-core_message-toolbox/moodle-core_message-toolbox-min.js [deleted file]
message/yui/build/moodle-core_message-toolbox/moodle-core_message-toolbox.js [deleted file]
message/yui/src/messenger/build.json [deleted file]
message/yui/src/messenger/js/manager.js [deleted file]
message/yui/src/messenger/js/sendmessage.js [deleted file]
message/yui/src/messenger/meta/messenger.json [deleted file]
message/yui/src/toolbox/build.json [deleted file]
message/yui/src/toolbox/js/delete.js [deleted file]
message/yui/src/toolbox/meta/toolbox.json [deleted file]
mod/assign/amd/build/grading_navigation.min.js
mod/assign/amd/build/participant_selector.min.js
mod/assign/amd/src/grading_navigation.js
mod/assign/amd/src/participant_selector.js
mod/assign/externallib.php
mod/assign/feedback/editpdf/classes/renderer.php
mod/assign/feedback/editpdf/lang/en/assignfeedback_editpdf.php
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-debug.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor-min.js
mod/assign/feedback/editpdf/yui/build/moodle-assignfeedback_editpdf-editor/moodle-assignfeedback_editpdf-editor.js
mod/assign/feedback/editpdf/yui/src/editor/js/commentsearch.js
mod/assign/feedback/editpdf/yui/src/editor/js/editor.js
mod/assign/feedback/file/importziplib.php
mod/assign/feedback/offline/importgradesform.php
mod/assign/gradingoptionsform.php
mod/assign/gradingtable.php
mod/assign/lang/en/assign.php
mod/assign/locallib.php
mod/assign/module.js
mod/assign/submission/file/locallib.php
mod/assign/tests/externallib_test.php
mod/book/delete.php
mod/book/edit.php
mod/book/lang/en/book.php
mod/book/locallib.php
mod/book/tests/behat/create_chapters.feature
mod/book/tests/behat/edit_navigation_options.feature
mod/book/tests/behat/log_entries.feature
mod/book/tests/behat/show_hide_chapters.feature
mod/book/view.php
mod/choice/lib.php
mod/data/tests/generator_test.php
mod/feedback/lang/en/deprecated.txt
mod/feedback/lang/en/feedback.php
mod/feedback/lib.php
mod/folder/lang/en/folder.php
mod/folder/lib.php
mod/forum/classes/output/forum_post.php
mod/forum/classes/post_form.php
mod/lesson/tests/behat/completion_condition_end_reached.feature
mod/lesson/tests/behat/lesson_question_attempts.feature
mod/lti/amd/src/contentitem.js
mod/lti/mod_form.php
mod/lti/tests/behat/contentitem.feature
mod/quiz/report/attemptsreport.php
mod/quiz/report/attemptsreport_table.php
mod/quiz/report/grading/report.php
mod/quiz/report/grading/tests/behat/grading.feature [new file with mode: 0644]
mod/quiz/report/overview/overview_table.php
mod/quiz/report/overview/report.php
mod/quiz/report/overview/tests/behat/basic.feature [new file with mode: 0644]
mod/quiz/report/overview/tests/report_test.php
mod/quiz/report/reportlib.php
mod/quiz/report/responses/last_responses_table.php
mod/quiz/report/responses/report.php
mod/quiz/report/statistics/classes/calculator.php
mod/quiz/report/statistics/db/upgrade.php
mod/quiz/report/statistics/report.php
mod/quiz/report/statistics/statisticslib.php
mod/quiz/report/statistics/tests/statisticslib_test.php [deleted file]
mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php
mod/quiz/report/statistics/upgrade.txt
mod/quiz/report/statistics/version.php
mod/quiz/report/upgrade.txt
mod/workshop/assessment.php
mod/workshop/classes/portfolio_caller.php [new file with mode: 0644]
mod/workshop/db/access.php
mod/workshop/lang/en/workshop.php
mod/workshop/locallib.php
mod/workshop/submission.php
mod/workshop/tests/behat/behat_mod_workshop.php
mod/workshop/tests/behat/export_submission.feature [new file with mode: 0644]
mod/workshop/tests/locallib_test.php
mod/workshop/tests/portfolio_caller_test.php [new file with mode: 0644]
mod/workshop/version.php
npm-shrinkwrap.json
package.json
pix/i/notifications.png [new file with mode: 0644]
pix/i/notifications.svg [new file with mode: 0644]
question/classes/bank/action_column_base.php
question/type/match/renderer.php
repository/dropbox/classes/authentication_exception.php [new file with mode: 0644]
repository/dropbox/classes/dropbox.php [new file with mode: 0644]
repository/dropbox/classes/dropbox_exception.php [new file with mode: 0644]
repository/dropbox/classes/provider_exception.php [new file with mode: 0644]
repository/dropbox/classes/rate_limit_exception.php [moved from message/discussion.php with 50% similarity]
repository/dropbox/db/upgrade.php
repository/dropbox/lang/en/repository_dropbox.php
repository/dropbox/lib.php
repository/dropbox/locallib.php [deleted file]
repository/dropbox/tests/api_test.php [new file with mode: 0644]
repository/dropbox/thumbnail.php
repository/dropbox/version.php
search/classes/manager.php
search/engine/solr/classes/engine.php
search/engine/solr/classes/schema.php
tag/templates/taglist.mustache
theme/boost/amd/build/loader.min.js
theme/boost/amd/src/loader.js
theme/boost/classes/output/core_renderer_maintenance.php [new file with mode: 0644]
theme/boost/config.php
theme/boost/lang/en/theme_boost.php
theme/boost/lib.php
theme/boost/pix/favicon.ico
theme/boost/scss/moodle.scss
theme/boost/scss/moodle/admin.scss
theme/boost/scss/moodle/calendar.scss
theme/boost/scss/moodle/core.scss
theme/boost/scss/moodle/course.scss
theme/boost/scss/moodle/forms.scss
theme/boost/scss/moodle/message.scss
theme/boost/scss/moodle/modules.scss
theme/boost/scss/moodle/popover-region.scss [new file with mode: 0644]
theme/boost/scss/moodle/question.scss
theme/boost/scss/moodle/user.scss
theme/boost/settings.php
theme/boost/templates/core/modal.mustache [new file with mode: 0644]
theme/boost/templates/core/modal_backdrop.mustache [new file with mode: 0644]
theme/boost/templates/core/progress_bar.mustache [new file with mode: 0644]
theme/boost/templates/core/skip_links.mustache
theme/boost/templates/core_form/element-autocomplete.mustache
theme/boost/templates/core_form/element-button-inline.mustache
theme/boost/templates/core_form/element-radio-inline.mustache
theme/boost/templates/core_form/element-radio.mustache
theme/boost/templates/header.mustache
theme/boost/templates/maintenance.mustache
theme/bootstrapbase/less/moodle.less
theme/bootstrapbase/less/moodle/blocks.less
theme/bootstrapbase/less/moodle/core.less
theme/bootstrapbase/less/moodle/course.less
theme/bootstrapbase/less/moodle/forms.less
theme/bootstrapbase/less/moodle/message.less
theme/bootstrapbase/less/moodle/popover_region.less [new file with mode: 0644]
theme/bootstrapbase/less/moodle/question.less
theme/bootstrapbase/less/moodle/responsive.less
theme/bootstrapbase/less/moodle/user.less
theme/bootstrapbase/style/moodle.css
theme/bootstrapbase/templates/theme_boost/admin_setting_tabs.mustache [new file with mode: 0644]
theme/clean/layout/columns1.php
theme/clean/layout/columns2.php
theme/clean/layout/columns3.php
theme/clean/style/custom.css
theme/more/style/custom.css
theme/upgrade.txt
user/editadvanced.php
user/editadvanced_form.php
user/externallib.php
user/lib.php
user/selector/lib.php
user/selector/module.js
user/selector/search.php
user/tests/behat/user_grade_navigation.feature
user/tests/behat/view_full_profile.feature
user/tests/behat/view_preferences_page.feature
user/tests/externallib_test.php
user/tests/userlib_test.php
version.php
webservice/lib.php
webservice/upgrade.txt

index e35675a..73b2b4a 100644 (file)
@@ -20,7 +20,8 @@ lib/phpexcel/
 lib/google/
 lib/htmlpurifier/
 lib/jabber/
-lib/minify/
+lib/minify/matthiasmullie-minify/
+lib/minify/matthiasmullie-pathconverter/
 lib/flowplayer/
 lib/pear/Auth/RADIUS.php
 lib/pear/Crypt/CHAP.php
index c701962..3514759 100644 (file)
--- a/.eslintrc
+++ b/.eslintrc
@@ -31,7 +31,6 @@
     'no-inner-declarations': 'error',
     'no-invalid-regexp': 'error',
     'no-irregular-whitespace': 'error',
-    'no-negated-in-lhs': 'error',
     'no-obj-calls': 'error',
     'no-prototype-builtins': 'off',
     'no-regex-spaces': 'error',
@@ -39,6 +38,7 @@
     'no-unexpected-multiline': 'error',
     'no-unreachable': 'warn',
     'no-unsafe-finally': 'error',
+    'no-unsafe-negation': 'error',
     'use-isnan': 'error',
     'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }],
     'valid-typeof': 'error',
@@ -63,6 +63,7 @@
     'no-extra-bind': 'warn',
     'no-fallthrough': 'error',
     'no-floating-decimal': 'warn',
+    'no-global-assign': 'warn',
     // Enabled by grunt for AMD modules: 'no-implicit-globals': 'error',
     'no-implied-eval': 'error',
     'no-invalid-this': 'error',
@@ -71,7 +72,6 @@
     'no-loop-func': 'error',
     'no-multi-spaces': 'warn',
     'no-multi-str': 'error',
-    'no-native-reassign': 'warn',
     'no-new-func': 'error',
     'no-new-wrappers': 'error',
     'no-octal': 'error',
@@ -96,7 +96,7 @@
     'no-delete-var': 'error',
     'no-undef': 'error',
     'no-undef-init': 'error',
-    'no-unused-vars': ['error', { 'caughtErrors': 'none', 'argsIgnorePattern': "(e|event)" }],
+    'no-unused-vars': ['error', { 'caughtErrors': 'none' }],
 
     // === Stylistic Issues ===
     'array-bracket-spacing': 'warn',
     'computed-property-spacing': 'error',
     'consistent-this': 'off',
     'eol-last': 'off',
+    'func-call-spacing': ['warn', 'never'],
     'func-names': 'off',
     'func-style': 'off',
     // indent currently not doing well with our wrapping style, so disabled.
     'no-nested-ternary': 'warn',
     'no-new-object': 'off',
     'no-plusplus': 'off',
-    'no-spaced-func': 'warn',
+    'no-tabs': 'error',
     'no-ternary': 'off',
     'no-trailing-spaces': 'error',
     'no-underscore-dangle': 'off',
     'spaced-comment': 'warn',
     'unicode-bom': 'error',
     'wrap-regex': 'off',
+
+    // === Deprecations ===
+    "no-restricted-properties": ['warn', {
+        'object': 'M',
+        'property': 'str',
+        'message': 'Use AMD module "core/str" or M.util.get_string()'
+    }],
   }
 }
index 9a2dc50..a446cc3 100644 (file)
@@ -1,5 +1,7 @@
 # Generated by "grunt ignorefiles"
 theme/bootstrapbase/style/
+theme/clean/style/custom.css
+theme/more/style/custom.css
 node_modules/
 vendor/
 auth/cas/CAS/
@@ -19,7 +21,8 @@ lib/phpexcel/
 lib/google/
 lib/htmlpurifier/
 lib/jabber/
-lib/minify/
+lib/minify/matthiasmullie-minify/
+lib/minify/matthiasmullie-pathconverter/
 lib/flowplayer/
 lib/pear/Auth/RADIUS.php
 lib/pear/Crypt/CHAP.php
index da666ee..a0d3845 100644 (file)
@@ -16,6 +16,9 @@ php:
     - 7.0
     - 5.6
 
+services:
+    - redis-server
+
 env:
     # Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
     # start first so that the total run time is not too high.
@@ -78,6 +81,10 @@ install:
                 echo 'auth.json' >> .git/info/exclude
             fi
 
+            # Enable Redis.
+            echo 'extension="redis.so"' > /tmp/redis.ini
+            phpenv config-add /tmp/redis.ini
+
             # Install composer dependencies.
             # We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
             # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
@@ -147,6 +154,7 @@ before_script:
         sed -i \
           -e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
           -e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
+          -e "/require_once/i \\define('TEST_SESSION_REDIS_HOST', '127.0.0.1');" \
           config.php ;
 
         # Initialise PHPUnit for Moodle.
index 8fc47df..5852cc4 100644 (file)
@@ -221,7 +221,12 @@ module.exports = function(grunt) {
       var eslintIgnores = ['# Generated by "grunt ignorefiles"', '*/**/yui/src/*/meta/', '*/**/build/'].concat(thirdPartyPaths);
       grunt.file.write('.eslintignore', eslintIgnores.join('\n'));
       // Generate .stylelintignore.
-      var stylelintIgnores = ['# Generated by "grunt ignorefiles"', 'theme/bootstrapbase/style/'].concat(thirdPartyPaths);
+      var stylelintIgnores = [
+          '# Generated by "grunt ignorefiles"',
+          'theme/bootstrapbase/style/',
+          'theme/clean/style/custom.css',
+          'theme/more/style/custom.css'
+      ].concat(thirdPartyPaths);
       grunt.file.write('.stylelintignore', stylelintIgnores.join('\n'));
     };
 
index 2cf9d1a..6f87285 100644 (file)
@@ -851,6 +851,7 @@ $registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOOD
 $cachewarnings = cache_helper::warnings();
 // Check if there are events 1 API handlers.
 $eventshandlers = $DB->get_records_sql('SELECT DISTINCT component FROM {events_handlers}');
+$themedesignermode = !empty($CFG->themedesignermode);
 
 admin_externalpage_setup('adminnotifications');
 
@@ -858,4 +859,4 @@ $output = $PAGE->get_renderer('core', 'admin');
 
 echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
                                        $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
-                                       $registered, $cachewarnings, $eventshandlers);
+                                       $registered, $cachewarnings, $eventshandlers, $themedesignermode);
index 7895c31..2b841d6 100644 (file)
@@ -281,7 +281,7 @@ class core_admin_renderer extends plugin_renderer_base {
      */
     public function admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
             $cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
-            $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0) {
+            $buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0, $themedesignermode = false) {
         global $CFG;
         $output = '';
 
@@ -290,6 +290,7 @@ class core_admin_renderer extends plugin_renderer_base {
         $output .= $this->legacy_log_store_writing_error();
         $output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
         $output .= $this->insecure_dataroot_warning($insecuredataroot);
+        $output .= $this->themedesignermode_warning($themedesignermode);
         $output .= $this->display_errors_warning($errorsdisplayed);
         $output .= $this->buggy_iconv_warning($buggyiconvnomb);
         $output .= $this->cron_overdue_warning($cronoverdue);
@@ -532,6 +533,19 @@ class core_admin_renderer extends plugin_renderer_base {
         return $this->warning(get_string('displayerrorswarning', 'admin'));
     }
 
+    /**
+     * Render an appropriate message if themdesignermode is enabled.
+     * @param bool $themedesignermode true if enabled
+     * @return string HTML to output.
+     */
+    protected function themedesignermode_warning($themedesignermode) {
+        if (!$themedesignermode) {
+            return '';
+        }
+
+        return $this->warning(get_string('themedesignermodewarning', 'admin'));
+    }
+
     /**
      * Render an appropriate message if iconv is buggy and mbstring missing.
      * @param bool $buggyiconvnomb
index 946abbd..c892566 100644 (file)
@@ -96,6 +96,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     $temp->add(new admin_setting_configcheckbox('passwordchangelogout',
         new lang_string('passwordchangelogout', 'admin'),
         new lang_string('passwordchangelogout_desc', 'admin'), 0));
+
+    $temp->add(new admin_setting_configcheckbox('passwordchangetokendeletion',
+        new lang_string('passwordchangetokendeletion', 'admin'),
+        new lang_string('passwordchangetokendeletion_desc', 'admin'), 0));
+
     $temp->add(new admin_setting_configcheckbox('groupenrolmentkeypolicy', new lang_string('groupenrolmentkeypolicy', 'admin'), new lang_string('groupenrolmentkeypolicy_desc', 'admin'), 1));
     $temp->add(new admin_setting_configcheckbox('disableuserimages', new lang_string('disableuserimages', 'admin'), new lang_string('configdisableuserimages', 'admin'), 0));
     $temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', new lang_string('emailchangeconfirmation', 'admin'), new lang_string('configemailchangeconfirmation', 'admin'), 1));
index 48327c7..a5b6616 100644 (file)
@@ -47,13 +47,15 @@ list($options, $unrecognized) = cli_get_params(
         'help'     => false,
         'fromrun'  => 1,
         'torun'    => 0,
-        'run-with-theme' => false,
         'optimize-runs' => '',
+        'add-core-features-to-theme' => false,
     ),
     array(
         'j' => 'parallel',
         'm' => 'maxruns',
         'h' => 'help',
+        'o' => 'optimize-runs',
+        'a' => 'add-core-features-to-theme',
     )
 );
 
@@ -69,8 +71,9 @@ Options:
 -m, --maxruns    Max parallel processes to be executed at one time.
 --fromrun        Execute run starting from (Used for parallel runs on different vms)
 --torun          Execute run till (Used for parallel runs on different vms)
---optimize-runs  Split features with specified tags in all parallel runs.
---run-with-theme Run all core features with specified theme.
+
+-o, --optimize-runs Split features with specified tags in all parallel runs.
+-a, --add-core-features-to-theme Add all core features to specified theme's
 
 -h, --help     Print out this help
 
@@ -99,7 +102,7 @@ if ($options['parallel'] && $options['parallel'] > 1) {
     }
 } else {
     // Only sanitize options for single run.
-    $cmdoptionsforsinglerun = array('run-with-theme');
+    $cmdoptionsforsinglerun = array('add-core-features-to-theme');
 
     foreach ($cmdoptionsforsinglerun as $option) {
         if (!empty($options[$option])) {
index a601967..b157ca7 100644 (file)
@@ -56,13 +56,15 @@ list($options, $unrecognized) = cli_get_params(
         'updatesteps' => false,
         'fromrun'     => 1,
         'torun'       => 0,
-        'run-with-theme' => false,
         'optimize-runs' => '',
+        'add-core-features-to-theme' => false,
     ),
     array(
         'h' => 'help',
         'j' => 'parallel',
         'm' => 'maxruns',
+        'o' => 'optimize-runs',
+        'a' => 'add-core-features-to-theme',
     )
 );
 
@@ -81,10 +83,10 @@ Options:
 --diag         Get behat test environment status code
 --updatesteps  Update feature step file.
 
--j, --parallel   Number of parallel behat run operation
--m, --maxruns    Max parallel processes to be executed at one time.
---optimize-runs  Split features with specified tags in all parallel runs.
---run-with-theme Run all core features with specified theme.
+-j, --parallel Number of parallel behat run operation
+-m, --maxruns Max parallel processes to be executed at one time.
+-o, --optimize-runs Split features with specified tags in all parallel runs.
+-a, --add-core-features-to-theme Add all core features to specified theme's
 
 -h, --help     Print out this help
 
@@ -180,14 +182,14 @@ if ($options['diag'] || $options['enable'] || $options['disable']) {
 } else if ($options['updatesteps']) {
     // Rewrite config file to ensure we have all the features covered.
     if (empty($options['parallel'])) {
-        behat_config_manager::update_config_file('', true, '', $options['run-with-theme'], false, false);
+        behat_config_manager::update_config_file('', true, '', $options['add-core-features-to-theme'], false, false);
     } else {
         // Update config file, ensuring we have up-to-date behat.yml.
         for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
             $CFG->behatrunprocess = $i;
 
             // Update config file for each run.
-            behat_config_manager::update_config_file('', true, $options['optimize-runs'], $options['run-with-theme'],
+            behat_config_manager::update_config_file('', true, $options['optimize-runs'], $options['add-core-features-to-theme'],
                 $options['parallel'], $i);
         }
         unset($CFG->behatrunprocess);
index 85987a0..3d0e2db 100644 (file)
@@ -47,11 +47,13 @@ list($options, $unrecognized) = cli_get_params(
         'diag'        => false,
         'tags'        => '',
         'updatesteps' => false,
-        'run-with-theme' => false,
         'optimize-runs' => '',
+        'add-core-features-to-theme' => false,
     ),
     array(
         'h' => 'help',
+        'o' => 'optimize-runs',
+        'a' => 'add-core-features-to-theme',
     )
 );
 
@@ -73,8 +75,9 @@ Options:
 --disable        Disables test environment
 --diag           Get behat test environment status code
 --updatesteps    Update feature step file.
---optimize-runs  Split features with specified tags in all parallel runs.
---run-with-theme Run all core features with specified theme.
+
+-o, --optimize-runs Split features with specified tags in all parallel runs.
+-a, --add-core-features-to-theme Add all core features to specified theme's
 
 -h, --help Print out this help
 
@@ -180,7 +183,7 @@ if ($options['install']) {
     }
 
     // Enable test mode.
-    behat_util::start_test_mode($options['run-with-theme'], $options['optimize-runs'], $parallel, $run);
+    behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
 
     // This is only displayed once for parallel install.
     if (empty($run)) {
diff --git a/admin/tool/behat/tests/behat/datetime_strings.feature b/admin/tool/behat/tests/behat/datetime_strings.feature
new file mode 100644 (file)
index 0000000..0b4e7e5
--- /dev/null
@@ -0,0 +1,25 @@
+@tool @tool_behat
+Feature: Transform date time string arguments
+  In order to write tests with relative date and time
+  As a user
+  I need to apply some transformations to the steps arguments
+
+  Scenario: Set date in table and check date with specific format
+    Given I am on site homepage
+    And the following "users" exist:
+      | username  | firstname | lastname |
+      | teacher1  | Teacher   | 1        |
+    And the following "courses" exist:
+      | fullname | shortname | category |
+      | Course 1 | C1        | 0        |
+    And the following "activities" exist:
+      | activity | course | idnumber | name                 | intro                       | duedate       |
+      | assign   | C1     | assign1  | Test assignment name | Test assignment description | ##yesterday## |
+    And the following "course enrolments" exist:
+      | user     | course | role    |
+      | teacher1 | C1     | editingteacher |
+    And I log in as "teacher1"
+    And I follow "Course 1"
+    And I follow "Test assignment name"
+    And I should see "##yesterday##l, j F Y##"
+    And I log out
index 4b4120d..f8d847d 100644 (file)
@@ -31,8 +31,9 @@ Feature: Transform steps arguments
     And I press "Update profile"
     And I follow "Edit profile"
     Then I should not see "NASTYSTRING"
-    And the field "Surname" matches value "$NASTYSTRING1"
-    And the field "City/town" matches value "$NASTYSTRING3"
+    # BEHAT Transformation regression - See MDL-56397
+    #And the field "Surname" matches value "$NASTYSTRING1"
+    #And the field "City/town" matches value "$NASTYSTRING3"
 
   Scenario: Use double quotes
     When I set the following fields to these values:
@@ -56,4 +57,5 @@ Feature: Transform steps arguments
     And I should see "My Firstname"
     And I should see "My Surname"
     And the field "First name" matches value "My Firstname $NASTYSTRING1"
-    And the field "Surname" matches value "My Surname $NASTYSTRING2"
+    # BEHAT Transformation regression - See MDL-56397
+    #And the field "Surname" matches value "My Surname $NASTYSTRING2"
index 5723743..6ae0a6c 100644 (file)
@@ -75,9 +75,11 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
         ),
     );
 
-    private $corefatures = array('test_1' => __DIR__.'/fixtures/core/test_1.feature',
-                                 'test_2' => __DIR__.'/fixtures/core/test_2.feature');
+    /** @var array List of core features. */
+    private $corefatures = array('test_1_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_1.feature',
+                                 'test_2_core_fixtures_tests_behat_tool' => __DIR__.'/fixtures/core/test_2.feature');
 
+    /** @var array List of core contexts. */
     private $corecontexts = array('behat_test_context_1' => __DIR__.'/fixtures/core/behat_test_context_1.php',
                                   'behat_test_context_2' => __DIR__.'/fixtures/core/behat_test_context_2.php');
 
@@ -461,5 +463,211 @@ class tool_behat_manager_util_testcase extends advanced_testcase {
             ['C:\mod_assign.feature', 'mod_assign', 'C:\mod_assign.feature'],
         );
     }
+
+    /**
+     * Behat config for blacklisted tags.
+     */
+    public function test_get_config_file_contents_with_blacklisted_tags() {
+
+        $mockbuilder = $this->getMockBuilder('behat_config_util');
+        $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme'));
+
+        $behatconfigutil = $mockbuilder->getMock();
+
+        $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
+
+        // Blacklisted tags.
+        $map = array(
+            array('withfeatures', 'tags', array('@test1')),
+            array('nofeatures', 'tags', array('@test2')),
+            array('withfeatures', 'features', array()),
+            array('nofeatures', 'features', array()),
+            array('withfeatures', 'contexts', array()),
+            array('nofeatures', 'contexts', array())
+        );
+
+        $behatconfigutil->expects($this->any())
+            ->method('get_blacklisted_tests_for_theme')
+            ->will($this->returnValueMap($map));
+
+        $behatconfigutil->set_theme_suite_to_include_core_features(true);
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+
+        // Three suites should be present.
+        $suites = $config['default']['suites'];
+        $this->assertCount(3, $suites);
+
+        $featurepaths = array(
+            'default' => array('test_1.feature', 'test_2.feature'),
+            'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
+                'theme_test_4.feature', 'theme_test_5.feature'),
+            'nofeatures' => array('test_1.feature')
+        );
+
+        // Check features.
+        foreach ($featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+        // Check contexts.
+        foreach ($this->contextspath as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['contexts']);
+
+            foreach ($paths as $key => $context) {
+                $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
+            }
+        }
+        // There are 6 step definitions.
+        $this->assertCount(6, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
+    }
+
+    /**
+     * Behat config for blacklisted features.
+     */
+    public function test_get_config_file_contents_with_blacklisted_features_contexts() {
+
+        $mockbuilder = $this->getMockBuilder('behat_config_util');
+        $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes', 'get_blacklisted_tests_for_theme'));
+
+        $behatconfigutil = $mockbuilder->getMock();
+
+        $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
+
+        // Blacklisted features and contexts.
+        $map = array(
+            array('withfeatures', 'tags', array()),
+            array('nofeatures', 'tags', array()),
+            array('withfeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_1.feature')),
+            array('nofeatures', 'features', array('admin/tool/behat/tests/fixtures/core/test_2.feature')),
+            array('withfeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_2.php')),
+            array('nofeatures', 'contexts', array('admin/tool/behat/tests/fixtures/core/behat_test_context_1.php'))
+        );
+
+        $behatconfigutil->expects($this->any())
+            ->method('get_blacklisted_tests_for_theme')
+            ->will($this->returnValueMap($map));
+
+        $behatconfigutil->set_theme_suite_to_include_core_features(true);
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+
+        // Three suites should be present.
+        $suites = $config['default']['suites'];
+        $this->assertCount(3, $suites);
+
+        $featurepaths = array(
+            'default' => array('test_1.feature', 'test_2.feature'),
+            'withfeatures' => array('test_2.feature', 'theme_test_1.feature', 'theme_test_2.feature', 'theme_test_3.feature',
+                'theme_test_4.feature', 'theme_test_5.feature'),
+            'nofeatures' => array('test_1.feature')
+        );
+        $contextspath = array(
+            'default' => array(
+                'behat_test_context_1',
+                'behat_test_context_2'
+            ),
+            'withfeatures' => array(
+                'behat_theme_withfeatures_test_context_2',
+                'behat_theme_withfeatures_behat_test_context_1'
+            ),
+            'nofeatures' => array(
+                'behat_theme_nofeatures_test_context_1',
+                'behat_theme_nofeatures_behat_test_context_2'
+            ),
+        );
+
+        // Check features.
+        foreach ($featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+        // Check contexts.
+        foreach ($contextspath as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['contexts']);
+
+            foreach ($paths as $key => $context) {
+                $this->assertTrue(in_array($context, $suites[$themename]['contexts']));
+            }
+        }
+        // There are 6 step definitions.
+        $this->assertCount(6, $config['default']['extensions']['Moodle\BehatExtension']['steps_definitions']);
+    }
+
+    /**
+     * Behat config for blacklisted tags.
+     */
+    public function test_core_features_to_include_in_specified_theme() {
+
+        $mockbuilder = $this->getMockBuilder('behat_config_util');
+        $mockbuilder->setMethods(array('get_theme_test_directory', 'get_list_of_themes'));
+
+        $behatconfigutil = $mockbuilder->getMock();
+
+        $behatconfigutil = $this->get_behat_config_util($behatconfigutil);
+
+        // Check features when, no theme is specified.
+        $behatconfigutil->set_theme_suite_to_include_core_features('');
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+        $suites = $config['default']['suites'];
+        foreach ($this->featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+
+        // Check features when all themes are specified.
+        $featurepaths = $this->featurepaths;
+        $featurepaths['withfeatures'] = array_merge ($featurepaths['default'], $featurepaths['withfeatures']);
+        $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
+
+        $behatconfigutil->set_theme_suite_to_include_core_features('ALL');
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+        $suites = $config['default']['suites'];
+        foreach ($featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+
+        // Check features when all themes are specified.
+        $featurepaths = $this->featurepaths;
+        $featurepaths['withfeatures'] = array_merge ($featurepaths['default'], $featurepaths['withfeatures']);
+        $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
+
+        $behatconfigutil->set_theme_suite_to_include_core_features('withfeatures, nofeatures');
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+        $suites = $config['default']['suites'];
+        foreach ($featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+
+        // Check features when specified themes are passed..
+        $featurepaths = $this->featurepaths;
+        $featurepaths['nofeatures'] = array_merge ($featurepaths['default'], $featurepaths['nofeatures']);
+
+        $behatconfigutil->set_theme_suite_to_include_core_features('nofeatures');
+        $config = $behatconfigutil->get_config_file_contents($this->corefatures, $this->corecontexts);
+        $suites = $config['default']['suites'];
+        foreach ($featurepaths as $themename => $paths) {
+            $this->assertCount(count($paths), $suites[$themename]['paths']);
+
+            foreach ($paths as $key => $feature) {
+                $this->assertContains($feature, $suites[$themename]['paths'][$key]);
+            }
+        }
+    }
 }
 // @codeCoverageIgnoreEnd
diff --git a/admin/tool/mobile/autologin.php b/admin/tool/mobile/autologin.php
new file mode 100644 (file)
index 0000000..d5ef969
--- /dev/null
@@ -0,0 +1,70 @@
+<?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/>.
+
+/**
+ * Auto-login end-point, a user can be fully authenticated in the site providing a valid key.
+ *
+ * @package    tool_mobile
+ * @copyright  2016 Juan Leyva
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once(__DIR__ . '/../../../config.php');
+require_once($CFG->libdir . '/externallib.php');
+
+$userid = required_param('userid', PARAM_INT);  // The user id the key belongs to (for double-checking).
+$key = required_param('key', PARAM_ALPHANUMEXT);    // The key generated by the tool_mobile_external::get_autologin_key() external function.
+$urltogo = optional_param('urltogo', $CFG->wwwroot, PARAM_URL);    // URL to redirect.
+
+$context = context_system::instance();
+$PAGE->set_context($context);
+// Force https.
+$PAGE->https_required();
+
+// Check if the user is already logged-in.
+if (isloggedin() and !isguestuser()) {
+    delete_user_key('tool_mobile', $userid);
+    if ($USER->id == $userid) {
+        redirect($urltogo);
+    } else {
+        throw new moodle_exception('alreadyloggedin', 'error', '', format_string(fullname($USER)));
+    }
+}
+
+tool_mobile\api::check_autologin_prerequisites($userid);
+
+// Validate and delete the key.
+$key = validate_user_key($key, 'tool_mobile', null);
+delete_user_key('tool_mobile', $userid);
+
+// Double check key belong to user.
+if ($key->userid != $userid) {
+    throw new moodle_exception('invalidkey');
+}
+
+// Key validated, now require an active user: not guest, not suspended.
+$user = core_user::get_user($key->userid, '*', MUST_EXIST);
+core_user::require_active_user($user, true, true);
+
+// Do the user log-in.
+if (!$user = get_complete_user_data('id', $user->id)) {
+    throw new moodle_exception('cannotfinduser', '', '', $user->id);
+}
+
+complete_user_login($user);
+\core\session\manager::apply_concurrent_login_limit($user->id, session_id());
+
+redirect($urltogo);
index 192b79e..657a0e2 100644 (file)
@@ -28,6 +28,7 @@ use core_component;
 use core_plugin_manager;
 use context_system;
 use moodle_url;
+use moodle_exception;
 
 /**
  * API exposed by tool_mobile
@@ -44,6 +45,8 @@ class api {
     const LOGIN_VIA_BROWSER = 2;
     /** @var int to identify the login via an embedded browser. */
     const LOGIN_VIA_EMBEDDED_BROWSER = 3;
+    /** @var int seconds an auto-login key will expire. */
+    const LOGIN_KEY_TTL = 60;
 
     /**
      * Returns a list of Moodle plugins supporting the mobile app.
@@ -180,4 +183,43 @@ class api {
         return $settings;
     }
 
+    /*
+     * Check if all the required conditions are met to allow the auto-login process continue.
+     *
+     * @param  int $userid  current user id
+     * @since Moodle 3.2
+     * @throws moodle_exception
+     */
+    public static function check_autologin_prerequisites($userid) {
+        global $CFG;
+
+        if (!$CFG->enablewebservices or !$CFG->enablemobilewebservice) {
+            throw new moodle_exception('enablewsdescription', 'webservice');
+        }
+
+        if (!is_https()) {
+            throw new moodle_exception('httpsrequired', 'tool_mobile');
+        }
+
+        if (has_capability('moodle/site:config', context_system::instance(), $userid) or is_siteadmin($userid)) {
+            throw new moodle_exception('autologinnotallowedtoadmins', 'tool_mobile');
+        }
+    }
+
+    /**
+     * Creates an auto-login key for the current user, this key is restricted by time and ip address.
+     *
+     * @return string the key
+     * @since Moodle 3.2
+     */
+    public static function get_autologin_key() {
+        global $USER;
+        // Delete previous keys.
+        delete_user_key('tool_mobile', $USER->id);
+
+        // Create a new key.
+        $iprestriction = getremoteaddr();
+        $validuntil = time() + self::LOGIN_KEY_TTL;
+        return create_user_key('tool_mobile', $USER->id, null, $iprestriction, $validuntil);
+    }
 }
index 8058a86..e06fe73 100644 (file)
@@ -32,6 +32,10 @@ use external_value;
 use external_single_structure;
 use external_multiple_structure;
 use external_warnings;
+use context_system;
+use moodle_exception;
+use moodle_url;
+use core_text;
 
 /**
  * This is the external API for this tool.
@@ -207,4 +211,101 @@ class external extends external_api {
             )
         );
     }
+
+    /**
+     * Returns description of get_autologin_key() parameters.
+     *
+     * @return external_function_parameters
+     * @since  Moodle 3.2
+     */
+    public static function get_autologin_key_parameters() {
+        return new external_function_parameters (
+            array(
+                'privatetoken' => new external_value(PARAM_ALPHANUM, 'Private token, usually generated by login/token.php'),
+            )
+        );
+    }
+
+    /**
+     * Creates an auto-login key for the current user. Is created only in https sites and is restricted by time and ip address.
+     *
+     * @param string $privatetoken the user private token for validating the request
+     * @return array with the settings and warnings
+     * @since  Moodle 3.2
+     */
+    public static function get_autologin_key($privatetoken) {
+        global $CFG, $DB, $USER;
+
+        $params = self::validate_parameters(self::get_autologin_key_parameters(), array('privatetoken' => $privatetoken));
+        $privatetoken = $params['privatetoken'];
+
+        $context = context_system::instance();
+
+        // We must toletare these two exceptions: forcepasswordchangenotice and usernotfullysetup.
+        try {
+            self::validate_context($context);
+        } catch (Exception $e) {
+            if ($e instanceof moodle_exception) {
+                if (($e->errorcode != 'usernotfullysetup') and
+                    ($e->errorcode != 'forcepasswordchangenotice')) {
+
+                    // In case we receive a different exception, throw it.
+                    throw $e;
+                }
+            } else {
+                throw $e;
+            }
+        }
+
+        api::check_autologin_prerequisites($USER->id);
+
+        if (isset($_GET['privatetoken']) or empty($privatetoken)) {
+            throw new moodle_exception('invalidprivatetoken', 'tool_mobile');
+        }
+
+        // Check the request counter, we must limit the number of times the privatetoken is sent.
+        // Between each request 6 minutes are required.
+        $last = get_user_preferences('tool_mobile_autologin_request_last', 0, $USER);
+        // Check if we must reset the count.
+        $timenow = time();
+        if ($timenow - $last < 6 * MINSECS) {
+            throw new moodle_exception('autologinkeygenerationlockout', 'tool_mobile');
+        }
+        set_user_preference('tool_mobile_autologin_request_last', $timenow, $USER);
+
+        // We are expecting a privatetoken linked to the current token being used.
+        // This WS is only valid when using mobile services via REST (this is intended).
+        $currenttoken = required_param('wstoken', PARAM_ALPHANUM);
+        $conditions = array(
+            'userid' => $USER->id,
+            'token' => $currenttoken,
+            'privatetoken' => $privatetoken,
+        );
+        if (!$token = $DB->get_record('external_tokens', $conditions)) {
+            throw new moodle_exception('invalidprivatetoken', 'tool_mobile');
+        }
+
+        $result = array();
+        $result['key'] = api::get_autologin_key();
+        $autologinurl = new moodle_url("/$CFG->admin/tool/mobile/autologin.php");
+        $result['autologinurl'] = $autologinurl->out(false);
+        $result['warnings'] = array();
+        return $result;
+    }
+
+    /**
+     * Returns description of get_autologin_key() result value.
+     *
+     * @return external_description
+     * @since  Moodle 3.2
+     */
+    public static function get_autologin_key_returns() {
+        return new external_single_structure(
+            array(
+                'key' => new external_value(PARAM_ALPHANUMEXT, 'Auto-login key for a single usage with time expiration.'),
+                'autologinurl' => new external_value(PARAM_URL, 'Auto-login URL.'),
+                'warnings' => new external_warnings(),
+            )
+        );
+    }
 }
index 13ac5b0..9a22aa8 100644 (file)
@@ -49,7 +49,15 @@ $functions = array(
         'description' => 'Returns a list of the site configurations, filtering by section.',
         'type'        => 'read',
         'services'    => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
-    )
+    ),
 
+    'tool_mobile_get_autologin_key' => array(
+        'classname'   => 'tool_mobile\external',
+        'methodname'  => 'get_autologin_key',
+        'description' => 'Creates an auto-login key for the current user.
+                            Is created only in https sites and is restricted by time and ip address.',
+        'type'        => 'write',
+        'services'    => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
+    )
 );
 
index e5b9a40..f8c0347 100644 (file)
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+$string['autologinkeygenerationlockout'] = 'Auto-login key generation is locked out, too much requests in an hour.';
+$string['autologinnotallowedtoadmins'] = 'Auto-login is not allowed to site admins';
 $string['clickheretolaunchtheapp'] = 'Click here if the app does not open automatically.';
 $string['enablesmartappbanners'] = 'Enable Smart App Banners';
 $string['enablesmartappbanners_desc'] = 'This will display a banner promoting the Moodle Mobile app when visiting the site in Mobile Safari.';
 $string['forcedurlscheme'] = 'The URL scheme allows to open the mobile app from other apps like the browser. Use this setting if you want to allow only your custom branded app to be opened by the browser.';
 $string['forcedurlscheme_key'] = 'URL scheme';
+$string['httpsrequired'] = 'HTTPS required';
+$string['invalidprivatetoken'] = 'Invalid private token. Token should not be empty or passed via GET parameter.';
 $string['iosappid'] = 'App\'s unique identifier';
 $string['iosappid_desc'] = 'You only need to change this value if you have a custom iOS app';
 $string['loginintheapp'] = 'Via the app';
diff --git a/admin/tool/mobile/tests/api_test.php b/admin/tool/mobile/tests/api_test.php
new file mode 100644 (file)
index 0000000..1cd4e21
--- /dev/null
@@ -0,0 +1,66 @@
+<?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/>.
+
+/**
+ * Moodle Mobile admin tool api tests.
+ *
+ * @package    tool_mobile
+ * @category   external
+ * @copyright  2016 Juan Leyva
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since      Moodle 3.1
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+
+require_once($CFG->dirroot . '/webservice/tests/helpers.php');
+
+use tool_mobile\api;
+
+/**
+ * Moodle Mobile admin tool api tests.
+ *
+ * @package     tool_mobile
+ * @copyright   2016 Juan Leyva
+ * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since       Moodle 3.1
+ */
+class tool_mobile_api_testcase extends externallib_advanced_testcase {
+
+    /**
+     * Test get_autologin_key.
+     */
+    public function test_get_autologin_key() {
+        global $USER, $DB;
+
+        $this->resetAfterTest(true);
+        $this->setAdminUser();
+
+        // Set server timezone for test.
+        $this->setTimezone('UTC');
+        // SEt user to GMT+5.
+        $USER->timezone = 5;
+
+        $timenow = time();
+        $key = api::get_autologin_key();
+
+        $key = $DB->get_record('user_private_key', array('value' => $key), '*', MUST_EXIST);
+        $this->assertEquals($timenow + api::LOGIN_KEY_TTL, $key->validuntil);
+        $this->assertEquals('0.0.0.0', $key->iprestriction);
+    }
+}
index 3fd3b3a..7300cc7 100644 (file)
@@ -34,7 +34,7 @@ use tool_mobile\external;
 use tool_mobile\api;
 
 /**
- * External learning plans webservice API tests.
+ * Moodle Mobile admin tool external functions tests.
  *
  * @package     tool_mobile
  * @copyright   2016 Juan Leyva
@@ -142,4 +142,123 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals($expected, $result['settings']);
     }
 
+    /*
+     * Test get_autologin_key.
+     */
+    public function test_get_autologin_key() {
+        global $DB, $CFG, $USER;
+
+        $this->resetAfterTest(true);
+
+        $user = $this->getDataGenerator()->create_user();
+        $this->setUser($user);
+        $service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
+
+        $token = external_generate_token_for_current_user($service);
+        $this->assertDebuggingCalled(); // MDL-55992.
+
+        // Check we got the private token.
+        $this->assertTrue(isset($token->privatetoken));
+
+        // Enable requeriments.
+        $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->httpswwwroot);    // Mock https.
+        $CFG->enablewebservices = 1;
+        $CFG->enablemobilewebservice = 1;
+        $_GET['wstoken'] = $token->token;   // Mock parameters.
+
+        $this->setCurrentTimeStart();
+        $result = external::get_autologin_key($token->privatetoken);
+        $result = external_api::clean_returnvalue(external::get_autologin_key_returns(), $result);
+        // Validate the key.
+        $this->assertEquals(32, core_text::strlen($result['key']));
+        $key = $DB->get_record('user_private_key', array('value' => $result['key']));
+        $this->assertEquals($USER->id, $key->userid);
+        $this->assertTimeCurrent($key->validuntil - api::LOGIN_KEY_TTL);
+
+        // Now, try with an invalid private token.
+        set_user_preference('tool_mobile_autologin_request_last', time() - HOURSECS, $USER);
+
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('invalidprivatetoken', 'tool_mobile'));
+        $result = external::get_autologin_key(random_string('64'));
+    }
+
+    /**
+     * Test get_autologin_key missing ws.
+     */
+    public function test_get_autologin_key_missing_ws() {
+        $this->resetAfterTest(true);
+
+        $this->setAdminUser();
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('enablewsdescription', 'webservice'));
+        $result = external::get_autologin_key('');
+    }
+
+    /**
+     * Test get_autologin_key missing https.
+     */
+    public function test_get_autologin_key_missing_https() {
+        global $CFG;
+
+        $this->resetAfterTest(true);
+        $this->setAdminUser();
+        $CFG->enablewebservices = 1;
+        $CFG->enablemobilewebservice = 1;
+
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('httpsrequired', 'tool_mobile'));
+        $result = external::get_autologin_key('');
+    }
+
+    /**
+     * Test get_autologin_key missing admin.
+     */
+    public function test_get_autologin_key_missing_admin() {
+        global $CFG;
+
+        $this->resetAfterTest(true);
+        $this->setAdminUser();
+        $CFG->enablewebservices = 1;
+        $CFG->enablemobilewebservice = 1;
+        $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->httpswwwroot);
+
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('autologinnotallowedtoadmins', 'tool_mobile'));
+        $result = external::get_autologin_key('');
+    }
+
+    /**
+     * Test get_autologin_key locked.
+     */
+    public function test_get_autologin_key_missing_locked() {
+        global $CFG, $DB, $USER;
+
+        $this->resetAfterTest(true);
+        $user = $this->getDataGenerator()->create_user();
+        $this->setUser($user);
+        $CFG->enablewebservices = 1;
+        $CFG->enablemobilewebservice = 1;
+        $CFG->httpswwwroot = str_replace('http:', 'https:', $CFG->httpswwwroot);
+
+        $service = $DB->get_record('external_services', array('shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
+
+        $token = external_generate_token_for_current_user($service);
+        $this->assertDebuggingCalled(); // MDL-55992.
+        $_GET['wstoken'] = $token->token;   // Mock parameters.
+
+        $result = external::get_autologin_key($token->privatetoken);
+        $result = external_api::clean_returnvalue(external::get_autologin_key_returns(), $result);
+
+        // Mock last time request.
+        $mocktime = time() - 7 * MINSECS;
+        set_user_preference('tool_mobile_autologin_request_last', $mocktime, $USER);
+        $result = external::get_autologin_key($token->privatetoken);
+        $result = external_api::clean_returnvalue(external::get_autologin_key_returns(), $result);
+
+        // We just requested one token, we must wait.
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('autologinkeygenerationlockout', 'tool_mobile'));
+        $result = external::get_autologin_key($token->privatetoken);
+    }
 }
index e0d5dbe..8c3f25b 100644 (file)
@@ -23,6 +23,6 @@
  */
 
 defined('MOODLE_INTERNAL') || die();
-$plugin->version   = 2016052304; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version   = 2016052305; // The current plugin version (Date: YYYYMMDDXX).
 $plugin->requires  = 2016051900; // Requires this Moodle version.
 $plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
index 496d709..bcf2ff6 100644 (file)
@@ -98,12 +98,13 @@ Feature: tool_monitor_subscriptions
     Then I should see "Subscription successfully removed"
     And "#toolmonitorsubs_r0" "css_element" should not exist
 
+  @_bug_phantomjs
   Scenario: Receiving notification on site level
     Given I log in as "admin"
     And I follow "Preferences" in the user menu
-    And I follow "Messaging"
-    And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
-    And I press "Save changes"
+    And I click on "Notification preferences" "link" in the "#page-content" "css_element"
+    And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
+    And I wait until the page is ready
     And I follow "Preferences" in the user menu
     And I follow "Event monitoring"
     And I set the field "Select a course" to "Acceptance test site"
@@ -113,16 +114,18 @@ Feature: tool_monitor_subscriptions
     And I am on site homepage
     And I trigger cron
     And I am on site homepage
-    When I follow "Messages" in the user menu
-    And I follow "Do not reply to this email (1)"
-    Then I should see "The course was viewed."
+    When I click on ".popover-region-notifications" "css_element"
+    And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
+    Then I should see "New rule site level"
+    And I should see "The course was viewed"
 
+  @_bug_phantomjs
   Scenario: Receiving notification on course level
     Given I log in as "teacher1"
     And I follow "Preferences" in the user menu
-    And I follow "Messaging"
-    And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
-    And I press "Save changes"
+    And I click on "Notification preferences" "link" in the "#page-content" "css_element"
+    And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
+    And I wait until the page is ready
     And I follow "Preferences" in the user menu
     And I follow "Event monitoring"
     And I set the field "Select a course" to "Course 1"
@@ -133,9 +136,10 @@ Feature: tool_monitor_subscriptions
     And I follow "Course 1"
     And I trigger cron
     And I am on site homepage
-    When I follow "Messages" in the user menu
-    And I follow "Do not reply to this email (1)"
-    Then I should see "The course was viewed."
+    When I click on ".popover-region-notifications" "css_element"
+    And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
+    Then I should see "New rule course level"
+    And I should see "The course was viewed"
 
   Scenario: Navigating via quick link to rules
     Given I log in as "admin"
index 2ef5d4c..23b7dcf 100644 (file)
@@ -117,17 +117,21 @@ class api {
         // Get the list of possible template directories.
         $dirs = mustache_template_finder::get_template_directories_for_component($component);
         $filename = false;
+        $themedir = core_component::get_plugin_types()['theme'];
 
         foreach ($dirs as $dir) {
             // Skip theme dirs - we only want the original plugin/core template.
-            if (strpos($dir, "/theme/") === false) {
-                $candidate = $dir . $template . '.mustache';
-                if (file_exists($candidate)) {
-                    $filename = $candidate;
-                    break;
-                }
+            if (strpos($dir, $themedir) === 0) {
+                continue;
+            }
+
+            $candidate = $dir . $template . '.mustache';
+            if (file_exists($candidate)) {
+                $filename = $candidate;
+                break;
             }
         }
+
         if ($filename === false) {
             throw new moodle_exception('filenotfound', 'error');
         }
index d6fa887..54f60e7 100644 (file)
@@ -5,6 +5,7 @@ information provided here is intended especially for developers.
 
 * New auth hook - pre_user_login_hook() - available, triggered right after the user object is created.
   This can be used to modify the user object before any authentication errors are raised.
+* The block_login now displays the loginpage_idp_list() links as well as main login page.
 
 === 3.0 ===
 
index 3b323ad..6ecf6fe 100644 (file)
@@ -381,7 +381,7 @@ class cc2moodle {
         if (!empty($format['defaultblocks'])) {
             $blocknames = $format['defaultblocks'];
         } else {
-            if (!empty($CFG->defaultblocks)) {
+            if (isset($CFG->defaultblocks)) {
                 $blocknames = $CFG->defaultblocks;
             } else {
                 $blocknames = 'participants,activity_modules,search_forums,course_list:news_items,calendar_upcoming,recent_activity';
index 2758c82..bb86bdb 100644 (file)
@@ -98,8 +98,9 @@ Feature: View the course overview block on the dashboard and test it's functiona
     Then I should see "Welcome Student" in the "Course overview" "block"
     And I should see "You have no unread messages" in the "Course overview" "block"
     And I follow "messages"
-    And I should see "Contact list empty"
+    And I should see "No messages"
 
+  @javascript
   Scenario: View the block by a user with the welcome area and the user having messages.
     Given the following config values are set as admin:
       | showwelcomearea | 1 | block_course_overview |
index 2c4eda4..47f8588 100644 (file)
@@ -32,7 +32,7 @@ class block_login extends block_base {
     }
 
     function get_content () {
-        global $USER, $CFG, $SESSION;
+        global $USER, $CFG, $SESSION, $OUTPUT;
         $wwwroot = '';
         $signup = '';
 
@@ -96,15 +96,32 @@ class block_login extends block_base {
             $this->content->text .= "</form>\n";
 
             if (!empty($signup)) {
-                $this->content->footer .= '<div><a href="'.$signup.'">'.get_string('startsignup').'</a></div>';
+                $this->content->text .= '<div><a href="'.$signup.'">'.get_string('startsignup').'</a></div>';
             }
             if (!empty($forgot)) {
-                $this->content->footer .= '<div><a href="'.$forgot.'">'.get_string('forgotaccount').'</a></div>';
+                $this->content->text .= '<div><a href="'.$forgot.'">'.get_string('forgotaccount').'</a></div>';
+            }
+
+            $authsequence = get_enabled_auth_plugins(true); // Get all auths, in sequence.
+            $potentialidps = array();
+            foreach ($authsequence as $authname) {
+                $authplugin = get_auth_plugin($authname);
+                $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($this->page->url->out(false)));
+            }
+
+            if (!empty($potentialidps)) {
+                $this->content->text .= '<div class="potentialidps">';
+                $this->content->text .= '<h6>' . get_string('potentialidps', 'auth') . '</h6>';
+                $this->content->text .= '<div class="potentialidplist">';
+                foreach ($potentialidps as $idp) {
+                    $this->content->text .= '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . s($idp['name']) . '">';
+                    $this->content->text .= $OUTPUT->render($idp['icon'], $idp['name']) . s($idp['name']) . '</a></div>';
+                }
+                $this->content->text .= '</div>';
+                $this->content->text .= '</div>';
             }
         }
 
         return $this->content;
     }
 }
-
-
index 068b0e0..43446c2 100644 (file)
@@ -31,8 +31,9 @@ Feature: The messages block allows users to list new messages an a course
     And I follow "Course 1"
     When I turn editing mode on
     And I add the "Messages" block
-    Then I should see "No messages waiting" in the "Messages" "block"
+    Then I should see "No messages" in the "Messages" "block"
 
+  @javascript
   Scenario: View the block by a user who has messages.
     Given I log in as "student1"
     And I follow "Messages" in the user menu
@@ -45,12 +46,13 @@ Feature: The messages block allows users to list new messages an a course
     And I add the "Messages" block
     Then I should see "Student 1" in the "Messages" "block"
 
+  @javascript
   Scenario: Use the block to send a message to a user.
     Given I log in as "teacher1"
     And I follow "Course 1"
     And I turn editing mode on
     And I add the "Messages" block
-    And I follow "Messages"
+    And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
     And I send "This is message 1" message to "Student 1" user
     And I log out
     When I log in as "student1"
index 8eb1918..509057e 100644 (file)
@@ -22,8 +22,9 @@ Feature: The messages block allows users to list new messages on the dashboard
     Given I log in as "teacher1"
     And I press "Customise this page"
     When I add the "Messages" block
-    Then I should see "No messages waiting" in the "Messages" "block"
+    Then I should see "No messages" in the "Messages" "block"
 
+  @javascript
   Scenario: View the block by a user who has messages.
     Given I log in as "student1"
     And I follow "Messages" in the user menu
@@ -35,11 +36,12 @@ Feature: The messages block allows users to list new messages on the dashboard
     And I add the "Messages" block
     Then I should see "Student 1" in the "Messages" "block"
 
+  @javascript
   Scenario: Use the block to send a message to a user.
     Given I log in as "teacher1"
     And I press "Customise this page"
     And I add the "Messages" block
-    And I follow "Messages"
+    And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
     And I send "This is message 1" message to "Student 1" user
     And I log out
     When I log in as "student1"
index df00991..2c71001 100644 (file)
@@ -28,13 +28,14 @@ Feature: The messages block allows users to list new messages on the frontpage
   Scenario: View the block by a user who does not have any messages.
     Given I log in as "teacher1"
     When I am on site homepage
-    Then I should see "No messages waiting" in the "Messages" "block"
+    Then I should see "No messages" in the "Messages" "block"
 
   Scenario: Try to view the block as a guest user.
     Given I log in as "guest"
     When I am on site homepage
     Then I should not see "Messages"
 
+  @javascript
   Scenario: View the block by a user who has messages.
     Given I log in as "student1"
     And I follow "Messages" in the user menu
@@ -45,10 +46,11 @@ Feature: The messages block allows users to list new messages on the frontpage
     And I am on site homepage
     Then I should see "Student 1" in the "Messages" "block"
 
+  @javascript
   Scenario: Use the block to send a message to a user.
     Given I log in as "teacher1"
     And I am on site homepage
-    And I follow "Messages"
+    And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block"
     And I send "This is message 1" message to "Student 1" user
     And I log out
     When I log in as "student1"
index dcf3133..9b2e19e 100644 (file)
@@ -39,7 +39,7 @@ class block_online_users extends block_base {
     }
 
     function get_content() {
-        global $USER, $CFG, $DB, $OUTPUT, $PAGE;
+        global $USER, $CFG, $DB, $OUTPUT;
 
         if ($this->content !== NULL) {
             return $this->content;
@@ -106,7 +106,6 @@ class block_online_users extends block_base {
             if (isloggedin() && has_capability('moodle/site:sendmessage', $this->page->context)
                            && !empty($CFG->messaging) && !isguestuser()) {
                 $canshowicon = true;
-                message_messenger_requirejs();
             } else {
                 $canshowicon = false;
             }
@@ -126,10 +125,8 @@ class block_online_users extends block_base {
                 if ($canshowicon and ($USER->id != $user->id) and !isguestuser($user)) {  // Only when logged in and messaging active etc
                     $anchortagcontents = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" />';
                     $anchorurl = new moodle_url('/message/index.php', array('id' => $user->id));
-                    $anchortag = html_writer::link($anchorurl, $anchortagcontents, array_merge(
-                      message_messenger_sendmessage_link_params($user),
-                      array('title' => get_string('messageselectadd'))
-                    ));
+                    $anchortag = html_writer::link($anchorurl, $anchortagcontents,
+                        array('title' => get_string('messageselectadd')));
 
                     $this->content->text .= '<div class="message">'.$anchortag.'</div>';
                 }
index de4aed6..b50286e 100644 (file)
@@ -31,7 +31,7 @@ Feature: People Block used in a course
     When I log in as "student1"
     And I follow "Course 1"
     And I click on "Participants" "link" in the "People" "block"
-    Then I should see "All participants" in the "h3" "css_element"
+    Then I should see "All participants" in the "#page-content" "css_element"
     And the "My courses" select box should contain "C101"
 
   Scenario: Student without permission can not view participants link
index 8a8e746..1cebc85 100644 (file)
Binary files a/blocks/settings/amd/build/settingsblock.min.js and b/blocks/settings/amd/build/settingsblock.min.js differ
index bdccda5..f17553f 100644 (file)
@@ -40,9 +40,6 @@ define(['jquery', 'core/tree'], function($, Tree) {
             };
             adminTree.collapseGroup = function(item) {
                 Tree.prototype.collapseGroup.call(this, item);
-                Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
-                    instanceid: instanceid
-                });
                 Y.use('moodle-core-event', function() {
                     Y.Global.fire(M.core.globalEvents.BLOCK_CONTENT_UPDATED, {
                         instanceid: instanceid
index 8de3bdc..9c12087 100644 (file)
@@ -36,7 +36,7 @@ class blog_edit_external_form extends moodleform {
 
         $mform =& $this->_form;
 
-        $mform->addElement('url', 'url', get_string('url', 'blog'), array('size' => 50));
+        $mform->addElement('url', 'url', get_string('url', 'blog'), array('size' => 50), array('usefilepicker' => false));
         $mform->setType('url', PARAM_URL);
         $mform->addRule('url', get_string('emptyurl', 'blog'), 'required', null, 'client');
         $mform->addHelpButton('url', 'url', 'blog');
index d6d1637..ac20bec 100644 (file)
@@ -198,7 +198,7 @@ class cache_factory {
         }
         $definition = $this->create_definition($component, $area);
         $definition->set_identifiers($identifiers);
-        $cache = $this->create_cache($definition, $identifiers);
+        $cache = $this->create_cache($definition);
         // Loaders are always held onto to speed up subsequent requests.
         $this->cachesfromdefinitions[$definitionname] = $cache;
         return $cache;
@@ -227,7 +227,7 @@ class cache_factory {
         }
         $definition = cache_definition::load_adhoc($mode, $component, $area, $options);
         $definition->set_identifiers($identifiers);
-        $cache = $this->create_cache($definition, $identifiers);
+        $cache = $this->create_cache($definition);
         $this->cachesfromparams[$key] = $cache;
         return $cache;
     }
index fae2f35..565f27e 100644 (file)
@@ -213,7 +213,8 @@ class cache_factory_disabled extends cache_factory {
      */
     public function create_cache_from_definition($component, $area, array $identifiers = array(), $unused = null) {
         $definition = $this->create_definition($component, $area);
-        $cache = $this->create_cache($definition, $identifiers);
+        $definition->set_identifiers($identifiers);
+        $cache = $this->create_cache($definition);
         return $cache;
     }
 
@@ -233,7 +234,8 @@ class cache_factory_disabled extends cache_factory {
      */
     public function create_cache_from_params($mode, $component, $area, array $identifiers = array(), array $options = array()) {
         $definition = cache_definition::load_adhoc($mode, $component, $area);
-        $cache = $this->create_cache($definition, $identifiers);
+        $definition->set_identifiers($identifiers);
+        $cache = $this->create_cache($definition);
         return $cache;
     }
 
index 2e6813e..e97dd56 100644 (file)
@@ -691,7 +691,7 @@ abstract class cache_administration_helper extends cache_helper {
                 'plugin' => $details['plugin'],
                 'default' => $details['default'],
                 'isready' => $store->is_ready(),
-                'requirementsmet' => $store->are_requirements_met(),
+                'requirementsmet' => $class::are_requirements_met(),
                 'mappings' => 0,
                 'lock' => $lock,
                 'modes' => array(
index a0dd6b8..27cd2e6 100644 (file)
@@ -69,7 +69,8 @@ class cachestore_apcu extends cache_store implements cache_is_key_aware, cache_i
      * @return bool True if the stores software/hardware requirements have been met and it can be used. False otherwise.
      */
     public static function are_requirements_met() {
-        if (!extension_loaded('apcu') || !ini_get('apc.enabled')) {
+        $enabled = ini_get('apc.enabled') && (php_sapi_name() != "cli" || ini_get('apc.enable_cli'));
+        if (!extension_loaded('apcu') || !$enabled) {
             return false;
         }
 
index 043111e..a7f8b88 100644 (file)
@@ -2196,10 +2196,13 @@ class api {
      */
     public static function reorder_template_competency($templateid, $competencyidfrom, $competencyidto) {
         static::require_enabled();
-        // First we do a permissions check.
-        $context = context_system::instance();
+        $template = new template($templateid);
 
-        require_capability('moodle/competency:templatemanage', $context);
+        // First we do a permissions check.
+        if (!$template->can_manage()) {
+            throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
+                'nopermissions', '');
+        }
 
         $down = true;
         $matches = template_competency::get_records(array('templateid' => $templateid, 'competencyid' => $competencyidfrom));
index cb815aa..d55446b 100644 (file)
@@ -1883,6 +1883,71 @@ class core_competency_api_testcase extends advanced_testcase {
         $this->assertInstanceOf('core_competency\\template_cohort', $result);
     }
 
+    public function test_reorder_template_competencies_permissions() {
+        $this->resetAfterTest(true);
+
+        $dg = $this->getDataGenerator();
+        $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
+        $cat = $dg->create_category();
+        $catcontext = context_coursecat::instance($cat->id);
+        $syscontext = context_system::instance();
+
+        $user = $dg->create_user();
+        $role = $dg->create_role();
+        assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $role, $syscontext->id, true);
+        $dg->role_assign($role, $user->id, $syscontext->id);
+
+        // Create a template.
+        $template = $lpg->create_template(array('contextid' => $catcontext->id));
+
+        // Create a competency framework.
+        $framework = $lpg->create_framework(array('contextid' => $catcontext->id));
+
+        // Create competencies.
+        $competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
+        $competency2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id()));
+
+        // Add the competencies.
+        $lpg->create_template_competency(array(
+            'templateid' => $template->get_id(),
+            'competencyid' => $competency1->get_id()
+        ));
+        $lpg->create_template_competency(array(
+            'templateid' => $template->get_id(),
+            'competencyid' => $competency2->get_id()
+        ));
+        $this->setUser($user);
+        // Can reorder competencies with system context permissions in category context.
+        $result = api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
+        $this->assertTrue($result);
+        unassign_capability('moodle/competency:templatemanage', $role, $syscontext->id);
+        accesslib_clear_all_caches_for_unit_testing();
+
+        try {
+            api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
+            $this->fail('Exception expected due to not permissions to manage template competencies');
+        } catch (required_capability_exception $e) {
+            $this->assertEquals('nopermissions', $e->errorcode);
+        }
+
+        // Giving permissions in category context.
+        assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $role, $catcontext->id, true);
+        $dg->role_assign($role, $user->id, $catcontext->id);
+        // User with templatemanage capability in category context can reorder competencies in temple.
+        $result = api::reorder_template_competency($template->get_id(), $competency1->get_id(), $competency2->get_id());
+        $this->assertTrue($result);
+        // Removing templatemanage capability in category context.
+        unassign_capability('moodle/competency:templatemanage', $role, $catcontext->id);
+        accesslib_clear_all_caches_for_unit_testing();
+
+        try {
+            api::reorder_template_competency($template->get_id(), $competency2->get_id(), $competency1->get_id());
+            $this->fail('Exception expected due to not permissions to manage template competencies');
+        } catch (required_capability_exception $e) {
+            $this->assertEquals('nopermissions', $e->errorcode);
+        }
+    }
+
     public function test_delete_template() {
         $this->resetAfterTest(true);
         $this->setAdminUser();
index 641d22b..3f7df7f 100644 (file)
@@ -5,7 +5,7 @@
     "type": "project",
     "homepage": "https://moodle.org",
     "require-dev": {
-        "phpunit/phpunit": "5.4.*",
+        "phpunit/phpunit": "5.5.*",
         "phpunit/dbUnit": "1.4.*",
         "moodlehq/behat-extension": "3.32.3"
     }
index f980783..8ebc23e 100644 (file)
@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "c3da2812d8753f3fb2429366b373afa8",
-    "content-hash": "a4e8fa2277e59a3c14afb3ae729bf4e7",
+    "hash": "ec5f1e9d8b8134cf6a4490ba5dfe0082",
+    "content-hash": "583f9a915721de799118a396dc81f177",
     "packages": [],
     "packages-dev": [
         {
         },
         {
             "name": "phpunit/phpunit",
-            "version": "5.4.8",
+            "version": "5.5.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "3132365e1430c091f208e120b8845d39c25f20e6"
+                "reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3132365e1430c091f208e120b8845d39c25f20e6",
-                "reference": "3132365e1430c091f208e120b8845d39c25f20e6",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3f67cee782c9abfaee5e32fd2f57cdd54bc257ba",
+                "reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba",
                 "shasum": ""
             },
             "require": {
                 "ext-dom": "*",
                 "ext-json": "*",
-                "ext-pcre": "*",
-                "ext-reflection": "*",
-                "ext-spl": "*",
+                "ext-libxml": "*",
+                "ext-mbstring": "*",
+                "ext-xml": "*",
                 "myclabs/deep-copy": "~1.3",
                 "php": "^5.6 || ^7.0",
                 "phpspec/prophecy": "^1.3.1",
             "conflict": {
                 "phpdocumentor/reflection-docblock": "3.0.2"
             },
+            "require-dev": {
+                "ext-pdo": "*"
+            },
             "suggest": {
+                "ext-tidy": "*",
+                "ext-xdebug": "*",
                 "phpunit/php-invoker": "~1.1"
             },
             "bin": [
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "5.4.x-dev"
+                    "dev-master": "5.5.x-dev"
                 }
             },
             "autoload": {
                 "testing",
                 "xunit"
             ],
-            "time": "2016-07-26 14:48:00"
+            "time": "2016-10-03 13:04:15"
         },
         {
             "name": "phpunit/phpunit-mock-objects",
-            "version": "3.2.7",
+            "version": "3.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
-                "reference": "546898a2c0c356ef2891b39dd7d07f5d82c8ed0a"
+                "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/546898a2c0c356ef2891b39dd7d07f5d82c8ed0a",
-                "reference": "546898a2c0c356ef2891b39dd7d07f5d82c8ed0a",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/03500345483e1e17b52e2e4d34a89c9408ab2902",
+                "reference": "03500345483e1e17b52e2e4d34a89c9408ab2902",
                 "shasum": ""
             },
             "require": {
                 "mock",
                 "xunit"
             ],
-            "time": "2016-09-06 16:07:45"
+            "time": "2016-10-04 11:03:26"
         },
         {
             "name": "psr/http-message",
             ],
             "time": "2016-08-06 14:39:51"
         },
+        {
+            "name": "psr/log",
+            "version": "1.0.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/php-fig/log.git",
+                "reference": "5277094ed527a1c4477177d102fe4c53551953e0"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0",
+                "reference": "5277094ed527a1c4477177d102fe4c53551953e0",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Psr\\Log\\": "Psr/Log/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "PHP-FIG",
+                    "homepage": "http://www.php-fig.org/"
+                }
+            ],
+            "description": "Common interface for logging libraries",
+            "homepage": "https://github.com/php-fig/log",
+            "keywords": [
+                "log",
+                "psr",
+                "psr-3"
+            ],
+            "time": "2016-09-19 16:02:08"
+        },
         {
             "name": "sebastian/code-unit-reverse-lookup",
             "version": "1.0.0",
         },
         {
             "name": "symfony/browser-kit",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/browser-kit.git",
-                "reference": "d2a07cc11c5fa94820240b1e67592ffb18e347b9"
+                "reference": "901319a31c9b3cee7857b4aeeb81b5d64dfa34fc"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/browser-kit/zipball/d2a07cc11c5fa94820240b1e67592ffb18e347b9",
-                "reference": "d2a07cc11c5fa94820240b1e67592ffb18e347b9",
+                "url": "https://api.github.com/repos/symfony/browser-kit/zipball/901319a31c9b3cee7857b4aeeb81b5d64dfa34fc",
+                "reference": "901319a31c9b3cee7857b4aeeb81b5d64dfa34fc",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony BrowserKit Component",
             "homepage": "https://symfony.com",
-            "time": "2016-07-26 08:04:17"
+            "time": "2016-09-06 11:02:40"
         },
         {
             "name": "symfony/class-loader",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/class-loader.git",
-                "reference": "2d0ba77c46ecc96a6641009a98f72632216811ba"
+                "reference": "bcb072aba46ddf3b1a496438c63be6be647739aa"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/class-loader/zipball/2d0ba77c46ecc96a6641009a98f72632216811ba",
-                "reference": "2d0ba77c46ecc96a6641009a98f72632216811ba",
+                "url": "https://api.github.com/repos/symfony/class-loader/zipball/bcb072aba46ddf3b1a496438c63be6be647739aa",
+                "reference": "bcb072aba46ddf3b1a496438c63be6be647739aa",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony ClassLoader Component",
             "homepage": "https://symfony.com",
-            "time": "2016-08-23 13:39:15"
+            "time": "2016-09-06 23:30:54"
         },
         {
             "name": "symfony/config",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/config.git",
-                "reference": "431d28df9c7bb6e77f8f6289d8670b044fabb9e8"
+                "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/config/zipball/431d28df9c7bb6e77f8f6289d8670b044fabb9e8",
-                "reference": "431d28df9c7bb6e77f8f6289d8670b044fabb9e8",
+                "url": "https://api.github.com/repos/symfony/config/zipball/949e7e846743a7f9e46dc50eb639d5fde1f53341",
+                "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony Config Component",
             "homepage": "https://symfony.com",
-            "time": "2016-08-27 18:50:07"
+            "time": "2016-09-25 08:27:07"
         },
         {
             "name": "symfony/console",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563"
+                "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/8ea494c34f0f772c3954b5fbe00bffc5a435e563",
-                "reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563",
+                "url": "https://api.github.com/repos/symfony/console/zipball/6cb0872fb57b38b3b09ff213c21ed693956b9eb0",
+                "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0",
                 "shasum": ""
             },
             "require": {
                 "php": ">=5.5.9",
+                "symfony/debug": "~2.8|~3.0",
                 "symfony/polyfill-mbstring": "~1.0"
             },
             "require-dev": {
             ],
             "description": "Symfony Console Component",
             "homepage": "https://symfony.com",
-            "time": "2016-08-19 06:48:39"
+            "time": "2016-09-28 00:11:12"
         },
         {
             "name": "symfony/css-selector",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/css-selector.git",
-                "reference": "2851e1932d77ce727776154d659b232d061e816a"
+                "reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a",
-                "reference": "2851e1932d77ce727776154d659b232d061e816a",
+                "url": "https://api.github.com/repos/symfony/css-selector/zipball/ca809c64072e0fe61c1c7fb3c76cdc32265042ac",
+                "reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony CssSelector Component",
             "homepage": "https://symfony.com",
-            "time": "2016-06-29 05:41:56"
+            "time": "2016-09-06 11:02:40"
+        },
+        {
+            "name": "symfony/debug",
+            "version": "v3.1.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/debug.git",
+                "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8",
+                "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.5.9",
+                "psr/log": "~1.0"
+            },
+            "conflict": {
+                "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
+            },
+            "require-dev": {
+                "symfony/class-loader": "~2.8|~3.0",
+                "symfony/http-kernel": "~2.8|~3.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "3.1-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Symfony\\Component\\Debug\\": ""
+                },
+                "exclude-from-classmap": [
+                    "/Tests/"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "https://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony Debug Component",
+            "homepage": "https://symfony.com",
+            "time": "2016-09-06 11:02:40"
         },
         {
             "name": "symfony/dependency-injection",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/dependency-injection.git",
-                "reference": "6e4f3316afdc9783d7b48a136db89bd791b55698"
+                "reference": "8fa4be9a36f41e49b0c3969678c41c81ed463816"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6e4f3316afdc9783d7b48a136db89bd791b55698",
-                "reference": "6e4f3316afdc9783d7b48a136db89bd791b55698",
+                "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8fa4be9a36f41e49b0c3969678c41c81ed463816",
+                "reference": "8fa4be9a36f41e49b0c3969678c41c81ed463816",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony DependencyInjection Component",
             "homepage": "https://symfony.com",
-            "time": "2016-08-23 13:39:15"
+            "time": "2016-09-24 15:56:48"
         },
         {
             "name": "symfony/dom-crawler",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/dom-crawler.git",
         },
         {
             "name": "symfony/event-dispatcher",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/event-dispatcher.git",
         },
         {
             "name": "symfony/filesystem",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/filesystem.git",
-                "reference": "bb29adceb552d202b6416ede373529338136e84f"
+                "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f",
-                "reference": "bb29adceb552d202b6416ede373529338136e84f",
+                "url": "https://api.github.com/repos/symfony/filesystem/zipball/682fd8fdb3135fdf05fc496a01579ccf6c85c0e5",
+                "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony Filesystem Component",
             "homepage": "https://symfony.com",
-            "time": "2016-07-20 05:44:26"
+            "time": "2016-09-14 00:18:46"
         },
         {
             "name": "symfony/polyfill-mbstring",
         },
         {
             "name": "symfony/process",
-            "version": "v2.8.11",
+            "version": "v2.8.12",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/process.git",
-                "reference": "05a03ed27073638658cab9405d99a67dd1014987"
+                "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/process/zipball/05a03ed27073638658cab9405d99a67dd1014987",
-                "reference": "05a03ed27073638658cab9405d99a67dd1014987",
+                "url": "https://api.github.com/repos/symfony/process/zipball/024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f",
+                "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony Process Component",
             "homepage": "https://symfony.com",
-            "time": "2016-09-06 10:55:00"
+            "time": "2016-09-29 14:03:54"
         },
         {
             "name": "symfony/translation",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation.git",
-                "reference": "a35edc277513c9bc0f063ca174c36b346f974528"
+                "reference": "93013a18d272e59dab8e67f583155b78c68947eb"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/translation/zipball/a35edc277513c9bc0f063ca174c36b346f974528",
-                "reference": "a35edc277513c9bc0f063ca174c36b346f974528",
+                "url": "https://api.github.com/repos/symfony/translation/zipball/93013a18d272e59dab8e67f583155b78c68947eb",
+                "reference": "93013a18d272e59dab8e67f583155b78c68947eb",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony Translation Component",
             "homepage": "https://symfony.com",
-            "time": "2016-08-05 08:37:39"
+            "time": "2016-09-06 11:02:40"
         },
         {
             "name": "symfony/yaml",
-            "version": "v3.1.4",
+            "version": "v3.1.5",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/yaml.git",
-                "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d"
+                "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d",
-                "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d",
+                "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3",
+                "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3",
                 "shasum": ""
             },
             "require": {
             ],
             "description": "Symfony Yaml Component",
             "homepage": "https://symfony.com",
-            "time": "2016-09-02 02:12:52"
+            "time": "2016-09-25 08:27:07"
         },
         {
             "name": "webmozart/assert",
index 302c5d9..f667427 100644 (file)
@@ -477,7 +477,7 @@ abstract class format_base {
      */
     public function get_default_blocks() {
         global $CFG;
-        if (!empty($CFG->defaultblocks)){
+        if (isset($CFG->defaultblocks)) {
             return blocks_parse_default_blocks_list($CFG->defaultblocks);
         }
         $blocknames = array(
index 2aaaadf..06e18da 100644 (file)
@@ -1,11 +1,6 @@
 .course-content ul.topics {
     margin: 0;
-}
-
-.course-content ul.topics li.section {
     list-style: none;
-    margin: 0 0 5px 0;
-    padding: 0;
 }
 
 .course-content ul.topics li.section .content {
index eb85763..e7f309d 100644 (file)
@@ -1,11 +1,6 @@
 .course-content ul.weeks {
     margin: 0;
-}
-
-.course-content ul.weeks li.section {
     list-style: none;
-    margin: 0 0 5px 0;
-    padding: 0;
 }
 
 .course-content ul.weeks li.section .content {
index e3094fd..e731709 100644 (file)
@@ -230,629 +230,6 @@ function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.tim
     return $result;
 }
 
-function build_logs_array($course, $user=0, $date=0, $order="l.time ASC", $limitfrom='', $limitnum='',
-                   $modname="", $modid=0, $modaction="", $groupid=0) {
-    global $DB, $SESSION, $USER;
-    // It is assumed that $date is the GMT time of midnight for that day,
-    // and so the next 86400 seconds worth of logs are printed.
-
-    /// Setup for group handling.
-
-    /// If the group mode is separate, and this user does not have editing privileges,
-    /// then only the user's group can be viewed.
-    if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', context_course::instance($course->id))) {
-        if (isset($SESSION->currentgroup[$course->id])) {
-            $groupid =  $SESSION->currentgroup[$course->id];
-        } else {
-            $groupid = groups_get_all_groups($course->id, $USER->id);
-            if (is_array($groupid)) {
-                $groupid = array_shift(array_keys($groupid));
-                $SESSION->currentgroup[$course->id] = $groupid;
-            } else {
-                $groupid = 0;
-            }
-        }
-    }
-    /// If this course doesn't have groups, no groupid can be specified.
-    else if (!$course->groupmode) {
-        $groupid = 0;
-    }
-
-    $joins = array();
-    $params = array();
-
-    if ($course->id != SITEID || $modid != 0) {
-        $joins[] = "l.course = :courseid";
-        $params['courseid'] = $course->id;
-    }
-
-    if ($modname) {
-        $joins[] = "l.module = :modname";
-        $params['modname'] = $modname;
-    }
-
-    if ('site_errors' === $modid) {
-        $joins[] = "( l.action='error' OR l.action='infected' )";
-    } else if ($modid) {
-        $joins[] = "l.cmid = :modid";
-        $params['modid'] = $modid;
-    }
-
-    if ($modaction) {
-        $firstletter = substr($modaction, 0, 1);
-        if ($firstletter == '-') {
-            $joins[] = $DB->sql_like('l.action', ':modaction', false, true, true);
-            $params['modaction'] = '%'.substr($modaction, 1).'%';
-        } else {
-            $joins[] = $DB->sql_like('l.action', ':modaction', false);
-            $params['modaction'] = '%'.$modaction.'%';
-        }
-    }
-
-
-    /// Getting all members of a group.
-    if ($groupid and !$user) {
-        if ($gusers = groups_get_members($groupid)) {
-            $gusers = array_keys($gusers);
-            $joins[] = 'l.userid IN (' . implode(',', $gusers) . ')';
-        } else {
-            $joins[] = 'l.userid = 0'; // No users in groups, so we want something that will always be false.
-        }
-    }
-    else if ($user) {
-        $joins[] = "l.userid = :userid";
-        $params['userid'] = $user;
-    }
-
-    if ($date) {
-        $enddate = $date + 86400;
-        $joins[] = "l.time > :date AND l.time < :enddate";
-        $params['date'] = $date;
-        $params['enddate'] = $enddate;
-    }
-
-    $selector = implode(' AND ', $joins);
-
-    $totalcount = 0;  // Initialise
-    $result = array();
-    $result['logs'] = get_logs($selector, $params, $order, $limitfrom, $limitnum, $totalcount);
-    $result['totalcount'] = $totalcount;
-    return $result;
-}
-
-
-function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
-                   $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
-
-    global $CFG, $DB, $OUTPUT;
-
-    if (!$logs = build_logs_array($course, $user, $date, $order, $page*$perpage, $perpage,
-                       $modname, $modid, $modaction, $groupid)) {
-        echo $OUTPUT->notification("No logs found!");
-        echo $OUTPUT->footer();
-        exit;
-    }
-
-    $courses = array();
-
-    if ($course->id == SITEID) {
-        $courses[0] = '';
-        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
-            foreach ($ccc as $cc) {
-                $courses[$cc->id] = $cc->shortname;
-            }
-        }
-    } else {
-        $courses[$course->id] = $course->shortname;
-    }
-
-    $totalcount = $logs['totalcount'];
-    $count=0;
-    $ldcache = array();
-    $tt = getdate(time());
-    $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-
-    $strftimedatetime = get_string("strftimedatetime");
-
-    echo "<div class=\"info\">\n";
-    print_string("displayingrecords", "", $totalcount);
-    echo "</div>\n";
-
-    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
-
-    $table = new html_table();
-    $table->classes = array('logtable','generaltable');
-    $table->align = array('right', 'left', 'left');
-    $table->head = array(
-        get_string('time'),
-        get_string('ip_address'),
-        get_string('fullnameuser'),
-        get_string('action'),
-        get_string('info')
-    );
-    $table->data = array();
-
-    if ($course->id == SITEID) {
-        array_unshift($table->align, 'left');
-        array_unshift($table->head, get_string('course'));
-    }
-
-    // Make sure that the logs array is an array, even it is empty, to avoid warnings from the foreach.
-    if (empty($logs['logs'])) {
-        $logs['logs'] = array();
-    }
-
-    foreach ($logs['logs'] as $log) {
-
-        if (isset($ldcache[$log->module][$log->action])) {
-            $ld = $ldcache[$log->module][$log->action];
-        } else {
-            $ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
-            $ldcache[$log->module][$log->action] = $ld;
-        }
-        if ($ld && is_numeric($log->info)) {
-            // ugly hack to make sure fullname is shown correctly
-            if ($ld->mtable == 'user' && $ld->field == $DB->sql_concat('firstname', "' '" , 'lastname')) {
-                $log->info = fullname($DB->get_record($ld->mtable, array('id'=>$log->info)), true);
-            } else {
-                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id'=>$log->info));
-            }
-        }
-
-        //Filter log->info
-        $log->info = format_string($log->info);
-
-        // If $log->url has been trimmed short by the db size restriction
-        // code in add_to_log, keep a note so we don't add a link to a broken url
-        $brokenurl=(core_text::strlen($log->url)==100 && core_text::substr($log->url,97)=='...');
-
-        $row = array();
-        if ($course->id == SITEID) {
-            if (empty($log->course)) {
-                $row[] = get_string('site');
-            } else {
-                $row[] = "<a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">". format_string($courses[$log->course])."</a>";
-            }
-        }
-
-        $row[] = userdate($log->time, '%a').' '.userdate($log->time, $strftimedatetime);
-
-        $link = new moodle_url("/iplookup/index.php?ip=$log->ip&user=$log->userid");
-        $row[] = $OUTPUT->action_link($link, $log->ip, new popup_action('click', $link, 'iplookup', array('height' => 440, 'width' => 700)));
-
-        $row[] = html_writer::link(new moodle_url("/user/view.php?id={$log->userid}&course={$log->course}"), fullname($log, has_capability('moodle/site:viewfullnames', context_course::instance($course->id))));
-
-        $displayaction="$log->module $log->action";
-        if ($brokenurl) {
-            $row[] = $displayaction;
-        } else {
-            $link = make_log_url($log->module,$log->url);
-            $row[] = $OUTPUT->action_link($link, $displayaction, new popup_action('click', $link, 'fromloglive'), array('height' => 440, 'width' => 700));
-        }
-        $row[] = $log->info;
-        $table->data[] = $row;
-    }
-
-    echo html_writer::table($table);
-    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
-}
-
-
-function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
-                   $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
-
-    global $CFG, $DB, $OUTPUT;
-
-    if (!$logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page*$perpage, $perpage,
-                       $modname, $modid, $modaction, $groupid)) {
-        echo $OUTPUT->notification("No logs found!");
-        echo $OUTPUT->footer();
-        exit;
-    }
-
-    if ($course->id == SITEID) {
-        $courses[0] = '';
-        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) {
-            foreach ($ccc as $cc) {
-                $courses[$cc->id] = $cc->shortname;
-            }
-        }
-    }
-
-    $totalcount = $logs['totalcount'];
-    $count=0;
-    $ldcache = array();
-    $tt = getdate(time());
-    $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-
-    $strftimedatetime = get_string("strftimedatetime");
-
-    echo "<div class=\"info\">\n";
-    print_string("displayingrecords", "", $totalcount);
-    echo "</div>\n";
-
-    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
-
-    echo "<table class=\"logtable\" cellpadding=\"3\" cellspacing=\"0\">\n";
-    echo "<tr>";
-    if ($course->id == SITEID) {
-        echo "<th class=\"c0 header\">".get_string('course')."</th>\n";
-    }
-    echo "<th class=\"c1 header\">".get_string('time')."</th>\n";
-    echo "<th class=\"c2 header\">".get_string('ip_address')."</th>\n";
-    echo "<th class=\"c3 header\">".get_string('fullnameuser')."</th>\n";
-    echo "<th class=\"c4 header\">".get_string('action')."</th>\n";
-    echo "<th class=\"c5 header\">".get_string('info')."</th>\n";
-    echo "</tr>\n";
-
-    if (empty($logs['logs'])) {
-        echo "</table>\n";
-        return;
-    }
-
-    $row = 1;
-    foreach ($logs['logs'] as $log) {
-
-        $log->info = $log->coursename;
-        $row = ($row + 1) % 2;
-
-        if (isset($ldcache[$log->module][$log->action])) {
-            $ld = $ldcache[$log->module][$log->action];
-        } else {
-            $ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
-            $ldcache[$log->module][$log->action] = $ld;
-        }
-        if (0 && $ld && !empty($log->info)) {
-            // ugly hack to make sure fullname is shown correctly
-            if (($ld->mtable == 'user') and ($ld->field == $DB->sql_concat('firstname', "' '" , 'lastname'))) {
-                $log->info = fullname($DB->get_record($ld->mtable, array('id'=>$log->info)), true);
-            } else {
-                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id'=>$log->info));
-            }
-        }
-
-        //Filter log->info
-        $log->info = format_string($log->info);
-
-        echo '<tr class="r'.$row.'">';
-        if ($course->id == SITEID) {
-            $courseshortname = format_string($courses[$log->course], true, array('context' => context_course::instance(SITEID)));
-            echo "<td class=\"r$row c0\" >\n";
-            echo "    <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">".$courseshortname."</a>\n";
-            echo "</td>\n";
-        }
-        echo "<td class=\"r$row c1\" align=\"right\">".userdate($log->time, '%a').
-             ' '.userdate($log->time, $strftimedatetime)."</td>\n";
-        echo "<td class=\"r$row c2\" >\n";
-        $link = new moodle_url("/iplookup/index.php?ip=$log->ip&user=$log->userid");
-        echo $OUTPUT->action_link($link, $log->ip, new popup_action('click', $link, 'iplookup', array('height' => 400, 'width' => 700)));
-        echo "</td>\n";
-        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', context_course::instance($course->id)));
-        echo "<td class=\"r$row c3\" >\n";
-        echo "    <a href=\"$CFG->wwwroot/user/view.php?id={$log->userid}\">$fullname</a>\n";
-        echo "</td>\n";
-        echo "<td class=\"r$row c4\">\n";
-        echo $log->action .': '.$log->module;
-        echo "</td>\n";
-        echo "<td class=\"r$row c5\">{$log->info}</td>\n";
-        echo "</tr>\n";
-    }
-    echo "</table>\n";
-
-    echo $OUTPUT->paging_bar($totalcount, $page, $perpage, "$url&perpage=$perpage");
-}
-
-
-function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
-                        $modid, $modaction, $groupid) {
-    global $DB, $CFG;
-
-    require_once($CFG->libdir . '/csvlib.class.php');
-
-    $csvexporter = new csv_export_writer('tab');
-
-    $header = array();
-    $header[] = get_string('course');
-    $header[] = get_string('time');
-    $header[] = get_string('ip_address');
-    $header[] = get_string('fullnameuser');
-    $header[] = get_string('action');
-    $header[] = get_string('info');
-
-    if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
-                       $modname, $modid, $modaction, $groupid)) {
-        return false;
-    }
-
-    $courses = array();
-
-    if ($course->id == SITEID) {
-        $courses[0] = '';
-        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
-            foreach ($ccc as $cc) {
-                $courses[$cc->id] = $cc->shortname;
-            }
-        }
-    } else {
-        $courses[$course->id] = $course->shortname;
-    }
-
-    $count=0;
-    $ldcache = array();
-    $tt = getdate(time());
-    $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-
-    $strftimedatetime = get_string("strftimedatetime");
-
-    $csvexporter->set_filename('logs', '.txt');
-    $title = array(get_string('savedat').userdate(time(), $strftimedatetime));
-    $csvexporter->add_data($title);
-    $csvexporter->add_data($header);
-
-    if (empty($logs['logs'])) {
-        return true;
-    }
-
-    foreach ($logs['logs'] as $log) {
-        if (isset($ldcache[$log->module][$log->action])) {
-            $ld = $ldcache[$log->module][$log->action];
-        } else {
-            $ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
-            $ldcache[$log->module][$log->action] = $ld;
-        }
-        if ($ld && is_numeric($log->info)) {
-            // ugly hack to make sure fullname is shown correctly
-            if (($ld->mtable == 'user') and ($ld->field ==  $DB->sql_concat('firstname', "' '" , 'lastname'))) {
-                $log->info = fullname($DB->get_record($ld->mtable, array('id'=>$log->info)), true);
-            } else {
-                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id'=>$log->info));
-            }
-        }
-
-        //Filter log->info
-        $log->info = format_string($log->info);
-        $log->info = strip_tags(urldecode($log->info));    // Some XSS protection
-
-        $coursecontext = context_course::instance($course->id);
-        $firstField = format_string($courses[$log->course], true, array('context' => $coursecontext));
-        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
-        $actionurl = $CFG->wwwroot. make_log_url($log->module,$log->url);
-        $row = array($firstField, userdate($log->time, $strftimedatetime), $log->ip, $fullname, $log->module.' '.$log->action.' ('.$actionurl.')', $log->info);
-        $csvexporter->add_data($row);
-    }
-    $csvexporter->download_file();
-    return true;
-}
-
-
-function print_log_xls($course, $user, $date, $order='l.time DESC', $modname,
-                        $modid, $modaction, $groupid) {
-
-    global $CFG, $DB;
-
-    require_once("$CFG->libdir/excellib.class.php");
-
-    if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
-                       $modname, $modid, $modaction, $groupid)) {
-        return false;
-    }
-
-    $courses = array();
-
-    if ($course->id == SITEID) {
-        $courses[0] = '';
-        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
-            foreach ($ccc as $cc) {
-                $courses[$cc->id] = $cc->shortname;
-            }
-        }
-    } else {
-        $courses[$course->id] = $course->shortname;
-    }
-
-    $count=0;
-    $ldcache = array();
-    $tt = getdate(time());
-    $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-
-    $strftimedatetime = get_string("strftimedatetime");
-
-    $nroPages = ceil(count($logs)/(EXCELROWS-FIRSTUSEDEXCELROW+1));
-    $filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
-    $filename .= '.xls';
-
-    $workbook = new MoodleExcelWorkbook('-');
-    $workbook->send($filename);
-
-    $worksheet = array();
-    $headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
-                        get_string('fullnameuser'),    get_string('action'), get_string('info'));
-
-    // Creating worksheets
-    for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
-        $sheettitle = get_string('logs').' '.$wsnumber.'-'.$nroPages;
-        $worksheet[$wsnumber] = $workbook->add_worksheet($sheettitle);
-        $worksheet[$wsnumber]->set_column(1, 1, 30);
-        $worksheet[$wsnumber]->write_string(0, 0, get_string('savedat').
-                                    userdate(time(), $strftimedatetime));
-        $col = 0;
-        foreach ($headers as $item) {
-            $worksheet[$wsnumber]->write(FIRSTUSEDEXCELROW-1,$col,$item,'');
-            $col++;
-        }
-    }
-
-    if (empty($logs['logs'])) {
-        $workbook->close();
-        return true;
-    }
-
-    $formatDate =& $workbook->add_format();
-    $formatDate->set_num_format(get_string('log_excel_date_format'));
-
-    $row = FIRSTUSEDEXCELROW;
-    $wsnumber = 1;
-    $myxls =& $worksheet[$wsnumber];
-    foreach ($logs['logs'] as $log) {
-        if (isset($ldcache[$log->module][$log->action])) {
-            $ld = $ldcache[$log->module][$log->action];
-        } else {
-            $ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
-            $ldcache[$log->module][$log->action] = $ld;
-        }
-        if ($ld && is_numeric($log->info)) {
-            // ugly hack to make sure fullname is shown correctly
-            if (($ld->mtable == 'user') and ($ld->field == $DB->sql_concat('firstname', "' '" , 'lastname'))) {
-                $log->info = fullname($DB->get_record($ld->mtable, array('id'=>$log->info)), true);
-            } else {
-                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id'=>$log->info));
-            }
-        }
-
-        // Filter log->info
-        $log->info = format_string($log->info);
-        $log->info = strip_tags(urldecode($log->info));  // Some XSS protection
-
-        if ($nroPages>1) {
-            if ($row > EXCELROWS) {
-                $wsnumber++;
-                $myxls =& $worksheet[$wsnumber];
-                $row = FIRSTUSEDEXCELROW;
-            }
-        }
-
-        $coursecontext = context_course::instance($course->id);
-
-        $myxls->write($row, 0, format_string($courses[$log->course], true, array('context' => $coursecontext)), '');
-        $myxls->write_date($row, 1, $log->time, $formatDate); // write_date() does conversion/timezone support. MDL-14934
-        $myxls->write($row, 2, $log->ip, '');
-        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
-        $myxls->write($row, 3, $fullname, '');
-        $actionurl = $CFG->wwwroot. make_log_url($log->module,$log->url);
-        $myxls->write($row, 4, $log->module.' '.$log->action.' ('.$actionurl.')', '');
-        $myxls->write($row, 5, $log->info, '');
-
-        $row++;
-    }
-
-    $workbook->close();
-    return true;
-}
-
-function print_log_ods($course, $user, $date, $order='l.time DESC', $modname,
-                        $modid, $modaction, $groupid) {
-
-    global $CFG, $DB;
-
-    require_once("$CFG->libdir/odslib.class.php");
-
-    if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
-                       $modname, $modid, $modaction, $groupid)) {
-        return false;
-    }
-
-    $courses = array();
-
-    if ($course->id == SITEID) {
-        $courses[0] = '';
-        if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
-            foreach ($ccc as $cc) {
-                $courses[$cc->id] = $cc->shortname;
-            }
-        }
-    } else {
-        $courses[$course->id] = $course->shortname;
-    }
-
-    $count=0;
-    $ldcache = array();
-    $tt = getdate(time());
-    $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
-
-    $strftimedatetime = get_string("strftimedatetime");
-
-    $nroPages = ceil(count($logs)/(EXCELROWS-FIRSTUSEDEXCELROW+1));
-    $filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
-    $filename .= '.ods';
-
-    $workbook = new MoodleODSWorkbook('-');
-    $workbook->send($filename);
-
-    $worksheet = array();
-    $headers = array(get_string('course'), get_string('time'), get_string('ip_address'),
-                        get_string('fullnameuser'),    get_string('action'), get_string('info'));
-
-    // Creating worksheets
-    for ($wsnumber = 1; $wsnumber <= $nroPages; $wsnumber++) {
-        $sheettitle = get_string('logs').' '.$wsnumber.'-'.$nroPages;
-        $worksheet[$wsnumber] = $workbook->add_worksheet($sheettitle);
-        $worksheet[$wsnumber]->set_column(1, 1, 30);
-        $worksheet[$wsnumber]->write_string(0, 0, get_string('savedat').
-                                    userdate(time(), $strftimedatetime));
-        $col = 0;
-        foreach ($headers as $item) {
-            $worksheet[$wsnumber]->write(FIRSTUSEDEXCELROW-1,$col,$item,'');
-            $col++;
-        }
-    }
-
-    if (empty($logs['logs'])) {
-        $workbook->close();
-        return true;
-    }
-
-    $formatDate =& $workbook->add_format();
-    $formatDate->set_num_format(get_string('log_excel_date_format'));
-
-    $row = FIRSTUSEDEXCELROW;
-    $wsnumber = 1;
-    $myxls =& $worksheet[$wsnumber];
-    foreach ($logs['logs'] as $log) {
-        if (isset($ldcache[$log->module][$log->action])) {
-            $ld = $ldcache[$log->module][$log->action];
-        } else {
-            $ld = $DB->get_record('log_display', array('module'=>$log->module, 'action'=>$log->action));
-            $ldcache[$log->module][$log->action] = $ld;
-        }
-        if ($ld && is_numeric($log->info)) {
-            // ugly hack to make sure fullname is shown correctly
-            if (($ld->mtable == 'user') and ($ld->field == $DB->sql_concat('firstname', "' '" , 'lastname'))) {
-                $log->info = fullname($DB->get_record($ld->mtable, array('id'=>$log->info)), true);
-            } else {
-                $log->info = $DB->get_field($ld->mtable, $ld->field, array('id'=>$log->info));
-            }
-        }
-
-        // Filter log->info
-        $log->info = format_string($log->info);
-        $log->info = strip_tags(urldecode($log->info));  // Some XSS protection
-
-        if ($nroPages>1) {
-            if ($row > EXCELROWS) {
-                $wsnumber++;
-                $myxls =& $worksheet[$wsnumber];
-                $row = FIRSTUSEDEXCELROW;
-            }
-        }
-
-        $coursecontext = context_course::instance($course->id);
-
-        $myxls->write_string($row, 0, format_string($courses[$log->course], true, array('context' => $coursecontext)));
-        $myxls->write_date($row, 1, $log->time);
-        $myxls->write_string($row, 2, $log->ip);
-        $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
-        $myxls->write_string($row, 3, $fullname);
-        $actionurl = $CFG->wwwroot. make_log_url($log->module,$log->url);
-        $myxls->write_string($row, 4, $log->module.' '.$log->action.' ('.$actionurl.')');
-        $myxls->write_string($row, 5, $log->info);
-
-        $row++;
-    }
-
-    $workbook->close();
-    return true;
-}
-
 /**
  * Checks the integrity of the course data.
  *
index 78c85b3..26f2863 100644 (file)
@@ -13,7 +13,7 @@ Feature: Course category management interface performs as expected
     And I go to the courses management page
     And I should see "Course and category management" in the "h2" "css_element"
     And I should see "Course categories" in the ".view-mode-selector" "css_element"
-    And I should see "Course categories" in the "h3" "css_element"
+    And I should see "Course categories" in the "#page-content" "css_element"
     And I should see the "Course categories and courses" management page
 
   @javascript
index 2d41a98..4134c39 100644 (file)
@@ -88,7 +88,7 @@ switch ($action) {
         break;
     case 'getassignable':
         $otheruserroles = optional_param('otherusers', false, PARAM_BOOL);
-        $outcome->response = array_reverse($manager->get_assignable_roles($otheruserroles), true);
+        $outcome->response = $manager->get_assignable_roles_for_json($otheruserroles);
         break;
     case 'searchotherusers':
         $search = optional_param('search', '', PARAM_RAW);
index 2d918da..4699b3a 100644 (file)
@@ -621,6 +621,22 @@ class course_enrolment_manager {
         }
     }
 
+    /**
+     * Gets all of the assignable roles for this course, wrapped in an array to ensure
+     * role sort order is not lost during json deserialisation.
+     *
+     * @param boolean $otherusers whether to include the assignable roles for other users
+     * @return array
+     */
+    public function get_assignable_roles_for_json($otherusers = false) {
+        $rolesarray = array();
+        $assignable = $this->get_assignable_roles($otherusers);
+        foreach ($assignable as $id => $role) {
+            $rolesarray[] = array('id' => $id, 'name' => $role);
+        }
+        return $rolesarray;
+    }
+
     /**
      * Gets all of the groups for this course.
      *
index 5aeca32..012cafb 100644 (file)
@@ -198,8 +198,8 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) {
                 var index = 0, count = 0;
                 for (var i in roles) {
                     count++;
-                    var option = create('<option value="'+i+'">'+roles[i]+'</option>');
-                    if (i == v) {
+                    var option = create('<option value="' + roles[i].id + '">' + roles[i].name + '</option>');
+                    if (roles[i].id == v) {
                         index = count;
                     }
                     s.append(option);
index 89390ee..23d8ba9 100644 (file)
@@ -314,10 +314,10 @@ YUI.add('moodle-enrol-otherusersmanager', function(Y) {
                     )
                     .append(Y.Node.create('<div class="'+CSS.OPTIONS+'"><span class="label">'+M.util.get_string('assignrole', 'role')+': </span></div>'))
                 );
-            var id = 0, roles = this._manager.get(ASSIGNABLEROLES);
-            for (id in roles) {
-                var role = Y.Node.create('<a href="#" class="'+CSS.ROLEOPTION+'">'+roles[id]+'</a>');
-                role.on('click', this.assignRoleToUser, this, id, role);
+            var roles = this._manager.get(ASSIGNABLEROLES);
+            for (var i in roles) {
+                var role = Y.Node.create('<a href="#" class="' + CSS.ROLEOPTION + '">' + roles[i].name + '</a>');
+                role.on('click', this.assignRoleToUser, this, roles[i].id, role);
                 this._node.one('.'+CSS.OPTIONS).append(role);
             }
             return this._node;
index 8fd9f65..a75d61a 100644 (file)
@@ -94,7 +94,7 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
                             if (o.error) {
                                 new M.core.ajaxException(o);
                             } else {
-                                this.users[userid].addRoleToDisplay(args.roleid, this.get(ASSIGNABLEROLES)[args.roleid]);
+                                this.users[userid].addRoleToDisplay(args.roleid, this._getAssignableRole(args.roleid));
                             }
                         } catch (e) {
                             new M.core.exception(e);
@@ -152,6 +152,15 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
                 }
             });
         },
+        _getAssignableRole: function(roleid) {
+            var roles = this.get(ASSIGNABLEROLES);
+            for (var i in roles) {
+                if (roles[i].id == roleid) {
+                    return roles[i].name;
+                }
+            }
+            return null;
+        },
         _loadAssignableRoles : function() {
             var c = this.get(COURSEID), params = {
                 id : this.get(COURSEID),
@@ -277,7 +286,7 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
             var current = this.get(CURRENTROLES);
             var allroles = true, i = 0;
             for (i in roles) {
-                if (!current[i]) {
+                if (!current[roles[i].id]) {
                     allroles = false;
                     break;
                 }
@@ -353,8 +362,10 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
             var content = element.one('.content');
             var roles = m.get(ASSIGNABLEROLES);
             for (i in roles) {
-                var button = Y.Node.create('<input type="button" value="'+roles[i]+'" id="add_assignable_role_'+i+'" />');
-                button.on('click', this.submit, this, i);
+                var buttonid = 'add_assignable_role_' + roles[i].id;
+                var buttonhtml = '<input type="button" value="' + roles[i].name + '" id="' + buttonid + '" />';
+                var button = Y.Node.create(buttonhtml);
+                button.on('click', this.submit, this, roles[i].id);
                 content.append(button);
             }
             Y.one(document.body).append(element);
index 48164e2..f9132d0 100644 (file)
@@ -70,6 +70,7 @@ if ($id) {
         $outcome_rec->courseid = $courseid;
         require_login();
         require_capability('moodle/grade:manage', $systemcontext);
+        $PAGE->set_context($systemcontext);
     }
 
 } else if ($courseid){
@@ -87,6 +88,7 @@ if ($id) {
 } else {
     require_login();
     require_capability('moodle/grade:manage', $systemcontext);
+    $PAGE->set_context($systemcontext);
 
     /// adding new outcome from admin section
     $outcome_rec = new stdClass();
diff --git a/grade/report/overview/classes/external.php b/grade/report/overview/classes/external.php
new file mode 100644 (file)
index 0000000..abdb080
--- /dev/null
@@ -0,0 +1,224 @@
+<?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/>.
+
+/**
+ * External