source: branches/version-2_5-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php @ 19974

Revision 19974, 4.9 KB checked in by kotani, 13 years ago (diff)

#564 MDB2化による各種問題の改善

  • 管理画面>基本情報管理>メール設定 で登録できない不具合改修
  • 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_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * メール設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Mail extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'basis/mail.tpl';
47        $this->tpl_subnavi = 'basis/subnavi.tpl';
48        $this->tpl_mainno = 'basis';
49        $this->tpl_subno = 'mail';
50        $this->tpl_subtitle = 'メール設定';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のアクション.
65     *
66     * @return void
67     */
68    function action() {
69        $objQuery = new SC_Query();
70        $objSess = new SC_Session();
71        $masterData = new SC_DB_MasterData_Ex();
72
73        // 認証可否の判定
74        SC_Utils_Ex::sfIsSuccess($objSess);
75
76
77        $this->arrMailTEMPLATE = $masterData->getMasterData("mtb_mail_template");
78
79        if (!isset($_POST['mode'])) $_POST['mode'] = "";
80
81        if ( $_POST['mode'] == 'id_set'){
82            // テンプレートプルダウン変更時
83
84            if ( SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){
85                $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
86                $result = $objQuery->getAll($sql, array($_POST['template_id']) );
87                if ( $result ){
88                    $this->arrForm = $result[0];
89                } else {
90                    $this->arrForm['template_id'] = $_POST['template_id'];
91                }
92            }
93
94        } elseif ( $_POST['mode'] == 'regist' && SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){
95
96            // POSTデータの引き継ぎ
97            $this->arrForm = $this->lfConvertParam($_POST);
98            $this->arrErr = $this->fnErrorCheck($this->arrForm);
99
100            if ( $this->arrErr ){
101                // エラーメッセージ
102                $this->tpl_msg = "エラーが発生しました";
103
104            } else {
105                // 正常
106                $this->lfRegist($objQuery, $this->arrForm);
107
108                // 完了メッセージ
109                $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');";
110                unset($this->arrForm);
111            }
112
113        }
114    }
115
116    /**
117     * デストラクタ.
118     *
119     * @return void
120     */
121    function destroy() {
122        parent::destroy();
123    }
124
125    function lfRegist(&$objQuery, $data ){
126
127        $data['creator_id'] = $_SESSION['member_id'];
128
129        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
130        $result = $objQuery->getAll($sql, array($_POST['template_id']) );
131        if ( $result ){
132            $sql_where = "template_id = ?";
133            $objQuery->update("dtb_mailtemplate", $data, $sql_where, array(addslashes($_POST['template_id'])));
134        }else{
135            $objQuery->insert("dtb_mailtemplate", $data);
136        }
137
138    }
139
140
141    function lfConvertParam($array) {
142
143        $new_array["template_id"] = $array["template_id"];
144        $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
145        $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
146        $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
147
148        return $new_array;
149    }
150
151    /* 入力エラーのチェック */
152    function fnErrorCheck($array) {
153
154        $objErr = new SC_CheckError($array);
155
156        $objErr->doFunc(array("テンプレート",'template_id'), array("EXIST_CHECK"));
157        $objErr->doFunc(array("メールタイトル",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
158        $objErr->doFunc(array("ヘッダー",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
159        $objErr->doFunc(array("フッター",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
160
161        return $objErr->arrErr;
162    }
163}
164?>
Note: See TracBrowser for help on using the repository browser.