Permalink
Browse files

Merge branch 'master' of https://github.com/moodle/moodle

  • Loading branch information...
2 parents 3a2b8bb + c92d6f4 commit 4a527126273f75e1df7ae5a0c1ebf14469d6c9e5 @pcharsle pcharsle committed Aug 21, 2012
Showing 2,834 changed files with 369,852 additions and 420,055 deletions.
@@ -71,22 +71,23 @@
$ADMIN->add('appearance', $temp);
// blog
- $temp = new admin_settingpage('blog', new lang_string('blog','blog'));
- $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'))));
- $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),
- 86400 => new lang_string('numhours', '', 24),
- 172800 => new lang_string('numdays', '', 2),
- 604800 => new lang_string('numdays', '', 7))));
- $temp->add(new admin_setting_configtext('maxexternalblogsperuser', new lang_string('maxexternalblogsperuser','blog'), new lang_string('configmaxexternalblogsperuser', 'blog'), 1));
- $temp->add(new admin_setting_configcheckbox('blogusecomments', new lang_string('enablecomments', 'admin'), new lang_string('configenablecomments', 'admin'), 1));
- $temp->add(new admin_setting_configcheckbox('blogshowcommentscount', new lang_string('showcommentscount', 'admin'), new lang_string('configshowcommentscount', 'admin'), 1));
- $ADMIN->add('appearance', $temp);
+ if (!empty($CFG->enableblogs)) {
+ $temp = new admin_settingpage('blog', new lang_string('blog','blog'));
+ $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'))));
+ $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),
+ 86400 => new lang_string('numhours', '', 24),
+ 172800 => new lang_string('numdays', '', 2),
+ 604800 => new lang_string('numdays', '', 7))));
+ $temp->add(new admin_setting_configtext('maxexternalblogsperuser', new lang_string('maxexternalblogsperuser','blog'), new lang_string('configmaxexternalblogsperuser', 'blog'), 1));
+ $temp->add(new admin_setting_configcheckbox('blogusecomments', new lang_string('enablecomments', 'admin'), new lang_string('configenablecomments', 'admin'), 1));
+ $temp->add(new admin_setting_configcheckbox('blogshowcommentscount', new lang_string('showcommentscount', 'admin'), new lang_string('configshowcommentscount', 'admin'), 1));
+ $ADMIN->add('appearance', $temp);
+ }
// Navigation settings
$temp = new admin_settingpage('navigation', new lang_string('navigation'));
@@ -26,11 +26,7 @@
$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));
@@ -1,33 +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/>.
-
-/**
- * Post installation and migration code.
- *
- * @package tool
- * @subpackage bloglevelupgrade
- * @copyright 2011 Petr Skoda {@link http://skodak.org}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die;
-
-function xmldb_tool_bloglevelupgrade_install() {
- global $CFG, $OUTPUT;
-
-}
-
-
@@ -1,174 +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/>.
-
-/**
- * Create "blog" forums in each course and copy blog entries from these courses' participants in these forums
- *
- * @package tool
- * @subpackage bloglevelupgrade
- * @copyright 2009 Nicolas Connault
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-define('NO_OUTPUT_BUFFERING', true);
-
-require('../../../config.php');
-require_once($CFG->dirroot.'/course/lib.php');
-require_once($CFG->dirroot.'/blog/lib.php');
-require_once($CFG->dirroot.'/mod/forum/lib.php');
-require_once($CFG->libdir.'/adminlib.php');
-
-admin_externalpage_setup('toolbloglevelupgrade');
-$PAGE->set_pagelayout('maintenance');
-
-$go = optional_param('go', 0, PARAM_BOOL);
-
-echo $OUTPUT->header();
-echo $OUTPUT->heading(get_string('pluginname', 'tool_bloglevelupgrade'));
-
-$strbloglevelupgrade = get_string('bloglevelupgradeinfo', 'tool_bloglevelupgrade');
-
-if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
- $optionsyes = array('go'=>1, 'sesskey'=>sesskey());
- echo $OUTPUT->confirm($strbloglevelupgrade, new moodle_url('/admin/tool/bloglevelupgrade/index.php', $optionsyes), new moodle_url('/admin/index.php'));
- echo $OUTPUT->footer();
- die;
-}
-
-echo $OUTPUT->box_start();
-
-/// Turn off time limits, sometimes upgrades can be slow.
-
-set_time_limit(0);
-
-$i = 0;
-
-// If $CFG->bloglevel is set to BLOG_GROUP_LEVEL or BLOG_COURSE_LEVEL, create a new "blog" forum in each course
-// whose enrolled students have written blog entries, copy these entries in that forum and switch off blogs at site level
-
-if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
- $pbar = new progress_bar('toolbloglevelupgrade', 500, true);
-
- $bloggers = $DB->get_records_sql("SELECT userid FROM {post} WHERE module = 'blog' GROUP BY userid");
- require_once($CFG->dirroot.'/mod/forum/lib.php');
-
- $a = new stdClass();
- $a->userscount = 0;
- $a->blogcount = 0;
-
- foreach ($bloggers as $blogger) {
- $courses = enrol_get_users_courses($blogger->userid, true, 'groupmode,groupmodeforce');
- $blogentries = $DB->get_records('post', array('module' => 'blog', 'userid' => $blogger->userid));
-
- foreach ($courses as $course) {
- $forum = forum_get_course_forum($course->id, 'blog');
- $cm = get_coursemodule_from_instance('forum', $forum->id);
-
- if ($CFG->bloglevel == BLOG_GROUP_LEVEL && $course->groupmode != NOGROUPS) {
- // Unless the course is set to separate groups forced, force the forum to Separate groups
- if (!($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce)) {
- $cm->groupmode = SEPARATEGROUPS;
- $DB->update_record('course_modules', $cm);
- }
-
- $groups = groups_get_user_groups($course->id, $blogger->userid);
- foreach ($groups[0] as $groupid) { // [0] is for all groupings combined
- $a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid);
- }
- } else {
- $a->blogcount += bloglevelupgrade_entries($blogentries, $forum, $cm);
- }
- }
-
- $a->userscount = $i . '/' . count($bloggers);
- $pbar->update($i, count($bloggers), get_string('bloglevelupgradeprogress', 'tool_bloglevelupgrade', $a));
- $i++;
- }
-}
-
-function bloglevelupgrade_entries($blogentries, $forum, $cm, $groupid=-1) {
- $count = 0;
-
- $forumcontext = context_module::instance($cm->id);
- $sitecontext = context_system::instance();
-
- foreach ($blogentries as $blogentry) {
- $discussion = new stdClass();
- $discussion->course = $forum->course;
- $discussion->forum = $forum->id;
- $discussion->name = $blogentry->subject;
- $discussion->assessed = $forum->assessed;
- $discussion->message = $blogentry->summary;
- $discussion->messageformat = $blogentry->summaryformat;
- $discussion->messagetrust = 0;
- $discussion->attachments = 0;
- $discussion->mailnow = false;
- $discussion->timemodified = $blogentry->created;
- $discussion->itemid = null;
- $discussion->groupid = $groupid;
- $message = '';
-
- $discussionid = forum_add_discussion($discussion, null, $message, $blogentry->userid);
-
- // Copy file attachment records
- $fs = get_file_storage();
- $files = $fs->get_area_files($sitecontext->id, 'blog', 'attachment', $blogentry->id);
-
- if (!empty($files)) {
- foreach ($files as $storedfile) {
- $newfile = new stdClass();
- $newfile->component = 'mod_forum';
- $newfile->filearea = 'attachment';
- $newfile->itemid = $discussion->firstpost;
- $newfile->contextid = $forumcontext->id;
- $fs->create_file_from_storedfile($newfile, $storedfile->get_id());
- }
- }
-
- $files = $fs->get_area_files($sitecontext->id, 'blog', 'post', $blogentry->id);
-
- if (!empty($files)) {
- foreach ($files as $storedfile) {
- $newfile = new stdClass();
- $newfile->component = 'mod_forum';
- $newfile->filearea = 'post';
- $newfile->itemid = $discussion->firstpost;
- $newfile->contextid = $forumcontext->id;
- $fs->create_file_from_storedfile($newfile, $storedfile->get_id());
- }
- }
- $count++;
- }
- return $count;
-}
-// END OF LOOP
-
-// set conversion flag - switches to new plugin automatically
-unset_config('tool_bloglevelupgrade_pending');
-// Finally switch bloglevel to 0 (disabled)
-set_config('bloglevel', 0);
-
-echo $OUTPUT->box_end();
-
-/// Rebuild course cache which might be incorrect now
-echo $OUTPUT->notification('Rebuilding course cache...', 'notifysuccess');
-rebuild_course_cache();
-echo $OUTPUT->notification('...finished', 'notifysuccess');
-
-echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
-
-echo $OUTPUT->footer();
-die;
@@ -1,33 +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/>.
-
-/**
- * Strings for component 'tool_bloglevelupgrade', language 'en', branch 'MOODLE_22_STABLE'
- *
- * @package tool
- * @subpackage bloglevelupgrade
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-$string['bloglevelupgradedescription'] = '<p>This site has recently been upgraded to Moodle 2.0.</p>
-<p>Blog visibility was simplified in 2.0, but your site still uses one of the old visibility types. </p>
-<p>To preserve the course-based or group-based visibility of the blog entries on your site, you need to run the following upgrade script, which will create a special "blog" type forum in each course whose enrolled users have posted blog entries, and will copy these blog entries in this special forum. </p>
-<p>Blogs will then be entirely switched off at the site level. No blog entries will be deleted in the process.</p>
-<p>You can run the script by visiting <a href="{$a->fixurl}">the blog level upgrade page</a>.</p>';
-$string['bloglevelupgradeinfo'] = 'Blog visibility was simplified in 2.0, but your site still uses one of the old visibility types. To preserve the course-based or group-based visibility of the blog entries on your site, the following upgrade script will create a special "blog" type forum in each course whose enrolled users have posted blog entries, and will copy these blog entries in this special forum. Blogs will then be entirely switched off at the site level. No blog entries will be deleted in the process.';
-$string['bloglevelupgradeprogress'] = 'Conversion progress: {$a->userscount} users reviewed, {$a->blogcount} entries converted.';
-$string['pluginname'] = 'Blog visibility upgrade';
@@ -1,30 +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/>.
-
-/**
- * Capability overview settings
- *
- * @package tool
- * @subpackage bloglevelupgrade
- * @copyright 2011 Petr Skoda
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die;
-
-if ($hassiteconfig) {
- $ADMIN->add('root', new admin_externalpage('toolbloglevelupgrade', get_string('pluginname', 'tool_bloglevelupgrade'), $CFG->wwwroot.'/'.$CFG->admin.'/tool/bloglevelupgrade/index.php', 'moodle/site:config', empty($CFG->tool_bloglevelupgrade_pending)));
-}
@@ -1,30 +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/>.
-
-/**
- * Version details.
- *
- * @package tool
- * @subpackage bloglevelupgrade
- * @copyright 2011 Petr Skoda
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-$plugin->version = 2012061700; // The current plugin version (Date: YYYYMMDDXX)
-$plugin->requires = 2012061700; // Requires this Moodle version
-$plugin->component = 'tool_bloglevelupgrade'; // Full name of the plugin (used for diagnostics)
@@ -508,7 +508,18 @@ public static function remove_excess_backups($course) {
if (!empty($dir) && ($storage == 1 || $storage == 2)) {
// Calculate backup filename regex, ignoring the date/time/info parts that can be
// variable, depending of languages, formats and automated backup settings
- $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
+
+
+ // MDL-33531: use different filenames depending on backup_shortname option
+ if ( !empty($config->backup_shortname) ) {
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $courseref = format_string($course->shortname, true, array('context' => $context));
+ $courseref = str_replace(' ', '_', $courseref);
+ $courseref = textlib::strtolower(trim(clean_filename($courseref), '_'));
+ } else {
+ $courseref = $course->id;
+ }
+ $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$courseref . '-';
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';
// Store all the matching files into fullpath => timemodified array
Oops, something went wrong.

0 comments on commit 4a52712

Please sign in to comment.