mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
BUGFIX Fixed userforms SQL to work with ANSI compatibility turned on
This commit is contained in:
parent
5588646af3
commit
7529460e80
@ -473,9 +473,15 @@ JS
|
||||
// a user selected
|
||||
if($recipient->SendEmailFromFieldID) {
|
||||
$name = Convert::raw2sql($recipient->SendEmailFromField()->Name);
|
||||
$SubmittedFormField = DataObject::get_one("SubmittedFormField", "Name = '$name' AND ParentID = '$submittedForm->ID'");
|
||||
if($SubmittedFormField) {
|
||||
$email->setTo($SubmittedFormField->Value);
|
||||
|
||||
if(defined('Database::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'");
|
||||
}
|
||||
|
||||
if($submittedFormField) {
|
||||
$email->setTo($submittedFormField->Value);
|
||||
}
|
||||
}
|
||||
$email->send();
|
||||
|
@ -86,9 +86,7 @@ class FieldEditor extends FormField {
|
||||
* @param DataObject Record to Save it In
|
||||
*/
|
||||
function saveInto(DataObject $record) {
|
||||
|
||||
$name = $this->name;
|
||||
|
||||
$fieldSet = $record->$name();
|
||||
|
||||
// @todo shouldn't we deal with customFormActions on that object?
|
||||
@ -100,16 +98,22 @@ class FieldEditor extends FormField {
|
||||
// alternatively, we could delete all the fields and re add them
|
||||
$missingFields = array();
|
||||
|
||||
foreach($fieldSet as $existingField){
|
||||
$missingFields[$existingField->ID] = $existingField;
|
||||
}
|
||||
|
||||
if($_REQUEST[$name]){
|
||||
foreach( array_keys( $_REQUEST[$name] ) as $newEditableID ) {
|
||||
$newEditableData = $_REQUEST[$name][$newEditableID];
|
||||
|
||||
$editable = DataObject::get_one('EditableFormField', "(`ParentID`='{$record->ID}' OR `ParentID`=0) AND `EditableFormField`.`ID`='$newEditableID'" );
|
||||
foreach($fieldSet as $existingField) {
|
||||
$missingFields[$existingField->ID] = $existingField;
|
||||
}
|
||||
|
||||
if($_REQUEST[$name]) {
|
||||
foreach(array_keys($_REQUEST[$name]) as $newEditableID) {
|
||||
if(!is_numeric($newEditableID)) continue;
|
||||
|
||||
$newEditableData = $_REQUEST[$name][$newEditableID];
|
||||
|
||||
if(defined('Database::USE_ANSI_SQL')) {
|
||||
$editable = DataObject::get_one('EditableFormField', "(\"ParentID\" = '{$record->ID}' OR \"ParentID\" = '0') AND \"EditableFormField\".\"ID\" = '$newEditableID'");
|
||||
} else {
|
||||
$editable = DataObject::get_one('EditableFormField', "(`ParentID` = '{$record->ID}' OR `ParentID` = 0) AND `EditableFormField`.`ID`='$newEditableID'" );
|
||||
}
|
||||
|
||||
// check if we are updating an existing field. One odd thing is a 'deleted' field
|
||||
// still exists in the post data (ID) so we need to check for type.
|
||||
if($editable && isset($missingFields[$editable->ID]) && isset($newEditableData['Type'])) {
|
||||
@ -154,7 +158,13 @@ class FieldEditor extends FormField {
|
||||
|
||||
if($parentID) {
|
||||
$parentID = Convert::raw2sql($parentID); // who knows what could happen
|
||||
$highestSort = DB::query("SELECT MAX(Sort) FROM EditableFormField WHERE ParentID = '$parentID'");
|
||||
|
||||
if(defined('Database::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'");
|
||||
}
|
||||
|
||||
$sort = $highestSort->value() + 1;
|
||||
|
||||
$className = (isset($_REQUEST['Type'])) ? $_REQUEST['Type'] : '';
|
||||
@ -185,7 +195,13 @@ class FieldEditor extends FormField {
|
||||
// work out the sort by getting the sort of the last field in the form +1
|
||||
if($parent) {
|
||||
$sql_parent = Convert::raw2sql($parent);
|
||||
$highestSort = DB::query("SELECT MAX(Sort) FROM EditableOption WHERE ParentID = '$sql_parent'");
|
||||
|
||||
if(defined('Database::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'");
|
||||
}
|
||||
|
||||
$sort = $highestSort->value() + 1;
|
||||
|
||||
if($parent) {
|
||||
|
@ -60,7 +60,12 @@ class SubmittedFormReportField extends FormField {
|
||||
}
|
||||
|
||||
// Get the CSV header rows from the database
|
||||
$tmp = DB::query("SELECT DISTINCT Name, Title FROM SubmittedFormField LEFT JOIN SubmittedForm ON SubmittedForm.ID = SubmittedFormField.ParentID WHERE SubmittedFormField.ParentID IN (" . implode(',', $inClause) . ")");
|
||||
|
||||
if(defined('Database::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) . ")");
|
||||
} else {
|
||||
$tmp = DB::query("SELECT DISTINCT Name, Title FROM SubmittedFormField LEFT JOIN SubmittedForm ON SubmittedForm.ID = SubmittedFormField.ParentID WHERE SubmittedFormField.ParentID IN (" . implode(',', $inClause) . ")");
|
||||
}
|
||||
|
||||
// Sort the Names and Titles from the database query into separate keyed arrays
|
||||
foreach($tmp as $array) {
|
||||
|
Loading…
Reference in New Issue
Block a user