mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Compare commits
4 Commits
126e672d84
...
dc27f0f783
Author | SHA1 | Date | |
---|---|---|---|
|
dc27f0f783 | ||
|
69548a5c12 | ||
|
5b71b31040 | ||
|
fadfec264b |
@ -14,6 +14,7 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
use SilverStripe\Control\HTTPResponse;
|
use SilverStripe\Control\HTTPResponse;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Forms\Form;
|
use SilverStripe\Forms\Form;
|
||||||
use SilverStripe\i18n\i18n;
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\ORM\ArrayList;
|
use SilverStripe\ORM\ArrayList;
|
||||||
@ -421,7 +422,9 @@ JS
|
|||||||
// Include any parsed merge field references from the CMS editor - this is already escaped
|
// Include any parsed merge field references from the CMS editor - this is already escaped
|
||||||
// This string substitution works for both HTML and plain text emails.
|
// This string substitution works for both HTML and plain text emails.
|
||||||
// $recipient->getEmailBodyContent() will retrieve the relevant version of the email
|
// $recipient->getEmailBodyContent() will retrieve the relevant version of the email
|
||||||
$emailData['Body'] = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields);
|
$emailData['Body'] = Deprecation::withSuppressedNotice(
|
||||||
|
fn () => SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields)
|
||||||
|
);
|
||||||
// only include visible fields if recipient visibility flag is set
|
// only include visible fields if recipient visibility flag is set
|
||||||
if ((bool) $recipient->HideInvisibleFields) {
|
if ((bool) $recipient->HideInvisibleFields) {
|
||||||
$emailData['Fields'] = $visibleSubmittedFields;
|
$emailData['Fields'] = $visibleSubmittedFields;
|
||||||
@ -487,10 +490,14 @@ JS
|
|||||||
if ($submittedFormField && trim($submittedFormField->Value ?? '')) {
|
if ($submittedFormField && trim($submittedFormField->Value ?? '')) {
|
||||||
$email->setSubject($submittedFormField->Value);
|
$email->setSubject($submittedFormField->Value);
|
||||||
} else {
|
} else {
|
||||||
$email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields));
|
$email->setSubject(Deprecation::withSuppressedNotice(
|
||||||
|
fn () => SSViewer::execute_string($recipient->EmailSubject, $mergeFields)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$email->setSubject(SSViewer::execute_string($recipient->EmailSubject, $mergeFields));
|
$email->setSubject(Deprecation::withSuppressedNotice(
|
||||||
|
fn () => SSViewer::execute_string($recipient->EmailSubject, $mergeFields)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->extend('updateEmail', $email, $recipient, $emailData);
|
$this->extend('updateEmail', $email, $recipient, $emailData);
|
||||||
|
@ -33,32 +33,32 @@ class UserFormsColumnCleanTask extends MigrationTask
|
|||||||
$schema = DataObject::getSchema();
|
$schema = DataObject::getSchema();
|
||||||
|
|
||||||
foreach ($this->tables as $db) {
|
foreach ($this->tables as $db) {
|
||||||
|
$table = $schema->tableName($db);
|
||||||
$columns = $schema->databaseFields($db);
|
$columns = $schema->databaseFields($db);
|
||||||
$query = "SHOW COLUMNS FROM $db";
|
$query = "SHOW COLUMNS FROM $table";
|
||||||
$liveColumns = DB::query($query)->column();
|
$liveColumns = DB::query($query)->column();
|
||||||
$backedUp = 0;
|
$query = "SHOW TABLES LIKE 'Backup_$table'";
|
||||||
$query = "SHOW TABLES LIKE 'Backup_$db'";
|
|
||||||
$tableExists = DB::query($query)->value();
|
$tableExists = DB::query($query)->value();
|
||||||
if ($tableExists != null) {
|
if ($tableExists != null) {
|
||||||
echo "Tasks run already on $db exiting";
|
echo "Tasks run already on $table exiting";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$backedUp = 0;
|
$backedUp = false;
|
||||||
foreach ($liveColumns as $index => $column) {
|
foreach ($liveColumns as $column) {
|
||||||
if ($backedUp == 0) {
|
if (!$backedUp) {
|
||||||
echo "Backing up $db <br />";
|
echo "Backing up $table <br />";
|
||||||
echo "Creating Backup_$db <br />";
|
echo "Creating Backup_$table <br />";
|
||||||
// backup table
|
// backup table
|
||||||
$query = "CREATE TABLE Backup_$db LIKE $db";
|
$query = "CREATE TABLE Backup_$table LIKE $table";
|
||||||
DB::query($query);
|
DB::query($query);
|
||||||
echo "Populating Backup_$db <br />";
|
echo "Populating Backup_$table <br />";
|
||||||
$query = "INSERT Backup_$db SELECT * FROM $db";
|
$query = "INSERT Backup_$table SELECT * FROM $table";
|
||||||
DB::query($query);
|
DB::query($query);
|
||||||
$backedUp = 1;
|
$backedUp = true;
|
||||||
}
|
}
|
||||||
if (!isset($columns[$column]) && !in_array($column, $this->keepColumns ?? [])) {
|
if (!isset($columns[$column]) && !in_array($column, $this->keepColumns ?? [])) {
|
||||||
echo "Dropping $column from $db <br />";
|
echo "Dropping $column from $table <br />";
|
||||||
$query = "ALTER TABLE $db DROP COLUMN $column";
|
$query = "ALTER TABLE $table DROP COLUMN $column";
|
||||||
DB::query($query);
|
DB::query($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user