From c33212007eb16c214812a0a193bf72588c0896b5 Mon Sep 17 00:00:00 2001 From: ouyou Date: Tue, 14 Jan 2020 20:18:06 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E3=83=86?= =?UTF-8?q?=E3=83=B3=E3=83=97=E3=83=AC=E3=83=BC=E3=83=88=E3=82=92=E6=96=B0?= =?UTF-8?q?=E8=A6=8F=E7=99=BB=E9=8C=B2/=E5=89=8A=E9=99=A4=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Setting/Shop/MailController.php | 161 +++++++--- src/Eccube/Entity/MailTemplate.php | 35 +++ src/Eccube/Event/EccubeEvents.php | 1 + src/Eccube/Form/Type/Admin/MailType.php | 102 ++++++- src/Eccube/Form/Type/Admin/OrderMailType.php | 4 +- .../Repository/MailTemplateRepository.php | 14 + .../import_csv/en/dtb_mail_template.csv | 18 +- .../import_csv/ja/dtb_mail_template.csv | 18 +- src/Eccube/Resource/locale/messages.en.yaml | 3 +- src/Eccube/Resource/locale/messages.ja.yaml | 3 +- .../template/admin/Setting/Shop/mail.twig | 279 +++++------------- .../admin/Setting/Shop/mail_edit.twig | 276 +++++++++++++++++ 12 files changed, 635 insertions(+), 279 deletions(-) create mode 100644 src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig diff --git a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php index 4ce9dcd4f81..9751b7cecb7 100644 --- a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php +++ b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php @@ -19,6 +19,7 @@ use Eccube\Event\EventArgs; use Eccube\Form\Type\Admin\MailType; use Eccube\Repository\MailTemplateRepository; +use Eccube\Util\CacheUtil; use Eccube\Util\StringUtil; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\Filesystem\Filesystem; @@ -48,10 +49,75 @@ public function __construct(MailTemplateRepository $mailTemplateRepository) /** * @Route("/%eccube_admin_route%/setting/shop/mail", name="admin_setting_shop_mail") - * @Route("/%eccube_admin_route%/setting/shop/mail/{id}", requirements={"id" = "\d+"}, name="admin_setting_shop_mail_edit") * @Template("@admin/Setting/Shop/mail.twig") */ - public function index(Request $request, MailTemplate $Mail = null, Environment $twig) + public function index() + { + $MailTemplates = $this->mailTemplateRepository->getList(); + + return ['MailTemplates' => $MailTemplates]; + } + + /** + * @Route("/%eccube_admin_route%/setting/shop/mail/{id}/delete", requirements={"id" = "\d+"}, name="admin_setting_shop_mail_delete", methods={"DELETE"}) + */ + public function delete(Request $request, $id = null, CacheUtil $cacheUtil) + { + $this->isTokenValid(); + + /** @var MailTemplate $Mail */ + $Mail = $this->mailTemplateRepository + ->findOneBy([ + 'id' => $id, + ]); + + if (!$Mail) { + $this->deleteMessage(); + + return $this->redirectToRoute('admin_setting_shop_mail'); + } + + // ユーザーが作ったページのみ削除する + if ($Mail->getEditType() == MailTemplate::EDIT_TYPE_USER) { + + $templatePath = $this->getParameter('eccube_theme_front_dir'); + $file = $templatePath.'/'.$Mail->getFileName(); + $htmlFile = $templatePath.'/'.$this->getHtmlFileName($Mail->getFileName()); + + $fs = new Filesystem(); + if ($fs->exists($file)) { + $fs->remove($file); + } + if ($fs->exists($htmlFile)) { + $fs->remove($htmlFile); + } + $this->entityManager->remove($Mail); + $this->entityManager->flush(); + + $event = new EventArgs( + [ + 'Mail' => $Mail, + ], + $request + ); + $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_DELETE_COMPLETE, $event); + + $this->addSuccess('admin.common.delete_complete', 'admin'); + + // キャッシュの削除 + $cacheUtil->clearTwigCache(); + $cacheUtil->clearDoctrineCache(); + } + + return $this->redirectToRoute('admin_setting_shop_mail'); + } + + /** + * @Route("/%eccube_admin_route%/setting/shop/mail/edit/new", name="admin_setting_shop_mail_new") + * @Route("/%eccube_admin_route%/setting/shop/mail/edit/{id}", requirements={"id" = "\d+"}, name="admin_setting_shop_mail_edit") + * @Template("@admin/Setting/Shop/mail_edit.twig") + */ + public function edit(Request $request, MailTemplate $Mail = null, Environment $twig) { $builder = $this->formFactory ->createBuilder(MailType::class, $Mail); @@ -66,11 +132,14 @@ public function index(Request $request, MailTemplate $Mail = null, Environment $ $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_INDEX_INITIALIZE, $event); $form = $builder->getForm(); - $form['template']->setData($Mail); - $htmlFileName = $Mail ? $this->getHtmlFileName($Mail->getFileName()) : null; + + $isUserType = false; // 更新時 if (!is_null($Mail)) { + + $htmlFileName = $this->getHtmlFileName($Mail->getFileName()); + // テンプレートファイルの取得 $source = $twig->getLoader() ->getSourceContext($Mail->getFileName()) @@ -84,57 +153,73 @@ public function index(Request $request, MailTemplate $Mail = null, Environment $ $form->get('html_tpl_data')->setData($source); } + } else { + $isUserType = true; } - if ('POST' === $request->getMethod()) { - $form->handleRequest($request); + $form->handleRequest($request); - // 新規登録は現時点では未実装とする. - if (is_null($Mail)) { - $this->addError('admin.common.save_error', 'admin'); + if ($form->isSubmitted() && $form->isValid()) { - return $this->redirectToRoute('admin_setting_shop_mail'); + if (is_null($Mail)) { + $fileName = sprintf('Mail/%s.twig', $form->get('file_name')->getData()); + } else { + $fileName = $Mail->getFileName(); } - if ($form->isValid()) { - $this->entityManager->flush(); - // ファイル生成・更新 - $templatePath = $this->getParameter('eccube_theme_front_dir'); - $filePath = $templatePath.'/'.$Mail->getFileName(); + // ファイル生成・更新 + $templatePath = $this->getParameter('eccube_theme_front_dir'); + $filePath = $templatePath.'/'.$fileName; + + $fs = new Filesystem(); + $mailData = $form->get('tpl_data')->getData(); + $mailData = StringUtil::convertLineFeed($mailData); + $fs->dumpFile($filePath, $mailData); + // HTMLファイル用 + $htmlMailData = $form->get('html_tpl_data')->getData(); + $htmlFile = $this->getHtmlFileName($filePath); + if (!is_null($htmlMailData)) { + $htmlMailData = StringUtil::convertLineFeed($htmlMailData); + $fs->dumpFile($htmlFile, $htmlMailData); + } else { $fs = new Filesystem(); - $mailData = $form->get('tpl_data')->getData(); - $mailData = StringUtil::convertLineFeed($mailData); - $fs->dumpFile($filePath, $mailData); - - // HTMLファイル用 - $htmlMailData = $form->get('html_tpl_data')->getData(); - if (!is_null($htmlMailData)) { - $htmlMailData = StringUtil::convertLineFeed($htmlMailData); - $fs->dumpFile($templatePath.'/'.$htmlFileName, $htmlMailData); + if ($fs->exists($htmlFile)) { + $fs->remove($htmlFile); } + } - $event = new EventArgs( - [ - 'form' => $form, - 'Mail' => $Mail, - 'templatePath' => $templatePath, - 'filePath' => $filePath, - ], - $request - ); - $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_INDEX_COMPLETE, $event); + /** @var MailTemplate $Mail */ + $Mail = $form->getData(); + if ($isUserType) { + $Mail->setEditType(MailTemplate::EDIT_TYPE_USER); + } + $Mail->setFileName($fileName); + $this->entityManager->persist($Mail); + $this->entityManager->flush(); - $this->addSuccess('admin.common.save_complete', 'admin'); - return $this->redirectToRoute('admin_setting_shop_mail_edit', ['id' => $Mail->getId()]); - } + $event = new EventArgs( + [ + 'form' => $form, + 'Mail' => $Mail, + 'templatePath' => $templatePath, + 'filePath' => $filePath, + ], + $request + ); + $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_INDEX_COMPLETE, $event); + + $this->addSuccess('admin.common.save_complete', 'admin'); + + return $this->redirectToRoute('admin_setting_shop_mail_edit', ['id' => $Mail->getId()]); } + return [ 'form' => $form->createView(), - 'id' => is_null($Mail) ? null : $Mail->getId(), + 'Mail' => $Mail, ]; } diff --git a/src/Eccube/Entity/MailTemplate.php b/src/Eccube/Entity/MailTemplate.php index 116e0ae53d9..bdf8c2a5d20 100644 --- a/src/Eccube/Entity/MailTemplate.php +++ b/src/Eccube/Entity/MailTemplate.php @@ -27,6 +27,10 @@ */ class MailTemplate extends \Eccube\Entity\AbstractEntity { + + const EDIT_TYPE_USER = 0; + const EDIT_TYPE_DEFAULT = 1; + /** * @return string */ @@ -65,6 +69,13 @@ public function __toString() */ private $mail_subject; + /** + * @var int + * + * @ORM\Column(name="edit_type", type="smallint", options={"unsigned":true,"default":1}) + */ + private $edit_type = self::EDIT_TYPE_DEFAULT; + /** * @var \DateTime * @@ -171,6 +182,30 @@ public function getMailSubject() return $this->mail_subject; } + /** + * Set editType. + * + * @param int $editType + * + * @return MailTemplate + */ + public function setEditType($editType) + { + $this->edit_type = $editType; + + return $this; + } + + /** + * Get editType. + * + * @return int + */ + public function getEditType() + { + return $this->edit_type; + } + /** * Set createDate. * diff --git a/src/Eccube/Event/EccubeEvents.php b/src/Eccube/Event/EccubeEvents.php index c3eb8cdf5e9..e18b4fb25f7 100644 --- a/src/Eccube/Event/EccubeEvents.php +++ b/src/Eccube/Event/EccubeEvents.php @@ -302,6 +302,7 @@ final class EccubeEvents // index const ADMIN_SETTING_SHOP_MAIL_INDEX_INITIALIZE = 'admin.setting.shop.mail.index.initialize'; const ADMIN_SETTING_SHOP_MAIL_INDEX_COMPLETE = 'admin.setting.shop.mail.index.complete'; + const ADMIN_SETTING_SHOP_MAIL_DELETE_COMPLETE = 'admin.setting.shop.mail.delete.complete'; // preview const ADMIN_SETTING_SHOP_MAIL_PREVIEW_COMPLETE = 'admin.setting.shop.mail.preview.complete'; diff --git a/src/Eccube/Form/Type/Admin/MailType.php b/src/Eccube/Form/Type/Admin/MailType.php index 5070180a1b5..3c8fa2e0310 100644 --- a/src/Eccube/Form/Type/Admin/MailType.php +++ b/src/Eccube/Form/Type/Admin/MailType.php @@ -13,29 +13,53 @@ namespace Eccube\Form\Type\Admin; -use Eccube\Form\Type\Master\MailTemplateType; +use Doctrine\ORM\EntityManagerInterface; +use Eccube\Common\EccubeConfig; +use Eccube\Entity\MailTemplate; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormError; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints as Assert; use Eccube\Form\Validator\TwigLint; class MailType extends AbstractType { + + /** + * @var EccubeConfig + */ + protected $eccubeConfig; + + /** + * @var EntityManagerInterface + */ + protected $entityManager; + + /** + * MailType constructor. + * @param EccubeConfig $eccubeConfig + * @param EntityManagerInterface $entityManager + */ + public function __construct( + EccubeConfig $eccubeConfig, + EntityManagerInterface $entityManager + ) + { + $this->eccubeConfig = $eccubeConfig; + $this->entityManager = $entityManager; + } + /** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('template', MailTemplateType::class, [ - 'required' => true, - 'mapped' => false, - 'constraints' => [ - new Assert\NotBlank(), - ], - ]) ->add('mail_subject', TextType::class, [ 'required' => true, 'constraints' => [ @@ -59,6 +83,68 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ; + + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { + /** @var MailTemplate $Mail */ + $Mail = $event->getData(); + if (!$Mail || !$Mail->getId()) { + $form = $event->getForm(); + + $form + ->add('name', TextType::class, [ + 'required' => true, + 'constraints' => [ + new Assert\Length([ + 'max' => $this->eccubeConfig['eccube_name_len'], + ]), + new Assert\NotBlank(), + ], + ]) + ->add('file_name', TextType::class, [ + 'required' => true, + 'constraints' => [ + new Assert\NotBlank(), + new Assert\Length([ + 'max' => $this->eccubeConfig['eccube_stext_len'], + ]), + new Assert\Regex([ + 'pattern' => '/^([0-9a-zA-Z_\-]+\/?)+$/', + ]), + ], + ]) + ; + } + }); + + $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { + $form = $event->getForm(); + + /** @var MailTemplate $Mail*/ + $Mail = $event->getData(); + + if (!$Mail->getId()) { + $qb = $this->entityManager->createQueryBuilder(); + $qb->select('count(m)') + ->from('Eccube\\Entity\\MailTemplate', 'm') + ->where('m.file_name = :file_name') + ->setParameter('file_name', $Mail['file_name']); + + $count = $qb->getQuery()->getSingleScalarResult(); + if ($count > 0) { + $form['file_name']->addError(new FormError(trans('admin.content.page_file_name_exists'))); + } + } + }); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => MailTemplate::class, + ]); } /** diff --git a/src/Eccube/Form/Type/Admin/OrderMailType.php b/src/Eccube/Form/Type/Admin/OrderMailType.php index 9a5f012dad2..3e37653a937 100644 --- a/src/Eccube/Form/Type/Admin/OrderMailType.php +++ b/src/Eccube/Form/Type/Admin/OrderMailType.php @@ -14,6 +14,7 @@ namespace Eccube\Form\Type\Admin; use Eccube\Common\EccubeConfig; +use Eccube\Entity\MailTemplate; use Eccube\Form\Type\Master\MailTemplateType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; @@ -52,8 +53,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'mapped' => false, 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('mt') - ->andWhere('mt.id = :id') + ->andWhere('mt.id = :id or mt.edit_type = :edit_type') ->setParameter('id', $this->eccubeConfig['eccube_order_mail_template_id']) + ->setParameter('edit_type', MailTemplate::EDIT_TYPE_USER) ->orderBy('mt.id', 'ASC'); }, ]) diff --git a/src/Eccube/Repository/MailTemplateRepository.php b/src/Eccube/Repository/MailTemplateRepository.php index 3ac031be969..037b506fd2c 100644 --- a/src/Eccube/Repository/MailTemplateRepository.php +++ b/src/Eccube/Repository/MailTemplateRepository.php @@ -28,4 +28,18 @@ public function __construct(RegistryInterface $registry) { parent::__construct($registry, MailTemplate::class); } + + /** + * getList + * + * @return array|null + */ + public function getList() + { + $qb = $this->createQueryBuilder('m') + ->orderBy('m.id'); + + return $qb->getQuery() + ->getResult(); + } } diff --git a/src/Eccube/Resource/doctrine/import_csv/en/dtb_mail_template.csv b/src/Eccube/Resource/doctrine/import_csv/en/dtb_mail_template.csv index 435963bd2fa..484bfcb93e4 100644 --- a/src/Eccube/Resource/doctrine/import_csv/en/dtb_mail_template.csv +++ b/src/Eccube/Resource/doctrine/import_csv/en/dtb_mail_template.csv @@ -1,9 +1,9 @@ -id,creator_id,name,file_name,mail_subject,create_date,update_date,discriminator_type -1,,Order Receipt,Mail/order.twig,Thank you for your order!,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -2,,Temporary Registration,Mail/entry_confirm.twig,Member registration confirmation,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -3,,Regular Registration,Mail/entry_complete.twig,Your registration has been completed,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -4,,Membership Cancelation,Mail/customer_withdraw_mail.twig,Membership cancelation completed,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -5,,Inquiry Receipt,Mail/contact_mail.twig,Thank you for your inqury,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -6,,Password Reset,Mail/forgot_mail.twig,Reset your password,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -7,,Password Reminder,Mail/reset_complete_mail.twig,Your password has been changed,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate -8,,Shipping Notice,Mail/shipping_notify.twig,Your order has been shipped,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +id,creator_id,name,file_name,mail_subject,edit_type,create_date,update_date,discriminator_type +1,,Order Receipt,Mail/order.twig,Thank you for your order!,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +2,,Temporary Registration,Mail/entry_confirm.twig,Member registration confirmation,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +3,,Regular Registration,Mail/entry_complete.twig,Your registration has been completed,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +4,,Membership Cancelation,Mail/customer_withdraw_mail.twig,Membership cancelation completed,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +5,,Inquiry Receipt,Mail/contact_mail.twig,Thank you for your inqury,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +6,,Password Reset,Mail/forgot_mail.twig,Reset your password,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +7,,Password Reminder,Mail/reset_complete_mail.twig,Your password has been changed,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate +8,,Shipping Notice,Mail/shipping_notify.twig,Your order has been shipped,1,2017-03-07 10:14:52,2017-03-07 10:14:52,mailtemplate diff --git a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv index c66e160a773..d4c941c0376 100644 --- a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv +++ b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv @@ -1,9 +1,9 @@ -id,creator_id,name,file_name,mail_subject,create_date,update_date,discriminator_type -"1",,"注文受付メール","Mail/order.twig","ご注文ありがとうございます","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"2",,"会員仮登録メール","Mail/entry_confirm.twig","会員登録のご確認","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"3",,"会員本登録メール","Mail/entry_complete.twig","会員登録が完了しました。","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"4",,"会員退会メール","Mail/customer_withdraw_mail.twig","退会手続きのご完了","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"5",,"問合受付メール","Mail/contact_mail.twig","お問い合わせを受け付けました。","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"6",,"パスワードリセット","Mail/forgot_mail.twig","パスワード変更のご確認","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"7",,"パスワードリマインダー","Mail/reset_complete_mail.twig","パスワード変更のお知らせ","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"8",,"出荷通知メール","Mail/shipping_notify.twig","商品出荷のお知らせ","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +id,creator_id,name,file_name,mail_subject,edit_type,create_date,update_date,discriminator_type +"1",,"注文受付メール","Mail/order.twig","ご注文ありがとうございます",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"2",,"会員仮登録メール","Mail/entry_confirm.twig","会員登録のご確認",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"3",,"会員本登録メール","Mail/entry_complete.twig","会員登録が完了しました。",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"4",,"会員退会メール","Mail/customer_withdraw_mail.twig","退会手続きのご完了",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"5",,"問合受付メール","Mail/contact_mail.twig","お問い合わせを受け付けました。",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"6",,"パスワードリセット","Mail/forgot_mail.twig","パスワード変更のご確認",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"7",,"パスワードリマインダー","Mail/reset_complete_mail.twig",1,"パスワード変更のお知らせ","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"8",,"出荷通知メール","Mail/shipping_notify.twig","商品出荷のお知らせ",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index 9487098e014..42cac2b754b 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -1147,6 +1147,8 @@ admin.setting.shop.mail.mail_body: Body admin.setting.shop.mail.mail_text: Text admin.setting.shop.mail.mail_html: HTML admin.setting.shop.mail.preview: Preview +admin.setting.shop.mail.file_name: This is the name of a twig template file which has the mail contents. +admin.setting.shop.mail_list: All Mail Templates #------------------------------------------------------------------------------------ # Settings : Store Settings : CSV Outputs @@ -1573,7 +1575,6 @@ tooltip.setting.shop.delivery.sale_type: Specify the sales type(s) available for tooltip.setting.shop.delivery.apply_to_pref: The same shipping charge can be applied to all prefectures. You can later change the shipping rate for each prefecture one by one. tooltip.setting.shop.delivery.shop_memo: This is a note for store Owner''s. It is not displayed on the storefront. tooltip.setting.shop.tax_setting: You can set the tax rates applicable to all products. The general tax rate can be overwritten if you enter a new rate. -tooltip.setting.shop.mail.mail_template: Please select an existing email template. Contents are displayed in the text field below. tooltip.setting.shop.csv.csv_columns: You can output various data in CSV format. You can specify the items for CSV output. tooltip.setting.shop.csv.csv_type: Specify the CSV file type. tooltip.setting.system.member.authority: You can select the authorization you have set under Authorization. diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index df48cb95065..9972ce26280 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -1147,6 +1147,8 @@ admin.setting.shop.mail.mail_body: 本文 admin.setting.shop.mail.mail_text: テキスト admin.setting.shop.mail.mail_html: HTML admin.setting.shop.mail.preview: プレビュー +admin.setting.shop.mail.file_name: ファイル名 +admin.setting.shop.mail_list: 一覧を見る #------------------------------------------------------------------------------------ # 設定:店舗設定:CSV出力項目設定 @@ -1573,7 +1575,6 @@ tooltip.setting.shop.delivery.sale_type: この配送方法で取り扱える販 tooltip.setting.shop.delivery.apply_to_pref: すべての都道府県に同じ送料を一括で設定できます。あとから個々の都道府県の送料を書き換えることも可能です。 tooltip.setting.shop.delivery.shop_memo: 店舗用のメモ欄です。フロント側には表示されません。 tooltip.setting.shop.tax_setting: 商品共通の税率を設定できます。新しい税率を追加することで基本税率設定を上書きすることが可能です。 -tooltip.setting.shop.mail.mail_template: 既存のメールテンプレートを選択してください。以下に内容が表示されます。 tooltip.setting.shop.csv.csv_columns: 各種のデータをCSVで出力できます。出力したい項目をこちらで設定することが可能です。 tooltip.setting.shop.csv.csv_type: 設定したいCSVの種類を指定してください。 tooltip.setting.system.member.authority: 権限管理で設定した権限を選択できます。 diff --git a/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig b/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig index fba3766717c..021eec4de2b 100644 --- a/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig +++ b/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig @@ -10,220 +10,94 @@ file that was distributed with this source code. #} {% extends '@admin/default_frame.twig' %} -{% set menus = ['setting', 'shop', 'shop_mail'] %} +{% set menus = ['setting', 'shop', 'shop_delivery'] %} -{% block title %}{{ 'admin.setting.shop.mail_setting'|trans }}{% endblock %} +{% block title %}{{ 'admin.setting.shop.delivery_list'|trans }}{% endblock %} {% block sub_title %}{{ 'admin.setting.shop'|trans }}{% endblock %} -{% form_theme form '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %} - -{% block stylesheet %} - - -{% endblock %} - {% block javascript %} - - - -{% endblock javascript %} +{% endblock %} {% block main %} -
- {{ form_widget(form._token) }} +
+
-
{{ 'admin.setting.shop.mail.mail_template_edit'|trans }}
-
-
-
-
- {{ 'admin.setting.shop.mail.mail_template'|trans }} -
-
-
- {{ form_widget(form.template) }} - {{ form_errors(form.template) }} -
-
-
-
{{ 'admin.setting.shop.mail.mail_subject'|trans }}{{ 'admin.common.required'|trans }}
-
- {{ form_widget(form.mail_subject) }} - {{ form_errors(form.mail_subject) }} -
-
-
-
{{ 'admin.setting.shop.mail.mail_body'|trans }}{{ 'admin.common.required'|trans }}
-
- {# タブ表示 #} - {% if id is not null %} - + + {% endfor %} {% endif %} -
-
- {{ form_label(form.tpl_data) }} -
-
{{ form_widget(form.tpl_data) }}
- {{ form_errors(form.tpl_data) }} -
- {% if form.html_tpl_data.vars.value %} -
- {{ form_label(form.html_tpl_data) }} -
-
{{ form_widget(form.html_tpl_data) }}
- {{ form_errors(form.html_tpl_data) }} + + +
- {# エンティティ拡張の自動出力 #} - {% for f in form if f.vars.eccube_form_options.auto_render %} - {% if f.vars.eccube_form_options.form_theme %} - {% form_theme f f.vars.eccube_form_options.form_theme %} - {{ form_row(f) }} - {% else %} -
-
{{ f.vars.label|trans }}
-
- {{ form_widget(f) }} - {{ form_errors(f) }} -
-
- {% endif %} - {% endfor %} -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
@@ -231,23 +105,4 @@ file that was distributed with this source code.
- - {% endblock %} diff --git a/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig b/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig new file mode 100644 index 00000000000..c76df2c3e85 --- /dev/null +++ b/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig @@ -0,0 +1,276 @@ +{# +This file is part of EC-CUBE + +Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. + +http://www.ec-cube.co.jp/ + +For the full copyright and license information, please view the LICENSE +file that was distributed with this source code. +#} +{% extends '@admin/default_frame.twig' %} + +{% set menus = ['setting', 'shop', 'shop_mail'] %} + +{% block title %}{{ 'admin.setting.shop.mail_setting'|trans }}{% endblock %} +{% block sub_title %}{{ 'admin.setting.shop'|trans }}{% endblock %} + +{% form_theme form '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %} + +{% block stylesheet %} + + +{% endblock %} + +{% block javascript %} + + + + +{% endblock javascript %} + +{% block main %} +
+ {{ form_widget(form._token) }} +
+
+
+
+
{{ 'admin.setting.shop.mail.mail_template_edit'|trans }}
+
+
+
+
+ {{ 'admin.setting.shop.mail.mail_template'|trans }}{{ 'admin.common.required'|trans }} +
+
+
+ {% if Mail is null %} + {{ form_widget(form.name) }} + {{ form_errors(form.name) }} + {% else %} + {{ Mail.name }} + {% endif %} +
+
+
+
+
+ {{ 'admin.setting.shop.mail.file_name'|trans }} +
+ {{ 'admin.common.required'|trans }} +
+
+
+ {% if Mail is null %} +
+ {{ form_widget(form.file_name) }} + {{ form_errors(form.file_name) }} +
+
.twig
+ {% else %} +
+ {{ Mail.file_name }} +
+ {% endif %} +
+
+
+
+
{{ 'admin.setting.shop.mail.mail_subject'|trans }}{{ 'admin.common.required'|trans }}
+
+ {{ form_widget(form.mail_subject) }} + {{ form_errors(form.mail_subject) }} +
+
+
+
{{ 'admin.setting.shop.mail.mail_body'|trans }}{{ 'admin.common.required'|trans }}
+
+ {# タブ表示 #} + + + +
+
+ {{ form_label(form.tpl_data) }} +
+
{{ form_widget(form.tpl_data) }}
+ {{ form_errors(form.tpl_data) }} +
+ +
+ {{ form_label(form.html_tpl_data) }} +
+
{{ form_widget(form.html_tpl_data) }}
+ {{ form_errors(form.html_tpl_data) }} +
+
+
+
+ {# エンティティ拡張の自動出力 #} + {% for f in form if f.vars.eccube_form_options.auto_render %} + {% if f.vars.eccube_form_options.form_theme %} + {% form_theme f f.vars.eccube_form_options.form_theme %} + {{ form_row(f) }} + {% else %} +
+
{{ f.vars.label|trans }}
+
+ {{ form_widget(f) }} + {{ form_errors(f) }} +
+
+ {% endif %} + {% endfor %} +
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+ + + +{% endblock %} From 0c9ed80c4ddce1449cdb1191727cd2b43fda4626 Mon Sep 17 00:00:00 2001 From: ouyou Date: Wed, 15 Jan 2020 00:35:56 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Setting/Shop/MailController.php | 2 +- .../doctrine/import_csv/ja/dtb_mail_template.csv | 16 ++++++++-------- .../template/admin/Setting/Shop/mail_edit.twig | 5 +---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php index 9751b7cecb7..800742e2a35 100644 --- a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php +++ b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php @@ -82,7 +82,7 @@ public function delete(Request $request, $id = null, CacheUtil $cacheUtil) $templatePath = $this->getParameter('eccube_theme_front_dir'); $file = $templatePath.'/'.$Mail->getFileName(); - $htmlFile = $templatePath.'/'.$this->getHtmlFileName($Mail->getFileName()); + $htmlFile = $this->getHtmlFileName($file); $fs = new Filesystem(); if ($fs->exists($file)) { diff --git a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv index d4c941c0376..4699b78b98b 100644 --- a/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv +++ b/src/Eccube/Resource/doctrine/import_csv/ja/dtb_mail_template.csv @@ -1,9 +1,9 @@ id,creator_id,name,file_name,mail_subject,edit_type,create_date,update_date,discriminator_type -"1",,"注文受付メール","Mail/order.twig","ご注文ありがとうございます",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"2",,"会員仮登録メール","Mail/entry_confirm.twig","会員登録のご確認",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"3",,"会員本登録メール","Mail/entry_complete.twig","会員登録が完了しました。",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"4",,"会員退会メール","Mail/customer_withdraw_mail.twig","退会手続きのご完了",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"5",,"問合受付メール","Mail/contact_mail.twig","お問い合わせを受け付けました。",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"6",,"パスワードリセット","Mail/forgot_mail.twig","パスワード変更のご確認",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"7",,"パスワードリマインダー","Mail/reset_complete_mail.twig",1,"パスワード変更のお知らせ","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" -"8",,"出荷通知メール","Mail/shipping_notify.twig","商品出荷のお知らせ",1,"2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"1",,"注文受付メール","Mail/order.twig","ご注文ありがとうございます","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"2",,"会員仮登録メール","Mail/entry_confirm.twig","会員登録のご確認","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"3",,"会員本登録メール","Mail/entry_complete.twig","会員登録が完了しました。","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"4",,"会員退会メール","Mail/customer_withdraw_mail.twig","退会手続きのご完了","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"5",,"問合受付メール","Mail/contact_mail.twig","お問い合わせを受け付けました。","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"6",,"パスワードリセット","Mail/forgot_mail.twig","パスワード変更のご確認","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"7",,"パスワードリマインダー","Mail/reset_complete_mail.twig","パスワード変更のお知らせ","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" +"8",,"出荷通知メール","Mail/shipping_notify.twig","商品出荷のお知らせ","1","2017-03-07 10:14:52","2017-03-07 10:14:52","mailtemplate" diff --git a/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig b/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig index c76df2c3e85..72475a87551 100644 --- a/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig +++ b/src/Eccube/Resource/template/admin/Setting/Shop/mail_edit.twig @@ -150,19 +150,16 @@ file that was distributed with this source code. {{ 'admin.common.required'|trans }}
-
{% if Mail is null %} -
+
{{ form_widget(form.file_name) }} {{ form_errors(form.file_name) }}
-
.twig
{% else %}
{{ Mail.file_name }}
{% endif %} -
From 2be74ad2bfe75d7a9d4506006f56afb66ab974cb Mon Sep 17 00:00:00 2001 From: ouyou Date: Wed, 15 Jan 2020 00:39:34 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tests/Web/Admin/Setting/Shop/MailControllerTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php index 9803af18176..0fa4bbf8bac 100644 --- a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php @@ -77,7 +77,6 @@ public function testEdit() $MailTemplate = $this->createMail(); $form = [ '_token' => 'dummy', - 'template' => $MailTemplate->getId(), 'mail_subject' => 'Test Subject', 'tpl_data' => 'Test TPL Data', ]; @@ -103,7 +102,6 @@ public function testEditHtml() $MailTemplate = $this->createMail(); $form = [ '_token' => 'dummy', - 'template' => $MailTemplate->getId(), 'mail_subject' => 'Test Subject', 'tpl_data' => 'Test TPL Data', 'html_tpl_data' => 'Test HTML TPL Data', @@ -127,7 +125,6 @@ public function testEditFail() $mid = 99999; $form = [ '_token' => 'dummy', - 'template' => $mid, 'mail_subject' => 'Test Subject', ]; $this->client->request( @@ -152,7 +149,6 @@ public function testCreateFail() { $form = [ '_token' => 'dummy', - 'template' => null, 'mail_subject' => null, ]; $this->client->request( From 4c1bb0efbdb61c27d68ce2332b09ede9134a9f0a Mon Sep 17 00:00:00 2001 From: ouyou Date: Wed, 15 Jan 2020 10:36:13 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BF=AE=E6=AD=A3=20#4398?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Setting/Shop/MailController.php | 16 ++++++-- .../Admin/Setting/Shop/MailControllerTest.php | 41 ++++++++++++++++--- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php index 800742e2a35..a9dff8f9f51 100644 --- a/src/Eccube/Controller/Admin/Setting/Shop/MailController.php +++ b/src/Eccube/Controller/Admin/Setting/Shop/MailController.php @@ -24,6 +24,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Twig\Environment; @@ -72,9 +73,7 @@ public function delete(Request $request, $id = null, CacheUtil $cacheUtil) ]); if (!$Mail) { - $this->deleteMessage(); - - return $this->redirectToRoute('admin_setting_shop_mail'); + throw new NotFoundHttpException(); } // ユーザーが作ったページのみ削除する @@ -117,8 +116,17 @@ public function delete(Request $request, $id = null, CacheUtil $cacheUtil) * @Route("/%eccube_admin_route%/setting/shop/mail/edit/{id}", requirements={"id" = "\d+"}, name="admin_setting_shop_mail_edit") * @Template("@admin/Setting/Shop/mail_edit.twig") */ - public function edit(Request $request, MailTemplate $Mail = null, Environment $twig) + public function edit(Request $request, $id = null, Environment $twig) { + + $Mail = null; + if ($id) { + $Mail = $this->mailTemplateRepository->find($id); + if (is_null($Mail)) { + throw new NotFoundHttpException(); + } + } + $builder = $this->formFactory ->createBuilder(MailType::class, $Mail); diff --git a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php index 0fa4bbf8bac..0de437d3f9d 100644 --- a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php @@ -133,12 +133,11 @@ public function testEditFail() ['mail' => $form] ); - $redirectUrl = $this->generateUrl('admin_setting_shop_mail'); + $redirectUrl = $this->generateUrl('admin_setting_shop_mail_edit', ['id' => $mid]); $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); - $outPut = $this->container->get('session')->getFlashBag()->get('eccube.admin.error'); - $this->actual = array_shift($outPut); - $this->expected = 'admin.common.save_error'; + $this->expected = 404; + $this->actual = $this->client->getResponse()->getStatusCode(); $this->verify(); } @@ -153,11 +152,43 @@ public function testCreateFail() ]; $this->client->request( 'POST', - $this->generateUrl('admin_setting_shop_mail'), + $this->generateUrl('admin_setting_shop_mail_edit'), ['mail' => $form] ); + $redirectUrl = $this->generateUrl('admin_setting_shop_mail_edit'); + $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); + } + + public function testDelete() + { + $TestMail = new MailTemplate(); + $TestMail->setEditType(MailTemplate::EDIT_TYPE_USER); + $TestMail->setFileName("test"); + $TestMail->setName("test"); + $TestMail->setMailSubject("test"); + $this->entityManager->persist($TestMail); + $this->entityManager->flush(); + $redirectUrl = $this->generateUrl('admin_setting_shop_mail'); + $this->client->request('DELETE', + $this->generateUrl('admin_setting_shop_mail_delete', ['id' => $TestMail->getId()]) + ); $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); } + + public function testDeleteIdNotFound() + { + // before + $mid = 99999; + + // main + $this->client->request('DELETE', + $this->generateUrl('admin_setting_shop_mail_edit', ['id' => $mid]) + ); + + $this->expected = 404; + $this->actual = $this->client->getResponse()->getStatusCode(); + $this->verify(); + } } From 721dd122a0f350b4f8bd2607c4c6423f73fa2df7 Mon Sep 17 00:00:00 2001 From: ouyou Date: Wed, 15 Jan 2020 11:23:53 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20#4398?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Form/Type/Admin/MailType.php | 5 +++-- src/Eccube/Resource/locale/messages.en.yaml | 1 + src/Eccube/Resource/locale/messages.ja.yaml | 1 + src/Eccube/Resource/template/admin/Setting/Shop/mail.twig | 4 ++-- .../Tests/Web/Admin/Setting/Shop/MailControllerTest.php | 8 ++++---- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Eccube/Form/Type/Admin/MailType.php b/src/Eccube/Form/Type/Admin/MailType.php index 3c8fa2e0310..70384883902 100644 --- a/src/Eccube/Form/Type/Admin/MailType.php +++ b/src/Eccube/Form/Type/Admin/MailType.php @@ -124,14 +124,15 @@ public function buildForm(FormBuilderInterface $builder, array $options) if (!$Mail->getId()) { $qb = $this->entityManager->createQueryBuilder(); + $qb->select('count(m)') ->from('Eccube\\Entity\\MailTemplate', 'm') ->where('m.file_name = :file_name') - ->setParameter('file_name', $Mail['file_name']); + ->setParameter('file_name', sprintf('Mail/%s.twig', $Mail['file_name'])); $count = $qb->getQuery()->getSingleScalarResult(); if ($count > 0) { - $form['file_name']->addError(new FormError(trans('admin.content.page_file_name_exists'))); + $form['file_name']->addError(new FormError(trans('admin.setting.shop.mail_file_name_exists'))); } } }); diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index 42cac2b754b..03cd600533c 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -1149,6 +1149,7 @@ admin.setting.shop.mail.mail_html: HTML admin.setting.shop.mail.preview: Preview admin.setting.shop.mail.file_name: This is the name of a twig template file which has the mail contents. admin.setting.shop.mail_list: All Mail Templates +admin.setting.shop.mail_file_name_exists: Data with the same file name already exists. Please enter a different one. #------------------------------------------------------------------------------------ # Settings : Store Settings : CSV Outputs diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index 9972ce26280..ed3de62fd1a 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -1149,6 +1149,7 @@ admin.setting.shop.mail.mail_html: HTML admin.setting.shop.mail.preview: プレビュー admin.setting.shop.mail.file_name: ファイル名 admin.setting.shop.mail_list: 一覧を見る +admin.setting.shop.mail_file_name_exists: 同じファイル名のデータが存在しています。別のファイル名を入力してください。 #------------------------------------------------------------------------------------ # 設定:店舗設定:CSV出力項目設定 diff --git a/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig b/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig index 021eec4de2b..aaba7bbc8c8 100644 --- a/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig +++ b/src/Eccube/Resource/template/admin/Setting/Shop/mail.twig @@ -10,9 +10,9 @@ file that was distributed with this source code. #} {% extends '@admin/default_frame.twig' %} -{% set menus = ['setting', 'shop', 'shop_delivery'] %} +{% set menus = ['setting', 'shop', 'shop_mail'] %} -{% block title %}{{ 'admin.setting.shop.delivery_list'|trans }}{% endblock %} +{% block title %}{{ 'admin.setting.shop.mail_setting'|trans }}{% endblock %} {% block sub_title %}{{ 'admin.setting.shop'|trans }}{% endblock %} {% block javascript %} diff --git a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php index 0de437d3f9d..b5c912d4ece 100644 --- a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php @@ -133,8 +133,8 @@ public function testEditFail() ['mail' => $form] ); - $redirectUrl = $this->generateUrl('admin_setting_shop_mail_edit', ['id' => $mid]); - $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); + //$redirectUrl = $this->generateUrl('admin_setting_shop_mail_edit', ['id' => $mid]); + //$this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); $this->expected = 404; $this->actual = $this->client->getResponse()->getStatusCode(); @@ -152,11 +152,11 @@ public function testCreateFail() ]; $this->client->request( 'POST', - $this->generateUrl('admin_setting_shop_mail_edit'), + $this->generateUrl('admin_setting_shop_mail_new'), ['mail' => $form] ); - $redirectUrl = $this->generateUrl('admin_setting_shop_mail_edit'); + $redirectUrl = $this->generateUrl('admin_setting_shop_mail_new'); $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); } From 7fd113111244da99639c7063330065f6fcc94d00 Mon Sep 17 00:00:00 2001 From: ouyou Date: Wed, 15 Jan 2020 13:20:57 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20#4398?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Content/PageController.php | 2 +- .../Admin/Setting/Shop/MailControllerTest.php | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/Eccube/Controller/Admin/Content/PageController.php b/src/Eccube/Controller/Admin/Content/PageController.php index 13bf8cfe0fb..ff10c2a8499 100644 --- a/src/Eccube/Controller/Admin/Content/PageController.php +++ b/src/Eccube/Controller/Admin/Content/PageController.php @@ -270,7 +270,7 @@ public function delete(Request $request, $id = null, CacheUtil $cacheUtil) // ユーザーが作ったページのみ削除する if ($Page->getEditType() == Page::EDIT_TYPE_USER) { $templatePath = $this->getParameter('eccube_theme_user_data_dir'); - $file = $templatePath.'/'.$Page->getFileName().'.twig'; + $file = $templatePath.'/'.$Page->getFileName(); $fs = new Filesystem(); if ($fs->exists($file)) { $fs->remove($file); diff --git a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php index b5c912d4ece..f43b0abb7da 100644 --- a/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Setting/Shop/MailControllerTest.php @@ -141,30 +141,11 @@ public function testEditFail() $this->verify(); } - /** - * Create - */ - public function testCreateFail() - { - $form = [ - '_token' => 'dummy', - 'mail_subject' => null, - ]; - $this->client->request( - 'POST', - $this->generateUrl('admin_setting_shop_mail_new'), - ['mail' => $form] - ); - - $redirectUrl = $this->generateUrl('admin_setting_shop_mail_new'); - $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); - } - public function testDelete() { $TestMail = new MailTemplate(); $TestMail->setEditType(MailTemplate::EDIT_TYPE_USER); - $TestMail->setFileName("test"); + $TestMail->setFileName("Mail/test.twig"); $TestMail->setName("test"); $TestMail->setMailSubject("test"); $this->entityManager->persist($TestMail); @@ -174,6 +155,7 @@ public function testDelete() $this->client->request('DELETE', $this->generateUrl('admin_setting_shop_mail_delete', ['id' => $TestMail->getId()]) ); + $this->assertTrue($this->client->getResponse()->isRedirect($redirectUrl)); }