From f77bdcc6364a0634a126c9cbd1c074006737fa2e Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 1 Jul 2004 19:44:55 +0000 Subject: [PATCH] Added support to timeopen, timeclose, release and allowupdate in backup and restore procedure. Added some special checks to mantain backwards compatibility whith pre-1.4 backup files, because the meaning of some settings has changed just now. (I've applied the same differences executed in the upgrade process). :-) --- mod/choice/backuplib.php | 4 ++++ mod/choice/restorelib.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/mod/choice/backuplib.php b/mod/choice/backuplib.php index 7dfcdfb2e7..a3d3115c39 100644 --- a/mod/choice/backuplib.php +++ b/mod/choice/backuplib.php @@ -46,7 +46,11 @@ fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5)); fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6)); fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered)); + fwrite ($bf,full_tag("TIMEOPEN",4,false,$choice->timeopen)); + fwrite ($bf,full_tag("TIMECLOSE",4,false,$choice->timeclose)); fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish)); + fwrite ($bf,full_tag("RELEASE",4,false,$choice->release)); + fwrite ($bf,full_tag("ALLOWUPDATE",4,false,$choice->allowupdate)); fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified)); //if we've selected to backup users info, then execute backup_choice_answers if ($preferences->mods["choice"]->userinfo) { diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index c817bf5005..2d0f3bd533 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -50,9 +50,30 @@ $choice->answer5 = backup_todb($info['MOD']['#']['ANSWER5']['0']['#']); $choice->answer6 = backup_todb($info['MOD']['#']['ANSWER6']['0']['#']); $choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']); + $choice->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']); + $choice->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']); $choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']); + $choice->release = backup_todb($info['MOD']['#']['RELEASE']['0']['#']); + $choice->allowupdate = backup_todb($info['MOD']['#']['ALLOWUPDATE']['0']['#']); $choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); + //To mantain compatibilty, in 1.4 the publish setting meaning has changed. We + //have to modify some things it if the release field isn't present in the backup file. + if (! isset($info['MOD']['#']['RELEASE']['0']['#'])) { //It's a pre-14 backup filea + //Set the allowupdate field + if ($choice->publish == 0) { + $choice->allowupdate = 1; + } + //Set the release field as defined by the old publish field + if ($choice->publish > 0) { + $choice->release = 1; + } + //Recode the publish field to its 1.4 meaning + if ($choice->publish > 0) { + $choice->publish--; + } + } + //The structure is equal to the db, so insert the choice $newid = insert_record ("choice",$choice); -- 2.39.5