1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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/admin/LC_Page_Admin_Ex.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * オーナーズストア:認証キー設定 のページクラス. |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class LC_Page_Admin_OwnersStore_Settings extends LC_Page_Admin_Ex |
---|
34 | { |
---|
35 | /** SC_FormParamのインスタンス */ |
---|
36 | public $objForm; |
---|
37 | |
---|
38 | /** リクエストパラメーターを格納する連想配列 */ |
---|
39 | public $arrForm; |
---|
40 | |
---|
41 | /** バリデーションエラー情報を格納する連想配列 */ |
---|
42 | public $arrErr; |
---|
43 | |
---|
44 | /** |
---|
45 | * Page を初期化する. |
---|
46 | * |
---|
47 | * @return void |
---|
48 | */ |
---|
49 | public function init() |
---|
50 | { |
---|
51 | parent::init(); |
---|
52 | |
---|
53 | $this->tpl_mainpage = 'ownersstore/settings.tpl'; |
---|
54 | $this->tpl_mainno = 'ownersstore'; |
---|
55 | $this->tpl_subno = 'settings'; |
---|
56 | $this->tpl_maintitle = 'オーナーズストア'; |
---|
57 | $this->tpl_subtitle = '認証キー設定'; |
---|
58 | $this->httpCacheControl('nocache'); |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * Page のプロセス. |
---|
63 | * |
---|
64 | * @return void |
---|
65 | */ |
---|
66 | public function process() |
---|
67 | { |
---|
68 | $this->action(); |
---|
69 | $this->sendResponse(); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * Page のアクション. |
---|
74 | * |
---|
75 | * @return void |
---|
76 | */ |
---|
77 | public function action() |
---|
78 | { |
---|
79 | switch ($this->getMode()) { |
---|
80 | // 入力内容をDBへ登録する |
---|
81 | case 'register': |
---|
82 | $this->execRegisterMode(); |
---|
83 | break; |
---|
84 | // 初回表示 |
---|
85 | default: |
---|
86 | $this->execDefaultMode(); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * registerアクションの実行. |
---|
92 | * 入力内容をDBへ登録する. |
---|
93 | * |
---|
94 | * @param void |
---|
95 | * @return void |
---|
96 | */ |
---|
97 | public function execRegisterMode() |
---|
98 | { |
---|
99 | // パラメーターオブジェクトの初期化 |
---|
100 | $this->initRegisterMode(); |
---|
101 | // POSTされたパラメーターの検証 |
---|
102 | $arrErr = $this->validateRegistermode(); |
---|
103 | |
---|
104 | // エラー時の処理 |
---|
105 | if (!empty($arrErr)) { |
---|
106 | $this->arrErr = $arrErr; |
---|
107 | $this->arrForm = $this->objForm->getHashArray(); |
---|
108 | |
---|
109 | return; |
---|
110 | } |
---|
111 | |
---|
112 | // エラーがなければDBへ登録 |
---|
113 | $arrForm = $this->objForm->getHashArray(); |
---|
114 | $this->registerOwnersStoreSettings($arrForm); |
---|
115 | |
---|
116 | $this->arrForm = $arrForm; |
---|
117 | |
---|
118 | $this->tpl_onload = "alert('登録しました。')"; |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * registerアクションの初期化. |
---|
123 | * SC_FormParamを初期化しメンバ変数にセットする. |
---|
124 | * |
---|
125 | * @param void |
---|
126 | * @return void |
---|
127 | */ |
---|
128 | public function initRegisterMode() |
---|
129 | { |
---|
130 | // 前後の空白を削除 |
---|
131 | if (isset($_POST['public_key'])) { |
---|
132 | $_POST['public_key'] = trim($_POST['public_key']); |
---|
133 | } |
---|
134 | |
---|
135 | $objForm = new SC_FormParam_Ex(); |
---|
136 | $objForm->addParam('認証キー', 'public_key', LTEXT_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
137 | $objForm->setParam($_POST); |
---|
138 | |
---|
139 | $this->objForm = $objForm; |
---|
140 | } |
---|
141 | |
---|
142 | /** |
---|
143 | * registerアクションのパラメーターを検証する. |
---|
144 | * |
---|
145 | * @param void |
---|
146 | * @return array エラー情報を格納した連想配列 |
---|
147 | */ |
---|
148 | public function validateRegistermode() |
---|
149 | { |
---|
150 | return $this->objForm->checkError(); |
---|
151 | } |
---|
152 | |
---|
153 | /** |
---|
154 | * defaultアクションの実行. |
---|
155 | * DBから登録内容を取得し表示する. |
---|
156 | * |
---|
157 | * @param void |
---|
158 | * @return void |
---|
159 | */ |
---|
160 | public function execDefaultMode() |
---|
161 | { |
---|
162 | $this->arrForm = $this->getOwnersStoreSettings(); |
---|
163 | } |
---|
164 | |
---|
165 | /** |
---|
166 | * DBへ入力内容を登録する. |
---|
167 | * |
---|
168 | * @param array $arrSettingsData オーナーズストア設定の連想配列 |
---|
169 | * @return void |
---|
170 | */ |
---|
171 | public function registerOwnersStoreSettings($arrSettingsData) |
---|
172 | { |
---|
173 | $table = 'dtb_ownersstore_settings'; |
---|
174 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
175 | $exists = $objQuery->exists($table); |
---|
176 | |
---|
177 | if ($exists) { |
---|
178 | $objQuery->update($table, $arrSettingsData); |
---|
179 | } else { |
---|
180 | $objQuery->insert($table, $arrSettingsData); |
---|
181 | } |
---|
182 | } |
---|
183 | |
---|
184 | /** |
---|
185 | * DBから登録内容を取得する. |
---|
186 | * |
---|
187 | * @param void |
---|
188 | * @return array |
---|
189 | */ |
---|
190 | public function getOwnersStoreSettings() |
---|
191 | { |
---|
192 | $table = 'dtb_ownersstore_settings'; |
---|
193 | $colmuns = '*'; |
---|
194 | |
---|
195 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
196 | $arrRet = $objQuery->select($colmuns, $table); |
---|
197 | |
---|
198 | if (isset($arrRet[0])) return $arrRet[0]; |
---|
199 | return array(); |
---|
200 | } |
---|
201 | } |
---|