diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 15289bc..28401ac 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -115,7 +115,7 @@ class UserDefinedForm extends Page { */ public function doPublish() { // remove fields on the live table which could have been orphaned. - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $live = Versioned::get_by_stage("EditableFormField", "Live", "\"EditableFormField\".\"ParentID\" = $this->ID"); } else { $live = Versioned::get_by_stage("EditableFormField", "Live", "`EditableFormField`.ParentID = $this->ID"); @@ -569,7 +569,7 @@ JS if($recipient->SendEmailFromField()) { $name = Convert::raw2sql($recipient->SendEmailFromField()->Name); - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $submittedFormField = DataObject::get_one("SubmittedFormField", "\"Name\" = '$name' AND \"ParentID\" = '$submittedForm->ID'"); } else { $submittedFormField = DataObject::get_one("SubmittedFormField", "Name = '$name' AND ParentID = '$submittedForm->ID'"); @@ -584,7 +584,7 @@ JS if($recipient->SendEmailToField()) { $name = Convert::raw2sql($recipient->SendEmailToField()->Name); - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $submittedFormField = DataObject::get_one("SubmittedFormField", "\"Name\" = '$name' AND \"ParentID\" = '$submittedForm->ID'"); } else { $submittedFormField = DataObject::get_one("SubmittedFormField", "Name = '$name' AND ParentID = '$submittedForm->ID'"); diff --git a/code/editor/EditableMultipleOptionField.php b/code/editor/EditableMultipleOptionField.php index 156b313..c8743a1 100644 --- a/code/editor/EditableMultipleOptionField.php +++ b/code/editor/EditableMultipleOptionField.php @@ -31,7 +31,7 @@ class EditableMultipleOptionField extends EditableFormField { * @return void */ public function publish($fromStage, $toStage, $createNewVersion = false) { - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $live = Versioned::get_by_stage("EditableOption", "Live", "\"EditableOption\".\"ParentID\" = $this->ID"); } else { $live = Versioned::get_by_stage("EditableOption", "Live", "`EditableOption`.ParentID = $this->ID"); diff --git a/code/editor/FieldEditor.php b/code/editor/FieldEditor.php index c693d69..3944d55 100755 --- a/code/editor/FieldEditor.php +++ b/code/editor/FieldEditor.php @@ -180,7 +180,7 @@ class FieldEditor extends FormField { if($parentID) { $parentID = Convert::raw2sql($parentID); // who knows what could happen - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $highestSort = DB::query("SELECT MAX(\"Sort\") FROM \"EditableFormField\" WHERE \"ParentID\" = '$parentID'"); } else { $highestSort = DB::query("SELECT MAX(Sort) FROM EditableFormField WHERE ParentID = '$parentID'"); @@ -218,7 +218,7 @@ class FieldEditor extends FormField { if($parent) { $sql_parent = Convert::raw2sql($parent); - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $highestSort = DB::query("SELECT MAX(\"Sort\") FROM \"EditableOption\" WHERE \"ParentID\" = '$sql_parent'"); } else { $highestSort = DB::query("SELECT MAX(Sort) FROM EditableOption WHERE ParentID = '$sql_parent'"); diff --git a/code/submissions/SubmittedFormReportField.php b/code/submissions/SubmittedFormReportField.php index 5fb7c2b..8ac93c9 100755 --- a/code/submissions/SubmittedFormReportField.php +++ b/code/submissions/SubmittedFormReportField.php @@ -82,7 +82,7 @@ class SubmittedFormReportField extends FormField { // Get the CSV header rows from the database - if(defined('Database::USE_ANSI_SQL')) { + if(defined('DB::USE_ANSI_SQL')) { $tmp = DB::query("SELECT DISTINCT \"Name\", \"Title\" FROM \"SubmittedFormField\" LEFT JOIN \"SubmittedForm\" ON \"SubmittedForm\".\"ID\" = \"SubmittedFormField\".\"ParentID\" WHERE \"SubmittedFormField\".\"ParentID\" IN (" . implode(',', $inClause) . ") ORDER BY \"SubmittedFormField\".\"ID\""); } else { $tmp = DB::query("SELECT DISTINCT `Name`, `Title` FROM `SubmittedFormField` LEFT JOIN `SubmittedForm` ON `SubmittedForm`.`ID` = `SubmittedFormField`.`ParentID` WHERE `SubmittedFormField`.`ParentID` IN (" . implode(',', $inClause) . ") ORDER BY `SubmittedFormField`.`ID`"); @@ -138,7 +138,8 @@ class SubmittedFormReportField extends FormField { user_error("No submissions to export.", E_USER_ERROR); } - HTTPRequest::send_file($csvData, $fileName)->output(); + if(class_exists('SS_HTTPRequest')) SS_HTTPRequest::send_file($csvData, $fileName)->output(); + else HTTPRequest::send_file($csvData, $fileName)->output(); } else { user_error("'$SQL_ID' is a valid type, but we can't find a UserDefinedForm in the database that matches the ID.", E_USER_ERROR); } diff --git a/tests/UserDefinedFormEditorTest.php b/tests/UserDefinedFormEditorTest.php index 37827f3..2d7f9cf 100644 --- a/tests/UserDefinedFormEditorTest.php +++ b/tests/UserDefinedFormEditorTest.php @@ -22,7 +22,7 @@ class UserDefinedFormEditorTest extends FunctionalTest { $id = $this->form->ID; $this->form->Fields()->add(new EditableFormField()); $this->form->doPublish(); - $whereClause = defined('Database::USE_ANSI_SQL') ? "\"UserDefinedForm_Live\".\"ID\" = $id" : "UserDefinedForm_Live.ID = $id"; + $whereClause = defined('DB::USE_ANSI_SQL') ? "\"UserDefinedForm_Live\".\"ID\" = $id" : "UserDefinedForm_Live.ID = $id"; $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", $whereClause); $this->assertEquals($live->Fields()->Count(), 1); } @@ -32,8 +32,8 @@ class UserDefinedFormEditorTest extends FunctionalTest { $this->form->Fields()->removeAll(); $this->form->Fields()->add(new EditableFormField()); $this->form->doUnPublish(); - $whereClauseStage = defined('Database::USE_ANSI_SQL') ? "\"UserDefinedForm\".\"ID\" = $id" : "UserDefinedForm.ID = $id"; - $whereClauseLive = defined('Database::USE_ANSI_SQL') ? "\"UserDefinedForm_Live\".\"ID\" = $id" : "UserDefinedForm_Live.ID = $id"; + $whereClauseStage = defined('DB::USE_ANSI_SQL') ? "\"UserDefinedForm\".\"ID\" = $id" : "UserDefinedForm.ID = $id"; + $whereClauseLive = defined('DB::USE_ANSI_SQL') ? "\"UserDefinedForm_Live\".\"ID\" = $id" : "UserDefinedForm_Live.ID = $id"; $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", $whereClauseLive); $stage = Versioned::get_one_by_stage("UserDefinedForm", "Stage", $whereClauseStage); $this->assertEquals($live, false);