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

Revision 20203, 5.1 KB checked in by fukuda, 13 years ago (diff)

・SC_Helper_Mail::sfGetMailTemplateの引数を簡潔に
・SC_Utils_Ex::sfCheckNumLength()をSC_Utils_Ex::sfIsInt()に統合
・ガイドラインに合わない $this->list_data を修正

  • 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-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
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        switch ($this->getMode()) {
79        case 'id_set':
80            // テンプレートプルダウン変更時
81
82            if ( SC_Utils_Ex::sfIsInt( $_POST['template_id']) ){
83                $result = $this->lfGetMailTemplateByTemplateID($_POST['template_id']);
84                if ( $result ){
85                    $this->arrForm = $result[0];
86                } else {
87                    $this->arrForm['template_id'] = $_POST['template_id'];
88                }
89            }
90            break;
91        case 'regist':
92            if (SC_Utils_Ex::sfIsInt( $_POST['template_id']) ){
93
94                // POSTデータの引き継ぎ
95                $this->arrForm = $this->lfConvertParam($_POST);
96                $this->arrErr = $this->fnErrorCheck($this->arrForm);
97
98                if ( $this->arrErr ){
99                    // エラーメッセージ
100                    $this->tpl_msg = "エラーが発生しました";
101
102                } else {
103                    // 正常
104                    $this->lfRegist($this->arrForm);
105
106                    // 完了メッセージ
107                    $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');";
108                    unset($this->arrForm);
109                }
110            }
111            break;
112        default:
113            break;
114        }
115    }
116
117    /**
118     * デストラクタ.
119     *
120     * @return void
121     */
122    function destroy() {
123        parent::destroy();
124    }
125
126    function lfGetMailTemplateByTemplateID($template_id) {
127        $objQuery =& SC_Query::getSingletonInstance();
128
129        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
130        return $objQuery->getAll($sql, array($template_id) );
131    }
132
133    function lfRegist($data ){
134        $objQuery =& SC_Query::getSingletonInstance();
135
136        $data['creator_id'] = $_SESSION['member_id'];
137
138        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
139        $result = $objQuery->getAll($sql, array($_POST['template_id']) );
140        if ( $result ){
141            $sql_where = "template_id = ?";
142            $objQuery->update("dtb_mailtemplate", $data, $sql_where, array(addslashes($_POST['template_id'])));
143        }else{
144            $objQuery->insert("dtb_mailtemplate", $data);
145        }
146
147    }
148
149
150    function lfConvertParam($array) {
151
152        $new_array["template_id"] = $array["template_id"];
153        $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
154        $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
155        $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
156
157        return $new_array;
158    }
159
160    /* 入力エラーのチェック */
161    function fnErrorCheck($array) {
162
163        $objErr = new SC_CheckError($array);
164
165        $objErr->doFunc(array("テンプレート",'template_id'), array("EXIST_CHECK"));
166        $objErr->doFunc(array("メールタイトル",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
167        $objErr->doFunc(array("ヘッダー",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
168        $objErr->doFunc(array("フッター",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
169
170        return $objErr->arrErr;
171    }
172}
173?>
Note: See TracBrowser for help on using the repository browser.