Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/BcColumn/config/data/default/BcMail/mail_contents.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,description,sender_1,sender_2,sender_name,subject_user,subject_admin,form_template,mail_template,redirect_url,auth_captcha,widget_area,ssl_on,save_info,publish_begin,publish_end,created,modified
1,"<p>お問い合わせの内容を入力してください。</p>",,,baser company お問い合わせ,【baser company】お問い合わせ頂きありがとうございます。,【baser company】お問い合わせを受け付けました,default,mail_default,/,1,,,1,,,,
id,description,,thanks,unpublish,sender_1,sender_2,sender_name,subject_user,subject_admin,form_template,mail_template,redirect_url,auth_captcha,widget_area,ssl_on,save_info,publish_begin,publish_end,created,modified
1,"<p>お問い合わせの内容を入力してください。</p>",,,,,baser company お問い合わせ,【baser company】お問い合わせ頂きありがとうございます。,【baser company】お問い合わせを受け付けました,default,mail_default,/,1,,,1,,,,
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"id","description","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","<p>このコンテンツはメールフォーム機能により作られており、この文章については管理画面の [お問い合わせ] &rarr; [設定] より更新ができます。また、メールフォームは [コンテンツ管理] よりいくつでも作成することができます。</p>","","","baserCMSサンプル","【baserCMS】お問い合わせ頂きありがとうございます。","【baserCMS】お問い合わせを受け付けました","default","mail_default","/","1","","","1","1","","","",""
"id","description","thanks","unpublish","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","<p>このコンテンツはメールフォーム機能により作られており、この文章については管理画面の [お問い合わせ] &rarr; [設定] より更新ができます。また、メールフォームは [コンテンツ管理] よりいくつでも作成することができます。</p>","<p>お問い合わせ頂きありがとうございました。<br>確認次第、ご連絡させて頂きます。</p>","<p>現在、受付を中止しています。</p>","","","baserCMSサンプル","【baserCMS】お問い合わせ頂きありがとうございます。","【baserCMS】お問い合わせを受け付けました","default","mail_default","/","1","","","1","1","","","",""
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"id","description","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","","","","サンプル","お問い合わせ頂きありがとうございます。","お問い合わせを受け付けました","default","mail_default","/","","","","1","1","","","",""
"id","description","thanks","unpublish","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","","","","","","サンプル","お問い合わせ頂きありがとうございます。","お問い合わせを受け付けました","default","mail_default","/","","","","1","1","","","",""
4 changes: 4 additions & 0 deletions plugins/baser-core/src/View/Helper/BcBaserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
* @method array getMailFormGroupValidErrors(array $mailFields, string $groupValid, array $options = [], bool $distinct = true)
* @method bool isMailFormGroupLastField(ResultSet $mailFields, MailField $currentMailField)
* @method string mailFormLabel(string $fieldName, ?string $text = null, array $options = [])
* @method bool mailFormThanksExists()
* @method void mailFormThanks()
* @method bool mailFormUnpublishExists()
* @method void mailFormUnpublish()
*
* ### BcUploadHelper
* @method void setTableToUpload(string $tableName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,40 @@
</span>
</section>

<section class="bca-section bca-section__mail-thanks">
<label for="MailContentThanksTmp" class="bca-form-table__label -label">
<?php echo $this->BcAdminForm->label('thanks', __d('baser_core', 'メールフォーム送信完了文')) ?>
</label>
<span class="bca-form-table__input-wrap">
<?php
echo $this->BcAdminForm->ckeditor('thanks', [
'editorWidth' => 'auto',
'editorHeight' => '120px',
'editorToolType' => 'simple',
'editorEnterBr' => $editorEnterBr
])
?>
<?php echo $this->BcAdminForm->error('thanks') ?>
</span>
</section>

<section class="bca-section bca-section__mail-unpublish">
<label for="MailContentUnpublishTmp" class="bca-form-table__label -label">
<?php echo $this->BcAdminForm->label('unpublish', __d('baser_core', 'メールフォーム受付中止文')) ?>
</label>
<span class="bca-form-table__input-wrap">
<?php
echo $this->BcAdminForm->ckeditor('unpublish', [
'editorWidth' => 'auto',
'editorHeight' => '120px',
'editorToolType' => 'simple',
'editorEnterBr' => $editorEnterBr
])
?>
<?php echo $this->BcAdminForm->error('unpublish') ?>
</span>
</section>

<div class="section">
<table class="form-table bca-form-table" data-bca-table-type="type2">
<tr>
Expand Down
4 changes: 2 additions & 2 deletions plugins/bc-front/config/data/default/BcMail/mail_contents.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"id","description","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","","","","サンプル","お問い合わせ頂きありがとうございます。","お問い合わせを受け付けました","default","mail_default","/","","","","1","1","","","",""
"id","description","thanks","unpublish","sender_1","sender_2","sender_name","subject_user","subject_admin","form_template","mail_template","redirect_url","auth_captcha","widget_area","ssl_on","save_info","auth_captcha","publish_begin","publish_end","created","modified"
"1","","","","","","サンプル","お問い合わせ頂きありがとうございます。","お問い合わせを受け付けました","default","mail_default","/","","","","1","1","","","",""
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
<h3 class="bs-mail-title-sub"><?php echo __d('baser_core', 'メール送信完了') ?></h3>

<div class="bs-mail-form">
<p><?php echo __d('baser_core', 'お問い合わせ頂きありがとうございました。') ?>
<?php echo __d('baser_core', '確認次第、ご連絡させて頂きます。') ?></p>
<?php if ($this->BcBaser->mailFormThanksExists()): ?>
<?php $this->BcBaser->mailFormThanks() ?>
<?php else: ?>
<p><?php echo __d('baser_core', 'お問い合わせ頂きありがとうございました。') ?>
<?php echo __d('baser_core', '確認次第、ご連絡させて頂きます。') ?></p>
<?php endif ?>
<?php if (!$this->BcBaser->isDebug() && $mailContent->redirect_url): ?>
<p>※<?php echo __d('baser_core', '{0} 秒後にトップページへ自動的に移動します。', 5) ?></p>
<p><a href="<?php echo $mailContent->redirect_url; ?>"><?php echo __d('baser_core', '移動しない場合はコチラをクリックしてください。') ?></a></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@

<h3 class="bs-mail-title-sub"><?php echo __d('baser_core', '受付中止') ?></h3>

<div class="bs-mail-form"><p><?php echo __d('baser_core', '現在、受付を中止しています。') ?></p></div>
<div class="bs-mail-form">
<?php if ($this->BcBaser->mailFormUnpublishExists()): ?>
<?php $this->BcBaser->mailFormUnpublish() ?>
<?php else: ?>
<p><?php echo __d('baser_core', '現在、受付を中止しています。') ?></p>
<?php endif ?>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);

