From 62d44b084b9c12d0120623ada4e6b5c9f6a0408a Mon Sep 17 00:00:00 2001 From: clicktx Date: Fri, 30 Aug 2024 11:03:19 +0900 Subject: [PATCH 1/5] =?UTF-8?q?sfSendRegistMail=E3=81=AE=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SC_Helper_Mail_TestBase.php | 50 +++++++++++++++++++ .../SC_Helper_Mail_sfSendRegistMailTest.php | 46 +++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php create mode 100644 tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php diff --git a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php new file mode 100644 index 0000000000..b366d124e5 --- /dev/null +++ b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_TestBase.php @@ -0,0 +1,50 @@ +checkMailCatcherStatus(); + $this->objHelperMail = new SC_Helper_Mail_Ex(); + + $this->faker = Faker\Factory::create('ja_JP'); + } + + protected function tearDown() + { + parent::tearDown(); + } + + protected function setUpCustomer($properties = []) + { + $this->email = $this->faker->safeEmail; + $this->customer_id = $this->objGenerator->createCustomer($this->email, $properties); + $this->arrCustomer = $this->objQuery->getRow('*', 'dtb_customer', 'customer_id = ?', [$this->customer_id]); + $this->objCustomer = new SC_Customer_Ex(); + } +} diff --git a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php new file mode 100644 index 0000000000..48076b6760 --- /dev/null +++ b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php @@ -0,0 +1,46 @@ +setUpCustomer(); + + $this->resetEmails(); + $this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key']); + + $message = $this->getLastMailCatcherMessage(); + $this->assertContains($this->arrCustomer['name01'] . $this->arrCustomer['name02'] . ' 様', $message['source']); + } + + public function test会員登録依頼メールの宛名が正しい() + { + # 仮会員を作成 + $this->setUpCustomer(['status' => 1]); + + $this->resetEmails(); + $this->objHelperMail->sfSendRegistMail($this->arrCustomer['secret_key'], '', false, true); + + $message = $this->getLastMailCatcherMessage(); + $this->assertContains($this->arrCustomer['name01'] . ' ' . $this->arrCustomer['name02'] . ' 様', $message['source']); + $this->assertContains('&id=' . $this->arrCustomer['secret_key'], $message['source']); + } +} From c2b31074664d7d1ade7a7fb3ea8f796e398f5f21 Mon Sep 17 00:00:00 2001 From: clicktx Date: Fri, 30 Aug 2024 11:23:45 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=90=8D?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php index 48076b6760..505d561181 100644 --- a/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php +++ b/tests/class/helper/SC_Helper_Mail/SC_Helper_Mail_sfSendRegistMailTest.php @@ -31,7 +31,7 @@ public function test会員登録メールの宛名が正しい() $this->assertContains($this->arrCustomer['name01'] . $this->arrCustomer['name02'] . ' 様', $message['source']); } - public function test会員登録依頼メールの宛名が正しい() + public function test会員登録依頼メールの宛名と登録リンクのidが正しい() { # 仮会員を作成 $this->setUpCustomer(['status' => 1]); From f7262f25b20e43a3529b045e00be1c8339fd12a6 Mon Sep 17 00:00:00 2001 From: clicktx Date: Sun, 1 Sep 2024 11:28:03 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix=20#982=20=E7=99=BB=E9=8C=B2=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E9=80=81=E4=BF=A1=E6=99=82=E3=81=AB=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E3=81=8C=E5=87=BA=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/default/mail_templates/customer_mail.tpl | 4 ++-- .../default/mail_templates/customer_regist_mail.tpl | 2 +- data/class/helper/SC_Helper_Mail.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/Smarty/templates/default/mail_templates/customer_mail.tpl b/data/Smarty/templates/default/mail_templates/customer_mail.tpl index 3eefb1f8dc..b955be97cf 100644 --- a/data/Smarty/templates/default/mail_templates/customer_mail.tpl +++ b/data/Smarty/templates/default/mail_templates/customer_mail.tpl @@ -33,7 +33,7 @@  ご連絡いただければ幸いです。 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - 様 + でございます。 @@ -44,7 +44,7 @@ 本会員登録を完了するには下記URLにアクセスしてください。 ※入力されたお客様の情報はSSL暗号化通信により保護されます。 -regist/?mode=regist&id= +regist/?mode=regist&id= 上記URLにて本会員登録が完了いたしましたら改めてご登録内容ご確認 メールをお送り致します。 diff --git a/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl b/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl index 4db002abbd..481bcebb5a 100644 --- a/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl +++ b/data/Smarty/templates/default/mail_templates/customer_regist_mail.tpl @@ -32,7 +32,7 @@  ご連絡いただければ幸いです。 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - 様 +でございます。 diff --git a/data/class/helper/SC_Helper_Mail.php b/data/class/helper/SC_Helper_Mail.php index 3fc82696e2..83652ebee7 100644 --- a/data/class/helper/SC_Helper_Mail.php +++ b/data/class/helper/SC_Helper_Mail.php @@ -373,10 +373,11 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa $objMailText = new SC_SiteView_Ex(); $objMailText->setPage($this->getPage()); $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $arrCustomerData['name01']); - $objMailText->assign('name02', $arrCustomerData['name02']); + $objMailText->assign('arrCustomer', $arrCustomerData); + + // 旧テンプレート互換用 https://github.com/EC-CUBE/ec-cube2/issues/982 + $objMailText->assignarray($arrCustomerData); $objMailText->assign('uniqid', $arrCustomerData['secret_key']); - $objMailText->assignobj($arrCustomerData); $objHelperMail = new SC_Helper_Mail_Ex(); // 仮会員が有効の場合 @@ -386,7 +387,6 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa } else { $subject = $objHelperMail->sfMakeSubject('会員登録のご完了', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - } $objMail = new SC_SendMail_Ex(); From fded29c5188917c4edb4b1b6636e31494a4ef5ac Mon Sep 17 00:00:00 2001 From: Seasoft Date: Sun, 1 Sep 2024 15:34:58 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0=E3=80=81=E3=82=BD=E3=83=BC?= =?UTF-8?q?=E3=82=B9=E6=95=B4=E5=BD=A2=E3=80=81=E3=82=BD=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/class/helper/SC_Helper_Mail.php | 8 +++++--- .../class/pages/admin/customer/LC_Page_Admin_Customer.php | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/data/class/helper/SC_Helper_Mail.php b/data/class/helper/SC_Helper_Mail.php index 83652ebee7..d76c1cb52e 100644 --- a/data/class/helper/SC_Helper_Mail.php +++ b/data/class/helper/SC_Helper_Mail.php @@ -349,7 +349,7 @@ public function sfCheckCustomerMailMaga($email) /** * 登録メールを送信する。 * - * @param string $secret_key 会員固有キー + * @param string $secret_key 会員固有キー。$customer_id に有効な数値が指定されると、無視される。 * @param integer $customer_id 会員ID * @param boolean $is_mobile false(default):PCアドレスにメールを送る true:携帯アドレスにメールを送る * @param $resend_flg true 仮登録メール再送 @@ -380,8 +380,10 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa $objMailText->assign('uniqid', $arrCustomerData['secret_key']); $objHelperMail = new SC_Helper_Mail_Ex(); - // 仮会員が有効の場合 - if (CUSTOMER_CONFIRM_MAIL == true and $arrCustomerData['status'] == 1 or $arrCustomerData['status'] == 1 and $resend_flg == true) { + // 仮会員が有効の場合 (FIXME: コメント不正確) + if ($arrCustomerData['status'] == 1 + && (CUSTOMER_CONFIRM_MAIL == true || $resend_flg == true) + ) { $subject = $objHelperMail->sfMakeSubject('会員登録のご確認', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); } else { diff --git a/data/class/pages/admin/customer/LC_Page_Admin_Customer.php b/data/class/pages/admin/customer/LC_Page_Admin_Customer.php index 3d968af10f..8ab63e5a2c 100644 --- a/data/class/pages/admin/customer/LC_Page_Admin_Customer.php +++ b/data/class/pages/admin/customer/LC_Page_Admin_Customer.php @@ -190,12 +190,13 @@ public function lfDoResendMail($customer_id) //対象となるデータが見つからない、または削除済み return false; } - //仮登録メール再送 - $resend_flg = true; - // 登録メール再送 + + // 仮登録メール送信 $objHelperMail = new SC_Helper_Mail_Ex(); $objHelperMail->setPage($this); + $resend_flg = true; $objHelperMail->sfSendRegistMail($arrData['secret_key'], $customer_id, null, $resend_flg); + return true; } From f14ed0911d9096ecb62bde02f2429ad5fe6ac930 Mon Sep 17 00:00:00 2001 From: Seasoft Date: Sun, 1 Sep 2024 15:40:08 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=95=E3=83=AD=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=A7=E7=99=BA=E7=94=9F=E3=81=97=E3=81=9F=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=82=92=E5=9B=9E=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ページクラスで処理せず、SC_Helper_Mail::sfSendRegistMail() を呼び出すように変更した。 --- data/class/pages/entry/LC_Page_Entry.php | 39 ++-------------------- data/class/pages/regist/LC_Page_Regist.php | 37 ++------------------ 2 files changed, 6 insertions(+), 70 deletions(-) diff --git a/data/class/pages/entry/LC_Page_Entry.php b/data/class/pages/entry/LC_Page_Entry.php index 03920f391b..cafb2dcc1a 100644 --- a/data/class/pages/entry/LC_Page_Entry.php +++ b/data/class/pages/entry/LC_Page_Entry.php @@ -222,44 +222,11 @@ public function lfMakeSqlVal(&$objFormParam) */ public function lfSendMail($uniqid, $arrForm) { - $CONF = SC_Helper_DB_Ex::sfGetBasisData(); + $objHelperMail = new SC_Helper_Mail_Ex(); - $objMailText = new SC_SiteView_Ex(); - $objMailText->setPage($this); - $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $arrForm['name01']); - $objMailText->assign('name02', $arrForm['name02']); - $objMailText->assign('uniqid', $uniqid); - - $objHelperMail = new SC_Helper_Mail_Ex(); $objHelperMail->setPage($this); - - // 仮会員が有効の場合 - if (CUSTOMER_CONFIRM_MAIL == true) { - $subject = $objHelperMail->sfMakeSubject('会員登録のご確認'); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); - } else { - $subject = $objHelperMail->sfMakeSubject('会員登録のご完了'); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - } - - $objMail = new SC_SendMail_Ex(); - $objMail->setItem( - '', // 宛先 - $subject, // サブジェクト - $toCustomerMail, // 本文 - $CONF['email03'], // 配送元アドレス - $CONF['shop_name'], // 配送元 名前 - $CONF['email03'], // reply_to - $CONF['email04'], // return_path - $CONF['email04'], // Errors_to - $CONF['email01'] // Bcc - ); - // 宛先の設定 - $objMail->setTo($arrForm['email'], - $arrForm['name01'] . $arrForm['name02'] .' 様'); - - $objMail->sendMail(); + $resend_flg = true; + $objHelperMail->sfSendRegistMail($uniqid, '', false, $resend_flg); } /** diff --git a/data/class/pages/regist/LC_Page_Regist.php b/data/class/pages/regist/LC_Page_Regist.php index cc96a408df..930e5b00dd 100644 --- a/data/class/pages/regist/LC_Page_Regist.php +++ b/data/class/pages/regist/LC_Page_Regist.php @@ -135,40 +135,9 @@ public function lfCheckError($array) */ public function lfSendRegistMail($registSecretKey) { - $objQuery = SC_Query_Ex::getSingletonInstance(); - $objCustomer = new SC_Customer_Ex(); - $objHelperMail = new SC_Helper_Mail_Ex(); + $objHelperMail = new SC_Helper_Mail_Ex(); + $objHelperMail->setPage($this); - $CONF = SC_Helper_DB_Ex::sfGetBasisData(); - - //-- 会員データを取得 - $arrCustomer = $objQuery->select('*', 'dtb_customer', 'secret_key = ?', array($registSecretKey)); - $data = $arrCustomer[0]; - $objCustomer->setLogin($data['email']); - - //-- メール送信 - $objMailText = new SC_SiteView_Ex(); - $objMailText->setPage($this); - $objMailText->assign('CONF', $CONF); - $objMailText->assign('name01', $data['name01']); - $objMailText->assign('name02', $data['name02']); - $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - $subject = $objHelperMail->sfMakesubject('会員登録が完了しました。'); - $objMail = new SC_SendMail_Ex(); - - $objMail->setItem( - '', // 宛先 - $subject, // サブジェクト - $toCustomerMail, // 本文 - $CONF['email03'], // 配送元アドレス - $CONF['shop_name'], // 配送元 名前 - $CONF['email03'], // reply_to - $CONF['email04'], // return_path - $CONF['email04'] // Errors_to - ); - // 宛先の設定 - $name = $data['name01'] . $data['name02'] .' 様'; - $objMail->setTo($data['email'], $name); - $objMail->sendMail(); + $objHelperMail->sfSendRegistMail($registSecretKey); } }