mirror of
https://github.com/moodle/moodle.git
synced 2025-06-01 13:46:35 +02:00
MDL-25012 - blogs: introduce a specific 'enabled' config setting
Rather than overloading the $CFG->bloglevel setting which had a confusing UI in the appearance subsystem. In order to achieve this we modify take the defaults from the existing bloglevel setting and set that for $CFG->enableblogs. Note that in order to prevent a bad default settings from being set we also set $CFG->bloglevel to a valid 'enabled' setting.
This commit is contained in:
parent
db9d7be602
commit
850d2db82a
@ -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),
|
||||
|
@ -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));
|
||||
|
@ -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()) {
|
||||
|
@ -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()) {
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ if ($courseid == SITEID) {
|
||||
$context = context_course::instance($courseid);
|
||||
}
|
||||
|
||||
if (empty($CFG->bloglevel)) {
|
||||
if (empty($CFG->enableblogs)) {
|
||||
print_error('blogdisable', 'blog');
|
||||
}
|
||||
|
||||
|
@ -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 <strong>hotmail.com yahoo.co.uk .live.com</strong>';
|
||||
$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';
|
||||
|
@ -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';
|
||||
|
@ -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...", '');
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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())) {
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user