diff --git a/admin/dumpgroup.php b/admin/dumpgroup.php index d0ffae05cb8..2774bae7135 100644 --- a/admin/dumpgroup.php +++ b/admin/dumpgroup.php @@ -133,9 +133,12 @@ function BuildOutput($Query) $lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type='F' AND gid=$gid"; $ldump = BuildOutput($lquery); +//8: Question Attributes +$query = "SELECT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes, {$dbprefix}questions WHERE {$dbprefix}question_attributes.qid={$dbprefix}questions.qid AND {$dbprefix}questions.sid=$sid AND {$dbprefix}.questions.gid=$gid"; +$qadump = BuildOutput($query); // HTTP/1.0 echo "#
\n"; -echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump; +echo $dumphead, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump, $qadump; echo "#\n"; ?> \ No newline at end of file diff --git a/admin/dumpquestion.php b/admin/dumpquestion.php index 9fe978ed632..9343221336d 100644 --- a/admin/dumpquestion.php +++ b/admin/dumpquestion.php @@ -114,6 +114,9 @@ function BuildOutput($Query) $lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid"; $ldump = BuildOutput($lquery); +//5: Question Attributes +$query = "SELECT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes WHERE {$dbprefix}question_attributes.qid=$qid"; +$qadump = BuildOutput($query); $fn = "question_$qid.sql"; header("Content-Type: application/download"); @@ -124,7 +127,7 @@ function BuildOutput($Query) header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); // HTTP/1.0 echo "#
\n"; -echo $dumphead, $qdump, $adump, $lsdump, $ldump; +echo $dumphead, $qdump, $adump, $lsdump, $ldump, $qadump; echo "#\n"; ?> \ No newline at end of file diff --git a/admin/dumpsurvey.php b/admin/dumpsurvey.php index 562368e8660..700e1d28840 100644 --- a/admin/dumpsurvey.php +++ b/admin/dumpsurvey.php @@ -134,6 +134,10 @@ function BuildOutput($Query) $lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type='F' AND sid=$sid"; $ldump = BuildOutput($lquery); +//8: Question Attributes +$query = "SELECT {$dbprefix}question_attributes.* FROM {$dbprefix}question_attributes, {$dbprefix}questions WHERE {$dbprefix}question_attributes.qid={$dbprefix}questions.qid AND {$dbprefix}questions.sid=$sid"; +$qadump = BuildOutput($query); + $fn = "survey_$sid.sql"; header("Content-Type: application/download"); @@ -145,6 +149,6 @@ function BuildOutput($Query) header("Pragma: no-cache"); // HTTP/1.0 echo "#
\n" - .$dumphead, $sdump, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump + .$dumphead, $sdump, $gdump, $qdump, $adump, $cdump, $lsdump, $ldump, $qadump ."#\n"; ?> \ No newline at end of file diff --git a/admin/importgroup.php b/admin/importgroup.php index 23d2fe3f64b..44e4f64856d 100644 --- a/admin/importgroup.php +++ b/admin/importgroup.php @@ -184,15 +184,36 @@ $bigarray = array_values($bigarray); //LABELS +if (array_search("# QUESTION_ATTRIBUTES TABLE\n", $bigarray)) + { + $stoppoint = array_search("# QUESTION_ATTRIBUTES TABLE\n", $bigarray); + } +elseif (array_search("# QUESTION_ATTRIBUTES TABLE\r\n", $bigarray)) + { + $stoppoint = array_search("# QUESTION_ATTRIBUTES TABLE\r\n", $bigarray); + } +else + { + $stoppoint = count($bigarray)-1; + } +for ($i=0; $i<=$stoppoint+1; $i++) + { + if ($i<$stoppoint-2) {$labelsarray[] = $bigarray[$i];} + unset($bigarray[$i]); + } +$bigarray = array_values($bigarray); + +//LAST LOT (now question_attributes) if (!isset($noconditions) || $noconditions != "Y") { $stoppoint = count($bigarray)-1; for ($i=0; $i<=$stoppoint+1; $i++) { - if ($i<$stoppoint-1) {$labelsarray[] = $bigarray[$i];} + if ($i<$stoppoint-1) {$question_attributesarray[] = $bigarray[$i];} unset($bigarray[$i]); } } +$bigarray = array_values($bigarray); if (isset($grouparray)) {$countgroups = count($grouparray);} if (isset($questionarray)) {$countquestions = count($questionarray);} @@ -200,6 +221,7 @@ if (isset($conditionsarray)) {$countconditions = count($conditionsarray);} if (isset($labelsetsarray)) {$countlabelsets = count($labelsetsarray);} if (isset($labelsarray)) {$countlabels = count($labelsarray);} +if (isset($question_attributesarray)) {$countquestion_attributes = count($question_attributesarray);} else {$countquestion_attributes=0;} $newsid = $_POST["sid"]; @@ -423,6 +445,28 @@ //We've built two arrays along the way - one containing the old SID, GID and QIDs - and their NEW equivalents //and one containing the old 'extended fieldname' and its new equivalent. These are needed to import conditions. +if (isset($question_attributesarray) && $question_attributesarray) {//ONLY DO THIS IF THERE ARE QUESTION_ATTRIBUES + foreach ($question_attributesarray as $qar) { + $fieldorders=convertToArray($qar, "`, `", "(`", "`)"); + $fieldcontents=convertToArray($qar, "', '", "('", "')"); + $newfieldcontents=$fieldcontents; + $oldqid=$fieldcontents[array_search("qid", $fieldorders)]; + foreach ($substitutions as $subs) { + if ($oldqid==$subs[2]) {$newqid=$subs[5];} + } + + $newfieldcontents[array_search("qid", $fieldorders)]=$newqid; + $newfieldcontents[array_search("qaid", $fieldorders)]=""; + + $newvalues="('".implode("', '", $newfieldcontents)."')"; + $insert=str_replace("('".implode("', '", $fieldcontents)."')", $newvalues, $qar); + $insert=str_replace("INTO question_attributes", "INTO {$dbprefix}question_attributes", $insert); + $result=mysql_query($insert) or die ("Couldn't insert question_attribute