source: branches/comu-ver2/data/class/pages/admin/ownersstore/LC_Page_Admin_OwnersStore_Settings.php @ 18187

Revision 18187, 6.1 KB checked in by ramrun, 15 years ago (diff)

#261 設定見直し

  • 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-2007 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_PATH . "pages/LC_Page.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 {
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
70        // ログインチェック
71        SC_Utils::sfIsSuccess(new SC_Session());
72
73        // トランザクションIDの取得
74        $this->transactionid = $this->getToken();
75
76        // $_POST['mode']によってアクション振り分け
77        switch($this->getMode()) {
78        // 入力内容をDBへ登録する
79        case 'register':
80            $this->execRegisterMode();
81            break;
82        // 初回表示
83        default:
84            $this->execDefaultMode();
85        }
86
87        // ページ出力
88        $objView = new SC_AdminView();
89        $objView->assignObj($this);
90        $objView->display(MAIN_FRAME);
91    }
92
93    /**
94     * デストラクタ.
95     *
96     * @return void
97     */
98    function destroy() {
99        parent::destroy();
100    }
101
102    /**
103     * switchアクション振り分け用パラメータを取得する.
104     *
105     * @param void
106     * @return string モード名
107     */
108    function getMode() {
109        $mode = '';
110        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
111            if (isset($_GET['mode'])) $mode = $_GET['mode'];
112        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
113            if (isset($_POST['mode'])) $mode = $_POST['mode'];
114        }
115        return $mode;
116    }
117
118    /**
119     * registerアクションの実行.
120     * 入力内容をDBへ登録する.
121     *
122     * @param void
123     * @return void
124     */
125    function execRegisterMode() {
126        if ($this->isValidToken() !== true) {
127            SC_Utils_Ex::sfDispError('');
128        }
129        // パラメータオブジェクトの初期化
130        $this->initRegisterMode();
131        // POSTされたパラメータの検証
132        $arrErr = $this->validateRegistermode();
133
134        // エラー時の処理
135        if (!empty($arrErr)) {
136            $this->arrErr  = $arrErr;
137            $this->arrForm = $this->objForm->getHashArray();
138            $this->transactionid = $this->getToken();
139            return;
140        }
141
142        // エラーがなければDBへ登録
143        $arrForm = $this->objForm->getHashArray();
144        $this->registerOwnersStoreSettings($arrForm);
145
146        $this->arrForm = $arrForm;
147
148        $this->tpl_onload = "alert('登録しました。')";
149        $this->transactionid = $this->getToken();
150    }
151
152    /**
153     * registerアクションの初期化.
154     * SC_FormParamを初期化しメンバ変数にセットする.
155     *
156     * @param void
157     * @return void
158     */
159    function initRegisterMode() {
160        // 前後の空白を削除
161        if (isset($_POST['public_key'])) {
162            $_POST['public_key'] = trim($_POST['public_key']);
163        }
164
165        $objForm = new SC_FormParam();
166        $objForm->addParam('認証キー', 'public_key', LTEXT_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
167        $objForm->setParam($_POST);
168
169        $this->objForm = $objForm;
170    }
171
172    /**
173     * registerアクションのパラメータを検証する.
174     *
175     * @param void
176     * @return array エラー情報を格納した連想配列
177     */
178    function validateRegistermode() {
179        return $this->objForm->checkError();
180    }
181
182    /**
183     * defaultアクションの実行.
184     * DBから登録内容を取得し表示する.
185     *
186     * @param void
187     * @return void
188     */
189    function execDefaultMode() {
190        $this->arrForm = $this->getOwnersStoreSettings();
191    }
192
193    /**
194     * DBへ入力内容を登録する.
195     *
196     * @param array $arrSettingsData オーナーズストア設定の連想配列
197     * @return void
198     */
199    function registerOwnersStoreSettings($arrSettingsData) {
200        $table = 'dtb_ownersstore_settings';
201        $objQuery = new SC_Query();
202        $count = $objQuery->count($table);
203
204        if ($count) {
205            $objQuery->update($table, $arrSettingsData);
206        } else {
207            $objQuery->insert($table, $arrSettingsData);
208        }
209    }
210
211    /**
212     * DBから登録内容を取得する.
213     *
214     * @param void
215     * @return array
216     */
217    function getOwnersStoreSettings(){
218        $table   = 'dtb_ownersstore_settings';
219        $colmuns = '*';
220
221        $objQuery = new SC_Query();
222        $arrRet = $objQuery->select($colmuns, $table);
223
224        if (isset($arrRet[0])) return $arrRet[0];
225
226        return array();
227    }
228}
229?>
Note: See TracBrowser for help on using the repository browser.