diff --git a/README b/README index 262ca4b..eedbdbf 100644 --- a/README +++ b/README @@ -12,7 +12,7 @@ Sean Harvey (Nickname: sharvey, halkyon) Requirements ----------------------------------------------- -SilverStripe 2.3.2+ +SilverStripe 2.4.0+ Documentation ----------------------------------------------- diff --git a/code/UserDefinedForm.php b/code/UserDefinedForm.php index 664cd4b..8903745 100755 --- a/code/UserDefinedForm.php +++ b/code/UserDefinedForm.php @@ -115,11 +115,8 @@ class UserDefinedForm extends Page { */ public function doPublish() { // remove fields on the live table which could have been orphaned. - 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"); - } + $live = Versioned::get_by_stage("EditableFormField", "Live", "\"EditableFormField\".\"ParentID\" = $this->ID"); + if($live) { foreach($live as $field) { $field->deleteFromStage('Live'); diff --git a/code/editor/EditableMultipleOptionField.php b/code/editor/EditableMultipleOptionField.php index a170dc2..5febc2f 100644 --- a/code/editor/EditableMultipleOptionField.php +++ b/code/editor/EditableMultipleOptionField.php @@ -31,11 +31,8 @@ class EditableMultipleOptionField extends EditableFormField { * @return void */ public function publish($fromStage, $toStage, $createNewVersion = false) { - 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"); - } + $live = Versioned::get_by_stage("EditableOption", "Live", "\"EditableOption\".\"ParentID\" = $this->ID"); + if($live) { foreach($live as $option) { $option->delete(); diff --git a/code/editor/FieldEditor.php b/code/editor/FieldEditor.php index 3944d55..0aa7291 100755 --- a/code/editor/FieldEditor.php +++ b/code/editor/FieldEditor.php @@ -48,8 +48,8 @@ class FieldEditor extends FormField { */ function Fields() { Requirements::css("userforms/css/FieldEditor.css"); - Requirements::javascript("jsparty/jquery/ui/ui.core.js"); - Requirements::javascript("jsparty/jquery/ui/ui.sortable.js"); + Requirements::javascript(SAPPHIRE_DIR ."/thirdparty/jquery-ui/ui.core.js"); + Requirements::javascript(SAPPHIRE_DIR ."/thirdparty/jquery-ui/ui.sortable.js"); Requirements::javascript("userforms/javascript/UserForm.js"); // Don't return any fields unless we actually have the dependent parameters set on the form field @@ -178,14 +178,10 @@ class FieldEditor extends FormField { $parentID = $this->form->getRecord()->ID; if($parentID) { - $parentID = Convert::raw2sql($parentID); // who knows what could happen - - 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'"); - } + $parentID = Convert::raw2sql($parentID); + $highestSort = DB::query("SELECT MAX(\"Sort\") FROM \"EditableFormField\" WHERE \"ParentID\" = '$parentID'"); + $sort = $highestSort->value() + 1; $className = (isset($_REQUEST['Type'])) ? $_REQUEST['Type'] : ''; @@ -218,12 +214,8 @@ class FieldEditor extends FormField { if($parent) { $sql_parent = Convert::raw2sql($parent); - 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'"); - } - + $highestSort = DB::query("SELECT MAX(\"Sort\") FROM \"EditableOption\" WHERE \"ParentID\" = '$sql_parent'"); + $sort = $highestSort->value() + 1; if($parent) { diff --git a/code/submissions/SubmittedFormReportField.php b/code/submissions/SubmittedFormReportField.php index a66c754..7855ba2 100755 --- a/code/submissions/SubmittedFormReportField.php +++ b/code/submissions/SubmittedFormReportField.php @@ -82,11 +82,7 @@ class SubmittedFormReportField extends FormField { // Get the CSV header rows from the database - 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`"); - } + $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\""); // Sort the Names and Titles from the database query into separate keyed arrays foreach($tmp as $array) { @@ -137,8 +133,8 @@ class SubmittedFormReportField extends FormField { user_error("No submissions to export.", E_USER_ERROR); } - if(class_exists('SS_HTTPRequest')) SS_HTTPRequest::send_file($csvData, $fileName)->output(); - else HTTPRequest::send_file($csvData, $fileName)->output(); + SS_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); }