From 8528bf260b69aae7744cb60e52700dd7e89139dc Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 20 Apr 2008 10:09:28 +0000 Subject: [PATCH] MDL-12861 overriding of database settings now optional when using presets; merged from MOODLE_19_STABLE --- lang/en_utf8/data.php | 1 + mod/data/lib.php | 29 +++++++++++++++++++++++------ mod/data/styles.php | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lang/en_utf8/data.php b/lang/en_utf8/data.php index 88449126bc..b7f2b772b0 100644 --- a/lang/en_utf8/data.php +++ b/lang/en_utf8/data.php @@ -180,6 +180,7 @@ $string['optionaldescription'] = 'Short description (optional)'; $string['optionalfilename'] = 'Filename (optional)'; $string['other'] = 'Other'; $string['overwrite'] = 'Overwrite'; +$string['overwritesettings'] = 'Overwrite current settings'; $string['pagesize'] = 'Entries per page'; $string['participants'] = 'Participants'; $string['picture'] = 'Picture'; diff --git a/mod/data/lib.php b/mod/data/lib.php index 5b45eb231b..da29b6dadf 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1994,8 +1994,8 @@ class PresetImporter { list($settings, $newfields, $currentfields) = $this->get_settings(); - echo '
'; - echo '
'; + echo '
'; + echo '
'; echo ''; echo ''; echo ''; @@ -2031,11 +2031,15 @@ class PresetImporter { } echo ''; echo "

$strwarning

"; - } - else if (empty($newfields)) { + + } else if (empty($newfields)) { error("New preset has no defined fields!"); } - echo '
'; + + echo '
'; + echo '
'; + + echo ''; } @@ -2045,6 +2049,8 @@ class PresetImporter { list($settings, $newfields, $currentfields) = $this->get_settings(); $preservedfields = array(); + $overwritesettings = optional_param('overwritesettings', 0, PARAM_BOOL); + /* Maps fields and makes new ones */ if (!empty($newfields)) { /* We require an injective mapping, and need to know what to protect */ @@ -2109,9 +2115,20 @@ class PresetImporter { } } + // do we want to overwrite current database settings? + if ($overwritesettings) { + // all settings + $overwrite = array_keys((array)$settings); + } else { + // only templates + $overwrite = array('singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter', + 'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate', 'jstemplate', + 'asearchtemplate'); + } + // existing values MUST be sent too - it can not work without them! foreach ($this->data as $prop=>$unused) { - if (array_key_exists($prop, (array)$settings)) { + if (in_array($prop, $overwrite)) { $this->data->$prop = $settings->$prop; } } diff --git a/mod/data/styles.php b/mod/data/styles.php index 88997fd356..6f64125fbd 100644 --- a/mod/data/styles.php +++ b/mod/data/styles.php @@ -2,6 +2,20 @@ text-align: right; } +#mod-data-preset .presetmapping { + text-align: center; +} + +#mod-data-preset .presetmapping table { + text-align: left; + margin-left: auto; + margin-right: auto; +} + +#mod-data-preset .overwritesettings { + margin-bottom: 1em; +} + .mod-data-field .c0 { text-align: right; } -- 2.39.5