Merge branch 'MDL-39776-master' of git://github.com/phalacee/moodle
authorDan Poltawski <dan@moodle.com>
Wed, 9 Oct 2013 08:54:02 +0000 (16:54 +0800)
committerDan Poltawski <dan@moodle.com>
Wed, 9 Oct 2013 08:54:02 +0000 (16:54 +0800)
471 files changed:
admin/auth.php
admin/blocks.php
admin/cli/install.php
admin/cli/install_database.php
admin/cli/upgrade.php
admin/courseformats.php
admin/editors.php
admin/enrol.php
admin/filters.php
admin/index.php
admin/localplugins.php
admin/message.php
admin/modules.php
admin/plagiarism.php
admin/plugins.php
admin/portfolio.php
admin/qbehaviours.php
admin/qtypes.php
admin/renderer.php
admin/reports.php
admin/repository.php
admin/repositoryinstance.php
admin/roles/assign.php
admin/roles/permissions.php
admin/settings/courses.php
admin/settings/plugins.php
admin/settings/security.php
admin/tool/behat/cli/util.php
admin/tool/behat/tests/behat/basic_actions.feature
admin/tool/behat/tests/behat/data_generators.feature
admin/tool/behat/tests/behat/manipulate_forms.feature
admin/tool/dbtransfer/locallib.php
admin/tool/installaddon/classes/installer.php
admin/tool/phpunit/cli/util.php
admin/tool/qeupgradehelper/locallib.php
admin/tool/uploadcourse/classes/course.php
admin/tool/uploadcourse/classes/processor.php
admin/tool/uploadcourse/tests/course_test.php
admin/tool/uploaduser/user_form.php
admin/tools.php
auth/cas/version.php
auth/db/auth.php
auth/test_settings.php [new file with mode: 0644]
backup/backup.php
backup/cc/cc_lib/gral_lib/cssparser.php
backup/moodle2/backup_stepslib.php
backup/moodle2/restore_stepslib.php
backup/util/dbops/backup_controller_dbops.class.php
backup/util/dbops/restore_dbops.class.php
backup/util/helper/backup_helper.class.php
backup/util/includes/backup_includes.php
backup/util/ui/backup_ui_stage.class.php
badges/ajax.php
badges/assertion.php
badges/backpackconnect.php
badges/criteria/award_criteria_courseset.php
badges/index.php
badges/newbadge.php
badges/renderer.php
badges/view.php
blocks/calendar_month/block_calendar_month.php
blocks/calendar_upcoming/block_calendar_upcoming.php
blocks/community/communitycourse.php
blocks/community/forms.php
blocks/feedback/version.php
blocks/glossary_random/version.php
blocks/quiz_results/version.php
blocks/search_forums/version.php
calendar/classes/type_base.php
calendar/classes/type_factory.php
calendar/delete.php
calendar/event.php
calendar/export.php
calendar/export_execute.php
calendar/lib.php
calendar/preferences.php
calendar/renderer.php
calendar/tests/behat/behat_calendar.php [new file with mode: 0644]
calendar/tests/behat/calendar.feature [new file with mode: 0644]
calendar/tests/calendartype_test.php
calendar/tests/calendartype_test_example.php
calendar/type/gregorian/classes/structure.php
calendar/type/gregorian/version.php
calendar/view.php
calendar/yui/build/moodle-calendar-eventmanager/assets/skins/sam/eventmanager.css [deleted file]
config-dist.php
course/ajax/management.php [new file with mode: 0644]
course/category.php
course/classes/deletecategory_form.php [new file with mode: 0644]
course/classes/editcategory_form.php [new file with mode: 0644]
course/classes/management/helper.php [new file with mode: 0644]
course/classes/management_renderer.php [new file with mode: 0644]
course/delete.php
course/delete_category_form.php
course/edit.php
course/editcategory.php
course/editcategory_form.php
course/format/lib.php
course/format/singleactivity/lib.php
course/format/singleactivity/settingslib.php
course/format/singleactivity/styles.css
course/lib.php
course/manage.php
course/management.php [new file with mode: 0644]
course/moodleform_mod.php
course/renderer.php
course/request.php
course/search.php
course/tests/behat/behat_course.php
course/tests/behat/category_change_visibility.feature [new file with mode: 0644]
course/tests/behat/category_management.feature [new file with mode: 0644]
course/tests/behat/category_resort.feature [new file with mode: 0644]
course/tests/behat/course_category_management_listing.feature [new file with mode: 0644]
course/tests/behat/course_change_visibility.feature [new file with mode: 0644]
course/tests/behat/course_resort.feature [new file with mode: 0644]
course/tests/courselib_test.php
course/tests/fixtures/course_capability_assignment.php [new file with mode: 0644]
course/tests/management_helper_test.php [new file with mode: 0644]
course/yui/build/moodle-course-management/moodle-course-management-debug.js [new file with mode: 0644]
course/yui/build/moodle-course-management/moodle-course-management-min.js [new file with mode: 0644]
course/yui/build/moodle-course-management/moodle-course-management.js [new file with mode: 0644]
course/yui/src/management/build.json [new file with mode: 0644]
course/yui/src/management/js/category.js [new file with mode: 0644]
course/yui/src/management/js/console.js [new file with mode: 0644]
course/yui/src/management/js/course.js [new file with mode: 0644]
course/yui/src/management/js/dd.js [new file with mode: 0644]
course/yui/src/management/js/item.js [new file with mode: 0644]
course/yui/src/management/meta/management.json [new file with mode: 0644]
enrol/cohort/lib.php
enrol/database/lib.php
enrol/imsenterprise/lib.php
enrol/imsenterprise/tests/imsenterprise_test.php
enrol/instances.php
enrol/manual/edit_form.php
enrol/paypal/edit_form.php
enrol/self/edit_form.php
enrol/test_settings.php [new file with mode: 0644]
files/coursefilesedit_form.php
files/tests/behat/course_files.feature [new file with mode: 0644]
filter/manage.php
grade/edit/tree/grade.php
grade/lib.php
lang/en/admin.php
lang/en/auth.php
lang/en/enrol.php
lang/en/error.php
lang/en/moodle.php
lang/en/notes.php
lang/en/question.php
lib/adminlib.php
lib/classes/component.php
lib/classes/event/note_created.php [new file with mode: 0644]
lib/classes/event/note_deleted.php [new file with mode: 0644]
lib/classes/event/note_updated.php [new file with mode: 0644]
lib/classes/event/notes_viewed.php [new file with mode: 0644]
lib/classes/plugin_manager.php [new file with mode: 0644]
lib/classes/plugininfo/auth.php [new file with mode: 0644]
lib/classes/plugininfo/base.php [new file with mode: 0644]
lib/classes/plugininfo/block.php [new file with mode: 0644]
lib/classes/plugininfo/cachelock.php [new file with mode: 0644]
lib/classes/plugininfo/cachestore.php [new file with mode: 0644]
lib/classes/plugininfo/calendartype.php [new file with mode: 0644]
lib/classes/plugininfo/coursereport.php [new file with mode: 0644]
lib/classes/plugininfo/editor.php [new file with mode: 0644]
lib/classes/plugininfo/enrol.php [new file with mode: 0644]
lib/classes/plugininfo/filter.php [new file with mode: 0644]
lib/classes/plugininfo/format.php [new file with mode: 0644]
lib/classes/plugininfo/general.php [new file with mode: 0644]
lib/classes/plugininfo/gradeexport.php [new file with mode: 0644]
lib/classes/plugininfo/gradeimport.php [new file with mode: 0644]
lib/classes/plugininfo/gradereport.php [new file with mode: 0644]
lib/classes/plugininfo/gradingform.php [new file with mode: 0644]
lib/classes/plugininfo/local.php [new file with mode: 0644]
lib/classes/plugininfo/message.php [new file with mode: 0644]
lib/classes/plugininfo/mnetservice.php [new file with mode: 0644]
lib/classes/plugininfo/mod.php [new file with mode: 0644]
lib/classes/plugininfo/plagiarism.php [new file with mode: 0644]
lib/classes/plugininfo/portfolio.php [new file with mode: 0644]
lib/classes/plugininfo/profilefield.php [new file with mode: 0644]
lib/classes/plugininfo/qbehaviour.php [new file with mode: 0644]
lib/classes/plugininfo/qformat.php [new file with mode: 0644]
lib/classes/plugininfo/qtype.php [new file with mode: 0644]
lib/classes/plugininfo/report.php [new file with mode: 0644]
lib/classes/plugininfo/repository.php [new file with mode: 0644]
lib/classes/plugininfo/theme.php [new file with mode: 0644]
lib/classes/plugininfo/tool.php [new file with mode: 0644]
lib/classes/plugininfo/webservice.php [new file with mode: 0644]
lib/classes/session/database.php
lib/classes/shutdown_manager.php [new file with mode: 0644]
lib/classes/text.php
lib/classes/update/checker.php [new file with mode: 0644]
lib/classes/update/checker_exception.php [new file with mode: 0644]
lib/classes/update/deployer.php [new file with mode: 0644]
lib/classes/update/info.php [new file with mode: 0644]
lib/completionlib.php
lib/coursecatlib.php
lib/cronlib.php
lib/db/caches.php
lib/db/install.xml [changed mode: 0644->0755]
lib/db/services.php
lib/db/upgrade.php
lib/deprecatedlib.php
lib/dml/moodle_database.php
lib/editor/atto/classes/plugininfo/atto.php [new file with mode: 0644]
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-debug.js
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button-min.js
lib/editor/atto/plugins/title/yui/build/moodle-atto_title-button/moodle-atto_title-button.js
lib/editor/atto/plugins/title/yui/src/button/js/button.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js
lib/editor/atto/yui/src/editor/js/editor.js
lib/editor/tinymce/adminlib.php
lib/editor/tinymce/classes/plugininfo/tinymce.php [new file with mode: 0644]
lib/editor/tinymce/settings.php
lib/editor/tinymce/subplugins.php
lib/editorlib.php
lib/enrollib.php
lib/filebrowser/file_info_context_course.php
lib/filelib.php
lib/filestorage/file_storage.php
lib/filestorage/stored_file.php
lib/filestorage/tests/file_storage_test.php
lib/form/dateselector.php
lib/form/datetimeselector.php
lib/form/htmleditor.php
lib/moodlelib.php
lib/navigationlib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/pear/HTML/QuickForm.php
lib/phpmailer/moodle_phpmailer.php
lib/phpunit/classes/util.php
lib/pluginlib.php
lib/setup.php
lib/setuplib.php
lib/tests/behat/behat_general.php
lib/tests/component_test.php
lib/tests/coursecatlib_test.php
lib/tests/datalib_test.php
lib/tests/editorlib_test.php [new file with mode: 0644]
lib/tests/messagelib_test.php
lib/tests/moodlelib_test.php
lib/tests/plugin_manager_test.php
lib/tests/text_test.php
lib/tests/update_checker_test.php [moved from lib/tests/available_update_checker_test.php with 97% similarity]
lib/tests/update_deployer_test.php [moved from lib/tests/available_update_deployer_test.php with 91% similarity]
lib/upgrade.txt
lib/upgradelib.php
lib/weblib.php
lib/yui/build/moodle-core-dock-loader/moodle-core-dock-loader-debug.js
lib/yui/build/moodle-core-dock-loader/moodle-core-dock-loader.js
lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js
lib/yui/build/moodle-core-dock/moodle-core-dock.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/src/dock/js/block.js
lib/yui/src/dock/js/dock.js
lib/yui/src/dock/js/dockeditem.js
lib/yui/src/dock/js/loader.js
lib/yui/src/dock/js/panel.js
lib/yui/src/dock/js/tabheightmanager.js
lib/yui/src/notification/js/dialogue.js
login/forgot_password.php
login/forgot_password_form.php
login/index.php
login/lib.php [new file with mode: 0644]
login/set_password_form.php [new file with mode: 0644]
message/lib.php
message/output/email/lang/en/message_email.php
message/output/email/message_output_email.php
message/output/email/settings.php
message/renderer.php
message/upgrade.txt
mod/assign/adminlib.php
mod/assign/classes/plugininfo/assignfeedback.php [new file with mode: 0644]
mod/assign/classes/plugininfo/assignsubmission.php [new file with mode: 0644]
mod/assign/feedback/editpdf/ajax.php
mod/assign/feedback/editpdf/classes/page_editor.php
mod/assign/feedback/editpdf/testgs.php
mod/assign/feedback/file/importziplib.php
mod/assign/lang/en/assign.php
mod/assign/lib.php
mod/assign/locallib.php
mod/assign/settings.php
mod/assign/tests/lib_test.php
mod/assignment/classes/plugininfo/assignment.php [new file with mode: 0644]
mod/assignment/lib.php
mod/assignment/type/online/assignment.class.php
mod/book/classes/event/chapter_created.php [new file with mode: 0644]
mod/book/classes/event/chapter_deleted.php [new file with mode: 0644]
mod/book/classes/event/chapter_updated.php [new file with mode: 0644]
mod/book/classes/event/chapter_viewed.php [new file with mode: 0644]
mod/book/classes/event/course_module_viewed.php [new file with mode: 0644]
mod/book/classes/event/instances_list_viewed.php [new file with mode: 0644]
mod/book/classes/plugininfo/booktool.php [new file with mode: 0644]
mod/book/delete.php
mod/book/edit.php
mod/book/index.php
mod/book/lang/en/book.php
mod/book/move.php
mod/book/show.php
mod/book/tests/events_test.php [new file with mode: 0644]
mod/book/tests/generator/lib.php [new file with mode: 0644]
mod/book/tests/generator_test.php [new file with mode: 0644]
mod/book/tool/exportimscp/classes/event/book_exported.php [new file with mode: 0644]
mod/book/tool/exportimscp/index.php
mod/book/tool/exportimscp/lang/en/booktool_exportimscp.php
mod/book/tool/exportimscp/tests/events_test.php [new file with mode: 0644]
mod/book/tool/importhtml/locallib.php
mod/book/tool/importhtml/tests/fixtures/chapters.zip [new file with mode: 0644]
mod/book/tool/importhtml/tests/locallib_test.php [new file with mode: 0644]
mod/book/tool/print/classes/event/book_printed.php [new file with mode: 0644]
mod/book/tool/print/classes/event/chapter_printed.php [new file with mode: 0644]
mod/book/tool/print/index.php
mod/book/tool/print/lang/en/booktool_print.php
mod/book/tool/print/tests/events_test.php [new file with mode: 0644]
mod/book/view.php
mod/data/classes/plugininfo/datafield.php [new file with mode: 0644]
mod/data/classes/plugininfo/datapreset.php [new file with mode: 0644]
mod/data/field/textarea/field.class.php
mod/data/templates.php
mod/feedback/edit_item.php
mod/feedback/show_nonrespondents.php
mod/folder/mod_form.php
mod/forum/externallib.php
mod/forum/index.php
mod/forum/lang/en/forum.php
mod/forum/lib.php
mod/forum/mod_form.php
mod/forum/post.php
mod/forum/settings.php
mod/forum/tests/behat/edit_post_student.feature
mod/forum/tests/behat/track_read_posts.feature
mod/forum/tests/externallib_test.php
mod/forum/tests/lib_test.php
mod/forum/upgrade.txt
mod/lti/view.php
mod/page/classes/event/course_module_viewed.php [new file with mode: 0644]
mod/page/classes/event/instances_list_viewed.php [new file with mode: 0644]
mod/page/index.php
mod/page/lang/en/page.php
mod/page/view.php
mod/quiz/attemptlib.php
mod/quiz/classes/plugininfo/quiz.php [moved from mod/quiz/adminlib.php with 85% similarity]
mod/quiz/classes/plugininfo/quizaccess.php [new file with mode: 0644]
mod/quiz/comment.php
mod/quiz/lang/en/quiz.php
mod/quiz/renderer.php
mod/quiz/report/attemptsreport.php
mod/quiz/report/grading/gradingsettings_form.php
mod/quiz/report/grading/lang/en/quiz_grading.php
mod/quiz/report/grading/report.php
mod/quiz/report/reportlib.php
mod/quiz/report/statistics/classes/calculated.php
mod/quiz/report/statistics/classes/calculator.php
mod/quiz/report/statistics/db/install.xml
mod/quiz/report/statistics/db/upgrade.php
mod/quiz/report/statistics/lang/en/quiz_statistics.php
mod/quiz/report/statistics/report.php
mod/quiz/report/statistics/statistics_form.php
mod/quiz/report/statistics/statistics_graph.php
mod/quiz/report/statistics/statisticslib.php
mod/quiz/report/statistics/tests/stats_from_steps_walkthrough_test.php
mod/quiz/report/statistics/version.php
mod/quiz/review.php
mod/quiz/view.php
mod/scorm/classes/plugininfo/scormreport.php [new file with mode: 0644]
mod/workshop/classes/plugininfo/workshopallocation.php [new file with mode: 0644]
mod/workshop/classes/plugininfo/workshopeval.php [new file with mode: 0644]
mod/workshop/classes/plugininfo/workshopform.php [new file with mode: 0644]
notes/index.php
notes/lib.php
notes/tests/events_test.php [new file with mode: 0644]
notes/tests/generator/lib.php [new file with mode: 0644]
notes/tests/generator_test.php [new file with mode: 0644]
question/behaviour/adaptive/behaviourtype.php [new file with mode: 0644]
question/behaviour/adaptivenopenalty/behaviour.php
question/behaviour/adaptivenopenalty/behaviourtype.php [new file with mode: 0644]
question/behaviour/behaviourbase.php
question/behaviour/behaviourtypebase.php [new file with mode: 0644]
question/behaviour/deferredcbm/behaviour.php
question/behaviour/deferredcbm/behaviourtype.php [new file with mode: 0644]
question/behaviour/deferredcbm/lang/en/qbehaviour_deferredcbm.php
question/behaviour/deferredcbm/renderer.php
question/behaviour/deferredcbm/styles.css [new file with mode: 0644]
question/behaviour/deferredcbm/tests/behaviourtype_test.php [new file with mode: 0644]
question/behaviour/deferredcbm/tests/question_cbm_test.php [new file with mode: 0644]
question/behaviour/deferredcbm/tests/walkthrough_test.php
question/behaviour/deferredfeedback/behaviour.php
question/behaviour/deferredfeedback/behaviourtype.php [new file with mode: 0644]
question/behaviour/immediatecbm/behaviour.php
question/behaviour/immediatecbm/behaviourtype.php [new file with mode: 0644]
question/behaviour/immediatecbm/tests/walkthrough_test.php
question/behaviour/immediatefeedback/behaviourtype.php [new file with mode: 0644]
question/behaviour/informationitem/behaviour.php
question/behaviour/informationitem/behaviourtype.php [new file with mode: 0644]
question/behaviour/interactive/behaviour.php
question/behaviour/interactive/behaviourtype.php [new file with mode: 0644]
question/behaviour/interactivecountback/behaviour.php
question/behaviour/interactivecountback/behaviourtype.php [new file with mode: 0644]
question/behaviour/manualgraded/behaviour.php
question/behaviour/manualgraded/behaviourtype.php [new file with mode: 0644]
question/behaviour/manualgraded/tests/walkthrough_test.php
question/behaviour/missing/behaviour.php
question/behaviour/missing/behaviourtype.php [new file with mode: 0644]
question/behaviour/missing/tests/missingbehaviour_test.php
question/behaviour/rendererbase.php
question/behaviour/upgrade.txt
question/engine/datalib.php
question/engine/lib.php
question/engine/questionattempt.php
question/engine/questionattemptstep.php
question/engine/questionusage.php
question/engine/renderer.php
question/engine/tests/helpers.php
question/engine/tests/questionattempt_db_test.php
question/engine/tests/questionattempt_with_steps_test.php
question/engine/tests/questioncbm_test.php [deleted file]
question/engine/tests/questionusagebyactivity_test.php
question/engine/tests/unitofwork_test.php
question/engine/upgrade.txt [new file with mode: 0644]
question/engine/upgrade/behaviourconverters.php
question/preview.php
question/type/calculated/tests/upgradelibnewqe_test.php
question/type/calculatedmulti/tests/upgradelibnewqe_test.php
question/type/calculatedsimple/tests/upgradelibnewqe_test.php
question/type/description/tests/upgradelibnewqe_test.php
question/type/essay/question.php
question/type/essay/tests/upgradelibnewqe_test.php
question/type/essay/tests/walkthrough_test.php
question/type/match/tests/upgradelibnewqe_test.php
question/type/multianswer/question.php
question/type/multianswer/tests/upgradelibnewqe_test.php
question/type/multichoice/tests/upgradelibnewqe_test.php
question/type/numerical/tests/upgradelibnewqe_test.php
question/type/questionbase.php
question/type/random/tests/upgradelibnewqe_test.php
question/type/shortanswer/tests/upgradelibnewqe_test.php
question/type/truefalse/tests/upgradelibnewqe_test.php
repository/boxnet/lib.php
repository/coursefiles/lib.php
repository/dropbox/lib.php
repository/equella/lib.php
repository/filesystem/lib.php
repository/lib.php
repository/local/lib.php
repository/tests/behat/delete_files.feature
repository/upgrade.txt
repository/user/lib.php
tag/edit.php
theme/base/style/core.css
theme/base/style/course.css
theme/base/style/filemanager.css
theme/bootstrapbase/less/moodle/bootstrapoverride.less
theme/bootstrapbase/less/moodle/core.less
theme/bootstrapbase/less/moodle/course.less
theme/bootstrapbase/less/moodle/filemanager.less
theme/bootstrapbase/less/moodle/responsive.less
theme/bootstrapbase/style/moodle.css
theme/bootstrapbase/yui/build/moodle-theme_bootstrap-bootstrap/moodle-theme_bootstrap-bootstrap-debug.js [deleted file]
theme/bootstrapbase/yui/build/moodle-theme_bootstrap-bootstrap/moodle-theme_bootstrap-bootstrap-min.js [deleted file]
theme/bootstrapbase/yui/build/moodle-theme_bootstrap-bootstrap/moodle-theme_bootstrap-bootstrap.js [deleted file]
user/editlib.php
user/externallib.php
user/message.html
user/messageselect.php
user/portfolio.php
user/tests/externallib_test.php
version.php

