source: branches/version-2_13-dev/data/class/helper/SC_Helper_Kiyaku.php @ 23546

Revision 23546, 4.8 KB checked in by shutta, 10 years ago (diff)

#2580 Copyrightを更新
Copyrightを2014に更新

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
24/**
25 * 会員規約を管理するヘルパークラス.
26 *
27 * @package Helper
28 * @author pineray
29 * @version $Id:$
30 */
31class SC_Helper_Kiyaku
32{
33    /**
34     * 会員規約の情報を取得.
35     *
36     * @param  integer $kiyaku_id   会員規約ID
37     * @param  boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false
38     * @return array
39     */
40    public function getKiyaku($kiyaku_id, $has_deleted = false)
41    {
42        $objQuery =& SC_Query_Ex::getSingletonInstance();
43        $where = 'kiyaku_id = ?';
44        if (!$has_deleted) {
45            $where .= ' AND del_flg = 0';
46        }
47        $arrRet = $objQuery->select('*', 'dtb_kiyaku', $where, array($kiyaku_id));
48
49        return $arrRet[0];
50    }
51
52    /**
53     * 会員規約一覧の取得.
54     *
55     * @param  boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false
56     * @return array
57     */
58    public function getList($has_deleted = false)
59    {
60        $objQuery =& SC_Query_Ex::getSingletonInstance();
61        $col = 'kiyaku_id, kiyaku_title, kiyaku_text';
62        $where = '';
63        if (!$has_deleted) {
64            $where .= 'del_flg = 0';
65        }
66        $table = 'dtb_kiyaku';
67        $objQuery->setOrder('rank DESC');
68        $arrRet = $objQuery->select($col, $table, $where);
69
70        return $arrRet;
71    }
72
73    /**
74     * 会員規約の登録.
75     *
76     * @param  array    $sqlval
77     * @return multiple 登録成功:会員規約ID, 失敗:FALSE
78     */
79    public function saveKiyaku($sqlval)
80    {
81        $objQuery =& SC_Query_Ex::getSingletonInstance();
82
83        $kiyaku_id = $sqlval['kiyaku_id'];
84        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
85        // 新規登録
86        if ($kiyaku_id == '') {
87            // INSERTの実行
88            $sqlval['rank'] = $objQuery->max('rank', 'dtb_kiyaku') + 1;
89            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
90            $sqlval['kiyaku_id'] = $objQuery->nextVal('dtb_kiyaku_kiyaku_id');
91            $ret = $objQuery->insert('dtb_kiyaku', $sqlval);
92        // 既存編集
93        } else {
94            unset($sqlval['creator_id']);
95            unset($sqlval['create_date']);
96            $where = 'kiyaku_id = ?';
97            $ret = $objQuery->update('dtb_kiyaku', $sqlval, $where, array($kiyaku_id));
98        }
99
100        return ($ret) ? $sqlval['kiyaku_id'] : FALSE;
101    }
102
103    /**
104     * 会員規約の削除.
105     *
106     * @param  integer $kiyaku_id 会員規約ID
107     * @return void
108     */
109    public function deleteKiyaku($kiyaku_id)
110    {
111        $objDb = new SC_Helper_DB_Ex();
112        // ランク付きレコードの削除
113        $objDb->sfDeleteRankRecord('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
114    }
115
116    /**
117     * 会員規約の表示順をひとつ上げる.
118     *
119     * @param  integer $kiyaku_id 会員規約ID
120     * @return void
121     */
122    public function rankUp($kiyaku_id)
123    {
124        $objDb = new SC_Helper_DB_Ex();
125        $objDb->sfRankUp('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
126    }
127
128    /**
129     * 会員規約の表示順をひとつ下げる.
130     *
131     * @param  integer $kiyaku_id 会員規約ID
132     * @return void
133     */
134    public function rankDown($kiyaku_id)
135    {
136        $objDb = new SC_Helper_DB_Ex();
137        $objDb->sfRankDown('dtb_kiyaku', 'kiyaku_id', $kiyaku_id);
138    }
139
140    /**
141     * 同じタイトルの規約が存在するか確認.
142     *
143     * @param  string  $title     規約タイトル
144     * @param  integer $kiyaku_id 会員規約ID
145     * @return boolean 同名のタイトルが存在:TRUE
146     */
147    public function isTitleExist($title, $kiyaku_id = NULL)
148    {
149        $objQuery =& SC_Query_Ex::getSingletonInstance();
150
151        $where  = 'del_flg = 0 AND kiyaku_title = ?';
152        $arrVal = array($title);
153
154        if (!SC_Utils_Ex::isBlank($kiyaku_id)) {
155            $where   .= ' AND kiyaku_id <> ?';
156            $arrVal[] = $kiyaku_id;
157        }
158
159        $arrRet = $objQuery->select('kiyaku_id, kiyaku_title', 'dtb_kiyaku', $where, $arrVal);
160
161        return !SC_Utils_Ex::isBlank($arrRet);
162    }
163}
Note: See TracBrowser for help on using the repository browser.