From 110831ceaade1541405ba1dce5e16fe801d9559d Mon Sep 17 00:00:00 2001 From: Itamar Tzadok Date: Fri, 14 Sep 2012 16:09:24 -0400 Subject: [PATCH] MDL-35216 My Moodle - Admin setting for controlling guest access to my moodle --- admin/settings/appearance.php | 1 + lang/en/admin.php | 2 ++ my/index.php | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 8130da4a9e658..acd62dfb1afc2 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -97,6 +97,7 @@ HOMEPAGE_USER => new lang_string('userpreference', 'admin') ); $temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices)); + $temp->add(new admin_setting_configcheckbox('allowguestmymoodle', new lang_string('allowguestmymoodle', 'admin'), new lang_string('configallowguestmymoodle', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0)); diff --git a/lang/en/admin.php b/lang/en/admin.php index 9f62c297ae845..aa0ecca784f62 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -49,6 +49,7 @@ $string['allowemailaddresses'] = 'Allowed email domains'; $string['allowframembedding'] = 'Allow frame embedding'; $string['allowframembedding_help'] = 'Allow embedding of this site in frames on external sites. Enabling of this feature is not recommended for security reasons.'; +$string['allowguestmymoodle'] = 'Allow guest access to My Moodle'; $string['allowobjectembed'] = 'Allow EMBED and OBJECT tags'; $string['allowthemechangeonurl'] = 'Allow theme changes in the URL'; $string['allowuserblockhiding'] = 'Allow users to hide blocks'; @@ -123,6 +124,7 @@ $string['configallowcategorythemes'] = 'If you enable this, then themes can be set at the category level. This will affect all child categories and courses unless they have specifically set their own theme. WARNING: Enabling category themes may affect performance.'; $string['configallowcoursethemes'] = 'If you enable this, then courses will be allowed to set their own themes. Course themes override all other theme choices (site, user, or session themes)'; $string['configallowemailaddresses'] = 'If you want to restrict all new email addresses to particular domains, then list them here separated by spaces. All other domains will be rejected. To allow subdomains add the domain with a preceding \'.\'. eg ourcollege.edu.au .gov.au'; +$string['configallowguestmymoodle'] = 'If enabled guests can access My Moodle, otherwise guests are redirected to the site front page.'; $string['configallowobjectembed'] = 'As a default security measure, normal users are not allowed to embed multimedia (like Flash) within texts using explicit EMBED and OBJECT tags in their HTML (although it can still be done safely using the mediaplugins filter). If you wish to allow these tags then enable this option.'; $string['configallowoverride'] = 'You can allow people with the roles on the left side to override some of the column roles'; $string['configallowoverride2'] = 'Select which role(s) can be overridden by each role in the left column.
Note that these settings only apply to users who have either the capability moodle/role:override or the capability moodle/role:safeoverride allowed.'; diff --git a/my/index.php b/my/index.php index 2005facfdc5ee..aa2852ca14b6e 100644 --- a/my/index.php +++ b/my/index.php @@ -48,6 +48,11 @@ $strmymoodle = get_string('myhome'); if (isguestuser()) { // Force them to see system default, no editing allowed + // If guests are not allowed my moodle, send them to front page. + if (empty($CFG->allowguestmymoodle)) { + redirect(new moodle_url('/', array('redirect' => 0))); + } + $userid = NULL; $USER->editing = $edit = 0; // Just in case $context = context_system::instance();