source: branches/version-2_13-dev/data/class/helper/SC_Helper_Mailtemplate.php @ 23124

Revision 23124, 3.4 KB checked in by kimoto, 11 years ago (diff)

#2043 typo修正・ソース整形・ソースコメントの改善 for 2.13.0
PHP4的な書き方の修正

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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_Mailtemplate
32{
33    /**
34     * メールテンプレートの情報を取得.
35     *
36     * @param  integer $template_id メールテンプレートID
37     * @param  boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false
38     * @return array
39     */
40    public function get($template_id, $has_deleted = false)
41    {
42        $objQuery =& SC_Query_Ex::getSingletonInstance();
43        $col = '*';
44        $where = 'template_id = ?';
45        if (!$has_deleted) {
46            $where .= ' AND del_flg = 0';
47        }
48        $arrRet = $objQuery->select($col, 'dtb_mailtemplate', $where, array($template_id));
49
50        return $arrRet[0];
51    }
52
53    /**
54     * メールテンプレート一覧の取得.
55     *
56     * @param  boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false
57     * @return array
58     */
59    public function getList($has_deleted = false)
60    {
61        $objQuery =& SC_Query_Ex::getSingletonInstance();
62        $col = '*';
63        $where = '';
64        if (!$has_deleted) {
65            $where .= 'del_flg = 0';
66        }
67        $table = 'dtb_mailtemplate';
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 save($sqlval)
80    {
81        $objQuery =& SC_Query_Ex::getSingletonInstance();
82
83        $template_id = $sqlval['template_id'];
84        $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
85        // 存在確認
86        $where = 'template_id = ?';
87        $exist = $objQuery->exists('dtb_mailtemplate', $where, array($template_id));
88        // 新規登録
89        if (!$exist) {
90            // INSERTの実行
91            $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
92            if (!$sqlval['template_id']) {
93                $sqlval['template_id'] = $objQuery->nextVal('dtb_mailtemplate_template_id');
94            }
95            $ret = $objQuery->insert('dtb_mailtemplate', $sqlval);
96        // 既存編集
97        } else {
98            unset($sqlval['creator_id']);
99            unset($sqlval['create_date']);
100            $ret = $objQuery->update('dtb_mailtemplate', $sqlval, $where, array($template_id));
101        }
102
103        return ($ret) ? $sqlval['template_id'] : FALSE;
104    }
105}
Note: See TracBrowser for help on using the repository browser.