index 4310901..c83e848 100644 (file)
@@ -10,7 +10,6 @@
 require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 require_login();
 require_capability('moodle/site:config', context_system::instance());
@@ -53,7 +52,7 @@ switch ($action) {
             set_config('registerauth', '');
         }
         \core\session\manager::gc(); // Remove stale sessions.
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         break;
 
     case 'enable':
@@ -64,7 +63,7 @@ switch ($action) {
             set_config('auth', implode(',', $authsenabled));
         }
         \core\session\manager::gc(); // Remove stale sessions.
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         break;
 
     case 'down':
index 1e37dd2..a37af21 100644 (file)
@@ -5,7 +5,6 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/adminlib.php');
     require_once($CFG->libdir.'/tablelib.php');
-    require_once($CFG->libdir.'/pluginlib.php');
 
     admin_externalpage_setup('manageblocks');
 
@@ -37,7 +36,7 @@
             print_error('blockdoesnotexist', 'error');
         }
         $DB->set_field('block', 'visible', '0', array('id'=>$block->id));      // Hide block
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         admin_get_root(true, false);  // settings not required - only pages
     }
 
@@ -46,7 +45,7 @@
             print_error('blockdoesnotexist', 'error');
         }
         $DB->set_field('block', 'visible', '1', array('id'=>$block->id));      // Show block
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         admin_get_root(true, false);  // settings not required - only pages
     }
 
@@ -97,8 +96,8 @@
 
     $table = new flexible_table('admin-blocks-compatible');
 
-    $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'uninstall', 'settings'));
-    $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $struninstall, $strsettings));
+    $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'settings', 'uninstall'));
+    $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strsettings, $struninstall));
     $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
     $table->set_attribute('class', 'admintable blockstable generaltable');
     $table->set_attribute('id', 'compatibleblockstable');
             }
         }
 
-        if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$blockname)) {
+        if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$blockname, 'manage')) {
             $uninstall = html_writer::link($uninstallurl, $struninstall);
         } else {
             $uninstall = '';
         } else {
             $visible = '<a href="blocks.php?show='.$blockid.'&amp;sesskey='.sesskey().'" title="'.$strshow.'">'.
                        '<img src="'.$OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="'.$strshow.'" /></a>';
-            $class = ' class="dimmed_text"'; // Leading space required!
+            $class = 'dimmed_text';
         }
 
         if ($dbversion == $plugin->version) {
         }
 
         $row = array(
-            '<span'.$class.'>'.$strblockname.'</span>',
+            $strblockname,
             $blocklist,
-            '<span'.$class.'>'.$version.'</span>',
+            $version,
             $visible,
             $undeletable,
+            $settings,
             $uninstall,
-            $settings
         );
-        $table->add_data($row);
+        $table->add_data($row, $class);
     }
 
     $table->print_html();
         $table->setup();
 
         foreach ($incompatible as $block) {
-            if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('block_'.$block->name)) {
+            if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('block_'.$block->name, 'manage')) {
                 $uninstall = html_writer::link($uninstallurl, $struninstall);
             } else {
                 $uninstall = '';
index 0a5ce9b..a6c3873 100644 (file)
@@ -753,9 +753,8 @@ if (!$envstatus) {
 }
 
 // Test plugin dependencies.
-require_once($CFG->libdir . '/pluginlib.php');
 $failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
     cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
     cli_error(get_string('pluginschecktodo', 'admin'));
 }
index 7a4f288..3ab6279 100644 (file)
@@ -167,9 +167,8 @@ if (!$envstatus) {
 }
 
 // Test plugin dependencies.
-require_once($CFG->libdir . '/pluginlib.php');
 $failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
     cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
     cli_error(get_string('pluginschecktodo', 'admin'));
 }
index 28d7c8d..be2ba8b 100644 (file)
@@ -43,7 +43,6 @@ require_once($CFG->libdir.'/adminlib.php');       // various admin-only function
 require_once($CFG->libdir.'/upgradelib.php');     // general upgrade/install related functions
 require_once($CFG->libdir.'/clilib.php');         // cli only functions
 require_once($CFG->libdir.'/environmentlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 // now get cli options
 list($options, $unrecognized) = cli_get_params(
@@ -117,7 +116,7 @@ if (!$envstatus) {
 
 // Test plugin dependencies.
 $failed = array();
-if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
     cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
     cli_error(get_string('pluginschecktodo', 'admin'));
 }
index f86c4be..80f7680 100644 (file)
@@ -24,7 +24,6 @@
 
 require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 $action  = required_param('action', PARAM_ALPHANUMEXT);
 $formatname   = required_param('format', PARAM_PLUGIN);
@@ -39,7 +38,7 @@ require_sesskey();
 
 $return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
 
-$formatplugins = plugin_manager::instance()->get_plugins_of_type('format');
+$formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
 $sortorder = array_flip(array_keys($formatplugins));
 
 if (!isset($formatplugins[$formatname])) {
@@ -53,13 +52,13 @@ switch ($action) {
                 print_error('cannotdisableformat', 'error', $return);
             }
             set_config('disabled', 1, 'format_'. $formatname);
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
         }
         break;
     case 'enable':
         if (!$formatplugins[$formatname]->is_enabled()) {
             unset_config('disabled', 'format_'. $formatname);
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
         }
         break;
     case 'up':
index 50ee7a5..e1be31f 100644 (file)
@@ -7,7 +7,6 @@
 require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 $action  = required_param('action', PARAM_ALPHANUMEXT);
 $editor  = required_param('editor', PARAM_PLUGIN);
@@ -94,7 +93,7 @@ if (empty($active_editors)) {
 }
 
 set_config('texteditors', implode(',', $active_editors));
-plugin_manager::reset_caches();
+core_plugin_manager::reset_caches();
 
 if ($return) {
     redirect ($returnurl);
index 14a7649..642d93b 100644 (file)
@@ -27,7 +27,6 @@ define('NO_OUTPUT_BUFFERING', true);
 
 require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 $action  = required_param('action', PARAM_ALPHANUMEXT);
 $enrol   = required_param('enrol', PARAM_PLUGIN);
@@ -51,7 +50,7 @@ switch ($action) {
     case 'disable':
         unset($enabled[$enrol]);
         set_config('enrol_plugins_enabled', implode(',', array_keys($enabled)));
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         $syscontext->mark_dirty(); // resets all enrol caches
         break;
 
@@ -62,7 +61,7 @@ switch ($action) {
         $enabled = array_keys($enabled);
         $enabled[] = $enrol;
         set_config('enrol_plugins_enabled', implode(',', $enabled));
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         $syscontext->mark_dirty(); // resets all enrol caches
         break;
 
@@ -122,7 +121,7 @@ switch ($action) {
 
         echo $OUTPUT->notification(get_string('success'), 'notifysuccess');
 
-        if (!$return = plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol)) {
+        if (!$return = core_plugin_manager::instance()->get_uninstall_url('enrol_'.$enrol, 'manage')) {
             $return = new moodle_url('/admin/plugins.php');
         }
         echo $OUTPUT->continue_button($return);
index 05c463a..ae64944 100644 (file)
@@ -33,7 +33,6 @@
 
     require_once(dirname(__FILE__) . '/../config.php');
     require_once($CFG->libdir . '/adminlib.php');
-    require_once($CFG->libdir . '/pluginlib.php');
 
     $action = optional_param('action', '', PARAM_ALPHANUMEXT);
     $filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
 
     // Reset caches and return
     if ($action) {
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         reset_text_filters_cache();
         redirect($returnurl);
     }
 
     $table = new html_table();
     $table->head  = array(get_string('filter'), get_string('isactive', 'filters'),
-            get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
+            get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('uninstallplugin', 'core_admin'));
     $table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
     $table->attributes['class'] = 'admintable generaltable';
     $table->id = 'filterssetting';
 
 function filters_action_url($filterpath, $action) {
     if ($action === 'delete') {
-        return new moodle_url('/admin/plugins.php', array('sesskey'=>sesskey(), 'uninstall'=>'filter_'.$filterpath));
+        return core_plugin_manager::instance()->get_uninstall_url('filter_'.$filterpath, 'manage');
     }
     return new moodle_url('/admin/filters.php', array('sesskey'=>sesskey(), 'filterpath'=>$filterpath, 'action'=>$action));
 }
@@ -233,7 +232,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
     }
 
     // Delete
-    $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
+    $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('uninstallplugin', 'core_admin') . '</a>';
 
     return $row;
 }
index cf2e78a..ea9f37d 100644 (file)
@@ -78,7 +78,6 @@ core_component::get_core_subsystems();
 
 require_once($CFG->libdir.'/adminlib.php');    // various admin-only functions
 require_once($CFG->libdir.'/upgradelib.php');  // general upgrade/install related functions
-require_once($CFG->libdir.'/pluginlib.php');   // available updates notifications
 
 $id             = optional_param('id', '', PARAM_TEXT);
 $confirmupgrade = optional_param('confirmupgrade', 0, PARAM_BOOL);
@@ -196,7 +195,7 @@ if (!core_tables_exist()) {
 
     // check plugin dependencies
     $failed = array();
-    if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+    if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
         $PAGE->navbar->add(get_string('pluginscheck', 'admin'));
         $PAGE->set_title($strinstallation);
         $PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
@@ -323,7 +322,7 @@ if (!$cache and $version > $CFG->version) {  // upgrade
 
         // check plugin dependencies first
         $failed = array();
-        if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+        if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
             echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
             die();
         }
@@ -332,12 +331,12 @@ if (!$cache and $version > $CFG->version) {  // upgrade
         if ($fetchupdates) {
             // no sesskey support guaranteed here
             if (empty($CFG->disableupdatenotifications)) {
-                available_update_checker::instance()->fetch();
+                \core\update\checker::instance()->fetch();
             }
             redirect($reloadurl);
         }
 
-        $deployer = available_update_deployer::instance();
+        $deployer = \core\update\deployer::instance();
         if ($deployer->enabled()) {
             $deployer->initialize($reloadurl, $reloadurl);
 
@@ -348,7 +347,7 @@ if (!$cache and $version > $CFG->version) {  // upgrade
             }
         }
 
-        echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
+        echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
                 $version, $showallplugins, $reloadurl,
                 new moodle_url('/admin/index.php', array('confirmupgrade'=>1, 'confirmrelease'=>1, 'confirmplugincheck'=>1)));
         die();
@@ -386,13 +385,13 @@ if (!$cache and moodle_needs_upgrading()) {
 
             if ($fetchupdates) {
                 // no sesskey support guaranteed here
-                available_update_checker::instance()->fetch();
+                \core\update\checker::instance()->fetch();
                 redirect($PAGE->url);
             }
 
             $output = $PAGE->get_renderer('core', 'admin');
 
-            $deployer = available_update_deployer::instance();
+            $deployer = \core\update\deployer::instance();
             if ($deployer->enabled()) {
                 $deployer->initialize($PAGE->url, $PAGE->url);
 
@@ -405,14 +404,14 @@ if (!$cache and moodle_needs_upgrading()) {
 
             // check plugin dependencies first
             $failed = array();
-            if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
+            if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
                 echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
                 die();
             }
             unset($failed);
 
             // dependencies check passed, let's rock!
-            echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
+            echo $output->upgrade_plugin_check_page(core_plugin_manager::instance(), \core\update\checker::instance(),
                     $version, $showallplugins,
                     new moodle_url($PAGE->url),
                     new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
@@ -514,6 +513,15 @@ if (any_new_admin_settings($adminroot)){
     redirect('upgradesettings.php');
 }
 
+// Return to original page that started the plugin uninstallation if necessary.
+if (isset($SESSION->pluginuninstallreturn)) {
+    $return = $SESSION->pluginuninstallreturn;
+    unset($SESSION->pluginuninstallreturn);
+    if ($return) {
+        redirect($return);
+    }
+}
+
 // Everything should now be set up, and the user is an admin
 
 // Print default admin page with notifications.
@@ -525,13 +533,13 @@ $dbproblems = $DB->diagnose();
 $maintenancemode = !empty($CFG->maintenance_enabled);
 
 // Available updates for Moodle core
-$updateschecker = available_update_checker::instance();
+$updateschecker = \core\update\checker::instance();
 $availableupdates = array();
 $availableupdates['core'] = $updateschecker->get_update_info('core',
     array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
 
 // Available updates for contributed plugins
-$pluginman = plugin_manager::instance();
+$pluginman = core_plugin_manager::instance();
 foreach ($pluginman->get_plugins() as $plugintype => $plugintypeinstances) {
     foreach ($plugintypeinstances as $pluginname => $plugininfo) {
         if (!empty($plugininfo->availableupdates)) {
index 8286e96..fb5c4cf 100644 (file)
@@ -30,7 +30,6 @@
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 admin_externalpage_setup('managelocalplugins');
 
@@ -60,7 +59,7 @@ core_collator::asort($plugins);
 
 foreach ($plugins as $plugin => $name) {
     $uninstall = '';
-    if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('local_'.$plugin)) {
+    if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('local_'.$plugin, 'manage')) {
         $uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
     }
 
index f9fee27..270a230 100644 (file)
@@ -24,7 +24,6 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->dirroot . '/message/lib.php');
 require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 // This is an admin page
 admin_externalpage_setup('managemessageoutputs');
@@ -43,7 +42,7 @@ if (!empty($disable) && confirm_sesskey()) {
         print_error('outputdoesnotexist', 'message');
     }
     $DB->set_field('message_processors', 'enabled', '0', array('id'=>$processor->id));      // Disable output
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
 }
 
 if (!empty($enable) && confirm_sesskey()) {
@@ -51,7 +50,7 @@ if (!empty($enable) && confirm_sesskey()) {
         print_error('outputdoesnotexist', 'message');
     }
     $DB->set_field('message_processors', 'enabled', '1', array('id'=>$processor->id));      // Enable output
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
 }
 
 if ($disable || $enable) {
index a964c73..4cca569 100644 (file)
@@ -5,7 +5,6 @@
     require_once('../course/lib.php');
     require_once($CFG->libdir.'/adminlib.php');
     require_once($CFG->libdir.'/tablelib.php');
-    require_once($CFG->libdir.'/pluginlib.php');
 
     // defines
     define('MODULE_TABLE','module_administration_table');
@@ -48,7 +47,7 @@
                                 FROM {course_modules}
                                WHERE visibleold=1 AND module=?)",
                 array($module->id));
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         admin_get_root(true, false);  // settings not required - only pages
     }
 
@@ -65,7 +64,7 @@
                                 FROM {course_modules}
                                WHERE visible=1 AND module=?)",
                 array($module->id));
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         admin_get_root(true, false);  // settings not required - only pages
     }
 
     // construct the flexible table ready to display
     $table = new flexible_table(MODULE_TABLE);
     $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'uninstall', 'settings'));
-    $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $struninstall, $strsettings));
+    $table->define_headers(array($stractivitymodule, $stractivities, $strversion, "$strhide/$strshow", $strsettings, $struninstall));
     $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/modules.php');
     $table->set_attribute('id', 'modules');
-    $table->set_attribute('class', 'generaltable');
+    $table->set_attribute('class', 'admintable generaltable');
     $table->setup();
 
     foreach ($modules as $module) {
         }
 
         $uninstall = '';
-        if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('mod_'.$module->name)) {
+        if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('mod_'.$module->name, 'manage')) {
             $uninstall = html_writer::link($uninstallurl, $struninstall);
         }
 
         } else {
             $visible = "<a href=\"modules.php?show=$module->name&amp;sesskey=".sesskey()."\" title=\"$strshow\">".
                        "<img src=\"" . $OUTPUT->pix_url('t/show') . "\" class=\"iconsmall\" alt=\"$strshow\" /></a>";
-            $class =   ' class="dimmed_text"';
+            $class =   'dimmed_text';
         }
         if ($module->name == "forum") {
             $uninstall = "";
         $version = get_config('mod_'.$module->name, 'version');
 
         $table->add_data(array(
-            '<span'.$class.'>'.$strmodulename.'</span>',
+            $strmodulename,
             $countlink,
-            '<span'.$class.'>'.$version.'</span>',
+            $version,
             $visible,
+            $settings,
             $uninstall,
-            $settings
-        ));
+        ), $class);
     }
 
     $table->print_html();
index d5fc85a..d004869 100644 (file)
@@ -29,7 +29,6 @@
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 
 admin_externalpage_setup('manageplagiarismplugins');
@@ -74,7 +73,7 @@ foreach ($plagiarismplugins as $plugin => $dir) {
         }
         // uninstall link.
         $uninstall = '';
-        if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin)) {
+        if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('plagiarism_'.$plugin, 'manage')) {
             $uninstall = html_writer::link($uninstallurl, $txt->uninstall);
         }
         $table->data[] = array($displayname, $version, $uninstall, $settings);
index a092e00..c156f9d 100644 (file)
 
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/filelib.php');
 
 $fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
 $updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
 $contribonly = optional_param('contribonly', false, PARAM_BOOL);
-$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
-$delete = optional_param('delete', '', PARAM_COMPONENT);
-$confirmed = optional_param('confirm', false, PARAM_BOOL);
+$uninstall   = optional_param('uninstall', '', PARAM_COMPONENT);
+$delete      = optional_param('delete', '', PARAM_COMPONENT);
+$confirmed   = optional_param('confirm', false, PARAM_BOOL);
+$return      = optional_param('return', 'overview', PARAM_ALPHA);
 
 // NOTE: do not use admin_externalpage_setup() here because it loads
 //       full admin tree which is not possible during uninstallation.
@@ -52,7 +52,7 @@ require_login();
 $syscontext = context_system::instance();
 require_capability('moodle/site:config', $syscontext);
 
