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). :-)
This commit is contained in:
stronk7
2004-07-01 19:44:55 +00:00
parent 8791a831f4
commit f77bdcc636
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -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) {
+21
View File
@@ -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);