source: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php @ 20297

Revision 20297, 4.6 KB checked in by coelacanth, 13 years ago (diff)

#964 リファクタリング action以外でのPOST、GET、SESSIONの利用を引数で渡す形に変更

  • 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_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * ポイント設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Point extends LC_Page_Admin {
35
36    // {{{ properties
37
38    /** フォームパラメータの配列 */
39    var $objFormParam;
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $this->tpl_mainpage = 'basis/point.tpl';
52        $this->tpl_subnavi = 'basis/subnavi.tpl';
53        $this->tpl_subno = 'point';
54        $this->tpl_mainno = 'basis';
55        $this->tpl_subtitle = 'ポイント設定';
56    }
57
58    /**
59     * Page のプロセス.
60     *
61     * @return void
62     */
63    function process() {
64        $this->action();
65        $this->sendResponse();
66    }
67
68    /**
69     * Page のアクション.
70     *
71     * @return void
72     */
73    function action() {
74        $objSess = new SC_Session();
75
76        // 認証可否の判定
77        SC_Utils_Ex::sfIsSuccess($objSess);
78
79        $objDb = new SC_Helper_DB_Ex();
80
81        // パラメータ管理クラス
82        $this->objFormParam = new SC_FormParam();
83        // パラメータ情報の初期化
84        $this->lfInitParam();
85        // POST値の取得
86        $this->objFormParam->setParam($_POST);
87
88        $cnt = $objDb->sfGetBasisCount();
89        if ($cnt > 0) {
90            $this->tpl_mode = "update";
91        } else {
92            $this->tpl_mode = "insert";
93        }
94
95        if(!empty($_POST)) {
96            // 入力値の変換
97            $this->objFormParam->convParam();
98            $this->arrErr = $this->objFormParam->checkError();
99
100            if(count($this->arrErr) == 0) {
101                switch($this->getMode()) {
102                case 'update':
103                    $this->lfUpdateData($this->objFormParam->getHashArray()); // 既存編集
104                    break;
105                case 'insert':
106                    $this->lfInsertData($this->objFormParam->getHashArray()); // 新規作成
107                    break;
108                default:
109                    break;
110                }
111                // 再表示
112                //sfReload();
113                $this->tpl_onload = "window.alert('ポイント設定が完了しました。');";
114            }
115        } else {
116            $arrCol = $this->objFormParam->getKeyList(); // キー名一覧を取得
117            $col    = SC_Utils_Ex::sfGetCommaList($arrCol);
118            $arrRet = $objDb->sfGetBasisData(true, $col);
119            $this->objFormParam->setParam($arrRet);
120        }
121
122        $this->arrForm = $this->objFormParam->getFormParamList();
123    }
124
125    /**
126     * デストラクタ.
127     *
128     * @return void
129     */
130    function destroy() {
131        parent::destroy();
132    }
133
134    /* パラメータ情報の初期化 */
135    function lfInitParam() {
136        $this->objFormParam->addParam("ポイント付与率", "point_rate", PERCENTAGE_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
137        $this->objFormParam->addParam("会員登録時付与ポイント", "welcome_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
138    }
139
140    function lfUpdateData($post) {
141        // 入力データを渡す。
142        $sqlval = $post;
143        $sqlval['update_date'] = 'Now()';
144        $objQuery =& SC_Query::getSingletonInstance();
145        // UPDATEの実行
146        $ret = $objQuery->update("dtb_baseinfo", $sqlval);
147    }
148
149    function lfInsertData($post) {
150        // 入力データを渡す。
151        $sqlval = $post;
152        $sqlval['update_date'] = 'Now()';
153        $objQuery =& SC_Query::getSingletonInstance();
154        // INSERTの実行
155        $ret = $objQuery->insert("dtb_baseinfo", $sqlval);
156    }
157}
158?>
Note: See TracBrowser for help on using the repository browser.