-$pluginman = plugin_manager::instance();
+$pluginman = core_plugin_manager::instance();
 
 if ($uninstall) {
     require_sesskey();
@@ -74,7 +74,7 @@ if ($uninstall) {
     // Make sure we know the plugin.
     if (is_null($pluginfo)) {
         throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
-            'plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
+            'core_plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
     }
 
     $pluginname = $pluginman->plugin_name($pluginfo->component);
@@ -84,15 +84,17 @@ if ($uninstall) {
     if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
         throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
             array('plugin' => $pluginfo->component),
-            'plugin_manager::can_uninstall_plugin() returned false');
+            'core_plugin_manager::can_uninstall_plugin() returned false');
     }
 
     if (!$confirmed) {
-        $continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
-        echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl);
+        $continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1, 'return'=>$return));
+        $cancelurl = $pluginfo->get_return_url_after_uninstall($return);
+        echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl, $cancelurl);
         exit();
 
     } else {
+        $SESSION->pluginuninstallreturn = $pluginfo->get_return_url_after_uninstall($return);
         $progress = new progress_trace_buffer(new text_progress_trace(), false);
         $pluginman->uninstall_plugin($pluginfo->component, $progress);
         $progress->finished();
@@ -133,7 +135,7 @@ if ($delete and $confirmed) {
     // Make sure we know the plugin.
     if (is_null($pluginfo)) {
         throw new moodle_exception('err_removing_unknown_plugin', 'core_plugin', '', array('plugin' => $delete),
-            'plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
+            'core_plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
     }
 
     $pluginname = $pluginman->plugin_name($pluginfo->component);
@@ -144,7 +146,7 @@ if ($delete and $confirmed) {
     if (!is_null($pluginfo->versiondb)) {
         throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
             array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb),
-            'plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
+            'core_plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
     }
 
     // Make sure the folder is removable.
@@ -176,7 +178,7 @@ admin_externalpage_setup('pluginsoverview');
 /** @var core_admin_renderer $output */
 $output = $PAGE->get_renderer('core', 'admin');
 
-$checker = available_update_checker::instance();
+$checker = \core\update\checker::instance();
 
 // Filtering options.
 $options = array(
@@ -190,7 +192,7 @@ if ($fetchremote) {
     redirect(new moodle_url($PAGE->url, $options));
 }
 
-$deployer = available_update_deployer::instance();
+$deployer = \core\update\deployer::instance();
 if ($deployer->enabled()) {
     $myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
     $deployer->initialize($myurl, new moodle_url('/admin'));
index 3b460fd..48237bb 100644 (file)
@@ -4,7 +4,6 @@ require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->libdir . '/portfoliolib.php');
 require_once($CFG->libdir . '/portfolio/forms.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 
 $portfolio     = optional_param('pf', '', PARAM_ALPHANUMEXT);
 $action        = optional_param('action', '', PARAM_ALPHA);
@@ -89,7 +88,7 @@ if (($action == 'edit') || ($action == 'new')) {
         } else {
             portfolio_static_function($plugin, 'create_instance', $plugin, $fromform->name, $fromform);
         }
-        plugin_manager::reset_caches();
+        core_plugin_manager::reset_caches();
         $savedstr = get_string('instancesaved', 'portfolio');
         redirect($baseurl, $savedstr, 1);
         exit;
@@ -118,7 +117,7 @@ if (($action == 'edit') || ($action == 'new')) {
 
     $instance->set('visible', $visible);
     $instance->save();
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     $return = true;
 } else if ($action == 'delete') {
     $instance = portfolio_instance($portfolio);
index 8e98af4..7cd027e 100644 (file)
@@ -28,7 +28,6 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->libdir . '/questionlib.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/tablelib.php');
 
 // Check permissions.
@@ -40,7 +39,7 @@ admin_externalpage_setup('manageqbehaviours');
 $thispageurl = new moodle_url('/admin/qbehaviours.php');
 
 $behaviours = core_component::get_plugin_list('qbehaviour');
-$pluginmanager = plugin_manager::instance();
+$pluginmanager = core_plugin_manager::instance();
 
 // Get some data we will need - question counts and which types are needed.
 $counts = $DB->get_records_sql_menu("
@@ -92,7 +91,7 @@ if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey(
         $disabledbehaviours[] = $disable;
         set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
     }
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     redirect($thispageurl);
 }
 
@@ -110,7 +109,7 @@ if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey())
         unset($disabledbehaviours[$key]);
         set_config('disabledbehaviours', implode(',', $disabledbehaviours), 'question');
     }
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     redirect($thispageurl);
 }
 
@@ -138,65 +137,6 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
     redirect($thispageurl);
 }
 
-// Delete.
-if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
-    // Check it is OK to delete this question type.
-    if ($delete == 'missing') {
-        print_error('cannotdeletemissingbehaviour', 'question', $thispageurl);
-    }
-
-    if (!isset($behaviours[$delete]) && !get_config('qbehaviour_' . $delete, 'version')) {
-        print_error('unknownbehaviour', 'question', $thispageurl, $delete);
-    }
-
-    $behaviourname = $sortedbehaviours[$delete];
-    if ($counts[$delete] > 0) {
-        print_error('cannotdeletebehaviourinuse', 'question', $thispageurl, $behaviourname);
-    }
-    if ($needed[$delete] > 0) {
-        print_error('cannotdeleteneededbehaviour', 'question', $thispageurl, $behaviourname);
-    }
-
-    // If not yet confirmed, display a confirmation message.
-    if (!optional_param('confirm', '', PARAM_BOOL)) {
-        echo $OUTPUT->header();
-        echo $OUTPUT->heading(get_string('deletebehaviourareyousure', 'question', $behaviourname));
-        echo $OUTPUT->confirm(
-                get_string('deletebehaviourareyousuremessage', 'question', $behaviourname),
-                new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
-                $thispageurl);
-        echo $OUTPUT->footer();
-        exit;
-    }
-
-    // Do the deletion.
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(get_string('deletingbehaviour', 'question', $behaviourname));
-
-    // 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');
-    }
-    $behaviourorder = array_keys($sortedbehaviours);
-    if (($key = array_search($delete, $behaviourorder)) !== false) {
-        unset($behaviourorder[$key]);
-        set_config('behavioursortorder', implode(',', $behaviourorder), 'question');
-    }
-
-    // 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);
-    echo $OUTPUT->box(get_string('qbehaviourdeletefiles', 'question', $a), 'generalbox', 'notice');
-    echo $OUTPUT->continue_button($thispageurl);
-    echo $OUTPUT->footer();
-    exit;
-}
-
 // End of process actions ==================================================
 
 // Print the page heading.
@@ -207,12 +147,12 @@ echo $OUTPUT->heading(get_string('manageqbehaviours', 'admin'));
 $table = new flexible_table('qbehaviouradmintable');
 $table->define_baseurl($thispageurl);
 $table->define_columns(array('behaviour', 'numqas', 'version', 'requires',
-        'available', 'delete'));
+        'available', 'uninstall'));
 $table->define_headers(array(get_string('behaviour', 'question'), get_string('numqas', 'question'),
         get_string('version'), get_string('requires', 'admin'),
-        get_string('availableq', 'question'), get_string('delete')));
+        get_string('availableq', 'question'), get_string('uninstallplugin', 'core_admin')));
 $table->set_attribute('id', 'qbehaviours');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'generaltable admintable');
 $table->setup();
 
 // Add a row for each question type.
@@ -267,9 +207,11 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
     if ($needed[$behaviour]) {
         $row[] = '';
     } else {
-        $row[] = html_writer::link(new moodle_url($thispageurl,
-                array('delete' => $behaviour, 'sesskey' => sesskey())), get_string('delete'),
+        $uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qbehaviour_'.$behaviour, 'manage');
+        if ($uninstallurl) {
+            $row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
                 array('title' => get_string('uninstallbehaviour', 'question')));
+        }
     }
 
     $table->add_data($row, $rowclass);
index 3e865d1..80c6c6d 100644 (file)
@@ -28,7 +28,6 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->libdir . '/questionlib.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 require_once($CFG->libdir . '/tablelib.php');
 
 // Check permissions.
@@ -41,7 +40,7 @@ admin_externalpage_setup('manageqtypes');
 $thispageurl = new moodle_url('/admin/qtypes.php');
 
 $qtypes = question_bank::get_all_qtypes();
-$pluginmanager = plugin_manager::instance();
+$pluginmanager = core_plugin_manager::instance();
 
 // Get some data we will need - question counts and which types are needed.
 $counts = $DB->get_records_sql("
@@ -122,58 +121,6 @@ if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
     redirect($thispageurl);
 }
 
-// Delete.
-if (($delete = optional_param('delete', '', PARAM_PLUGIN)) && confirm_sesskey()) {
-    // Check it is OK to delete this question type.
-    if ($delete == 'missingtype') {
-        print_error('cannotdeletemissingqtype', 'question', $thispageurl);
-    }
-
-    if (!isset($qtypes[$delete]) && !get_config('qtype_' . $delete, 'version')) {
-        print_error('unknownquestiontype', 'question', $thispageurl, $delete);
-    }
-
-    $qtypename = $qtypes[$delete]->local_name();
-    if ($counts[$delete]->numquestions + $counts[$delete]->numhidden > 0) {
-        print_error('cannotdeleteqtypeinuse', 'question', $thispageurl, $qtypename);
-    }
-
-    if ($needed[$delete] > 0) {
-        print_error('cannotdeleteqtypeneeded', 'question', $thispageurl, $qtypename);
-    }
-
-    // If not yet confirmed, display a confirmation message.
-    if (!optional_param('confirm', '', PARAM_BOOL)) {
-        $qtypename = $qtypes[$delete]->local_name();
-        echo $OUTPUT->header();
-        echo $OUTPUT->heading(get_string('deleteqtypeareyousure', 'question', $qtypename));
-        echo $OUTPUT->confirm(get_string('deleteqtypeareyousuremessage', 'question', $qtypename),
-                new moodle_url($thispageurl, array('delete' => $delete, 'confirm' => 1)),
-                $thispageurl);
-        echo $OUTPUT->footer();
-        exit;
-    }
-
-    // Do the deletion.
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(get_string('deletingqtype', 'question', $qtypename));
-
-    // Delete any questoin configuration records mentioning this plugin.
-    unset_config($delete . '_disabled', 'question');
-    unset_config($delete . '_sortorder', 'question');
-
-    // Then uninstall the plugin.
-    uninstall_plugin('qtype', $delete);
-
-    $a = new stdClass();
-    $a->qtype = $qtypename;
-    $a->directory = $qtypes[$delete]->plugin_dir();
-    echo $OUTPUT->box(get_string('qtypedeletefiles', 'question', $a), 'generalbox', 'notice');
-    echo $OUTPUT->continue_button($thispageurl);
-    echo $OUTPUT->footer();
-    exit;
-}
-
 // End of process actions ==================================================
 
 // Print the page heading.
@@ -184,10 +131,10 @@ echo $OUTPUT->heading(get_string('manageqtypes', 'admin'));
 $table = new flexible_table('qtypeadmintable');
 $table->define_baseurl($thispageurl);
 $table->define_columns(array('questiontype', 'numquestions', 'version', 'requires',
-        'availableto', 'delete', 'settings'));
+        'availableto', 'uninstall', 'settings'));
 $table->define_headers(array(get_string('questiontype', 'question'), get_string('numquestions', 'question'),
         get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
-        get_string('delete'), get_string('settings')));
+        get_string('settings'), get_string('uninstallplugin', 'core_admin')));
 $table->set_attribute('id', 'qtypes');
 $table->set_attribute('class', 'admintable generaltable');
 $table->setup();
