Merge branch 'MDL-40852_master' of git://github.com/dmonllao/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 12 Aug 2013 21:10:28 +0000 (09:10 +1200)
committerSam Hemelryk <sam@moodle.com>
Mon, 12 Aug 2013 21:10:28 +0000 (09:10 +1200)
350 files changed:
admin/blocks.php
admin/cli/install.php
admin/localplugins.php
admin/mnet/access_control.php
admin/purgecaches.php
admin/registration/forms.php
admin/reports.php
admin/roles/allow.php
admin/roles/assign.php
admin/roles/classes/define_role_table_advanced.php
admin/roles/define.php
admin/roles/manage.php
admin/roles/override.php
admin/tool/behat/tests/behat/data_generators.feature
admin/tool/uploadcourse/classes/course.php
admin/tool/uploadcourse/classes/helper.php
admin/tool/uploadcourse/classes/step1_form.php
admin/tool/uploadcourse/cli/uploadcourse.php
admin/tool/uploadcourse/lang/en/tool_uploadcourse.php
admin/tool/uploadcourse/tests/course_test.php
admin/tool/uploaduser/locallib.php
admin/tool/uploaduser/user_form.php
admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php
admin/tools.php
admin/webservice/forms.php
auth/cas/auth.php
auth/db/auth.php
auth/email/auth.php
auth/ldap/auth.php
auth/manual/auth.php
auth/nologin/auth.php
auth/none/auth.php
auth/tests/auth_test.php [deleted file]
auth/upgrade.txt
backup/controller/tests/controller_test.php
backup/converter/moodle1/handlerlib.php
backup/converter/moodle1/lib.php
backup/converter/moodle1/tests/moodle1_converter_test.php [moved from backup/converter/moodle1/tests/lib_test.php with 99% similarity]
backup/util/dbops/backup_plan_dbops.class.php
backup/util/helper/backup_cron_helper.class.php
badges/tests/badgeslib_test.php
blocks/activity_modules/block_activity_modules.php
blocks/comments/tests/behat/behat_block_comments.php
blocks/community/forms.php
blocks/completionstatus/details.php
blocks/course_overview/db/access.php
blocks/course_overview/lang/en/block_course_overview.php
blocks/course_overview/locallib.php
blocks/course_overview/version.php
blocks/navigation/block_navigation.php
blocks/navigation/tests/behat/view_my_courses.feature
blocks/rss_client/block_rss_client.php
blog/lib.php
blog/locallib.php
blog/tests/behat/comment.feature
blog/tests/bloglib_test.php
cache/tests/administration_helper_test.php [new file with mode: 0644]
cache/tests/cache_test.php
cache/tests/config_writer_test.php [moved from cache/tests/locallib_test.php with 57% similarity]
calendar/tests/externallib_test.php
calendar/tests/ical_test.php [moved from calendar/tests/calendarical_test.php with 100% similarity]
cohort/tests/cohortlib_test.php
cohort/tests/externallib_test.php
comment/comment.js
config-dist.php
course/dnduploadlib.php
course/format/upgrade.txt
course/lib.php
course/manage.php
course/publish/forms.php
course/renderer.php
course/tests/courselib_test.php
course/tests/courserequest_test.php
course/tests/externallib_test.php
course/yui/dragdrop/dragdrop.js
enrol/database/lib.php
enrol/externallib.php
enrol/flatfile/lib.php
enrol/flatfile/settings.php
enrol/flatfile/tests/flatfile_test.php
enrol/guest/locallib.php
enrol/ldap/lib.php
enrol/ldap/settingslib.php
enrol/locallib.php
enrol/paypal/ipn.php
enrol/self/db/services.php [new file with mode: 0644]
enrol/self/externallib.php [new file with mode: 0644]
enrol/self/lib.php
enrol/self/locallib.php
enrol/self/tests/externallib_test.php [new file with mode: 0644]
enrol/self/version.php
enrol/tests/enrollib_test.php
enrol/tests/externallib_test.php
enrol/tests/role_external_test.php [moved from enrol/tests/externallib_role_test.php with 98% similarity]
files/externallib.php
files/renderer.php
files/tests/externallib_test.php
grade/edit/scale/edit_form.php
grade/edit/tree/action.php
grade/edit/tree/lib.php
grade/export/grade_export_form.php
grade/export/key_form.php
grade/grading/tests/grading_manager_test.php [moved from grade/grading/tests/lib_test.php with 98% similarity]
grade/import/grade_import_form.php
grade/import/key_form.php
grade/lib.php
grade/report/user/lang/en/gradereport_user.php
grade/report/user/lib.php
grade/report/user/styles.css
grade/tests/edittreelib_test.php [moved from grade/tests/edittree_test.php with 96% similarity]
grade/tests/externallib_test.php
grade/tests/querylib_test.php
grade/tests/report_graderlib_test.php [moved from grade/tests/reportgrader_test.php with 98% similarity]
grade/tests/reportlib_test.php
grade/tests/reportuserlib_test.php [moved from grade/tests/reportuser_test.php with 99% similarity]
group/group_form.php
group/grouping_form.php
group/tests/externallib_test.php
index.php
install.php
install/lang/de/error.php
install/lang/hu/error.php
install/lang/it/install.php
install/lang/pl/install.php
install/lang/ru/error.php
iplookup/lib.php
iplookup/tests/geoip_test.php
iplookup/tests/geoplugin_test.php
lang/en/auth.php
lang/en/blog.php
lang/en/cache.php
lang/en/error.php
lang/en/message.php
lang/en/moodle.php
lang/en/question.php
lang/en/role.php
lang/en/webservice.php
lib/accesslib.php
lib/adminlib.php
lib/ajax/tests/ajaxlib_test.php
lib/authlib.php
lib/bennu/iCalendar_rfc2445.php
lib/bennu/readme_moodle.txt
lib/blocklib.php
lib/classes/collator.php
lib/classes/component.php
lib/classes/event/base.php
lib/classes/event/blog_entry_created.php [new file with mode: 0644]
lib/classes/event/manager.php
lib/classes/event/role_allow_assign_updated.php [new file with mode: 0644]
lib/classes/event/role_allow_override_updated.php [new file with mode: 0644]
lib/classes/event/role_allow_switch_updated.php [new file with mode: 0644]
lib/classes/event/role_assigned.php
lib/classes/event/role_capabilities_updated.php [new file with mode: 0644]
lib/classes/event/role_deleted.php [new file with mode: 0644]
lib/classes/event/role_unassigned.php
lib/classes/event/user_loggedin.php [moved from auth/classes/event/user_loggedin.php with 87% similarity]
lib/classes/minify.php [new file with mode: 0644]
lib/classes/string_manager.php [new file with mode: 0644]
lib/classes/string_manager_install.php [new file with mode: 0644]
lib/classes/string_manager_standard.php [new file with mode: 0644]
lib/conditionlib.php
lib/coursecatlib.php
lib/csslib.php
lib/csvlib.class.php
lib/datalib.php
lib/db/caches.php
lib/db/install.xml
lib/db/services.php
lib/db/upgrade.php
lib/ddl/tests/ddl_test.php
lib/deprecatedlib.php
lib/dml/tests/dml_test.php
lib/editor/tinymce/adminlib.php
lib/editor/tinymce/plugins/loader.php
lib/editor/tinymce/plugins/managefiles/tinymce/editor_plugin.js
lib/editor/tinymce/plugins/spellchecker/classes/GoogleSpell.php
lib/eventslib.php
lib/excellib.class.php
lib/external/tests/external_test.php [moved from lib/external/tests/externallib_test.php with 100% similarity]
lib/filebrowser/file_info.php
lib/filebrowser/file_info_context_course.php
lib/filebrowser/file_info_stored.php
lib/filestorage/file_archive.php
lib/filestorage/file_storage.php
lib/filestorage/tests/file_storage_test.php
lib/filestorage/tests/zip_packer_test.php
lib/filestorage/zip_archive.php
lib/filterlib.php
lib/form/filemanager.js
lib/formslib.php
lib/grade/grade_category.php
lib/grade/grade_item.php
lib/grade/grade_object.php
lib/grade/tests/fixtures/lib.php
lib/grade/tests/grade_category_test.php
lib/grade/tests/grade_grade_test.php
lib/grade/tests/grade_item_test.php
lib/grade/tests/grade_outcome_test.php
lib/grade/tests/grade_scale_test.php
lib/gradelib.php
lib/graphlib.php
lib/html2text.php
lib/html2text_readme.txt
lib/javascript.php
lib/jslib.php
lib/medialib.php
lib/minify/readme_moodle.txt
lib/modinfolib.php
lib/moodlelib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/phpmailer/moodle_phpmailer.php
lib/phpunit/classes/advanced_testcase.php
lib/phpunit/classes/autoloader.php
lib/phpunit/classes/event_mock.php [new file with mode: 0644]
lib/phpunit/classes/util.php
lib/phpunit/lib.php
lib/questionlib.php
lib/setuplib.php
lib/simplepie/moodle_simplepie.php
lib/tablelib.php
lib/testing/classes/util.php
lib/tests/accesslib_test.php
lib/tests/authlib_test.php
lib/tests/behat/behat_data_generators.php
lib/tests/event_test.php
lib/tests/fixtures/event_fixtures.php
lib/tests/html2text_test.php
lib/tests/htmlpurifier_test.php
lib/tests/minify_test.php [new file with mode: 0644]
lib/tests/moodlelib_test.php
lib/tests/pluginlib_test.php
lib/tests/string_manager_standard_test.php [moved from lib/tests/string_manager_test.php with 95% similarity]
lib/tokeniserlib.php
lib/upgrade.txt
lib/upgradelib.php
lib/weblib.php
lib/xhprof/xhprof_moodle.php
lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js
lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js
lib/yui/build/moodle-core-blocks/moodle-core-blocks.js
lib/yui/build/moodle-core-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/dragdrop/dragdrop.js
lib/yui/src/blocks/js/blocks.js
lib/yui/src/notification/js/dialogue.js
login/forgot_password.php
login/index.php
login/signup_form.php
login/token.php
message/bell.mp3 [new file with mode: 0644]
message/bell.ogg [new file with mode: 0644]
message/edit.php
message/lib.php
message/renderer.php
message/tests/externallib_test.php
mod/assign/adminlib.php
mod/assign/lang/en/assign.php
mod/assign/locallib.php
mod/assign/yui/history/history.js
mod/book/db/upgradelib.php
mod/book/tool/importhtml/locallib.php
mod/chat/gui_basic/index.php
mod/chat/lib.php
mod/data/field/file/field.class.php
mod/data/field/picture/field.class.php
mod/data/import_form.php
mod/data/lang/en/data.php
mod/data/lib.php
mod/data/module.js [new file with mode: 0644]
mod/data/templates.php
mod/data/tests/lib_test.php [new file with mode: 0644]
mod/data/view.php
mod/feedback/import.php
mod/forum/backup/moodle2/restore_forum_stepslib.php
mod/forum/mod_form.php
mod/glossary/edit_form.php
mod/glossary/editcategories.php
mod/glossary/exportentry.php
mod/glossary/import.php
mod/glossary/lib.php
mod/glossary/print.php
mod/glossary/sql.php
mod/glossary/view.php
mod/label/lib.php
mod/lesson/format.php
mod/lesson/locallib.php
mod/lesson/pagetypes/endofbranch.php
mod/lesson/pagetypes/endofcluster.php
mod/lesson/pagetypes/essay.php
mod/lesson/pagetypes/matching.php
mod/lesson/pagetypes/truefalse.php
mod/lti/locallib.php
mod/quiz/lib.php
mod/quiz/renderer.php
mod/quiz/settings.php
mod/quiz/styles.css
mod/survey/download.php
mod/upgrade.txt
mod/wiki/locallib.php
mod/wiki/pagelib.php
notes/tests/externallib_test.php
phpunit.xml.dist
question/behaviour/behaviourbase.php
question/behaviour/deferredcbm/tests/walkthrough_test.php
question/behaviour/deferredfeedback/tests/walkthrough_test.php
question/engine/bank.php
question/engine/datalib.php
question/engine/questionattempt.php
question/engine/tests/helpers.php
question/engine/upgrade/upgradelib.php
question/format.php
question/format/learnwise/format.php
question/format/webct/TODO.txt [deleted file]
question/format/webct/format.php
question/format/webct/lang/en/qformat_webct.php
question/format/webct/tests/fixtures/sample_webct.txt [new file with mode: 0644]
question/format/webct/tests/webctformat_test.php [new file with mode: 0644]
question/format/webct/version.php
question/type/multianswer/renderer.php
report/completion/index.php
report/log/locallib.php
report/progress/index.php
repository/filepicker.js
repository/filesystem/lib.php
repository/googledocs/lib.php
repository/lib.php
repository/local/lib.php
repository/tests/generator_test.php
repository/tests/repositorylib_test.php [moved from repository/tests/repository_test.php with 99% similarity]
tag/coursetagslib.php
tag/lib.php
tag/locallib.php
theme/base/style/core.css
theme/bootstrapbase/less/moodle/core.less
theme/bootstrapbase/less/moodle/forms.less
theme/bootstrapbase/style/moodle.css
theme/javascript.php
user/editadvanced_form.php
user/externallib.php
user/filters/date.php
user/lib.php
user/tests/externallib_test.php
version.php
webservice/externallib.php
webservice/tests/externallib_test.php
webservice/upgrade.txt [new file with mode: 0644]
webservice/upload.php

index 2ad0a0e..6a2d31e 100644 (file)
             $blocknames[$blockid] = $blockname;
         }
     }
-    collatorlib::asort($blocknames);
+    core_collator::asort($blocknames);
 
     foreach ($blocknames as $blockid=>$strblockname) {
         $block = $blocks[$blockid];
index e8cffe0..21617cf 100644 (file)
@@ -172,6 +172,9 @@ ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include
 
 require_once($CFG->libdir.'/classes/component.php');
 require_once($CFG->libdir.'/classes/text.php');
+require_once($CFG->libdir.'/classes/string_manager.php');
+require_once($CFG->libdir.'/classes/string_manager_install.php');
+require_once($CFG->libdir.'/classes/string_manager_standard.php');
 require_once($CFG->libdir.'/installlib.php');
 require_once($CFG->libdir.'/clilib.php');
 require_once($CFG->libdir.'/setuplib.php');
@@ -309,6 +312,8 @@ if ($interactive) {
     }
 }
 $CFG->directorypermissions = $chmod;
+$CFG->filepermissions      = ($CFG->directorypermissions & 0666);
+$CFG->umaskpermissions     = (($CFG->directorypermissions & 0777) ^ 0777);
 
 //We need wwwroot before we test dataroot
 $wwwroot = clean_param($options['wwwroot'], PARAM_URL);
index 145f65a..be09151 100644 (file)
@@ -55,7 +55,7 @@ foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
     }
     $plugins[$plugin] = $strpluginname;
 }
