mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
Merge branch 'MDL-48266-master' of git://github.com/FMCorz/moodle
Conflicts: version.php
This commit is contained in:
commit
16dafa5d9f
6 changed files with 64 additions and 13 deletions
|
@ -221,7 +221,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||||
2 => new lang_string('storagecourseandexternal', 'backup')
|
2 => new lang_string('storagecourseandexternal', 'backup')
|
||||||
);
|
);
|
||||||
$temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
|
$temp->add(new admin_setting_configselect('backup/backup_auto_storage', new lang_string('automatedstorage', 'backup'), new lang_string('automatedstoragehelp', 'backup'), 0, $storageoptions));
|
||||||
$temp->add(new admin_setting_configdirectory('backup/backup_auto_destination', new lang_string('saveto'), new lang_string('backupsavetohelp'), ''));
|
$temp->add(new admin_setting_special_backup_auto_destination());
|
||||||
$keepoptoins = array(
|
$keepoptoins = array(
|
||||||
0 => new lang_string('all'), 1 => '1',
|
0 => new lang_string('all'), 1 => '1',
|
||||||
2 => '2',
|
2 => '2',
|
||||||
|
|
|
@ -397,16 +397,11 @@ abstract class backup_cron_automated_helper {
|
||||||
$outcome = self::outcome_from_results($results);
|
$outcome = self::outcome_from_results($results);
|
||||||
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
$file = $results['backup_destination']; // May be empty if file already moved to target location.
|
||||||
|
|
||||||
if (empty($dir) && $storage !== 0) {
|
// If we need to copy the backup file to an external dir and it is not writable, change status to error.
|
||||||
// This is intentionally left as a warning instead of an error because of the current behaviour of backup settings.
|
// This is a feature to prevent moodledata to be filled up and break a site when the admin misconfigured
|
||||||
// See MDL-48266 for details.
|
// the automated backups storage type and destination directory.
|
||||||
$bc->log('No directory specified for automated backups',
|
if ($storage !== 0 && (empty($dir) || !file_exists($dir) || !is_dir($dir) || !is_writable($dir))) {
|
||||||
backup::LOG_WARNING);
|
$bc->log('Specified backup directory is not writable - ', backup::LOG_ERROR, $dir);
|
||||||
$outcome = self::BACKUP_STATUS_WARNING;
|
|
||||||
} else if ($storage !== 0 && (!file_exists($dir) || !is_dir($dir) || !is_writable($dir))) {
|
|
||||||
// If we need to copy the backup file to an external dir and it is not writable, change status to error.
|
|
||||||
$bc->log('Specified backup directory is not writable - ',
|
|
||||||
backup::LOG_ERROR, $dir);
|
|
||||||
$dir = null;
|
$dir = null;
|
||||||
$outcome = self::BACKUP_STATUS_ERROR;
|
$outcome = self::BACKUP_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,7 @@ $string['backupdatenew'] = ' {$a->TAG} is now {$a->weekday}, {$a->mday} {$
|
||||||
$string['backupdateold'] = '{$a->TAG} was {$a->weekday}, {$a->mday} {$a->month} {$a->year}';
|
$string['backupdateold'] = '{$a->TAG} was {$a->weekday}, {$a->mday} {$a->month} {$a->year}';
|
||||||
$string['backupdaterecordtype'] = '<br />{$a->recordtype} - {$a->recordname}<br />';
|
$string['backupdaterecordtype'] = '<br />{$a->recordtype} - {$a->recordname}<br />';
|
||||||
$string['backupdetails'] = 'Backup details';
|
$string['backupdetails'] = 'Backup details';
|
||||||
|
$string['backuperrorinvaliddestination'] = 'The backup destination folder does not exist or is not writable.';
|
||||||
$string['backupexecuteathelp'] = 'Choose what time automated backups should run at.';
|
$string['backupexecuteathelp'] = 'Choose what time automated backups should run at.';
|
||||||
$string['backupfailed'] = 'Some of your courses weren\'t saved!!';
|
$string['backupfailed'] = 'Some of your courses weren\'t saved!!';
|
||||||
$string['backupfilename'] = 'backup';
|
$string['backupfilename'] = 'backup';
|
||||||
|
@ -194,7 +195,7 @@ $string['backupnonisowarning'] = 'Warning: this backup is from a non-Unicode ver
|
||||||
$string['backupnotyetrun'] = 'Automated backup pending';
|
$string['backupnotyetrun'] = 'Automated backup pending';
|
||||||
$string['backuporiginalname'] = 'Backup name';
|
$string['backuporiginalname'] = 'Backup name';
|
||||||
$string['backuproleassignments'] = 'Backup role assignments for these roles';
|
$string['backuproleassignments'] = 'Backup role assignments for these roles';
|
||||||
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files<br />(leave blank to save in its course default dir)';
|
$string['backupsavetohelp'] = 'Full path to the directory where you want to save the backup files';
|
||||||
$string['backupsitefileshelp'] = 'If enabled then site files used in courses will be included in automated backups';
|
$string['backupsitefileshelp'] = 'If enabled then site files used in courses will be included in automated backups';
|
||||||
$string['backuptakealook'] = 'Please take a look at your backup logs in:
|
$string['backuptakealook'] = 'Please take a look at your backup logs in:
|
||||||
{$a}';
|
{$a}';
|
||||||
|
|
|
@ -4390,6 +4390,44 @@ class admin_setting_special_backupdays extends admin_setting_configmulticheckbox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special setting for backup auto destination.
|
||||||
|
*
|
||||||
|
* @package core
|
||||||
|
* @subpackage admin
|
||||||
|
* @copyright 2014 Frédéric Massart - FMCorz.net
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
class admin_setting_special_backup_auto_destination extends admin_setting_configdirectory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls parent::__construct with specific arguments.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct('backup/backup_auto_destination', new lang_string('saveto'), new lang_string('backupsavetohelp'), '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the directory must be set, depending on backup/backup_auto_storage.
|
||||||
|
*
|
||||||
|
* Note: backup/backup_auto_storage must be specified BEFORE this setting otherwise
|
||||||
|
* there will be conflicts if this validation happens before the other one.
|
||||||
|
*
|
||||||
|
* @param string $data Form data.
|
||||||
|
* @return string Empty when no errors.
|
||||||
|
*/
|
||||||
|
public function write_setting($data) {
|
||||||
|
$storage = (int) get_config('backup', 'backup_auto_storage');
|
||||||
|
if ($storage !== 0) {
|
||||||
|
if (empty($data) || !file_exists($data) || !is_dir($data) || !is_writable($data) ) {
|
||||||
|
// The directory must exist and be writable.
|
||||||
|
return get_string('backuperrorinvaliddestination');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent::write_setting($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special debug setting
|
* Special debug setting
|
||||||
|
|
|
@ -4121,6 +4121,23 @@ function xmldb_main_upgrade($oldversion) {
|
||||||
|
|
||||||
// Main savepoint reached.
|
// Main savepoint reached.
|
||||||
upgrade_main_savepoint(true, 2015010800.01);
|
upgrade_main_savepoint(true, 2015010800.01);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2015011501.02) {
|
||||||
|
|
||||||
|
// If the site is using internal and external storage, or just external
|
||||||
|
// storage, and the external path specified is empty we change the setting
|
||||||
|
// to internal only. That is how the backup code is handling this
|
||||||
|
// misconfiguration.
|
||||||
|
$storage = (int) get_config('backup_auto_storage', 'backup');
|
||||||
|
$folder = get_config('backup_auto_destination', 'backup');
|
||||||
|
if ($storage !== 0 && empty($folder)) {
|
||||||
|
set_config('backup_auto_storage', 0, 'backup');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main savepoint reached.
|
||||||
|
upgrade_main_savepoint(true, 2015011501.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$version = 2015012300.00; // YYYYMMDD = weekly release date of this DEV branch.
|
$version = 2015012600.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||||
// RR = release increments - 00 in DEV branches.
|
// RR = release increments - 00 in DEV branches.
|
||||||
// .XX = incremental changes.
|
// .XX = incremental changes.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue