source: branches/version-2_5-dev/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore_Settings.php @ 19803

Revision 19803, 6.2 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#628(未使用処理・定義などの削除)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 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// {{{ requires
25require_once(CLASS_FILE_PATH . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * EC-CUBEアプリケーション管理:アプリケーション設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_OwnersStore_Settings extends LC_Page_Admin {
35
36    /** SC_FormParamのインスタンス */
37    var $objForm;
38
39    /** リクエストパラメータを格納する連想配列 */
40    var $arrForm;
41
42    /** バリデーションエラー情報を格納する連想配列 */
43    var $arrErr;
44
45    // }}}
46    // {{{ functions
47
48    /**
49     * Page を初期化する.
50     *
51     * @return void
52     */
53    function init() {
54        parent::init();
55
56        $this->tpl_mainpage = 'ownersstore/settings.tpl';
57        $this->tpl_mainno   = 'ownersstore';
58        $this->tpl_subno    = 'settings';
59        $this->tpl_subtitle = '認証キー設定';
60        $this->httpCacheControl('nocache');
61    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function process() {
69        $this->action();
70        $this->sendResponse();
71    }
72
73    /**
74     * Page のアクション.
75     *
76     * @return void
77     */
78    function action() {
79        // ログインチェック
80        SC_Utils::sfIsSuccess(new SC_Session());
81
82        // トランザクションIDの取得
83        $this->transactionid = SC_Helper_Session_Ex::getToken();
84
85        // $_POST['mode']によってアクション振り分け
86        switch($this->getMode()) {
87        // 入力内容をDBへ登録する
88        case 'register':
89            $this->execRegisterMode();
90            break;
91        // 初回表示
92        default:
93            $this->execDefaultMode();
94        }
95    }
96
97    /**
98     * デストラクタ.
99     *
100     * @return void
101     */
102    function destroy() {
103        parent::destroy();
104    }
105
106    /**
107     * switchアクション振り分け用パラメータを取得する.
108     *
109     * @param void
110     * @return string モード名
111     */
112    function getMode() {
113        $mode = '';
114        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
115            if (isset($_GET['mode'])) $mode = $_GET['mode'];
116        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
117            if (isset($_POST['mode'])) $mode = $_POST['mode'];
118        }
119        return $mode;
120    }
121
122    /**
123     * registerアクションの実行.
124     * 入力内容をDBへ登録する.
125     *
126     * @param void
127     * @return void
128     */
129    function execRegisterMode() {
130        if (SC_Helper_Session_Ex::isValidToken() !== true) {
131            SC_Utils_Ex::sfDispError('');
132        }
133        // パラメータオブジェクトの初期化
134        $this->initRegisterMode();
135        // POSTされたパラメータの検証
136        $arrErr = $this->validateRegistermode();
137
138        // エラー時の処理
139        if (!empty($arrErr)) {
140            $this->arrErr  = $arrErr;
141            $this->arrForm = $this->objForm->getHashArray();
142            $this->transactionid = SC_Helper_Session_Ex::getToken();
143            return;
144        }
145
146        // エラーがなければDBへ登録
147        $arrForm = $this->objForm->getHashArray();
148        $this->registerOwnersStoreSettings($arrForm);
149
150        $this->arrForm = $arrForm;
151
152        $this->tpl_onload = "alert('登録しました。')";
153        $this->transactionid = SC_Helper_Session_Ex::getToken();
154    }
155
156    /**
157     * registerアクションの初期化.
158     * SC_FormParamを初期化しメンバ変数にセットする.
159     *
160     * @param void
161     * @return void
162     */
163    function initRegisterMode() {
164        // 前後の空白を削除
165        if (isset($_POST['public_key'])) {
166            $_POST['public_key'] = trim($_POST['public_key']);
167        }
168
169        $objForm = new SC_FormParam();
170        $objForm->addParam('認証キー', 'public_key', LTEXT_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
171        $objForm->setParam($_POST);
172
173        $this->objForm = $objForm;
174    }
175
176    /**
177     * registerアクションのパラメータを検証する.
178     *
179     * @param void
180     * @return array エラー情報を格納した連想配列
181     */
182    function validateRegistermode() {
183        return $this->objForm->checkError();
184    }
185
186    /**
187     * defaultアクションの実行.
188     * DBから登録内容を取得し表示する.
189     *
190     * @param void
191     * @return void
192     */
193    function execDefaultMode() {
194        $this->arrForm = $this->getOwnersStoreSettings();
195    }
196
197    /**
198     * DBへ入力内容を登録する.
199     *
200     * @param array $arrSettingsData オーナーズストア設定の連想配列
201     * @return void
202     */
203    function registerOwnersStoreSettings($arrSettingsData) {
204        $table = 'dtb_ownersstore_settings';
205        $objQuery = new SC_Query();
206        $count = $objQuery->count($table);
207
208        if ($count) {
209            $objQuery->update($table, $arrSettingsData);
210        } else {
211            $objQuery->insert($table, $arrSettingsData);
212        }
213    }
214
215    /**
216     * DBから登録内容を取得する.
217     *
218     * @param void
219     * @return array
220     */
221    function getOwnersStoreSettings(){
222        $table   = 'dtb_ownersstore_settings';
223        $colmuns = '*';
224
225        $objQuery = new SC_Query();
226        $arrRet = $objQuery->select($colmuns, $table);
227
228        if (isset($arrRet[0])) return $arrRet[0];
229
230        return array();
231    }
232}
233?>
Note: See TracBrowser for help on using the repository browser.