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