backup MDL-22142 P13 - File name is now given default value and correctly sized
This commit is contained in:
@@ -49,7 +49,7 @@ class backup_root_task extends backup_task {
|
||||
|
||||
// Define filename setting
|
||||
$filename = new backup_filename_setting('filename', base_setting::IS_FILENAME, 'backup.zip');
|
||||
$filename->set_ui(get_string('filename', 'backup'), 'backup.zip');
|
||||
$filename->set_ui(get_string('filename', 'backup'), '', array('size'=>50));
|
||||
$this->add_setting($filename);
|
||||
|
||||
// Define users setting (keeping it on hand to define dependencies)
|
||||
|
||||
@@ -345,6 +345,41 @@ class backup_ui {
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
/**
|
||||
* Gets the format for the backup
|
||||
* @return int
|
||||
*/
|
||||
public function get_backup_format() {
|
||||
return $this->controller->get_format();
|
||||
}
|
||||
/**
|
||||
* Gets the type of the backup
|
||||
* @return int
|
||||
*/
|
||||
public function get_backup_type() {
|
||||
return $this->controller->get_type();
|
||||
}
|
||||
/**
|
||||
* Gets the ID used in creating the controller. Relates to course/section/cm
|
||||
* @return int
|
||||
*/
|
||||
public function get_controller_id() {
|
||||
return $this->controller->get_id();
|
||||
}
|
||||
/**
|
||||
* Gets the value for the requested setting
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_setting_value($name, $default = false) {
|
||||
try {
|
||||
return $this->controller->get_plan()->get_setting($name)->get_value();
|
||||
} catch (Exception $e) {
|
||||
debugging('Failed to find the setting: '.$name, DEBUG_DEVELOPER);
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,6 +152,9 @@ abstract class backup_setting_ui extends base_setting_ui {
|
||||
* @return array
|
||||
*/
|
||||
public function apply_options(array $properties) {
|
||||
if (!empty($this->options['size'])) {
|
||||
$properties['attributes']['size'] = $this->options['size'];
|
||||
}
|
||||
return $properties;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -427,6 +427,15 @@ class backup_ui_stage_confirmation extends backup_ui_stage {
|
||||
if ($setting->get_name() != 'filename') {
|
||||
$form->add_fixed_setting($setting);
|
||||
} else {
|
||||
$value = $setting->get_value();
|
||||
if (empty($value)) {
|
||||
$format = $this->ui->get_backup_format();
|
||||
$type = $this->ui->get_backup_type();
|
||||
$id = $this->ui->get_controller_id();
|
||||
$users = $this->ui->get_setting_value('users');
|
||||
$anonymised = $this->ui->get_setting_value('anonymize');
|
||||
$setting->set_value(backup_plan_dbops::get_default_backup_filename($format, $type, $id, $users, $anonymised));
|
||||
}
|
||||
$form->add_setting($setting, $task);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user