mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUGFIX: Updated module to support 2.4 API changes
This commit is contained in:
parent
97e49b296f
commit
2ca993b7c4
@ -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'");
|
||||
|
@ -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");
|
||||
|
@ -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'");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user