From 6b76bc641a8855372291b541e2e2fffdf2aaef5c Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 10 Apr 2017 23:15:32 +1200 Subject: [PATCH 01/10] FIX Ensure field GridField has a 100% relative width rather than fixed --- javascript/FieldEditor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/FieldEditor.js b/javascript/FieldEditor.js index 6d998d4..5e9b14e 100644 --- a/javascript/FieldEditor.js +++ b/javascript/FieldEditor.js @@ -47,8 +47,8 @@ // Make sure gridfield buttons stick to top of page when user scrolls down stickyHeaderInterval = setInterval(function () { var offsetTop = fieldEditor.offset().top; - $buttonrow.width(self.width()); - if (offsetTop > navHeight || offsetTop === 0) { + $buttonrow.width('100%'); + if (offsetTop > navHeight || offsetTop === 0) { $buttonrow.removeClass('stickyButtons'); } else { $buttonrow.addClass('stickyButtons'); From dcc821f3c612cdff59f33b460df91ea187973727 Mon Sep 17 00:00:00 2001 From: Michael van Schaik Date: Tue, 14 Mar 2017 06:10:27 +0100 Subject: [PATCH 02/10] Update UserFormRecipientItemRequest::preview to use theme-templates Fixes #556 --- code/model/recipients/UserFormRecipientItemRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index 171efb4..cbd2341 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -20,6 +20,9 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest */ public function preview() { + // Enable theme for preview (may be needed for Shortcodes) + Config::inst()->update('SSViewer', 'theme_enabled', true); + return $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, From 091997027b95901d1a430230b3426b4426aef6e2 Mon Sep 17 00:00:00 2001 From: Michael van Schaik Date: Fri, 2 Jun 2017 09:17:39 +0200 Subject: [PATCH 03/10] Adding back previous value for SSViewer::theme_enabled --- code/model/recipients/UserFormRecipientItemRequest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index cbd2341..1d9e494 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -21,13 +21,19 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest public function preview() { // Enable theme for preview (may be needed for Shortcodes) + $previous_theme_enabled = Config::inst()->get('SSViewer', 'theme_enabled'); Config::inst()->update('SSViewer', 'theme_enabled', true); - return $this->customise(new ArrayData(array( + $ret = $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, 'Fields' => $this->getPreviewFieldData() )))->renderWith($this->record->EmailTemplate); + + // reset theme preview value + Config::inst()->update('SSViewer', 'theme_enabled', $previous_theme_enabled); + + return $ret; } /** From c02181e69b4b7b060ac17959d52bf45255769f5e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 9 Jun 2017 10:19:58 +1200 Subject: [PATCH 04/10] FIX Use configuration nesting wrapper around themed preview logic --- .../recipients/UserFormRecipientItemRequest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/code/model/recipients/UserFormRecipientItemRequest.php b/code/model/recipients/UserFormRecipientItemRequest.php index 1d9e494..777e92a 100644 --- a/code/model/recipients/UserFormRecipientItemRequest.php +++ b/code/model/recipients/UserFormRecipientItemRequest.php @@ -21,19 +21,18 @@ class UserFormRecipientItemRequest extends GridFieldDetailForm_ItemRequest public function preview() { // Enable theme for preview (may be needed for Shortcodes) - $previous_theme_enabled = Config::inst()->get('SSViewer', 'theme_enabled'); + Config::nest(); Config::inst()->update('SSViewer', 'theme_enabled', true); - - $ret = $this->customise(new ArrayData(array( + + $content = $this->customise(new ArrayData(array( 'Body' => $this->record->getEmailBodyContent(), 'HideFormData' => $this->record->HideFormData, 'Fields' => $this->getPreviewFieldData() )))->renderWith($this->record->EmailTemplate); - - // reset theme preview value - Config::inst()->update('SSViewer', 'theme_enabled', $previous_theme_enabled); - - return $ret; + + Config::unnest(); + + return $content; } /** From 5ad7767ead3933d01a9bb839559681efae03f386 Mon Sep 17 00:00:00 2001 From: Cam Findlay Date: Sat, 17 Jun 2017 12:34:15 +1200 Subject: [PATCH 05/10] ENHANCEMENT Display and export the submitter email --- code/model/UserDefinedForm.php | 1 + code/model/submissions/SubmittedForm.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 4b7f3aa..c587913 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -232,6 +232,7 @@ SQL; // attach every column to the print view form $columns['Created'] = 'Created'; + $columns['SubmittedBy.Email'] = 'Submitter'; $filter->setColumns($columns); // print configuration diff --git a/code/model/submissions/SubmittedForm.php b/code/model/submissions/SubmittedForm.php index f026509..7e8ec61 100755 --- a/code/model/submissions/SubmittedForm.php +++ b/code/model/submissions/SubmittedForm.php @@ -57,7 +57,23 @@ class SubmittedForm extends DataObject $this->beforeUpdateCMSFields(function ($fields) use ($self) { $fields->removeByName('Values'); - $fields->dataFieldByName('SubmittedByID')->setDisabled(true); + + //check to ensure there is a Member to extract an Email from else null value + if($self->SubmittedBy() && $self->SubmittedBy()->exists()){ + $submitter = $self->SubmittedBy()->Email; + } else { + $submitter = null; + } + + //replace scaffolded field with readonly submitter + $fields->replaceField( + 'SubmittedByID', + ReadonlyField::create( + 'Submitter', + 'Submitter', + $submitter + ) + ); $values = new GridField( 'Values', From d88ce281742833205401e1df366a834a8178c61d Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 20 Jun 2017 15:35:36 +1200 Subject: [PATCH 06/10] FIX Pass submissions GridFieldConfig to GridField constructor to avoid error in state This framework bug causes the submissions GridField to lose the filter context when exporting as CSV. Passing the config directly to the GridField constructor allows the state to be set containing the config, where setting it after construction will lose this context. This will be fixed in SS 3.5.x and 3.6.x core releases, but this fix patches it for userforms anyway. --- code/model/UserDefinedForm.php | 45 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 98ee0ab..0c8ea2e 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -118,14 +118,13 @@ class UserDefinedForm extends Page /** * @return FieldList */ - public function getCMSFields() - { - Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css'); + public function getCMSFields() + { + Requirements::css(USERFORMS_DIR . '/css/UserForm_cms.css'); - $self = $this; - - $this->beforeUpdateCMSFields(function ($fields) use ($self) { + $self = $this; + $this->beforeUpdateCMSFields(function ($fields) use ($self) { // define tabs $fields->findOrMakeTab('Root.FormOptions', _t('UserDefinedForm.CONFIGURATION', 'Configuration')); $fields->findOrMakeTab('Root.Recipients', _t('UserDefinedForm.RECIPIENTS', 'Recipients')); @@ -167,12 +166,6 @@ class UserDefinedForm extends Page // view the submissions - $submissions = new GridField( - 'Submissions', - _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), - $self->Submissions()->sort('Created', 'DESC') - ); - // make sure a numeric not a empty string is checked against this int column for SQL server $parentID = (!empty($self->ID)) ? (int) $self->ID : 0; @@ -229,23 +222,33 @@ SQL; $export->setCsvHasHeader(true); $export->setExportColumns($columns); - $submissions->setConfig($config); + $submissions = GridField::create( + 'Submissions', + _t('UserDefinedForm.SUBMISSIONS', 'Submissions'), + $self->Submissions()->sort('Created', 'DESC'), + $config + ); $fields->addFieldToTab('Root.Submissions', $submissions); - $fields->addFieldToTab('Root.FormOptions', new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server'))); - + $fields->addFieldToTab( + 'Root.FormOptions', + CheckboxField::create( + 'DisableSaveSubmissions', + _t('UserDefinedForm.SAVESUBMISSIONS', 'Disable Saving Submissions to Server') + ) + ); }); - $fields = parent::getCMSFields(); + $fields = parent::getCMSFields(); - if ($this->EmailRecipients()->Count() == 0 && static::config()->recipients_warning_enabled) { - $fields->addFieldToTab("Root.Main", new LiteralField("EmailRecipientsWarning", + if ($this->EmailRecipients()->Count() == 0 && static::config()->recipients_warning_enabled) { + $fields->addFieldToTab("Root.Main", new LiteralField("EmailRecipientsWarning", "

