diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 9995af38048..212554b0950 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -75,8 +75,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $temp->add(new admin_setting_configcheckbox('useblogassociations', new lang_string('useblogassociations', 'blog'), new lang_string('configuseblogassociations','blog'), 1)); $temp->add(new admin_setting_bloglevel('bloglevel', new lang_string('bloglevel', 'admin'), new lang_string('configbloglevel', 'admin'), 4, array(BLOG_GLOBAL_LEVEL => new lang_string('worldblogs','blog'), BLOG_SITE_LEVEL => new lang_string('siteblogs','blog'), - BLOG_USER_LEVEL => new lang_string('personalblogs','blog'), - 0 => new lang_string('disableblogs','blog')))); + BLOG_USER_LEVEL => new lang_string('personalblogs','blog')))); $temp->add(new admin_setting_configcheckbox('useexternalblogs', new lang_string('useexternalblogs', 'blog'), new lang_string('configuseexternalblogs','blog'), 1)); $temp->add(new admin_setting_configselect('externalblogcrontime', new lang_string('externalblogcrontime', 'blog'), new lang_string('configexternalblogcrontime', 'blog'), 86400, array(43200 => new lang_string('numhours', '', 12), diff --git a/admin/settings/subsystems.php b/admin/settings/subsystems.php index 0e629b805c0..0d3db2ed1d2 100644 --- a/admin/settings/subsystems.php +++ b/admin/settings/subsystems.php @@ -26,11 +26,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', new lang_string('enablerssfeeds', 'admin'), new lang_string('configenablerssfeeds', 'admin'), 0)); - $optionalsubsystems->add(new admin_setting_bloglevel('bloglevel', new lang_string('bloglevel', 'admin'), - new lang_string('configbloglevel', 'admin'), 4, array(5 => new lang_string('worldblogs','blog'), - 4 => new lang_string('siteblogs','blog'), - 1 => new lang_string('personalblogs','blog'), - 0 => new lang_string('disableblogs','blog')))); + $optionalsubsystems->add(new admin_setting_configcheckbox('enableblogs', new lang_string('enableblogs', 'admin'), new lang_string('configenableblogs', 'admin'), 1)); $options = array('off'=>new lang_string('off', 'mnet'), 'strict'=>new lang_string('on', 'mnet')); $optionalsubsystems->add(new admin_setting_configselect('mnet_dispatcher_mode', new lang_string('net', 'mnet'), new lang_string('configmnet', 'mnet'), 'off', $options)); diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php index c85576a0f26..bdbe4573830 100644 --- a/blocks/blog_menu/block_blog_menu.php +++ b/blocks/blog_menu/block_blog_menu.php @@ -58,7 +58,7 @@ class block_blog_menu extends block_base { return $this->content; } - if (empty($CFG->bloglevel)) { + if (empty($CFG->enableblogs)) { $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { diff --git a/blocks/blog_recent/block_blog_recent.php b/blocks/blog_recent/block_blog_recent.php index fe6c970c8fe..1bee81e6c96 100644 --- a/blocks/blog_recent/block_blog_recent.php +++ b/blocks/blog_recent/block_blog_recent.php @@ -52,7 +52,7 @@ class block_blog_recent extends block_base { } // verify blog is enabled - if (empty($CFG->bloglevel)) { + if (empty($CFG->enableblogs)) { $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { diff --git a/blog/edit.php b/blog/edit.php index 3ed91554cdb..d39ec414c13 100644 --- a/blog/edit.php +++ b/blog/edit.php @@ -69,7 +69,7 @@ if ($action == 'edit') { $id = required_param('entryid', PARAM_INT); } -if (empty($CFG->bloglevel)) { +if (empty($CFG->enableblogs)) { print_error('blogdisable', 'blog'); } diff --git a/blog/index.php b/blog/index.php index feb320e9cbd..94bc527cfcb 100644 --- a/blog/index.php +++ b/blog/index.php @@ -34,7 +34,7 @@ foreach ($url_params as $var => $val) { } $PAGE->set_url('/blog/index.php', $url_params); -if (empty($CFG->bloglevel)) { +if (empty($CFG->enableblogs)) { print_error('blogdisable', 'blog'); } diff --git a/blog/lib.php b/blog/lib.php index 764fc64a060..280102965b0 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -64,7 +64,7 @@ function blog_user_can_edit_entry($blogentry) { function blog_user_can_view_user_entry($targetuserid, $blogentry=null) { global $CFG, $USER, $DB; - if (empty($CFG->bloglevel)) { + if (empty($CFG->enableblogs)) { return false; // blog system disabled } @@ -349,8 +349,7 @@ function blog_get_context_url($context=null) { */ function blog_is_enabled_for_user() { global $CFG; - //return (!empty($CFG->bloglevel) && $CFG->bloglevel <= BLOG_GLOBAL_LEVEL && isloggedin() && !isguestuser()); - return (!empty($CFG->bloglevel) && (isloggedin() || ($CFG->bloglevel == BLOG_GLOBAL_LEVEL))); + return (!empty($CFG->enableblogs) && (isloggedin() || ($CFG->bloglevel == BLOG_GLOBAL_LEVEL))); } /** @@ -406,7 +405,7 @@ function blog_get_all_options(moodle_page $page, stdClass $userid = null) { } // If blog level is global then display a link to view all site entries - if (!empty($CFG->bloglevel) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) { + if (!empty($CFG->enableblogs) && $CFG->bloglevel >= BLOG_GLOBAL_LEVEL && has_capability('moodle/blog:view', context_system::instance())) { $options[CONTEXT_SYSTEM] = array('viewsite' => array( 'string' => get_string('viewsiteentries', 'blog'), 'link' => new moodle_url('/blog/index.php') diff --git a/blog/locallib.php b/blog/locallib.php index 813b6c6a7d8..0356e24abaa 100644 --- a/blog/locallib.php +++ b/blog/locallib.php @@ -602,7 +602,7 @@ class blog_entry { global $CFG, $USER, $DB; $sitecontext = context_system::instance(); - if (empty($CFG->bloglevel) || !has_capability('moodle/blog:view', $sitecontext)) { + if (empty($CFG->enableblogs) || !has_capability('moodle/blog:view', $sitecontext)) { return false; // blog system disabled or user has no blog view capability } diff --git a/blog/preferences.php b/blog/preferences.php index 3ab869b2eaa..9bbc3fcf6c0 100644 --- a/blog/preferences.php +++ b/blog/preferences.php @@ -64,7 +64,7 @@ if ($courseid == SITEID) { $context = context_course::instance($courseid); } -if (empty($CFG->bloglevel)) { +if (empty($CFG->enableblogs)) { print_error('blogdisable', 'blog'); } diff --git a/lang/en/admin.php b/lang/en/admin.php index 9c143985d96..63d3bf4e96e 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -180,6 +180,7 @@ $string['configdefaultuserroleid'] = 'All logged in users will be given the capa $string['configdeleteincompleteusers'] = 'After this period, old not fully setup accounts are deleted.'; $string['configdeleteunconfirmed'] = 'If you are using email authentication, this is the period within which a response will be accepted from users. After this period, old unconfirmed accounts are deleted.'; $string['configdenyemailaddresses'] = 'To deny email addresses from particular domains list them here in the same way. All other domains will be accepted. To deny subdomains add the domain with a preceding \'.\'. eg hotmail.com yahoo.co.uk .live.com'; +$string['configenableblogs'] = 'This switch provides all site users with their own blog.'; $string['configenabledevicedetection'] = 'Enables detection of mobiles, smartphones, tablets or default devices (desktop PCs, laptops, etc) for the application of themes and other features.'; $string['configdisableuserimages'] = 'Disable the ability for users to change user profile images.'; $string['configdisplayloginfailures'] = 'This will display information to selected users about previous failed logins.'; @@ -464,6 +465,7 @@ $string['emoticons_desc'] = 'This form defines the emoticons (or smileys) used a $string['emoticonsreset'] = 'Reset emoticons setting to default values'; $string['emptysettingvalue'] = 'Empty'; $string['enableajax'] = 'Enable AJAX'; +$string['enableblogs'] = 'Enable blogs'; $string['enablecalendarexport'] = 'Enable calendar export'; $string['enablecomments'] = 'Enable comments'; $string['enablecourserequests'] = 'Enable course requests'; diff --git a/lang/en/blog.php b/lang/en/blog.php index 197931e0c15..546753e80ea 100644 --- a/lang/en/blog.php +++ b/lang/en/blog.php @@ -74,7 +74,6 @@ $string['deleteexternalblog'] = 'Unregister this external blog'; $string['deleteotagswarn'] = 'Are you sure you want to remove these tags from all blog posts and remove it from the system?'; $string['description'] = 'Description'; $string['description_help'] = 'Enter a sentence or two summarising the contents of your external blog. (If no description is supplied, the description recorded in your external blog will be used).'; -$string['disableblogs'] = 'Disable blog system completely'; $string['donothaveblog'] = 'You do not have your own blog, sorry.'; $string['editentry'] = 'Edit a blog entry'; $string['editexternalblog'] = 'Edit this external blog'; diff --git a/lib/cronlib.php b/lib/cronlib.php index 8535689effe..7ec99e5c0f0 100644 --- a/lib/cronlib.php +++ b/lib/cronlib.php @@ -352,7 +352,7 @@ function cron_run() { // Run external blog cron if needed - if ($CFG->useexternalblogs) { + if (!empty($CFG->enableblogs) && $CFG->useexternalblogs) { require_once($CFG->dirroot . '/blog/lib.php'); mtrace("Fetching external blog entries...", ''); $sql = "timefetched < ? OR timefetched = 0"; @@ -364,7 +364,7 @@ function cron_run() { mtrace('done.'); } // Run blog associations cleanup - if ($CFG->useblogassociations) { + if (!empty($CFG->enableblogs) && $CFG->useblogassociations) { require_once($CFG->dirroot . '/blog/lib.php'); // delete entries whose contextids no longer exists mtrace("Deleting blog associations linked to non-existent contexts...", ''); diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 726428213b3..6079ed35da4 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1081,5 +1081,25 @@ function xmldb_main_upgrade($oldversion) { // Main savepoint reached upgrade_main_savepoint(true, 2012072600.01); } + + if ($oldversion < 2012080600.00) { + // Move the ability to disable blogs to its own setting MDL-25012. + + if (isset($CFG->bloglevel)) { + // Only change settings if existing setting was set. + if (empty($CFG->bloglevel)) { + set_config('enableblogs', 0); + // Now set the bloglevel to a valid setting as the disabled setting has been removed. + // This prevents confusing results when users enable the blog system in future. + set_config('bloglevel', BLOG_USER_LEVEL); + } else { + set_config('enableblogs', 1); + } + } + + // Main savepoint reached + upgrade_main_savepoint(true, 2012080600.00); + } + return true; } diff --git a/lib/filelib.php b/lib/filelib.php index 32df4bceee7..366b1593037 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -3451,7 +3451,7 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) { send_file_not_found(); } - if (empty($CFG->bloglevel)) { + if (empty($CFG->enableblogs)) { print_error('siteblogdisable', 'blog'); } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 0317445fd87..43dfe9eefb4 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2296,7 +2296,7 @@ class global_navigation extends navigation_node { } // Add blog nodes - if (!empty($CFG->bloglevel)) { + if (!empty($CFG->enableblogs)) { if (!$this->cache->cached('userblogoptions'.$user->id)) { require_once($CFG->dirroot.'/blog/lib.php'); // Get all options for the user @@ -2658,7 +2658,7 @@ class global_navigation extends navigation_node { $filterselect = 0; // Blogs - if (!empty($CFG->bloglevel) + if (!empty($CFG->enableblogs) and ($CFG->bloglevel == BLOG_GLOBAL_LEVEL or ($CFG->bloglevel == BLOG_SITE_LEVEL and (isloggedin() and !isguestuser()))) and has_capability('moodle/blog:view', context_system::instance())) { $blogsurls = new moodle_url('/blog/index.php', array('courseid' => $filterselect)); @@ -4196,7 +4196,7 @@ class settings_navigation extends navigation_node { } // Blogs - if ($currentuser && !empty($CFG->bloglevel)) { + if ($currentuser && !empty($CFG->enableblogs)) { $blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs'); $blog->add(get_string('preferences', 'blog'), new moodle_url('/blog/preferences.php'), navigation_node::TYPE_SETTING); if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', context_system::instance())) { diff --git a/version.php b/version.php index 6f790c025fb..cc69f894e03 100644 --- a/version.php +++ b/version.php @@ -30,7 +30,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2012080200.01; // YYYYMMDD = weekly release date of this DEV branch +$version = 2012080600.00; // YYYYMMDD = weekly release date of this DEV branch // RR = release increments - 00 in DEV branches // .XX = incremental changes