-collatorlib::asort($plugins);
+core_collator::asort($plugins);
 
 foreach ($plugins as $plugin => $name) {
     $uninstall = '';
index 1c0470e..79c744c 100644 (file)
@@ -103,7 +103,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
         $usernames = explode(',', $form->username);
 
         foreach ($usernames as $username) {
-            $username = trim(textlib::strtolower($username));
+            $username = trim(core_text::strtolower($username));
             if (!empty($username)) {
                 if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) {
                     if ($form->accessctrl == 'allow') {
index 006bb0d..c2247dc 100644 (file)
@@ -27,37 +27,37 @@ require_once('../config.php');
 require_once($CFG->libdir.'/adminlib.php');
 
 $confirm = optional_param('confirm', 0, PARAM_BOOL);
+$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
 
-admin_externalpage_setup('purgecaches');
-
-require_login();
-require_capability('moodle/site:config', context_system::instance());
-
-if ($confirm) {
-    require_sesskey();
+// If we have got here as a confirmed aciton, do it.
+if ($confirm && isloggedin() && confirm_sesskey()) {
+    require_capability('moodle/site:config', context_system::instance());
 
-    // Valid request. Purge, and redisplay the form so it is easy to purge again
-    // in the near future.
+    // Valid request. Purge, and redirect the user back to where they came from.
     purge_all_caches();
-    redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
-
-} else {
-    // Show a confirm form.
-    echo $OUTPUT->header();
-    echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
-
-    $url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
-    $button = new single_button($url, get_string('purgecaches','admin'), 'post');
-
-    // Cancel button takes them back to the page the were on, if possible,
-    // otherwise to the site home page.
-    $return = new moodle_url('/');
-    if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
-        if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
-            $return = $_SERVER['HTTP_REFERER'];
-        }
+
+    if ($returnurl) {
+        $returnurl = $CFG->wwwroot . $returnurl;
+    } else {
+        $returnurl = new moodle_url('/admin/purgecaches.php');
     }
+    redirect($returnurl, get_string('purgecachesfinished', 'admin'));
+}
 
-    echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
-    echo $OUTPUT->footer();
+// Otherwise, show a button to actually purge the caches.
+admin_externalpage_setup('purgecaches');
+
+$actionurl = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
+if ($returnurl) {
+    $actionurl->param('returnurl', $returnurl);
 }
+
+echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
+
+echo $OUTPUT->box_start('generalbox', 'notice');
+echo html_writer::tag('p', get_string('purgecachesconfirm', 'admin'));
+echo $OUTPUT->single_button($actionurl, get_string('purgecaches', 'admin'), 'post');
+echo $OUTPUT->box_end();
+
+echo $OUTPUT->footer();
index 1f868d0..8eff841 100644 (file)
@@ -137,8 +137,8 @@ class hub_selector_form extends moodleform {
         $options = array();
         foreach ($hubs as $hub) {
             //to not display a name longer than 100 character (too big)
-            if (textlib::strlen($hub['name']) > 100) {
-                $hubname = textlib::substr($hub['name'], 0, 100);
+            if (core_text::strlen($hub['name']) > 100) {
+                $hubname = core_text::substr($hub['name'], 0, 100);
                 $hubname = $hubname . "...";
             } else {
                 $hubname = $hub['name'];
@@ -287,7 +287,7 @@ class site_registration_form extends moodleform {
         $mform->addHelpButton('description', 'sitedesc', 'hub');
 
         $languages = get_string_manager()->get_list_of_languages();
-        collatorlib::asort($languages);
+        core_collator::asort($languages);
         $mform->addElement('select', 'language', get_string('sitelang', 'hub'),
                 $languages);
         $mform->setType('language', PARAM_ALPHANUMEXT);
index 70ec952..0a73d22 100644 (file)
@@ -57,7 +57,7 @@ foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
     }
     $plugins[$plugin] = $strpluginname;
 }
-collatorlib::asort($plugins);
+core_collator::asort($plugins);
 
 $like = $DB->sql_like('plugin', '?', true, true, false, '|');
 $params = array('report|_%');
index 9b7e709..8ffd54d 100644 (file)
@@ -46,7 +46,22 @@ $controller = new $classformode[$mode]();
 if (optional_param('submit', false, PARAM_BOOL) && data_submitted() && confirm_sesskey()) {
     $controller->process_submission();
     $syscontext->mark_dirty();
-    add_to_log(SITEID, 'role', 'edit allow ' . $mode, str_replace($CFG->wwwroot . '/', '', $baseurl), '', '', $USER->id);
+    $event = null;
+    // Create event depending on mode.
+    switch ($mode) {
+        case 'assign':
+            $event = \core\event\role_allow_assign_updated::create(array('context' => $syscontext));
+            break;
+        case 'override':
+            $event = \core\event\role_allow_override_updated::create(array('context' => $syscontext));
+            break;
+        case 'switch':
+            $event = \core\event\role_allow_switch_updated::create(array('context' => $syscontext));
+            break;
+    }
+    if ($event) {
+        $event->trigger();
+    }
     redirect($baseurl);
 }
 
index 8346640..cce2334 100644 (file)
@@ -110,8 +110,6 @@ if ($roleid) {
             $potentialuserselector->invalidate_selected_users();
             $currentuserselector->invalidate_selected_users();
 
-            $rolename = $assignableroles[$roleid];
-            add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
             // Counts have changed, so reload.
             list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
         }
@@ -130,8 +128,6 @@ if ($roleid) {
             $potentialuserselector->invalidate_selected_users();
             $currentuserselector->invalidate_selected_users();
 
-            $rolename = $assignableroles[$roleid];
-            add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
             // Counts have changed, so reload.
             list($assignableroles, $assigncounts, $nameswithcounts) = get_assignable_roles($context, ROLENAME_BOTH, true);
         }
index 496df3e..cd7741c 100644 (file)
@@ -99,8 +99,8 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
         $shortname = optional_param('shortname', null, PARAM_RAW);
         if (!is_null($shortname)) {
             $this->role->shortname = $shortname;
-            $this->role->shortname = textlib::specialtoascii($this->role->shortname);
-            $this->role->shortname = textlib::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
+            $this->role->shortname = core_text::specialtoascii($this->role->shortname);
+            $this->role->shortname = core_text::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT));
             if (empty($this->role->shortname)) {
                 $this->errors['shortname'] = get_string('errorbadroleshortname', 'core_role');
             }
index f588d1a..265b100 100644 (file)
@@ -196,8 +196,22 @@ if (optional_param('cancel', false, PARAM_BOOL)) {
 // Process submission in necessary.
 if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey() && $definitiontable->is_submission_valid()) {
     $definitiontable->save_changes();
-    add_to_log(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' .
-            $definitiontable->get_role_id(), $definitiontable->get_role_name(), '', $USER->id);
+    $tableroleid = $definitiontable->get_role_id();
+    // Trigger event.
+    $event = \core\event\role_capabilities_updated::create(
+        array(
+            'context' => $systemcontext,
+            'objectid' => $roleid,
+            'other' => array('name' => $definitiontable->get_role_name())
+        )
+    );
+    $event->set_legacy_logdata(array(SITEID, 'role', $action, 'admin/roles/define.php?action=view&roleid=' . $tableroleid,
+        $definitiontable->get_role_name(), '', $USER->id));
+    if (!empty($role)) {
+        $event->add_record_snapshot('role', $role);
+    }
+    $event->trigger();
+
     if ($action === 'add') {
         redirect(new moodle_url('/admin/roles/define.php', array('action'=>'view', 'roleid'=>$definitiontable->get_role_id())));
     } else {
index ec02517..e3e094a 100644 (file)
@@ -90,7 +90,6 @@ switch ($action) {
         }
         // Deleted a role sitewide...
         $systemcontext->mark_dirty();
-        add_to_log(SITEID, 'role', 'delete', 'admin/roles/manage.php', $roles[$roleid]->localname, '', $USER->id);
         redirect($baseurl);
         break;
 
index 7d27dc2..bc506f1 100644 (file)
@@ -125,7 +125,25 @@ $overridestable->read_submitted_permissions();
 if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) {
     $overridestable->save_changes();
     $rolename = $overridableroles[$roleid];
-    add_to_log($course->id, 'role', 'override', 'admin/roles/override.php?contextid='.$context->id.'&roleid='.$roleid, $rolename, '', $USER->id);
+    // Trigger event.
+    $event = \core\event\role_capabilities_updated::create(
+        array(
+            'context' => $context,
+            'objectid' => $roleid,
+            'courseid' => $courseid,
+            'other' => array('name' => $rolename)
+        )
+    );
+
+    $event->set_legacy_logdata(
+        array(
+            $course->id, 'role', 'override', 'admin/roles/override.php?contextid=' . $context->id . '&roleid=' . $roleid,
+            $rolename, '', $USER->id
+        )
+    );
+    $event->add_record_snapshot('role', $role);
+    $event->trigger();
+
     redirect($returnurl);
 }
 
index e37f9bc..c0d3665 100644 (file)
@@ -65,6 +65,37 @@ Feature: Set up contextual data for tests
     And I should see "Grouping 1"
     And I should see "Grouping 2"
 
+  @javascript
+  Scenario: Role overrides
+    Given the following "users" exists:
+      | username | firstname | lastname | email |
+      | teacher1 | Teacher | 1 | teacher1@asd.com |
+      | student1 | Student | 1 | student1@asd.com |
+    And the following "categories" exists:
+      | name | category | idnumber |
+      | Cat 1 | 0 | CAT1 |
+    And the following "courses" exists:
+      | fullname | shortname |
+      | Course 1 | C1 |
+    And the following "course enrolments" exists:
+      | user | course | role |
+      | student1 | C1 | student |
+      | teacher1 | C1 | editingteacher |
+    And the following "permission overrides" exists:
+      | capability | permission | role | contextlevel | reference |
+      | mod/forum:editanypost | Allow | student | Course | C1 |
+      | mod/forum:replynews | Prevent | editingteacher | Course | C1 |
+    When I log in as "admin"
+    And I follow "Course 1"
+    And I expand "Users" node
+    And I follow "Permissions"
+    And I select "Student (1)" from "Advanced role override"
+    Then the "mod/forum:editanypost" field should match "1" value
+    And I press "Cancel"
+    And I select "Teacher (1)" from "Advanced role override"
+    And the "mod/forum:replynews" field should match "-1" value
+    And I press "Cancel"
+
   Scenario: Add course enrolments
     Given the following "users" exists:
       | username | firstname | lastname | email |
index faa404d..782e1e8 100644 (file)
@@ -399,7 +399,7 @@ class tool_uploadcourse_course {
      * @return bool false is any error occured.
      */
     public function prepare() {
-        global $DB;
+        global $DB, $SITE;
         $this->prepared = true;
 
         // Validate the shortname.
@@ -432,6 +432,12 @@ class tool_uploadcourse_course {
                 $this->error('courseexistsanduploadnotallowed',
                     new lang_string('courseexistsanduploadnotallowed', 'tool_uploadcourse'));
                 return false;
+            } else if ($this->can_update()) {
+                // We can never allow for any front page changes!
+                if ($this->shortname == $SITE->shortname) {
+                    $this->error('cannotupdatefrontpage', new lang_string('cannotupdatefrontpage', 'tool_uploadcourse'));
+                    return false;
+                }
             }
         } else {
             if (!$this->can_create()) {
@@ -608,6 +614,13 @@ class tool_uploadcourse_course {
         if ($exists) {
             $missingonly = ($updatemode === tool_uploadcourse_processor::UPDATE_MISSING_WITH_DATA_OR_DEFAUTLS);
             $coursedata = $this->get_final_update_data($coursedata, $usedefaults, $missingonly);
+
+            // Make sure we are not trying to mess with the front page, though we should never get here!
+            if ($coursedata['id'] == $SITE->id) {
+                $this->error('cannotupdatefrontpage', new lang_string('cannotupdatefrontpage', 'tool_uploadcourse'));
+                return false;
+            }
+
             $this->do = self::DO_UPDATE;
         } else {
             $coursedata = $this->get_final_create_data($coursedata);
index 11ff373..ebd0b75 100644 (file)
@@ -117,18 +117,18 @@ class tool_uploadcourse_helper {
 
         switch ($block[1]) {
             case '+':
-                $repl = textlib::strtoupper($repl);
+                $repl = core_text::strtoupper($repl);
                 break;
             case '-':
-                $repl = textlib::strtolower($repl);
+                $repl = core_text::strtolower($repl);
                 break;
             case '~':
-                $repl = textlib::strtotitle($repl);
+                $repl = core_text::strtotitle($repl);
                 break;
         }
 
         if (!empty($block[2])) {
-            $repl = textlib::substr($repl, 0, $block[2]);
+            $repl = core_text::substr($repl, 0, $block[2]);
         }
 
         return $repl;
index cd0abc0..189ff9e 100644 (file)
@@ -57,7 +57,7 @@ class tool_uploadcourse_step1_form extends tool_uploadcourse_base_form {
             $mform->setDefault('delimiter_name', 'comma');
         }
 
-        $choices = textlib::get_encodings();
+        $choices = core_text::get_encodings();
         $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices);
         $mform->setDefault('encoding', 'UTF-8');
 
index 1aa4613..511d602 100644 (file)
@@ -145,7 +145,7 @@ if (!file_exists($options['file'])) {
 }
 
 // Encoding.
-$encodings = textlib::get_encodings();
+$encodings = core_text::get_encodings();
 if (!isset($encodings[$options['encoding']])) {
     echo get_string('invalidencoding', 'tool_uploadcourse')."\n";
     echo $help;
index 83138d3..3be7ec4 100644 (file)
@@ -32,6 +32,7 @@ $string['cannotreadbackupfile'] = 'Cannot read the backup file';
 $string['cannotrenamecoursenotexist'] = 'Cannot rename a course that does not exist';
 $string['cannotrenameidnumberconflict'] = 'Cannot rename the course, the ID number conflicts with an existing course';
 $string['cannotrenameshortnamealreadyinuse'] = 'Cannot rename the course, the shortname is already used';
+$string['cannotupdatefrontpage'] = 'It is forbidden to modify the front page';
 $string['canonlyrenameinupdatemode'] = 'Can only rename a course when update is allowed';
 $string['canonlyresetcourseinupdatemode'] = 'Can only reset a course in update mode';
 $string['couldnotresolvecatgorybyid'] = 'Could not resolve category by ID';
index f04a2ea..ee979b4 100644 (file)
@@ -768,6 +768,7 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
     }
 
     public function test_create_bad_category() {
+        global $DB;
         $this->resetAfterTest(true);
 
         // Ensure fails when category cannot be resolved upon creation.
@@ -778,6 +779,14 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         $this->assertFalse($co->prepare());
         $this->assertArrayHasKey('couldnotresolvecatgorybyid', $co->get_errors());
 
+        // Ensure fails when category is 0 on create.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => 'c1', 'summary' => 'summary', 'fullname' => 'FN', 'category' => '0');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('missingmandatoryfields', $co->get_errors());
+
         // Ensure fails when category cannot be resolved upon update.
         $c1 = $this->getDataGenerator()->create_course();
         $mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
@@ -786,6 +795,31 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         $co = new tool_uploadcourse_course($mode, $updatemode, $data);
         $this->assertFalse($co->prepare());
         $this->assertArrayHasKey('couldnotresolvecatgorybyid', $co->get_errors());
+
+        // Ensure does not update the category when it is 0.
+        $c1 = $this->getDataGenerator()->create_course();
+        $mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => $c1->shortname, 'category' => '0');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data);
+        $this->assertTrue($co->prepare());
+        $this->assertEmpty($co->get_errors());
+        $this->assertEmpty($co->get_statuses());
+        $co->proceed();
+        $this->assertEquals($c1->category, $DB->get_field('course', 'category', array('id' => $c1->id)));
+
+        // Ensure does not update the category when it is set to 0 in the defaults.
+        $c1 = $this->getDataGenerator()->create_course();
+        $mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_OR_DEFAUTLS;
+        $data = array('shortname' => $c1->shortname);
+        $defaults = array('category' => '0');
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data, $defaults);
+        $this->assertTrue($co->prepare());
+        $this->assertEmpty($co->get_errors());
+        $this->assertEmpty($co->get_statuses());
+        $co->proceed();
+        $this->assertEquals($c1->category, $DB->get_field('course', 'category', array('id' => $c1->id)));
     }
 
     public function test_enrolment_data() {
@@ -920,4 +954,47 @@ class tool_uploadcourse_course_testcase extends advanced_testcase {
         $this->assertArrayHasKey('courseshortnameincremented', $co->get_statuses());
     }
 
+    public function test_mess_with_frontpage() {
+        global $SITE;
+        $this->resetAfterTest(true);
+
+        // Updating the front page.
+        $mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => $SITE->shortname, 'idnumber' => 'NewIDN');
+        $importoptions = array();
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data, array(), $importoptions);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('cannotupdatefrontpage', $co->get_errors());
+
+        // Updating the front page.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => $SITE->shortname, 'idnumber' => 'NewIDN');
+        $importoptions = array();
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data, array(), $importoptions);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('cannotupdatefrontpage', $co->get_errors());
+
+        // Generating a shortname should not be allowed in update mode, and so we cannot update the front page.
+        $mode = tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('idnumber' => 'NewIDN', 'fullname' => 'FN', 'category' => 1);
+        $importoptions = array('shortnametemplate' => $SITE->shortname);
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data, array(), $importoptions);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('cannotgenerateshortnameupdatemode', $co->get_errors());
+
+        // Renaming to the front page should not be allowed.
+        $c1 = $this->getDataGenerator()->create_course();
+        $mode = tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE;
+        $updatemode = tool_uploadcourse_processor::UPDATE_ALL_WITH_DATA_ONLY;
+        $data = array('shortname' => $c1->shortname, 'fullname' => 'FN', 'idnumber' => 'NewIDN', 'rename' => $SITE->shortname);
+        $importoptions = array('canrename' => true);
+        $co = new tool_uploadcourse_course($mode, $updatemode, $data, array(), $importoptions);
+        $this->assertFalse($co->prepare());
+        $this->assertArrayHasKey('cannotrenameshortnamealreadyinuse', $co->get_errors());
+
+    }
+
 }
index 928b13e..01863f9 100644 (file)
@@ -183,7 +183,7 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $pr
     $processed = array();
     foreach ($columns as $key=>$unused) {
         $field = $columns[$key];
-        $lcfield = textlib::strtolower($field);
+        $lcfield = core_text::strtolower($field);
         if (in_array($field, $stdfields) or in_array($lcfield, $stdfields)) {
             // standard fields are only lowercase
             $newfield = $lcfield;
@@ -295,18 +295,18 @@ function uu_process_template_callback($username, $firstname, $lastname, $block)
 
     switch ($block[1]) {
         case '+':
-            $repl = textlib::strtoupper($repl);
+            $repl = core_text::strtoupper($repl);
             break;
         case '-':
-            $repl = textlib::strtolower($repl);
+            $repl = core_text::strtolower($repl);
             break;
         case '~':
-            $repl = textlib::strtotitle($repl);
+            $repl = core_text::strtotitle($repl);
             break;
     }
 
     if (!empty($block[2])) {
-        $repl = textlib::substr($repl, 0 , $block[2]);
+        $repl = core_text::substr($repl, 0 , $block[2]);
     }
 
     return $repl;
@@ -321,12 +321,13 @@ function uu_process_template_callback($username, $firstname, $lastname, $block)
  * @return array type=>name
  */
 function uu_supported_auths() {
-    // only following plugins are guaranteed to work properly
-    $whitelist = array('manual', 'nologin', 'none', 'email');
+    // Get all the enabled plugins.
     $plugins = get_enabled_auth_plugins();
     $choices = array();
     foreach ($plugins as $plugin) {
-        if (!in_array($plugin, $whitelist)) {
+        $objplugin = get_auth_plugin($plugin);
+        // If the plugin can not be manually set skip it.
+        if (!$objplugin->can_be_manually_set()) {
             continue;
         }
         $choices[$plugin] = get_string('pluginname', "auth_{$plugin}");
index b377a9b..ce32ea2 100644 (file)
@@ -53,7 +53,7 @@ class admin_uploaduser_form1 extends moodleform {
             $mform->setDefault('delimiter_name', 'comma');
         }
 
-        $choices = textlib::get_encodings();
+        $choices = core_text::get_encodings();
         $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
         $mform->setDefault('encoding', 'UTF-8');
 
index 8041672..f2128b1 100644 (file)
@@ -75,8 +75,8 @@ class check_oracle_semantics extends XMLDBCheckAction {
                 // Get current semantic from dictionary, we only will process B (BYTE) ones
                 // suplying the SQL code to change them to C (CHAR) semantic
                 $params = array(
-                    'table_name' => textlib::strtoupper($DB->get_prefix() . $xmldb_table->getName()),
-                    'column_name' => textlib::strtoupper($xmldb_field->getName()),
+                    'table_name' => core_text::strtoupper($DB->get_prefix() . $xmldb_table->getName()),
+                    'column_name' => core_text::strtoupper($xmldb_field->getName()),
                     'data_type' => 'VARCHAR2');
                 $currentsemantic = $DB->get_field_sql('
                     SELECT char_used
index 491e451..5f6a468 100644 (file)
@@ -57,7 +57,7 @@ foreach (core_component::get_plugin_list('tool') as $plugin => $plugindir) {
     }
     $plugins[$plugin] = $strpluginname;
 }
-collatorlib::asort($plugins);
+core_collator::asort($plugins);
 
 $like = $DB->sql_like('plugin', '?', true, true, false, '|');
 $params = array('tool|_%');
index b1c09ae..3aef57c 100644 (file)
@@ -73,12 +73,17 @@ class external_service_form extends moodleform {
         $mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice');
         $mform->setType('restrictedusers', PARAM_BOOL);
 
-        //can users download files
+        // Can users download files?
         $mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice'));
         $mform->setAdvanced('downloadfiles');
         $mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice');
         $mform->setType('downloadfiles', PARAM_BOOL);
 
+        // Can users upload files?
+        $mform->addElement('advcheckbox', 'uploadfiles', get_string('uploadfiles', 'webservice'));
+        $mform->setAdvanced('uploadfiles');
+        $mform->addHelpButton('uploadfiles', 'uploadfiles', 'webservice');
+
         /// needed to select automatically the 'No required capability" option
         $currentcapabilityexist = false;
         if (empty($service->requiredcapability)) {
@@ -297,4 +302,4 @@ class web_service_token_form extends moodleform {
         return $errors;
     }
 
-}
\ No newline at end of file
+}
index 95ab725..6d1d582 100644 (file)
@@ -61,7 +61,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
      */
     function user_login ($username, $password) {
         $this->connectCAS();
-        return phpCAS::isAuthenticated() && (trim(textlib::strtolower(phpCAS::getUser())) == $username);
+        return phpCAS::isAuthenticated() && (trim(core_text::strtolower(phpCAS::getUser())) == $username);
     }
 
     /**
@@ -381,15 +381,15 @@ class auth_plugin_cas extends auth_plugin_ldap {
         set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
         set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig);
         set_config('contexts', trim($config->contexts), $this->pluginconfig);
-        set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
-        set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
+        set_config('user_type', core_text::strtolower(trim($config->user_type)), $this->pluginconfig);
+        set_config('user_attribute', core_text::strtolower(trim($config->user_attribute)), $this->pluginconfig);
         set_config('search_sub', $config->search_sub, $this->pluginconfig);
         set_config('opt_deref', $config->opt_deref, $this->pluginconfig);
         set_config('bind_dn', trim($config->bind_dn), $this->pluginconfig);
         set_config('bind_pw', $config->bind_pw, $this->pluginconfig);
         set_config('ldap_version', $config->ldap_version, $this->pluginconfig);
         set_config('objectclass', trim($config->objectclass), $this->pluginconfig);
-        set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig);
+        set_config('memberattribute', core_text::strtolower(trim($config->memberattribute)), $this->pluginconfig);
         set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig);
         set_config('attrcreators', trim($config->attrcreators), $this->pluginconfig);
         set_config('groupecreators', trim($config->groupecreators), $this->pluginconfig);
@@ -409,7 +409,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
             return false;
         }
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         // Test for group creator
         if (!empty($this->config->groupecreators)) {
index f245d60..de5061d 100644 (file)
@@ -58,8 +58,8 @@ class auth_plugin_db extends auth_plugin_base {
     function user_login($username, $password) {
         global $CFG, $DB;
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding);
-        $extpassword = textlib::convert($password, 'utf-8', $this->config->extencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding);
+        $extpassword = core_text::convert($password, 'utf-8', $this->config->extencoding);
 
         if ($this->is_internal()) {
             // Lookup username externally, but resolve
@@ -176,7 +176,7 @@ class auth_plugin_db extends auth_plugin_base {
     function get_userinfo($username) {
         global $CFG;
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding);
 
         $authdb = $this->db_init();
 
@@ -199,7 +199,7 @@ class auth_plugin_db extends auth_plugin_base {
                     $fields_obj = $rs->FetchObj();
                     $fields_obj = (object)array_change_key_case((array)$fields_obj , CASE_LOWER);
                     foreach ($selectfields as $localname=>$externalname) {
-                        $result[$localname] = textlib::convert($fields_obj->{$localname}, $this->config->extencoding, 'utf-8');
+                        $result[$localname] = core_text::convert($fields_obj->{$localname}, $this->config->extencoding, 'utf-8');
                      }
                  }
                  $rs->Close();
@@ -426,7 +426,7 @@ class auth_plugin_db extends auth_plugin_base {
         // Init result value.
         $result = false;
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding);
 
         $authdb = $this->db_init();
 
@@ -501,7 +501,7 @@ class auth_plugin_db extends auth_plugin_base {
         global $CFG, $DB;
 
         //just in case check text case
-        $username = trim(textlib::strtolower($username));
+        $username = trim(core_text::strtolower($username));
 
         // get the current user record
         $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id));
@@ -569,7 +569,7 @@ class auth_plugin_db extends auth_plugin_base {
             return false;
         }
 
-        $extusername = textlib::convert($olduser->username, 'utf-8', $this->config->extencoding);
+        $extusername = core_text::convert($olduser->username, 'utf-8', $this->config->extencoding);
 
         $authdb = $this->db_init();
 
@@ -586,7 +586,7 @@ class auth_plugin_db extends auth_plugin_base {
             }
             $nuvalue = $newuser->$key;
             if ($nuvalue != $value) {
-                $update[] = $this->config->{"field_map_$key"}."='".$this->ext_addslashes(textlib::convert($nuvalue, 'utf-8', $this->config->extencoding))."'";
+                $update[] = $this->config->{"field_map_$key"}."='".$this->ext_addslashes(core_text::convert($nuvalue, 'utf-8', $this->config->extencoding))."'";
             }
         }
         if (!empty($update)) {
index 9ac59bd..e459004 100644 (file)
@@ -195,6 +195,15 @@ class auth_plugin_email extends auth_plugin_base {
         return true;
     }
 
+    /**
+     * Returns true if plugin can be manually set.
+     *
+     * @return bool
+     */
+    function can_be_manually_set() {
+        return true;
+    }
+
     /**
      * Prints a form for configuring this authentication plugin.
      *
index e9d82b7..a1a9645 100644 (file)
@@ -168,8 +168,8 @@ class auth_plugin_ldap extends auth_plugin_base {
             return false;
         }
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
-        $extpassword = textlib::convert($password, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extpassword = core_text::convert($password, 'utf-8', $this->config->ldapencoding);
 
         // Before we connect to LDAP, check if this is an AD SSO login
         // if we succeed in this block, we'll return success early.
@@ -250,7 +250,7 @@ class auth_plugin_ldap extends auth_plugin_base {
      * @return mixed array with no magic quotes or false on error
      */
     function get_userinfo($username) {
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
         if(!($user_dn = $this->ldap_find_userdn($ldapconnection, $extusername))) {
@@ -298,9 +298,9 @@ class auth_plugin_ldap extends auth_plugin_base {
                     continue; // wrong data mapping!
                 }
                 if (is_array($entry[$value])) {
-                    $newval = textlib::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
+                    $newval = core_text::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8');
                 } else {
-                    $newval = textlib::convert($entry[$value], $this->config->ldapencoding, 'utf-8');
+                    $newval = core_text::convert($entry[$value], $this->config->ldapencoding, 'utf-8');
                 }
                 if (!empty($newval)) { // favour ldap entries that are set
                     $ldapval = $newval;
@@ -351,7 +351,7 @@ class auth_plugin_ldap extends auth_plugin_base {
      * @param string $username
      */
     function user_exists($username) {
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         // Returns true if given username exists on ldap
         $users = $this->ldap_get_userlist('('.$this->config->user_attribute.'='.ldap_filter_addslashes($extusername).')');
@@ -367,8 +367,8 @@ class auth_plugin_ldap extends auth_plugin_base {
      * @param mixed $plainpass   Plaintext password
      */
     function user_create($userobject, $plainpass) {
-        $extusername = textlib::convert($userobject->username, 'utf-8', $this->config->ldapencoding);
-        $extpassword = textlib::convert($plainpass, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($userobject->username, 'utf-8', $this->config->ldapencoding);
+        $extpassword = core_text::convert($plainpass, 'utf-8', $this->config->ldapencoding);
 
         switch ($this->config->passtype) {
             case 'md5':
@@ -393,7 +393,7 @@ class auth_plugin_ldap extends auth_plugin_base {
             }
             foreach ($values as $value) {
                 if (!empty($userobject->$key) ) {
-                    $newuser[$value] = textlib::convert($userobject->$key, 'utf-8', $this->config->ldapencoding);
+                    $newuser[$value] = core_text::convert($userobject->$key, 'utf-8', $this->config->ldapencoding);
                 }
             }
         }
@@ -509,6 +509,15 @@ class auth_plugin_ldap extends auth_plugin_base {
         return !empty($this->config->stdchangepassword);
     }
 
+    /**
+     * Returns true if plugin can be manually set.
+     *
+     * @return bool
+     */
+    function can_be_manually_set() {
+        return true;
+    }
+
     /**
      * Returns true if plugin allows signup and user creation.
      *
@@ -628,7 +637,7 @@ class auth_plugin_ldap extends auth_plugin_base {
     function password_expire($username) {
         $result = 0;
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
         $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
@@ -726,7 +735,7 @@ class auth_plugin_ldap extends auth_plugin_base {
                 if ($entry = @ldap_first_entry($ldapconnection, $ldap_result)) {
                     do {
                         $value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute);
-                        $value = textlib::convert($value[0], $this->config->ldapencoding, 'utf-8');
+                        $value = core_text::convert($value[0], $this->config->ldapencoding, 'utf-8');
                         $this->ldap_bulk_insert($value);
                     } while ($entry = ldap_next_entry($ldapconnection, $entry));
                 }
@@ -936,7 +945,7 @@ class auth_plugin_ldap extends auth_plugin_base {
                 $user->mnethostid = $CFG->mnet_localhost_id;
                 // get_userinfo_asobj() might have replaced $user->username with the value
                 // from the LDAP server (which can be mixed-case). Make sure it's lowercase
-                $user->username = trim(textlib::strtolower($user->username));
+                $user->username = trim(core_text::strtolower($user->username));
                 if (empty($user->lang)) {
                     $user->lang = $CFG->lang;
                 }
@@ -982,7 +991,7 @@ class auth_plugin_ldap extends auth_plugin_base {
         global $CFG, $DB;
 
         // Just in case check text case
-        $username = trim(textlib::strtolower($username));
+        $username = trim(core_text::strtolower($username));
 
         // Get the current user record
         $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id));
@@ -1031,7 +1040,7 @@ class auth_plugin_ldap extends auth_plugin_base {
     function ldap_bulk_insert($username) {
         global $DB, $CFG;
 
-        $username = textlib::strtolower($username); // usernames are __always__ lowercase.
+        $username = core_text::strtolower($username); // usernames are __always__ lowercase.
         $DB->insert_record_raw('tmp_extuser', array('username'=>$username,
                                                     'mnethostid'=>$CFG->mnet_localhost_id), false, true);
         echo '.';
@@ -1044,7 +1053,7 @@ class auth_plugin_ldap extends auth_plugin_base {
      * @return boolean result
      */
     function user_activate($username) {
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
 
@@ -1094,7 +1103,7 @@ class auth_plugin_ldap extends auth_plugin_base {
             return null;
         }
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
 
@@ -1152,7 +1161,7 @@ class auth_plugin_ldap extends auth_plugin_base {
             return true;
         }
 
-        $extoldusername = textlib::convert($olduser->username, 'utf-8', $this->config->ldapencoding);
+        $extoldusername = core_text::convert($olduser->username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
 
@@ -1214,9 +1223,9 @@ class auth_plugin_ldap extends auth_plugin_base {
                         $ambiguous = false;
                     }
 
-                    $nuvalue = textlib::convert($newuser->$profilefield, 'utf-8', $this->config->ldapencoding);
+                    $nuvalue = core_text::convert($newuser->$profilefield, 'utf-8', $this->config->ldapencoding);
                     empty($nuvalue) ? $nuvalue = array() : $nuvalue;
-                    $ouvalue = textlib::convert($olduser->$profilefield, 'utf-8', $this->config->ldapencoding);
+                    $ouvalue = core_text::convert($olduser->$profilefield, 'utf-8', $this->config->ldapencoding);
 
                     foreach ($ldapkeys as $ldapkey) {
                         $ldapkey   = $ldapkey;
@@ -1312,8 +1321,8 @@ class auth_plugin_ldap extends auth_plugin_base {
         $result = false;
         $username = $user->username;
 
-        $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding);
-        $extpassword = textlib::convert($newpassword, 'utf-8', $this->config->ldapencoding);
+        $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
+        $extpassword = core_text::convert($newpassword, 'utf-8', $this->config->ldapencoding);
 
         switch ($this->config->passtype) {
             case 'md5':
@@ -1489,13 +1498,13 @@ class auth_plugin_ldap extends auth_plugin_base {
 
         foreach ($userfields as $field) {
             if (!empty($this->config->{"field_map_$field"})) {
-                $moodleattributes[$field] = textlib::strtolower(trim($this->config->{"field_map_$field"}));
+                $moodleattributes[$field] = core_text::strtolower(trim($this->config->{"field_map_$field"}));
                 if (preg_match('/,/', $moodleattributes[$field])) {
                     $moodleattributes[$field] = explode(',', $moodleattributes[$field]); // split ?
                 }
             }
         }
-        $moodleattributes['username'] = textlib::strtolower(trim($this->config->user_attribute));
+        $moodleattributes['username'] = core_text::strtolower(trim($this->config->user_attribute));
         return $moodleattributes;
     }
 
@@ -1546,7 +1555,7 @@ class auth_plugin_ldap extends auth_plugin_base {
                 $users = ldap_get_entries_moodle($ldapconnection, $ldap_result);
                 // Add found users to list.
                 for ($i = 0; $i < count($users); $i++) {
-                    $extuser = textlib::convert($users[$i][$this->config->user_attribute][0],
+                    $extuser = core_text::convert($users[$i][$this->config->user_attribute][0],
                                                 $this->config->ldapencoding, 'utf-8');
                     array_push($fresult, $extuser);
                 }
@@ -1687,7 +1696,7 @@ class auth_plugin_ldap extends auth_plugin_base {
             // (according to my reading of RFC-1945, RFC-2616 and RFC-2617 and
             // my local tests), so we need to convert the REMOTE_USER value
             // (i.e., what we got from the HTTP WWW-Authenticate header) into UTF-8
-            $username = textlib::convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8');
+            $username = core_text::convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8');
 
             switch ($this->config->ntlmsso_type) {
                 case 'ntlm':
@@ -1706,7 +1715,7 @@ class auth_plugin_ldap extends auth_plugin_base {
                     return false; // Should never happen!
             }
 
-            $username = textlib::strtolower($username); // Compatibility hack
+            $username = core_text::strtolower($username); // Compatibility hack
             set_cache_flag($this->pluginconfig.'/ntlmsess', $sesskey, $username, AUTH_NTLMTIMEOUT);
             return true;
         }
@@ -1915,7 +1924,7 @@ class auth_plugin_ldap extends auth_plugin_base {
 
         // Try to remove duplicates before storing the contexts (to avoid problems in sync_users()).
         $config->contexts = explode(';', $config->contexts);
-        $config->contexts = array_map(create_function('$x', 'return textlib::strtolower(trim($x));'),
+        $config->contexts = array_map(create_function('$x', 'return core_text::strtolower(trim($x));'),
                                       $config->contexts);
         $config->contexts = implode(';', array_unique($config->contexts));
 
@@ -1925,8 +1934,8 @@ class auth_plugin_ldap extends auth_plugin_base {
         set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig);
         set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig);
         set_config('contexts', $config->contexts, $this->pluginconfig);
-        set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig);
-        set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig);
+        set_config('user_type', core_text::strtolower(trim($config->user_type)), $this->pluginconfig);
+        set_config('user_attribute', core_text::strtolower(trim($config->user_attribute)), $this->pluginconfig);
         set_config('search_sub', $config->search_sub, $this->pluginconfig);
         set_config('opt_deref', $config->opt_deref, $this->pluginconfig);
         set_config('preventpassindb', $config->preventpassindb, $this->pluginconfig);
@@ -1934,15 +1943,15 @@ class auth_plugin_ldap extends auth_plugin_base {
         set_config('bind_pw', $config->bind_pw, $this->pluginconfig);
         set_config('ldap_version', $config->ldap_version, $this->pluginconfig);
         set_config('objectclass', trim($config->objectclass), $this->pluginconfig);
-        set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig);
+        set_config('memberattribute', core_text::strtolower(trim($config->memberattribute)), $this->pluginconfig);
         set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig);
         set_config('creators', trim($config->creators), $this->pluginconfig);
         set_config('create_context', trim($config->create_context), $this->pluginconfig);
         set_config('expiration', $config->expiration, $this->pluginconfig);
         set_config('expiration_warning', trim($config->expiration_warning), $this->pluginconfig);
-        set_config('expireattr', textlib::strtolower(trim($config->expireattr)), $this->pluginconfig);
+        set_config('expireattr', core_text::strtolower(trim($config->expireattr)), $this->pluginconfig);
         set_config('gracelogins', $config->gracelogins, $this->pluginconfig);
-        set_config('graceattr', textlib::strtolower(trim($config->graceattr)), $this->pluginconfig);
+        set_config('graceattr', core_text::strtolower(trim($config->graceattr)), $this->pluginconfig);
         set_config('auth_user_create', $config->auth_user_create, $this->pluginconfig);
         set_config('forcechangepassword', $config->forcechangepassword, $this->pluginconfig);
         set_config('stdchangepassword', $config->stdchangepassword, $this->pluginconfig);
index 3b4fdae..1c7ff9e 100644 (file)
@@ -129,6 +129,15 @@ class auth_plugin_manual extends auth_plugin_base {
         return true;
     }
 
+    /**
+     * Returns true if plugin can be manually set.
+     *
+     * @return bool
+     */
+    function can_be_manually_set() {
+        return true;
+    }
+
     /**
      * Prints a form for configuring this authentication plugin.
      *
index 29f018e..c3ed391 100644 (file)
@@ -85,6 +85,14 @@ class auth_plugin_nologin extends auth_plugin_base {
         return false;
     }
 
+    /**
+     * Returns true if plugin can be manually set.
+     *
+     * @return bool
+     */
+    function can_be_manually_set() {
+        return true;
+    }
 }
 
 
index 9d3bfc2..fcfce4c 100644 (file)
@@ -115,6 +115,15 @@ class auth_plugin_none extends auth_plugin_base {
         return true;
     }
 
+    /**
+     * Returns true if plugin can be manually set.
+     *
+     * @return bool
+     */
+    function can_be_manually_set() {
+        return true;
+    }
+
     /**
      * Prints a form for configuring this authentication plugin.
      *
diff --git a/auth/tests/auth_test.php b/auth/tests/auth_test.php
deleted file mode 100644 (file)
index 0b2b8ae..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Tests for auth.
- *
- * @package    core_auth
- * @copyright  2013 Frédéric Massart
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-global $CFG;
-require_once($CFG->libdir . '/authlib.php');
-
-/**
- * Auth testcase class.
- *
- * @package    core_auth
- * @copyright  2013 Frédéric Massart
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class auth_testcase extends advanced_testcase {
-
-    public function test_user_loggedin_event() {
-        global $USER;
-        $this->resetAfterTest(true);
-        $this->setAdminUser();
-
-        $sink = $this->redirectEvents();
-        $user = clone($USER);
-        login_attempt_valid($user);
-        $events = $sink->get_events();
-        $sink->close();
-
-        $this->assertCount(1, $events);
-        $event = reset($events);
-        $this->assertInstanceOf('\core_auth\event\user_loggedin', $event);
-        $this->assertEquals('user', $event->objecttable);
-        $this->assertEquals('2', $event->objectid);
-        $this->assertEquals(context_system::instance()->id, $event->contextid);
-        $this->assertEquals($user, $event->get_record_snapshot('user', 2));
-    }
-
-    public function test_user_loggedin_event_exceptions() {
-        try {
-            $event = \core_auth\event\user_loggedin::create(array('objectid' => 1));
-            $this->fail('\core_auth\event\user_loggedin requires other[\'username\']');
-        } catch(Exception $e) {
-            $this->assertInstanceOf('coding_exception', $e);
-        }
-
-        try {
-            $event = \core_auth\event\user_loggedin::create(array('other' => array('username' => 'test')));
-            $this->fail('\core_auth\event\user_loggedin requires objectid');
-        } catch(Exception $e) {
-            $this->assertInstanceOf('coding_exception', $e);
-        }
-    }
-
-}
index 4618dd5..6085397 100644 (file)
@@ -1,6 +1,11 @@
 This files describes API changes in /auth/* - plugins,
 information provided here is intended especially for developers.
 
+=== 2.6 ===
+
+* can_be_manually_set() - This function was introduced in the base class and returns false by default. If overriden by
+  an authentication plugin to return true, the authentication plugin will be able to be manually set for users. For example,
+  when bulk uploading users you will be able to select it as the authentication method they use.
 
 === 2.4 ===
 
index 6b44703..a485145 100644 (file)
@@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
 /*
  * controller tests (all)
  */
-class backup_controller_testcase extends advanced_testcase {
+class core_backup_controller_testcase extends advanced_testcase {
 
     protected $moduleid;  // course_modules id used for testing
     protected $sectionid; // course_sections id used for testing
index 539d804..c3df06b 100644 (file)
@@ -1222,7 +1222,7 @@ class moodle1_question_bank_handler extends moodle1_xml_handler {
 
         // replay the upgrade step 2010080901 - updating question image
         if (!empty($data['image'])) {
-            if (textlib::substr(textlib::strtolower($data['image']), 0, 7) == 'http://') {
+            if (core_text::substr(core_text::strtolower($data['image']), 0, 7) == 'http://') {
                 // it is a link, appending to existing question text
                 $data['questiontext'] .= ' <img src="' . $data['image'] . '" />';
 
index 8f7ec30..fb9b9e1 100644 (file)
@@ -1233,7 +1233,7 @@ class moodle1_file_manager implements loggable {
         }
         $filepath = clean_param($filepath, PARAM_PATH);
 
-        if (textlib::strlen($filepath) > 255) {
+        if (core_text::strlen($filepath) > 255) {
             throw new moodle1_convert_exception('file_path_longer_than_255_chars');
         }
 
@@ -30,7 +30,7 @@ global $CFG;
 require_once($CFG->dirroot . '/backup/converter/moodle1/lib.php');
 
 
-class moodle1_converter_testcase extends advanced_testcase {
+class core_backup_moodle1_converter_testcase extends advanced_testcase {
 
     /** @var string the name of the directory containing the unpacked Moodle 1.9 backup */
     protected $tempdir;
index 2e2faae..5307637 100644 (file)
@@ -204,7 +204,7 @@ abstract class backup_plan_dbops extends backup_dbops {
         global $DB;
 
         // Calculate backup word
-        $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
+        $backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename')));
         $backupword = trim(clean_filename($backupword), '_');
 
         // Not $useidonly, lets fetch the name
@@ -228,7 +228,7 @@ abstract class backup_plan_dbops extends backup_dbops {
                     break;
             }
             $shortname = str_replace(' ', '_', $shortname);
-            $shortname = textlib::strtolower(trim(clean_filename($shortname), '_'));
+            $shortname = core_text::strtolower(trim(clean_filename($shortname), '_'));
         }
 
         // The name will always contain the ID, but we append the course short name if requested.
@@ -240,7 +240,7 @@ abstract class backup_plan_dbops extends backup_dbops {
         // Calculate date
         $backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
         $date = userdate(time(), $backupdateformat, 99, false);
-        $date = textlib::strtolower(trim(clean_filename($date), '_'));
+        $date = core_text::strtolower(trim(clean_filename($date), '_'));
 
         // Calculate info
         $info = '';
index e90125d..5913324 100644 (file)
@@ -554,7 +554,7 @@ abstract class backup_cron_automated_helper {
             return true;
         }
 
-        $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
+        $backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename')));
         $backupword = trim(clean_filename($backupword), '_');
 
         if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) {
index b51d155..9ccafc1 100644 (file)
@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
 global $CFG;
 require_once($CFG->libdir . '/badgeslib.php');
 
-class badges_testcase extends advanced_testcase {
+class core_badgeslib_testcase extends advanced_testcase {
     protected $badgeid;
 
     protected function setUp() {
index 7383658..6dc2f9b 100644 (file)
@@ -49,7 +49,7 @@ class block_activity_modules extends block_list {
             }
         }
 
-        collatorlib::asort($modfullnames);
+        core_collator::asort($modfullnames);
 
         foreach ($modfullnames as $modname => $modfullname) {
             if ($modname === 'resources') {
index 3cac07a..e7eaf88 100644 (file)
@@ -103,10 +103,6 @@ class behat_block_comments extends behat_base {
         $deleteicon = $this->find('css', '.comment-delete a img', $deleteexception, $commentnode);
         $deleteicon->click();
 
-        // Yes confirm.
-        $confirmnode = $this->find('xpath', "//div[@class='comment-delete-confirm']/descendant::a[contains(., '" . get_string('yes') . "')]");
-        $confirmnode->click();
-
         // Wait for the AJAX request.
         $this->getSession()->wait(4 * 1000, false);
     }
index cb8d7d3..3a01716 100644 (file)
@@ -272,7 +272,7 @@ class community_hub_search_form extends moodleform {
             $mform->setDefault('licence', $licence);
 
             $languages = get_string_manager()->get_list_of_languages();
-            collatorlib::asort($languages);
+            core_collator::asort($languages);
             $languages = array_merge(array('all' => get_string('any')), $languages);
             $mform->addElement('select', 'language', get_string('language'), $languages);
 
index b842fb4..be4cd2f 100644 (file)
@@ -210,12 +210,12 @@ if (empty($completions)) {
                 $agg = $info->get_aggregation_method($row['type']);
                 echo '('. html_writer::start_tag('i');
                 if ($agg == COMPLETION_AGGREGATION_ALL) {
-                    echo textlib::strtolower(get_string('all', 'completion'));
+                    echo core_text::strtolower(get_string('all', 'completion'));
                 } else {
-                    echo textlib::strtolower(get_string('any', 'completion'));
+                    echo core_text::strtolower(get_string('any', 'completion'));
                 }
 
-                echo html_writer::end_tag('i') .textlib::strtolower(get_string('required')).')';
+                echo html_writer::end_tag('i') .core_text::strtolower(get_string('required')).')';
                 $agg_type = false;
             }
         }
index 00752d3..95abb63 100644 (file)
@@ -34,5 +34,17 @@ $capabilities = array(
         ),
 
         'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/course_overview:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
     )
 );
index b7f0ec6..01a6091 100644 (file)
@@ -27,6 +27,7 @@ $string['alwaysshowall'] = 'Always Show All';
 $string['collapseall'] = 'Collapse All Course Lists';
 $string['configotherexpanded'] = 'If enabled, Other Courses will be expanded by default unless overriden by user preferences.';
 $string['configpreservestates'] = 'If enabled, the collapsed/expanded states set by the user are stored and used on each load.';
+$string['course_overview:addinstance'] = 'Add a new course overview block';
 $string['course_overview:myaddinstance'] = 'Add a new course overview block to My home';
 $string['defaultmaxcourses'] = 'Default maximum courses';
 $string['defaultmaxcoursesdesc'] = 'Maximum courses which should be displayed on course overview block, 0 will show all courses';
index bc159de..71267b6 100644 (file)
 function block_course_overview_get_overviews($courses) {
     $htmlarray = array();
     if ($modules = get_plugin_list_with_function('mod', 'print_overview')) {
-        foreach ($modules as $fname) {
-            $fname($courses,$htmlarray);
+        // Split courses list into batches with no more than MAX_MODINFO_CACHE_SIZE courses in one batch.
+        // Otherwise we exceed the cache limit in get_fast_modinfo() and rebuild it too often.
+        if (defined('MAX_MODINFO_CACHE_SIZE') && MAX_MODINFO_CACHE_SIZE > 0 && count($courses) > MAX_MODINFO_CACHE_SIZE) {
+            $batches = array_chunk($courses, MAX_MODINFO_CACHE_SIZE, true);
+        } else {
+            $batches = array($courses);
+        }
+        foreach ($batches as $courses) {
+            foreach ($modules as $fname) {
+                $fname($courses, $htmlarray);
+            }
         }
     }
     return $htmlarray;
index 3a6878d..8607737 100644 (file)
@@ -24,6 +24,6 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2013050100;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2013073000;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'block_course_overview'; // Full name of the plugin (used for diagnostics)
index 2252e85..9b2613b 100644 (file)
@@ -255,31 +255,31 @@ class block_navigation extends block_base {
     public function trim(navigation_node $node, $mode=1, $long=50, $short=25, $recurse=true) {
         switch ($mode) {
             case self::TRIM_RIGHT :
-                if (textlib::strlen($node->text)>($long+3)) {
+                if (core_text::strlen($node->text)>($long+3)) {
                     // Truncate the text to $long characters
                     $node->text = $this->trim_right($node->text, $long);
                 }
-                if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
+                if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) {
                     // Truncate the shorttext
                     $node->shorttext = $this->trim_right($node->shorttext, $short);
                 }
                 break;
             case self::TRIM_LEFT :
-                if (textlib::strlen($node->text)>($long+3)) {
+                if (core_text::strlen($node->text)>($long+3)) {
                     // Truncate the text to $long characters
                     $node->text = $this->trim_left($node->text, $long);
                 }
-                if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
+                if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) {
                     // Truncate the shorttext
                     $node->shorttext = $this->trim_left($node->shorttext, $short);
                 }
                 break;
             case self::TRIM_CENTER :
-                if (textlib::strlen($node->text)>($long+3)) {
+                if (core_text::strlen($node->text)>($long+3)) {
                     // Truncate the text to $long characters
                     $node->text = $this->trim_center($node->text, $long);
                 }
-                if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) {
+                if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) {
                     // Truncate the shorttext
                     $node->shorttext = $this->trim_center($node->shorttext, $short);
                 }
@@ -298,7 +298,7 @@ class block_navigation extends block_base {
      * @return string The truncated string
      */
     protected function trim_left($string, $length) {
-        return '...'.textlib::substr($string, textlib::strlen($string)-$length, $length);
+        return '...'.core_text::substr($string, core_text::strlen($string)-$length, $length);
     }
     /**
      * Truncate a string from the right
@@ -307,7 +307,7 @@ class block_navigation extends block_base {
      * @return string The truncated string
      */
     protected function trim_right($string, $length) {
-        return textlib::substr($string, 0, $length).'...';
+        return core_text::substr($string, 0, $length).'...';
     }
     /**
      * Truncate a string in the center
@@ -317,8 +317,8 @@ class block_navigation extends block_base {
      */
     protected function trim_center($string, $length) {
         $trimlength = ceil($length/2);
-        $start = textlib::substr($string, 0, $trimlength);
-        $end = textlib::substr($string, textlib::strlen($string)-$trimlength);
+        $start = core_text::substr($string, 0, $trimlength);
+        $end = core_text::substr($string, core_text::strlen($string)-$trimlength);
         $string = $start.'...'.$end;
         return $string;
     }
index 102a03c..567250b 100644 (file)
@@ -57,12 +57,15 @@ Feature: View my courses in navigation block
     Then I should see "cat1" in the "div.block_navigation .type_system" "css_element"
     And I should see "cat3" in the "div.block_navigation .type_system" "css_element"
     And I should not see "cat2" in the "div.block_navigation .type_system" "css_element"
-    When I expand "cat3" node
-    Then I should see "cat31" in the "div.block_navigation .type_system" "css_element"
+    And I expand "cat3" node
+    And I wait "2" seconds
+    And I should see "cat31" in the "div.block_navigation .type_system" "css_element"
     And I should see "cat33" in the "div.block_navigation .type_system" "css_element"
     And I should not see "cat32" in the "div.block_navigation .type_system" "css_element"
-    When I expand "cat31" node
-    Then I should see "c31" in the "div.block_navigation .type_system" "css_element"
-    When I expand "cat33" node
+    And I expand "cat31" node
+    And I wait "2" seconds
+    And I should see "c31" in the "div.block_navigation .type_system" "css_element"
+    And I expand "cat33" node
+    And I wait "2" seconds
     And I should see "c331" in the "div.block_navigation .type_system" "css_element"
     And I should not see "c332" in the "div.block_navigation .type_system" "css_element"
index 4b861a8..e2ab922 100644 (file)
 
         if(empty($title)){
             // no title present, use portion of description
-            $title = textlib::substr(strip_tags($description), 0, 20) . '...';
+            $title = core_text::substr(strip_tags($description), 0, 20) . '...';
         }else{
             $title = break_up_long_words($title, 30);
         }
      */
     function format_title($title,$max=64) {
 
-        if (textlib::strlen($title) <= $max) {
+        if (core_text::strlen($title) <= $max) {
             return s($title);
         } else {
-            return s(textlib::substr($title,0,$max-3).'...');
+            return s(core_text::substr($title,0,$max-3).'...');
         }
     }
 
index cfe8771..c7ee5bd 100644 (file)
@@ -205,8 +205,8 @@ function blog_sync_external_entries($externalblog) {
         $newentry->subject = clean_param($entry->get_title(), PARAM_TEXT);
         // Observe 128 max chars in DB
         // TODO: +1 to raise this to 255
-        if (textlib::strlen($newentry->subject) > 128) {
-            $newentry->subject = textlib::substr($newentry->subject, 0, 125) . '...';
+        if (core_text::strlen($newentry->subject) > 128) {
+            $newentry->subject = core_text::substr($newentry->subject, 0, 125) . '...';
         }
         $newentry->summary = $entry->get_description();
 
@@ -241,7 +241,7 @@ function blog_sync_external_entries($externalblog) {
             $oldesttimestamp = $timestamp;
         }
 
-        if (textlib::strlen($newentry->uniquehash) > 255) {
+        if (core_text::strlen($newentry->uniquehash) > 255) {
             // The URL for this item is too long for the field. Rather than add
             // the entry without the link we will skip straight over it.
             // RSS spec says recommended length 500, we use 255.
index a508052..7038060 100644 (file)
@@ -239,7 +239,6 @@ class blog_entry implements renderable {
     /**
      * Inserts this entry in the database. Access control checks must be done by calling code.
      * TODO Set the publishstate correctly
-     * @param mform $form Used for attachments
      * @return void
      */
     public function add() {
@@ -259,11 +258,17 @@ class blog_entry implements renderable {
 
         if (!empty($CFG->useblogassociations)) {
             $this->add_associations();
-            add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$this->userid.'&entryid='.$this->id, $this->subject);
         }
 
         tag_set('post', $this->id, $this->tags);
-        events_trigger('blog_entry_added', $this);
+
+        // Trigger an event for the new entry.
+        $event = \core\event\blog_entry_created::create(array('objectid' => $this->id,
+                                                            'userid'   => $this->userid,
+                                                            'other'    => array ("subject" => $this->subject)
+                                                      ));
+        $event->set_custom_data($this);
+        $event->trigger();
     }
 
     /**
index 7828194..1527a3c 100644 (file)
@@ -55,7 +55,6 @@ Feature: Comment on a blog entry
     And I follow "Save comment"
     And I wait "4" seconds
     When I click on ".comment-delete a" "css_element"
-    And I click on "Yes" "link"
     And I wait "4" seconds
     Then I should not see "$My own >nasty< \"string\"!"
     And I follow "Blog post from user 1"
index f385eb3..6ed0658 100644 (file)
@@ -31,7 +31,7 @@ require_once($CFG->dirroot . '/blog/lib.php');
 /**
  * Test functions that rely on the DB tables
  */
-class bloglib_testcase extends advanced_testcase {
+class core_bloglib_testcase extends advanced_testcase {
 
     private $courseid; // To store important ids to be used in tests
     private $cmid;
@@ -150,4 +150,33 @@ class bloglib_testcase extends advanced_testcase {
         $blog_headers = blog_get_headers($this->courseid);
         $this->assertNotEquals($blog_headers['heading'], '');
     }
+
+    /**
+     * Test various blog related events.
+     */
+    public function test_blog_entry_events() {
+        global $USER;
+
+        $this->setAdminUser();
+        $this->resetAfterTest();
+
+        // Create a blog entry.
+        $blog = new blog_entry();
+        $blog->summary = "This is summary of blog";
+        $blog->subject = "Subject of blog";
+        $states = blog_entry::get_applicable_publish_states();
+        $blog->publishstate = reset($states);
+        $sink = $this->redirectEvents();
+        $blog->add();
+        $events = $sink->get_events();
+        $event = reset($events);
+        $sitecontext = context_system::instance();
+
+        // Validate event data.
+        $this->assertInstanceOf('\core\event\blog_entry_created', $event);
+        $this->assertEquals($sitecontext->id, $event->contextid);
+        $this->assertEquals($blog->id, $event->objectid);
+        $this->assertEquals($USER->id, $event->userid);
+        $this->assertEquals("post", $event->objecttable);
+    }
 }
diff --git a/cache/tests/administration_helper_test.php b/cache/tests/administration_helper_test.php
new file mode 100644 (file)
index 0000000..6a1630d
--- /dev/null
@@ -0,0 +1,236 @@
+<?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/>.
+
+/**
+ * PHPunit tests for the cache API and in particular things in locallib.php
+ *
+ * This file is part of Moodle's cache API, affectionately called MUC.
+ * It contains the components that are requried in order to use caching.
+ *
+ * @package    core
+ * @category   cache
+ * @copyright  2012 Sam Hemelryk
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+// Include the necessary evils.
+global $CFG;
+require_once($CFG->dirroot.'/cache/locallib.php');
+require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php');
+
+
+/**
+ * PHPunit tests for the cache API and in particular the cache_administration_helper
+ *
+ * @copyright  2012 Sam Hemelryk
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_cache_administration_helper_testcase extends advanced_testcase {
+
+    /**
+     * Set things back to the default before each test.
+     */
+    public function setUp() {
+        parent::setUp();
+        cache_factory::reset();
+        cache_config_phpunittest::create_default_configuration();
+    }
+
+    /**
+     * Final task is to reset the cache system
+     */
+    public static function tearDownAfterClass() {
+        parent::tearDownAfterClass();
+        cache_factory::reset();
+    }
+
+    /**
+     * Test the numerous summaries the helper can produce.
+     */
+    public function test_get_summaries() {
+        // First the preparation.
+        $config = cache_config_writer::instance();
+        $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
+        $config->set_definition_mappings('core/eventinvalidation', array('summariesstore'));
+        $this->assertTrue($config->set_mode_mappings(array(
+            cache_store::MODE_APPLICATION => array('summariesstore'),
+            cache_store::MODE_SESSION => array('default_session'),
+            cache_store::MODE_REQUEST => array('default_request'),
+        )));
+
+        $storesummaries = cache_administration_helper::get_store_instance_summaries();
+        $this->assertInternalType('array', $storesummaries);
+        $this->assertArrayHasKey('summariesstore', $storesummaries);
+        $summary = $storesummaries['summariesstore'];
+        // Check the keys
+        $this->assertArrayHasKey('name', $summary);
+        $this->assertArrayHasKey('plugin', $summary);
+        $this->assertArrayHasKey('default', $summary);
+        $this->assertArrayHasKey('isready', $summary);
+        $this->assertArrayHasKey('requirementsmet', $summary);
+        $this->assertArrayHasKey('mappings', $summary);
+        $this->assertArrayHasKey('modes', $summary);
+        $this->assertArrayHasKey('supports', $summary);
+        // Check the important/known values
+        $this->assertEquals('summariesstore', $summary['name']);
+        $this->assertEquals('file', $summary['plugin']);
+        $this->assertEquals(0, $summary['default']);
+        $this->assertEquals(1, $summary['isready']);
+        $this->assertEquals(1, $summary['requirementsmet']);
+        $this->assertEquals(1, $summary['mappings']);
+
+        $definitionsummaries = cache_administration_helper::get_definition_summaries();
+        $this->assertInternalType('array', $definitionsummaries);
+        $this->assertArrayHasKey('core/eventinvalidation', $definitionsummaries);
+        $summary = $definitionsummaries['core/eventinvalidation'];
+        // Check the keys
+        $this->assertArrayHasKey('id', $summary);
+        $this->assertArrayHasKey('name', $summary);
+        $this->assertArrayHasKey('mode', $summary);
+        $this->assertArrayHasKey('component', $summary);
+        $this->assertArrayHasKey('area', $summary);
+        $this->assertArrayHasKey('mappings', $summary);
+        // Check the important/known values
+        $this->assertEquals('core/eventinvalidation', $summary['id']);
+        $this->assertInstanceOf('lang_string', $summary['name']);
+        $this->assertEquals(cache_store::MODE_APPLICATION, $summary['mode']);
+        $this->assertEquals('core', $summary['component']);
+        $this->assertEquals('eventinvalidation', $summary['area']);
+        $this->assertInternalType('array', $summary['mappings']);
+        $this->assertContains('summariesstore', $summary['mappings']);
+
+        $pluginsummaries = cache_administration_helper::get_store_plugin_summaries();
+        $this->assertInternalType('array', $pluginsummaries);
+        $this->assertArrayHasKey('file', $pluginsummaries);
+        $summary = $pluginsummaries['file'];
+        // Check the keys
+        $this->assertArrayHasKey('name', $summary);
+        $this->assertArrayHasKey('requirementsmet', $summary);
+        $this->assertArrayHasKey('instances', $summary);
+        $this->assertArrayHasKey('modes', $summary);
+        $this->assertArrayHasKey('supports', $summary);
+        $this->assertArrayHasKey('canaddinstance', $summary);
+
+        $locksummaries = cache_administration_helper::get_lock_summaries();
+        $this->assertInternalType('array', $locksummaries);
+        $this->assertTrue(count($locksummaries) > 0);
+
+        $mappings = cache_administration_helper::get_default_mode_stores();
+        $this->assertInternalType('array', $mappings);
+        $this->assertCount(3, $mappings);
+        $this->assertArrayHasKey(cache_store::MODE_APPLICATION, $mappings);
+        $this->assertInternalType('array', $mappings[cache_store::MODE_APPLICATION]);
+        $this->assertContains('summariesstore', $mappings[cache_store::MODE_APPLICATION]);
+
+        $potentials = cache_administration_helper::get_definition_store_options('core', 'eventinvalidation');
+        $this->assertInternalType('array', $potentials); // Currently used, suitable, default
+        $this->assertCount(3, $potentials);
+        $this->assertArrayHasKey('summariesstore', $potentials[0]);
+        $this->assertArrayHasKey('summariesstore', $potentials[1]);
+        $this->assertArrayHasKey('default_application', $potentials[1]);
+    }
+
+    /**
+     * Test instantiating an add store form.
+     */
+    public function test_get_add_store_form() {
+        $form = cache_administration_helper::get_add_store_form('file');
+        $this->assertInstanceOf('moodleform', $form);
+
+        try {
+            $form = cache_administration_helper::get_add_store_form('somethingstupid');
+            $this->fail('You should not be able to create an add form for a store plugin that does not exist.');
+        } catch (moodle_exception $e) {
+            $this->assertInstanceOf('coding_exception', $e, 'Needs to be: ' .get_class($e)." ::: ".$e->getMessage());
+        }
+    }
+
+    /**
+     * Test instantiating a form to edit a store instance.
+     */
+    public function test_get_edit_store_form() {
+        $config = cache_config_writer::instance();
+        $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
+
+        $form = cache_administration_helper::get_edit_store_form('file', 'summariesstore');
+        $this->assertInstanceOf('moodleform', $form);
+
+        try {
+            $form = cache_administration_helper::get_edit_store_form('somethingstupid', 'moron');
+            $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
+        } catch (moodle_exception $e) {
+            $this->assertInstanceOf('coding_exception', $e);
+        }
+
+        try {
+            $form = cache_administration_helper::get_edit_store_form('file', 'blisters');
+            $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
+        } catch (moodle_exception $e) {
+            $this->assertInstanceOf('coding_exception', $e);
+        }
+    }
+
+    /**
+     * Test the hash_key functionality.
+     */
+    public function test_hash_key() {
+        global $CFG;
+
+        $currentdebugging = $CFG->debug;
+
+        $CFG->debug = E_ALL;
+
+        // First with simplekeys
+        $instance = cache_config_phpunittest::instance(true);
+        $instance->phpunit_add_definition('phpunit/hashtest', array(
+            'mode' => cache_store::MODE_APPLICATION,
+            'component' => 'phpunit',
+            'area' => 'hashtest',
+            'simplekeys' => true
+        ));
+        $factory = cache_factory::instance();
+        $definition = $factory->create_definition('phpunit', 'hashtest');
+
+        $result = cache_helper::hash_key('test', $definition);
+        $this->assertEquals('test-'.$definition->generate_single_key_prefix(), $result);
+
+        try {
+            cache_helper::hash_key('test/test', $definition);
+            $this->fail('Invalid key was allowed, you should see this.');
+        } catch (coding_exception $e) {
+            $this->assertEquals('test/test', $e->debuginfo);
+        }
+
+        // Second without simple keys
+        $instance->phpunit_add_definition('phpunit/hashtest2', array(
+            'mode' => cache_store::MODE_APPLICATION,
+            'component' => 'phpunit',
+            'area' => 'hashtest2',
+            'simplekeys' => false
+        ));
+        $definition = $factory->create_definition('phpunit', 'hashtest2');
+
+        $result = cache_helper::hash_key('test', $definition);
+        $this->assertEquals(sha1($definition->generate_single_key_prefix().'-test'), $result);
+
+        $result = cache_helper::hash_key('test/test', $definition);
+        $this->assertEquals(sha1($definition->generate_single_key_prefix().'-test/test'), $result);
+
+        $CFG->debug = $currentdebugging;
+    }
+}
index 1388004..e7f4cdc 100644 (file)
@@ -39,7 +39,7 @@ require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php');
  * @copyright  2012 Sam Hemelryk
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class cache_phpunit_tests extends advanced_testcase {
+class core_cache_testcase extends advanced_testcase {
 
     /**
      * Set things back to the default before each test.
similarity index 57%
rename from cache/tests/locallib_test.php
rename to cache/tests/config_writer_test.php
index 56397f2..f49f65e 100644 (file)
@@ -39,7 +39,7 @@ require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php');
  * @copyright  2012 Sam Hemelryk
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class cache_config_writer_phpunit_tests extends advanced_testcase {
+class core_cache_config_writer_testcase extends advanced_testcase {
 
     /**
      * Set things back to the default before each test.
@@ -288,204 +288,3 @@ class cache_config_writer_phpunit_tests extends advanced_testcase {
         }
     }
 }
-
-/**
- * PHPunit tests for the cache API and in particular the cache_administration_helper
- *
- * @copyright  2012 Sam Hemelryk
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class cache_administration_helper_phpunit_tests extends advanced_testcase {
-
-    /**
-     * Set things back to the default before each test.
-     */
-    public function setUp() {
-        parent::setUp();
-        cache_factory::reset();
-        cache_config_phpunittest::create_default_configuration();
-    }
-
-    /**
-     * Final task is to reset the cache system
-     */
-    public static function tearDownAfterClass() {
-        parent::tearDownAfterClass();
-        cache_factory::reset();
-    }
-
-    /**
-     * Test the numerous summaries the helper can produce.
-     */
-    public function test_get_summaries() {
-        // First the preparation.
-        $config = cache_config_writer::instance();
-        $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
-        $config->set_definition_mappings('core/eventinvalidation', array('summariesstore'));
-        $this->assertTrue($config->set_mode_mappings(array(
-            cache_store::MODE_APPLICATION => array('summariesstore'),
-            cache_store::MODE_SESSION => array('default_session'),
-            cache_store::MODE_REQUEST => array('default_request'),
-        )));
-
-        $storesummaries = cache_administration_helper::get_store_instance_summaries();
-        $this->assertInternalType('array', $storesummaries);
-        $this->assertArrayHasKey('summariesstore', $storesummaries);
-        $summary = $storesummaries['summariesstore'];
-        // Check the keys
-        $this->assertArrayHasKey('name', $summary);
-        $this->assertArrayHasKey('plugin', $summary);
-        $this->assertArrayHasKey('default', $summary);
-        $this->assertArrayHasKey('isready', $summary);
-        $this->assertArrayHasKey('requirementsmet', $summary);
-        $this->assertArrayHasKey('mappings', $summary);
-        $this->assertArrayHasKey('modes', $summary);
-        $this->assertArrayHasKey('supports', $summary);
-        // Check the important/known values
-        $this->assertEquals('summariesstore', $summary['name']);
-        $this->assertEquals('file', $summary['plugin']);
-        $this->assertEquals(0, $summary['default']);
-        $this->assertEquals(1, $summary['isready']);
-        $this->assertEquals(1, $summary['requirementsmet']);
-        $this->assertEquals(1, $summary['mappings']);
-
-        $definitionsummaries = cache_administration_helper::get_definition_summaries();
-        $this->assertInternalType('array', $definitionsummaries);
-        $this->assertArrayHasKey('core/eventinvalidation', $definitionsummaries);
-        $summary = $definitionsummaries['core/eventinvalidation'];
-        // Check the keys
-        $this->assertArrayHasKey('id', $summary);
-        $this->assertArrayHasKey('name', $summary);
-        $this->assertArrayHasKey('mode', $summary);
-        $this->assertArrayHasKey('component', $summary);
-        $this->assertArrayHasKey('area', $summary);
-        $this->assertArrayHasKey('mappings', $summary);
-        // Check the important/known values
-        $this->assertEquals('core/eventinvalidation', $summary['id']);
-        $this->assertInstanceOf('lang_string', $summary['name']);
-        $this->assertEquals(cache_store::MODE_APPLICATION, $summary['mode']);
-        $this->assertEquals('core', $summary['component']);
-        $this->assertEquals('eventinvalidation', $summary['area']);
-        $this->assertInternalType('array', $summary['mappings']);
-        $this->assertContains('summariesstore', $summary['mappings']);
-
-        $pluginsummaries = cache_administration_helper::get_store_plugin_summaries();
-        $this->assertInternalType('array', $pluginsummaries);
-        $this->assertArrayHasKey('file', $pluginsummaries);
-        $summary = $pluginsummaries['file'];
-        // Check the keys
-        $this->assertArrayHasKey('name', $summary);
-        $this->assertArrayHasKey('requirementsmet', $summary);
-        $this->assertArrayHasKey('instances', $summary);
-        $this->assertArrayHasKey('modes', $summary);
-        $this->assertArrayHasKey('supports', $summary);
-        $this->assertArrayHasKey('canaddinstance', $summary);
-
-        $locksummaries = cache_administration_helper::get_lock_summaries();
-        $this->assertInternalType('array', $locksummaries);
-        $this->assertTrue(count($locksummaries) > 0);
-
-        $mappings = cache_administration_helper::get_default_mode_stores();
-        $this->assertInternalType('array', $mappings);
-        $this->assertCount(3, $mappings);
-        $this->assertArrayHasKey(cache_store::MODE_APPLICATION, $mappings);
-        $this->assertInternalType('array', $mappings[cache_store::MODE_APPLICATION]);
-        $this->assertContains('summariesstore', $mappings[cache_store::MODE_APPLICATION]);
-
-        $potentials = cache_administration_helper::get_definition_store_options('core', 'eventinvalidation');
-        $this->assertInternalType('array', $potentials); // Currently used, suitable, default
-        $this->assertCount(3, $potentials);
-        $this->assertArrayHasKey('summariesstore', $potentials[0]);
-        $this->assertArrayHasKey('summariesstore', $potentials[1]);
-        $this->assertArrayHasKey('default_application', $potentials[1]);
-    }
-
-    /**
-     * Test instantiating an add store form.
-     */
-    public function test_get_add_store_form() {
-        $form = cache_administration_helper::get_add_store_form('file');
-        $this->assertInstanceOf('moodleform', $form);
-
-        try {
-            $form = cache_administration_helper::get_add_store_form('somethingstupid');
-            $this->fail('You should not be able to create an add form for a store plugin that does not exist.');
-        } catch (moodle_exception $e) {
-            $this->assertInstanceOf('coding_exception', $e, 'Needs to be: ' .get_class($e)." ::: ".$e->getMessage());
-        }
-    }
-
-    /**
-     * Test instantiating a form to edit a store instance.
-     */
-    public function test_get_edit_store_form() {
-        $config = cache_config_writer::instance();
-        $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
-
-        $form = cache_administration_helper::get_edit_store_form('file', 'summariesstore');
-        $this->assertInstanceOf('moodleform', $form);
-
-        try {
-            $form = cache_administration_helper::get_edit_store_form('somethingstupid', 'moron');
-            $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
-        } catch (moodle_exception $e) {
-            $this->assertInstanceOf('coding_exception', $e);
-        }
-
-        try {
-            $form = cache_administration_helper::get_edit_store_form('file', 'blisters');
-            $this->fail('You should not be able to create an edit form for a store plugin that does not exist.');
-        } catch (moodle_exception $e) {
-            $this->assertInstanceOf('coding_exception', $e);
-        }
-    }
-
-    /**
-     * Test the hash_key functionality.
-     */
-    public function test_hash_key() {
-        global $CFG;
-
-        $currentdebugging = $CFG->debug;
-
-        $CFG->debug = E_ALL;
-
-        // First with simplekeys
-        $instance = cache_config_phpunittest::instance(true);
-        $instance->phpunit_add_definition('phpunit/hashtest', array(
-            'mode' => cache_store::MODE_APPLICATION,
-            'component' => 'phpunit',
-            'area' => 'hashtest',
-            'simplekeys' => true
-        ));
-        $factory = cache_factory::instance();
-        $definition = $factory->create_definition('phpunit', 'hashtest');
-
-        $result = cache_helper::hash_key('test', $definition);
-        $this->assertEquals('test-'.$definition->generate_single_key_prefix(), $result);
-
-        try {
-            cache_helper::hash_key('test/test', $definition);
-            $this->fail('Invalid key was allowed, you should see this.');
-        } catch (coding_exception $e) {
-            $this->assertEquals('test/test', $e->debuginfo);
-        }
-
-        // Second without simple keys
-        $instance->phpunit_add_definition('phpunit/hashtest2', array(
-            'mode' => cache_store::MODE_APPLICATION,
-            'component' => 'phpunit',
-            'area' => 'hashtest2',
-            'simplekeys' => false
-        ));
-        $definition = $factory->create_definition('phpunit', 'hashtest2');
-
-        $result = cache_helper::hash_key('test', $definition);
-        $this->assertEquals(sha1($definition->generate_single_key_prefix().'-test'), $result);
-
-        $result = cache_helper::hash_key('test/test', $definition);
-        $this->assertEquals(sha1($definition->generate_single_key_prefix().'-test/test'), $result);
-
-        $CFG->debug = $currentdebugging;
-    }
-}
index e38538e..44bb9e7 100644 (file)
@@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php');
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since Moodle 2.5
  */
-class core_calendar_external_testcase extends externallib_advanced_testcase {
+class core_calendar_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Tests set up
index db0b2f0..e6446e7 100644 (file)
@@ -37,7 +37,7 @@ require_once("$CFG->dirroot/cohort/lib.php");
  * @copyright  2012 Petr Skoda {@link http://skodak.org}
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class cohort_testcase extends advanced_testcase {
+class core_cohort_cohortlib_testcase extends advanced_testcase {
 
     public function test_cohort_add_cohort() {
         global $DB;
index c8137fb..8f7f4ba 100644 (file)
@@ -30,7 +30,7 @@ global $CFG;
 require_once($CFG->dirroot . '/webservice/tests/helpers.php');
 require_once($CFG->dirroot . '/cohort/externallib.php');
 
-class core_cohort_external_testcase extends externallib_advanced_testcase {
+class core_cohort_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Test create_cohorts
index 544d82f..d1cf768 100644 (file)
@@ -59,11 +59,6 @@ M.core_comment = {
                     }, this);
                 }
                 scope.toggle_textarea(false);
-                CommentHelper.confirmoverlay = new Y.Overlay({
-bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-'+this.client_id+'">'+M.str.moodle.yes+'</a> <a href="#" id="canceldelete-'+this.client_id+'">'+M.str.moodle.no+'</a></div>',
-                                        visible: false
-                                        });
-                CommentHelper.confirmoverlay.render(document.body);
             },
             post: function() {
                 var ta = Y.one('#dlg-content-'+this.client_id);
@@ -238,7 +233,6 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
             dodelete: function(id) { // note: delete is a reserved word in javascript, chrome and safary do not like it at all here!
                 var scope = this;
                 var params = {'commentid': id};
-                scope.cancel_delete();
                 function remove_dom(type, anim, cmt) {
                     cmt.remove();
                 }
@@ -294,37 +288,23 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
                         if (commentid[1]) {
                             Y.Event.purgeElement('#'+theid, false, 'click');
                         }
-                        node.on('click', function(e, node) {
+                        node.on('click', function(e) {
                             e.preventDefault();
-                            var width = CommentHelper.confirmoverlay.bodyNode.getStyle('width');
-                            var re = new RegExp("(\\d+).*", "i");
-                            var result = width.match(re);
-                            if (result[1]) {
-                                width = Number(result[1]);
-                            } else {
-                                width = 0;
+                            if (commentid[1]) {
+                                scope.dodelete(commentid[1]);
                             }
-                            //CommentHelper.confirmoverlay.set('xy', [e.pageX-(width/2), e.pageY]);
-                            CommentHelper.confirmoverlay.set('xy', [e.pageX-width-5, e.pageY]);
-                            CommentHelper.confirmoverlay.set('visible', true);
-                            Y.one('#canceldelete-'+scope.client_id).on('click', function(e) {
-                                e.preventDefault();
-                                scope.cancel_delete();
-                                });
-                            Y.Event.purgeElement('#confirmdelete-'+scope.client_id, false, 'click');
-                            Y.one('#confirmdelete-'+scope.client_id).on('click', function(e) {
-                                e.preventDefault();
-                                if (commentid[1]) {
-                                    scope.dodelete(commentid[1]);
-                                }
-                            });
-                        }, scope, node);
+                        });
+                        // Also handle space/enter key.
+                        node.on('key', function(e) {
+                            e.preventDefault();
+                            if (commentid[1]) {
+                                scope.dodelete(commentid[1]);
+                            }
+                        }, '13,32');
+                        // 13 and 32 are the keycodes for space and enter.
                     }
                 );
             },
-            cancel_delete: function() {
-                CommentHelper.confirmoverlay.set('visible', false);
-            },
             register_pagination: function() {
                 var scope = this;
                 // page buttons
@@ -374,7 +354,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
                 if (ta) {
                     //toggle_textarea.apply(ta, [false]);
                     //// reset textarea size
-                    ta.on('click', function() {
+                    ta.on('focus', function() {
                         this.toggle_textarea(true);
                     }, this);
                     //ta.onkeypress = function() {
index 2022649..8c3b733 100644 (file)
@@ -365,25 +365,6 @@ $CFG->admin = 'admin';
 // Locking resolves race conditions and is strongly recommended for production servers.
 //     $CFG->preventfilelocking = false;
 //
-// If $CFG->langstringcache is enabled (which should always be in production
-// environment), Moodle keeps aggregated strings in its own internal format
-// optimised for performance. By default, this on-disk cache is created in
-// $CFG->cachedir/lang. In cluster environment, you may wish to specify
-// an alternative location of this cache so that each web server in the cluster
-// uses its own local cache and does not need to access the shared dataroot.
-// Make sure that the web server process has write permission to this location
-// and that it has permission to remove the folder, too (so that the cache can
-// be pruned).
-//
-//     $CFG->langcacheroot = '/var/www/moodle/htdocs/altcache/lang';
-//
-// If $CFG->langcache is enabled (which should always be in production
-// environment), Moodle stores the list of available languages in a cache file.
-// By default, the file $CFG->dataroot/languages is used. You may wish to
-// specify an alternative location of this cache file.
-//
-//     $CFG->langmenucachefile = '/var/www/moodle/htdocs/altcache/languages';
-//
 // Site default language can be set via standard administration interface. If you
 // want to have initial error messages for eventual database connection problems
 // localized too, you have to set your language code here.
@@ -488,7 +469,7 @@ $CFG->admin = 'admin';
 // Prevent JS caching
 // $CFG->jsrev = -1; // NOT FOR PRODUCTION SERVERS!
 //
-// Prevent core_string_manager on-disk cache
+// Prevent core_string_manager application caching
 // $CFG->langstringcache = false; // NOT FOR PRODUCTION SERVERS!
 //
 // When working with production data on test servers, no emails or other messages
index fee7ec0..917d670 100644 (file)
@@ -588,9 +588,9 @@ class dndupload_ajax_processor {
      * @return string the display name to use
      */
     protected function display_name_from_file($filename) {
-        $pos = textlib::strrpos($filename, '.');
+        $pos = core_text::strrpos($filename, '.');
         if ($pos) { // Want to skip if $pos === 0 OR $pos === false.
-            $filename = textlib::substr($filename, 0, $pos);
+            $filename = core_text::substr($filename, 0, $pos);
         }
         return str_replace('_', ' ', $filename);
     }
index c484953..f29a06e 100644 (file)
@@ -6,6 +6,9 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
 
 * core_course_renderer::course_section_cm_edit_actions has two new optional arguments and now uses and action_menu component.
 * core_course_renderer::course_section_cm has been altered to call core_course_renderer::course_section_cm_edit_actions with the two new arguments
+* An additional course renderer function has been created which allows you to
+  specify the wrapper for a course module within a section (e.g. the <li>).  This can be
+  found in core_course_renderer::course_section_cm_list_item().
 
 === 2.5 ===
 
index 670e6d2..9ab44a3 100644 (file)
@@ -405,7 +405,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
 
         // If $log->url has been trimmed short by the db size restriction
         // code in add_to_log, keep a note so we don't add a link to a broken url
-        $brokenurl=(textlib::strlen($log->url)==100 && textlib::substr($log->url,97)=='...');
+        $brokenurl=(core_text::strlen($log->url)==100 && core_text::substr($log->url,97)=='...');
 
         $row = array();
         if ($course->id == SITEID) {
@@ -1039,8 +1039,8 @@ function get_module_types_names($plural = false) {
                     $modnames[1][$mod->name] = get_string("modulenameplural", "$mod->name");
                 }
             }
-            collatorlib::asort($modnames[0]);
-            collatorlib::asort($modnames[1]);
+            core_collator::asort($modnames[0]);
+            core_collator::asort($modnames[1]);
         }
     }
     return $modnames[(int)$plural];
@@ -1966,11 +1966,11 @@ function course_format_name ($course,$max=100) {
     $shortname = format_string($course->shortname, true, array('context' => $context));
     $fullname = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
     $str = $shortname.': '. $fullname;
-    if (textlib::strlen($str) <= $max) {
+    if (core_text::strlen($str) <= $max) {
         return $str;
     }
     else {
-        return textlib::substr($str,0,$max-3).'...';
+        return core_text::substr($str,0,$max-3).'...';
     }
 }
 
@@ -2965,6 +2965,9 @@ function include_course_ajax($course, $usedmodules = array(), $enabledmodules =
             'markedthistopic',
             'move',
             'movesection',
+            'movecontent',
+            'aftercontent',
+            'emptydragdropregion'
         ), 'moodle');
 
     // Include format-specific strings
index df8c5f4..d4a9054 100644 (file)
@@ -194,7 +194,7 @@ if ((!empty($moveupcat) or !empty($movedowncat)) and confirm_sesskey()) {
 if ($coursecat->id && $canmanage && $resort && confirm_sesskey()) {
     // Resort the category.
     if ($courses = get_courses($coursecat->id, '', 'c.id,c.fullname,c.sortorder')) {
-        collatorlib::asort_objects_by_property($courses, 'fullname', collatorlib::SORT_NATURAL);
+        core_collator::asort_objects_by_property($courses, 'fullname', core_collator::SORT_NATURAL);
         $i = 1;
         foreach ($courses as $course) {
             $DB->set_field('course', 'sortorder', $coursecat->sortorder + $i, array('id' => $course->id));
index ceb6b10..898c5ac 100644 (file)
@@ -248,7 +248,7 @@ class course_publication_form extends moodleform {
         $mform->addHelpButton('description', 'description', 'hub');
 
         $languages = get_string_manager()->get_list_of_languages();
-        collatorlib::asort($languages);
+        core_collator::asort($languages);
         $mform->addElement('select', 'language', get_string('language'), $languages);
         $mform->setDefault('language', $defaultlanguage);
         $mform->addHelpButton('language', 'language', 'hub');
index 1d4549b..8096fd6 100644 (file)
@@ -708,8 +708,8 @@ class core_course_renderer extends plugin_renderer_base {
         // Avoid unnecessary duplication: if e.g. a forum name already
         // includes the word forum (or Forum, etc) then it is unhelpful
         // to include that in the accessible description that is added.
-        if (false !== strpos(textlib::strtolower($instancename),
-                textlib::strtolower($altname))) {
+        if (false !== strpos(core_text::strtolower($instancename),
+                core_text::strtolower($altname))) {
             $altname = '';
         }
         // File type after name, for alphabetic lists (screen reader).
@@ -785,11 +785,20 @@ class core_course_renderer extends plugin_renderer_base {
             return $output;
         }
         $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
-        $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
-        $accessiblebutdim = !$mod->visible || $conditionalhidden;
+        if ($this->page->user_is_editing()) {
+            // In editing mode, when an item is conditionally hidden from some users
+            // we show it as greyed out.
+            $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
+            $dim = !$mod->visible || $conditionalhidden;
+        } else {
+            // When not in editing mode, we only show item as hidden if it is
+            // actually not available to the user
+            $conditionalhidden = false;
+            $dim = !$mod->uservisible;
+        }
         $textclasses = '';
         $accesstext = '';
-        if ($accessiblebutdim) {
+        if ($dim) {
             $textclasses .= ' dimmed_text';
             if ($conditionalhidden) {
                 $textclasses .= ' conditionalhidden';
@@ -854,6 +863,28 @@ class core_course_renderer extends plugin_renderer_base {
         return '';
     }
 
+    /**
+     * Renders HTML to display one course module for display within a section.
+     *
+     * This function calls:
+     * {@link core_course_renderer::course_section_cm()}
+     *
+     * @param stdClass $course
+     * @param completion_info $completioninfo
+     * @param cm_info $mod
+     * @param int|null $sectionreturn
+     * @param array $displayoptions
+     * @return String
+     */
+    public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
+        $output = '';
+        if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
+            $modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->get_extra_classes();
+            $output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
+        }
+        return $output;
+    }
+
     /**
      * Renders HTML to display one course module in a course section
      *
@@ -990,40 +1021,35 @@ class core_course_renderer extends plugin_renderer_base {
                     continue;
                 }
 
-                if ($modulehtml = $this->course_section_cm($course,
+                if ($modulehtml = $this->course_section_cm_list_item($course,
                         $completioninfo, $mod, $sectionreturn, $displayoptions)) {
                     $moduleshtml[$modnumber] = $modulehtml;
                 }
             }
         }
 
+        $sectionoutput = '';
         if (!empty($moduleshtml) || $ismoving) {
-
-            $output .= html_writer::start_tag('ul', array('class' => 'section img-text'));
-
             foreach ($moduleshtml as $modnumber => $modulehtml) {
                 if ($ismoving) {
                     $movingurl = new moodle_url('/course/mod.php', array('moveto' => $modnumber, 'sesskey' => sesskey()));
-                    $output .= html_writer::tag('li', html_writer::link($movingurl, $this->output->render($movingpix)),
+                    $sectionoutput .= html_writer::tag('li', html_writer::link($movingurl, $this->output->render($movingpix)),
                             array('class' => 'movehere', 'title' => $strmovefull));
                 }
 
-                $mod = $modinfo->cms[$modnumber];
-                $modclasses = 'activity '. $mod->modname. ' modtype_'.$mod->modname. ' '. $mod->get_extra_classes();
-                $output .= html_writer::start_tag('li', array('class' => $modclasses, 'id' => 'module-'. $mod->id));
-                $output .= $modulehtml;
-                $output .= html_writer::end_tag('li');
+                $sectionoutput .= $modulehtml;
             }
 
             if ($ismoving) {
                 $movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey()));
-                $output .= html_writer::tag('li', html_writer::link($movingurl, $this->output->render($movingpix)),
+                $sectionoutput .= html_writer::tag('li', html_writer::link($movingurl, $this->output->render($movingpix)),
                         array('class' => 'movehere', 'title' => $strmovefull));
             }
-
-            $output .= html_writer::end_tag('ul'); // .section
         }
 
+        // Always output the section module list.
+        $output .= html_writer::tag('ul', $sectionoutput, array('class' => 'section img-text'));
+
         return $output;
     }
 
index 50d191c..55db3b2 100644 (file)
@@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die();
 global $CFG;
 require_once($CFG->dirroot.'/course/lib.php');
 
-class courselib_testcase extends advanced_testcase {
+class core_course_courselib_testcase extends advanced_testcase {
 
     /**
      * Set forum specific test values for calling create_module().
index d376772..0b23a4e 100644 (file)
@@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die();
 global $CFG;
 require_once($CFG->dirroot.'/course/lib.php');
 
-class courserequest_testcase extends advanced_testcase {
+class core_course_courserequest_testcase extends advanced_testcase {
 
     public function test_create_request() {
         global $DB, $USER;
index ab0a67e..8693632 100644 (file)
@@ -37,7 +37,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php');
  * @copyright  2012 Jerome Mouneyrac
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class core_course_external_testcase extends externallib_advanced_testcase {
+class core_course_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Tests set up
index 0145f0f..fc5f88d 100644 (file)
@@ -295,6 +295,7 @@ YUI.add('moodle-course-dragdrop', function(Y) {
                     resources.addClass(CSS.SECTION);
                     sectionnode.one('.'+CSS.CONTENT+' div.'+CSS.SUMMARY).insert(resources, 'after');
                 }
+                resources.setAttribute('data-draggroups', this.groups.join(' '));
                 // Define empty ul as droptarget, so that item could be moved to empty list
                 var tar = new Y.DD.Drop({
                     node: resources,
index fc57b58..052458a 100644 (file)
@@ -855,7 +855,7 @@ class enrol_database_plugin extends enrol_plugin {
             }
             return $text;
         } else {
-            return textlib::convert($text, 'utf-8', $dbenc);
+            return core_text::convert($text, 'utf-8', $dbenc);
         }
     }
 
@@ -870,7 +870,7 @@ class enrol_database_plugin extends enrol_plugin {
             }
             return $text;
         } else {
-            return textlib::convert($text, $dbenc, 'utf-8');
+            return core_text::convert($text, $dbenc, 'utf-8');
         }
     }
 
index 582828e..ddfb976 100644 (file)
@@ -561,6 +561,64 @@ class core_enrol_external extends external_api {
         );
     }
 
+    /**
+     * Returns description of get_course_enrolment_methods() parameters
+     *
+     * @return external_function_parameters
+     */
+    public static function get_course_enrolment_methods_parameters() {
+        return new external_function_parameters(
+            array(
+                'courseid' => new external_value(PARAM_INT, 'Course id')
+            )
+        );
+    }
+
+    /**
+     * Get list of active course enrolment methods for current user.
+     *
+     * @param int $courseid
+     * @return array of course enrolment methods
+     */
+    public static function get_course_enrolment_methods($courseid) {
+
+        $params = self::validate_parameters(self::get_course_enrolment_methods_parameters(), array('courseid' => $courseid));
+
+        $coursecontext = context_course::instance($params['courseid']);
+        $categorycontext = $coursecontext->get_parent_context();
+        self::validate_context($categorycontext);
+
+        $result = array();
+        $enrolinstances = enrol_get_instances($params['courseid'], true);
+        foreach ($enrolinstances as $enrolinstance) {
+            if ($enrolplugin = enrol_get_plugin($enrolinstance->enrol)) {
+                if ($instanceinfo = $enrolplugin->get_enrol_info($enrolinstance)) {
+                    $result[] = (array) $instanceinfo;
+                }
+            }
+        }
+        return $result;
+    }
+
+    /**
+     * Returns description of get_course_enrolment_methods() result value
+     *
+     * @return external_description
+     */
+    public static function get_course_enrolment_methods_returns() {
+        return new external_multiple_structure(
+            new external_single_structure(
+                array(
+                    'id' => new external_value(PARAM_INT, 'id of course enrolment instance'),
+                    'courseid' => new external_value(PARAM_INT, 'id of course'),
+                    'type' => new external_value(PARAM_PLUGIN, 'type of enrolment plugin'),
+                    'name' => new external_value(PARAM_RAW, 'name of enrolment plugin'),
+                    'status' => new external_value(PARAM_RAW, 'status of enrolment plugin'),
+                    'wsfunction' => new external_value(PARAM_ALPHANUMEXT, 'webservice function to get more information', VALUE_OPTIONAL),
+                )
+            )
+        );
+    }
 }
 
 /**
index f3a0908..4add14e 100644 (file)
@@ -252,7 +252,7 @@ class enrol_flatfile_plugin extends enrol_plugin {
 
             $rolemap = $this->get_role_map($trace);
 
-            $content = textlib::convert($content, $this->get_config('encoding', 'utf-8'), 'utf-8');
+            $content = core_text::convert($content, $this->get_config('encoding', 'utf-8'), 'utf-8');
             $content = str_replace("\r", '', $content);
             $content = explode("\n", $content);
 
@@ -278,8 +278,8 @@ class enrol_flatfile_plugin extends enrol_plugin {
                     continue;
                 }
 
-                $fields[0] = trim(textlib::strtolower($fields[0]));
-                $fields[1] = trim(textlib::strtolower($fields[1]));
+                $fields[0] = trim(core_text::strtolower($fields[0]));
+                $fields[1] = trim(core_text::strtolower($fields[1]));
                 $fields[2] = trim($fields[2]);
                 $fields[3] = trim($fields[3]);
                 $fields[4] = isset($fields[4]) ? (int)trim($fields[4]) : 0;
@@ -664,7 +664,7 @@ class enrol_flatfile_plugin extends enrol_plugin {
         $roles = $DB->get_records('role', null, '', 'id, name, shortname');
         foreach ($roles as $id=>$role) {
             $alias = $this->get_config('map_'.$id, $role->shortname, '');
-            $alias = trim(textlib::strtolower($alias));
+            $alias = trim(core_text::strtolower($alias));
             if ($alias === '') {
                 // Either not configured yet or somebody wants to skip these intentionally.
                 continue;
index 379568e..5b7d345 100644 (file)
@@ -34,7 +34,7 @@ if ($ADMIN->fulltree) {
 
     $settings->add(new admin_setting_configfile('enrol_flatfile/location', get_string('location', 'enrol_flatfile'), get_string('location_desc', 'enrol_flatfile'), ''));
 
-    $options = textlib::get_encodings();
+    $options = core_text::get_encodings();
     $settings->add(new admin_setting_configselect('enrol_flatfile/encoding', get_string('encoding', 'enrol_flatfile'), '', 'UTF-8', $options));
 
     $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailstudents', get_string('notifyenrolled', 'enrol_flatfile'), '', 0));
index 976d109..93ed0ef 100644 (file)
@@ -167,7 +167,7 @@ class enrol_flatfile_testcase extends advanced_testcase {
         // Test encoding.
 
         $data = "add;student;čtvrtý;c3";
-        $data = textlib::convert($data, 'utf-8', 'iso-8859-2');
+        $data = core_text::convert($data, 'utf-8', 'iso-8859-2');
         file_put_contents($file, $data);
         $flatfileplugin->set_config('encoding', 'iso-8859-2');
 
index 14e13a9..2fecf89 100644 (file)
@@ -61,7 +61,7 @@ class enrol_guest_enrol_form extends moodleform {
             if ($data['guestpassword'] !== $instance->password) {
                 $plugin = enrol_get_plugin('guest');
                 if ($plugin->get_config('showhint')) {
-                    $hint = textlib::substr($instance->password, 0, 1);
+                    $hint = core_text::substr($instance->password, 0, 1);
                     $errors['guestpassword'] = get_string('passwordinvalidhint', 'enrol_guest', $hint);
                 } else {
                     $errors['guestpassword'] = get_string('passwordinvalid', 'enrol_guest');
index a4448c7..9ebacb8 100644 (file)
@@ -327,7 +327,7 @@ class enrol_ldap_plugin extends enrol_plugin {
                 $trace->finished();
                 return;
             }
-            $oneidnumber = ldap_filter_addslashes(textlib::convert($course->idnumber, 'utf-8', $this->get_config('ldapencoding')));
+            $oneidnumber = ldap_filter_addslashes(core_text::convert($course->idnumber, 'utf-8', $this->get_config('ldapencoding')));
         }
 
         // Get enrolments for each type of role.
@@ -689,7 +689,7 @@ class enrol_ldap_plugin extends enrol_plugin {
             return array();
         }
 
-        $extmemberuid = textlib::convert($memberuid, 'utf-8', $this->get_config('ldapencoding'));
+        $extmemberuid = core_text::convert($memberuid, 'utf-8', $this->get_config('ldapencoding'));
 
         if($this->get_config('memberattribute_isdn')) {
             if (!($extmemberuid = $this->ldap_find_userdn($extmemberuid))) {
index c090c2c..7b943ab 100644 (file)
@@ -63,7 +63,7 @@ class admin_setting_configtext_trim_lower extends admin_setting_configtext {
             return $validated;
         }
         if ($this->lowercase) {
-            $data = textlib::strtolower($data);
+            $data = core_text::strtolower($data);
         }
         if (!$this->enabled) {
             return '';
@@ -134,7 +134,7 @@ class admin_setting_ldap_rolemapping extends admin_setting {
             if (!$this->config_write('contexts_role'.$roleid, trim($data['contexts']))) {
                 $return = get_string('errorsetting', 'admin');
             }
-            if (!$this->config_write('memberattribute_role'.$roleid, textlib::strtolower(trim($data['memberattribute'])))) {
+            if (!$this->config_write('memberattribute_role'.$roleid, core_text::strtolower(trim($data['memberattribute'])))) {
                 $return = get_string('errorsetting', 'admin');
             }
         }
index 29f6eeb..1746697 100644 (file)
@@ -960,7 +960,7 @@ class course_enrolment_manager {
                     if (strpos($userrole->component, 'enrol_') === 0) {
                         $plugin = substr($userrole->component, 6);
                         if (isset($plugins[$plugin])) {
-                            $changeable = !$plugin[$plugin]->roles_protected();
+                            $changeable = !$plugins[$plugin]->roles_protected();
                         }
                     }
                 }
index 4a09dc5..32c67ca 100644 (file)
@@ -171,7 +171,7 @@ if (strlen($result) > 0) {
 
         }
 
-        if (textlib::strtolower($data->business) !== textlib::strtolower($plugin->get_config('paypalbusiness'))) {   // Check that the email is the one we want it to be
+        if (core_text::strtolower($data->business) !== core_text::strtolower($plugin->get_config('paypalbusiness'))) {   // Check that the email is the one we want it to be
             message_paypal_error_to_admin("Business email is {$data->business} (not ".
                     $plugin->get_config('paypalbusiness').")", $data);
             die;
diff --git a/enrol/self/db/services.php b/enrol/self/db/services.php
new file mode 100644 (file)
index 0000000..dd50355
--- /dev/null
@@ -0,0 +1,34 @@
+<?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/>.
+
+/**
+ * Self enrol plugin external functions and service definitions.
+ *
+ * @package   enrol_self
+ * @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.6
+ */
+
+$functions = array(
+    'enrol_self_get_instance_info' => array(
+        'classname'   => 'enrol_self_external',
+        'methodname'  => 'get_instance_info',
+        'classpath'   => 'enrol/self/externallib.php',
+        'description' => 'self enrolment instance information.',
+        'type'        => 'read'
+    )
+);
diff --git a/enrol/self/externallib.php b/enrol/self/externallib.php
new file mode 100644 (file)
index 0000000..4451087
--- /dev/null
@@ -0,0 +1,100 @@
+<?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/>.
+
+/**
+ * Self enrol plugin external functions
+ *
+ * @package    enrol_self
+ * @copyright  2013 Rajesh Taneja <rajesh@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once("$CFG->libdir/externallib.php");
+
+/**
+ * Self enrolment external functions.
+ *
+ * @package   enrol_self
+ * @copyright 2012 Rajesh Taneja <rajesh@moodle.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.6
+ */
+class enrol_self_external extends external_api {
+
+    /**
+     * Returns description of get_instance_info() parameters.
+     *
+     * @return external_function_parameters
+     */
+    public static function get_instance_info_parameters() {
+        return new external_function_parameters(
+                array('instanceid' => new external_value(PARAM_INT, 'instance id of self enrolment plugin.'))
+            );
+    }
+
+    /**
+     * Return self-enrolment instance information.
+     *
+     * @param int $instanceid instance id of self enrolment plugin.
+     * @return array instance information.
+     */
+    public static function get_instance_info($instanceid) {
+        global $DB, $CFG;
+
+        require_once($CFG->libdir . '/enrollib.php');
+
+        $params = self::validate_parameters(self::get_instance_info_parameters(), array('instanceid' => $instanceid));
+
+        // Retrieve self enrolment plugin.
+        $enrolplugin = enrol_get_plugin('self');
+        if (empty($enrolplugin)) {
+            throw new moodle_exception('invaliddata', 'error');
+        }
+
+        $enrolinstance = $DB->get_record('enrol', array('id' => $params['instanceid']), '*', MUST_EXIST);
+        $coursecontext = context_course::instance($enrolinstance->courseid);
+        $categorycontext = $coursecontext->get_parent_context();
+        self::validate_context($categorycontext);
+
+        $instanceinfo = (array) $enrolplugin->get_enrol_info($enrolinstance);
+        if (isset($instanceinfo['requiredparam']->enrolpassword)) {
+            $instanceinfo['enrolpassword'] = $instanceinfo['requiredparam']->enrolpassword;
+        }
+        unset($instanceinfo->requiredparam);
+
+        return $instanceinfo;
+    }
+
+    /**
+     * Returns description of get_instance_info() result value.
+     *
+     * @return external_description
+     */
+    public static function get_instance_info_returns() {
+        return new external_single_structure(
+            array(
+                'id' => new external_value(PARAM_INT, 'id of course enrolment instance'),
+                'courseid' => new external_value(PARAM_INT, 'id of course'),
+                'type' => new external_value(PARAM_PLUGIN, 'type of enrolment plugin'),
+                'name' => new external_value(PARAM_RAW, 'name of enrolment plugin'),
+                'status' => new external_value(PARAM_RAW, 'status of enrolment plugin'),
+                'enrolpassword' => new external_value(PARAM_RAW, 'password required for enrolment', VALUE_OPTIONAL),
+            )
+        );
+    }
+}
index 86a8899..9b0fa48 100644 (file)
@@ -335,6 +335,10 @@ class enrol_self_plugin extends enrol_plugin {
             $instanceinfo->requiredparam->enrolpassword = get_string('password', 'enrol_self');
         }
 
+        // If enrolment is possible and password is required then return ws function name to get more information.
+        if ((true === $instanceinfo->status) && $instance->password) {
+            $instanceinfo->wsfunction = 'enrol_self_get_instance_info';
+        }
         return $instanceinfo;
     }
 
index 7d6a917..cd010eb 100644 (file)
@@ -101,7 +101,7 @@ class enrol_self_enrol_form extends moodleform {
                 } else {
                     $plugin = enrol_get_plugin('self');
                     if ($plugin->get_config('showhint')) {
-                        $hint = textlib::substr($instance->password, 0, 1);
+                        $hint = core_text::substr($instance->password, 0, 1);
                         $errors['enrolpassword'] = get_string('passwordinvalidhint', 'enrol_self', $hint);
                     } else {
                         $errors['enrolpassword'] = get_string('passwordinvalid', 'enrol_self');
diff --git a/enrol/self/tests/externallib_test.php b/enrol/self/tests/externallib_test.php
new file mode 100644 (file)
index 0000000..343af57
--- /dev/null
@@ -0,0 +1,96 @@
+<?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/>.
+
+/**
+ * Self enrol external PHPunit tests
+ *
+ * @package   enrol_self
+ * @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.6
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+
+require_once($CFG->dirroot . '/webservice/tests/helpers.php');
+require_once($CFG->dirroot . '/enrol/self/externallib.php');
+
+class enrol_self_external_testcase extends externallib_advanced_testcase {
+
+    /**
+     * Test get_instance_info
+     */
+    public function test_get_instance_info() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Check if self enrolment plugin is enabled.
+        $selfplugin = enrol_get_plugin('self');
+        $this->assertNotEmpty($selfplugin);
+
+        $studentrole = $DB->get_record('role', array('shortname'=>'student'));
+        $this->assertNotEmpty($studentrole);
+
+        $course = self::getDataGenerator()->create_course();
+
+        // Add enrolment methods for course.
+        $instanceid1 = $selfplugin->add_instance($course, array('status' => ENROL_INSTANCE_ENABLED,
+                                                                'name' => 'Test instance 1',
+                                                                'customint6' => 1,
+                                                                'roleid' => $studentrole->id));
+        $instanceid2 = $selfplugin->add_instance($course, array('status' => ENROL_INSTANCE_DISABLED,
+                                                                'customint6' => 1,
+                                                                'name' => 'Test instance 2',
+                                                                'roleid' => $studentrole->id));
+
+        $instanceid3 = $selfplugin->add_instance($course, array('status' => ENROL_INSTANCE_ENABLED,
+                                                                'roleid' => $studentrole->id,
+                                                                'customint6' => 1,
+                                                                'name' => 'Test instance 3',
+                                                                'password' => 'test'));
+
+        $enrolmentmethods = $DB->get_records('enrol', array('courseid' => $course->id, 'status' => ENROL_INSTANCE_ENABLED));
+        $this->assertCount(3, $enrolmentmethods);
+
+        $instanceinfo1 = enrol_self_external::get_instance_info($instanceid1);
+
+        $this->assertEquals($instanceid1, $instanceinfo1['id']);
+        $this->assertEquals($course->id, $instanceinfo1['courseid']);
+        $this->assertEquals('self', $instanceinfo1['type']);
+        $this->assertEquals('Test instance 1', $instanceinfo1['name']);
+        $this->assertTrue($instanceinfo1['status']);
+        $this->assertFalse(isset($instanceinfo1['enrolpassword']));
+
+        $instanceinfo2 = enrol_self_external::get_instance_info($instanceid2);
+        $this->assertEquals($instanceid2, $instanceinfo2['id']);
+        $this->assertEquals($course->id, $instanceinfo2['courseid']);
+        $this->assertEquals('self', $instanceinfo2['type']);
+        $this->assertEquals('Test instance 2', $instanceinfo2['name']);
+        $this->assertEquals(get_string('canntenrol', 'enrol_self'), $instanceinfo2['status']);
+        $this->assertFalse(isset($instanceinfo2['enrolpassword']));
+
+        $instanceinfo3 = enrol_self_external::get_instance_info($instanceid3);
+        $this->assertEquals($instanceid3, $instanceinfo3['id']);
+        $this->assertEquals($course->id, $instanceinfo3['courseid']);
+        $this->assertEquals('self', $instanceinfo3['type']);
+        $this->assertEquals('Test instance 3', $instanceinfo3['name']);
+        $this->assertTrue($instanceinfo3['status']);
+        $this->assertEquals(get_string('password', 'enrol_self'), $instanceinfo3['enrolpassword']);
+    }
+}
index c0d980e..b186821 100644 (file)
@@ -24,7 +24,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version   = 2013062500;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->version   = 2013071100;        // The current plugin version (Date: YYYYMMDDXX)
 $plugin->requires  = 2013050100;        // Requires this Moodle version
 $plugin->component = 'enrol_self';      // Full name of the plugin (used for diagnostics)
 $plugin->cron      = 600;
index 5505cb2..250fcd8 100644 (file)
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
  * @copyright  2012 Petr Skoda {@link http://skodak.org}
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class core_enrol_testcase extends advanced_testcase {
+class core_enrollib_testcase extends advanced_testcase {
 
     public function test_enrol_get_all_users_courses() {
         global $DB, $CFG;
index c93ebcb..073448e 100644 (file)
@@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/enrol/externallib.php');
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since Moodle 2.4
  */
-class core_enrol_external_testcase extends externallib_advanced_testcase {
+class core_enrol_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Test get_enrolled_users
@@ -155,4 +155,66 @@ class core_enrol_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals(1, count($expecteduserlist['users']));
 
     }
+
+    /**
+     * Test get_course_enrolment_methods
+     */
+    public function test_get_course_enrolment_methods() {
+        global $DB;
+
+        $this->resetAfterTest(true);
+
+        // Get enrolment plugins.
+        $selfplugin = enrol_get_plugin('self');
+        $this->assertNotEmpty($selfplugin);
+        $manualplugin = enrol_get_plugin('manual');
+        $this->assertNotEmpty($manualplugin);
+
+        $studentrole = $DB->get_record('role', array('shortname'=>'student'));
+        $this->assertNotEmpty($studentrole);
+
+        $course1 = self::getDataGenerator()->create_course();
+        $course2 = self::getDataGenerator()->create_course();
+
+        // Add enrolment methods for course.
+        $instanceid1 = $selfplugin->add_instance($course1, array('status' => ENROL_INSTANCE_ENABLED,
+                                                                'name' => 'Test instance 1',
+                                                                'customint6' => 1,
+                                                                'roleid' => $studentrole->id));
+        $instanceid2 = $selfplugin->add_instance($course1, array('status' => ENROL_INSTANCE_DISABLED,
+                                                                'name' => 'Test instance 2',
+                                                                'roleid' => $studentrole->id));
+
+        $instanceid3 = $manualplugin->add_instance($course1, array('status' => ENROL_INSTANCE_ENABLED,
+                                                                'name' => 'Test instance 3'));
+
+        $enrolmentmethods = $DB->get_records('enrol', array('courseid' => $course1->id, 'status' => ENROL_INSTANCE_ENABLED));
+        $this->assertCount(2, $enrolmentmethods);
+
+        // Check if information is returned.
+        $enrolmentmethods = core_enrol_external::get_course_enrolment_methods($course1->id);
+        // Enrolment information is currently returned by self enrolment plugin, so count == 1.
+        // This should be changed as we implement get_enrol_info() for other enrolment plugins.
+        $this->assertCount(1, $enrolmentmethods);
+
+        $enrolmentmethod = $enrolmentmethods[0];
+        $this->assertEquals($course1->id, $enrolmentmethod['courseid']);
+        $this->assertEquals('self', $enrolmentmethod['type']);
+        $this->assertTrue($enrolmentmethod['status']);
+        $this->assertFalse(isset($enrolmentmethod['wsfunction']));
+
+        $instanceid4 = $selfplugin->add_instance($course2, array('status' => ENROL_INSTANCE_ENABLED,
+                                                                'name' => 'Test instance 4',
+                                                                'roleid' => $studentrole->id,
+                                                                'customint6' => 1,
+                                                                'password' => 'test'));
+        $enrolmentmethods = core_enrol_external::get_course_enrolment_methods($course2->id);
+        $this->assertCount(1, $enrolmentmethods);
+
+        $enrolmentmethod = $enrolmentmethods[0];
+        $this->assertEquals($course2->id, $enrolmentmethod['courseid']);
+        $this->assertEquals('self', $enrolmentmethod['type']);
+        $this->assertTrue($enrolmentmethod['status']);
+        $this->assertEquals('enrol_self_get_instance_info', $enrolmentmethod['wsfunction']);
+    }
 }
similarity index 98%
rename from enrol/tests/externallib_role_test.php
rename to enrol/tests/role_external_test.php
index f3b77f0..2a8c4a8 100644 (file)
@@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/enrol/externallib.php');
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since Moodle 2.4
  */
-class core_role_external_testcase extends externallib_advanced_testcase {
+class core_enrol_role_external_testcase extends externallib_advanced_testcase {
 
     /**
      * Tests set up
index f2b0ab6..e086c6e 100644 (file)
@@ -272,11 +272,24 @@ class core_files_external extends external_api {
             $filepath = '/';
         }
 
+        // Only allow uploads to draft or private areas (private is deprecated but still supported)
+        if (!($fileinfo['component'] == 'user' and in_array($fileinfo['filearea'], array('private', 'draft')))) {
+            throw new coding_exception('File can be uploaded to user private or draft areas only');
+        } else {
+            $component = 'user';
+            $filearea = $fileinfo['filearea'];
+        }
+
+        $itemid = 0;
         if (isset($fileinfo['itemid'])) {
+            $itemid = $fileinfo['itemid'];
+        }
+        if ($filearea == 'draft' && $itemid <= 0) {
+            // Generate a draft area for the files.
+            $itemid = file_get_unused_draft_itemid();
+        } else if ($filearea == 'private') {
             // TODO MDL-31116 in user private area, itemid is always 0.
             $itemid = 0;
-        } else {
-            throw new coding_exception('itemid cannot be empty');
         }
 
         // We need to preserve backword compatibility. Context id is no more a required.
@@ -287,13 +300,8 @@ class core_files_external extends external_api {
         // Get and validate context.
         $context = self::get_context_from_params($fileinfo);
         self::validate_context($context);
-
-        if (!($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'private')) {
-            throw new coding_exception('File can be uploaded to user private area only');
-        } else {
-            // TODO MDL-31116 hard-coded to use user_private area.
-            $component = 'user';
-            $filearea = 'private';
+        if (($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'private')) {
+            debugging('Uploading directly to user private files area is deprecated. Upload to a draft area and then move the files with core_user::add_user_private_files');
         }
 
         $browser = get_file_browser();
index 5f9eb61..5d9e479 100644 (file)
@@ -114,7 +114,7 @@ class core_files_renderer extends plugin_renderer_base {
                 array('invalidjson', 'repository'), array('popupblockeddownload', 'repository'),
                 array('unknownoriginal', 'repository'), array('confirmdeletefolder', 'repository'),
                 array('confirmdeletefilewithhref', 'repository'), array('confirmrenamefolder', 'repository'),
-                array('confirmrenamefile', 'repository'), array('newfolder', 'repository')
+                array('confirmrenamefile', 'repository'), array('newfolder', 'repository'), array('edit', 'moodle')
             )
         );
         if (empty($filemanagertemplateloaded)) {
@@ -304,9 +304,9 @@ class core_files_renderer extends plugin_renderer_base {
      */
     private function fm_js_template_mkdir() {
         $rv = '
-<div class="filemanager fp-mkdir-dlg">
+<div class="filemanager fp-mkdir-dlg" role="dialog" aria-live="assertive" aria-labelledby="fp-mkdir-dlg-title">
     <div class="fp-mkdir-dlg-text">
-        <label>' . get_string('newfoldername', 'repository') . '</label><br/>
+        <label id="fp-mkdir-dlg-title">' . get_string('newfoldername', 'repository') . '</label><br/>
         <input type="text" />
     </div>
     <button class="{!}fp-dlg-butcreate">'.get_string('makeafolder').'</button>
@@ -527,7 +527,7 @@ class core_files_renderer extends plugin_renderer_base {
             <li class="{!}fp-repo"><a href="#"><img class="{!}fp-repo-icon" alt="'. get_string('repositoryicon', 'repository') .'" width="16" height="16" />&nbsp;<span class="{!}fp-repo-name"></span></a></li>
         </ul>
     </div>
-    <div class="fp-repo-items">
+    <div class="fp-repo-items" tabindex="0">
         <div class="fp-navbar">
             <div>
                 <div class="{!}fp-toolbar">
@@ -803,8 +803,8 @@ class core_files_renderer extends plugin_renderer_base {
      */
     private function fp_js_template_message() {
         $rv = '
-<div class="file-picker fp-msg">
-    <p class="{!}fp-msg-text"></p>
+<div class="file-picker fp-msg" role="alertdialog" aria-live="assertive" aria-labelledby="fp-msg-labelledby">
+    <p class="{!}fp-msg-text" id="fp-msg-labelledby"></p>
     <button class="{!}fp-msg-butok">'.get_string('ok').'</button>
 </div>';
         return preg_replace('/\{\!\}/', '', $rv);
index ce91c1c..7f6de7d 100644 (file)
@@ -31,7 +31,7 @@ global $CFG;
 require_once($CFG->dirroot . '/webservice/tests/helpers.php');
 require_once($CFG->dirroot . '/files/externallib.php');
 
-class test_external_files extends advanced_testcase {
+class core_files_externallib_testcase extends advanced_testcase {
 
     /*
      * Test core_files_external::upload().
@@ -45,7 +45,7 @@ class test_external_files extends advanced_testcase {
         $context = context_user::instance($USER->id);
         $contextid = $context->id;
         $component = "user";
-        $filearea = "private";
+        $filearea = "draft";
         $itemid = 0;
         $filepath = "/";
         $filename = "Simple.txt";
@@ -59,15 +59,16 @@ class test_external_files extends advanced_testcase {
         $this->assertEmpty($file);
 
         // Call the api to create a file.
-        core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
+        $fileinfo = core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
                 $filename, $filecontent, $contextlevel, $instanceid);
+        // Get the created draft item id.
+        $itemid = $fileinfo['itemid'];
 
         // Make sure the file was created.
         $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
         $this->assertNotEmpty($file);
 
         // Make sure no file exists.
-        $itemid = 2;
         $filename = "Simple2.txt";
         $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
         $this->assertEmpty($file);
@@ -75,12 +76,10 @@ class test_external_files extends advanced_testcase {
         // Call the api to create a file.
         $fileinfo = core_files_external::upload($contextid, $component, $filearea, $itemid,
                 $filepath, $filename, $filecontent, $contextlevel, $instanceid);
-
-        // Make sure itemid is always set to 0.
-        $this->assertEquals(0, $fileinfo['itemid']);
+        $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
+        $this->assertNotEmpty($file);
 
         // Let us try creating a file using contextlevel and instance id.
-        $itemid = 0;
         $filename = "Simple5.txt";
         $contextid = 0;
         $contextlevel = "user";
@@ -89,7 +88,8 @@ class test_external_files extends advanced_testcase {
         $this->assertEmpty($file);
         $fileinfo = core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
                 $filename, $filecontent, $contextlevel, $instanceid);
-        $this->assertEmpty($file);
+        $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
+        $this->assertNotEmpty($file);
 
         // Make sure the same file cannot be created again.
         $this->setExpectedException("moodle_exception");
@@ -123,7 +123,7 @@ class test_external_files extends advanced_testcase {
     }
 
     /*
-     * Make sure only private area is allowed in  core_files_external::upload().
+     * Make sure only private or draft areas are allowed in  core_files_external::upload().
      */
     public function test_upload_param_area() {
         global $USER;
@@ -134,17 +134,18 @@ class test_external_files extends advanced_testcase {
         $contextid = $context->id;
         $component = "user";
         $filearea = "draft";
-        $itemid = 0;
+        $itemid = file_get_unused_draft_itemid();
         $filepath = "/";
         $filename = "Simple4.txt";
         $filecontent = base64_encode("Let us create a nice simple file");
         $contextlevel = null;
         $instanceid = null;
 
-        // Make sure exception is thrown.
-        $this->setExpectedException("coding_exception");
-        core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath,
-                $filename, $filecontent, $contextlevel, $instanceid);
+        // Make sure the file is created.
+        @core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
+        $browser = get_file_browser();
+        $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
+        $this->assertNotEmpty($file);
     }
 
     /*
@@ -164,10 +165,14 @@ class test_external_files extends advanced_testcase {
         $filename = "Simple4.txt";
         $filecontent = base64_encode("Let us create a nice simple file");
 
-        // Make sure the file is created.
         @core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
+
+        // Assert debugging called (deprecation warning).
+        $this->assertDebuggingCalled();
+
+        // Make sure the file is created.
         $browser = get_file_browser();
         $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
         $this->assertNotEmpty($file);
     }
-}
\ No newline at end of file
+}
index 8cd7d0d..848cc4b 100644 (file)
@@ -141,7 +141,7 @@ class edit_scale_form extends moodleform {
                 $thescale = implode(',',$scalearray);
 
                 //this check strips out whitespace from the scale we're validating but not from those already in the DB
-                $count = $DB->count_records_select('scale', "courseid=:courseid AND ".$DB->sql_compare_text('scale', textlib::strlen($thescale)).'=:scale',
+                $count = $DB->count_records_select('scale', "courseid=:courseid AND ".$DB->sql_compare_text('scale', core_text::strlen($thescale)).'=:scale',
                     array('courseid'=>$courseid, 'scale'=>$thescale));
 
                 if ($count) {
index 33c702e..f8d18f3 100644 (file)
@@ -62,6 +62,9 @@ switch ($action) {
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
             }
+            if (!$object->can_control_visibility()) {
+                print_error('componentcontrolsvisibility', 'grades', $returnurl);
+            }
             $object->set_hidden(1, true);
         }
         break;
@@ -74,6 +77,9 @@ switch ($action) {
             if ($type == 'grade' and empty($object->id)) {
                 $object->insert();
             }
+            if (!$object->can_control_visibility()) {
+                print_error('componentcontrolsvisibility', 'grades', $returnurl);
+            }
             $object->set_hidden(0, true);
         }
         break;
index 6a71f1a..e782303 100644 (file)
@@ -26,7 +26,7 @@ class grade_edit_tree {
     public $columns = array();
 
     /**
-     * @var object $gtree          @see grade/lib.php
+     * @var grade_tree $gtree   @see grade/lib.php
      */
     public $gtree;
 
index 9081f00..1772b0a 100644 (file)
@@ -110,10 +110,12 @@ class grade_export_form extends moodleform {
             $mform->addElement('text', 'iprestriction', get_string('keyiprestriction', 'userkey'), array('size'=>80));
             $mform->addHelpButton('iprestriction', 'keyiprestriction', 'userkey');
             $mform->setDefault('iprestriction', getremoteaddr()); // own IP - just in case somebody does not know what user key is
+            $mform->setType('iprestriction', PARAM_RAW_TRIMMED);
 
             $mform->addElement('date_time_selector', 'validuntil', get_string('keyvaliduntil', 'userkey'), array('optional'=>true));
             $mform->addHelpButton('validuntil', 'keyvaliduntil', 'userkey');
             $mform->setDefault('validuntil', time()+3600*24*7); // only 1 week default duration - just in case somebody does not know what user key is
+            $mform->setType('validuntil', PARAM_INT);
 
             $mform->disabledIf('iprestriction', 'key', 'noteq', 1);
             $mform->disabledIf('validuntil', 'key', 'noteq', 1);
index 8c44f19..e30a3a5 100644 (file)
@@ -39,7 +39,10 @@ class key_form extends moodleform {
 
         $mform->addElement('static', 'value', get_string('keyvalue', 'userkey'));
         $mform->addElement('text', 'iprestriction', get_string('keyiprestriction', 'userkey'), array('size'=>80));
+        $mform->setType('iprestriction', PARAM_RAW_TRIMMED);
+
         $mform->addElement('date_time_selector', 'validuntil', get_string('keyvaliduntil', 'userkey'), array('optional'=>true));
+        $mform->setType('validuntil', PARAM_INT);
 
         $mform->addHelpButton('iprestriction', 'keyiprestriction', 'userkey');
         $mform->addHelpButton('validuntil', 'keyvaliduntil', 'userkey');
similarity index 98%
rename from grade/grading/tests/lib_test.php
rename to grade/grading/tests/grading_manager_test.php
index 087f40c..0e806e8 100644 (file)
@@ -49,7 +49,7 @@ class testable_grading_manager extends grading_manager {
  * @copyright  2011 David Mudrak <david@moodle.com>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class grading_manager_testcase extends advanced_testcase {
+class core_grade_grading_manager_testcase extends advanced_testcase {
     public function test_basic_instantiation() {
         $manager1 = get_grading_manager();
 
index 9f86e48..73ff680 100644 (file)
@@ -41,7 +41,7 @@ class grade_import_form extends moodleform {
         // file upload
         $mform->addElement('filepicker', 'userfile', get_string('file'));
         $mform->addRule('userfile', null, 'required');
-        $encodings = textlib::get_encodings();
+        $encodings = core_text::get_encodings();
         $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
 
         if (!empty($features['includeseparator'])) {
index 6706381..afda858 100644 (file)
@@ -43,6 +43,7 @@ class key_form extends moodleform {
 
         $mform->addHelpButton('iprestriction', 'keyiprestriction', 'userkey');
         $mform->addHelpButton('validuntil', 'keyvaliduntil', 'userkey');
+        $mform->setType('iprestriction', PARAM_RAW_TRIMMED);
 
         $mform->addElement('hidden','id');
         $mform->setType('id', PARAM_INT);
index 3603ac4..7639e08 100644 (file)
@@ -1541,6 +1541,10 @@ class grade_structure {
     public function get_hiding_icon($element, $gpr) {
         global $CFG, $OUTPUT;
 
+        if (!$element['object']->can_control_visibility()) {
+            return '';
+        }
+
         if (!has_capability('moodle/grade:manage', $this->context) and
             !has_capability('moodle/grade:hide', $this->context)) {
             return '';
index 70da1b1..73c2474 100644 (file)
@@ -24,3 +24,4 @@
 
 $string['pluginname'] = 'User report';
 $string['user:view'] = 'View your own grade report';
+$string['tablesummary'] = 'The table is arranged as a list of graded items including categories of graded items. When items are in a category they will be indicated as such.';
index 3526c58..adb3bad 100644 (file)
@@ -337,6 +337,9 @@ class grade_report_user extends grade_report {
 
         /// Process those items that have scores associated
         if ($type == 'item' or $type == 'categoryitem' or $type == 'courseitem') {
+            $header_row = "row_{$eid}_{$this->user->id}";
+            $header_cat = "cat_{$grade_object->categoryid}_{$this->user->id}";
+
             if (! $grade_grade = grade_grade::fetch(array('itemid'=>$grade_object->id,'userid'=>$this->user->id))) {
                 $grade_grade = new grade_grade();
                 $grade_grade->userid = $this->user->id;
@@ -387,11 +390,16 @@ class grade_report_user extends grade_report {
                 } else {
                    $class .= ($type == 'categoryitem' or $type == 'courseitem') ? " ".$alter."d$depth baggb" : " item b1b";
                 }
+                if ($type == 'categoryitem' or $type == 'courseitem') {
+                    $header_cat = "cat_{$grade_object->iteminstance}_{$this->user->id}";
+                }
 
                 /// Name
                 $data['itemname']['content'] = $fullname;
                 $data['itemname']['class'] = $class;
                 $data['itemname']['colspan'] = ($this->maxdepth - $depth);
+                $data['itemname']['celltype'] = 'th';
+                $data['itemname']['id'] = $header_row;
 
                 /// Actual Grade
                 $gradeval = $grade_grade->finalgrade;
@@ -404,6 +412,7 @@ class grade_report_user extends grade_report {
                 if ($this->showweight) {
                     $data['weight']['class'] = $class;
                     $data['weight']['content'] = '-';
+                    $data['weight']['headers'] = "$header_cat $header_row weight";
                     // has a weight assigned, might be extra credit
                     if ($grade_object->aggregationcoef > 0 && $type <> 'courseitem') {
                         $data['weight']['content'] = number_format($grade_object->aggregationcoef,2).'%';
@@ -429,12 +438,14 @@ class grade_report_user extends grade_report {
                         $gradeval = $this->blank_hidden_total($this->courseid, $grade_grade->grade_item, $gradeval);
                         $data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);
                     }
+                    $data['grade']['headers'] = "$header_cat $header_row grade";
                 }
 
                 // Range
                 if ($this->showrange) {
                     $data['range']['class'] = $class;
                     $data['range']['content'] = $grade_grade->grade_item->get_formatted_range(GRADE_DISPLAY_TYPE_REAL, $this->rangedecimals);
+                    $data['range']['headers'] = "$header_cat $header_row range";
                 }
 
                 // Percentage
@@ -449,6 +460,7 @@ class grade_report_user extends grade_report {
                         $data['percentage']['class'] = $class;
                         $data['percentage']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true, GRADE_DISPLAY_TYPE_PERCENTAGE);
                     }
+                    $data['percentage']['headers'] = "$header_cat $header_row percentage";
                 }
 
                 // Lettergrade
@@ -467,6 +479,7 @@ class grade_report_user extends grade_report {
                         $data['lettergrade']['class'] = $class;
                         $data['lettergrade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true, GRADE_DISPLAY_TYPE_LETTER);
                     }
+                    $data['lettergrade']['headers'] = "$header_cat $header_row lettergrade";
                 }
 
                 // Rank
@@ -494,6 +507,7 @@ class grade_report_user extends grade_report {
                         $data['rank']['class'] = $class;
                         $data['rank']['content'] = "$rank/".$this->get_numusers(false); // total course users
                     }
+                    $data['rank']['headers'] = "$header_cat $header_row rank";
                 }
 
                 // Average
@@ -504,6 +518,7 @@ class grade_report_user extends grade_report {
                     } else {
                         $data['average']['content'] = '-';
                     }
+                    $data['average']['headers'] = "$header_cat $header_row average";
                 }
 
                 // Feedback
@@ -518,6 +533,7 @@ class grade_report_user extends grade_report {
                         $data['feedback']['class'] = $classfeedback.' feedbacktext';
                         $data['feedback']['content'] = format_text($grade_grade->feedback, $grade_grade->feedbackformat);
                     }
+                    $data['feedback']['headers'] = "$header_cat $header_row feedback";
                 }
             }
         }
@@ -534,6 +550,8 @@ class grade_report_user extends grade_report {
             }
             $data['itemname']['colspan'] = ($this->maxdepth - $depth + count($this->tablecolumns) - 1);
             $data['itemname']['content'] = $fullname;
+            $data['itemname']['celltype'] = 'th';
+            $data['itemname']['id'] = "cat_{$grade_object->id}_{$this->user->id}";
         }
 
         /// Add this row to the overall system
@@ -557,13 +575,16 @@ class grade_report_user extends grade_report {
 
         /// Build table structure
         $html = "
-            <table cellspacing='0' cellpadding='0' class='boxaligncenter generaltable user-grade'>
+            <table cellspacing='0'
+                   cellpadding='0'
+                   summary='" . s($this->get_lang_string('tablesummary', 'gradereport_user')) . "'
+                   class='boxaligncenter generaltable user-grade'>
             <thead>
                 <tr>
-                    <th class=\"header\" colspan='$maxspan'>".$this->tableheaders[0]."</th>\n";
+                    <th id='".$this->tablecolumns[0]."' class=\"header\" colspan='$maxspan'>".$this->tableheaders[0]."</th>\n";
 
         for ($i = 1; $i < count($this->tableheaders); $i++) {
-            $html .= "<th class=\"header\">".$this->tableheaders[$i]."</th>\n";
+            $html .= "<th id='".$this->tablecolumns[$i]."' class=\"header\">".$this->tableheaders[$i]."</th>\n";
         }
 
         $html .= "
@@ -584,8 +605,11 @@ class grade_report_user extends grade_report {
                 $class = (isset($this->tabledata[$i][$name]['class'])) ? $this->tabledata[$i][$name]['class'] : '';
                 $colspan = (isset($this->tabledata[$i][$name]['colspan'])) ? "colspan='".$this->tabledata[$i][$name]['colspan']."'" : '';
                 $content = (isset($this->tabledata[$i][$name]['content'])) ? $this->tabledata[$i][$name]['content'] : null;
+                $celltype = (isset($this->tabledata[$i][$name]['celltype'])) ? $this->tabledata[$i][$name]['celltype'] : 'td';
+                $id = (isset($this->tabledata[$i][$name]['id'])) ? "id='{$this->tabledata[$i][$name]['id']}'" : '';
+                $headers = (isset($this->tabledata[$i][$name]['headers'])) ? "headers='{$this->tabledata[$i][$name]['headers']}'" : '';
                 if (isset($content)) {
-                    $html .= "<td class='$class' $colspan>$content</td>\n";
+                    $html .= "<$celltype $id $headers class='$class' $colspan>$content</$celltype>\n";
                 }
             }
             $html .= "</tr>\n";
index f0e5a3c..2a958d3 100644 (file)
 .user-grade td {margin: 1px;padding: 0.25em;min-width: 2em;vertical-align: top;}
 .user-grade thead {border-bottom: 3px double black;}
 .user-grade thead th {padding: 0.25em 0.75em;}
-.user-grade td.oddd1 {background-color: #f3dfd0;}
-.user-grade td.oddd2 {background-color: #d0dbf3;}
-.user-grade td.oddd3 {background-color: #d0f3d6;}
-.user-grade td.oddd4 {background-color: #f0f0aa;}
-.user-grade td.evend2 {background-color: #b0bbd3;}
-.user-grade td.evend3 {background-color: #b0dfb6;}
-.user-grade td.evend4 {background-color: #cac8be;}
+.user-grade tbody th {text-align:left;}
+.user-grade td.oddd1,
+.user-grade th.oddd1 {background-color: #f3dfd0;}
+.user-grade td.oddd2,
+.user-grade th.oddd2 {background-color: #d0dbf3;}
+.user-grade td.oddd3,
+.user-grade th.oddd3 {background-color: #d0f3d6;}
+.user-grade td.oddd4,
+.user-grade th.oddd4 {background-color: #f0f0aa;}
+.user-grade td.evend2,
+.user-grade th.evend2 {background-color: #b0bbd3;}
+.user-grade td.evend3,
+.user-grade th.evend3 {background-color: #b0dfb6;}
+.user-grade td.evend4,
+.user-grade th.evend4 {background-color: #cac8be;}
 .user-grade td.b1t,
-.user-grade td.b2t {border-top: 2px solid black;}
+.user-grade td.b2t,
+.user-grade th.b1t,
+.user-grade th.b2t {border-top: 2px solid black;}
 .user-grade td.b1r,
-.user-grade td.b2r {border-right: 2px solid black;}
+.user-grade td.b2r,
+.user-grade th.b1r,
+.user-grade th.b2r {border-right: 2px solid black;}
 .user-grade td.b1b,
-.user-grade td.b2b {border-bottom: 2px solid black;}
+.user-grade td.b2b,
+.user-grade th.b1b,
+.user-grade th.b2b {border-bottom: 2px solid black;}
 .user-grade td.b1l,
-.user-grade td.b2l {border-left: 2px solid black;}
+.user-grade td.b2l,
+.user-grade th.b1l,
+.user-grade th.b2l {border-left: 2px solid black;}
 .user-grade td.baggt,
-.user-grade td.baggb {font-style: italic;font-weight: bold;}
-.user-grade td.baggt {border-top: 3px double black;}
-.user-grade td.baggb {border-bottom: 3px double black;}
-.user-grade td.item {border-left: 1px solid gray;border-right: 1px solid gray;}
+.user-grade td.baggb,
+.user-grade th.baggt,
+.user-grade th.baggb {font-style: italic;font-weight: bold;}
+.user-grade td.baggt,
+.user-grade th.baggt {border-top: 3px double black;}
+.user-grade td.baggb,
+.user-grade th.baggb {border-bottom: 3px double black;}
+.user-grade td.item,
+.user-grade th.item {border-left: 1px solid gray;border-right: 1px solid gray}
 .user-grade td.excluded {background-color: #666;}
 .user-grade td.hidden {color: #aaa;}
 .user-grade td.feedbacktext {max-width:600px;padding:2px 2px;}
similarity index 96%
rename from grade/tests/edittree_test.php
rename to grade/tests/edittreelib_test.php
index 7cac516..59e4a23 100644 (file)
@@ -32,7 +32,7 @@ require_once($CFG->dirroot.'/grade/edit/tree/lib.php');
 /**
  * Tests grade_edit_tree (deals with the data on the categories and items page in the gradebook)
  */
-class gradeedittreelib_testcase extends basic_testcase {
+class core_grade_edittreelib_testcase extends basic_testcase {
     var $courseid = 1;
     var $context = null;
     var $grade_edit_tree = null;
index a1cbfc5..defbe49 100644 (file)
@@ -28,7 +28,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php');
  * @copyright 2013 Paul Charsley
  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class core_grade_external_testcase extends externallib_advanced_testcase {
+class core_grade_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Tests set up
index b37df34..dca1a9e 100644 (file)
@@ -30,7 +30,7 @@ require_once($CFG->libdir.'/gradelib.php');
 require_once($CFG->dirroot.'/grade/querylib.php');
 
 
-class grade_querylib_testcase extends advanced_testcase {
+class core_grade_querylib_testcase extends advanced_testcase {
 
     public function test_grade_get_gradable_activities() {
         $this->resetAfterTest(true);
similarity index 98%
rename from grade/tests/reportgrader_test.php
rename to grade/tests/report_graderlib_test.php
index 07be5e3..f3fd1ee 100644 (file)
@@ -32,7 +32,7 @@ require_once($CFG->dirroot.'/grade/report/grader/lib.php');
 /**
  * Tests grade_report_grader (the grader report)
  */
-class grade_report_graderlib_testcase extends advanced_testcase {
+class core_grade_report_graderlib_testcase extends advanced_testcase {
 
     /**
      * Tests grade_report_grader::process_data()
index af3f791..dac85f9 100644 (file)
@@ -61,7 +61,7 @@ class grade_report_test extends grade_report {
 /**
  * Tests grade_report, the parent class for all grade reports.
  */
-class gradereportlib_testcase extends advanced_testcase {
+class core_grade_reportlib_testcase extends advanced_testcase {
 
     /**
      * Tests grade_report::blank_hidden_total()
similarity index 99%
rename from grade/tests/reportuser_test.php
rename to grade/tests/reportuserlib_test.php
index b27d717..10cea41 100644 (file)
@@ -33,7 +33,7 @@ require_once($CFG->dirroot.'/grade/report/user/lib.php');
 /**
  * Tests grade_report_user (the gradebook's user report)
  */
-class gradereportuserlib_testcase extends advanced_testcase {
+class core_grade_reportuserlib_testcase extends advanced_testcase {
 
     /**
      * Tests grade_report_user::inject_rowspans()
index 46f0137..6818ca2 100644 (file)
@@ -101,7 +101,7 @@ class group_form extends moodleform {
             $idnumber = '';
         }
         if ($data['id'] and $group = $DB->get_record('groups', array('id'=>$data['id']))) {
-            if (textlib::strtolower($group->name) != textlib::strtolower($name)) {
+            if (core_text::strtolower($group->name) != core_text::strtolower($name)) {
                 if (groups_get_group_by_name($COURSE->id,  $name)) {
                     $errors['name'] = get_string('groupnameexists', 'group', $name);
                 }
index 1f15bc7..d44444b 100644 (file)
@@ -93,7 +93,7 @@ class grouping_form extends moodleform {
             $idnumber = '';
         }
         if ($data['id'] and $grouping = $DB->get_record('groupings', array('id'=>$data['id']))) {
-            if (textlib::strtolower($grouping->name) != textlib::strtolower($name)) {
+            if (core_text::strtolower($grouping->name) != core_text::strtolower($name)) {
                 if (groups_get_grouping_by_name($COURSE->id,  $name)) {
                     $errors['name'] = get_string('groupingnameexists', 'group', $name);
                 }
index 8048d18..d3ca01e 100644 (file)
@@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php');
 require_once($CFG->dirroot . '/group/externallib.php');
 require_once($CFG->dirroot . '/group/lib.php');
 
-class core_group_external_testcase extends externallib_advanced_testcase {
+class core_group_externallib_testcase extends externallib_advanced_testcase {
 
     /**
      * Test create_groups
index b5dc321..54defb4 100644 (file)
--- a/index.php
+++ b/index.php
                     $newsforumcontext = context_module::instance($newsforumcm->id, MUST_EXIST);
 
                     $forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext));
-                    echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block'));
+                    echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block'));
 
                     // wraps site news forum in div container.
                     echo html_writer::start_tag('div', array('id'=>'site-news-forum'));
             case FRONTPAGEENROLLEDCOURSELIST:
                 $mycourseshtml = $courserenderer->frontpage_my_courses();
                 if (!empty($mycourseshtml)) {
-                    echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block'));
+                    echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block'));
 
                     //wrap frontpage course list in div container
                     echo html_writer::start_tag('div', array('id'=>'frontpage-course-list'));
             case FRONTPAGEALLCOURSELIST:
                 $availablecourseshtml = $courserenderer->frontpage_available_courses();
                 if (!empty($availablecourseshtml)) {
-                    echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block'));
+                    echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block'));
 
                     //wrap frontpage course list in div container
                     echo html_writer::start_tag('div', array('id'=>'frontpage-course-list'));
             break;
 
             case FRONTPAGECATEGORYNAMES:
-                echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block'));
+                echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block'));
 
                 //wrap frontpage category names in div container
                 echo html_writer::start_tag('div', array('id'=>'frontpage-category-names'));
             break;
 
             case FRONTPAGECATEGORYCOMBO:
-                echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block'));
+                echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block'));
 
                 //wrap frontpage category combo in div container
                 echo html_writer::start_tag('div', array('id'=>'frontpage-category-combo'));
index b54d765..7b5fa23 100644 (file)
@@ -176,6 +176,8 @@ $CFG->docroot              = 'http://docs.moodle.org';
 $CFG->langotherroot        = $CFG->dataroot.'/lang';
 $CFG->langlocalroot        = $CFG->dataroot.'/lang';
 $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
+$CFG->filepermissions      = ($CFG->directorypermissions & 0666);
+$CFG->umaskpermissions     = (($CFG->directorypermissions & 0777) ^ 0777);
 $CFG->running_installer    = true;
 $CFG->early_install_lang   = true;
 $CFG->ostype               = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
@@ -196,6 +198,9 @@ if (!empty($memlimit) and $memlimit != -1) {
 
 // Continue with lib loading
 require_once($CFG->libdir.'/classes/text.php');
+require_once($CFG->libdir.'/classes/string_manager.php');
+require_once($CFG->libdir.'/classes/string_manager_install.php');
+require_once($CFG->libdir.'/classes/string_manager_standard.php');
 require_once($CFG->libdir.'/weblib.php');
 require_once($CFG->libdir.'/outputlib.php');
 require_once($CFG->libdir.'/dmllib.php');
index b013f2c..a804109 100644 (file)
@@ -30,6 +30,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
+$string['cannotcreatedboninstall'] = '<p>Die Datenbank konnte nicht angelegt werden.</p><p>Die angegebene Datenbank existiert nicht und das genannten Nutzerkonto hat keine Rechte, die Datenbank neu anzulegen. Die Datenbank-Konfiguration muss überprüft werden.</p>';
 $string['cannotcreatelangdir'] = 'Verzeichnis \'lang\' wurde nicht angelegt';
 $string['cannotcreatetempdir'] = 'Das Verzeichnis \'temp\' wurde nicht angelegt';
 $string['cannotdownloadcomponents'] = 'Einige Komponenten können nicht geladen werden.';
@@ -39,6 +40,7 @@ $string['cannotsavemd5file'] = 'Die md5-Datei wurde nicht gespeichert';
 $string['cannotsavezipfile'] = 'Die ZIP-Datei wurde nicht gespeichert';
 $string['cannotunzipfile'] = 'Die Datei kann nicht entpackt werden';
 $string['componentisuptodate'] = 'Die Komponente ist aktuell.';
+$string['dmlexceptiononinstall'] = '<p>Ein Datenbankfehler ist aufgetreten [{$a->errorcode}]. <br />{$a->debuginfo}</p>';
 $string['downloadedfilecheckfailed'] = 'Die Überprüfung der heruntergeladenen Datei ist gescheitert';
 $string['invalidmd5'] = 'Der Prüfwert ist ungültig. Versuchen Sie es bitte nochmal!';
 $string['missingrequiredfield'] = 'Einige erforderliche Felder sind nicht ausgefüllt.';
index 52a8c02..2ab2c48 100644 (file)
@@ -30,6 +30,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
+$string['cannotcreatedboninstall'] = '<p>Az adatbázis nem hozható létre.</p> <p>A megadott adatbázis nem létezik, a felhasználó pedig nem jogosult létrehozni egyet.</p> <p>A portál rendszergazdájának ellenőrizni kell az adatbázis-beállításokat.</p>';
 $string['cannotcreatelangdir'] = 'Nem hozható létre a lang könyvtár.';
 $string['cannotcreatetempdir'] = 'Nem hozható létre a temp könyvtár.';
 $string['cannotdownloadcomponents'] = 'Az összetevőket nem lehet letölteni.';
@@ -39,6 +40,7 @@ $string['cannotsavemd5file'] = 'Az md5 állományt nem lehet elmenteni.';
 $string['cannotsavezipfile'] = 'A tömörített állományt nem lehet elmenteni.';
 $string['cannotunzipfile'] = 'A tömörített állományt nem lehet kicsomagolni.';
 $string['componentisuptodate'] = 'Az összetevő a legújabb.';
+$string['dmlexceptiononinstall'] = '<p>Adatbázishiba történt [{$a->errorcode}].<br />{$a->debuginfo}</p>';
 $string['downloadedfilecheckfailed'] = 'A letöltött állomány ellenőrzése nem sikerült.';
 $string['invalidmd5'] = 'Az ellenőrző változó hibás volt – próbálkozzék ismét';
 $string['missingrequiredfield'] = 'Egy szükséges mező hiányzik.';
index 0c2e798..8f71671 100644 (file)
@@ -37,14 +37,14 @@ $string['chooselanguagesub'] = 'Scegli la lingua da usare durante l\'installazio
 $string['clialreadyconfigured'] = 'Il file config.php esiste già, per favore utilizza admin/cli/install_database.php se desideri installare questo sito.';
 $string['clialreadyinstalled'] = 'Il file config.php è già presente, se desideri aggiornare il sito per favore utilizza admin/cli/upgrade.php.';
 $string['cliinstallheader'] = 'Programma di installazione Moodle {$a} via linea di comando';
-$string['databasehost'] = 'Database host:';
-$string['databasename'] = 'Nome del Database';
+$string['databasehost'] = 'Host database';
+$string['databasename'] = 'Nome database';
 $string['databasetypehead'] = 'Scegli un database driver';
-$string['dataroot'] = 'Cartella dei dati';
-$string['datarootpermission'] = 'Permessi cartella dei dati';
+$string['dataroot'] = 'Cartella dati';
+$string['datarootpermission'] = 'Permessi cartella dati';
 $string['dbprefix'] = 'Prefisso tabelle';
 $string['dirroot'] = 'Cartella di Moodle';
-$string['environmenthead'] = 'Verifica del vostro ambiente...';
+$string['environmenthead'] = 'Verifica dell\'ambiente...';
 $string['environmentsub2'] = 'Ciascuna release di Moodle prevede come requisito minimo una data versione del PHP ed una serie di estensioni. Prima di una installazione o di un aggiornamento viene eseguita la verifica dei requisiti minimi. Se non sai come installare nuove versioni del PHP o le sue estensioni, contatta l\'amministratore del tuo server.';
 $string['errorsinenvironment'] = 'Ci sono problemi nel vostro ambiente';
 $string['installation'] = 'Installazione';
@@ -65,8 +65,8 @@ Questo consentirà a Moodle di impostare in autonomia il limite di memoria.</li>
 $string['paths'] = 'Percorsi';
 $string['pathserrcreatedataroot'] = 'Lo script di installazione non ha potuto creare la Cartella dei dati ({$a->dataroot}).';
 $string['pathshead'] = 'Conferma percorsi';
-$string['pathsrodataroot'] = 'La Cartella dei dati non è scrivibile.';
-$string['pathsroparentdataroot'] = 'La cartella superiore ({$a->parent}) non è scrivibile. Lo script di installazione non può creare la Cartella dei dati ({$a->dataroot}).';
+$string['pathsrodataroot'] = 'Non è possibile scrivere nella  Cartella dati.';
+$string['pathsroparentdataroot'] = 'La cartella genitore ({$a->parent}) non è scrivibile. Lo script di installazione non può creare la Cartella dati ({$a->dataroot}).';
 $string['pathssubadmindir'] = 'Alcuni web host utilizzano la cartella /admin come URL di accesso a pannelli di controllo od altre funzioni particolari. Tuttavia questo nome coincide con il nome della cartella che Moodle utilizza per i propri file di amministrazione. Per evitare conflitti, è possibile specificare un nome alternativo per la cartella Admin di Moodle. Ad esempio:<p><b>moodleadmin</b></p>
 Tutti i link che puntano ai file di amministrazione di Moodle terranno conto di questa variazione.';
 $string['pathssubdataroot'] = 'E\' necessario specificare una cartella dove Moodle inserirà i file caricati dagli utenti. Il web server (in genere \'nobody\' o \'apache\') DEVE avere i permessi di lettura e di scrittura su questa cartella. In aggiunta, la cartella dei dati NON DEVE essere direttamente accessibile via web. Se la Cartella dei dati non esiste, lo script di installazione tenterà di crearla.';
@@ -74,7 +74,7 @@ $string['pathssubdirroot'] = 'Percorso assoluto della cartella di installazione
 $string['pathssubwwwroot'] = 'Indirizzo web per accedere a Moodle. Non è possibile accedere alla stessa installazione Moodle usando più di un indirizzi web. Se il tuo sito usa più indirizzi web, devi configurare dei re-indirizzamenti permanenti per tutti gli altri indirizzi.
 Se il tuo sito è raggiungibile sia dalla Internet che dalla Intranet, allora usa l\'indirizzo Internet pubblico ed imposta il DNS in modo che anche gli utenti della Intranet possano accedere usando l\'indirizzo pubblico.
 Se l\'indirizzo è errato per favore correggilo nella barra degli indirizzi del browser per avviare nuovamente l\'installazione.';
-$string['pathsunsecuredataroot'] = 'La posizione della Cartella dei dati non è sicura';
+$string['pathsunsecuredataroot'] = 'La posizione della Cartella dati non è sicura';
 $string['pathswrongadmindir'] = 'La cartella Admin non esiste';
 $string['phpextension'] = '{$a} estensioni PHP';
 $string['phpversion'] = 'Versione PHP';
@@ -88,5 +88,5 @@ $string['welcomep30'] = 'La release di <strong>{$a->installername}</strong> incl
 $string['welcomep40'] = 'Il pacchetto include anche <strong>Moodle {$a->moodlerelease} ({$a->moodleversion})</strong>.';
 $string['welcomep50'] = 'L\'utilizzo delle applicazioni incluse in questo pacchetto è regolato dalle rispettive licenze. L\'intero pacchetto <strong>{$a->installername}</strong> è <a href="http://www.opensource.org/docs/definition_plain.html">open source</a>&nbs