1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * 退会手続き のページクラス. |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class LC_Page_Mypage_Refusal extends LC_Page_AbstractMypage_Ex |
---|
34 | { |
---|
35 | /** |
---|
36 | * Page を初期化する. |
---|
37 | * |
---|
38 | * @return void |
---|
39 | */ |
---|
40 | public function init() |
---|
41 | { |
---|
42 | parent::init(); |
---|
43 | $this->tpl_subtitle = '退会手続き(入力ページ)'; |
---|
44 | $this->tpl_mypageno = 'refusal'; |
---|
45 | } |
---|
46 | |
---|
47 | /** |
---|
48 | * Page のプロセス. |
---|
49 | * |
---|
50 | * @return void |
---|
51 | */ |
---|
52 | public function process() |
---|
53 | { |
---|
54 | parent::process(); |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Page のAction. |
---|
59 | * |
---|
60 | * @return void |
---|
61 | */ |
---|
62 | public function action() |
---|
63 | { |
---|
64 | switch ($this->getMode()) { |
---|
65 | case 'confirm': |
---|
66 | // トークンを設定 |
---|
67 | $this->refusal_transactionid = $this->getRefusalToken(); |
---|
68 | |
---|
69 | $this->tpl_mainpage = 'mypage/refusal_confirm.tpl'; |
---|
70 | $this->tpl_subtitle = '退会手続き(確認ページ)'; |
---|
71 | break; |
---|
72 | |
---|
73 | case 'complete': |
---|
74 | // トークン入力チェック |
---|
75 | if (!$this->isValidRefusalToken()) { |
---|
76 | // エラー画面へ遷移する |
---|
77 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); |
---|
78 | SC_Response_Ex::actionExit(); |
---|
79 | } |
---|
80 | |
---|
81 | $objCustomer = new SC_Customer_Ex(); |
---|
82 | $this->lfSendRefusalMail($objCustomer->getValue('customer_id')); |
---|
83 | $this->lfDeleteCustomer($objCustomer->getValue('customer_id')); |
---|
84 | $objCustomer->EndSession(); |
---|
85 | |
---|
86 | SC_Response_Ex::sendRedirect('refusal_complete.php'); |
---|
87 | break; |
---|
88 | |
---|
89 | default: |
---|
90 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
91 | $this->refusal_transactionid = $this->getRefusalToken(); |
---|
92 | } |
---|
93 | break; |
---|
94 | } |
---|
95 | |
---|
96 | } |
---|
97 | |
---|
98 | /** |
---|
99 | * トランザクショントークンを取得する |
---|
100 | * |
---|
101 | * @return string |
---|
102 | */ |
---|
103 | function getRefusalToken() { |
---|
104 | if (empty($_SESSION['refusal_transactionid'])) { |
---|
105 | $_SESSION['refusal_transactionid'] = SC_Helper_Session_Ex::createToken(); |
---|
106 | } |
---|
107 | return $_SESSION['refusal_transactionid']; |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * トランザクショントークンのチェックを行う |
---|
112 | */ |
---|
113 | function isValidRefusalToken() { |
---|
114 | if (empty($_POST['refusal_transactionid'])) { |
---|
115 | $ret = false; |
---|
116 | } else { |
---|
117 | $ret = $_POST['refusal_transactionid'] === $_SESSION['refusal_transactionid']; |
---|
118 | } |
---|
119 | |
---|
120 | return $ret; |
---|
121 | } |
---|
122 | |
---|
123 | /** |
---|
124 | * トランザクショントークを破棄する |
---|
125 | */ |
---|
126 | function destroyRefusalToken() { |
---|
127 | unset($_SESSION['refusal_transactionid']); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * 会員情報を削除する |
---|
132 | * |
---|
133 | * @access private |
---|
134 | * @return boolean |
---|
135 | */ |
---|
136 | public function lfDeleteCustomer($customer_id) |
---|
137 | { |
---|
138 | return SC_Helper_Customer_Ex::delete($customer_id); |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * 退会手続き完了メール送信する |
---|
143 | * |
---|
144 | * @access private |
---|
145 | * @param integer $customer_id 会員ID |
---|
146 | * @return void |
---|
147 | */ |
---|
148 | public function lfSendRefusalMail($customer_id) |
---|
149 | { |
---|
150 | // 会員データの取得 |
---|
151 | if (SC_Utils_Ex::sfIsInt($customer_id)) { |
---|
152 | $arrCustomerData = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
153 | } |
---|
154 | if (SC_Utils_Ex::isBlank($arrCustomerData)) { |
---|
155 | return false; |
---|
156 | } |
---|
157 | |
---|
158 | $CONF = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
159 | |
---|
160 | $objMailText = new SC_SiteView_Ex(); |
---|
161 | $objMailText->setPage($this); |
---|
162 | $objMailText->assign('CONF', $CONF); |
---|
163 | $objMailText->assign('name01', $arrCustomerData['name01']); |
---|
164 | $objMailText->assign('name02', $arrCustomerData['name02']); |
---|
165 | $objMailText->assignobj($this); |
---|
166 | |
---|
167 | $objHelperMail = new SC_Helper_Mail_Ex(); |
---|
168 | $objHelperMail->setPage($this); |
---|
169 | |
---|
170 | $subject = $objHelperMail->sfMakeSubject('退会手続きのご完了', $objMailText); |
---|
171 | $toCustomerMail = $objMailText->fetch('mail_templates/customer_refusal_mail.tpl'); |
---|
172 | |
---|
173 | $objMail = new SC_SendMail_Ex(); |
---|
174 | $objMail->setItem( |
---|
175 | '', // 宛先 |
---|
176 | $subject, // サブジェクト |
---|
177 | $toCustomerMail, // 本文 |
---|
178 | $CONF['email03'], // 配送元アドレス |
---|
179 | $CONF['shop_name'], // 配送元 名前 |
---|
180 | $CONF['email03'], // reply_to |
---|
181 | $CONF['email04'], // return_path |
---|
182 | $CONF['email04'], // Errors_to |
---|
183 | $CONF['email01'] // Bcc |
---|
184 | ); |
---|
185 | $objMail->setTo($arrCustomerData['email'], $arrCustomerData['name01'] . $arrCustomerData['name02'] .' 様'); |
---|
186 | |
---|
187 | $objMail->sendMail(); |
---|
188 | } |
---|
189 | |
---|
190 | } |
---|