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

Revision 22735, 6.1 KB checked in by h_yoshimoto, 11 years ago (diff)

#2193 ユニットテストチームのコミットをマージ(from camp/camp-2_13-tests)

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