@@ -259,15 +206,6 @@ foreach ($sortedqtypes as $qtypename => $localname) {
     $icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
     $row[] = $icons;
 
-    // Delete link, if available.
-    if ($needed[$qtypename]) {
-        $row[] = '';
-    } else {
-        $row[] = html_writer::link(new moodle_url($thispageurl,
-                array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'),
-                array('title' => get_string('uninstallqtype', 'question')));
-    }
-
     // Settings link, if available.
     $settings = admin_get_root()->locate('qtypesetting' . $qtypename);
     if ($settings instanceof admin_externalpage) {
@@ -279,6 +217,17 @@ foreach ($sortedqtypes as $qtypename => $localname) {
         $row[] = '';
     }
 
+    // Uninstall link, if available.
+    if ($needed[$qtypename]) {
+        $row[] = '';
+    } else {
+        $uninstallurl = core_plugin_manager::instance()->get_uninstall_url('qtype_'.$qtypename, 'manage');
+        if ($uninstallurl) {
+            $row[] = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'),
+                array('title' => get_string('uninstallqtype', 'question')));
+        }
+    }
+
     $table->add_data($row, $rowclass);
 }
 
index ca1a28c..0f84e00 100644 (file)
@@ -25,7 +25,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-require_once($CFG->libdir . '/pluginlib.php');
 
 /**
  * Standard HTML output renderer for core_admin subsystem
@@ -121,7 +120,7 @@ class core_admin_renderer extends plugin_renderer_base {
         $output .= $this->header();
         $output .= $this->heading(get_string('pluginscheck', 'admin'));
         $output .= $this->warning(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
-        $output .= $this->plugins_check_table(plugin_manager::instance(), $version, array('xdep' => true));
+        $output .= $this->plugins_check_table(core_plugin_manager::instance(), $version, array('xdep' => true));
         $output .= $this->warning(get_string('pluginschecktodo', 'admin'));
         $output .= $this->continue_button($reloadurl);
 
@@ -190,15 +189,15 @@ class core_admin_renderer extends plugin_renderer_base {
 
     /**
      * Display the upgrade page that lists all the plugins that require attention.
-     * @param plugin_manager $pluginman provides information about the plugins.
-     * @param available_update_checker $checker provides information about available updates.
+     * @param core_plugin_manager $pluginman provides information about the plugins.
+     * @param \core\update\checker $checker provides information about available updates.
      * @param int $version the version of the Moodle code from version.php.
      * @param bool $showallplugins
      * @param moodle_url $reloadurl
      * @param moodle_url $continueurl
      * @return string HTML to output.
      */
-    public function upgrade_plugin_check_page(plugin_manager $pluginman, available_update_checker $checker,
+    public function upgrade_plugin_check_page(core_plugin_manager $pluginman, \core\update\checker $checker,
             $version, $showallplugins, $reloadurl, $continueurl) {
         global $CFG;
 
@@ -240,11 +239,11 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Prints a page with a summary of plugin deployment to be confirmed.
      *
-     * @param available_update_deployer $deployer
-     * @param array $data deployer's data package as returned by {@link available_update_deployer::submitted_data()}
+     * @param \core\update\deployer $deployer
+     * @param array $data deployer's data package as returned by {@link \core\update\deployer::submitted_data()}
      * @return string
      */
-    public function upgrade_plugin_confirm_deploy_page(available_update_deployer $deployer, array $data) {
+    public function upgrade_plugin_confirm_deploy_page(\core\update\deployer $deployer, array $data) {
 
         if (!$deployer->initialized()) {
             throw new coding_exception('Unable to render a page for non-initialized deployer.');
@@ -302,7 +301,7 @@ class core_admin_renderer extends plugin_renderer_base {
      * @param bool $dbproblems warn db has problems
      * @param bool $maintenancemode warn in maintenance mode
      * @param bool $buggyiconvnomb warn iconv problems
-     * @param array|null $availableupdates array of available_update_info objects or null
+     * @param array|null $availableupdates array of \core\update\info objects or null
      * @param int|null $availableupdatesfetch timestamp of the most recent updates fetch or null (unknown)
      *
      * @return string HTML to output.
@@ -341,12 +340,12 @@ class core_admin_renderer extends plugin_renderer_base {
      *  bool contribonly - show only contributed extensions
      *  bool updatesonly - show only plugins with an available update
      *
-     * @param plugin_manager $pluginman
-     * @param available_update_checker $checker
+     * @param core_plugin_manager $pluginman
+     * @param \core\update\checker $checker
      * @param array $options filtering options
      * @return string HTML to output.
      */
-    public function plugin_management_page(plugin_manager $pluginman, available_update_checker $checker, array $options = array()) {
+    public function plugin_management_page(core_plugin_manager $pluginman, \core\update\checker $checker, array $options = array()) {
         global $CFG;
 
         $output = '';
@@ -377,12 +376,13 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Display a page to confirm the plugin uninstallation.
      *
-     * @param plugin_manager $pluginman
-     * @param plugininfo_base $pluginfo
+     * @param core_plugin_manager $pluginman
+     * @param \core\plugininfo\base $pluginfo
      * @param moodle_url $continueurl URL to continue after confirmation
+     * @param moodle_url $cancelurl URL to to go if cancelled
      * @return string
      */
-    public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugininfo_base $pluginfo, moodle_url $continueurl) {
+    public function plugin_uninstall_confirm_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, moodle_url $continueurl, moodle_url $cancelurl) {
         $output = '';
 
         $pluginname = $pluginman->plugin_name($pluginfo->component);
@@ -394,7 +394,7 @@ class core_admin_renderer extends plugin_renderer_base {
 
         $output .= $this->output->header();
         $output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
-        $output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
+        $output .= $this->output->confirm($confirm, $continueurl, $cancelurl);
         $output .= $this->output->footer();
 
         return $output;
@@ -403,13 +403,13 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Display a page with results of plugin uninstallation and offer removal of plugin files.
      *
-     * @param plugin_manager $pluginman
-     * @param plugininfo_base $pluginfo
+     * @param core_plugin_manager $pluginman
+     * @param \core\plugininfo\base $pluginfo
      * @param progress_trace_buffer $progress
      * @param moodle_url $continueurl URL to continue to remove the plugin folder
      * @return string
      */
-    public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
+    public function plugin_uninstall_results_removable_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo,
                                                             progress_trace_buffer $progress, moodle_url $continueurl) {
         $output = '';
 
@@ -442,12 +442,12 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
      *
-     * @param plugin_manager $pluginman
-     * @param plugininfo_base $pluginfo
+     * @param core_plugin_manager $pluginman
+     * @param \core\plugininfo\base $pluginfo
      * @param progress_trace_buffer $progress
      * @return string
      */
-    public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
+    public function plugin_uninstall_results_page(core_plugin_manager $pluginman, \core\plugininfo\base $pluginfo, progress_trace_buffer $progress) {
         $output = '';
 
         $pluginname = $pluginfo->component;
@@ -676,7 +676,7 @@ class core_admin_renderer extends plugin_renderer_base {
      * The structure of the $updates param has changed since 2.4. It contains not only updates
      * for the core itself, but also for all other installed plugins.
      *
-     * @param array|null $updates array of (string)component => array of available_update_info objects or null
+     * @param array|null $updates array of (string)component => array of \core\update\info objects or null
      * @param int|null $fetch timestamp of the most recent updates fetch or null (unknown)
      * @return string
      */
@@ -748,9 +748,9 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Helper method to render the information about the available Moodle update
      *
-     * @param available_update_info $updateinfo information about the available Moodle core update
+     * @param \core\update\info $updateinfo information about the available Moodle core update
      */
-    protected function moodle_available_update_info(available_update_info $updateinfo) {
+    protected function moodle_available_update_info(\core\update\info $updateinfo) {
 
         $boxclasses = 'moodleupdateinfo';
         $info = array();
@@ -817,12 +817,12 @@ class core_admin_renderer extends plugin_renderer_base {
      *     (bool)full = false: whether to display up-to-date plugins, too
      *     (bool)xdep = false: display the plugins with unsatisified dependecies only
      *
-     * @param plugin_manager $pluginman provides information about the plugins.
+     * @param core_plugin_manager $pluginman provides information about the plugins.
      * @param int $version the version of the Moodle code from version.php.
      * @param array $options rendering options
      * @return string HTML code
      */
-    public function plugins_check_table(plugin_manager $pluginman, $version, array $options = array()) {
+    public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
         global $CFG;
 
         $plugininfo = $pluginman->get_plugins();
@@ -915,7 +915,7 @@ class core_admin_renderer extends plugin_renderer_base {
                 $requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
 
                 $statusisboring = in_array($statuscode, array(
-                        plugin_manager::PLUGIN_STATUS_NODB, plugin_manager::PLUGIN_STATUS_UPTODATE));
+                        core_plugin_manager::PLUGIN_STATUS_NODB, core_plugin_manager::PLUGIN_STATUS_UPTODATE));
 
                 $coredependency = $plugin->is_core_dependency_satisfied($version);
                 $otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
@@ -991,12 +991,12 @@ class core_admin_renderer extends plugin_renderer_base {
 
     /**
      * Formats the information that needs to go in the 'Requires' column.
-     * @param plugininfo_base $plugin the plugin we are rendering the row for.
-     * @param plugin_manager $pluginman provides data on all the plugins.
+     * @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
+     * @param core_plugin_manager $pluginman provides data on all the plugins.
      * @param string $version
      * @return string HTML code
      */
-    protected function required_column(plugininfo_base $plugin, plugin_manager $pluginman, $version) {
+    protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) {
         $requires = array();
 
         if (!empty($plugin->versionrequires)) {
@@ -1048,11 +1048,11 @@ class core_admin_renderer extends plugin_renderer_base {
     /**
      * Prints an overview about the plugins - number of installed, number of extensions etc.
      *
-     * @param plugin_manager $pluginman provides information about the plugins
+     * @param core_plugin_manager $pluginman provides information about the plugins
      * @param array $options filtering options
      * @return string as usually
      */
-    public function plugins_overview_panel(plugin_manager $pluginman, array $options = array()) {
+    public function plugins_overview_panel(core_plugin_manager $pluginman, array $options = array()) {
         global $CFG;
 
         $plugininfo = $pluginman->get_plugins();
@@ -1061,7 +1061,7 @@ class core_admin_renderer extends plugin_renderer_base {
 
         foreach ($plugininfo as $type => $plugins) {
             foreach ($plugins as $name => $plugin) {
-                if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
+                if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
                     continue;
                 }
                 $numtotal++;
@@ -1128,11 +1128,11 @@ class core_admin_renderer extends plugin_renderer_base {
      *
      * This default implementation renders all plugins into one big table.
      *
-     * @param plugin_manager $pluginman provides information about the plugins.
+     * @param core_plugin_manager $pluginman provides information about the plugins.
      * @param array $options filtering options
      * @return string HTML code
      */
-    public function plugins_control_panel(plugin_manager $pluginman, array $options = array()) {
+    public function plugins_control_panel(core_plugin_manager $pluginman, array $options = array()) {
         global $CFG;
 
         $plugininfo = $pluginman->get_plugins();
@@ -1186,8 +1186,12 @@ class core_admin_renderer extends plugin_renderer_base {
         );
 
         foreach ($plugininfo as $type => $plugins) {
-
-            $header = new html_table_cell($pluginman->plugintype_name_plural($type));
+            $heading = $pluginman->plugintype_name_plural($type);
+            $pluginclass = core_plugin_manager::resolve_plugininfo_class($type);
+            if ($manageurl = $pluginclass::get_manage_url()) {
+                $heading = html_writer::link($manageurl, $heading);
+            }
+            $header = new html_table_cell(html_writer::tag('span', $heading, array('id'=>'plugin_type_cell_'.$type)));
             $header->header = true;
             $header->colspan = array_sum($table->headspan);
             $header = new html_table_row(array($header));
@@ -1214,9 +1218,9 @@ class core_admin_renderer extends plugin_renderer_base {
                 }
                 $status = $plugin->get_status();
                 $row->attributes['class'] .= ' status-'.$status;
-                if ($status === plugin_manager::PLUGIN_STATUS_MISSING) {
+                if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
                     $msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
-                } else if ($status === plugin_manager::PLUGIN_STATUS_NEW) {
+                } else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
                     $msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
                 } else {
                     $msg = '';
@@ -1254,8 +1258,7 @@ class core_admin_renderer extends plugin_renderer_base {
                 }
                 $settings = new html_table_cell($settings);
 
-                if ($pluginman->can_uninstall_plugin($plugin->component)) {
-                    $uninstallurl = $plugin->get_uninstall_url();
+                if ($uninstallurl = $pluginman->get_uninstall_url($plugin->component, 'overview')) {
                     $uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
                 } else {
                     $uninstall = '';
@@ -1295,9 +1298,9 @@ class core_admin_renderer extends plugin_renderer_base {
      * The passed objects always provides at least the 'version' property containing
      * the (higher) version of the plugin available.
      *
-     * @param available_update_info $updateinfo information about the available update for the plugin
+     * @param \core\update\info $updateinfo information about the available update for the plugin
      */
-    protected function plugin_available_update_info(available_update_info $updateinfo) {
+    protected function plugin_available_update_info(\core\update\info $updateinfo) {
 
         $boxclasses = 'pluginupdateinfo';
         $info = array();
@@ -1326,7 +1329,7 @@ class core_admin_renderer extends plugin_renderer_base {
         $box .= html_writer::tag('div', get_string('updateavailable', 'core_plugin', $updateinfo->version), array('class' => 'version'));
         $box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
 
-        $deployer = available_update_deployer::instance();
+        $deployer = \core\update\deployer::instance();
         if ($deployer->initialized()) {
             $impediments = $deployer->deployment_impediments($updateinfo);
             if (empty($impediments)) {
index 879497c..46c244f 100644 (file)
@@ -30,7 +30,6 @@
 require_once(dirname(__FILE__) . '/../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/tablelib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 
 admin_externalpage_setup('managereports');
 
@@ -46,7 +45,7 @@ $table->define_columns(array('name', 'version', 'uninstall'));
 $table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall));
 $table->define_baseurl($PAGE->url);
 $table->set_attribute('id', 'reportplugins');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'admintable generaltable');
 $table->setup();
 
 $plugins = array();
@@ -74,7 +73,7 @@ foreach ($installed as $config) {
 
 foreach ($plugins as $plugin => $name) {
     $uninstall = '';
-    if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('report_'.$plugin)) {
+    if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('report_'.$plugin, 'manage')) {
         $uninstall = html_writer::link($uninstallurl, $struninstall);
     }
 
index 05fc755..1e991e4 100644 (file)
@@ -17,7 +17,6 @@
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->dirroot . '/repository/lib.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 
 $repository       = optional_param('repos', '', PARAM_ALPHANUMEXT);
 $action           = optional_param('action', '', PARAM_ALPHANUMEXT);
@@ -149,7 +148,7 @@ if (($action == 'edit') || ($action == 'new')) {
         }
         if ($success) {
             // configs saved
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
             redirect($baseurl);
         } else {
             print_error('instancenotsaved', 'repository', $baseurl);
@@ -190,7 +189,7 @@ if (($action == 'edit') || ($action == 'new')) {
         print_error('invalidplugin', 'repository', '', $repository);
     }
     $repositorytype->update_visibility(true);
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     $return = true;
 } else if ($action == 'hide') {
     if (!confirm_sesskey()) {
@@ -201,7 +200,7 @@ if (($action == 'edit') || ($action == 'new')) {
         print_error('invalidplugin', 'repository', '', $repository);
     }
     $repositorytype->update_visibility(false);
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     $return = true;
 } else if ($action == 'delete') {
     $repositorytype = repository::get_type_by_typename($repository);
@@ -212,7 +211,7 @@ if (($action == 'edit') || ($action == 'new')) {
         }
 
         if ($repositorytype->delete($downloadcontents)) {
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
             redirect($baseurl);
         } else {
             print_error('instancenotdeleted', 'repository', $baseurl);
index 3def4f3..0373857 100644 (file)
@@ -17,7 +17,6 @@
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 require_once($CFG->dirroot . '/repository/lib.php');
 require_once($CFG->libdir . '/adminlib.php');
-require_once($CFG->libdir . '/pluginlib.php');
 
 require_sesskey();
 
@@ -103,7 +102,7 @@ if (!empty($edit) || !empty($new)) {
             $data = data_submitted();
         }
         if ($success) {
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
             redirect($parenturl);
         } else {
             print_error('instancenotsaved', 'repository', $parenturl);
@@ -120,7 +119,7 @@ if (!empty($edit) || !empty($new)) {
 } else if (!empty($hide)) {
     $instance = repository::get_type_by_typename($hide);
     $instance->hide();
-    plugin_manager::reset_caches();
+    core_plugin_manager::reset_caches();
     $return = true;
 } else if (!empty($delete)) {
     $instance = repository::get_instance($delete);
@@ -133,7 +132,7 @@ if (!empty($edit) || !empty($new)) {
     if ($sure) {
         if ($instance->delete($downloadcontents)) {
             $deletedstr = get_string('instancedeleted', 'repository');
-            plugin_manager::reset_caches();
+            core_plugin_manager::reset_caches();
             redirect($parenturl, $deletedstr, 3);
         } else {
             print_error('instancenotdeleted', 'repository', $parenturl);
index cce2334..980e2ae 100644 (file)
@@ -29,6 +29,7 @@ define("MAX_USERS_TO_LIST_PER_ROLE", 10);
 
 $contextid = required_param('contextid', PARAM_INT);
 $roleid    = optional_param('roleid', 0, PARAM_INT);
+$returnto  = optional_param('return', null, PARAM_ALPHANUMEXT);
 
 list($context, $course, $cm) = get_context_info_array($contextid);
 
@@ -181,6 +182,9 @@ if ($roleid) {
 
     // Print the form.
     $assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+    if ($returnto !== null) {
+        $assignurl->param('return', $returnto);
+    }
 ?>
 <form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
   <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
@@ -225,10 +229,17 @@ if ($roleid) {
     // Print a form to swap roles, and a link back to the all roles list.
     echo '<div class="backlink">';
 
-    $select = new single_select($PAGE->url, 'roleid', $nameswithcounts, $roleid, null);
+    $newroleurl = new moodle_url($PAGE->url);
+    if ($returnto !== null) {
+        $newroleurl->param('return', $returnto);
+    }
+    $select = new single_select($newroleurl, 'roleid', $nameswithcounts, $roleid, null);
     $select->label = get_string('assignanotherrole', 'core_role');
     echo $OUTPUT->render($select);
     $backurl = new moodle_url('/admin/roles/assign.php', array('contextid' => $contextid));
+    if ($returnto !== null) {
+        $backurl->param('return', $returnto);
+    }
     echo '<p><a href="' . $backurl->out() . '">' . get_string('backtoallroles', 'core_role') . '</a></p>';
     echo '</div>';
 
@@ -255,7 +266,8 @@ if ($roleid) {
     foreach ($assignableroles as $roleid => $notused) {
         $roleusers = '';
         if (0 < $assigncounts[$roleid] && $assigncounts[$roleid] <= MAX_USERS_TO_LIST_PER_ROLE) {
-            $roleusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname');
+            $userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
+            $roleusers = get_role_users($roleid, $context, false, $userfields);
             if (!empty($roleusers)) {
                 $strroleusers = array();
                 foreach ($roleusers as $user) {
@@ -266,6 +278,9 @@ if ($roleid) {
             }
         } else if ($assigncounts[$roleid] > MAX_USERS_TO_LIST_PER_ROLE) {
             $assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+            if ($returnto !== null) {
+                $assignurl->param('return', $returnto);
+            }
             $roleholdernames[$roleid] = '<a href="'.$assignurl.'">'.$strmorethanmax.'</a>';
         } else {
             $roleholdernames[$roleid] = '';
@@ -286,6 +301,9 @@ if ($roleid) {
     foreach ($assignableroles as $roleid => $rolename) {
         $description = format_string($DB->get_field('role', 'description', array('id'=>$roleid)));
         $assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
+        if ($returnto !== null) {
+            $assignurl->param('return', $returnto);
+        }
         $row = array('<a href="'.$assignurl.'">'.$rolename.'</a>',
                 $description, $assigncounts[$roleid]);
         if ($showroleholders) {
@@ -297,8 +315,15 @@ if ($roleid) {
     echo html_writer::table($table);
 
     if ($context->contextlevel > CONTEXT_USER) {
+
+        if ($context->contextlevel === CONTEXT_COURSECAT && $returnto === 'management') {
+            $url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
+        } else {
+            $url = $context->get_url();
+        }
+
         echo html_writer::start_tag('div', array('class'=>'backlink'));
-        echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
+        echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
         echo html_writer::end_tag('div');
     }
 }
index cfff956..8af137a 100644 (file)
@@ -33,6 +33,7 @@ $prevent    = optional_param('prevent', 0, PARAM_BOOL);
 $allow      = optional_param('allow', 0, PARAM_BOOL);
 $unprohibit = optional_param('unprohibit', 0, PARAM_BOOL);
 $prohibit   = optional_param('prohibit', 0, PARAM_BOOL);
+$return     = optional_param('return', null, PARAM_ALPHANUMEXT);
 
 list($context, $course, $cm) = get_context_info_array($contextid);
 
@@ -201,8 +202,15 @@ echo $OUTPUT->box_end();
 
 
 if ($context->contextlevel > CONTEXT_USER) {
+
+    if ($context->contextlevel === CONTEXT_COURSECAT && $return === 'management') {
+        $url = new moodle_url('/course/management.php', array('categoryid' => $context->instanceid));
+    } else {
+        $url = $context->get_url();
+    }
+
     echo html_writer::start_tag('div', array('class'=>'backlink'));
-    echo html_writer::tag('a', get_string('backto', '', $contextname), array('href'=>$context->get_url()));
+    echo html_writer::tag('a', get_string('backto', '', $contextname), array('href' => $url));
     echo html_writer::end_tag('div');
 }
 
index 4005c7c..d69b8e2 100644 (file)
@@ -1,20 +1,51 @@
 <?php
-
-// This file defines settingpages and externalpages under the "courses" category
-
-if ($hassiteconfig
- or has_capability('moodle/backup:backupcourse', $systemcontext)
- or has_capability('moodle/category:manage', $systemcontext)
- or has_capability('moodle/course:create', $systemcontext)
- or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
-
-    $ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/manage.php',
-            array('moodle/category:manage', 'moodle/course:create')));
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file defines settingpages and externalpages under the "courses" category
+ *
+ * @package core
+ * @copyright 2002 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$capabilities = array(
+    'moodle/backup:backupcourse',
+    'moodle/category:manage',
+    'moodle/course:create',
+    'moodle/site:approvecourse'
+);
+if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
+    // Speedup for non-admins, add all caps used on this page.
+    $ADMIN->add('courses',
+        new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'),
+            $CFG->wwwroot . '/course/management.php',
+            array('moodle/category:manage', 'moodle/course:create')
+        )
+    );
+    $ADMIN->add('courses',
+        new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
+            new moodle_url('/course/editcategory.php', array('parent' => 0)),
+            array('moodle/category:manage')
+        )
+    );
 
     // Course Default Settings Page.
     // NOTE: these settings must be applied after all other settings because they depend on them.
 
-
     // Main course settings.
     $temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
     require_once($CFG->dirroot.'/course/lib.php');
@@ -25,7 +56,6 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
         1, $choices));
 
-
     // Course format.
     $temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
 
@@ -55,7 +85,6 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
         new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
 
-
     // Appearance.
     $temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
 
@@ -73,7 +102,6 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
         array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 
-
     // Files and uploads.
     $temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
 
@@ -92,13 +120,11 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
         new lang_string('coursehelpmaximumupload'), key($choices), $choices));
 
-
     // Completion tracking.
     $temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
     $temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
         new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
 
-
     // Groups.
     $temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
     $choices = array();
@@ -119,13 +145,13 @@ if ($hassiteconfig
     $temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
     $ADMIN->add('courses', $temp);
 
-/// Pending course requests.
+    // Pending course requests.
     if (!empty($CFG->enablecourserequests)) {
         $ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
                 $CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
     }
 
-    // Add a category for backups
+    // Add a category for backups.
     $ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
 
     // Create a page for general backups configuration and defaults.
@@ -239,10 +265,8 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
     $temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
 
-
     //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
     //$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
 
     $ADMIN->add('backups', $temp);
-
-} // end of speedup
+}
index 19bace3..63d39ab 100644 (file)
@@ -1,23 +1,38 @@
 <?php
-
-/*
- * Please note that is file is always loaded last - it means that you can inject entries into other categories too.
- */
+// 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/>.
+
+/**
+ * Load all plugins into the admin tree.
+ *
+* Please note that is file is always loaded last - it means that you can inject entries into other categories too.
+*
+* @package    core
+* @copyright  2007 Petr Skoda {@link http://skodak.org}
+* @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+*/
 
 if ($hassiteconfig) {
-    require_once("$CFG->libdir/pluginlib.php");
-    $allplugins = plugin_manager::instance()->get_plugins();
-
     $ADMIN->add('modules', new admin_page_pluginsoverview());
 
     // activity modules
     $ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
     $ADMIN->add('modsettings', new admin_page_managemods());
-    foreach ($allplugins['mod'] as $module) {
-        if (!$module->is_updated()) {
-            continue;
-        }
-        $module->load_settings($ADMIN, 'modsettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
+        /** @var \core\plugininfo\mod $plugin */
+        $plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
     }
 
     // course formats
@@ -25,32 +40,26 @@ if ($hassiteconfig) {
     $temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
     $temp->add(new admin_setting_manageformats());
     $ADMIN->add('formatsettings', $temp);
-    foreach ($allplugins['format'] as $format) {
-        if (!$format->is_updated()) {
-            continue;
-        }
-        $format->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('format') as $plugin) {
+        /** @var \core\plugininfo\format $plugin */
+        $plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
     }
 
     // blocks
     $ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
     $ADMIN->add('blocksettings', new admin_page_manageblocks());
-    foreach ($allplugins['block'] as $block) {
-        if (!$block->is_updated()) {
-            continue;
-        }
-        $block->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('block') as $plugin) {
+        /** @var \core\plugininfo\block $plugin */
+        $plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
     }
 
     // message outputs
     $ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
     $ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
     $ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
-    foreach ($allplugins['message'] as $processor) {
-        if (!$processor->is_updated()) {
-            continue;
-        }
-        $processor->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('message') as $plugin) {
+        /** @var \core\plugininfo\message $plugin */
+        $plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
     }
 
     // authentication plugins
@@ -78,11 +87,12 @@ if ($hassiteconfig) {
     $temp->add(new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS));
     $ADMIN->add('authsettings', $temp);
 
-    foreach ($allplugins['auth'] as $auth) {
-        if (!$auth->is_updated()) {
-            continue;
-        }
-        $auth->load_settings($ADMIN, 'authsettings', $hassiteconfig);
+    $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
+    $ADMIN->add('authsettings', $temp);
+
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('auth') as $plugin) {
+        /** @var \core\plugininfo\auth $plugin */
+        $plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
     }
 
     // Enrolment plugins
@@ -90,11 +100,13 @@ if ($hassiteconfig) {
     $temp = new admin_settingpage('manageenrols', new lang_string('manageenrols', 'enrol'));
     $temp->add(new admin_setting_manageenrols());
     $ADMIN->add('enrolments', $temp);
-    foreach($allplugins['enrol'] as $enrol) {
-        if (!$enrol->is_updated()) {
-            continue;
-        }
-        $enrol->load_settings($ADMIN, 'enrolments', $hassiteconfig);
+
+    $temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
+    $ADMIN->add('enrolments', $temp);
+
+    foreach(core_plugin_manager::instance()->get_plugins_of_type('enrol') as $plugin) {
+        /** @var \core\plugininfo\enrol $plugin */
+        $plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
     }
 
 
@@ -103,11 +115,9 @@ if ($hassiteconfig) {
     $temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
     $temp->add(new admin_setting_manageeditors());
     $ADMIN->add('editorsettings', $temp);
-    foreach ($allplugins['editor'] as $editor) {
-        if (!$editor->is_updated()) {
-            continue;
-        }
-        $editor->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('editor') as $plugin) {
+        /** @var \core\plugininfo\editor $plugin */
+        $plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
     }
 
 /// License types
@@ -168,11 +178,9 @@ if ($hassiteconfig) {
     }
     $ADMIN->add('filtersettings', $temp);
 
-    foreach ($allplugins['filter'] as $filter) {
-        if (!$filter->is_updated()) {
-            continue;
-        }
-        $filter->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('filter') as $plugin) {
+        /** @var \core\plugininfo\filter $plugin */
+        $plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
     }
 
 
@@ -251,6 +259,7 @@ if ($hassiteconfig) {
     $temp->add(new admin_setting_configtext('repositorycacheexpire', new lang_string('cacheexpire', 'repository'), new lang_string('configcacheexpire', 'repository'), 120));
     $temp->add(new admin_setting_configcheckbox('repositoryallowexternallinks', new lang_string('allowexternallinks', 'repository'), new lang_string('configallowexternallinks', 'repository'), 1));
     $temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
+    $temp->add(new admin_setting_configcheckbox('legacyfilesaddallowed', new lang_string('legacyfilesaddallowed', 'admin'), new lang_string('legacyfilesaddallowed_help', 'admin'), 1));
     $ADMIN->add('repositorysettings', $temp);
     $ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
         new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
@@ -262,11 +271,9 @@ if ($hassiteconfig) {
         new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
     $ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
         new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
-    foreach ($allplugins['repository'] as $repositorytype) {
-        if (!$repositorytype->is_updated()) {
-            continue;
-        }
-        $repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('repository') as $plugin) {
+        /** @var \core\plugininfo\repository $plugin */
+        $plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
     }
 
 /// Web services
@@ -314,11 +321,9 @@ if ($hassiteconfig) {
                         'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
     $ADMIN->add('webservicesettings', $temp);
     /// links to protocol pages
-    foreach ($allplugins['webservice'] as $webservice) {
-        if (!$webservice->is_updated()) {
-            continue;
-        }
-        $webservice->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('webservice') as $plugin) {
+        /** @var \core\plugininfo\webservice $plugin */
+        $plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
     }
     /// manage token page link
     $ADMIN->add('webservicesettings', new admin_externalpage('addwebservicetoken', new lang_string('managetokens', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/tokens.php", 'moodle/site:config', true));
@@ -332,10 +337,6 @@ if ($hassiteconfig) {
 
 // Question type settings
 if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext)) {
-    if (!$hassiteconfig) {
-        require_once("$CFG->libdir/pluginlib.php");
-        $allplugins = plugin_manager::instance()->get_plugins();
-    }
 
     // Question behaviour settings.
     $ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
@@ -392,11 +393,9 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
             get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
 
     // Settings for particular question types.
-    foreach ($allplugins['qtype'] as $qtype) {
-        if (!$qtype->is_updated()) {
-            continue;
-        }
-        $qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('qtype') as $plugin) {
+        /** @var \core\plugininfo\qtype $plugin */
+        $plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
     }
 }
 
@@ -406,10 +405,8 @@ if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
     $ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
         $CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
 
-    foreach ($allplugins['plagiarism'] as $plugin) {
-        if (!$plugin->is_updated()) {
-            continue;
-        }
+    foreach (core_plugin_manager::instance()->get_plugins_of_type('plagiarism') as $plugin) {
+        /** @var \core\plugininfo\plagiarism $plugin */
         $plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
     }
 }
@@ -466,12 +463,10 @@ if ($hassiteconfig) {
                                                      $CFG->wwwroot . '/' . $CFG->admin . '/tools.php'));
 }
 
-// Now add various admin tools
-foreach (core_component::get_plugin_list('tool') as $plugin => $plugindir) {
-    $settings_path = "$plugindir/settings.php";
-    if (file_exists($settings_path)) {
-        include($settings_path);
-    }
+// Now add various admin tools.
+foreach (core_plugin_manager::instance()->get_plugins_of_type('tool') as $plugin) {
+    /** @var \core\plugininfo\tool $plugin */
+    $plugin->load_settings($ADMIN, null, $hassiteconfig);
 }
 
 // Now add the Cache plugins
@@ -497,12 +492,9 @@ if ($hassiteconfig) {
                                                         $CFG->wwwroot . '/' . $CFG->admin . '/localplugins.php'));
 }
 
-// extend settings for each local plugin. Note that their settings may be in any part of the
-// settings tree and may be visible not only for administrators. We can not use $allplugins here
-foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
-    $settings_path = "$plugindir/settings.php";
-    if (file_exists($settings_path)) {
-        include($settings_path);
-        continue;
-    }
+// Extend settings for each local plugin. Note that their settings may be in any part of the
+// settings tree and may be visible not only for administrators.
+foreach (core_plugin_manager::instance()->get_plugins_of_type('local') as $plugin) {
+    /** @var \core\plugininfo\local $plugin */
+    $plugin->load_settings($ADMIN, null, $hassiteconfig);
 }
index 3d63ce6..62712e3 100644 (file)
@@ -70,6 +70,22 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     $temp->add(new admin_setting_configtext('minpasswordupper', new lang_string('minpasswordupper', 'admin'), new lang_string('configminpasswordupper', 'admin'), 1, PARAM_INT));
     $temp->add(new admin_setting_configtext('minpasswordnonalphanum', new lang_string('minpasswordnonalphanum', 'admin'), new lang_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT));
     $temp->add(new admin_setting_configtext('maxconsecutiveidentchars', new lang_string('maxconsecutiveidentchars', 'admin'), new lang_string('configmaxconsecutiveidentchars', 'admin'), 0, PARAM_INT));
+    $pwresetoptions = array(
+        300 => new lang_string('numminutes', '', 5),
+        900 => new lang_string('numminutes', '', 15),
+        1800 => new lang_string('numminutes', '', 30),
+        2700 => new lang_string('numminutes', '', 45),
+        3600 => new lang_string('numminutes', '', 60),
+        7200 => new lang_string('numminutes', '', 120),
+        14400 => new lang_string('numminutes', '', 240)
+    );
+    $adminsetting = new admin_setting_configselect(
+            'pwresettime',
+            new lang_string('passwordresettime','admin'),
+            new lang_string('configpasswordresettime','admin'),
+            1800,
+            $pwresetoptions);
+    $temp->add($adminsetting);
     $temp->add(new admin_setting_configcheckbox('groupenrolmentkeypolicy', new lang_string('groupenrolmentkeypolicy', 'admin'), new lang_string('groupenrolmentkeypolicy_desc', 'admin'), 1));
     $temp->add(new admin_setting_configcheckbox('disableuserimages', new lang_string('disableuserimages', 'admin'), new lang_string('configdisableuserimages', 'admin'), 0));
     $temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', new lang_string('emailchangeconfirmation', 'admin'), new lang_string('configemailchangeconfirmation', 'admin'), 1));
index ab41e3d..287a535 100644 (file)
@@ -164,7 +164,6 @@ require("$CFG->dirroot/lib/setup.php");
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/upgradelib.php');
 require_once($CFG->libdir.'/clilib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 require_once($CFG->libdir.'/installlib.php');
 require_once($CFG->libdir.'/testing/classes/test_lock.php');
 
index 4ec803d..364b54e 100644 (file)
@@ -36,7 +36,7 @@ Feature: Page contents assertions
     And I log in as "admin"
     And I follow "Course 1"
     When I click on "Move this to the dock" "button" in the "Administration" "block"
-    Then I should not see "Question bank"
+    Then I should not see "Question bank" in the "region-pre" "region"
     And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
 
   @javascript
@@ -46,4 +46,4 @@ Feature: Page contents assertions
       | Course 1 | C1 | 0 |
     And I log in as "admin"
     When I click on "Move this to the dock" "button" in the "Administration" "block"
-    Then I should not see "Turn editing on"
+    Then I should not see "Turn editing on" in the "region-pre" "region"
index c0d3665..45d1ed6 100644 (file)
@@ -37,9 +37,9 @@ Feature: Set up contextual data for tests
     And I follow "Cat 3"
     And I should see "Course 1"
     And I should see "Course 2"
-    And I select "Cat 1 / Cat 2" from "Course categories:"
+    And I follow "Cat 2"
     And I should see "No courses in this category"
-    And I select "Miscellaneous" from "Course categories:"
+    And I follow "Miscellaneous"
     And I should see "Course 3"
 
   @javascript
index 4bf47d0..9aa1c88 100644 (file)
@@ -10,10 +10,10 @@ Feature: Forms manipulation
     And I follow "Admin User"
     And I follow "Edit profile"
     When I fill in "First name" with "Field value"
-    And I select "Use standard web forms" from "When editing text"
+    And I select "Plain text area" from "Text editor"
     And I check "Unmask"
     Then the "First name" field should match "Field value" value
-    And the "When editing text" select box should contain "Use standard web forms"
+    And the "Text editor" select box should contain "Plain text area"
     And the "Unmask" checkbox should be checked
     And I uncheck "Unmask"
     And the "Unmask" checkbox should not be checked
@@ -32,5 +32,5 @@ Feature: Forms manipulation
     Then I should see "Close the quiz"
     And I should see "Group mode"
     And I should see "Grouping"
-    And I should not see "Show more..."
+    And I should not see "Show more..." in the "region-main-box" "region"
     And I should see "Show less..."
index 3357365..c7e622f 100644 (file)
@@ -165,7 +165,7 @@ function tool_dbtransfer_get_drivers() {
 function tool_dbtransfer_create_maintenance_file() {
     global $CFG;
 
-    register_shutdown_function('tool_dbtransfer_maintenance_callback');
+    core_shutdown_manager::register_function('tool_dbtransfer_maintenance_callback');
 
     $options = new stdClass();
     $options->trusted = false;
index 37c3600..1a1866c 100644 (file)
@@ -158,9 +158,8 @@ class tool_installaddon_installer {
      */
     public function get_plugin_types_menu() {
         global $CFG;
-        require_once($CFG->libdir.'/pluginlib.php');
 
-        $pluginman = plugin_manager::instance();
+        $pluginman = core_plugin_manager::instance();
 
         $menu = array('' => get_string('choosedots'));
         foreach (array_keys($pluginman->get_plugin_types()) as $plugintype) {
index be593a2..13dcacc 100644 (file)
@@ -90,7 +90,6 @@ require(__DIR__ . '/../../../../lib/phpunit/bootstrap.php');
 require_once($CFG->libdir.'/adminlib.php');
 require_once($CFG->libdir.'/upgradelib.php');
 require_once($CFG->libdir.'/clilib.php');
-require_once($CFG->libdir.'/pluginlib.php');
 require_once($CFG->libdir.'/installlib.php');
 
 if ($unrecognized) {
index eda56a8..f471b23 100644 (file)
@@ -572,6 +572,7 @@ function tool_qeupgradehelper_generate_unit_test($questionsessionid, $namesuffix
             'variant' => 1,
             'maxmark' => {$question->maxmark},
             'minfraction' => 0,
+            'maxfraction' => 1,
             'flagged' => 0,
             'questionsummary' => '',
             'rightanswer' => '',
index 782e1e8..4691ead 100644 (file)
@@ -347,7 +347,8 @@ class tool_uploadcourse_course {
     /**
      * Get the directory of the object to restore.
      *
-     * @return string|false subdirectory in $CFG->tempdir/backup/...
+     * @return string|false|null subdirectory in $CFG->tempdir/backup/..., false when an error occured
+     *                           and null when there is simply nothing.
      */
     protected function get_restore_content_dir() {
         $backupfile = null;
@@ -366,6 +367,9 @@ class tool_uploadcourse_course {
                 $this->error($key, $message);
             }
             return false;
+        } else if ($dir === false) {
+            // We want to return null when nothing was wrong, but nothing was found.
+            $dir = null;
         }
 
         if (empty($dir) && !empty($this->importoptions['restoredir'])) {
@@ -656,8 +660,12 @@ class tool_uploadcourse_course {
         $this->enrolmentdata = tool_uploadcourse_helper::get_enrolment_data($this->rawdata);
 
         // Restore data.
-        // TODO log warnings.
+        // TODO Speed up things by not really extracting the backup just yet, but checking that
+        // the backup file or shortname passed are valid. Extraction should happen in proceed().
         $this->restoredata = $this->get_restore_content_dir();
+        if ($this->restoredata === false) {
+            return false;
+        }
 
         // We can only reset courses when allowed and we are updating the course.
         if ($this->importoptions['reset'] || $this->options['reset']) {
index 79b10ed..7113ded 100644 (file)
@@ -194,6 +194,10 @@ class tool_uploadcourse_processor {
         $deleted = 0;
         $errors = 0;
 
+        // We will most certainly need extra time and memory to process big files.
+        @set_time_limit(0);
+        raise_memory_limit(MEMORY_EXTRA);
+
         // Loop over the CSV lines.
         while ($line = $this->cir->next()) {
             $this->linenb++;
@@ -330,6 +334,10 @@ class tool_uploadcourse_processor {
         }
         $tracker->start();
 
+        // We might need extra time and memory depending on the number of rows to preview.
+        @set_time_limit(0);
+        raise_memory_limit(MEMORY_EXTRA);
+
         // Loop over the CSV lines.
         $preview = array();
         while (($line = $this->cir->next()) && $rows > $this->linenb) {
index 3459c4a..8f86212 100644 (file)
@@ -708,6 +708,46 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         set_time_limit(0);
     }
 
+    public function test_restore_invalid_file() {
+        $this->resetAfterTest();
+
+        // Restore from a non-existing file should not be allowed.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => 'A1', 'backupfile' => '/lead/no/where',
+            'category' => 1, 'fullname' => 'A1');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('cannotreadbackupfile', $co->get_errors());
+
+        // Restore from an invalid file should not be allowed.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => 'A1', 'backupfile' => __FILE__,
+            'category' => 1, 'fullname' => 'A1');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('invalidbackupfile', $co->get_errors());
+
+        // Zip packer throws a debugging message, this assertion is only here to prevent
+        // the message from being displayed.
+        $this->assertDebuggingCalled();
+    }
+
+    public function test_restore_invalid_course() {
+        $this->resetAfterTest();
+
+        // Restore from an invalid file should not be allowed.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => 'A1', 'templatecourse' => 'iamnotavalidcourse',
+            'category' => 1, 'fullname' => 'A1');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('coursetorestorefromdoesnotexist', $co->get_errors());
+    }
+
     /**
      * Testing the reset on groups, group members and enrolments.
      */
index 26876ce..9dfc288 100644 (file)
@@ -237,19 +237,6 @@ class admin_uploaduser_form2 extends moodleform {
         $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
         $mform->setDefault('autosubscribe', 1);
 
-        $editors = editors_get_enabled();
-        if (count($editors) > 1) {
-            $choices = array();
-            $choices['0'] = get_string('texteditor');
-            $choices['1'] = get_string('htmleditor');
-            $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
-            $mform->setDefault('htmleditor', 1);
-        } else {
-            $mform->addElement('hidden', 'htmleditor');
-            $mform->setDefault('htmleditor', 1);
-            $mform->setType('htmleditor', PARAM_INT);
-        }
-
         $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="25"');
         $mform->setType('city', PARAM_TEXT);
         if (empty($CFG->defaultcity)) {
index 5f6a468..d4223b6 100644 (file)
@@ -45,7 +45,7 @@ $table->define_columns(array('name', 'version', 'uninstall'));
 $table->define_headers(array(get_string('plugin'), get_string('version'), $struninstall));
 $table->define_baseurl($PAGE->url);
 $table->set_attribute('id', 'toolplugins');
-$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
+$table->set_attribute('class', 'admintable generaltable');
 $table->setup();
 
 $plugins = array();
@@ -73,7 +73,7 @@ foreach ($installed as $config) {
 
 foreach ($plugins as $plugin => $name) {
     $uninstall = '';
-    if ($uninstallurl = plugin_manager::instance()->get_uninstall_url('tool_'.$plugin)) {
+    if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url('tool_'.$plugin, 'manage')) {
         $uninstall = html_writer::link($uninstallurl, $struninstall);
     }
 
index b18fa1a..3155958 100644 (file)
@@ -29,3 +29,5 @@ defined('MOODLE_INTERNAL') || die();
 $plugin->version   = 2013052100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'auth_cas';        // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('auth_ldap' => 2013052100);
index a01fc6e..333142a 100644 (file)
@@ -134,6 +134,11 @@ class auth_plugin_db extends auth_plugin_base {
         }
     }
 
+    /**
+     * Connect to external database.
+     *
+     * @return ADOConnection
+     */
     function db_init() {
         // Connect to the external database (forcing new connection).
         $authdb = ADONewConnection($this->config->type);
@@ -781,6 +786,76 @@ class auth_plugin_db extends auth_plugin_base {
         }
         return $text;
     }
+
+    /**
+     * Test if settings are ok, print info to output.
+     * @private
+     */
+    public function test_settings() {
+        global $CFG, $OUTPUT;
+
+        // NOTE: this is not localised intentionally, admins are supposed to understand English at least a bit...
+
+        raise_memory_limit(MEMORY_HUGE);
+
+        if (empty($this->config->table)) {
+            echo $OUTPUT->notification('External table not specified.', 'notifyproblem');
+            return;
+        }
+
+        if (empty($this->config->fielduser)) {
+            echo $OUTPUT->notification('External user field not specified.', 'notifyproblem');
+            return;
+        }
+
+        $olddebug = $CFG->debug;
+        $olddisplay = ini_get('display_errors');
+        ini_set('display_errors', '1');
+        $CFG->debug = DEBUG_DEVELOPER;
+        $olddebugauthdb = $this->config->debugauthdb;
+        $this->config->debugauthdb = 1;
+        error_reporting($CFG->debug);
+
+        $adodb = $this->db_init();
+
+        if (!$adodb or !$adodb->IsConnected()) {
+            $this->config->debugauthdb = $olddebugauthdb;
+            $CFG->debug = $olddebug;
+            ini_set('display_errors', $olddisplay);
+            error_reporting($CFG->debug);
+            ob_end_flush();
+
+            echo $OUTPUT->notification('Cannot connect the database.', 'notifyproblem');
+            return;
+        }
+
+        $rs = $adodb->Execute("SELECT *
+                                 FROM {$this->config->table}
+                                WHERE {$this->config->fielduser} <> 'random_unlikely_username'"); // Any unlikely name is ok here.
+
+        if (!$rs) {
+            echo $OUTPUT->notification('Can not read external table.', 'notifyproblem');
+
+        } else if ($rs->EOF) {
+            echo $OUTPUT->notification('External table is empty.', 'notifyproblem');
+            $rs->close();
+
+        } else {
+            $fields_obj = $rs->FetchObj();
+            $columns = array_keys((array)$fields_obj);
+
+            echo $OUTPUT->notification('External table contains following columns:<br />'.implode(', ', $columns), 'notifysuccess');
+            $rs->close();
+        }
+
+        $adodb->Close();
+
+        $this->config->debugauthdb = $olddebugauthdb;
+        $CFG->debug = $olddebug;
+        ini_set('display_errors', $olddisplay);
+        error_reporting($CFG->debug);
+        ob_end_flush();
+    }
 }
 
 
diff --git a/auth/test_settings.php b/auth/test_settings.php
new file mode 100644 (file)
index 0000000..a0ff227
--- /dev/null
@@ -0,0 +1,78 @@
+<?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/>.
+
+/**
+ * Test auth settings.
+ *
+ * @package    core_auth
+ * @copyright  2013 Petr Skoda {@link http://skodak.org}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require(__DIR__.'../../config.php');
+require_once("$CFG->libdir/adminlib.php");
+
+$auth = optional_param('auth', '', PARAM_RAW);
+if (!core_component::is_valid_plugin_name('auth', $auth)) {
+    $auth = '';
+} else if (!file_exists("$CFG->dirroot/auth/$auth/auth.php")) {
+    $auth = '';
+}
+
+require_login();
+require_capability('moodle/site:config', context_system::instance());
+
+navigation_node::override_active_url(new moodle_url('/admin/settings.php', array('section'=>'manageauths')));
+admin_externalpage_setup('authtestsettings');
+
+$returnurl = new moodle_url('/admin/settings.php', array('section'=>'manageauths'));
+
+echo $OUTPUT->header();
+
+if (!$auth) {
+    $options = array();
+    $plugins = core_component::get_plugin_list('auth');
+    foreach ($plugins as $name => $fulldir) {
+        $plugin = get_auth_plugin($name);
+        if (!$plugin or !method_exists($plugin, 'test_settings')) {
+            continue;
+        }
+        $options[$name] = get_string('pluginname', 'auth_'.$name);
+    }
+
+    if (!$options) {
+        redirect($returnurl);
+    }
+
+    echo $OUTPUT->heading(get_string('testsettings', 'core_auth'));
+
+    $url = new moodle_url('/auth/test_settings.php', array('sesskey'=>sesskey()));
+    echo $OUTPUT->single_select($url, 'auth', $options);
+
+    echo $OUTPUT->footer();
+}
+
+$plugin = get_auth_plugin($auth);
+if (!$plugin or !method_exists($plugin, 'test_settings')) {
+    redirect($returnurl);
+}
+
+echo $OUTPUT->heading(get_string('testsettingsheading', 'core_auth', get_string('pluginname', 'auth_'.$auth)));
+
+$plugin->test_settings();
+
+echo $OUTPUT->continue_button($returnurl);
+echo $OUTPUT->footer();
index cf7d3be..aa1ad4d 100644 (file)
@@ -88,14 +88,30 @@ if (!($bc = backup_ui::load_controller($backupid))) {
                             backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id);
 }
 $backup = new backup_ui($bc);
-$backup->process();
 
-$PAGE->set_title($heading.': '.$backup->get_stage_name());
+$PAGE->set_title($heading);
 $PAGE->set_heading($heading);
-$PAGE->navbar->add($backup->get_stage_name());
 
 $renderer = $PAGE->get_renderer('core','backup');
 echo $OUTPUT->header();
+
+// Prepare a progress bar which can display optionally during long-running
+// operations while setting up the UI.
+$slowprogress = new core_backup_display_progress_if_slow(get_string('preparingui', 'backup'));
+
+$previous = optional_param('previous', false, PARAM_BOOL);
+if ($backup->get_stage() == backup_ui::STAGE_SCHEMA && !$previous) {
+    // After schema stage, we are probably going to get to the confirmation stage,
+    // The confirmation stage has 2 sets of progress, so this is needed to prevent
+    // it showing 2 progress bars.
+    $twobars = true;
+    $slowprogress->start_progress('', 2);
+} else {
+    $twobars = false;
+}
+$backup->get_controller()->set_progress($slowprogress);
+$backup->process();
+
 if ($backup->enforce_changed_dependencies()) {
     debugging('Your settings have been altered due to unmet dependencies', DEBUG_DEVELOPER);
 }
@@ -112,8 +128,16 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
     $backup->save_controller();
 }
 
+// Displaying UI can require progress reporting, so do it here before outputting
+// the backup stage bar (as part of the existing progress bar, if required).
+$ui = $backup->display($renderer);
+if ($twobars) {
+    $slowprogress->end_progress();
+}
+
 echo $renderer->progress_bar($backup->get_progress_bar());
-echo $backup->display($renderer);
+
+echo $ui;
 $backup->destroy();
 unset($backup);
-echo $OUTPUT->footer();
\ No newline at end of file
+echo $OUTPUT->footer();
index 1dcbee8..3d5653f 100644 (file)
@@ -20,7 +20,7 @@ class cssparser {
 
   function cssparser($html = true) {
     // Register "destructor"
-    register_shutdown_function(array(&$this, "finalize"));
+    core_shutdown_manager::register_function(array(&$this, "finalize"));
     $this->html = ($html != false);
     $this->Clear();
   }
index 922318c..3877335 100644 (file)
@@ -209,7 +209,7 @@ abstract class backup_questions_activity_structure_step extends backup_activity_
 
         $qas = new backup_nested_element($nameprefix . 'question_attempts');
         $qa = new backup_nested_element($nameprefix . 'question_attempt', array('id'), array(
-                'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction',
+                'slot', 'behaviour', 'questionid', 'maxmark', 'minfraction', 'maxfraction',
                 'flagged', 'questionsummary', 'rightanswer', 'responsesummary',
                 'timemodified'));
 
@@ -1191,7 +1191,7 @@ class backup_users_structure_step extends backup_structure_step {
             'confirmed', 'policyagreed', 'deleted',
             'lang', 'theme', 'timezone', 'firstaccess',
             'lastaccess', 'lastlogin', 'currentlogin',
-            'mailformat', 'maildigest', 'maildisplay', 'htmleditor',
+            'mailformat', 'maildigest', 'maildisplay',
             'autosubscribe', 'trackforums', 'timecreated',
             'timemodified', 'trustbitmask');
 
@@ -1589,7 +1589,8 @@ class backup_main_structure_step extends backup_structure_step {
         $info['original_system_contextid'] = context_system::instance()->id;
 
         // Get more information from controller
-        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($this->get_backupid());
+        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
+                $this->get_backupid(), $this->get_task()->get_progress());
 
         // Define elements
 
@@ -1753,7 +1754,8 @@ class backup_store_backup_file extends backup_execution_step {
         $has_file_references = backup_controller_dbops::backup_includes_file_references($this->get_backupid());
         // Perform storage and return it (TODO: shouldn't be array but proper result object)
         return array(
-            'backup_destination' => backup_helper::store_backup_file($this->get_backupid(), $zipfile),
+            'backup_destination' => backup_helper::store_backup_file($this->get_backupid(), $zipfile,
+                    $this->task->get_progress()),
             'include_file_references_to_external_content' => $has_file_references
         );
     }
index 1afa523..dea8ab0 100644 (file)
@@ -4047,6 +4047,10 @@ abstract class restore_questions_activity_structure_step extends restore_activit
         $data->questionid      = $question->newitemid;
         $data->timemodified    = $this->apply_date_offset($data->timemodified);
 
+        if (!property_exists($data, 'maxfraction')) {
+            $data->maxfraction = 1;
+        }
+
         $newitemid = $DB->insert_record('question_attempts', $data);
 
         $this->set_mapping($nameprefix . 'question_attempt', $oldid, $newitemid);
index 9fd95ac..cb4577c 100644 (file)
@@ -350,15 +350,32 @@ abstract class backup_controller_dbops extends backup_dbops {
 
     /**
      * Get details information for main moodle_backup.xml file, extracting it from
-     * the specified controller
+     * the specified controller.
+     *
+     * If you specify the progress monitor, this will start a new progress section
+     * to track progress in processing (in case this task takes a long time).
+     *
+     * @param string $backupid Backup ID
+     * @param core_backup_progress $progress Optional progress monitor
      */
-    public static function get_moodle_backup_information($backupid) {
+    public static function get_moodle_backup_information($backupid,
+            core_backup_progress $progress = null) {
+
+        // Start tracking progress if required (for load_controller).
+        if ($progress) {
+            $progress->start_progress('get_moodle_backup_information', 2);
+        }
 
         $detailsinfo = array(); // Information details
         $contentsinfo= array(); // Information about backup contents
         $settingsinfo= array(); // Information about backup settings
         $bc = self::load_controller($backupid); // Load controller
 
+        // Note that we have loaded controller.
+        if ($progress) {
+            $progress->progress(1);
+        }
+
         // Details info
         $detailsinfo['id'] = $bc->get_id();
         $detailsinfo['backup_id'] = $bc->get_backupid();
@@ -377,8 +394,15 @@ abstract class backup_controller_dbops extends backup_dbops {
         $contentsinfo['sections']   = array();
         $contentsinfo['course']     = array();
 
+        // Get tasks and start nested progress.
+        $tasks = $bc->get_plan()->get_tasks();
+        if ($progress) {
+            $progress->start_progress('get_moodle_backup_information', count($tasks));
+            $done = 1;
+        }
+
         // Contents info (extract information from tasks)
-        foreach ($bc->get_plan()->get_tasks() as $task) {
+        foreach ($tasks as $task) {
 
             if ($task instanceof backup_activity_task) { // Activity task
 
@@ -407,10 +431,21 @@ abstract class backup_controller_dbops extends backup_dbops {
                 list($contentinfo, $settings) = self::get_root_backup_information($task);
                 $settingsinfo = array_merge($settingsinfo, $settings);
             }
+
+            // Report task handled.
+            if ($progress) {
+                $progress->progress($done++);
+            }
         }
 
         $bc->destroy(); // Always need to destroy controller to handle circular references
 
+        // Finish progress reporting.
+        if ($progress) {
+            $progress->end_progress();
+            $progress->end_progress();
+        }
+
         return array(array((object)$detailsinfo), $contentsinfo, $settingsinfo);
     }
 
index b1561d8..bdb3775 100644 (file)
@@ -1180,6 +1180,16 @@ abstract class restore_dbops {
                         $status = $DB->insert_record('user_preferences', $preference);
                     }
                 }
+                // Special handling for htmleditor which was converted to a preference.
+                if (isset($user->htmleditor)) {
+                    if ($user->htmleditor == 0) {
+                        $preference = new stdClass();
+                        $preference->userid = $newuserid;
+                        $preference->name = 'htmleditor';
+                        $preference->value = 'textarea';
+                        $status = $DB->insert_record('user_preferences', $preference);
+                    }
+                }
 
                 // Create user files in pool (profile, icon, private) by context
                 restore_dbops::send_files_to_pool($basepath, $restoreid, 'user', 'icon', $recuser->parentitemid, $userid);
index 87b6eba..e1c9d1e 100644 (file)
@@ -179,17 +179,22 @@ abstract class backup_helper {
      *
      * Note: the $filepath is deleted if the backup file is created successfully
      *
+     * If you specify the progress monitor, this will start a new progress section
+     * to track progress in processing (in case this task takes a long time).
+     *
      * @param int $backupid
      * @param string $filepath zip file containing the backup
+     * @param core_backup_progress $progress Optional progress monitor
      * @return stored_file if created, null otherwise
      *
      * @throws moodle_exception in case of any problems
      */
-    static public function store_backup_file($backupid, $filepath) {
+    static public function store_backup_file($backupid, $filepath, core_backup_progress $progress = null) {
         global $CFG;
 
         // First of all, get some information from the backup_controller to help us decide
-        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information($backupid);
+        list($dinfo, $cinfo, $sinfo) = backup_controller_dbops::get_moodle_backup_information(
+                $backupid, $progress);
 
         // Extract useful information to decide
         $hasusers  = (bool)$sinfo['users']->value;     // Backup has users
index 2a4f06b..5b19a2b 100644 (file)
@@ -74,6 +74,7 @@ require_once($CFG->dirroot . '/backup/util/loggers/output_indented_logger.class.
 require_once($CFG->dirroot . '/backup/util/progress/core_backup_progress.class.php');
 require_once($CFG->dirroot . '/backup/util/progress/core_backup_null_progress.class.php');
 require_once($CFG->dirroot . '/backup/util/progress/core_backup_display_progress.class.php');
+require_once($CFG->dirroot . '/backup/util/progress/core_backup_display_progress_if_slow.class.php');
 require_once($CFG->dirroot . '/backup/util/settings/setting_dependency.class.php');
 require_once($CFG->dirroot . '/backup/util/settings/base_setting.class.php');
 require_once($CFG->dirroot . '/backup/util/settings/backup_setting.class.php');
index 4065212..257a2ec 100644 (file)
@@ -170,6 +170,11 @@ class backup_ui_stage_initial extends backup_ui_stage {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 class backup_ui_stage_schema extends backup_ui_stage {
+    /**
+     * @var int Maximum number of settings to add to form at once
+     */
+    const MAX_SETTINGS_BATCH = 1000;
+
     /**
      * Schema stage constructor
      * @param backup_moodleform $ui
@@ -236,6 +241,14 @@ class backup_ui_stage_schema extends backup_ui_stage {
             $courseheading = false;
             $add_settings = array();
             $dependencies = array();
+
+            // Track progress through each stage.
+            $progress = $this->ui->get_controller()->get_progress();
+            $progress->start_progress('Initialise stage form', 3);
+
+            // Get settings for all tasks.
+            $progress->start_progress('', count($tasks));
+            $done = 1;
             foreach ($tasks as $task) {
                 if (!($task instanceof backup_root_task)) {
                     if (!$courseheading) {
@@ -263,11 +276,37 @@ class backup_ui_stage_schema extends backup_ui_stage {
                         }
                     }
                 }
+                // Update progress.
+                $progress->progress($done++);
             }
-            $form->add_settings($add_settings);
+            $progress->end_progress();
+
+            // Add settings for tasks in batches of up to 1000. Adding settings
+            // in larger batches improves performance, but if it takes too long,
+            // we won't be able to update the progress bar so the backup might
+            // time out. 1000 is chosen to balance this.
+            $numsettings = count($add_settings);
+            $progress->start_progress('', ceil($numsettings / self::MAX_SETTINGS_BATCH));
+            $start = 0;
+            $done = 1;
+            while($start < $numsettings) {
+                $length = min(self::MAX_SETTINGS_BATCH, $numsettings - $start);
+                $form->add_settings(array_slice($add_settings, $start, $length));
+                $start += $length;
+                $progress->progress($done++);
+            }
+            $progress->end_progress();
+
+            $progress->start_progress('', count($dependencies));
+            $done = 1;
             foreach ($dependencies as $depsetting) {
                 $form->add_dependencies($depsetting);
+                $progress->progress($done++);
             }
+            $progress->end_progress();
+
+            // End overall progress through creating form.
+            $progress->end_progress();
             $this->stageform = $form;
         }
         return $this->stageform;
@@ -357,7 +396,13 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
                 }
             }
 
-            foreach ($this->ui->get_tasks() as $task) {
+            // Track progress through tasks.
+            $progress = $this->ui->get_controller()->get_progress();
+            $tasks = $this->ui->get_tasks();
+            $progress->start_progress('initialise_stage_form', count($tasks));
+            $done = 1;
+
+            foreach ($tasks as $task) {
                 if ($task instanceof backup_root_task) {
                     // If its a backup root add a root settings heading to group nicely
                     $form->add_heading('rootsettings', get_string('rootsettings', 'backup'));
@@ -373,7 +418,10 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
                         $form->add_fixed_setting($setting, $task);
                     }
                 }
+                // Update progress.
+                $progress->progress($done++);
             }
+            $progress->end_progress();
             $this->stageform = $form;
         }
         return $this->stageform;
index 29c1f1d..1615dac 100644 (file)
@@ -41,6 +41,8 @@ $result = badges_check_backpack_accessibility();
 $outcome = new stdClass();
 $outcome->code = $result;
 $outcome->response = get_string('error:backpacknotavailable', 'badges') . $OUTPUT->help_icon('backpackavailability', 'badges');
+
+echo $OUTPUT->header();
 echo json_encode($outcome);
 
 die();
index 0bd944e..2e8d3ac 100644 (file)
@@ -24,6 +24,8 @@
  * @author     Yuliya Bozhko <yuliya.bozhko@totaralms.com>
  */
 
+define('AJAX_SCRIPT', true);
+
 require_once(dirname(dirname(__FILE__)) . '/config.php');
 
 if (empty($CFG->enablebadges)) {
@@ -43,6 +45,6 @@ if (!is_null($action)) {
     $json = $assertion->get_badge_assertion();
 }
 
-header('Content-type: application/json; charset=utf-8');
 
+echo $OUTPUT->header();
 echo json_encode($json);
index 55bc2ec..bbcc78f 100644 (file)
@@ -34,6 +34,7 @@ require_sesskey();
 require_login();
 $PAGE->set_url('/badges/backpackconnect.php');
 $PAGE->set_context(context_system::instance());
+echo $OUTPUT->header();
 
 // Use PHP input filtering as there is no PARAM type for
 // the type of cleaning that is required (ASCII chars 32-127 only).
index 8144a38..a20e70b 100644 (file)
@@ -160,10 +160,11 @@ class award_criteria_courseset extends award_criteria {
         // In courseset, print out only the ones that were already selected.
         foreach ($this->params as $p) {
             if ($course = $DB->get_record('course', array('id' => $p['course']))) {
+                $coursecontext = context_course::instance($course->id);
                 $param = array(
                         'id' => $course->id,
                         'checked' => true,
-                        'name' => ucfirst($course->fullname),
+                        'name' => ucfirst(format_string($course->fullname, true, array('context' => $coursecontext))),
                         'error' => false
                 );
 
index a0d2f17..d476cfc 100644 (file)
@@ -82,10 +82,11 @@ if ($type == BADGE_TYPE_SITE) {
     navigation_node::override_active_url(new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)));
 } else {
     require_login($course);
+    $coursecontext = context_course::instance($course->id);
     $title = get_string('coursebadges', 'badges');
-    $PAGE->set_context(context_course::instance($course->id));
+    $PAGE->set_context($coursecontext);
     $PAGE->set_pagelayout('course');
-    $PAGE->set_heading($course->fullname . ': ' . $hdr);
+    $PAGE->set_heading(format_string($course->fullname, true, array('context' => $coursecontext)) . ': ' . $hdr);
     navigation_node::override_active_url(
         new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_COURSE, 'id' => $course->id))
     );
index 756ef91..d83ce59 100644 (file)
@@ -45,11 +45,13 @@ $title = get_string('create', 'badges');
 
 if (($type == BADGE_TYPE_COURSE) && ($course = $DB->get_record('course', array('id' => $courseid)))) {
     require_login($course);
-    $PAGE->set_context(context_course::instance($course->id));
+    $coursecontext = context_course::instance($course->id);
+    $PAGE->set_context($coursecontext);
     $PAGE->set_pagelayout('course');
     $PAGE->set_url('/badges/newbadge.php', array('type' => $type, 'id' => $course->id));
-    $PAGE->set_heading($course->fullname . ": " . $title);
-    $PAGE->set_title($course->fullname . ": " . $title);
+    $heading = format_string($course->fullname, true, array('context' => $coursecontext)) . ": " . $title;
+    $PAGE->set_heading($heading);
+    $PAGE->set_title($heading);
 } else {
     $PAGE->set_context(context_system::instance());
     $PAGE->set_pagelayout('admin');
index b3fa735..2fa2614 100644 (file)
@@ -493,8 +493,8 @@ class core_badges_renderer extends plugin_renderer_base {
 
         // Local badges.
         $localhtml = html_writer::start_tag('fieldset', array('id' => 'issued-badge-table', 'class' => 'generalbox'));
-        $localhtml .= html_writer::tag('legend',
-                    $this->output->heading_with_help(get_string('localbadges', 'badges', $SITE->fullname), 'localbadgesh', 'badges'));
+        $heading = get_string('localbadges', 'badges', format_string($SITE->fullname, true, array('context' => context_system::instance())));
+        $localhtml .= html_writer::tag('legend', $this->output->heading_with_help($heading, 'localbadgesh', 'badges'));
         if ($badges->badges) {
             $table = new html_table();
             $table->attributes['class'] = 'statustable';
index 33f2b91..d623c81 100644 (file)
@@ -68,7 +68,8 @@ if ($type == BADGE_TYPE_SITE) {
     $PAGE->set_heading($title);
 } else {
     require_login($course);
-    $title = $course->fullname . ': ' . get_string('coursebadges', 'badges');
+    $coursename = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
+    $title = $coursename . ': ' . get_string('coursebadges', 'badges');
     $PAGE->set_context(context_course::instance($course->id));
     $PAGE->set_pagelayout('course');
     $PAGE->set_heading($title);
index abe2808..41cd98e 100644 (file)
@@ -1,25 +1,71 @@
 <?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/>.
 
+/**
+ * Handles displaying the calendar block.
+ *
+ * @package    block_calendar_month
+ * @copyright  2004 Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 class block_calendar_month extends block_base {
-    function init() {
+
+    /**
+     * Initialise the block.
+     */
+    public function init() {
         $this->title = get_string('pluginname', 'block_calendar_month');
     }
 
-    function preferred_width() {
+    /**
+     * Return preferred_width.
+     *
+     * @return int
+     */
+    public function preferred_width() {
         return 210;
     }
 
-    function get_content() {
-        global $USER, $CFG, $SESSION;
-        $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
-        $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
+    /**
+     * Return the content of this block.
+     *
+     * @return stdClass the content
+     */
+    public function get_content() {
+        global $CFG;
+
+        $calm = optional_param('cal_m', 0, PARAM_INT);
+        $caly = optional_param('cal_y', 0, PARAM_INT);
+        $time = optional_param('time', 0, PARAM_INT);
 
         require_once($CFG->dirroot.'/calendar/lib.php');
 
-        if ($this->content !== NULL) {
+        if ($this->content !== null) {
             return $this->content;
         }
 
+        // If a day, month and year were passed then convert it to a timestamp. If these were passed then we can assume
+        // the day, month and year are passed as Gregorian, as no where in core should we be passing these values rather
+        // than the time. This is done for BC.
+        if (!empty($calm) && (!empty($caly))) {
+            $time = make_timestamp($caly, $calm, 1);
+        } else if (empty($time)) {
+            $time = time();
+        }
+
         $this->content = new stdClass;
         $this->content->text = '';
         $this->content->footer = '';
@@ -41,12 +87,12 @@ class block_calendar_month extends block_base {
 
         list($courses, $group, $user) = calendar_set_filters($filtercourse);
         if ($issite) {
-            // For the front page
-            $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'frontpage', $courseid);
-            // No filters for now
+            // For the front page.
+            $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'frontpage', $courseid, $time);
+            // No filters for now.
         } else {
-            // For any other course
-            $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y, 'course', $courseid);
+            // For any other course.
+            $this->content->text .= calendar_get_mini($courses, $group, $user, false, false, 'course', $courseid, $time);
             $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
             $this->content->text .= '<div class="filters calendar_filters">'.calendar_filter_controls($this->page->url).'</div>';
         }
index a387294..335bcc4 100644 (file)
@@ -1,25 +1,53 @@
 <?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/>.
 
+/**
+ * Handles displaying the calendar upcoming events block.
+ *
+ * @package    block_calendar_upcoming
+ * @copyright  2004 Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 class block_calendar_upcoming extends block_base {
-    function init() {
+
+    /**
+     * Initialise the block.
+     */
+    public function init() {
         $this->title = get_string('pluginname', 'block_calendar_upcoming');
     }
 
-    function get_content() {
-        global $USER, $CFG, $SESSION;
-        $cal_m = optional_param( 'cal_m', 0, PARAM_INT );
-        $cal_y = optional_param( 'cal_y', 0, PARAM_INT );
+    /**
+     * Return the content of this block.
+     *
+     * @return stdClass the content
+     */
+    public function get_content() {
+        global $CFG;
 
         require_once($CFG->dirroot.'/calendar/lib.php');
 
-        if ($this->content !== NULL) {
+        if ($this->content !== null) {
             return $this->content;
         }
         $this->content = new stdClass;
         $this->content->text = '';
 
         $filtercourse    = array();
-        if (empty($this->instance)) { // Overrides: use no course at all
+        if (empty($this->instance)) { // Overrides: use no course at all.
             $courseshown = false;
             $this->content->footer = '';
 
index fe21d76..a7224e5 100644 (file)
@@ -142,7 +142,7 @@ $fromformdata['subject'] = optional_param('subject', 'all', PARAM_ALPHANUMEXT);
 $fromformdata['audience'] = optional_param('audience', 'all', PARAM_ALPHANUMEXT);
 $fromformdata['language'] = optional_param('language', current_language(), PARAM_ALPHANUMEXT);
 $fromformdata['educationallevel'] = optional_param('educationallevel', 'all', PARAM_ALPHANUMEXT);
-$fromformdata['downloadable'] = optional_param('downloadable', 1, PARAM_ALPHANUM);
+$fromformdata['downloadable'] = optional_param('downloadable', $usercandownload, PARAM_ALPHANUM);
 $fromformdata['orderby'] = optional_param('orderby', 'newest', PARAM_ALPHA);
 $fromformdata['huburl'] = optional_param('huburl', HUB_MOODLEORGHUBURL, PARAM_URL);
 $fromformdata['search'] = $search;
index 3a01716..b92dd5c 100644 (file)
@@ -213,6 +213,7 @@ class community_hub_search_form extends moodleform {
             } else {
                 $mform->addElement('hidden', 'downloadable', 0);
             }
+            $mform->setType('downloadable', PARAM_INT);
 
             $options = array();
             $options['all'] = get_string('any');
index 9636ae7..8af781e 100644 (file)
@@ -28,3 +28,5 @@ defined('MOODLE_INTERNAL') || die();
 $plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'block_feedback';  // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('mod_feedback' => 2013050100);
index 1348e96..dd5d0e2 100644 (file)
@@ -28,3 +28,5 @@ defined('MOODLE_INTERNAL') || die();
 $plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'block_glossary_random'; // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('mod_glossary' => 2013050100);
index 0ed1df9..c16b985 100644 (file)
@@ -28,3 +28,5 @@ defined('MOODLE_INTERNAL') || die();
 $plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'block_quiz_results'; // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('mod_quiz' => 2013100200);
index 5159923..32317ce 100644 (file)
@@ -28,3 +28,5 @@ defined('MOODLE_INTERNAL') || die();
 $plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'block_search_forums'; // Full name of the plugin (used for diagnostics)
+
+$plugin->dependencies = array('mod_forum' => 2013092600);
index 6458220..b470ffc 100644 (file)
@@ -27,6 +27,16 @@ namespace core_calendar;
  */
 abstract class type_base {
 
+    /**
+     * Returns the name of the calendar.
+     *
+     * This is the non-translated name, usually just
+     * the name of the calendar folder.
+     *
+     * @return string the calendar name
+     */
+    public abstract function get_name();
+
     /**
      * Returns a list of all the possible days for all months.
      *
@@ -62,10 +72,76 @@ abstract class type_base {
      */
     public abstract function get_max_year();
 
+    /**
+     * Returns the number of days in a week.
+     *
+     * @return int the number of days
+     */
+    public abstract function get_num_weekdays();
+
+    /**
+     * Returns an indexed list of all the names of the weekdays.
+     *
+     * The list starts with the index 0. Each index, representing a
+     * day, must be an array that contains the indexes 'shortname'
+     * and 'fullname'.
+     *
+     * @return array array of days
+     */
+    public abstract function get_weekdays();
+
+    /**
+     * Returns the index of the starting week day.
+     *
+     * This may vary, for example in the Gregorian calendar, some may consider Monday
+     * as the start of the week, where as others may consider Sunday the start.
+     *
+     * @return int
+     */
+    public abstract function get_starting_weekday();
+
+    /**
+     * Returns the index of the weekday for a specific calendar date.
+     *
+     * @param int $year
+     * @param int $month
+     * @param int $day
+     * @return int
+     */
+    public abstract function get_weekday($year, $month, $day);
+
+    /**
+     * Returns the number of days in a given month.
+     *
+     *
+     * @param int $year
+     * @param int $month
+     * @return int the number of days
+     */
+    public abstract function get_num_days_in_month($year, $month);
+
+    /**
+     * Get the previous month.
+     *
+     * @param int $year
+     * @param int $month
+     * @return array previous month and year
+     */
+    public abstract function get_prev_month($year, $month);
+
+    /**
+     * Get the next month.
+     *
+     * @param int $year
+     * @param int $month
+     * @return array the following month and year
+     */
+    public abstract function get_next_month($year, $month);
+
     /**
      * Returns a formatted string that represents a date in user time.
      *
-     * @param int $date the timestamp in UTC, as obtained from the database
+     * @param int $time the timestamp in UTC, as obtained from the database
      * @param string $format strftime format
      * @param int|float|string $timezone the timezone to use
      *        {@link http://docs.moodle.org/dev/Time_API#Timezone}
@@ -75,7 +151,7 @@ abstract class type_base {
      *        if false then the leading zero is maintained
      * @return string the formatted date/time
      */
-    public abstract function timestamp_to_date_string($date, $format, $timezone, $fixday, $fixhour);
+    public abstract function timestamp_to_date_string($time, $format, $timezone, $fixday, $fixhour);
 
     /**
      * Given a $time timestamp in GMT (seconds since epoch), returns an array that represents
@@ -86,7 +162,7 @@ abstract class type_base {
      *        {@link http://docs.moodle.org/dev/Time_API#Timezone}
      * @return array an array that represents the date in user time
      */
-    public abstract function timestamp_to_date_array($time, $timezone);
+    public abstract function timestamp_to_date_array($time, $timezone = 99);
 
     /**
      * Provided with a day, month, year, hour and minute in the specific
@@ -97,7 +173,7 @@ abstract class type_base {
      * @param int $day
      * @param int $hour
      * @param int $minute
-     * @return array the converted day, month and year.
+     * @return array the converted date
      */
     public abstract function convert_to_gregorian($year, $month, $day, $hour = 0, $minute = 0);
 
@@ -110,7 +186,7 @@ abstract class type_base {
      * @param int $day
      * @param int $hour
      * @param int $minute
-     * @return array the converted day, month and year.
+     * @return array the converted date
      */
     public abstract function convert_from_gregorian($year, $month, $day, $hour = 0, $minute = 0);
 }
index 535dd2b..8a47a84 100644 (file)
@@ -74,7 +74,8 @@ class type_factory {
     public static function get_calendar_type() {
         global $CFG, $USER, $SESSION, $COURSE;
 
-        if (!empty($COURSE->id) and $COURSE->id != SITEID and !empty($COURSE->calendartype)) { // Course calendartype can override all other settings for this page.
+        // Course calendartype can override all other settings for this page.
+        if (!empty($COURSE->id) and $COURSE->id != SITEID and !empty($COURSE->calendartype)) {
             $return = $COURSE->calendartype;
         } else if (!empty($SESSION->calendartype)) { // Session calendartype can override other settings.
             $return = $SESSION->calendartype;
index 4f72df7..4074b1e 100644 (file)
@@ -69,8 +69,7 @@ $event->count_repeats();
 
 // Is used several times, and sometimes with modification if required
 $viewcalendarurl = new moodle_url(CALENDAR_URL.'view.php', array('view'=>'upcoming'));
-$viewcalendarurl->param('cal_y', userdate($event->timestart, '%Y'));
-$viewcalendarurl->param('cal_m', userdate($event->timestart, '%m'));
+$viewcalendarurl->param('time', $event->timestart, '%Y');
 
 // If confirm is set (PARAM_BOOL) then we have confirmation of initention to delete
 if ($confirm) {
index 027527b..bf1c6c2 100644 (file)
@@ -57,26 +57,34 @@ $action = optional_param('action', 'new', PARAM_ALPHA);
 $eventid = optional_param('id', 0, PARAM_INT);
 $courseid = optional_param('courseid', SITEID, PARAM_INT);
 $courseid = optional_param('course', $courseid, PARAM_INT);
-$cal_y = optional_param('cal_y', 0, PARAM_INT);
-$cal_m = optional_param('cal_m', 0, PARAM_INT);
-$cal_d = optional_param('cal_d', 0, PARAM_INT);
+$day = optional_param('cal_d', 0, PARAM_INT);
+$month = optional_param('cal_m', 0, PARAM_INT);
+$year = optional_param('cal_y', 0, PARAM_INT);
+$time = optional_param('time', 0, PARAM_INT);
+
+// If a day, month and year were passed then convert it to a timestamp. If these were passed
+// then we can assume the day, month and year are passed as Gregorian, as no where in core
+// should we be passing these values rather than the time. This is done for BC.
+if (!empty($day) && !empty($month) && !empty($year)) {
+    if (checkdate($month, $day, $year)) {
+        $time = make_timestamp($year, $month, $day);
+    } else {
+        $time = time();
+    }
+} else if (empty($time)) {
+    $time = time();
+}
 
 $url = new moodle_url('/calendar/event.php', array('action' => $action));
+
 if ($eventid != 0) {
     $url->param('id', $eventid);
 }
+
 if ($courseid != SITEID) {
     $url->param('course', $courseid);
 }
-if ($cal_y !== 0) {
-    $url->param('cal_y', $cal_y);
-}
-if ($cal_m !== 0) {
-    $url->param('cal_m', $cal_m);
-}
-if ($cal_d !== 0) {
-    $url->param('cal_d', $cal_d);
-}
+
 $PAGE->set_url($url);
 $PAGE->set_pagelayout('standard');
 
@@ -99,7 +107,7 @@ if ($action === 'delete' && $eventid > 0) {
     redirect($deleteurl);
 }
 
-$calendar = new calendar_information($cal_d, $cal_m, $cal_y);
+$calendar = new calendar_information(0, 0, 0, $time);
 $calendar->prepare_for_view($course, $courses);
 
 $formoptions = new stdClass;
@@ -133,16 +141,7 @@ if ($eventid !== 0) {
             unset($formoptions->eventtypes->groups);
         }
     }
-    if($cal_y && $cal_m && $cal_d && checkdate($cal_m, $cal_d, $cal_y)) {
-        $event->timestart = make_timestamp($cal_y, $cal_m, $cal_d, 0, 0, 0);
-    } else if($cal_y && $cal_m && checkdate($cal_m, 1, $cal_y)) {
-        $now = usergetdate(time());
-        if($cal_y == $now['year'] && $cal_m == $now['mon']) {
-            $event->timestart = make_timestamp($cal_y, $cal_m, $now['mday'], 0, 0, 0);
-        } else {
-            $event->timestart = make_timestamp($cal_y, $cal_m, 1, 0, 0, 0);
-        }
-    }
+    $event->timestart = $time;
     $event = new calendar_event($event);
     if (!calendar_add_event_allowed($event)) {
         print_error('nopermissions');
@@ -168,9 +167,7 @@ if ($data) {
 
     $params = array(
         'view' => 'day',
-        'cal_d' => userdate($event->timestart, '%d'),
-        'cal_m' => userdate($event->timestart, '%m'),
-        'cal_y' => userdate($event->timestart, '%Y'),
+        'time' => $event->timestart,
     );
     $eventurl = new moodle_url('/calendar/view.php', $params);
     if (!empty($event->courseid) && $event->courseid != SITEID) {
index d6a7981..92c2db3 100644 (file)
@@ -56,11 +56,28 @@ if (empty($CFG->enablecalendarexport)) {
 
 $courseid = optional_param('course', SITEID, PARAM_INT);
 $action = optional_param('action', '', PARAM_ALPHA);
-$day  = optional_param('cal_d', 0, PARAM_INT);
-$mon  = optional_param('cal_m', 0, PARAM_INT);
-$yr   = optional_param('cal_y', 0, PARAM_INT);
+$day = optional_param('cal_d', 0, PARAM_INT);
+$mon = optional_param('cal_m', 0, PARAM_INT);
+$year = optional_param('cal_y', 0, PARAM_INT);
+$time = optional_param('time', 0, PARAM_INT);
 $generateurl = optional_param('generateurl', 0, PARAM_BOOL);
 
+// Get the calendar type we are using.
+$calendartype = \core_calendar\type_factory::get_calendar_instance();
+
+// If a day, month and year were passed then convert it to a timestamp. If these were passed
+// then we can assume the day, month and year are passed as Gregorian, as no where in core
+// should we be passing these values rather than the time. This is done for BC.
+if (!empty($day) && !empty($mon) && !empty($year)) {
+    if (checkdate($mon, $day, $year)) {
+        $time = make_timestamp($year, $mon, $day);
+    } else {
+        $time = time();
+    }
+} else if (empty($time)) {
+    $time = time();
+}
+
 if ($courseid != SITEID && !empty($courseid)) {
     $course = $DB->get_record('course', array('id' => $courseid));
     $courses = array($course->id => $course);
@@ -72,36 +89,29 @@ if ($courseid != SITEID && !empty($courseid)) {
 }
 require_course_login($course);
 
-$url = new moodle_url('/calendar/export.php');
+$url = new moodle_url('/calendar/export.php', array('time' => $time));
+
 if ($action !== '') {
     $url->param('action', $action);
 }
-if ($day !== 0) {
-    $url->param('cal_d', $day);
-}
-if ($mon !== 0) {
-    $url->param('cal_m', $mon);
-}
-if ($yr !== 0) {
-    $url->param('cal_y', $yr);
-}
+
 if ($course !== NULL) {
     $url->param('course', $course->id);
 }
 $PAGE->set_url($url);
 
-$calendar = new calendar_information($day, $mon, $yr);
+$calendar = new calendar_information(0, 0, 0, $time);
 $calendar->prepare_for_view($course, $courses);
 
 $pagetitle = get_string('export', 'calendar');
-$now = usergetdate(time());
+$now = $calendartype->timestamp_to_date_array($time);
 
 // Print title and header
 if ($issite) {
     $PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id'=>$course->id)));
 }
 $link = new moodle_url(CALENDAR_URL.'view.php', array('view'=>'upcoming', 'course'=>$calendar->courseid));
-$PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, $now['mday'], $now['mon'], $now['year']));
+$PAGE->navbar->add(get_string('calendar', 'calendar'), calendar_get_link_href($link, 0, 0, 0, $time));
 $PAGE->navbar->add($pagetitle);
 
 $PAGE->set_title($course->shortname.': '.get_string('calendar', 'calendar').': '.$pagetitle);
@@ -125,14 +135,17 @@ switch($action) {
             $weekend = intval($CFG->calendar_weekend);
         }
 
+        // Get the number of days.
+        $numberofdaysinweek = $calendartype->get_num_weekdays();
+
         $authtoken = sha1($USER->id . $DB->get_field('user', 'password', array('id'=>$USER->id)). $CFG->calendar_exportsalt);
         // Let's populate some vars to let "common tasks" be somewhat smart...
-        // If today it's weekend, give the "next week" option
-        $allownextweek  = $weekend & (1 << $now['wday']);
-        // If it's the last week of the month, give the "next month" option
-        $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < 7;
-        // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option
-        $allowthisweek  = !(($weekend & (1 << $now['wday'])) && !($weekend & (1 << (($now['wday'] + 1) % 7))));
+        // If today it's weekend, give the "next week" option.
+        $allownextweek = $weekend & (1 << $now['wday']);
+        // If it's the last week of the month, give the "next month" option.
+        $allownextmonth = calendar_days_in_month($now['mon'], $now['year']) - $now['mday'] < $numberofdaysinweek;
+        // If today it's weekend but tomorrow it isn't, do NOT give the "this week" option.
+        $allowthisweek = !(($weekend & (1 << $now['wday'])) && !($weekend & (1 << (($now['wday'] + 1) % $numberofdaysinweek))));
         echo $renderer->basic_export_form($allowthisweek, $allownextweek, $allownextmonth, $USER->id, $authtoken);
         break;
 }
index 7cd585b..6e76e33 100644 (file)
@@ -31,10 +31,14 @@ if (!$authuserid && !$authusername) {
     die('Invalid authentication');
 }
 
+// Get the calendar type we are using.
+$calendartype = \core_calendar\type_factory::get_calendar_instance();
+
 $what = optional_param('preset_what', 'all', PARAM_ALPHA);
 $time = optional_param('preset_time', 'weeknow', PARAM_ALPHA);
 
-$now = usergetdate(time());
+$now = $calendartype->timestamp_to_date_array(time());
+
 // Let's see if we have sufficient and correct data
 $allowed_what = array('all', 'courses');
 $allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming', 'custom');
@@ -74,20 +78,23 @@ if(!empty($what) && !empty($time)) {
             $groups = false;
         }
 
+        // Store the number of days in the week.
+        $numberofdaysinweek = $calendartype->get_num_weekdays();
+
         switch($time) {
             case 'weeknow':
-                $startweekday  = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
-                $startmonthday = find_day_in_month($now['mday'] - 6, $startweekday, $now['mon'], $now['year']);
-                $startmonth    = $now['mon'];
-                $startyear     = $now['year'];
+                $startweekday = calendar_get_starting_weekday();
+                $startmonthday = find_day_in_month($now['mday'] - ($numberofdaysinweek - 1), $startweekday, $now['mon'], $now['year']);
+                $startmonth = $now['mon'];
+                $startyear = $now['year'];
                 if($startmonthday > calendar_days_in_month($startmonth, $startyear)) {
                     list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear);
                     $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
                 }
                 $timestart = make_timestamp($startyear, $startmonth, $startmonthday);
-                $endmonthday = $startmonthday + 7;
-                $endmonth    = $startmonth;
-                $endyear     = $startyear;
+                $endmonthday = $startmonthday + $numberofdaysinweek;
+                $endmonth = $startmonth;
+                $endyear = $startyear;
                 if($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
                     list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
                     $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
@@ -95,18 +102,18 @@ if(!empty($what) && !empty($time)) {
                 $timeend = make_timestamp($endyear, $endmonth, $endmonthday) - 1;
             break;
             case 'weeknext':
-                $startweekday  = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
+                $startweekday = calendar_get_starting_weekday();
                 $startmonthday = find_day_in_month($now['mday'] + 1, $startweekday, $now['mon'], $now['year']);
-                $startmonth    = $now['mon'];
-                $startyear     = $now['year'];
+                $startmonth = $now['mon'];
+                $startyear = $now['year'];
                 if($startmonthday > calendar_days_in_month($startmonth, $startyear)) {
                     list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear);
                     $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear);
                 }
                 $timestart = make_timestamp($startyear, $startmonth, $startmonthday);
-                $endmonthday = $startmonthday + 7;
-                $endmonth    = $startmonth;
-                $endyear     = $startyear;
+                $endmonthday = $startmonthday + $numberofdaysinweek;
+                $endmonth = $startmonth;
+                $endyear = $startyear;
                 if($endmonthday > calendar_days_in_month($endmonth, $endyear)) {
                     list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear);
                     $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear);
@@ -114,13 +121,24 @@ if(!empty($what) && !empty($time)) {
                 $timeend = make_timestamp($endyear, $endmonth, $endmonthday) - 1;
             break;
             case 'monthnow':
-                $timestart = make_timestamp($now['year'], $now['mon'], 1);
-                $timeend   = make_timestamp($now['year'], $now['mon'], calendar_days_in_month($now['mon'], $now['year']), 23, 59, 59);
+                // Convert to gregorian.
+                $gregoriandate = $calendartype->convert_to_gregorian($now['year'], $now['mon'], 1);
+
+                $timestart = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day']);
+                $timeend = make_timestamp($gregoriandate['year'], $gregoriandate['month'],
+                    calendar_days_in_month($now['mon'], $now['year']), 23, 59, 59);
             break;
             case 'monthnext':
+                // Get the next month for this calendar.
                 list($nextmonth, $nextyear) = calendar_add_month($now['mon'], $now['year']);
-                $timestart = make_timestamp($nextyear, $nextmonth, 1);
-                $timeend   = make_timestamp($nextyear, $nextmonth, calendar_days_in_month($nextmonth, $nextyear), 23, 59, 59);
+
+                // Convert to gregorian.
+                $gregoriandate = $calendartype->convert_to_gregorian($nextyear, $nextmonth, 1);
+
+                // Create the timestamps.
+                $timestart = make_timestamp($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day']);
+                $timeend   = make_timestamp($gregoriandate['year'], $gregoriandate['month'],
+                    calendar_days_in_month($nextmonth, $nextyear), 23, 59, 59);
             break;
             case 'recentupcoming':
                 //Events in the last 5 or next 60 days
index ede8280..a805f33 100644 (file)
@@ -126,7 +126,8 @@ define('CALENDAR_SUBSCRIPTION_REMOVE', 2);
  * @return array array of days
  */
 function calendar_get_days() {
-    return array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+    $calendartype = \core_calendar\type_factory::get_calendar_instance();
+    return $calendartype->get_weekdays();
 }
 
 /**
@@ -158,19 +159,8 @@ function calendar_get_subscription($id) {
  * @return int
  */
 function calendar_get_starting_weekday() {
-    global $CFG;
-
-    if (isset($CFG->calendar_startwday)) {
-        $firstday = $CFG->calendar_startwday;
-    } else {
-        $firstday = get_string('firstdayofweek', 'langconfig');
-    }
-
-    if(!is_numeric($firstday)) {
-        return CALENDAR_DEFAULT_STARTING_WEEKDAY;
-    } else {
-        return intval($firstday) % 7;
-    }
+    $calendartype = \core_calendar\type_factory::get_calendar_instance();
+    return $calendartype->get_starting_weekday();
 }
 
 /**
@@ -179,83 +169,96 @@ function calendar_get_starting_weekday() {
  * @param array $courses list of course to list events from
  * @param array $groups list of group
  * @param array $users user's info
- * @param int $cal_month calendar month in numeric, default is set to false
- * @param int $cal_year calendar month in numeric, default is set to false
- * @param string $placement the place/page the calendar is set to appear - passed on the the controls function
- * @param int $courseid id of the course the calendar is displayed on - passed on the the controls function
+ * @param int|bool $calmonth calendar month in numeric, default is set to false
+ * @param int|bool $calyear calendar month in numeric, default is set to false
+ * @param string|bool $placement the place/page the calendar is set to appear - passed on the the controls function
+ * @param int|bool $courseid id of the course the calendar is displayed on - passed on the the controls function
+ * @param int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth
+ *     and $calyear to support multiple calendars
  * @return string $content return html table for mini calendar
  */
-function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false, $placement = false, $courseid = false ) {
-    global $CFG, $USER, $OUTPUT;
+function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyear = false, $placement = false,
+    $courseid = false, $time = 0) {
+    global $CFG, $OUTPUT;
+
+    // Get the calendar type we are using.
+    $calendartype = \core_calendar\type_factory::get_calendar_instance();
 
     $display = new stdClass;
-    $display->minwday = get_user_preferences('calendar_startwday', calendar_get_starting_weekday());
-    $display->maxwday = $display->minwday + 6;
+
+    // Assume we are not displaying this month for now.
+    $display->thismonth = false;
 
     $content = '';
 
-    if(!empty($cal_month) && !empty($cal_year)) {
-        $thisdate = usergetdate(time()); // Date and time the user sees at his location
-        if($cal_month == $thisdate['mon'] && $cal_year == $thisdate['year']) {
-            // Navigated to this month
-            $date = $thisdate;
-            $display->thismonth = true;
+    // Do this check for backwards compatibility. The core should be passing a timestamp rather than month and year.
+    // If a month and year are passed they will be in Gregorian.
+    if (!empty($calmonth) && !empty($calyear)) {
+        // Ensure it is a valid date, else we will just set it to the current timestamp.
+        if (checkdate($calmonth, 1, $calyear)) {
+            $time = make_timestamp($calyear, $calmonth, 1);
         } else {
-            // Navigated to other month, let's do a nice trick and save us a lot of work...
-            if(!checkdate($cal_month, 1, $cal_year)) {
-                $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
-                $display->thismonth = true;
-            } else {
-                $date = array('mday' => 1, 'mon' => $cal_month, 'year' => $cal_year);
-                $display->thismonth = false;
-            }
+            $time = time();
+        }
+        $date = usergetdate($time);
+        if ($calmonth == $date['mon'] && $calyear == $date['year']) {
+            $display->thismonth = true;
+        }
+        // We can overwrite date now with the date used by the calendar type, if it is not Gregorian, otherwise
+        // there is no need as it is already in Gregorian.
+        if ($calendartype->get_name() != 'gregorian') {
+            $date = $calendartype->timestamp_to_date_array($time);
+        }
+    } else if (!empty($time)) {
+        // Get the specified date in the calendar type being used.
+        $date = $calendartype->timestamp_to_date_array($time);
+        $thisdate = $calendartype->timestamp_to_date_array(time());
+        if ($date['month'] == $thisdate['month'] && $date['year'] == $thisdate['year']) {
+            $display->thismonth = true;
+            // If we are the current month we want to set the date to the current date, not the start of the month.
+            $date = $thisdate;
         }
     } else {
-        $date = usergetdate(time()); // Date and time the user sees at his location
+        // Get the current date in the calendar type being used.
+        $time = time();
+        $date = $calendartype->timestamp_to_date_array($time);
         $display->thismonth = true;
     }
 
-    // Fill in the variables we 're going to use, nice and tidy
-    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']); // This is what we want to display
-    $display->maxdays = calendar_days_in_month($m, $y);
+    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']); // This is what we want to display.
 
-    if (get_user_timezone_offset() < 99) {
-        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
-        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y); // This is GMT
-        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y); // GMT
-    } else {
-        // no timezone info specified
-        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
-        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
-    }
+    // Get Gregorian date.
+    $gregoriandate = $calendartype->convert_to_gregorian($date['year'], $date['mon'], 1);
 
+    // Store the gregorian year and month to be used later.
+    list($gy, $gm, $gd, $gh, $gmin) = array($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'],
+        $gregoriandate['hour'], $gregoriandate['minute']);
+
+    // Get the max number of days in this month for this calendar type.
+    $display->maxdays = calendar_days_in_month($m, $y);
+    // Get the starting week day for this month.
     $startwday = dayofweek(1, $m, $y);
+    // Get the days in a week.
+    $daynames = calendar_get_days();
+    // Store the number of days in a week.
+    $numberofdaysinweek = $calendartype->get_num_weekdays();
+
+    // Set the min and max weekday.
+    $display->minwday = calendar_get_starting_weekday();
+    $display->maxwday = $display->minwday + ($numberofdaysinweek - 1);
+
+    // These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
+    $display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
+    $display->tend = make_timestamp($gy, $gm, $display->maxdays, 23, 59, 59);
 
     // Align the starting weekday to fall in our display range
     // This is simple, not foolproof.
-    if($startwday < $display->minwday) {
-        $startwday += 7;
+    if ($startwday < $display->minwday) {
+        $startwday += $numberofdaysinweek;
     }
 
-    // TODO: THIS IS TEMPORARY CODE!
-    // [pj] I was just reading through this and realized that I when writing this code I was probably
-    // asking for trouble, as all these time manipulations seem to be unnecessary and a simple
-    // make_timestamp would accomplish the same thing. So here goes a test:
-    //$test_start = make_timestamp($y, $m, 1);
-    //$test_end   = make_timestamp($y, $m, $display->maxdays, 23, 59, 59);
-    //if($test_start != usertime($display->tstart) - dst_offset_on($display->tstart)) {
-        //notify('Failed assertion in calendar/lib.php line 126; display->tstart = '.$display->tstart.', dst_offset = '.dst_offset_on($display->tstart).', usertime = '.usertime($display->tstart).', make_t = '.$test_start);
-    //}
-    //if($test_end != usertime($display->tend) - dst_offset_on($display->tend)) {
-        //notify('Failed assertion in calendar/lib.php line 130; display->tend = '.$display->tend.', dst_offset = '.dst_offset_on($display->tend).', usertime = '.usertime($display->tend).', make_t = '.$test_end);
-    //}
-
-
     // Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
-    $events = calendar_get_events(
-        usertime($display->tstart) - dst_offset_on($display->tstart),
-        usertime($display->tend) - dst_offset_on($display->tend),
-        $users, $groups, $courses);
+    $events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
 
     // Set event course class for course events
     if (!empty($events)) {
@@ -273,7 +276,6 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
     // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
     // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
     // arguments to this function.
-
     $hrefparams = array();
     if(!empty($courses)) {
         $courses = array_diff($courses, array(SITEID));
@@ -283,27 +285,21 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
     }
 
     // We want to have easy access by day, since the display is on a per-day basis.
-    // Arguments passed by reference.
-    //calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
     calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
 
-    //Accessibility: added summary and <abbr> elements.
-    $days_title = calendar_get_days();
-
-    $summary = get_string('calendarheading', 'calendar', userdate(make_timestamp($y, $m), get_string('strftimemonthyear')));
-    $content .= '<table class="minicalendar calendartable" summary="'.$summary.'">'; // Begin table
-    if (($placement !== false) && ($courseid  !== false)) {
-        $content .= '<caption>'. calendar_top_controls($placement, array('id' => $courseid, 'm' => $m, 'y' => $y)) .'</caption>';
+    // Accessibility: added summary and <abbr> elements.
+    $summary = get_string('calendarheading', 'calendar', userdate($display->tstart, get_string('strftimemonthyear')));
+    $content .= '<table class="minicalendar calendartable" summary="'.$summary.'">'; // Begin table.
+    if (($placement !== false) && ($courseid !== false)) {
+        $content .= '<caption>'. calendar_top_controls($placement, array('id' => $courseid, 'time' => $time)) .'</caption>';
     }
     $content .= '<tr class="weekdays">'; // Header row: day names
 
-    // Print out the names of the weekdays
-    $days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
-    for($i = $display->minwday; $i <= $display->maxwday; ++$i) {
-        // This uses the % operator to get the correct weekday no matter what shift we have
-        // applied to the $display->minwday : $display->maxwday range from the default 0 : 6
-        $content .= '<th scope="col"><abbr title="'. get_string($days_title[$i % 7], 'calendar') .'">'.
-            get_string($days[$i % 7], 'calendar') ."</abbr></th>\n";
+    // Print out the names of the weekdays.
+    for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
+        $pos = $i % $numberofdaysinweek;
+        $content .= '<th scope="col"><abbr title="'. $daynames[$pos]['fullname'] .'">'.
+            $daynames[$pos]['shortname'] ."</abbr></th>\n";
     }
 
     $content .= '</tr><tr>'; // End of day names; prepare for day numbers
@@ -322,16 +318,17 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
     }
 
     // Now display all the calendar
+    $daytime = $display->tstart - DAYSECS;
     for($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
+        $daytime += DAYSECS;
         if($dayweek > $display->maxwday) {
             // We need to change week (table row)
             $content .= '</tr><tr>';
             $dayweek = $display->minwday;
         }
 
-        // Reset vars
-        $cell = '';
-        if ($weekend & (1 << ($dayweek % 7))) {
+        // Reset vars.
+        if ($weekend & (1 << ($dayweek % $numberofdaysinweek))) {
             // Weekend. This is true no matter what the exact range is.
             $class = 'weekend day';
         } else {
@@ -341,9 +338,10 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
 
         // Special visual fx if an event is defined
         if(isset($eventsbyday[$day])) {
+
             $class .= ' hasevent';
             $hrefparams['view'] = 'day';
-            $dayhref = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', $hrefparams), $day, $m, $y);
+            $dayhref = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $hrefparams), 0, 0, 0, $daytime);
 
             $popupcontent = '';
             foreach($eventsbyday[$day] as $eventid) {
@@ -353,17 +351,17 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
                 $event = new calendar_event($events[$eventid]);
                 $popupalt  = '';
                 $component = 'moodle';
-                if(!empty($event->modulename)) {
+                if (!empty($event->modulename)) {
                     $popupicon = 'icon';
                     $popupalt  = $event->modulename;
                     $component = $event->modulename;
-                } else if ($event->courseid == SITEID) {                                // Site event
+                } else if ($event->courseid == SITEID) { // Site event.
                     $popupicon = 'i/siteevent';
-                } else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {      // Course event
+                } else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event.
                     $popupicon = 'i/courseevent';
-                } else if ($event->groupid) {                                      // Group event
+                } else if ($event->groupid) { // Group event.
                     $popupicon = 'i/groupevent';
-                } else if ($event->userid) {                                       // User event
+                } else { // Must be a user event.
                     $popupicon = 'i/userevent';
                 }
 
@@ -823,43 +821,59 @@ function calendar_get_events_by_id($eventids) {
  * @return string $content return available control for the calender in html
  */
 function calendar_top_controls($type, $data) {
-    global $CFG, $PAGE;
+    global $PAGE;
+
+    // Get the calendar type we are using.
+    $calendartype = \core_calendar\type_factory::get_calendar_instance();
+
     $content = '';
-    if(!isset($data['d'])) {
-        $data['d'] = 1;
-    }
 
-    // Ensure course id passed if relevant
-    // Required due to changes in view/lib.php mainly (calendar_session_vars())
+    // Ensure course id passed if relevant.
     $courseid = '';
     if (!empty($data['id'])) {
         $courseid = '&amp;course='.$data['id'];
     }
 
-    if(!checkdate($data['m'], $data['d'], $data['y'])) {
+    // If we are passing a month and year then we need to convert this to a timestamp to
+    // support multiple calendars. No where in core should these be passed, this logic
+    // here is for third party plugins that may use this function.
+    if (!empty($data['m']) && !empty($date['y'])) {
+        if (!isset($data['d'])) {
+            $data['d'] = 1;
+        }
+        if (!checkdate($data['m'], $data['d'], $data['y'])) {
+            $time = time();
+        } else {
+            $time = make_timestamp($data['y'], $data['m'], $data['d']);
+        }
+    } else if (!empty($data['time'])) {
+        $time = $data['time'];
+    } else {
         $time = time();
     }
-    else {
-        $time = make_timestamp($data['y'], $data['m'], $data['d']);
-    }
-    $date = usergetdate($time);
 
-    $data['m'] = $date['mon'];
-    $data['y'] = $date['year'];
+    // Get the date for the calendar type.
+    $date = $calendartype->timestamp_to_date_array($time);
+
     $urlbase = $PAGE->url;
 
-    //Accessibility: calendar block controls, replaced <table> with <div>.
-    //$nexttext = link_arrow_right(get_string('monthnext', 'access'), $url='', $accesshide=true);
-    //$prevtext = link_arrow_left(get_string('monthprev', 'access'), $url='', $accesshide=true);
+    // We need to get the previous and next months in certain cases.
+    if ($type == 'frontpage' || $type == 'course' || $type == 'month') {
+        $prevmonth = calendar_sub_month($date['mon'], $date['year']);
+        $prevmonthtime = $calendartype->convert_to_gregorian($prevmonth[1], $prevmonth[0], $date['mday']);
+        $prevmonthtime = make_timestamp($prevmonthtime['year'], $prevmonthtime['month'], $prevmonthtime['day']);
+
+        $nextmonth = calendar_add_month($date['mon'], $date['year']);
+        $nextmonthtime = $calendartype->convert_to_gregorian($nextmonth[1], $nextmonth[0], $date['mday']);
+        $nextmonthtime = make_timestamp($nextmonthtime['year'], $nextmonthtime['month'], $nextmonthtime['day']);
+    }
 
-    switch($type) {
+    switch ($type) {
         case 'frontpage':
-            list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']);
-            list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']);
-            $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, 0, $nextmonth, $nextyear, true);
-            $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, 0, $prevmonth, $prevyear, true);
+            $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, false, false, false, true, $prevmonthtime);
+            $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, false, false, false, true, $nextmonthtime);
+            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view' => 'month')), false, false, false, $time);
 
-            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view'=>'month')), 1, $data['m'], $data['y']);
             if (!empty($data['id'])) {
                 $calendarlink->param('course', $data['id']);
             }
@@ -881,12 +895,10 @@ function calendar_top_controls($type, $data) {
 
             break;
         case 'course':
-            list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']);
-            list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']);
-            $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, 0, $nextmonth, $nextyear, true);
-            $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, 0, $prevmonth, $prevyear, true);
+            $prevlink = calendar_get_link_previous(get_string('monthprev', 'access'), $urlbase, false, false, false, true, $prevmonthtime);
+            $nextlink = calendar_get_link_next(get_string('monthnext', 'access'), $urlbase, false, false, false, true, $nextmonthtime);
+            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view' => 'month')), false, false, false, $time);
 
-            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view'=>'month')), 1, $data['m'], $data['y']);
             if (!empty($data['id'])) {
                 $calendarlink->param('course', $data['id']);
             }
@@ -907,7 +919,7 @@ function calendar_top_controls($type, $data) {
             $content .= html_writer::end_tag('div');
             break;
         case 'upcoming':
-            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view'=>'upcoming')), 1, $data['m'], $data['y']);
+            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view' => 'upcoming')), false, false, false, $time);
             if (!empty($data['id'])) {
                 $calendarlink->param('course', $data['id']);
             }
@@ -915,7 +927,7 @@ function calendar_top_controls($type, $data) {
             $content .= html_writer::tag('div', $calendarlink, array('class'=>'centered'));
             break;
         case 'display':
-            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view'=>'month')), 1, $data['m'], $data['y']);
+            $calendarlink = calendar_get_link_href(new moodle_url(CALENDAR_URL.'view.php', array('view' => 'month')), false, false, false, $time);
             if (!empty($data['id'])) {
                 $calendarlink->param('course', $data['id']);
             }
@@ -923,12 +935,8 @@ function calendar_top_controls($type, $data) {
             $content .= html_writer::tag('h3', $calendarlink);
             break;
         case 'month':
-            list($prevmonth, $prevyear) = calendar_sub_month($data['m'], $data['y']);
-            list($nextmonth, $nextyear) = calendar_add_month($data['m'], $data['y']);
-            $prevdate = make_timestamp($prevyear, $prevmonth, 1);
-            $nextdate = make_timestamp($nextyear, $nextmonth, 1);
-            $