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

Revision 23606, 6.1 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/e0f27994-b3c7-4fc6-ad70-55d3cd63769b/patches

  • 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-2014 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
24require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
25
26/**
27 * 会員規約設定 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Admin_Basis_Kiyaku extends LC_Page_Admin_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    public function init()
41    {
42        parent::init();
43        $this->tpl_mainpage = 'basis/kiyaku.tpl';
44        $this->tpl_subno = 'kiyaku';
45        $this->tpl_maintitle = '基本情報管理';
46        $this->tpl_subtitle = '会員規約設定';
47        $this->tpl_mainno = 'basis';
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    public function process()
56    {
57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のアクション.
63     *
64     * @return void
65     */
66    public function action()
67    {
68        $objKiyaku = new SC_Helper_Kiyaku_Ex();
69
70        $mode = $this->getMode();
71        $objFormParam = new SC_FormParam_Ex();
72        $this->lfInitParam($mode, $objFormParam);
73        $objFormParam->setParam($_POST);
74        $objFormParam->convParam();
75
76        $kiyaku_id = $objFormParam->getValue('kiyaku_id');
77
78        // 要求判定
79        switch ($mode) {
80            // 編集処理
81            case 'confirm':
82                // エラーチェック
83                $this->arrErr = $this->lfCheckError($objFormParam, $objKiyaku);
84                if (!SC_Utils_Ex::isBlank($this->arrErr['kiyaku_id'])) {
85                    trigger_error('', E_USER_ERROR);
86
87                    return;
88                }
89
90                if (SC_Utils_Ex::isBlank($this->arrErr)) {
91                    // POST値の引き継ぎ
92                    $arrParam = $objFormParam->getHashArray();
93                    // 登録実行
94                    $res_kiyaku_id = $this->doRegist($kiyaku_id, $arrParam, $objKiyaku);
95                    if ($res_kiyaku_id !== FALSE) {
96                        // 完了メッセージ
97                        $kiyaku_id = $res_kiyaku_id;
98                        $this->tpl_onload = "alert('登録が完了しました。');";
99                    }
100                }
101
102                // 編集中の規約IDを渡す
103                $this->tpl_kiyaku_id = $kiyaku_id;
104                break;
105            // 削除
106            case 'delete':
107                $objKiyaku->deleteKiyaku($kiyaku_id);
108                break;
109
110            // 編集前処理
111            case 'pre_edit':
112                // 編集項目を取得する。
113                $arrKiyakuData = $objKiyaku->getKiyaku($kiyaku_id);
114                $objFormParam->setParam($arrKiyakuData);
115
116                // 編集中の規約IDを渡す
117                $this->tpl_kiyaku_id = $kiyaku_id;
118                break;
119
120            case 'down':
121                $objKiyaku->rankDown($kiyaku_id);
122
123                // 再表示
124                $this->objDisplay->reload();
125                break;
126
127            case 'up':
128                $objKiyaku->rankUp($kiyaku_id);
129
130                // 再表示
131                $this->objDisplay->reload();
132                break;
133
134            default:
135                break;
136        }
137
138        $this->arrForm = $objFormParam->getFormParamList();
139
140        // 規約一覧を取得
141        $this->arrKiyaku = $objKiyaku->getList();
142    }
143
144    /**
145     * 登録処理を実行.
146     *
147     * @param  integer  $kiyaku_id
148     * @param  array    $sqlval
149     * @param  SC_Helper_Kiyaku_Ex   $objKiyaku
150     * @return multiple
151     */
152    public function doRegist($kiyaku_id, $sqlval, SC_Helper_Kiyaku_Ex &$objKiyaku)
153    {
154        $sqlval['kiyaku_id'] = $kiyaku_id;
155        $sqlval['creator_id'] = $_SESSION['member_id'];
156
157        return $objKiyaku->saveKiyaku($sqlval);
158    }
159
160    /**
161     * @param string|null $mode
162     * @param SC_FormParam_Ex $objFormParam
163     */
164    public function lfInitParam($mode, &$objFormParam)
165    {
166        switch ($mode) {
167            case 'confirm':
168            case 'pre_edit':
169                $objFormParam->addParam('規約タイトル', 'kiyaku_title', SMTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
170                $objFormParam->addParam('規約内容', 'kiyaku_text', MLTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
171                $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
172                break;
173            case 'delete':
174            case 'down':
175            case 'up':
176            default:
177                $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
178                break;
179        }
180    }
181
182    /**
183     * 入力エラーチェック
184     *
185     * @param  SC_Helper_Kiyaku_Ex $objKiyaku
186     * @param SC_FormParam_Ex $objFormParam
187     * @return array
188     */
189    public function lfCheckError($objFormParam, SC_Helper_Kiyaku_Ex &$objKiyaku)
190    {
191        $arrErr = $objFormParam->checkError();
192        $arrForm = $objFormParam->getHashArray();
193
194        $isTitleExist = $objKiyaku->isTitleExist($arrForm['kiyaku_title'], $arrForm['kiyaku_id']);
195        // 編集中のレコード以外に同じ名称が存在する場合
196        if ($isTitleExist) {
197            $arrErr['name'] = '※ 既に同じ内容の登録が存在します。<br />';
198        }
199
200        return $arrErr;
201    }
202}
Note: See TracBrowser for help on using the repository browser.