mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-62572-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
e034670fac
@ -326,11 +326,11 @@ class backup_controller extends base_controller {
|
||||
// Basic/initial prevention against time/memory limits
|
||||
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
// If this is not a course backup, inform the plan we are not
|
||||
// If this is not a course backup, or single activity backup (e.g. duplicate) inform the plan we are not
|
||||
// including all the activities for sure. This will affect any
|
||||
// task/step executed conditionally to stop including information
|
||||
// for section and activity backup. MDL-28180.
|
||||
if ($this->get_type() !== backup::TYPE_1COURSE) {
|
||||
if ($this->get_type() !== backup::TYPE_1COURSE && $this->get_type() !== backup::TYPE_1ACTIVITY) {
|
||||
$this->log('notifying plan about excluded activities by type', backup::LOG_DEBUG);
|
||||
$this->plan->set_excluding_activities();
|
||||
}
|
||||
|
@ -341,11 +341,11 @@ class restore_controller extends base_controller {
|
||||
// Basic/initial prevention against time/memory limits
|
||||
core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
// If this is not a course restore, inform the plan we are not
|
||||
// If this is not a course restore or single activity restore (e.g. duplicate), inform the plan we are not
|
||||
// including all the activities for sure. This will affect any
|
||||
// task/step executed conditionally to stop processing information
|
||||
// for section and activity restore. MDL-28180.
|
||||
if ($this->get_type() !== backup::TYPE_1COURSE) {
|
||||
if ($this->get_type() !== backup::TYPE_1COURSE && $this->get_type() !== backup::TYPE_1ACTIVITY) {
|
||||
$this->log('notifying plan about excluded activities by type', backup::LOG_DEBUG);
|
||||
$this->plan->set_excluding_activities();
|
||||
}
|
||||
|
@ -580,6 +580,17 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
'backup_import_competencies' => 'competencies'
|
||||
);
|
||||
self::apply_admin_config_defaults($controller, $settings, true);
|
||||
if ((!$controller->get_interactive()) &&
|
||||
$controller->get_type() == backup::TYPE_1ACTIVITY) {
|
||||
// This is duplicate - there is no concept of defaults - these settings must be on.
|
||||
$settings = array(
|
||||
'activities',
|
||||
'blocks',
|
||||
'filters',
|
||||
'questionbank'
|
||||
);
|
||||
self::force_enable_settings($controller, $settings);
|
||||
}
|
||||
break;
|
||||
case backup::MODE_AUTOMATED:
|
||||
// Load the automated defaults.
|
||||
@ -607,6 +618,30 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn these settings on. No defaults from admin settings.
|
||||
*
|
||||
* @param backup_controller $controller
|
||||
* @param array $settings a map from admin config names to setting names (Config name => Setting name)
|
||||
*/
|
||||
private static function force_enable_settings(backup_controller $controller, array $settings) {
|
||||
$plan = $controller->get_plan();
|
||||
foreach ($settings as $config => $settingname) {
|
||||
$value = true;
|
||||
if ($plan->setting_exists($settingname)) {
|
||||
$setting = $plan->get_setting($settingname);
|
||||
// We do not allow this setting to be locked for a duplicate function.
|
||||
if ($setting->get_status() !== base_setting::NOT_LOCKED) {
|
||||
$setting->set_status(base_setting::NOT_LOCKED);
|
||||
}
|
||||
$setting->set_value($value);
|
||||
$setting->set_status(base_setting::LOCKED_BY_CONFIG);
|
||||
} else {
|
||||
$controller->log('Unknown setting: ' . $setting, BACKUP::LOG_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the controller settings default values from the admin config.
|
||||
*
|
||||
|
@ -183,6 +183,18 @@ abstract class restore_controller_dbops extends restore_dbops {
|
||||
);
|
||||
self::apply_admin_config_defaults($controller, $settings, true);
|
||||
}
|
||||
if ($controller->get_mode() == backup::MODE_IMPORT &&
|
||||
(!$controller->get_interactive()) &&
|
||||
$controller->get_type() == backup::TYPE_1ACTIVITY) {
|
||||
// This is duplicate - there is no concept of defaults - these settings must be on.
|
||||
$settings = array(
|
||||
'activities',
|
||||
'blocks',
|
||||
'filters',
|
||||
'questionbank'
|
||||
);
|
||||
self::force_enable_settings($controller, $settings);
|
||||
};
|
||||
|
||||
// Add some dependencies.
|
||||
$plan = $controller->get_plan();
|
||||
@ -233,6 +245,30 @@ abstract class restore_controller_dbops extends restore_dbops {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn these settings on. No defaults from admin settings.
|
||||
*
|
||||
* @param restore_controller $controller
|
||||
* @param array $settings a map from admin config names to setting names (Config name => Setting name)
|
||||
*/
|
||||
private static function force_enable_settings(restore_controller $controller, array $settings) {
|
||||
$plan = $controller->get_plan();
|
||||
foreach ($settings as $config => $settingname) {
|
||||
$value = true;
|
||||
if ($plan->setting_exists($settingname)) {
|
||||
$setting = $plan->get_setting($settingname);
|
||||
// We do not allow this setting to be locked for a duplicate function.
|
||||
if ($setting->get_status() !== base_setting::NOT_LOCKED) {
|
||||
$setting->set_status(base_setting::NOT_LOCKED);
|
||||
}
|
||||
$setting->set_value($value);
|
||||
$setting->set_status(base_setting::LOCKED_BY_CONFIG);
|
||||
} else {
|
||||
$controller->log('Unknown setting: ' . $settingname, BACKUP::LOG_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the controller settings default values from the admin config.
|
||||
*
|
||||
|
@ -14,6 +14,10 @@ Feature: Duplicate activities
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And I log in as "admin"
|
||||
And I set the following administration settings values:
|
||||
| backup_import_activities | 0 |
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Database" to section "1" and I fill the form with:
|
||||
|
Loading…
x
Reference in New Issue
Block a user