" . _t("UserDefinedForm.NORECIPIENTS", "Warning: You have not configured any recipients. Form submissions may be missed.") . "

"), "Title"); - } + } - return $fields; - } + return $fields; + } /** * Allow overriding the EmailRecipients on a {@link DataExtension} From f24af09f00b32e2fb7e22c2bbdf4349be35fdb24 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 21 Jun 2017 14:14:17 +1200 Subject: [PATCH 07/10] Use get_by_id on display rules model loads to ensure they get cached --- code/model/UserDefinedForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 98ee0ab..f808fc3 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -455,7 +455,7 @@ class UserDefinedForm_Controller extends Page_Controller foreach ($field->EffectiveDisplayRules() as $rule) { // Get the field which is effected - $formFieldWatch = EditableFormField::get()->byId($rule->ConditionFieldID); + $formFieldWatch = DataObject::get_by_id('EditableFormField', $rule->ConditionFieldID); // Skip deleted fields if (!$formFieldWatch) { From 683ee14428b70358b327dbbd1002463c31008232 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 21 Jun 2017 15:42:18 +1200 Subject: [PATCH 08/10] FIX Preview recipient email link for SS 3.6 --- code/model/recipients/UserDefinedForm_EmailRecipient.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/model/recipients/UserDefinedForm_EmailRecipient.php b/code/model/recipients/UserDefinedForm_EmailRecipient.php index 79110f3..1636492 100644 --- a/code/model/recipients/UserDefinedForm_EmailRecipient.php +++ b/code/model/recipients/UserDefinedForm_EmailRecipient.php @@ -221,14 +221,17 @@ class UserDefinedForm_EmailRecipient extends DataObject 'The email address which the recipient is able to \'reply\' to.' )) )); - + $fields->fieldByName('Root.EmailDetails')->setTitle(_t('UserDefinedForm_EmailRecipient.EMAILDETAILSTAB', 'Email Details')); // Only show the preview link if the recipient has been saved. if (!empty($this->EmailTemplate)) { $preview = sprintf( '