use BaserCore\Database\Migration\BcMigration;

class AddThanksAndUnpublishToMailContents extends BcMigration
{
/**
* Up Method.
* @return void
*/
public function up()
{
$this->table('mail_contents')
->addColumn('thanks', 'text', [
'after' => 'description',
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('unpublish', 'text', [
'after' => 'thanks',
'default' => null,
'limit' => null,
'null' => true,
])
->update();
}

/**
* Down Method.
* @return void
*/
public function down()
{
$this->table('mail_contents')
->removeColumn('thanks')
->removeColumn('unpublish')
->update();
}
}
2 changes: 2 additions & 0 deletions plugins/bc-mail/config/Seeds/MailContentsSeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function run(): void
[
'id' => 1,
'description' => '<p>このコンテンツはメールフォーム機能により作られており、この文章については管理画面の [お問い合わせ] &rarr; [設定] より更新ができます。また、メールフォームは [コンテンツ管理] よりいくつでも作成することができます。</p>',
'thanks' => '<p>お問い合わせ頂きありがとうございました。<br>確認次第、ご連絡させて頂きます。</p>',
'unpublish' => '<p>現在、受付を中止しています。</p>',
'sender_1' => '',
'sender_2' => '',
'sender_name' => 'baserCMSサンプル',
Expand Down
2 changes: 2 additions & 0 deletions plugins/bc-mail/src/Model/Entity/MailContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* Class MailContent
* @property int $id
* @property string $description
* @property string $thanks
* @property string $unpublish
* @property string $sender_1
* @property string $sender_2
* @property string $sender_name
Expand Down
24 changes: 24 additions & 0 deletions plugins/bc-mail/src/Model/Table/MailContentsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@ public function validationDefault(Validator $validator): Validator
]
]);

