source: branches/version-2_4/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php @ 18734

Revision 18734, 6.7 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

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