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

Revision 19805, 6.9 KB checked in by Seasoft, 13 years ago (diff)

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

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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_Kiyaku extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'basis/kiyaku.tpl';
47        $this->tpl_subnavi = 'basis/subnavi.tpl';
48        $this->tpl_subno = 'kiyaku';
49        $this->tpl_subtitle = '会員規約登録';
50        $this->tpl_mainno = 'basis';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のアクション.
65     *
66     * @return void
67     */
68    function action() {
69        $objSess = new SC_Session();
70        $objQuery = new SC_Query();
71        $objDb = new SC_Helper_DB_Ex();
72
73        // 認証可否の判定
74        SC_Utils_Ex::sfIsSuccess($objSess);
75
76        if (!isset($_POST['mode'])) $_POST['mode'] = "";
77
78        // 要求判定
79        switch($_POST['mode']) {
80        // 編集処理
81        case 'edit':
82            // POST値の引き継ぎ
83            $this->arrForm = $_POST;
84            // 入力文字の変換
85            $this->arrForm = $this->lfConvertParam($this->arrForm);
86
87            // エラーチェック
88            $this->arrErr = $this->lfErrorCheck();
89            if(count($this->arrErr) <= 0) {
90                if($_POST['kiyaku_id'] == "") {
91                    $this->lfInsertClass($this->arrForm);   // 新規作成
92                } else {
93                    $this->lfUpdateClass($this->arrForm);   // 既存編集
94                }
95                // 再表示
96                $this->objDisplay->reload();
97            } else {
98                // POSTデータを引き継ぐ
99                $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
100            }
101            break;
102        // 削除
103        case 'delete':
104            $objDb->sfDeleteRankRecord("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id'], "", true);
105            // 再表示
106            $this->objDisplay->reload();
107            break;
108        // 編集前処理
109        case 'pre_edit':
110            // 編集項目をDBより取得する。
111            $where = "kiyaku_id = ?";
112            $arrRet = $objQuery->select("kiyaku_text, kiyaku_title", "dtb_kiyaku", $where, array($_POST['kiyaku_id']));
113            // 入力項目にカテゴリ名を入力する。
114            $this->arrForm['kiyaku_title'] = $arrRet[0]['kiyaku_title'];
115            $this->arrForm['kiyaku_text'] = $arrRet[0]['kiyaku_text'];
116            // POSTデータを引き継ぐ
117            $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
118        break;
119        case 'down':
120            $objDb->sfRankDown("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
121            // 再表示
122            $this->objDisplay->reload();
123            break;
124        case 'up':
125            $objDb->sfRankUp("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
126            // 再表示
127            $this->objDisplay->reload();
128            break;
129        default:
130            break;
131        }
132
133        // 規格の読込
134        $where = "del_flg <> 1";
135        $objQuery->setOrder("rank DESC");
136        $this->arrKiyaku = $objQuery->select("kiyaku_title, kiyaku_text, kiyaku_id", "dtb_kiyaku", $where);
137    }
138
139    /**
140     * デストラクタ.
141     *
142     * @return void
143     */
144    function destroy() {
145        parent::destroy();
146    }
147
148    /* DBへの挿入 */
149    function lfInsertClass($arrData) {
150        $objQuery = new SC_Query();
151        // INSERTする値を作成する。
152        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
153        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
154        $sqlval['creator_id'] = $_SESSION['member_id'];
155        $sqlval['rank'] = $objQuery->max("rank", "dtb_kiyaku") + 1;
156        $sqlval['update_date'] = "Now()";
157        $sqlval['create_date'] = "Now()";
158        // INSERTの実行
159        $sqlval['kiyaku_id'] = $objQuery->nextVal('dtb_kiyaku_kiyaku_id');
160        $ret = $objQuery->insert("dtb_kiyaku", $sqlval);
161        return $ret;
162    }
163
164    /* DBへの更新 */
165    function lfUpdateClass($arrData) {
166        $objQuery = new SC_Query();
167        // UPDATEする値を作成する。
168        $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
169        $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
170        $sqlval['update_date'] = "Now()";
171        $where = "kiyaku_id = ?";
172        // UPDATEの実行
173        $ret = $objQuery->update("dtb_kiyaku", $sqlval, $where, array($_POST['kiyaku_id']));
174        return $ret;
175    }
176
177    /* 取得文字列の変換 */
178    function lfConvertParam($array) {
179        // 文字変換
180        $arrConvList['kiyaku_title'] = "KVa";
181        $arrConvList['kiyaku_text'] = "KVa";
182
183        foreach ($arrConvList as $key => $val) {
184            // POSTされてきた値のみ変換する。
185            if(isset($array[$key])) {
186                $array[$key] = mb_convert_kana($array[$key] ,$val);
187            }
188        }
189        return $array;
190    }
191
192    /* 入力エラーチェック */
193    function lfErrorCheck() {
194        $objErr = new SC_CheckError();
195        $objErr->doFunc(array("規約タイトル", "kiyaku_title", SMTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
196        $objErr->doFunc(array("規約内容", "kiyaku_text", MLTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
197        if(!isset($objErr->arrErr['name'])) {
198            $objQuery = new SC_Query();
199            $arrRet = $objQuery->select("kiyaku_id, kiyaku_title", "dtb_kiyaku", "del_flg = 0 AND kiyaku_title = ?", array($_POST['kiyaku_title']));
200            // 編集中のレコード以外に同じ名称が存在する場合
201            if ($arrRet[0]['kiyaku_id'] != $_POST['kiyaku_id'] && $arrRet[0]['kiyaku_title'] == $_POST['kiyaku_title']) {
202                $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
203            }
204        }
205        return $objErr->arrErr;
206    }
207}
208?>
Note: See TracBrowser for help on using the repository browser.