[16070] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[21867] | 5 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
[16070] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[16070] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php'; |
---|
[16070] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 登録内容変更 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20162] | 34 | class LC_Page_Mypage_Change extends LC_Page_AbstractMypage_Ex { |
---|
[16070] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
[22100] | 46 | $this->tpl_subtitle = t('LC_Page_Mypage_Change_001'); |
---|
[16070] | 47 | $this->tpl_mypageno = 'change'; |
---|
| 48 | |
---|
[20147] | 49 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[21481] | 50 | $this->arrReminder = $masterData->getMasterData('mtb_reminder'); |
---|
[20147] | 51 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[21481] | 52 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
| 53 | $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type'); |
---|
| 54 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
[18187] | 55 | $this->httpCacheControl('nocache'); |
---|
[20041] | 56 | |
---|
[19892] | 57 | // 生年月日選択肢の取得 |
---|
[20538] | 58 | $objDate = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now'))); |
---|
[20477] | 59 | $this->arrYear = $objDate->getYear('', START_BIRTH_YEAR, ''); |
---|
[20147] | 60 | $this->arrMonth = $objDate->getMonth(true); |
---|
| 61 | $this->arrDay = $objDate->getDay(true); |
---|
[16070] | 62 | } |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * Page のプロセス. |
---|
| 66 | * |
---|
| 67 | * @return void |
---|
| 68 | */ |
---|
| 69 | function process() { |
---|
[20147] | 70 | parent::process(); |
---|
[19661] | 71 | } |
---|
[20041] | 72 | |
---|
[19661] | 73 | /** |
---|
[19892] | 74 | * Page のプロセス |
---|
[19661] | 75 | * @return void |
---|
| 76 | */ |
---|
| 77 | function action() { |
---|
[21596] | 78 | |
---|
[20490] | 79 | $objCustomer = new SC_Customer_Ex(); |
---|
[20147] | 80 | $customer_id = $objCustomer->getValue('customer_id'); |
---|
[20041] | 81 | |
---|
[19892] | 82 | // mobile用(戻るボタンでの遷移かどうかを判定) |
---|
[20538] | 83 | if (!empty($_POST['return'])) { |
---|
| 84 | $_POST['mode'] = 'return'; |
---|
[16070] | 85 | } |
---|
[20041] | 86 | |
---|
[20970] | 87 | // パラメーター管理クラス,パラメーター情報の初期化 |
---|
[20501] | 88 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20147] | 89 | SC_Helper_Customer_Ex::sfCustomerMypageParam($objFormParam); |
---|
| 90 | $objFormParam->setParam($_POST); // POST値の取得 |
---|
[20041] | 91 | |
---|
[20147] | 92 | switch ($this->getMode()) { |
---|
[21275] | 93 | // 確認 |
---|
| 94 | case 'confirm': |
---|
[21683] | 95 | if (isset($_POST['submit_address'])) { |
---|
[21679] | 96 | // 入力エラーチェック |
---|
[21883] | 97 | $this->arrErr = $this->lfCheckError($_POST); |
---|
[21679] | 98 | // 入力エラーの場合は終了 |
---|
| 99 | if (count($this->arrErr) == 0) { |
---|
| 100 | // 郵便番号検索文作成 |
---|
| 101 | $zipcode = $_POST['zip01'] . $_POST['zip02']; |
---|
| 102 | |
---|
| 103 | // 郵便番号検索 |
---|
| 104 | $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode); |
---|
[21683] | 105 | |
---|
[21679] | 106 | // 郵便番号が発見された場合 |
---|
| 107 | if (!empty($arrAdsList)) { |
---|
| 108 | $data['pref'] = $arrAdsList[0]['state']; |
---|
| 109 | $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town']; |
---|
[21683] | 110 | $objFormParam->setParam($data); |
---|
[21679] | 111 | |
---|
[21683] | 112 | } |
---|
| 113 | // 該当無し |
---|
| 114 | else { |
---|
[22100] | 115 | $this->arrErr['zip01'] = t('LC_Page_Mypage_Change_002'); |
---|
[21679] | 116 | } |
---|
| 117 | } |
---|
[21683] | 118 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 119 | break; |
---|
| 120 | } |
---|
[21275] | 121 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam); |
---|
| 122 | $this->arrForm = $objFormParam->getHashArray(); |
---|
[20041] | 123 | |
---|
[21275] | 124 | // 入力エラーなし |
---|
| 125 | if (empty($this->arrErr)) { |
---|
| 126 | //パスワード表示 |
---|
| 127 | $this->passlen = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password'])); |
---|
[20041] | 128 | |
---|
[21275] | 129 | $this->tpl_mainpage = 'mypage/change_confirm.tpl'; |
---|
[22100] | 130 | $this->tpl_title = t('LC_Page_Mypage_Change_003'); |
---|
| 131 | $this->tpl_subtitle = t('LC_Page_Mypage_Change_004'); |
---|
[21275] | 132 | } |
---|
| 133 | break; |
---|
| 134 | // 会員登録と完了画面 |
---|
| 135 | case 'complete': |
---|
| 136 | $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam); |
---|
| 137 | $this->arrForm = $objFormParam->getHashArray(); |
---|
[20041] | 138 | |
---|
[21275] | 139 | // 入力エラーなし |
---|
| 140 | if (empty($this->arrErr)) { |
---|
| 141 | // 会員情報の登録 |
---|
| 142 | $this->lfRegistCustomerData($objFormParam, $customer_id); |
---|
[21596] | 143 | |
---|
[21737] | 144 | //セッション情報を最新の状態に更新する |
---|
| 145 | $objCustomer->updateSession(); |
---|
| 146 | |
---|
[21275] | 147 | |
---|
| 148 | // 完了ページに移動させる。 |
---|
| 149 | SC_Response_Ex::sendRedirect('change_complete.php'); |
---|
| 150 | } |
---|
| 151 | break; |
---|
| 152 | // 確認ページからの戻り |
---|
| 153 | case 'return': |
---|
| 154 | $this->arrForm = $objFormParam->getHashArray(); |
---|
| 155 | break; |
---|
| 156 | default: |
---|
| 157 | $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($customer_id); |
---|
| 158 | break; |
---|
[16234] | 159 | } |
---|
[21743] | 160 | |
---|
[16234] | 161 | } |
---|
| 162 | |
---|
| 163 | /** |
---|
[16070] | 164 | * デストラクタ. |
---|
| 165 | * |
---|
| 166 | * @return void |
---|
| 167 | */ |
---|
| 168 | function destroy() { |
---|
| 169 | parent::destroy(); |
---|
| 170 | } |
---|
| 171 | |
---|
[18839] | 172 | /** |
---|
[20147] | 173 | * 会員情報を登録する |
---|
[18839] | 174 | * |
---|
[20147] | 175 | * @param mixed $objFormParam |
---|
| 176 | * @param mixed $customer_id |
---|
| 177 | * @access private |
---|
| 178 | * @return void |
---|
[18839] | 179 | */ |
---|
[20147] | 180 | function lfRegistCustomerData(&$objFormParam, $customer_id) { |
---|
| 181 | $arrRet = $objFormParam->getHashArray(); |
---|
| 182 | $sqlval = $objFormParam->getDbArray(); |
---|
| 183 | $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']); |
---|
[20041] | 184 | |
---|
[20147] | 185 | SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id); |
---|
[16070] | 186 | } |
---|
[21679] | 187 | |
---|
| 188 | /** |
---|
| 189 | * 入力エラーのチェック. |
---|
| 190 | * |
---|
| 191 | * @param array $arrRequest リクエスト値($_GET) |
---|
| 192 | * @return array $arrErr エラーメッセージ配列 |
---|
| 193 | */ |
---|
[21883] | 194 | function lfCheckError($arrRequest) { |
---|
[21679] | 195 | // パラメーター管理クラス |
---|
| 196 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 197 | // パラメーター情報の初期化 |
---|
[22100] | 198 | $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
| 199 | $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK')); |
---|
[21679] | 200 | // // リクエスト値をセット |
---|
[21683] | 201 | $arrData['zip01'] = $arrRequest['zip01']; |
---|
| 202 | $arrData['zip02'] = $arrRequest['zip02']; |
---|
[21679] | 203 | $objFormParam->setParam($arrData); |
---|
| 204 | // エラーチェック |
---|
| 205 | $arrErr = $objFormParam->checkError(); |
---|
| 206 | // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック |
---|
| 207 | if (!$this->lfInputNameCheck($addData['zip01'])) { |
---|
[22100] | 208 | $arrErr['zip01'] = t('LC_Page_Mypage_Change_005'); |
---|
[21679] | 209 | } |
---|
| 210 | if (!$this->lfInputNameCheck($arrdata['zip02'])) { |
---|
[22100] | 211 | $arrErr['zip02'] = t('LC_Page_Mypage_Change_006'); |
---|
[21679] | 212 | } |
---|
| 213 | |
---|
| 214 | return $arrErr; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | /** |
---|
| 218 | * エラーチェック. |
---|
| 219 | * |
---|
| 220 | * @param string $value |
---|
| 221 | * @return エラーなし:true エラー:false |
---|
| 222 | */ |
---|
| 223 | function lfInputNameCheck($value) { |
---|
| 224 | // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー |
---|
| 225 | if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) { |
---|
| 226 | return false; |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | return true; |
---|
| 230 | } |
---|
[16070] | 231 | } |
---|