// thanks
$validator
->scalar('thanks')
->allowEmptyString('thanks')
->add('thanks', [
'containsScript' => [
'rule' => ['containsScript'],
'provider' => 'bc',
'message' => __d('baser_core', '送信完了文でスクリプトの入力は許可されていません。')
]
]);

// unpublish
$validator
->scalar('unpublish')
->allowEmptyString('unpublish')
->add('unpublish', [
'containsScript' => [
'rule' => ['containsScript'],
'provider' => 'bc',
'message' => __d('baser_core', '受付中止文でスクリプトの入力は許可されていません。')
]
]);

// publish_end
$validator
->add('publish_end', [
Expand Down
4 changes: 4 additions & 0 deletions plugins/bc-mail/src/View/Helper/BcMailBaserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public function methods(): array
'isMail' => ['Mail', 'isMail'],
'mailFormDescriptionExists' => ['Mail', 'descriptionExists'],
'mailFormDescription' => ['Mail', 'description'],
'mailFormThanksExists' => ['Mail', 'thanksExists'],
'mailFormThanks' => ['Mail', 'thanks'],
'mailFormUnpublishExists' => ['Mail', 'unpublishExists'],
'mailFormUnpublish' => ['Mail', 'unpublish'],
'freezeMailForm' => ['Mailform', 'freeze'],
'createMailForm' => ['Mailform', 'create'],
'mailFormHidden' => ['Mailform', 'hidden'],
Expand Down
82 changes: 82 additions & 0 deletions plugins/bc-mail/src/View/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,88 @@ public function descriptionExists()
return true;
}

/**
* メールフォームの送信完了文を取得する
* @return string メールフォームの送信完了文
* @checked
* @noTodo
* @unitTest
*/
public function getThanks(): string
{
return $this->currentMailContent->thanks;
}

/**
* メールの送信完了文を出力する
*
* @return void
* @checked
* @noTodo
* @unitTest ラッパーのためテスト不要
*/
public function thanks(): void
{
echo $this->getThanks();
}

/**
* メールの送信完了文が設定されているかどうかを判定する
*
* @return bool 設定されている場合 true を返す
* @checked
* @noTodo
* @unitTest
*/
public function thanksExists(): bool
{
if (empty($this->currentMailContent->thanks)) {
return false;
}
return true;
}

/**
* メールフォームの受付停止文を取得する
* @return string メールフォームの受付停止文
* @checked
* @noTodo
* @unitTest
*/
public function getUnpublish(): string
{
return $this->currentMailContent->unpublish;
}

/**
* メールの受付停止文を出力する
*
* @return void
* @checked
* @noTodo
* @unitTest ラッパーのためテスト不要
*/
public function unpublish(): void
{
echo $this->getUnpublish();
}

/**
* メールの受付停止文が設定されているかどうかを判定する
*
* @return bool 設定されている場合 true を返す
* @checked
* @noTodo
* @unitTest
*/
public function unpublishExists(): bool
{
if (empty($this->currentMailContent->unpublish)) {
return false;
}
return true;
}

/**
* メールフォームへのリンクを生成する
* $contentsNameはコンテンツ管理上の1階層のみ対応
Expand Down
4 changes: 4 additions & 0 deletions plugins/bc-mail/tests/Scenario/MailContentsScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public function load(...$args): mixed
MailContentFactory::make([
'id' => 1,
'description' => 'description test',
'thanks' => 'thanks test',
'unpublish' => 'unpublish test',
'sender_name' => 'baserCMSサンプル',
'subject_user' => '【baserCMS】お問い合わせ頂きありがとうございます。',
'subject_admin' => '【baserCMS】お問い合わせを受け付けました',
Expand All @@ -80,6 +82,8 @@ public function load(...$args): mixed

MailContentFactory::make([
'description' => 'description test 2',
'thanks' => 'thanks test 2',
'unpublish' => 'unpublish test 2',
'sender_name' => '送信先名を入力してください',
'subject_user' => 'お問い合わせ頂きありがとうございます',
'subject_admin' => 'お問い合わせを頂きました',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public function testView()
// 戻る値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertEquals('description test', $result->mailContent->description);
$this->assertEquals('thanks test', $result->mailContent->thanks);
$this->assertEquals('unpublish test', $result->mailContent->unpublish);
$this->assertEquals('baserCMSサンプル', $result->mailContent->sender_name);
$this->assertEquals('【baserCMS】お問い合わせ頂きありがとうございます。', $result->mailContent->subject_user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@

use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BcMail\Model\Entity\MailContent;
use BcMail\Model\Table\MailContentsTable;
use BcMail\Service\MailContentsServiceInterface;
use BcMail\Test\Scenario\MailContentsScenario;
use Cake\Core\Configure;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

/**
* Class MailContentTest
*
* @property MailContent $MailContent
* @property MailContentsTable $MailContent
*/
class MailContentsTableTest extends BcTestCase
{
Expand Down Expand Up @@ -434,6 +433,10 @@ public function testValidationDefault()
//containsScript
$errors = $validator->validate(['description' => '<script></script>']);
$this->assertEquals('説明文でスクリプトの入力は許可されていません。', current($errors['description']));
$errors = $validator->validate(['thanks' => '<script></script>']);
$this->assertEquals('送信完了文でスクリプトの入力は許可されていません。', current($errors['thanks']));
$errors = $validator->validate(['unpublish' => '<script></script>']);
$this->assertEquals('受付中止文でスクリプトの入力は許可されていません。', current($errors['unpublish']));

//emails
$errors = $validator->validate(['sender_1' => 'カタカナ', 'sender_2' => 'カタカナ']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public function testMethods()
$this->assertEquals(['Mail', 'isMail'], $methods['isMail']);
$this->assertEquals(['Mail', 'descriptionExists'], $methods['mailFormDescriptionExists']);
$this->assertEquals(['Mail', 'description'], $methods['mailFormDescription']);
$this->assertEquals(['Mail', 'thanksExists'], $methods['mailFormThanksExists']);
$this->assertEquals(['Mail', 'thanks'], $methods['mailFormThanks']);
$this->assertEquals(['Mail', 'unpublishExists'], $methods['mailFormUnpublishExists']);
$this->assertEquals(['Mail', 'unpublish'], $methods['mailFormUnpublish']);
$this->assertEquals(['Mailform', 'freeze'], $methods['freezeMailForm']);
$this->assertEquals(['Mailform', 'create'], $methods['createMailForm']);
$this->assertEquals(['Mailform', 'hidden'], $methods['mailFormHidden']);
Expand All @@ -51,4 +55,4 @@ public function testMethods()
$this->assertEquals(['Mailform', 'isGroupLastField'], $methods['isMailFormGroupLastField']);
$this->assertEquals(['Mailform', 'label'], $methods['mailFormLabel']);
}
}
}
Loading