%s

%s', - "admin/pages/edit/EditForm/field/EmailRecipients/item/{$this->ID}/preview", + Controller::join_links( + singleton('CMSPageEditController')->getEditForm()->FormAction(), + "field/EmailRecipients/item/{$this->ID}/preview" + ), _t('UserDefinedForm.PREVIEW_EMAIL', 'Preview email'), _t('UserDefinedForm.PREVIEW_EMAIL_DESCRIPTION', 'Note: Unsaved changes will not appear in the preview.') ); From e0acfbdefb65586e9ca6d1caf6873c822b697f31 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 15 Jun 2017 11:45:07 +1200 Subject: [PATCH 09/10] Add PHP7 + SS3.6 build to Travis configuration --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a695d7..9f1d072 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details +# See https://github.com/silverstripe/silverstripe-travis-support for setup details sudo: false @@ -14,9 +14,11 @@ matrix: env: DB=MYSQL CORE_RELEASE=3 - php: 5.6 env: DB=MYSQL CORE_RELEASE=3.5 SECUREASSETS=1 + - php: 7.1 + env: DB=MYSQL CORE_RELEASE=3.6 before_script: - - git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support + - git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support - "if [ \"$SECUREASSETS\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi" - "if [ \"$SECUREASSETS\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/secureassets; fi" - cd ~/builds/ss From 3ea5c7a4fab979ebb79914870547cee7e0930aa8 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 22 Jun 2017 17:41:27 +1200 Subject: [PATCH 10/10] Update minimum required framework/cms version to 3.2 UserFormsUpgradeService uses DB::get_schema() which was introduced in framework 3.2 as part of the database abstraction overhaul. This now ensures the module requires at least that version. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1ffde3c..930e378 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,8 @@ } ], "require": { - "silverstripe/framework": "~3.1", - "silverstripe/cms": "~3.1", + "silverstripe/framework": "~3.2", + "silverstripe/cms": "~3.2", "silverstripe-australia/gridfieldextensions": "~1.1", "silverstripe/segment-field": "^1.0" },