Merge branch 'MDL-41146-master' of git://github.com/sammarshallou/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 3 Sep 2013 23:01:19 +0000 (01:01 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 3 Sep 2013 23:01:19 +0000 (01:01 +0200)
773 files changed:
admin/cli/automated_backups.php
admin/cli/install.php
admin/index.php
admin/plugins.php
admin/purgecaches.php
admin/qbehaviours.php
admin/qtypes.php
admin/renderer.php
admin/repository.php
admin/roles/allow.php
admin/roles/assign.php
admin/roles/classes/define_role_table_advanced.php
admin/roles/define.php
admin/roles/manage.php
admin/roles/override.php
admin/settings/server.php
admin/tool/behat/renderer.php
admin/tool/behat/tests/behat/basic_actions.feature
admin/tool/behat/tests/behat/data_generators.feature
admin/tool/generator/classes/backend.php [new file with mode: 0644]
admin/tool/generator/classes/course_backend.php [new file with mode: 0644]
admin/tool/generator/classes/make_form.php [new file with mode: 0644]
admin/tool/generator/classes/site_backend.php [new file with mode: 0644]
admin/tool/generator/cli/generate.php
admin/tool/generator/cli/maketestcourse.php [new file with mode: 0644]
admin/tool/generator/cli/maketestsite.php [new file with mode: 0644]
admin/tool/generator/index.php
admin/tool/generator/lang/en/tool_generator.php
admin/tool/generator/maketestcourse.php [new file with mode: 0644]
admin/tool/generator/settings.php [new file with mode: 0644]
admin/tool/generator/tests/maketestcourse_test.php [new file with mode: 0644]
admin/tool/generator/version.php
admin/tool/langimport/lang/en/tool_langimport.php
admin/tool/phpunit/webrunner.php
admin/tool/uploadcourse/classes/helper.php
admin/tool/uploadcourse/classes/processor.php
admin/tool/uploadcourse/classes/step2_form.php
admin/tool/uploadcourse/index.php
admin/tool/uploadcourse/lang/en/tool_uploadcourse.php
admin/tool/uploadcourse/tests/course_test.php
admin/tool/uploadcourse/tests/helper_test.php
admin/tool/uploaduser/index.php
admin/tool/xmldb/lang/en/tool_xmldb.php
admin/user.php
admin/webservice/forms.php
auth/cas/cli/sync_users.php
auth/db/auth.php
auth/email/auth.php
auth/ldap/auth.php
auth/ldap/cli/sync_users.php
auth/ldap/ntlmsso_magic.php
auth/mnet/auth.php
backup/backup.php
backup/controller/backup_controller.class.php
backup/controller/restore_controller.class.php
backup/import.php
backup/moodle2/backup_final_task.class.php
backup/moodle2/restore_qtype_plugin.class.php
backup/moodle2/restore_stepslib.php
backup/restore.php
backup/util/factories/backup_factory.class.php
backup/util/factories/tests/factories_test.php
backup/util/includes/backup_includes.php
backup/util/includes/restore_includes.php
backup/util/loggers/database_logger.class.php
backup/util/plan/backup_plan.class.php
backup/util/plan/base_plan.class.php
backup/util/plan/base_task.class.php
backup/util/plan/restore_plan.class.php
backup/util/plan/tests/fixtures/plan_fixtures.php
backup/util/progress/core_backup_display_progress.class.php [new file with mode: 0644]
backup/util/progress/core_backup_null_progress.class.php [new file with mode: 0644]
backup/util/progress/core_backup_progress.class.php [new file with mode: 0644]
backup/util/progress/tests/progress_test.php [new file with mode: 0644]
backup/util/structure/tests/baseoptiogroup_test.php
backup/util/ui/renderer.php
backup/util/ui/restore_ui_components.php
backup/util/ui/tests/behat/backup_courses.feature
backup/util/ui/tests/behat/restore_moodle2_courses.feature
badges/classes/observer.php [new file with mode: 0644]
badges/external.php
badges/lib/awardlib.php
badges/mybackpack.php
badges/renderer.php
badges/tests/badgeslib_test.php
blocks/calendar_upcoming/block_calendar_upcoming.php
blocks/course_list/lang/en/block_course_list.php
blocks/moodleblock.class.php
blocks/navigation/tests/behat/view_my_courses.feature
blocks/tags/block_tags.php
blog/locallib.php
blog/tests/bloglib_test.php
cache/classes/loaders.php
cache/locallib.php
cache/stores/file/lib.php
cache/stores/memcache/lib.php
cache/stores/memcached/lib.php
cache/stores/session/lib.php
cache/stores/session/tests/session_test.php
cache/testperformance.php
cache/tests/administration_helper_test.php
cache/tests/cache_test.php
cache/tests/fixtures/lib.php
calendar/lib.php
calendar/tests/lib_test.php [new file with mode: 0644]
cohort/lib.php
cohort/tests/cohortlib_test.php
completion/completion_completion.php
config-dist.php
course/completion.php
course/delete.php
course/editsection.php
course/externallib.php
course/format/renderer.php
course/format/scorm/format.php [deleted file]
course/format/scorm/lib.php [deleted file]
course/lib.php
course/loginas.php
course/manage.php
course/moodleform_mod.php
course/rest.php
course/tests/behat/course_controls.feature
course/tests/courselib_test.php
course/view.php
course/yui/dragdrop/dragdrop.js
enrol/flatfile/lib.php
enrol/ldap/cli/sync.php
enrol/ldap/lang/en/enrol_ldap.php
enrol/ldap/lib.php
enrol/manual/locallib.php
enrol/meta/classes/observer.php [new file with mode: 0644]
enrol/meta/db/events.php
enrol/meta/locallib.php
enrol/meta/tests/plugin_test.php
enrol/tests/enrollib_test.php
enrol/yui/rolemanager/assets/skins/sam/rolemanager.css
enrol/yui/rolemanager/rolemanager.js
files/externallib.php
files/renderer.php
files/tests/externallib_test.php
grade/edit/tree/action.php
grade/edit/tree/lib.php
grade/export/lib.php
grade/externallib.php
grade/grading/form/guide/lib.php
grade/grading/form/lib.php
grade/grading/form/rubric/lib.php
grade/lib.php
grade/report/grader/lib.php
grade/tests/externallib_test.php
group/index.php
group/lib.php
group/tests/lib_test.php [new file with mode: 0644]
install.php
install/lang/hi/admin.php [new file with mode: 0644]
lang/en/admin.php
lang/en/auth.php
lang/en/backup.php
lang/en/badges.php
lang/en/blog.php
lang/en/cache.php
lang/en/cohort.php
lang/en/completion.php
lang/en/enrol.php
lang/en/error.php
lang/en/form.php
lang/en/group.php
lang/en/install.php
lang/en/mathslib.php
lang/en/moodle.php
lang/en/repository.php
lang/en/role.php
lang/en/tag.php
lang/en/webservice.php
lib/accesslib.php
lib/adminlib.php
lib/ajax/ajaxlib.php
lib/ajax/tests/ajaxlib_test.php [deleted file]
lib/badgeslib.php
lib/behat/behat_base.php
lib/behat/behat_files.php
lib/behat/classes/behat_command.php
lib/behat/classes/behat_selectors.php [new file with mode: 0644]
lib/behat/classes/util.php
lib/blocklib.php
lib/classes/component.php
lib/classes/event/assessable_submitted.php [new file with mode: 0644]
lib/classes/event/assessable_uploaded.php [new file with mode: 0644]
lib/classes/event/base.php
lib/classes/event/blog_entry_created.php
lib/classes/event/blog_entry_deleted.php [new file with mode: 0644]
lib/classes/event/cohort_created.php [new file with mode: 0644]
lib/classes/event/cohort_deleted.php [new file with mode: 0644]
lib/classes/event/cohort_member_added.php [new file with mode: 0644]
lib/classes/event/cohort_member_removed.php [new file with mode: 0644]
lib/classes/event/cohort_updated.php [new file with mode: 0644]
lib/classes/event/content_viewed.php [new file with mode: 0644]
lib/classes/event/course_category_deleted.php [new file with mode: 0644]
lib/classes/event/course_completed.php [new file with mode: 0644]
lib/classes/event/course_completion_updated.php [new file with mode: 0644]
lib/classes/event/course_content_deleted.php [new file with mode: 0644]
lib/classes/event/course_created.php [new file with mode: 0644]
lib/classes/event/course_deleted.php [new file with mode: 0644]
lib/classes/event/course_module_completion_updated.php [new file with mode: 0644]
lib/classes/event/course_restored.php [new file with mode: 0644]
lib/classes/event/course_section_updated.php [new file with mode: 0644]
lib/classes/event/course_updated.php [new file with mode: 0644]
lib/classes/event/group_created.php [new file with mode: 0644]
lib/classes/event/group_deleted.php [new file with mode: 0644]
lib/classes/event/group_member_added.php [new file with mode: 0644]
lib/classes/event/group_member_removed.php [new file with mode: 0644]
lib/classes/event/group_updated.php [new file with mode: 0644]
lib/classes/event/grouping_created.php [new file with mode: 0644]
lib/classes/event/grouping_deleted.php [new file with mode: 0644]
lib/classes/event/grouping_updated.php [new file with mode: 0644]
lib/classes/event/role_allow_assign_updated.php [new file with mode: 0644]
lib/classes/event/role_allow_override_updated.php [new file with mode: 0644]
lib/classes/event/role_allow_switch_updated.php [new file with mode: 0644]
lib/classes/event/role_assigned.php
lib/classes/event/role_capabilities_updated.php [new file with mode: 0644]
lib/classes/event/role_deleted.php [new file with mode: 0644]
lib/classes/event/role_unassigned.php
lib/classes/event/user_created.php [new file with mode: 0644]
lib/classes/event/user_deleted.php [new file with mode: 0644]
lib/classes/event/user_enrolment_created.php [new file with mode: 0644]
lib/classes/event/user_enrolment_deleted.php [new file with mode: 0644]
lib/classes/event/user_enrolment_updated.php [new file with mode: 0644]
lib/classes/event/user_loggedin.php
lib/classes/event/user_loggedinas.php [new file with mode: 0644]
lib/classes/event/user_loggedout.php [new file with mode: 0644]
lib/classes/event/user_updated.php [new file with mode: 0644]
lib/classes/string_manager.php [new file with mode: 0644]
lib/classes/string_manager_install.php [new file with mode: 0644]
lib/classes/string_manager_standard.php [new file with mode: 0644]
lib/classes/text.php
lib/classes/useragent.php [new file with mode: 0644]
lib/completionlib.php
lib/configonlylib.php
lib/coursecatlib.php
lib/cronlib.php
lib/csslib.php
lib/db/caches.php
lib/db/events.php
lib/db/install.xml
lib/db/services.php
lib/db/upgrade.php
lib/ddl/tests/ddl_test.php
lib/ddl/tests/fixtures/invalid.xml
lib/ddl/tests/fixtures/xmldb_table.xml
lib/deprecatedlib.php
lib/dml/mssql_native_moodle_database.php
lib/dml/pdo_moodle_database.php
lib/dml/sqlsrv_native_moodle_database.php
lib/dml/tests/dml_test.php
lib/editor/atto/db/install.php [new file with mode: 0644]
lib/editor/atto/db/subplugins.php [moved from course/format/scorm/lang/en/format_scorm.php with 68% similarity]
lib/editor/atto/lang/en/editor_atto.php [new file with mode: 0644]
lib/editor/atto/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/bold/lang/en/atto_bold.php [new file with mode: 0644]
lib/editor/atto/plugins/bold/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/bold/pix/bold.png [new file with mode: 0644]
lib/editor/atto/plugins/bold/pix/bold.svg [new file with mode: 0644]
lib/editor/atto/plugins/bold/version.php [moved from course/format/scorm/version.php with 73% similarity]
lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/bold/yui/build/moodle-atto_bold-button/moodle-atto_bold-button.js [new file with mode: 0644]
lib/editor/atto/plugins/bold/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/bold/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/bold/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/clear/lang/en/atto_clear.php [new file with mode: 0644]
lib/editor/atto/plugins/clear/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/clear/pix/clear.png [new file with mode: 0644]
lib/editor/atto/plugins/clear/pix/clear.svg [new file with mode: 0644]
lib/editor/atto/plugins/clear/version.php [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/build/moodle-atto_clear-button/moodle-atto_clear-button.js [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/clear/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/html/lang/en/atto_html.php [new file with mode: 0644]
lib/editor/atto/plugins/html/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/html/pix/html.png [new file with mode: 0644]
lib/editor/atto/plugins/html/pix/html.svg [new file with mode: 0644]
lib/editor/atto/plugins/html/version.php [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/build/moodle-atto_html-button/moodle-atto_html-button.js [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/html/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/image/lang/en/atto_image.php [new file with mode: 0644]
lib/editor/atto/plugins/image/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/image/pix/image.png [new file with mode: 0644]
lib/editor/atto/plugins/image/pix/image.svg [new file with mode: 0644]
lib/editor/atto/plugins/image/version.php [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/image/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/indent/lang/en/atto_indent.php [new file with mode: 0644]
lib/editor/atto/plugins/indent/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/indent/pix/indent.png [new file with mode: 0644]
lib/editor/atto/plugins/indent/pix/indent.svg [new file with mode: 0644]
lib/editor/atto/plugins/indent/version.php [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/build/moodle-atto_indent-button/moodle-atto_indent-button.js [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/indent/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/italic/lang/en/atto_italic.php [new file with mode: 0644]
lib/editor/atto/plugins/italic/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/italic/pix/italic.png [new file with mode: 0644]
lib/editor/atto/plugins/italic/pix/italic.svg [new file with mode: 0644]
lib/editor/atto/plugins/italic/version.php [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/build/moodle-atto_italic-button/moodle-atto_italic-button.js [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/italic/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/link/lang/en/atto_link.php [new file with mode: 0644]
lib/editor/atto/plugins/link/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/link/pix/link.png [new file with mode: 0644]
lib/editor/atto/plugins/link/pix/link.svg [new file with mode: 0644]
lib/editor/atto/plugins/link/version.php [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/link/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/media/lang/en/atto_media.php [new file with mode: 0644]
lib/editor/atto/plugins/media/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/media/pix/media.png [new file with mode: 0644]
lib/editor/atto/plugins/media/pix/media.svg [new file with mode: 0644]
lib/editor/atto/plugins/media/version.php [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/build/moodle-atto_media-button/moodle-atto_media-button.js [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/media/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/lang/en/atto_orderedlist.php [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/pix/orderedlist.png [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/pix/orderedlist.svg [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/version.php [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/build/moodle-atto_orderedlist-button/moodle-atto_orderedlist-button.js [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/orderedlist/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/outdent/lang/en/atto_outdent.php [new file with mode: 0644]
lib/editor/atto/plugins/outdent/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/outdent/pix/outdent.png [new file with mode: 0644]
lib/editor/atto/plugins/outdent/pix/outdent.svg [new file with mode: 0644]
lib/editor/atto/plugins/outdent/version.php [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/build/moodle-atto_outdent-button/moodle-atto_outdent-button.js [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/outdent/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/strike/lang/en/atto_strike.php [new file with mode: 0644]
lib/editor/atto/plugins/strike/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/strike/pix/strike.png [new file with mode: 0644]
lib/editor/atto/plugins/strike/pix/strike.svg [new file with mode: 0644]
lib/editor/atto/plugins/strike/version.php [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/build/moodle-atto_strike-button/moodle-atto_strike-button.js [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/strike/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/title/lang/en/atto_title.php [new file with mode: 0644]
lib/editor/atto/plugins/title/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/title/pix/title.png [new file with mode: 0644]
lib/editor/atto/plugins/title/pix/title.svg [new file with mode: 0644]
lib/editor/atto/plugins/title/version.php [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/underline/lang/en/atto_underline.php [new file with mode: 0644]
lib/editor/atto/plugins/underline/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/underline/pix/underline.png [new file with mode: 0644]
lib/editor/atto/plugins/underline/pix/underline.svg [new file with mode: 0644]
lib/editor/atto/plugins/underline/version.php [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/build/moodle-atto_underline-button/moodle-atto_underline-button.js [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/underline/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php [new file with mode: 0644]
lib/editor/atto/plugins/unlink/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/unlink/pix/unlink.png [new file with mode: 0644]
lib/editor/atto/plugins/unlink/pix/unlink.svg [new file with mode: 0644]
lib/editor/atto/plugins/unlink/version.php [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/build/moodle-atto_unlink-button/moodle-atto_unlink-button.js [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/unlink/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/lang/en/atto_unorderedlist.php [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/lib.php [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.png [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/pix/unorderedlist.svg [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/version.php [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-debug.js [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button-min.js [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/build/moodle-atto_unorderedlist-button/moodle-atto_unorderedlist-button.js [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/src/button/build.json [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/src/button/js/button.js [new file with mode: 0644]
lib/editor/atto/plugins/unorderedlist/yui/src/button/meta/editor.json [new file with mode: 0644]
lib/editor/atto/styles.css [new file with mode: 0644]
lib/editor/atto/version.php [new file with mode: 0644]
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js [new file with mode: 0644]
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js [new file with mode: 0644]
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js [new file with mode: 0644]
lib/editor/atto/yui/src/editor/build.json [new file with mode: 0644]
lib/editor/atto/yui/src/editor/js/editor.js [new file with mode: 0644]
lib/editor/atto/yui/src/editor/meta/editor.json [new file with mode: 0644]
lib/editor/tinymce/classes/plugin.php
lib/editor/tinymce/cli/update_lang_files.php
lib/editor/tinymce/lib.php
lib/editor/tinymce/module.js
lib/editor/tinymce/plugins/managefiles/tinymce/editor_plugin.js
lib/editor/tinymce/plugins/pdw/readme_moodle.txt
lib/editor/tinymce/plugins/pdw/tinymce/editor_plugin.js
lib/editor/tinymce/plugins/spellchecker/lib.php
lib/editor/tinymce/styles.css
lib/editor/tinymce/version.php
lib/editor/tinymce/yui/build/moodle-editor_tinymce-collapse/moodle-editor_tinymce-collapse-debug.js [deleted file]
lib/editor/tinymce/yui/build/moodle-editor_tinymce-collapse/moodle-editor_tinymce-collapse-min.js [deleted file]
lib/editor/tinymce/yui/build/moodle-editor_tinymce-collapse/moodle-editor_tinymce-collapse.js [deleted file]
lib/editor/tinymce/yui/src/collapse/build.json [deleted file]
lib/editor/tinymce/yui/src/collapse/js/collapse.js [deleted file]
lib/editor/tinymce/yui/src/collapse/meta/collapse.json [deleted file]
lib/editorlib.php
lib/enrollib.php
lib/excellib.class.php
lib/external/tests/external_test.php
lib/filelib.php
lib/filestorage/file_storage.php
lib/filestorage/tests/file_storage_test.php
lib/filestorage/tests/zip_packer_test.php
lib/form/editor.php
lib/form/filemanager.js
lib/form/tests/dateselector_test.php
lib/form/tests/datetimeselector_test.php
lib/form/tests/duration_test.php
lib/formslib.php
lib/grade/grade_category.php
lib/grade/grade_item.php
lib/grade/grade_object.php
lib/grade/tests/fixtures/lib.php
lib/grade/tests/grade_category_test.php
lib/grade/tests/grade_grade_test.php
lib/grade/tests/grade_item_test.php
lib/grade/tests/grade_scale_test.php
lib/installlib.php
lib/ldaplib.php
lib/medialib.php
lib/minify/config.php
lib/modinfolib.php
lib/moodlelib.php
lib/navigationlib.php
lib/outputcomponents.php
lib/outputlib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/pagelib.php
lib/phpmailer/moodle_phpmailer.php
lib/phpunit/bootstrap.php
lib/phpunit/classes/advanced_testcase.php
lib/phpunit/classes/phpmailer_sink.php [new file with mode: 0644]
lib/phpunit/classes/util.php
lib/phpunit/lib.php
lib/phpunit/tests/advanced_test.php
lib/phpunit/tests/basic_test.php
lib/pluginlib.php
lib/portfoliolib.php
lib/sessionlib.php
lib/setup.php
lib/setuplib.php
lib/simplepie/moodle_simplepie.php
lib/testing/classes/util.php
lib/testing/tests/generator_test.php
lib/tests/accesslib_test.php
lib/tests/behat/behat_data_generators.php
lib/tests/behat/behat_hooks.php
lib/tests/completionlib_test.php
lib/tests/component_test.php
lib/tests/configonlylib_test.php
lib/tests/csslib_test.php
lib/tests/environment_test.php
lib/tests/event_content_viewed_test.php [new file with mode: 0644]
lib/tests/event_test.php
lib/tests/fixtures/event_fixtures.php
lib/tests/medialib_test.php
lib/tests/modinfolib_test.php
lib/tests/moodlelib_test.php
lib/tests/navigationlib_test.php
lib/tests/sessionlib_test.php [new file with mode: 0644]
lib/tests/statslib_test.php
lib/tests/string_manager_standard_test.php [moved from lib/tests/string_manager_test.php with 95% similarity]
lib/tests/text_test.php
lib/tests/theme_config_test.php
lib/tests/useragent_test.php [new file with mode: 0644]
lib/tests/weblib_test.php
lib/upgrade.txt
lib/upgradelib.php
lib/weblib.php
lib/xhprof/xhprof_moodle.php
lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js
lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js
lib/yui/build/moodle-core-blocks/moodle-core-blocks.js
lib/yui/build/moodle-core-chooserdialogue/moodle-core-chooserdialogue-debug.js
lib/yui/build/moodle-core-chooserdialogue/moodle-core-chooserdialogue-min.js
lib/yui/build/moodle-core-chooserdialogue/moodle-core-chooserdialogue.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-debug.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue-min.js
lib/yui/build/moodle-core-notification-dialogue/moodle-core-notification-dialogue.js
lib/yui/build/moodle-core-notification/moodle-core-notification-debug.js
lib/yui/dragdrop/dragdrop.js
lib/yui/src/blocks/js/blockregion.js
lib/yui/src/blocks/js/blocks.js
lib/yui/src/blocks/js/manager.js
lib/yui/src/chooserdialogue/js/chooserdialogue.js
lib/yui/src/notification/js/dialogue.js
lib/yui/src/notification/js/notification.js
login/change_password.php
mod/assign/adminlib.php
mod/assign/backup/moodle2/restore_assign_stepslib.php
mod/assign/classes/event/all_submissions_downloaded.php [new file with mode: 0644]
mod/assign/classes/event/assessable_submitted.php [new file with mode: 0644]
mod/assign/classes/event/extension_granted.php [new file with mode: 0644]
mod/assign/classes/event/identities_revealed.php [new file with mode: 0644]
mod/assign/classes/event/marker_updated.php [new file with mode: 0644]
mod/assign/classes/event/statement_accepted.php [new file with mode: 0644]
mod/assign/classes/event/submission_duplicated.php [new file with mode: 0644]
mod/assign/classes/event/submission_graded.php [new file with mode: 0644]
mod/assign/classes/event/submission_locked.php [new file with mode: 0644]
mod/assign/classes/event/submission_status_updated.php [new file with mode: 0644]
mod/assign/classes/event/submission_unlocked.php [new file with mode: 0644]
mod/assign/classes/event/submission_updated.php [new file with mode: 0644]
mod/assign/classes/event/workflow_state_updated.php [new file with mode: 0644]
mod/assign/lang/en/assign.php
mod/assign/locallib.php
mod/assign/submission/file/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/assign/submission/file/lang/en/assignsubmission_file.php
mod/assign/submission/file/locallib.php
mod/assign/submission/file/tests/events_test.php [new file with mode: 0644]
mod/assign/submission/onlinetext/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/assign/submission/onlinetext/lang/en/assignsubmission_onlinetext.php
mod/assign/submission/onlinetext/locallib.php
mod/assign/submission/onlinetext/tests/events_test.php [new file with mode: 0644]
mod/assign/tests/base_test.php
mod/assign/tests/generator/lib.php
mod/assign/tests/lib_test.php
mod/assign/tests/locallib_test.php
mod/assignment/backup/moodle1/lib.php
mod/assignment/backup/moodle2/restore_assignment_stepslib.php
mod/assignment/lang/en/assignment.php
mod/assignment/lib.php
mod/assignment/mod_form.php
mod/assignment/type/online/assignment.class.php
mod/assignment/type/online/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/assignment/type/online/lang/en/assignment_online.php
mod/assignment/type/upload/assignment.class.php
mod/assignment/type/upload/classes/event/assessable_submitted.php [new file with mode: 0644]
mod/assignment/type/upload/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/assignment/type/upload/lang/en/assignment_upload.php
mod/assignment/view.php
mod/chat/gui_ajax/index.php
mod/chat/gui_ajax/module.js
mod/chat/gui_ajax/theme/bubble/chat.css
mod/chat/gui_ajax/theme/bubble/config.php
mod/chat/gui_basic/index.php
mod/chat/lib.php
mod/chat/styles.css
mod/choice/lib.php
mod/choice/renderer.php
mod/choice/report.php
mod/choice/view.php
mod/data/field/file/field.class.php
mod/data/field/picture/field.class.php
mod/data/lang/en/data.php
mod/data/lib.php
mod/data/module.js [new file with mode: 0644]
mod/data/templates.php
mod/data/tests/lib_test.php [new file with mode: 0644]
mod/data/view.php
mod/feedback/lang/en/feedback.php
mod/forum/backup/moodle2/backup_forum_stepslib.php
mod/forum/backup/moodle2/restore_forum_stepslib.php
mod/forum/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/forum/classes/observer.php [new file with mode: 0644]
mod/forum/classes/post_form.php [new file with mode: 0644]
mod/forum/db/events.php
mod/forum/db/install.xml
mod/forum/db/upgrade.php
mod/forum/index.php
mod/forum/lang/en/forum.php
mod/forum/lib.php
mod/forum/maildigest.php [new file with mode: 0644]
mod/forum/post.php
mod/forum/post_form.php
mod/forum/tests/lib_test.php [new file with mode: 0644]
mod/forum/tests/maildigest_test.php [new file with mode: 0644]
mod/forum/upgrade.txt
mod/forum/version.php
mod/lesson/essay.php
mod/lesson/format.php
mod/lesson/import.php
mod/lesson/lang/en/lesson.php
mod/lti/lang/en/lti.php
mod/lti/locallib.php
mod/quiz/editlib.php
mod/quiz/lib.php
mod/quiz/mod_form.php
mod/quiz/renderer.php
mod/quiz/report/statistics/report.php
mod/quiz/report/statistics/tests/fixtures/qstats00.csv [new file with mode: 0644]
mod/quiz/report/statistics/tests/fixtures/questions00.csv [new file with mode: 0644]
mod/quiz/report/statistics/tests/fixtures/results00.csv [new file with mode: 0644]
mod/quiz/report/statistics/tests/fixtures/steps00.csv [new file with mode: 0644]
mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php [new file with mode: 0644]
mod/quiz/settings.php
mod/quiz/styles.css
mod/quiz/tests/attempt_walkthrough_from_csv_test.php
mod/quiz/upgrade.txt
mod/resource/tests/generator/lib.php [new file with mode: 0644]
mod/resource/tests/generator_test.php [new file with mode: 0644]
mod/scorm/datamodels/aicc.js.php
mod/scorm/datamodels/aicclib.php
mod/scorm/datamodels/scorm_12.js.php
mod/scorm/datamodels/scorm_13.js.php
mod/scorm/db/upgrade.php
mod/scorm/lang/en/scorm.php
mod/scorm/lib.php
mod/scorm/locallib.php
mod/scorm/mod_form.php
mod/scorm/tests/packages/badscorm.zip [new file with mode: 0644]
mod/scorm/tests/packages/invalid.zip [new file with mode: 0644]
mod/scorm/tests/packages/validaicc.zip [new file with mode: 0644]
mod/scorm/tests/packages/validscorm.zip [new file with mode: 0644]
mod/scorm/tests/validatepackage_test.php [new file with mode: 0644]
mod/scorm/version.php
mod/wiki/pagelib.php
mod/workshop/classes/event/assessable_uploaded.php [new file with mode: 0644]
mod/workshop/lang/en/workshop.php
mod/workshop/locallib.php
mod/workshop/renderer.php
mod/workshop/submission.php
phpunit.xml.dist
portfolio/googledocs/db/upgrade.php
portfolio/googledocs/db/upgradelib.php [new file with mode: 0644]
portfolio/picasa/db/upgrade.php
portfolio/picasa/db/upgradelib.php [new file with mode: 0644]
question/behaviour/informationitem/lang/en/qbehaviour_informationitem.php
question/behaviour/manualgraded/tests/walkthrough_test.php
question/category.php
question/category_class.php
question/category_form.php
question/engine/datalib.php
question/engine/lib.php
question/engine/questionattempt.php
question/engine/questionattemptstep.php
question/engine/tests/questionattempt_test.php
question/format.php
question/format/webct/TODO.txt [deleted file]
question/format/webct/format.php
question/format/webct/lang/en/qformat_webct.php
question/format/webct/tests/fixtures/sample_webct.txt [new file with mode: 0644]
question/format/webct/tests/webctformat_test.php [new file with mode: 0644]
question/format/webct/version.php
question/format/xhtml/format.php
question/format/xhtml/lib.php [new file with mode: 0644]
question/type/edit_question_form.php
question/type/essay/question.php
question/type/essay/tests/helper.php
question/type/essay/tests/question_test.php
question/type/essay/tests/walkthrough_test.php
question/type/match/db/upgrade.php
question/type/multianswer/module.js
question/type/multianswer/styles.css
question/type/multichoice/questiontype.php
question/type/numerical/edit_numerical_form.php
question/type/numerical/styles.css
question/type/questionbase.php
question/type/upgrade.txt
report/log/classes/event/content_viewed.php [new file with mode: 0644]
report/log/graph.php
report/log/index.php
report/log/user.php
report/loglive/classes/event/content_viewed.php [new file with mode: 0644]
report/loglive/index.php
report/outline/classes/event/content_viewed.php [new file with mode: 0644]
report/outline/index.php
report/outline/user.php
report/participation/classes/event/content_viewed.php [new file with mode: 0644]
report/participation/index.php
report/performance/locallib.php
report/security/lang/en/report_security.php
report/stats/classes/event/content_viewed.php [new file with mode: 0644]
report/stats/graph.php
report/stats/index.php
report/stats/user.php
repository/coursefiles/lib.php
repository/filepicker.js
repository/filesystem/lib.php
repository/googledocs/db/upgrade.php
repository/googledocs/db/upgradelib.php [new file with mode: 0644]
repository/lib.php
repository/picasa/db/upgrade.php
repository/picasa/db/upgradelib.php [new file with mode: 0644]
repository/repository_ajax.php
repository/skydrive/lib.php
repository/tests/behat/behat_filepicker.php
repository/tests/behat/cancel_add_file.feature
repository/upgrade.txt
repository/url/locallib.php
tag/coursetags_more.php
tag/coursetagslib.php
tag/locallib.php
tag/manage.php
tag/upgrade.txt
theme/base/style/admin.css
theme/base/style/core.css
theme/base/style/course.css
theme/base/style/filemanager.css
theme/base/version.php
theme/bootstrapbase/config.php
theme/bootstrapbase/less/moodle/backup-restore.less
theme/bootstrapbase/less/moodle/bootstrapoverride.less
theme/bootstrapbase/less/moodle/core.less
theme/bootstrapbase/less/moodle/filemanager.less
theme/bootstrapbase/less/moodle/forms.less
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/version.php
theme/index.php
theme/mymobile/config.php
theme/switchdevice.php
theme/upgrade.txt
user/edit.php
user/editadvanced.php
user/editlib.php
user/emailupdate.php
user/externallib.php
user/filters/lib.php
user/lib.php
user/messageselect.php
user/profile/field/menu/lang/en/profilefield_menu.php
user/tests/externallib_test.php
user/tests/userlib_test.php [new file with mode: 0644]
version.php
webservice/externallib.php
webservice/tests/externallib_test.php
webservice/upgrade.txt [new file with mode: 0644]
webservice/upload.php

index dc80c7a..3c3841e 100644 (file)
@@ -75,8 +75,7 @@ if (!empty($CFG->showcronsql)) {
     $DB->set_debug(true);
 }
 if (!empty($CFG->showcrondebugging)) {
-    $CFG->debug = DEBUG_DEVELOPER;
-    $CFG->debugdisplay = true;
+    set_debugging(DEBUG_DEVELOPER, true);
 }
 
 $starttime = microtime();
index 2d992b5..fcd25b2 100644 (file)
@@ -162,6 +162,9 @@ $CFG->running_installer    = true;
 $CFG->early_install_lang   = true;
 $CFG->ostype               = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
 $CFG->dboptions            = array();
+$CFG->debug                = (E_ALL | E_STRICT);
+$CFG->debugdisplay         = true;
+$CFG->debugdeveloper       = true;
 
 $parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
 $CFG->admin                = array_pop($parts);
@@ -172,6 +175,9 @@ ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include
 
 require_once($CFG->libdir.'/classes/component.php');
 require_once($CFG->libdir.'/classes/text.php');
+require_once($CFG->libdir.'/classes/string_manager.php');
+require_once($CFG->libdir.'/classes/string_manager_install.php');
+require_once($CFG->libdir.'/classes/string_manager_standard.php');
 require_once($CFG->libdir.'/installlib.php');
 require_once($CFG->libdir.'/clilib.php');
 require_once($CFG->libdir.'/setuplib.php');
index 1e9e810..466832c 100644 (file)
@@ -59,6 +59,10 @@ if (empty($_GET['cache']) and empty($_POST['cache']) and empty($_GET['sesskey'])
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
+    $cache = 0;
+
+} else {
+    $cache = 1;
 }
 
 require('../config.php');
@@ -74,22 +78,28 @@ $showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
 $agreelicense   = optional_param('agreelicense', 0, PARAM_BOOL);
 $fetchupdates   = optional_param('fetchupdates', 0, PARAM_BOOL);
 $newaddonreq    = optional_param('installaddonrequest', null, PARAM_RAW);
-$cache          = optional_param('cache', 0, PARAM_BOOL);
 
 // Set up PAGE.
 $url = new moodle_url('/admin/index.php');
-if (!is_null($newaddonreq)) {
-    // We need to set the eventual add-on installation request in the $PAGE's URL
-    // so that it is stored in $SESSION->wantsurl and the admin is redirected
-    // correctly once they are logged-in.
-    $url->param('installaddonrequest', $newaddonreq);
-}
 if ($cache) {
-    $url->param('cache', $cache);
+    $url->param('cache', 1);
 }
 $PAGE->set_url($url);
 unset($url);
 
+// Are we returning from an add-on installation request at moodle.org/plugins?
+if ($newaddonreq and !$cache and empty($CFG->disableonclickaddoninstall)) {
+    $target = new moodle_url('/admin/tool/installaddon/index.php', array(
+        'installaddonrequest' => $newaddonreq,
+        'confirm' => 0));
+    if (!isloggedin() or isguestuser()) {
+        // Login and go the the add-on tool page.
+        $SESSION->wantsurl = $target->out();
+        redirect(get_login_url());
+    }
+    redirect($target);
+}
+
 $PAGE->set_pagelayout('admin'); // Set a default pagelayout
 
 $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
@@ -153,6 +163,7 @@ if (!core_tables_exist()) {
         $PAGE->set_heading($strinstallation);
         $PAGE->set_cacheable(false);
 
+        /** @var core_admin_renderer $output */
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->install_licence_page();
         die();
@@ -167,6 +178,7 @@ if (!core_tables_exist()) {
         $PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
         $PAGE->set_cacheable(false);
 
+        /** @var core_admin_renderer $output */
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
         die();
@@ -221,14 +233,12 @@ if (empty($CFG->version)) {
 }
 
 // Detect config cache inconsistency, this happens when you switch branches on dev servers.
-if ($cache) {
-    if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))) {
-        purge_all_caches();
-        redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
-    }
+if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))) {
+    purge_all_caches();
+    redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
 }
 
-if ($version > $CFG->version) {  // upgrade
+if (!$cache and $version > $CFG->version) {  // upgrade
     // We purge all of MUC's caches here.
     // Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
     // This ensures a real config object is loaded and the stores will be purged.
@@ -245,6 +255,7 @@ if ($version > $CFG->version) {  // upgrade
         $PAGE->set_title($stradministration);
         $PAGE->set_cacheable(false);
 
+        /** @var core_admin_renderer $output */
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->upgrade_stale_php_files_page();
         die();
@@ -260,6 +271,7 @@ if ($version > $CFG->version) {  // upgrade
         $PAGE->set_heading($strdatabasechecking);
         $PAGE->set_cacheable(false);
 
+        /** @var core_admin_renderer $output */
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->upgrade_confirm_page($a->newversion, $maturity);
         die();
@@ -274,6 +286,7 @@ if ($version > $CFG->version) {  // upgrade
         $PAGE->set_heading($strcurrentrelease);
         $PAGE->set_cacheable(false);
 
+        /** @var core_admin_renderer $output */
         $output = $PAGE->get_renderer('core', 'admin');
         echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
         die();
@@ -288,10 +301,12 @@ if ($version > $CFG->version) {  // upgrade
 
         $reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
 
+        /** @var core_admin_renderer $output */
+        $output = $PAGE->get_renderer('core', 'admin');
+
         // check plugin dependencies first
         $failed = array();
         if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
-            $output = $PAGE->get_renderer('core', 'admin');
             echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
             die();
         }
@@ -305,8 +320,6 @@ if ($version > $CFG->version) {  // upgrade
             redirect($reloadurl);
         }
 
-        $output = $PAGE->get_renderer('core', 'admin');
-
         $deployer = available_update_deployer::instance();
         if ($deployer->enabled()) {
             $deployer->initialize($reloadurl, $reloadurl);
@@ -333,15 +346,15 @@ if ($version > $CFG->version) {  // upgrade
 }
 
 // Updated human-readable release version if necessary
-if ($release <> $CFG->release) {  // Update the release version
+if (!$cache and $release <> $CFG->release) {  // Update the release version
     set_config('release', $release);
 }
 
-if ($branch <> $CFG->branch) {  // Update the branch
+if (!$cache and $branch <> $CFG->branch) {  // Update the branch
     set_config('branch', $branch);
 }
 
-if (moodle_needs_upgrading()) {
+if (!$cache and moodle_needs_upgrading()) {
     if (!$PAGE->headerprinted) {
         // means core upgrade or installation was not already done
         if (!$confirmplugins) {
@@ -450,8 +463,8 @@ if (during_initial_install()) {
 
 // Now we can be sure everything was upgraded and caches work fine,
 // redirect if necessary to make sure caching is enabled.
-if (!$cache and !optional_param('sesskey', '', PARAM_RAW)) {
-    redirect(new moodle_url($PAGE->url, array('cache' => 1)));
+if (!$cache) {
+    redirect(new moodle_url('/admin/index.php', array('cache' => 1)));
 }
 
 // Check for valid admin user - no guest autologin
@@ -473,17 +486,6 @@ if (!empty($id) and $id == $CFG->siteidentifier) {
     set_config('registered', time());
 }
 
-// Check if we are returning from an add-on installation request at moodle.org/plugins
-if (!is_null($newaddonreq)) {
-    if (!empty($CFG->disableonclickaddoninstall)) {
-        // The feature is disabled in config.php, ignore the request.
-    } else {
-        redirect(new moodle_url('/admin/tool/installaddon/index.php', array(
-            'installaddonrequest' => $newaddonreq,
-            'confirm' => 0)));
-    }
-}
-
 // setup critical warnings before printing admin tree block
 $insecuredataroot = is_dataroot_insecure(true);
 $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
index 8ceba12..a092e00 100644 (file)
@@ -38,9 +38,6 @@ require_once($CFG->libdir . '/adminlib.php');
 require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/filelib.php');
 
-admin_externalpage_setup('pluginsoverview');
-require_capability('moodle/site:config', context_system::instance());
-
 $fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
 $updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
 $contribonly = optional_param('contribonly', false, PARAM_BOOL);
@@ -48,12 +45,30 @@ $uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
 $delete = optional_param('delete', '', PARAM_COMPONENT);
 $confirmed = optional_param('confirm', false, PARAM_BOOL);
 
-$output = $PAGE->get_renderer('core', 'admin');
+// NOTE: do not use admin_externalpage_setup() here because it loads
+//       full admin tree which is not possible during uninstallation.
+
+require_login();
+$syscontext = context_system::instance();
+require_capability('moodle/site:config', $syscontext);
 
 $pluginman = plugin_manager::instance();
 
 if ($uninstall) {
     require_sesskey();
+
+    if (!$confirmed) {
+        admin_externalpage_setup('pluginsoverview');
+    } else {
+        $PAGE->set_url('/admin/plugins.php');
+        $PAGE->set_context($syscontext);
+        $PAGE->set_pagelayout('maintenance');
+        $PAGE->set_popup_notification_allowed(false);
+    }
+
+    /** @var core_admin_renderer $output */
+    $output = $PAGE->get_renderer('core', 'admin');
+
     $pluginfo = $pluginman->get_plugin_info($uninstall);
 
     // Make sure we know the plugin.
@@ -104,6 +119,15 @@ if ($uninstall) {
 
 if ($delete and $confirmed) {
     require_sesskey();
+
+    $PAGE->set_url('/admin/plugins.php');
+    $PAGE->set_context($syscontext);
+    $PAGE->set_pagelayout('maintenance');
+    $PAGE->set_popup_notification_allowed(false);
+
+    /** @var core_admin_renderer $output */
+    $output = $PAGE->get_renderer('core', 'admin');
+
     $pluginfo = $pluginman->get_plugin_info($delete);
 
     // Make sure we know the plugin.
@@ -143,9 +167,15 @@ if ($delete and $confirmed) {
     if (function_exists('opcache_reset')) {
         opcache_reset();
     }
-    redirect($PAGE->url);
+    // We need to execute upgrade to make sure everything including caches is up to date.
+    redirect(new moodle_url('/admin/index.php'));
 }
 
+admin_externalpage_setup('pluginsoverview');
+
+/** @var core_admin_renderer $output */
+$output = $PAGE->get_renderer('core', 'admin');
+
 $checker = available_update_checker::instance();
 
 // Filtering options.
index 006bb0d..c2247dc 100644 (file)
@@ -27,37 +27,37 @@ require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 
 $confirm = optional_param('confirm', 0, PARAM_BOOL);
+$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
 
-admin_externalpage_setup('purgecaches');
-
-require_login();
-require_capability('moodle/site:config', context_system::instance());
-
-if ($confirm) {
-    require_sesskey();
+// If we have got here as a confirmed aciton, do it.
+if ($confirm && isloggedin() && confirm_sesskey()) {
+    require_capability('moodle/site:config', context_system::instance());
 
-    // Valid request. Purge, and redisplay the form so it is easy to purge again
-    // in the near future.
+    // Valid request. Purge, and redirect the user back to where they came from.
     purge_all_caches();
-    redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
-
-} else {
-    // Show a confirm form.
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
-
-    $url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
-    $button = new single_button($url, get_string('purgecaches','admin'), 'post');
-
-    // Cancel button takes them back to the page the were on, if possible,
-    // otherwise to the site home page.
-    $return = new moodle_url('/');
-    if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
-        if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
-            $return = $_SERVER['HTTP_REFERER'];
-        }
+
+    if ($returnurl) {
+        $returnurl = $CFG->wwwroot . $returnurl;
+    } else {
+        $returnurl = new moodle_url('/admin/purgecaches.php');
     }
+    redirect($returnurl, get_string('purgecachesfinished', 'admin'));
+}
 
-    echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
-    echo $OUTPUT->footer();
+// Otherwise, show a button to actually purge the caches.
+admin_externalpage_setup('purgecaches');
+
+$actionurl = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
+if ($returnurl) {
+    $actionurl->param('returnurl', $returnurl);
 }
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
+
+echo $OUTPUT->box_start('generalbox', 'notice');
+echo html_writer::tag('p', get_string('purgecachesconfirm', 'admin'));
+echo $OUTPUT->single_button($actionurl, get_string('purgecaches', 'admin'), 'post');
+echo $OUTPUT->box_end();
+
+echo $OUTPUT->footer();
index cb59976..85f0c8e 100644 (file)
@@ -143,7 +143,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey())
         print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
     }
 
-    if (!isset($behaviours[$delete])) {
+    if (!isset($behaviours[$delete]) && !get_config('qbehaviour_' . $delete, 'version')) {
         print_error('unknownbehaviour', 'question', $thispageurl, $delete);
     }
 
@@ -171,10 +171,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey())
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
 
-    // Delete any configuration records.
-    if (!unset_all_config_for_plugin('qbehaviour_' . $delete)) {
-        echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qbehaviour_' . $delete));
-    }
+    // Remove this behaviour from configurations where it might appear.
     if (($key = array_search($delete, $disabledbehaviours)) !== false) {
         unset($disabledbehaviours[$key]);
         set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
@@ -185,12 +182,10 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey())
         set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
     }
 
-    // Then the tables themselves
-    drop_plugin_tables($delete, core_component::get_plugin_directory('qbehaviour', $delete) . '/db/install.xml', false);
-
-    // Remove event handlers and dequeue pending events
-    events_uninstall('qbehaviour_' . $delete);
+    // Then uninstall the plugin.
+    uninstall_plugin('qbehaviour', $delete);
 
+    // Display a message.
     $a = new stdClass();
     $a->behaviour = $behaviourname;
     $a->directory = core_component::get_plugin_directory('qbehaviour', $delete);
index e12d3cc..3e865d1 100644 (file)
@@ -129,7 +129,7 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey())
         print_error('cannotdeletemissingqtype', 'question', $thispageurl);
     }
 
-    if (!isset($qtypes[$delete])) {
+    if (!isset($qtypes[$delete]) && !get_config('qtype_' . $delete, 'version')) {
         print_error('unknownquestiontype', 'question', $thispageurl, $delete);
     }
 
@@ -158,18 +158,12 @@ if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey())
     echo $OUTPUT->header();
     echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
 
-    // Delete any configuration records.
-    if (!unset_all_config_for_plugin('qtype_' . $delete)) {
-        echo $OUTPUT->notification(get_string('errordeletingconfig', 'admin', 'qtype_' . $delete));
-    }
+    // Delete any questoin configuration records mentioning this plugin.
     unset_config($delete . '_disabled', 'question');
     unset_config($delete . '_sortorder', 'question');
 
-    // Then the tables themselves
-    drop_plugin_tables($delete, $qtypes[$delete]->plugin_dir() . '/db/install.xml', false);
-
-    // Remove event handlers and dequeue pending events
-    events_uninstall('qtype_' . $delete);
+    // Then uninstall the plugin.
+    uninstall_plugin('qtype', $delete);
 
     $a = new stdClass();
     $a->qtype = $qtypename;
index 68cdb49..350254c 100644 (file)
@@ -140,12 +140,13 @@ class core_admin_renderer extends plugin_renderer_base {
     public function upgrade_confirm_page($strnewversion, $maturity) {
         $output = '';
 
-        $continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
-        $cancelurl = new moodle_url('index.php');
+        $continueurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1));
+        $continue = new single_button($continueurl, get_string('continue'), 'get');
+        $cancelurl = new moodle_url('/admin/index.php');
 
         $output .= $this->header();
         $output .= $this->maturity_warning($maturity);
-        $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
+        $output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continue, $cancelurl);
         $output .= $this->footer();
 
         return $output;
@@ -412,6 +413,10 @@ class core_admin_renderer extends plugin_renderer_base {
 
         $pluginname = $pluginman->plugin_name($pluginfo->component);
 
+        // Do not show navigation here, they must click one of the buttons.
+        $this->page->set_pagelayout('maintenance');
+        $this->page->set_cacheable(false);
+
         $output .= $this->output->header();
         $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
 
@@ -425,7 +430,8 @@ class core_admin_renderer extends plugin_renderer_base {
                 'uninstalldeleteconfirmexternal');
         }
 
-        $output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
+        // After any uninstall we must execute full upgrade to finish the cleanup!
+        $output .= $this->output->confirm($confirm, $continueurl, new moodle_url('/admin/index.php'));
         $output .= $this->output->footer();
 
         return $output;
@@ -442,7 +448,7 @@ class core_admin_renderer extends plugin_renderer_base {
     public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
         $output = '';
 
-        $pluginname = $pluginman->plugin_name($pluginfo->component);
+        $pluginname = $pluginfo->component;
 
         $output .= $this->output->header();
         $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
@@ -451,7 +457,7 @@ class core_admin_renderer extends plugin_renderer_base {
 
         $output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
             array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
-        $output .= $this->output->continue_button($this->page->url);
+        $output .= $this->output->continue_button(new moodle_url('/admin/index.php'));
         $output .= $this->output->footer();
 
         return $output;
@@ -708,7 +714,7 @@ class core_admin_renderer extends plugin_renderer_base {
 
         if (!$registered) {
 
-            $registerbutton = $this->single_button(new moodle_url('registration/register.php',
+            $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php',
                     array('huburl' =>  HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.org')),
                     get_string('register', 'admin'));
 
@@ -1005,9 +1011,11 @@ class core_admin_renderer extends plugin_renderer_base {
             } else {
                 $str = 'otherplugin';
             }
+            $componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component);
+            $componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out()));
             $requires[] = html_writer::tag('li',
                     get_string($str, 'core_plugin',
-                            array('component' => $component, 'version' => $requiredversion)),
+                            array('component' => $componenturl, 'version' => $requiredversion)),
                     array('class' => $class));
         }
 
index 50a08ee..8f976cf 100644 (file)
@@ -143,8 +143,10 @@ if (($action == 'edit') || ($action == 'new')) {
             $success = $repositorytype->update_options($settings);
         } else {
             $type = new repository_type($plugin, (array)$fromform, $visible);
-            $type->create();
             $success = true;
+            if (!$repoid = $type->create()) {
+                $success = false;
+            }
             $data = data_submitted();
         }
         if ($success) {
index 9b7e709..8ffd54d 100644 (file)
@@ -46,7 +46,22 @@ $controller = new $classformode[$mode]();
 if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
     $controller->process_submission();
     $syscontext->mark_dirty();
-    add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
+    $event = null;
+    // Create event depending on mode.
+    switch ($mode) {
+        case 'assign':
+            $event = \core\event\role_allow_assign_updated::create(array('context' => $syscontext));
+            break;
+        case 'override':
+            $event = \core\event\role_allow_override_updated::create(array('context' => $syscontext));
+            break;
+        case 'switch':
+            $event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
+            break;
+    }
+    if ($event) {
+        $event->trigger();
+    }
     redirect($baseurl);
 }
 
index 8346640..cce2334 100644 (file)
@@ -110,8 +110,6 @@ if ($roleid) {
             $potentialuserselector->invalidate_selected_users();
             $currentuserselector->invalidate_selected_users();
 
-            $rolename = $assignableroles[$roleid];
-            add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
             // Counts have changed, so reload.
             list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
         }
@@ -130,8 +128,6 @@ if ($roleid) {
             $potentialuserselector->invalidate_selected_users();
             $currentuserselector->invalidate_selected_users();
 
-            $rolename = $assignableroles[$roleid];
-            add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
             // Counts have changed, so reload.
             list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
         }
index cd7741c..66cc014 100644 (file)
@@ -49,14 +49,11 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
         $this->displaypermissions = $this->allpermissions;
         $this->strperms[$this->allpermissions[CAP_INHERIT]] = get_string('notset', 'core_role');
 
-        $this->allcontextlevels = array(
-            CONTEXT_SYSTEM => get_string('coresystem'),
-            CONTEXT_USER => get_string('user'),
-            CONTEXT_COURSECAT => get_string('category'),
-            CONTEXT_COURSE => get_string('course'),
-            CONTEXT_MODULE => get_string('activitymodule'),
-            CONTEXT_BLOCK => get_string('block')
-        );
+        $this->allcontextlevels = array();
+        $levels = context_helper::get_all_levels();
+        foreach ($levels as $level => $classname) {
+            $this->allcontextlevels[$level] = context_helper::get_level_name($level);
+        }
     }
 
     protected function load_current_permissions() {
index f588d1a..265b100 100644 (file)
@@ -196,8 +196,22 @@ if (optional_param('cancel', false, PARAM_BOOL)) {
 // Process submission in necessary.
 if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
     $definitiontable->save_changes();
-    add_to_log(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' .
-            $definitiontable->get_role_id(), $definitiontable->get_role_name(), '', $USER->id);
+    $tableroleid = $definitiontable->get_role_id();
+    // Trigger event.
+    $event = \core\event\role_capabilities_updated::create(
+        array(
+            'context' => $systemcontext,
+            'objectid' => $roleid,
+            'other' => array('name' => $definitiontable->get_role_name())
+        )
+    );
+    $event->set_legacy_logdata(array(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' . $tableroleid,
+        $definitiontable->get_role_name(), '', $USER->id));
+    if (!empty($role)) {
+        $event->add_record_snapshot('role', $role);
+    }
+    $event->trigger();
+
     if ($action === 'add') {
         redirect(new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$definitiontable->get_role_id())));
     } else {
index ec02517..e3e094a 100644 (file)
@@ -90,7 +90,6 @@ switch ($action) {
         }
         // Deleted a role sitewide...
         $systemcontext->mark_dirty();
-        add_to_log(SITEID, 'role', 'delete', 'admin/roles/manage.php', $roles[$roleid]->localname, '', $USER->id);
         redirect($baseurl);
         break;
 
index 7d27dc2..bc506f1 100644 (file)
@@ -125,7 +125,25 @@ $overridestable->read_submitted_permissions();
 if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
     $overridestable->save_changes();
     $rolename = $overridableroles[$roleid];
-    add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
+    // Trigger event.
+    $event = \core\event\role_capabilities_updated::create(
+        array(
+            'context' => $context,
+            'objectid' => $roleid,
+            'courseid' => $courseid,
+            'other' => array('name' => $rolename)
+        )
+    );
+
+    $event->set_legacy_logdata(
+        array(
+            $course->id, 'role', 'override', 'admin/roles/override.php?contextid=' . $context->id . '&roleid=' . $roleid,
+            $rolename, '', $USER->id
+        )
+    );
+    $event->add_record_snapshot('role', $role);
+    $event->trigger();
+
     redirect($returnurl);
 }
 
index 85e3f2d..3a58d34 100644 (file)
@@ -175,16 +175,25 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo
 // "performance" settingpage
 $temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
 
+// Memory limit options for large administration tasks.
+$memoryoptions = array(
+    '64M' => '64M',
+    '128M' => '128M',
+    '256M' => '256M',
+    '512M' => '512M',
+    '1024M' => '1024M',
+    '2048M' => '2048M');
+
+// Allow larger memory usage for 64-bit sites only.
+if (PHP_INT_SIZE === 8) {
+    $memoryoptions['3072M'] = '3072M';
+    $memoryoptions['4096M'] = '4096M';
+}
+
 $temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
                                           new lang_string('configextramemorylimit', 'admin'), '512M',
-                                          // if this option is set to 0, default 128M will be used
-                                          array( '64M' => '64M',
-                                                 '128M' => '128M',
-                                                 '256M' => '256M',
-                                                 '512M' => '512M',
-                                                 '1024M' => '1024M',
-                                                 '2048M' => '2048M',
-                                             )));
+                                          $memoryoptions));
+
 $temp->add(new admin_setting_configtext('curlcache', new lang_string('curlcache', 'admin'),
                                         new lang_string('configcurlcache', 'admin'), 120, PARAM_INT));
 
index db94c85..0f5ac5e 100644 (file)
@@ -25,7 +25,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 global $CFG;
-require_once($CFG->libdir . '/behat/classes/behat_command.php');
+require_once($CFG->libdir . '/behat/classes/behat_selectors.php');
 
 /**
  * Renderer for behat tool web features
@@ -92,7 +92,7 @@ class tool_behat_renderer extends plugin_renderer_base {
             // Replace text selector type arguments with a user-friendly select.
             $stepsdefinitions = preg_replace_callback('/(TEXT_SELECTOR\d?_STRING)/',
                 function ($matches) {
-                    return html_writer::select(behat_command::$allowedtextselectors, uniqid());
+                    return html_writer::select(behat_selectors::get_allowed_text_selectors(), uniqid());
                 },
                 $stepsdefinitions
             );
@@ -100,7 +100,7 @@ class tool_behat_renderer extends plugin_renderer_base {
             // Replace selector type arguments with a user-friendly select.
             $stepsdefinitions = preg_replace_callback('/(SELECTOR\d?_STRING)/',
                 function ($matches) {
-                    return html_writer::select(behat_command::$allowedselectors, uniqid());
+                    return html_writer::select(behat_selectors::get_allowed_selectors(), uniqid());
                 },
                 $stepsdefinitions
             );
index 637086f..4ec803d 100644 (file)
@@ -35,7 +35,7 @@ Feature: Page contents assertions
       | Course 1 | C1 | 0 |
     And I log in as "admin"
     And I follow "Course 1"
-    When I click on "Move this to the dock" "button" in the ".block_settings" "css_element"
+    When I click on "Move this to the dock" "button" in the "Administration" "block"
     Then I should not see "Question bank"
     And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
 
@@ -45,5 +45,5 @@ Feature: Page contents assertions
       | fullname | shortname | category |
       | Course 1 | C1 | 0 |
     And I log in as "admin"
-    When I click on "Move this to the dock" "button" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' block_settings ')]" "xpath_element"
+    When I click on "Move this to the dock" "button" in the "Administration" "block"
     Then I should not see "Turn editing on"
index e37f9bc..c0d3665 100644 (file)
@@ -65,6 +65,37 @@ Feature: Set up contextual data for tests
     And I should see "Grouping 1"
     And I should see "Grouping 2"
 
+  @javascript
+  Scenario: Role overrides
+    Given the following "users" exists:
+      | username | firstname | lastname | email |
+      | teacher1 | Teacher | 1 | teacher1@asd.com |
+      | student1 | Student | 1 | student1@asd.com |
+    And the following "categories" exists:
+      | name | category | idnumber |
+      | Cat 1 | 0 | CAT1 |
+    And the following "courses" exists:
+      | fullname | shortname |
+      | Course 1 | C1 |
+    And the following "course enrolments" exists:
+      | user | course | role |
+      | student1 | C1 | student |
+      | teacher1 | C1 | editingteacher |
+    And the following "permission overrides" exists:
+      | capability | permission | role | contextlevel | reference |
+      | mod/forum:editanypost | Allow | student | Course | C1 |
+      | mod/forum:replynews | Prevent | editingteacher | Course | C1 |
+    When I log in as "admin"
+    And I follow "Course 1"
+    And I expand "Users" node
+    And I follow "Permissions"
+    And I select "Student (1)" from "Advanced role override"
+    Then the "mod/forum:editanypost" field should match "1" value
+    And I press "Cancel"
+    And I select "Teacher (1)" from "Advanced role override"
+    And the "mod/forum:replynews" field should match "-1" value
+    And I press "Cancel"
+
   Scenario: Add course enrolments
     Given the following "users" exists:
       | username | firstname | lastname | email |
diff --git a/admin/tool/generator/classes/backend.php b/admin/tool/generator/classes/backend.php
new file mode 100644 (file)
index 0000000..20b3370
--- /dev/null
@@ -0,0 +1,192 @@
+<?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/>.
+
+/**
+ * Backend generic code.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Backend generic code for all tool_generator commands.
+ *
+ * @abstract
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class tool_generator_backend {
+    /**
+     * @var int Lowest (smallest) size index
+     */
+    const MIN_SIZE = 0;
+    /**
+     * @var int Highest (largest) size index
+     */
+    const MAX_SIZE = 5;
+    /**
+     * @var int Default size index
+     */
+    const DEFAULT_SIZE = 3;
+
+    /**
+     * @var bool True if we want a fixed dataset or false to generate random data
+     */
+    protected $fixeddataset;
+
+    /**
+     * @var bool True if displaying progress
+     */
+    protected $progress;
+
+    /**
+     * @var int Epoch time at which last dot was displayed
+     */
+    protected $lastdot;
+
+    /**
+     * @var int Epoch time at which last percentage was displayed
+     */
+    protected $lastpercentage;
+
+    /**
+     * @var int Epoch time at which current step (current set of dots) started
+     */
+    protected $starttime;
+
+    /**
+     * @var int Size code (index in the above arrays)
+     */
+    protected $size;
+
+    /**
+     * Generic generator class
+     *
+     * @param int $size Size as numeric index
+     * @param bool $fixeddataset To use fixed or random data
+     * @param bool $progress True if progress information should be displayed
+     * @throws coding_exception If parameters are invalid
+     */
+    public function __construct($size, $fixeddataset = false, $progress = true) {
+
+        // Check parameter.
+        if ($size < self::MIN_SIZE || $size > self::MAX_SIZE) {
+            throw new coding_exception('Invalid size');
+        }
+
+        // Set parameters.
+        $this->size = $size;
+        $this->fixeddataset = $fixeddataset;
+        $this->progress = $progress;
+    }
+
+    /**
+     * Converts a size name into the numeric constant.
+     *
+     * @param string $sizename Size name e.g. 'L'
+     * @return int Numeric version
+     * @throws coding_exception If the size name is not known
+     */
+    public static function size_for_name($sizename) {
+        for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
+            if ($sizename == get_string('shortsize_' . $size, 'tool_generator')) {
+                return $size;
+            }
+        }
+        throw new coding_exception("Unknown size name '$sizename'");
+    }
+
+    /**
+     * Displays information as part of progress.
+     * @param string $langstring Part of langstring (after progress_)
+     * @param mixed $a Optional lang string parameters
+     * @param bool $leaveopen If true, doesn't close LI tag (ready for dots)
+     */
+    protected function log($langstring, $a = null, $leaveopen = false) {
+        if (!$this->progress) {
+            return;
+        }
+        if (CLI_SCRIPT) {
+            echo '* ';
+        } else {
+            echo html_writer::start_tag('li');
+        }
+        echo get_string('progress_' . $langstring, 'tool_generator', $a);
+        if (!$leaveopen) {
+            if (CLI_SCRIPT) {
+                echo "\n";
+            } else {
+                echo html_writer::end_tag('li');
+            }
+        } else {
+            echo ': ';
+            $this->lastdot = time();
+            $this->lastpercentage = $this->lastdot;
+            $this->starttime = microtime(true);
+        }
+    }
+
+    /**
+     * Outputs dots. There is up to one dot per second. Once a minute, it
+     * displays a percentage.
+     * @param int $number Number of completed items
+     * @param int $total Total number of items to complete
+     */
+    protected function dot($number, $total) {
+        if (!$this->progress) {
+            return;
+        }
+        $now = time();
+        if ($now == $this->lastdot) {
+            return;
+        }
+        $this->lastdot = $now;
+        if (CLI_SCRIPT) {
+            echo '.';
+        } else {
+            echo ' . ';
+        }
+        if ($now - $this->lastpercentage >= 30) {
+            echo round(100.0 * $number / $total, 1) . '%';
+            $this->lastpercentage = $now;
+        }
+
+        // Update time limit so PHP doesn't time out.
+        if (!CLI_SCRIPT) {
+            set_time_limit(120);
+        }
+    }
+
+    /**
+     * Ends a log string that was started using log function with $leaveopen.
+     */
+    protected function end_log() {
+        if (!$this->progress) {
+            return;
+        }
+        echo get_string('done', 'tool_generator', round(microtime(true) - $this->starttime, 1));
+        if (CLI_SCRIPT) {
+            echo "\n";
+        } else {
+            echo html_writer::end_tag('li');
+        }
+    }
+
+}
diff --git a/admin/tool/generator/classes/course_backend.php b/admin/tool/generator/classes/course_backend.php
new file mode 100644 (file)
index 0000000..07e1e7b
--- /dev/null
@@ -0,0 +1,507 @@
+<?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/>.
+
+/**
+ * tool_generator course backend code.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Backend code for the 'make large course' tool.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tool_generator_course_backend extends tool_generator_backend {
+    /**
+     * @var array Number of sections in course
+     */
+    private static $paramsections = array(1, 10, 100, 500, 1000, 2000);
+    /**
+     * @var array Number of Page activities in course
+     */
+    private static $parampages = array(1, 50, 200, 1000, 5000, 10000);
+    /**
+     * @var array Number of students enrolled in course
+     */
+    private static $paramusers = array(1, 100, 1000, 10000, 50000, 100000);
+    /**
+     * Total size of small files: 1KB, 1MB, 10MB, 100MB, 1GB, 2GB.
+     *
+     * @var array Number of small files created in a single file activity
+     */
+    private static $paramsmallfilecount = array(1, 64, 128, 1024, 16384, 32768);
+    /**
+     * @var array Size of small files (to make the totals into nice numbers)
+     */
+    private static $paramsmallfilesize = array(1024, 16384, 81920, 102400, 65536, 65536);
+    /**
+     * Total size of big files: 8KB, 8MB, 80MB, 800MB, 8GB, 16GB.
+     *
+     * @var array Number of big files created as individual file activities
+     */
+    private static $parambigfilecount = array(1, 2, 5, 10, 10, 10);
+    /**
+     * @var array Size of each large file
+     */
+    private static $parambigfilesize = array(8192, 4194304, 16777216, 83886080,
+            858993459, 1717986918);
+    /**
+     * @var array Number of forum discussions
+     */
+    private static $paramforumdiscussions = array(1, 10, 100, 500, 1000, 2000);
+    /**
+     * @var array Number of forum posts per discussion
+     */
+    private static $paramforumposts = array(2, 2, 5, 10, 10, 10);
+
+    /**
+     * @var string Course shortname
+     */
+    private $shortname;
+
+    /**
+     * @var testing_data_generator Data generator
+     */
+    protected $generator;
+
+    /**
+     * @var stdClass Course object
+     */
+    private $course;
+
+    /**
+     * @var array Array from test user number (1...N) to userid in database
+     */
+    private $userids;
+
+    /**
+     * Constructs object ready to create course.
+     *
+     * @param string $shortname Course shortname
+     * @param int $size Size as numeric index
+     * @param bool $fixeddataset To use fixed or random data
+     * @param bool $progress True if progress information should be displayed
+     * @return int Course id
+     */
+    public function __construct($shortname, $size, $fixeddataset = false, $progress = true) {
+
+        // Set parameters.
+        $this->shortname = $shortname;
+
+        parent::__construct($size, $fixeddataset, $progress);
+    }
+
+    /**
+     * Gets a list of size choices supported by this backend.
+     *
+     * @return array List of size (int) => text description for display
+     */
+    public static function get_size_choices() {
+        $options = array();
+        for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
+            $options[$size] = get_string('coursesize_' . $size, 'tool_generator');
+        }
+        return $options;
+    }
+
+    /**
+     * Checks that a shortname is available (unused).
+     *
+     * @param string $shortname Proposed course shortname
+     * @return string An error message if the name is unavailable or '' if OK
+     */
+    public static function check_shortname_available($shortname) {
+        global $DB;
+        $fullname = $DB->get_field('course', 'fullname',
+                array('shortname' => $shortname), IGNORE_MISSING);
+        if ($fullname !== false) {
+            // I wanted to throw an exception here but it is not possible to
+            // use strings from moodle.php in exceptions, and I didn't want
+            // to duplicate the string in tool_generator, so I changed this to
+            // not use exceptions.
+            return get_string('shortnametaken', 'moodle', $fullname);
+        }
+        return '';
+    }
+
+    /**
+     * Runs the entire 'make' process.
+     *
+     * @return int Course id
+     */
+    public function make() {
+        global $DB, $CFG;
+        require_once($CFG->dirroot . '/lib/phpunit/classes/util.php');
+
+        raise_memory_limit(MEMORY_EXTRA);
+
+        if ($this->progress && !CLI_SCRIPT) {
+            echo html_writer::start_tag('ul');
+        }
+
+        $entirestart = microtime(true);
+
+        // Start transaction.
+        $transaction = $DB->start_delegated_transaction();
+
+        // Get generator.
+        $this->generator = phpunit_util::get_data_generator();
+
+        // Make course.
+        $this->course = $this->create_course();
+        $this->create_users();
+        $this->create_pages();
+        $this->create_small_files();
+        $this->create_big_files();
+        $this->create_forum();
+
+        // Log total time.
+        $this->log('coursecompleted', round(microtime(true) - $entirestart, 1));
+
+        if ($this->progress && !CLI_SCRIPT) {
+            echo html_writer::end_tag('ul');
+        }
+
+        // Commit transaction and finish.
+        $transaction->allow_commit();
+        return $this->course->id;
+    }
+
+    /**
+     * Creates the actual course.
+     *
+     * @return stdClass Course record
+     */
+    private function create_course() {
+        $this->log('createcourse', $this->shortname);
+        $courserecord = array('shortname' => $this->shortname,
+                'fullname' => get_string('fullname', 'tool_generator',
+                    array('size' => get_string('shortsize_' . $this->size, 'tool_generator'))),
+                'numsections' => self::$paramsections[$this->size]);
+        return $this->generator->create_course($courserecord, array('createsections' => true));
+    }
+
+    /**
+     * Creates a number of user accounts and enrols them on the course.
+     * Note: Existing user accounts that were created by this system are
+     * reused if available.
+     */
+    private function create_users() {
+        global $DB;
+
+        // Work out total number of users.
+        $count = self::$paramusers[$this->size];
+
+        // Get existing users in order. We will 'fill up holes' in this up to
+        // the required number.
+        $this->log('checkaccounts', $count);
+        $nextnumber = 1;
+        $rs = $DB->get_recordset_select('user', $DB->sql_like('username', '?'),
+                array('tool_generator_%'), 'username', 'id, username');
+        foreach ($rs as $rec) {
+            // Extract number from username.
+            $matches = array();
+            if (!preg_match('~^tool_generator_([0-9]{6})$~', $rec->username, $matches)) {
+                continue;
+            }
+            $number = (int)$matches[1];
+
+            // Create missing users in range up to this.
+            if ($number != $nextnumber) {
+                $this->create_user_accounts($nextnumber, min($number - 1, $count));
+            } else {
+                $this->userids[$number] = (int)$rec->id;
+            }
+
+            // Stop if we've got enough users.
+            $nextnumber = $number + 1;
+            if ($number >= $count) {
+                break;
+            }
+        }
+        $rs->close();
+
+        // Create users from end of existing range.
+        if ($nextnumber <= $count) {
+            $this->create_user_accounts($nextnumber, $count);
+        }
+
+        // Assign all users to course.
+        $this->log('enrol', $count, true);
+
+        $enrolplugin = enrol_get_plugin('manual');
+        $instances = enrol_get_instances($this->course->id, true);
+        foreach ($instances as $instance) {
+            if ($instance->enrol === 'manual') {
+                break;
+            }
+        }
+        if ($instance->enrol !== 'manual') {
+            throw new coding_exception('No manual enrol plugin in course');
+        }
+        $role = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
+
+        for ($number = 1; $number <= $count; $number++) {
+            // Enrol user.
+            $enrolplugin->enrol_user($instance, $this->userids[$number], $role->id);
+            $this->dot($number, $count);
+        }
+
+        // Sets the pointer at the beginning to be aware of the users we use.
+        reset($this->userids);
+
+        $this->end_log();
+    }
+
+    /**
+     * Creates user accounts with a numeric range.
+     *
+     * @param int $first Number of first user
+     * @param int $last Number of last user
+     */
+    private function create_user_accounts($first, $last) {
+        $this->log('createaccounts', (object)array('from' => $first, 'to' => $last), true);
+        $count = $last - $first + 1;
+        $done = 0;
+        for ($number = $first; $number <= $last; $number++, $done++) {
+            // Work out username with 6-digit number.
+            $textnumber = (string)$number;
+            while (strlen($textnumber) < 6) {
+                $textnumber = '0' . $textnumber;
+            }
+            $username = 'tool_generator_' . $textnumber;
+
+            // Create user account.
+            $record = array('firstname' => get_string('firstname', 'tool_generator'),
+                    'lastname' => $number, 'username' => $username);
+            $user = $this->generator->create_user($record);
+            $this->userids[$number] = (int)$user->id;
+            $this->dot($done, $count);
+        }
+        $this->end_log();
+    }
+
+    /**
+     * Creates a number of Page activities.
+     */
+    private function create_pages() {
+        // Set up generator.
+        $pagegenerator = $this->generator->get_plugin_generator('mod_page');
+
+        // Create pages.
+        $number = self::$parampages[$this->size];
+        $this->log('createpages', $number, true);
+        for ($i=0; $i<$number; $i++) {
+            $record = array('course' => $this->course->id);
+            $options = array('section' => $this->get_target_section());
+            $pagegenerator->create_instance($record, $options);
+            $this->dot($i, $number);
+        }
+
+        $this->end_log();
+    }
+
+    /**
+     * Creates one resource activity with a lot of small files.
+     */
+    private function create_small_files() {
+        $count = self::$paramsmallfilecount[$this->size];
+        $this->log('createsmallfiles', $count, true);
+
+        // Create resource with default textfile only.
+        $resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
+        $record = array('course' => $this->course->id,
+                'name' => get_string('smallfiles', 'tool_generator'));
+        $options = array('section' => 0);
+        $resource = $resourcegenerator->create_instance($record, $options);
+
+        // Add files.
+        $fs = get_file_storage();
+        $context = context_module::instance($resource->cmid);
+        $filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
+                'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/');
+        for ($i = 0; $i < $count; $i++) {
+            $filerecord['filename'] = 'smallfile' . $i . '.dat';
+
+            // Generate random binary data (different for each file so it
+            // doesn't compress unrealistically).
+            $data = self::get_random_binary(self::$paramsmallfilesize[$this->size]);
+
+            $fs->create_file_from_string($filerecord, $data);
+            $this->dot($i, $count);
+        }
+
+        $this->end_log();
+    }
+
+    /**
+     * Creates a string of random binary data. The start of the string includes
+     * the current time, in an attempt to avoid large-scale repetition.
+     *
+     * @param int $length Number of bytes
+     * @return Random data
+     */
+    private static function get_random_binary($length) {
+        $data = microtime(true);
+        if (strlen($data) > $length) {
+            // Use last digits of data.
+            return substr($data, -$length);
+        }
+        $length -= strlen($data);
+        for ($j=0; $j < $length; $j++) {
+            $data .= chr(rand(1, 255));
+        }
+        return $data;
+    }
+
+    /**
+     * Creates a number of resource activities with one big file each.
+     */
+    private function create_big_files() {
+        global $CFG;
+
+        // Work out how many files and how many blocks to use (up to 64KB).
+        $count = self::$parambigfilecount[$this->size];
+        $blocks = ceil(self::$parambigfilesize[$this->size] / 65536);
+        $blocksize = floor(self::$parambigfilesize[$this->size] / $blocks);
+
+        $this->log('createbigfiles', $count, true);
+
+        // Prepare temp area.
+        $tempfolder = make_temp_directory('tool_generator');
+        $tempfile = $tempfolder . '/' . rand();
+
+        // Create resources and files.
+        $fs = get_file_storage();
+        $resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
+        for ($i = 0; $i < $count; $i++) {
+            // Create resource.
+            $record = array('course' => $this->course->id,
+                    'name' => get_string('bigfile', 'tool_generator', $i));
+            $options = array('section' => $this->get_target_section());
+            $resource = $resourcegenerator->create_instance($record, $options);
+
+            // Write file.
+            $handle = fopen($tempfile, 'w');
+            if (!$handle) {
+                throw new coding_exception('Failed to open temporary file');
+            }
+            for ($j = 0; $j < $blocks; $j++) {
+                $data = self::get_random_binary($blocksize);
+                fwrite($handle, $data);
+                $this->dot($i * $blocks + $j, $count * $blocks);
+            }
+            fclose($handle);
+
+            // Add file.
+            $context = context_module::instance($resource->cmid);
+            $filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
+                    'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/',
+                    'filename' => 'bigfile' . $i . '.dat');
+            $fs->create_file_from_pathname($filerecord, $tempfile);
+        }
+
+        unlink($tempfile);
+        $this->end_log();
+    }
+
+    /**
+     * Creates one forum activity with a bunch of posts.
+     */
+    private function create_forum() {
+        global $DB;
+
+        $discussions = self::$paramforumdiscussions[$this->size];
+        $posts = self::$paramforumposts[$this->size];
+        $totalposts = $discussions * $posts;
+
+        $this->log('createforum', $totalposts, true);
+
+        // Create empty forum.
+        $forumgenerator = $this->generator->get_plugin_generator('mod_forum');
+        $record = array('course' => $this->course->id,
+                'name' => get_string('pluginname', 'forum'));
+        $options = array('section' => 0);
+        $forum = $forumgenerator->create_instance($record, $options);
+
+        // Add discussions and posts.
+        $sofar = 0;
+        for ($i=0; $i < $discussions; $i++) {
+            $record = array('forum' => $forum->id, 'course' => $this->course->id,
+                    'userid' => $this->get_target_user());
+            $discussion = $forumgenerator->create_discussion($record);
+            $parentid = $DB->get_field('forum_posts', 'id', array('discussion' => $discussion->id), MUST_EXIST);
+            $sofar++;
+            for ($j=0; $j < $posts - 1; $j++, $sofar++) {
+                $record = array('discussion' => $discussion->id,
+                        'userid' => $this->get_target_user(), 'parent' => $parentid);
+                $forumgenerator->create_post($record);
+                $this->dot($sofar, $totalposts);
+            }
+        }
+
+        $this->end_log();
+    }
+
+    /**
+     * Gets a section number.
+     *
+     * Depends on $this->fixeddataset.
+     *
+     * @return int A section number from 1 to the number of sections
+     */
+    private function get_target_section() {
+
+        if (!$this->fixeddataset) {
+            $key = rand(1, self::$paramsections[$this->size]);
+        } else {
+            // Using section 1.
+            $key = 1;
+        }
+
+        return $key;
+    }
+
+    /**
+     * Gets a user id.
+     *
+     * Depends on $this->fixeddataset.
+     *
+     * @return int A user id for a random created user
+     */
+    private function get_target_user() {
+
+        if (!$this->fixeddataset) {
+            $userid = $this->userids[rand(1, self::$paramusers[$this->size])];
+        } else if ($userid = current($this->userids)) {
+            // Moving pointer to the next user.
+            next($this->userids);
+        } else {
+            // Returning to the beginning if we reached the end.
+            $userid = reset($this->userids);
+        }
+
+        return $userid;
+    }
+
+}
diff --git a/admin/tool/generator/classes/make_form.php b/admin/tool/generator/classes/make_form.php
new file mode 100644 (file)
index 0000000..879364d
--- /dev/null
@@ -0,0 +1,59 @@
+<?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/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->libdir . '/formslib.php');
+
+/**
+ * Form with options for creating large course.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tool_generator_make_form extends moodleform {
+
+    public function definition() {
+        $mform = $this->_form;
+
+        $mform->addElement('select', 'size', get_string('size', 'tool_generator'),
+                tool_generator_course_backend::get_size_choices());
+        $mform->setDefault('size', tool_generator_course_backend::DEFAULT_SIZE);
+
+        $mform->addElement('text', 'shortname', get_string('shortnamecourse'));
+        $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
+        $mform->setType('shortname', PARAM_TEXT);
+
+        $mform->addElement('submit', 'submit', get_string('createcourse', 'tool_generator'));
+    }
+
+    public function validation($data, $files) {
+        global $DB;
+        $errors = array();
+
+        // Check course doesn't already exist.
+        if (!empty($data['shortname'])) {
+            // Check shortname.
+            $error =  tool_generator_course_backend::check_shortname_available($data['shortname']);
+            if ($error) {
+                $errors['shortname'] = $error;
+            }
+        }
+
+        return $errors;
+    }
+}
diff --git a/admin/tool/generator/classes/site_backend.php b/admin/tool/generator/classes/site_backend.php
new file mode 100644 (file)
index 0000000..01bde97
--- /dev/null
@@ -0,0 +1,203 @@
+<?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/>.
+
+/**
+ * tool_generator site backend.
+ *
+ * @package tool_generator
+ * @copyright 2013 David Monllaó
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Backend code for the site generator.
+ *
+ * @package tool_generator
+ * @copyright 2013 David Monllaó
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tool_generator_site_backend extends tool_generator_backend {
+
+    /**
+     * @var string The course's shortname prefix.
+     */
+    const SHORTNAMEPREFIX = 'testcourse_';
+
+    /**
+     * @var bool If the debugging level checking was skipped.
+     */
+    protected $bypasscheck;
+
+    /**
+     * @var array Multidimensional array where the first level is the course size and the second the site size.
+     */
+    protected static $sitecourses = array(
+        array(2, 8, 64, 256, 1024, 4096),
+        array(1, 4, 8, 16, 32, 64),
+        array(0, 0, 1, 4, 8, 16),
+        array(0, 0, 0, 1, 0, 0),
+        array(0, 0, 0, 0, 1, 0),
+        array(0, 0, 0, 0, 0, 1)
+    );
+
+    /**
+     * Constructs object ready to make the site.
+     *
+     * @param int $size Size as numeric index
+     * @param bool $bypasscheck If debugging level checking was skipped.
+     * @param bool $fixeddataset To use fixed or random data
+     * @param bool $progress True if progress information should be displayed
+     * @return int Course id
+     */
+    public function __construct($size, $bypasscheck, $fixeddataset = false, $progress = true) {
+
+        // Set parameters.
+        $this->bypasscheck = $bypasscheck;
+
+        parent::__construct($size, $fixeddataset, $progress);
+    }
+
+    /**
+     * Gets a list of size choices supported by this backend.
+     *
+     * @return array List of size (int) => text description for display
+     */
+    public static function get_size_choices() {
+        $options = array();
+        for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
+            $options[$size] = get_string('sitesize_' . $size, 'tool_generator');
+        }
+        return $options;
+    }
+
+    /**
+     * Runs the entire 'make' process.
+     *
+     * @return int Course id
+     */
+    public function make() {
+        global $DB, $CFG;
+
+        raise_memory_limit(MEMORY_EXTRA);
+
+        if ($this->progress && !CLI_SCRIPT) {
+            echo html_writer::start_tag('ul');
+        }
+
+        $entirestart = microtime(true);
+
+        // Create courses.
+        $prevchdir = getcwd();
+        chdir($CFG->dirroot);
+        $ncourse = $this->get_last_testcourse_id();
+        foreach (self::$sitecourses as $coursesize => $ncourses) {
+            for ($i = 1; $i <= $ncourses[$this->size]; $i++) {
+                // Non language-dependant shortname.
+                $ncourse++;
+                $this->run_create_course(self::SHORTNAMEPREFIX . $ncourse, $coursesize);
+            }
+        }
+        chdir($prevchdir);
+
+        // Store last course id to return it (will be the bigger one).
+        $lastcourseid = $DB->get_field('course', 'id', array('shortname' => self::SHORTNAMEPREFIX . $ncourse));
+
+        // Log total time.
+        $this->log('sitecompleted', round(microtime(true) - $entirestart, 1));
+
+        if ($this->progress && !CLI_SCRIPT) {
+            echo html_writer::end_tag('ul');
+        }
+
+        return $lastcourseid;
+    }
+
+    /**
+     * Creates a course with the specified shortname, coursesize and the provided maketestsite options.
+     *
+     * @param string $shortname The course shortname
+     * @param int $coursesize One of the possible course sizes.
+     * @return void
+     */
+    protected function run_create_course($shortname, $coursesize) {
+
+        // We are in $CFG->dirroot.
+        $command = 'php admin/tool/generator/cli/maketestcourse.php';
+
+        $options = array(
+            '--shortname="' . $shortname . '"',
+            '--size="' . get_string('shortsize_' . $coursesize, 'tool_generator') . '"'
+        );
+
+        if (!$this->progress) {
+            $options[] = '--quiet';
+        }
+
+        // Extend options.
+        $optionstoextend = array(
+            'fixeddataset' => 'fixeddataset',
+            'bypasscheck' => 'bypasscheck',
+        );
+
+        // Getting an options string.
+        foreach ($optionstoextend as $attribute => $option) {
+            if (!empty($this->{$attribute})) {
+                $options[] = '--' . $option;
+            }
+        }
+        $options = implode(' ', $options);
+        if ($this->progress) {
+            system($command . ' ' . $options, $exitcode);
+        } else {
+            passthru($command . ' ' . $options, $exitcode);
+        }
+
+        if ($exitcode != 0) {
+            exit($exitcode);
+        }
+    }
+
+    /**
+     * Obtains the last unique sufix (numeric) using the test course prefix.
+     *
+     * @return int The last generated numeric value.
+     */
+    protected function get_last_testcourse_id() {
+        global $DB;
+
+        $params = array();
+        $params['shortnameprefix'] = $DB->sql_like_escape(self::SHORTNAMEPREFIX) . '%';
+        $like = $DB->sql_like('shortname', ':shortnameprefix');
+
+        if (!$testcourses = $DB->get_records_select('course', $like, $params, 'shortname DESC')) {
+            return 0;
+        }
+
+        // They come ordered by shortname DESC, so non-numeric values will be the first ones.
+        foreach ($testcourses as $testcourse) {
+            $sufix = substr($testcourse->shortname, strlen(self::SHORTNAMEPREFIX));
+            if (is_numeric($sufix)) {
+                return $sufix;
+            }
+        }
+
+        // If all sufixes are not numeric this is the fist make test site run.
+        return 0;
+    }
+
+}
index 4514fd7..353883e 100644 (file)
@@ -28,7 +28,7 @@ define('CLI_SCRIPT', true);
 require(dirname(__FILE__) . '/../../../../config.php');
 require_once(dirname(__FILE__) . '/../locallib.php');
 
-if (!debugging('', DEBUG_DEVELOPER)) {
+if (!$CFG->debugdeveloper) {
     echo("This script is for developers only!!!\n");
     exit(1);
 }
diff --git a/admin/tool/generator/cli/maketestcourse.php b/admin/tool/generator/cli/maketestcourse.php
new file mode 100644 (file)
index 0000000..407a58f
--- /dev/null
@@ -0,0 +1,97 @@
+<?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/>.
+
+/**
+ * CLI interface for creating a test course.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('CLI_SCRIPT', true);
+define('NO_OUTPUT_BUFFERING', true);
+
+require(dirname(__FILE__) . '/../../../../config.php');
+require_once($CFG->libdir. '/clilib.php');
+
+// CLI options.
+list($options, $unrecognized) = cli_get_params(
+    array(
+        'help' => false,
+        'shortname' => false,
+        'size' => false,
+        'fixeddataset' => false,
+        'bypasscheck' => false,
+        'quiet' => false
+    ),
+    array(
+        'h' => 'help'
+    )
+);
+
+// Display help.
+if (!empty($options['help']) || empty($options['shortname']) || empty($options['size'])) {
+    echo "
+Utility to create standard test course. (Also available in GUI interface.)
+
+Not for use on live sites; only normally works if debugging is set to DEVELOPER
+level.
+
+Options:
+--shortname    Shortname of course to create (required)
+--size         Size of course to create XS, S, M, L, XL, or XXL (required)
+--fixeddataset Use a fixed data set instead of randomly generated data
+--bypasscheck  Bypasses the developer-mode check (be careful!)
+--quiet        Do not show any output
+
+-h, --help     Print out this help
+
+Example from Moodle root directory:
+\$ php admin/tool/generator/cli/maketestcourse.php --shortname=SIZE_S --size=S
+";
+    // Exit with error unless we're showing this because they asked for it.
+    exit(empty($options['help']) ? 1 : 0);
+}
+
+// Check debugging is set to developer level.
+if (empty($options['bypasscheck']) && !debugging('', DEBUG_DEVELOPER)) {
+    cli_error(get_string('error_notdebugging', 'tool_generator'));
+}
+
+// Get options.
+$shortname = $options['shortname'];
+$sizename = $options['size'];
+$fixeddataset = $options['fixeddataset'];
+
+// Check size.
+try {
+    $size = tool_generator_course_backend::size_for_name($sizename);
+} catch (coding_exception $e) {
+    cli_error("Invalid size ($sizename). Use --help for help.");
+}
+
+// Check shortname.
+if ($error = tool_generator_course_backend::check_shortname_available($shortname)) {
+    cli_error($error);
+}
+
+// Switch to admin user account.
+session_set_user(get_admin());
+
+// Do backend code to generate course.
+$backend = new tool_generator_course_backend($shortname, $size, $fixeddataset, empty($options['quiet']));
+$id = $backend->make();
diff --git a/admin/tool/generator/cli/maketestsite.php b/admin/tool/generator/cli/maketestsite.php
new file mode 100644 (file)
index 0000000..bc91d7d
--- /dev/null
@@ -0,0 +1,95 @@
+<?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/>.
+
+/**
+ * CLI interface for creating a test site.
+ *
+ * @package tool_generator
+ * @copyright 2013 David Monllaó
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+define('CLI_SCRIPT', true);
+define('NO_OUTPUT_BUFFERING', true);
+
+require(__DIR__ . '/../../../../config.php');
+require_once($CFG->libdir. '/clilib.php');
+
+// CLI options.
+list($options, $unrecognized) = cli_get_params(
+    array(
+        'help' => false,
+        'size' => false,
+        'fixeddataset' => false,
+        'bypasscheck' => false,
+        'quiet' => false
+    ),
+    array(
+        'h' => 'help'
+    )
+);
+
+$sitesizes = '* ' . implode(PHP_EOL . '* ', tool_generator_site_backend::get_size_choices());
+
+// Display help.
+if (!empty($options['help']) || empty($options['size'])) {
+    echo "
+Utility to generate a standard test site data set.
+
+Not for use on live sites; only normally works if debugging is set to DEVELOPER
+level.
+
+Consider that, depending on the size you select, this CLI tool can really generate a lot of data, aproximated sizes:
+
+$sitesizes
+
+Options:
+--size         Size of the generated site, this value affects the number of courses and their size. Accepted values: XS, S, M, L, XL, or XXL (required)
+--fixeddataset Use a fixed data set instead of randomly generated data
+--bypasscheck  Bypasses the developer-mode check (be careful!)
+--quiet        Do not show any output
+
+-h, --help     Print out this help
+
+Example from Moodle root directory:
+\$ php admin/tool/generator/cli/maketestsite.php --size=S
+";
+    // Exit with error unless we're showing this because they asked for it.
+    exit(empty($options['help']) ? 1 : 0);
+}
+
+// Check debugging is set to developer level.
+if (empty($options['bypasscheck']) && !$CFG->debugdeveloper) {
+    cli_error(get_string('error_notdebugging', 'tool_generator'));
+}
+
+// Get options.
+$sizename = $options['size'];
+$fixeddataset = $options['fixeddataset'];
+
+// Check size.
+try {
+    $size = tool_generator_site_backend::size_for_name($sizename);
+} catch (coding_exception $e) {
+    cli_error("Invalid size ($sizename). Use --help for help.");
+}
+
+// Switch to admin user account.
+session_set_user(get_admin());
+
+// Do backend code to generate site.
+$backend = new tool_generator_site_backend($size, $options['bypasscheck'], $fixeddataset, empty($options['quiet']));
+$backend->make();
index f77c8e0..7a917e9 100644 (file)
@@ -34,7 +34,7 @@ if (!is_siteadmin()) {
     error('Only for admins');
 }
 
-if (!debugging('', DEBUG_DEVELOPER)) {
+if (!$CFG->debugdeveloper) {
     error('This script is for developers only!!!');
 }
 
index 051d04f..a204ce8 100644 (file)
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Strings for component 'tool_generator', language 'en', branch 'MOODLE_22_STABLE'
+ * Language strings.
  *
- * @package    tool
- * @subpackage generator
- * @copyright  2011 Petr Skoda
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$string['pluginname'] = 'Random course generator';
+$string['bigfile'] = 'Big file {$a}';
+$string['coursesize_0'] = 'XS (~10KB; create in ~1 second)';
+$string['coursesize_1'] = 'S (~10MB; create in ~30 seconds)';
+$string['coursesize_2'] = 'M (~100MB; create in ~5 minutes)';
+$string['coursesize_3'] = 'L (~1GB; create in ~1 hour)';
+$string['coursesize_4'] = 'XL (~10GB; create in ~4 hours)';
+$string['coursesize_5'] = 'XXL (~20GB; create in ~8 hours)';
+$string['createcourse'] = 'Create course';
+$string['creating'] = 'Creating course';
+$string['done'] = 'done ({$a}s)';
+$string['explanation'] = 'This tool creates standard test courses that include many
+sections, activities, and files.
+
+This is intended to provide a standardised measure for checking the reliability
+and performance of various system components (such as backup and restore).
+
+This test is important because there have been many cases previously where,
+faced with real-life use cases (e.g. a course with 1,000 activities), the system
+does not work.
+
+Courses created using this feature can occupy a large amount of database and
+filesystem space (tens of gigabytes). You will need to delete the courses
+(and wait for various cleanup runs) to release this space again.
+
+**Do not use this feature on a live system**. Use only on a developer server.
+(To avoid accidental use, this feature is disabled unless you have also selected
+DEVELOPER debugging level.)';
+
+$string['error_notdebugging'] = 'Not available on this server because debugging is not set to DEVELOPER';
+$string['firstname'] = 'Test course user';
+$string['fullname'] = 'Test course: {$a->size}';
+$string['maketestcourse'] = 'Make test course';
+$string['pluginname'] = 'Development data generator';
+$string['progress_createcourse'] = 'Creating course {$a}';
+$string['progress_checkaccounts'] = 'Checking user accounts ({$a})';
+$string['progress_coursecompleted'] = 'Course completed ({$a}s)';
+$string['progress_createaccounts'] = 'Creating user accounts ({$a->from} - {$a->to})';
+$string['progress_createbigfiles'] = 'Creating big files ({$a})';
+$string['progress_createforum'] = 'Creating forum ({$a} posts)';
+$string['progress_createpages'] = 'Creating pages ({$a})';
+$string['progress_createsmallfiles'] = 'Creating small files ({$a})';
+$string['progress_enrol'] = 'Enrolling users into course ({$a})';
+$string['progress_sitecompleted'] = 'Site completed ({$a}s)';
+$string['shortsize_0'] = 'XS';
+$string['shortsize_1'] = 'S';
+$string['shortsize_2'] = 'M';
+$string['shortsize_3'] = 'L';
+$string['shortsize_4'] = 'XL';
+$string['shortsize_5'] = 'XXL';
+$string['sitesize_0'] = 'XS (~10MB; 3 courses, created in ~30 seconds)';
+$string['sitesize_1'] = 'S (~50MB; 8 courses, created in ~2 minutes)';
+$string['sitesize_2'] = 'M (~200MB; 73 courses, created in ~10 minutes)';
+$string['sitesize_3'] = 'L (~1\'5GB; 277 courses, created in ~1\'5 hours)';
+$string['sitesize_4'] = 'XL (~10GB; 1065 courses, created in ~5 hours)';
+$string['sitesize_5'] = 'XXL (~20GB; 4177 courses, created in ~10 hours)';
+$string['size'] = 'Size of course';
+$string['smallfiles'] = 'Small files';
diff --git a/admin/tool/generator/maketestcourse.php b/admin/tool/generator/maketestcourse.php
new file mode 100644 (file)
index 0000000..82af097
--- /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/>.
+
+/**
+ * Script creates a standardised large course for testing reliability and
+ * performance.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+// Disable buffering so that the progress output displays gradually without
+// needing to call flush().
+define('NO_OUTPUT_BUFFERING', true);
+
+require('../../../config.php');
+
+require_once($CFG->libdir . '/adminlib.php');
+
+// Initialise page and check permissions.
+admin_externalpage_setup('toolgenerator');
+
+// Start page.
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('maketestcourse', 'tool_generator'));
+
+// Information message.
+$context = context_system::instance();
+echo $OUTPUT->box(format_text(get_string('explanation', 'tool_generator'),
+        FORMAT_MARKDOWN, array('context' => $context)));
+
+// Check debugging is set to DEVELOPER.
+if (!debugging('', DEBUG_DEVELOPER)) {
+    echo $OUTPUT->notification(get_string('error_notdebugging', 'tool_generator'));
+    echo $OUTPUT->footer();
+    exit;
+}
+
+// Set up the form.
+$mform = new tool_generator_make_form('maketestcourse.php');
+if ($data = $mform->get_data()) {
+    // Do actual work.
+    echo $OUTPUT->heading(get_string('creating', 'tool_generator'));
+    $backend = new tool_generator_course_backend($data->shortname, $data->size);
+    $id = $backend->make();
+
+    echo html_writer::div(
+            html_writer::link(new moodle_url('/course/view.php', array('id' => $id)),
+                get_string('continue')));
+} else {
+    // Display form.
+    $mform->display();
+}
+
+// Finish page.
+echo $OUTPUT->footer();
diff --git a/admin/tool/generator/settings.php b/admin/tool/generator/settings.php
new file mode 100644 (file)
index 0000000..39a40ae
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Admin settings.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+if ($hassiteconfig) {
+    $ADMIN->add('development', new admin_externalpage('toolgenerator',
+            get_string('maketestcourse', 'tool_generator'),
+            $CFG->wwwroot . '/' . $CFG->admin . '/tool/generator/maketestcourse.php'));
+}
+
diff --git a/admin/tool/generator/tests/maketestcourse_test.php b/admin/tool/generator/tests/maketestcourse_test.php
new file mode 100644 (file)
index 0000000..b8637f4
--- /dev/null
@@ -0,0 +1,154 @@
+<?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/>.
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Automated unit testing. This tests the 'make large course' backend,
+ * using the 'XS' option so that it completes quickly.
+ *
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class tool_generator_maketestcourse_testcase extends advanced_testcase {
+    /**
+     * Creates a small test course and checks all the components have been put in place.
+     */
+    public function test_make_xs_course() {
+        global $DB;
+
+        $this->resetAfterTest();
+        $this->setAdminUser();
+
+        // Create the XS course.
+        $backend = new tool_generator_course_backend('TOOL_MAKELARGECOURSE_XS', 0, false, false);
+        $courseid = $backend->make();
+
+        // Get course details.
+        $course = get_course($courseid);
+        $context = context_course::instance($courseid);
+        $modinfo = get_fast_modinfo($course);
+
+        // Check sections (just section 0 plus one other).
+        $this->assertEquals(2, count($modinfo->get_section_info_all()));
+
+        // Check user is enrolled.
+        $users = get_enrolled_users($context);
+        $this->assertEquals(1, count($users));
+        $this->assertEquals('tool_generator_000001', reset($users)->username);
+
+        // Check there's a page on the course.
+        $pages = $modinfo->get_instances_of('page');
+        $this->assertEquals(1, count($pages));
+
+        // Check there are small files.
+        $resources = $modinfo->get_instances_of('resource');
+        $ok = false;
+        foreach ($resources as $resource) {
+            if ($resource->sectionnum == 0) {
+                // The one in section 0 is the 'small files' resource.
+                $ok = true;
+                break;
+            }
+        }
+        $this->assertTrue($ok);
+
+        // Check it contains 2 files (the default txt and a dat file).
+        $fs = get_file_storage();
+        $resourcecontext = context_module::instance($resource->id);
+        $files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
+        $files = array_values($files);
+        $this->assertEquals(2, count($files));
+        $this->assertEquals('resource1.txt', $files[0]->get_filename());
+        $this->assertEquals('smallfile0.dat', $files[1]->get_filename());
+
+        // Check there's a single 'big' file (it's actually only 8KB).
+        $ok = false;
+        foreach ($resources as $resource) {
+            if ($resource->sectionnum == 1) {
+                $ok = true;
+                break;
+            }
+        }
+        $this->assertTrue($ok);
+
+        // Check it contains 2 files.
+        $resourcecontext = context_module::instance($resource->id);
+        $files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
+        $files = array_values($files);
+        $this->assertEquals(2, count($files));
+        $this->assertEquals('bigfile0.dat', $files[0]->get_filename());
+        $this->assertEquals('resource2.txt', $files[1]->get_filename());
+
+        // Get forum and count the number of posts on it.
+        $forums = $modinfo->get_instances_of('forum');
+        $forum = reset($forums);
+        $posts = $DB->count_records_sql("
+                SELECT
+                    COUNT(1)
+                FROM
+                    {forum_posts} fp
+                    JOIN {forum_discussions} fd ON fd.id = fp.discussion
+                WHERE
+                    fd.forum = ?", array($forum->instance));
+        $this->assertEquals(2, $posts);
+    }
+
+    /**
+     * Creates an small test course with fixed data set and checks the used sections and users.
+     */
+    public function test_fixed_data_set() {
+        global $DB;
+
+        $this->resetAfterTest();
+        $this->setAdminUser();
+
+        // Create the S course (more sections and activities than XS).
+        $backend = new tool_generator_course_backend('TOOL_S_COURSE_1', 1, true, false);
+        $courseid = $backend->make();
+
+        // Get course details.
+        $course = get_course($courseid);
+        $modinfo = get_fast_modinfo($course);
+
+        // Check module instances belongs to section 1.
+        $instances = $modinfo->get_instances_of('page');
+        $npageinstances = count($instances);
+        foreach ($instances as $instance) {
+            $this->assertEquals(1, $instance->sectionnum);
+        }
+
+        // Users that started discussions are the same.
+        $forums = $modinfo->get_instances_of('forum');
+        $nforuminstances = count($forums);
+        $discussions = forum_get_discussions(reset($forums), 'd.timemodified ASC');
+        $lastusernumber = 0;
+        $discussionstarters = array();
+        foreach ($discussions as $discussion) {
+            $usernumber = intval($discussion->lastname);
+
+            // Checks that the users are odd numbers.
+            $this->assertEquals(1, $usernumber % 2);
+
+            // Checks that the users follows an increasing order.
+            $this->assertGreaterThan($lastusernumber, $usernumber);
+            $lastusernumber = $usernumber;
+            $discussionstarters[$discussion->userid] = $discussion->subject;
+        }
+
+    }
+}
index 0e01250..3733d98 100644 (file)
 /**
  * Version details.
  *
- * @package    tool
- * @subpackage generator
- * @copyright  2009 Nicolas Connault
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package tool_generator
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires  = 2013050100; // Requires this Moodle version
-$plugin->component = 'tool_generator'; // Full name of the plugin (used for diagnostics)
-
-$plugin->maturity  = MATURITY_ALPHA; // this version's maturity level
+$plugin->version = 2013090200;
+$plugin->requires = 2013090200;
+$plugin->component = 'tool_generator';
index e194219..87dee88 100644 (file)
@@ -23,7 +23,7 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$string['install'] = 'Install selected language pack';
+$string['install'] = 'Install selected language pack(s)';
 $string['installedlangs'] = 'Installed language packs';
 $string['langimport'] = 'Language import utility';
 $string['langimportdisabled'] = 'Language import feature has been disabled. You have to update your language packs manually at the file-system level. Do not forget to purge string caches after you do so.';
@@ -38,7 +38,7 @@ $string['nolangupdateneeded'] = 'All your language packs are up to date, no upda
 $string['pluginname'] = 'Language packs';
 $string['purgestringcaches'] = 'Purge string caches';
 $string['remotelangnotavailable'] = 'Because Moodle cannot connect to download.moodle.org, it is not possible for language packs to be installed automatically. Please download the appropriate ZIP file(s) from <a href="http://download.moodle.org/langpack/">download.moodle.org/langpack</a>, copy them to your {$a} directory and unzip them manually.';
-$string['uninstall'] = 'Uninstall selected language pack';
+$string['uninstall'] = 'Uninstall selected language pack(s)';
 $string['uninstallconfirm'] = 'You are about to completely uninstall language pack {$a}, are you sure?';
 $string['updatelangs'] = 'Update all installed language packs';
 
index f697f7e..f52bf6b 100644 (file)
@@ -34,7 +34,7 @@ $execute   = optional_param('execute', 0, PARAM_BOOL);
 navigation_node::override_active_url(new moodle_url('/admin/tool/phpunit/index.php'));
 admin_externalpage_setup('toolphpunitwebrunner');
 
-if (!debugging('', DEBUG_DEVELOPER)) {
+if (!$CFG->debugdeveloper) {
     error('Not available on production sites, sorry.');
 }
 
@@ -82,7 +82,7 @@ if ($execute) {
         if ($code != 0) {
             tool_phpunit_problem('Can not initialize database');
         }
-        $CFG->debug = 0; // no pesky redirect warning, we really want to redirect
+        set_debugging(DEBUG_NONE, false); // Hack: no redirect warning, we really want to redirect.
         redirect(new moodle_url($PAGE->url, array('execute'=>1, 'tespath'=>$testpath, 'testclass'=>$testclass, 'sesskey'=>sesskey())), 'Reloading page');
         echo $OUTPUT->footer();
         die();
@@ -103,7 +103,7 @@ if ($execute) {
         if ($code != 0) {
             tool_phpunit_problem('Can not initialize database');
         }
-        $CFG->debug = 0; // no pesky redirect warning, we really want to redirect
+        set_debugging(DEBUG_NONE, false); // Hack: no redirect warning, we really want to redirect.
         redirect(new moodle_url($PAGE->url, array('execute'=>1, 'tespath'=>$testpath, 'testclass'=>$testclass, 'sesskey'=>sesskey())), 'Reloading page');
         die();
 
index ebd0b75..2873f3b 100644 (file)
@@ -37,31 +37,6 @@ require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
  */
 class tool_uploadcourse_helper {
 
-    /**
-     * Remove the restore content from disk and cache.
-     *
-     * @return void
-     */
-    public static function clean_restore_content() {
-        global $CFG;
-
-        // There are some sloppy unclosed file handles in backup/restore code,
-        // let's hope somebody unset all controllers before calling this
-        // and destroy magic will close all remaining open file handles,
-        // otherwise Windows will fail deleting the directory.
-        gc_collect_cycles();
-
-        if (!empty($CFG->keeptempdirectoriesonbackup)) {
-            $cache = cache::make('tool_uploadcourse', 'helper');
-            $backupids = (array) $cache->get('backupids');
-            foreach ($backupids as $cachekey => $backupid) {
-                $cache->delete($cachekey);
-                fulldelete("$CFG->tempdir/backup/$backupid/");
-            }
-            $cache->delete('backupids');
-        }
-    }
-
     /**
      * Generate a shortname based on a template.
      *
@@ -216,7 +191,9 @@ class tool_uploadcourse_helper {
      * Get the restore content tempdir.
      *
      * The tempdir is the sub directory in which the backup has been extracted.
-     * This caches the result for better performance.
+     *
+     * This caches the result for better performance, but $CFG->keeptempdirectoriesonbackup
+     * needs to be enabled, otherwise the cache is ignored.
      *
      * @param string $backupfile path to a backup file.
      * @param string $shortname shortname of a course.
@@ -229,6 +206,10 @@ class tool_uploadcourse_helper {
         $cachekey = null;
         if (!empty($backupfile)) {
             $backupfile = realpath($backupfile);
+            if (empty($backupfile) || !is_readable($backupfile)) {
+                $errors['cannotreadbackupfile'] = new lang_string('cannotreadbackupfile', 'tool_uploadcourse');
+                return false;
+            }
             $cachekey = 'backup_path:' . $backupfile;
         } else if (!empty($shortname) || is_numeric($shortname)) {
             $cachekey = 'backup_sn:' . $shortname;
@@ -238,23 +219,27 @@ class tool_uploadcourse_helper {
             return false;
         }
 
-        $cache = cache::make('tool_uploadcourse', 'helper');
-        if (($backupid = $cache->get($cachekey)) === false) {
-            // Use false instead of null because it would consider that the cache
-            // key has not been set.
-            $backupid = false;
+        // If $CFG->keeptempdirectoriesonbackup is not set to true, any restore happening would
+        // automatically delete the backup directory... causing the cache to return an unexisting directory.
+        $usecache = !empty($CFG->keeptempdirectoriesonbackup);
+        if ($usecache) {
+            $cache = cache::make('tool_uploadcourse', 'helper');
+        }
+
+        // If we don't use the cache, or if we do and not set, or the directory doesn't exist any more.
+        if (!$usecache || (($backupid = $cache->get($cachekey)) === false || !is_dir("$CFG->tempdir/backup/$backupid"))) {
+
+            // Use null instead of false because it would consider that the cache key has not been set.
+            $backupid = null;
+
             if (!empty($backupfile)) {
-                if (!is_readable($backupfile)) {
-                    $errors['cannotreadbackupfile'] = new lang_string('cannotreadbackupfile', 'tool_uploadcourse');
-                } else {
-                    // Extracting the backup file.
-                    $packer = get_file_packer('application/vnd.moodle.backup');
-                    $backupid = restore_controller::get_tempdir_name(SITEID, $USER->id);
-                    $path = "$CFG->tempdir/backup/$backupid/";
-                    $result = $packer->extract_to_pathname($backupfile, $path);
-                    if (!$result) {
-                        $errors['invalidbackupfile'] = new lang_string('invalidbackupfile', 'tool_uploadcourse');
-                    }
+                // Extracting the backup file.
+                $packer = get_file_packer('application/vnd.moodle.backup');
+                $backupid = restore_controller::get_tempdir_name(SITEID, $USER->id);
+                $path = "$CFG->tempdir/backup/$backupid/";
+                $result = $packer->extract_to_pathname($backupfile, $path);
+                if (!$result) {
+                    $errors['invalidbackupfile'] = new lang_string('invalidbackupfile', 'tool_uploadcourse');
                 }
             } else if (!empty($shortname) || is_numeric($shortname)) {
                 // Creating restore from an existing course.
@@ -270,14 +255,15 @@ class tool_uploadcourse_helper {
                         new lang_string('coursetorestorefromdoesnotexist', 'tool_uploadcourse');
                 }
             }
-            $cache->set($cachekey, $backupid);
 
-            // Store all the directories to be able to remove them in self::clean_restore_content().
-            $backupids = (array) $cache->get('backupids');
-            $backupids[$cachekey] = $backupid;
-            $cache->set('backupids', $backupids);
+            if ($usecache) {
+                $cache->set($cachekey, $backupid);
+            }
         }
 
+        if ($backupid === null) {
+            $backupid = false;
+        }
         return $backupid;
     }
 
index 94ab8a7..79b10ed 100644 (file)
@@ -223,8 +223,6 @@ class tool_uploadcourse_processor {
 
         $tracker->finish();
         $tracker->results($total, $created, $updated, $deleted, $errors);
-
-        $this->remove_restore_content();
     }
 
     /**
@@ -349,20 +347,10 @@ class tool_uploadcourse_processor {
         }
 
         $tracker->finish();
-        $this->remove_restore_content();
 
         return $preview;
     }
 
-    /**
-     * Delete the restore object.
-     *
-     * @return void
-     */
-    protected function remove_restore_content() {
-        tool_uploadcourse_helper::clean_restore_content();
-    }
-
     /**
      * Reset the current process.
      *
index 7464e4e..32886ef 100644 (file)
@@ -58,11 +58,12 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
         $mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE);
         $mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_UPDATE_ONLY);
 
+        // Restore file is not in the array options on purpose, because formslib can't handle it!
         $contextid = $this->_customdata['contextid'];
         $mform->addElement('hidden', 'contextid', $contextid);
         $mform->setType('contextid', PARAM_INT);
-        $mform->addElement('filepicker', 'options[restorefile]', get_string('templatefile', 'tool_uploadcourse'));
-        $mform->addHelpButton('options[restorefile]', 'templatefile', 'tool_uploadcourse');
+        $mform->addElement('filepicker', 'restorefile', get_string('templatefile', 'tool_uploadcourse'));
+        $mform->addHelpButton('restorefile', 'templatefile', 'tool_uploadcourse');
 
         $mform->addElement('text', 'options[templatecourse]', get_string('coursetemplatename', 'tool_uploadcourse'));
         $mform->setType('options[templatecourse]', PARAM_TEXT);
@@ -188,33 +189,4 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
         $mform->closeHeaderBefore('buttonar');
     }
 
-    /**
-     * Server side validation.
-     * @param array $data - form data
-     * @param object $files  - form files
-     * @return array $errors - form errors
-     */
-    public function validation($data, $files) {
-        $errors = parent::validation($data, $files);
-        $columns = $this->_customdata['columns'];
-        $optype  = $data['options']['mode'];
-
-        // Look for other required data.
-        if ($optype != tool_uploadcourse_processor::MODE_UPDATE_ONLY) {
-            if (!in_array('fullname', $columns)) {
-                if (isset($errors['mode'])) {
-                    $errors['mode'] .= ' ';
-                }
-                $errors['mode'] .= get_string('missingfield', 'error', 'fullname');
-            }
-            if (!in_array('summary', $columns)) {
-                if (isset($errors['mode'])) {
-                    $errors['mode'] .= ' ';
-                }
-                $errors['mode'] .= get_string('missingfield', 'error', 'summary');
-            }
-        }
-
-        return $errors;
-    }
 }
index 667551e..0f290e2 100644 (file)
@@ -78,6 +78,13 @@ if ($form2data = $mform2->is_cancelled()) {
 
     $options = (array) $form2data->options;
     $defaults = (array) $form2data->defaults;
+
+    // Restorefile deserves its own logic because formslib does not really appreciate
+    // when the name of a filepicker is an array...
+    $options['restorefile'] = '';
+    if (!empty($form2data->restorefile)) {
+        $options['restorefile'] = $mform2->save_temp_file('restorefile');
+    }
     $processor = new tool_uploadcourse_processor($cir, $options, $defaults);
 
     echo $OUTPUT->header();
@@ -91,6 +98,11 @@ if ($form2data = $mform2->is_cancelled()) {
         echo $OUTPUT->continue_button($returnurl);
     }
 
+    // Deleting the file after processing or preview.
+    if (!empty($options['restorefile'])) {
+        @unlink($options['restorefile']);
+    }
+
 } else {
     $processor = new tool_uploadcourse_processor($cir, $form1data->options, array());
     echo $OUTPUT->header();
index 3be7ec4..999ca70 100644 (file)
@@ -99,7 +99,7 @@ $string['shortnametemplate_help'] = 'The short name of the course is displayed i
 $string['templatefile'] = 'Restore from this file after upload';
 $string['templatefile_help'] = 'Select a file to use as a template for the creation of all courses.';
 $string['unknownimportmode'] = 'Unknown import mode';
-$string['updatemissing'] = 'Fill in missing from CSV data and defaults';
+$string['updatemissing'] = 'Fill in missing items from CSV data and defaults';
 $string['updatemode'] = 'Update mode';
 $string['updatemodedoessettonothing'] = 'Update mode does not allow anything to be updated';
 $string['updateonly'] = 'Only update existing courses';
index ee979b4..3459c4a 100644 (file)
@@ -635,6 +635,23 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         }
         $this->assertTrue($found);
 
+        // Restoring twice from the same course should work.
+        $data = array('shortname' => 'B1', 'templatecourse' => $c1->shortname, 'summary' => 'B', 'category' => 1,
+            'fullname' => 'B1');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertTrue($co->prepare());
+        $co->proceed();
+        $course = $DB->get_record('course', array('shortname' => 'B1'));
+        $modinfo = get_fast_modinfo($course);
+        $found = false;
+        foreach ($modinfo->get_cms() as $cmid => $cm) {
+            if ($cm->modname == 'forum' && $cm->name == $c1f1->name) {
+                $found = true;
+                break;
+            }
+        }
+        $this->assertTrue($found);
+
         // Restore the time limit to prevent warning.
         set_time_limit(0);
     }
@@ -668,6 +685,25 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         }
         $this->assertTrue($found);
 
+        // Restoring twice from the same file should work.
+        $data = array('shortname' => 'B1', 'backupfile' => __DIR__ . '/fixtures/backup.mbz',
+            'summary' => 'B', 'category' => 1, 'fullname' => 'B1');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertTrue($co->prepare());
+        $co->proceed();
+        $course = $DB->get_record('course', array('shortname' => 'B1'));
+        $modinfo = get_fast_modinfo($course);
+        $found = false;
+        foreach ($modinfo->get_cms() as $cmid => $cm) {
+            if ($cm->modname == 'glossary' && $cm->name == 'Imported Glossary') {
+                $found = true;
+            } else if ($cm->modname == 'forum' && $cm->name == $c1f1->name) {
+                // We should not find this!
+                $this->assertTrue(false);
+            }
+        }
+        $this->assertTrue($found);
+
         // Restore the time limit to prevent warning.
         set_time_limit(0);
     }
index 31e53e0..ae42a1e 100644 (file)
@@ -141,6 +141,9 @@ class tool_uploadcourse_helper_testcase extends advanced_testcase {
         $bc->destroy();
         unset($bc); // File logging is a mess, we can only try to rely on gc to close handles.
 
+        $oldcfg = isset($CFG->keeptempdirectoriesonbackup) ? $CFG->keeptempdirectoriesonbackup : false;
+        $CFG->keeptempdirectoriesonbackup = true;
+
         // Checking restore dir.
         $dir = tool_uploadcourse_helper::get_restore_content_dir($c1backupfile, null);
         $bcinfo = backup_general_helper::get_backup_information($dir);
@@ -179,18 +182,26 @@ class tool_uploadcourse_helper_testcase extends advanced_testcase {
         $this->assertFalse($dir);
         $this->assertArrayHasKey('coursetorestorefromdoesnotexist', $errors);
 
-        // Cleaning content directories.
-        $oldcfg = isset($CFG->keeptempdirectoriesonbackup) ? $CFG->keeptempdirectoriesonbackup : false;
-        $dir = "$CFG->tempdir/backup/$dir";
-        $this->assertTrue(file_exists($dir));
-
+        // Trying again without caching. $CFG->keeptempdirectoriesonbackup is required for caching.
         $CFG->keeptempdirectoriesonbackup = false;
-        tool_uploadcourse_helper::clean_restore_content();
-        $this->assertTrue(file_exists($dir));
 
-        $CFG->keeptempdirectoriesonbackup = true;
-        tool_uploadcourse_helper::clean_restore_content();
-        $this->assertFalse(file_exists($dir));
+        // Checking restore dir.
+        $dir = tool_uploadcourse_helper::get_restore_content_dir($c1backupfile, null);
+        $dir2 = tool_uploadcourse_helper::get_restore_content_dir($c1backupfile, null);
+        $this->assertNotEquals($dir, $dir2);
+
+        // Checking with a shortname.
+        $dir = tool_uploadcourse_helper::get_restore_content_dir(null, $c1->shortname);
+        $dir2 = tool_uploadcourse_helper::get_restore_content_dir(null, $c1->shortname);
+        $this->assertNotEquals($dir, $dir2);
+
+        // Get a course that does not exist.
+        $errors = array();
+        $dir = tool_uploadcourse_helper::get_restore_content_dir(null, 'DoesNotExist', $errors);
+        $this->assertFalse($dir);
+        $this->assertArrayHasKey('coursetorestorefromdoesnotexist', $errors);
+        $dir2 = tool_uploadcourse_helper::get_restore_content_dir(null, 'DoesNotExist', $errors);
+        $this->assertEquals($dir, $dir2);
 
         $CFG->keeptempdirectoriesonbackup = $oldcfg;
 
index c052d1c..7949d94 100644 (file)
@@ -27,6 +27,7 @@ require('../../../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/csvlib.class.php');
 require_once($CFG->dirroot.'/user/profile/lib.php');
+require_once($CFG->dirroot.'/user/lib.php');
 require_once($CFG->dirroot.'/group/lib.php');
 require_once($CFG->dirroot.'/cohort/lib.php');
 require_once('locallib.php');
@@ -654,9 +655,8 @@ if ($formdata = $mform2->is_cancelled()) {
             }
 
             if ($doupdate or $existinguser->password !== $oldpw) {
-                // we want only users that were really updated
-
-                $DB->update_record('user', $existinguser);
+                // We want only users that were really updated.
+                user_update_user($existinguser, false);
 
                 $upt->track('status', $struserupdated);
                 $usersupdated++;
@@ -668,8 +668,6 @@ if ($formdata = $mform2->is_cancelled()) {
                     profile_save_data($existinguser);
                 }
 
-                events_trigger('user_updated', $existinguser);
-
                 if ($bulk == UU_BULK_UPDATED or $bulk == UU_BULK_ALL) {
                     if (!in_array($user->id, $SESSION->bulk_users)) {
                         $SESSION->bulk_users[] = $user->id;
@@ -789,8 +787,7 @@ if ($formdata = $mform2->is_cancelled()) {
                 $upt->track('password', '-', 'normal', false);
             }
 
-            // create user - insert_record ignores any extra properties
-            $user->id = $DB->insert_record('user', $user);
+            $user->id = user_create_user($user, false);
             $upt->track('username', html_writer::link(new moodle_url('/user/profile.php', array('id'=>$user->id)), s($user->username)), 'normal', false);
 
             // pre-process custom profile menu fields data from csv file
@@ -812,8 +809,6 @@ if ($formdata = $mform2->is_cancelled()) {
             // make sure user context exists
             context_user::instance($user->id);
 
-            events_trigger('user_created', $user);
-
             if ($bulk == UU_BULK_NEW or $bulk == UU_BULK_ALL) {
                 if (!in_array($user->id, $SESSION->bulk_users)) {
                     $SESSION->bulk_users[] = $user->id;
index 4dfc221..040cf3a 100644 (file)
@@ -33,24 +33,38 @@ $string['confirmdeleteindex'] = 'Are you absolutely sure that you want to delete
 $string['confirmdeletekey'] = 'Are you absolutely sure that you want to delete the key:';
 $string['confirmdeletetable'] = 'Are you absolutely sure that you want to delete the table:';
 $string['confirmdeletexmlfile'] = 'Are you absolutely sure that you want to delete the file:';
-$string['confirmcheckbigints'] = 'This functionality will search for <a href="http://tracker.moodle.org/browse/MDL-11038">potential wrong integer fields</a> in your Moodle server, generating (but not executing!) automatically the needed SQL statements to have all the integers in your DB properly defined.<br /><br />
-Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).<br /><br />
-It\'s highly recommended to be running the latest (+ version) available of your Moodle release (1.8, 1.9, 2.x ...) before executing the search of wrong integers.<br /><br />
+$string['confirmcheckbigints'] = 'This functionality will search for <a href="http://tracker.moodle.org/browse/MDL-11038">potential wrong integer fields</a> in your Moodle server, generating (but not executing!) automatically the needed SQL statements to have all the integers in your DB properly defined.
+
+Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).
+
+It\'s highly recommended to be running the latest (+ version) available of your Moodle release before executing the search of wrong integers.
+
 This functionality doesn\'t perform any action against the DB (just reads from it), so can be safely executed at any moment.';
-$string['confirmcheckdefaults'] = 'This functionality will search for inconsistent default values in your Moodle server, generating (but not executing!) the needed SQL statements to have all the default values properly defined.<br /><br />
-Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).<br /><br />
-It\'s highly recommended to be running the latest (+ version) available of your Moodle release (1.8, 1.9, 2.x ...) before executing the search of inconsistent default values.<br /><br />
+$string['confirmcheckdefaults'] = 'This functionality will search for inconsistent default values in your Moodle server, generating (but not executing!) the needed SQL statements to have all the default values properly defined.
+
+Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).
+
+It\'s highly recommended to be running the latest (+ version) available of your Moodle release before executing the search of inconsistent default values.
+
 This functionality doesn\'t perform any action against the DB (just reads from it), so can be safely executed at any moment.';
-$string['confirmcheckforeignkeys'] = 'This functionality will search for potential violations of the foreign keys defined in the install.xml definitions. (Moodle does not currently generate actual foreign key constraints in the database, which is why invalid data may be present.)<br /><br />
-It\'s highly recommended to be running the latest (+ version) available of your Moodle release (1.8, 1.9, 2.x ...) before executing the search of missing indexes.<br /><br />
+$string['confirmcheckforeignkeys'] = 'This functionality will search for potential violations of the foreign keys defined in the install.xml definitions. (Moodle does not currently generate actual foreign key constraints in the database, which is why invalid data may be present.)
+
+It\'s highly recommended to be running the latest (+ version) available of your Moodle release before executing the search of missing indexes.
+
 This functionality doesn\'t perform any action against the DB (just reads from it), so can be safely executed at any moment.';
-$string['confirmcheckindexes'] = 'This functionality will search for potential missing indexes in your Moodle server, generating (but not executing!) automatically the needed SQL statements to keep everything updated.<br /><br />
-Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).<br /><br />
-It\'s highly recommended to be running the latest (+ version) available of your Moodle release (1.8, 1.9, 2.x ...) before executing the search of missing indexes.<br /><br />
+$string['confirmcheckindexes'] = 'This functionality will search for potential missing indexes in your Moodle server, generating (but not executing!) automatically the needed SQL statements to keep everything updated.
+
+Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).
+
+It\'s highly recommended to be running the latest (+ version) available of your Moodle release before executing the search of missing indexes.
+
 This functionality doesn\'t perform any action against the DB (just reads from it), so can be safely executed at any moment.';
-$string['confirmcheckoraclesemantics'] = 'This functionality will search for <a href="http://tracker.moodle.org/browse/MDL-29322">Oracle varchar2 columns using BYTE semantics</a> in your Moodle server, generating (but not executing!) automatically the needed SQL statements to have all the columns converted to use CHAR semantics instead (better for cross-db compatibility and increased contents max. length).<br /><br />
-Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).<br /><br />
-It\'s highly recommended to be running the latest (+ version) available of your Moodle release (2.2, 2.3, 2.x ...) before executing the search of BYTE semantics.<br /><br />
+$string['confirmcheckoraclesemantics'] = 'This functionality will search for <a href="http://tracker.moodle.org/browse/MDL-29322">Oracle varchar2 columns using BYTE semantics</a> in your Moodle server, generating (but not executing!) automatically the needed SQL statements to have all the columns converted to use CHAR semantics instead (better for cross-db compatibility and increased contents max. length).
+
+Once generated you can copy such statements and execute them safely with your favourite SQL interface (don\'t forget to backup your data before doing that).
+
+It\'s highly recommended to be running the latest (+ version) available of your Moodle release before executing the search of BYTE semantics.
+
 This functionality doesn\'t perform any action against the DB (just reads from it), so can be safely executed at any moment.';
 $string['confirmrevertchanges'] = 'Are you absolutely sure that you want to revert changes performed over:';
 $string['create'] = 'Create';
index 0f66603..699babb 100644 (file)
@@ -4,6 +4,7 @@
     require_once($CFG->libdir.'/adminlib.php');
     require_once($CFG->libdir.'/authlib.php');
     require_once($CFG->dirroot.'/user/filters/lib.php');
+    require_once($CFG->dirroot.'/user/lib.php');
 
     $delete       = optional_param('delete', 0, PARAM_INT);
     $confirm      = optional_param('confirm', '', PARAM_ALPHANUM);   //md5 confirmation hash
         if ($user = $DB->get_record('user', array('id'=>$suspend, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0))) {
             if (!is_siteadmin($user) and $USER->id != $user->id and $user->suspended != 1) {
                 $user->suspended = 1;
-                $user->timemodified = time();
-                $DB->set_field('user', 'suspended', $user->suspended, array('id'=>$user->id));
-                $DB->set_field('user', 'timemodified', $user->timemodified, array('id'=>$user->id));
-                // force logout
+                // Force logout.
                 session_kill_user($user->id);
-                events_trigger('user_updated', $user);
+                user_update_user($user, false);
             }
         }
         redirect($returnurl);
         if ($user = $DB->get_record('user', array('id'=>$unsuspend, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0))) {
             if ($user->suspended != 0) {
                 $user->suspended = 0;
-                $user->timemodified = time();
-                $DB->set_field('user', 'suspended', $user->suspended, array('id'=>$user->id));
-                $DB->set_field('user', 'timemodified', $user->timemodified, array('id'=>$user->id));
-                events_trigger('user_updated', $user);
+                user_update_user($user, false);
             }
         }
         redirect($returnurl);
index b1c09ae..3aef57c 100644 (file)
@@ -73,12 +73,17 @@ class external_service_form extends moodleform {
         $mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice');
         $mform->setType('restrictedusers', PARAM_BOOL);
 
-        //can users download files
+        // Can users download files?
         $mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice'));
         $mform->setAdvanced('downloadfiles');
         $mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice');
         $mform->setType('downloadfiles', PARAM_BOOL);
 
+        // Can users upload files?
+        $mform->addElement('advcheckbox', 'uploadfiles', get_string('uploadfiles', 'webservice'));
+        $mform->setAdvanced('uploadfiles');
+        $mform->addHelpButton('uploadfiles', 'uploadfiles', 'webservice');
+
         /// needed to select automatically the 'No required capability" option
         $currentcapabilityexist = false;
         if (empty($service->requiredcapability)) {
@@ -297,4 +302,4 @@ class web_service_token_form extends moodleform {
         return $errors;
     }
 
-}
\ No newline at end of file
+}
index 33cf33a..a02c32f 100644 (file)
@@ -48,7 +48,7 @@ require(dirname(dirname(dirname(dirname(__FILE__)))).'/config.php');
 require_once($CFG->dirroot.'/course/lib.php');
 
 // Ensure errors are well explained
-$CFG->debug = DEBUG_NORMAL;
+set_debugging(DEBUG_DEVELOPER, true);
 
 if (!is_enabled_auth('cas')) {
     error_log('[AUTH CAS] '.get_string('pluginnotenabled', 'auth_ldap'));
index de5061d..a01fc6e 100644 (file)
@@ -284,6 +284,7 @@ class auth_plugin_db extends auth_plugin_base {
             $remove_users = $DB->get_records_sql($sql, $params);
 
             if (!empty($remove_users)) {
+                require_once($CFG->dirroot.'/user/lib.php');
                 $trace->output(get_string('auth_dbuserstoremove','auth_db', count($remove_users)));
 
                 foreach ($remove_users as $user) {
@@ -294,8 +295,7 @@ class auth_plugin_db extends auth_plugin_base {
                         $updateuser = new stdClass();
                         $updateuser->id   = $user->id;
                         $updateuser->suspended = 1;
-                        $updateuser->timemodified = time();
-                        $DB->update_record('user', $updateuser);
+                        user_update_user($updateuser, false);
                         $trace->output(get_str