| 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_PATH . "pages/LC_Page.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 { |
|---|
| 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 | $conn = new SC_DBConn(); |
|---|
| 60 | $objView = new SC_AdminView(); |
|---|
| 61 | $objSess = new SC_Session(); |
|---|
| 62 | $masterData = new SC_DB_MasterData_Ex(); |
|---|
| 63 | |
|---|
| 64 | // 認証可否の判定 |
|---|
| 65 | SC_Utils_Ex::sfIsSuccess($objSess); |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | $this->arrMailTEMPLATE = $masterData->getMasterData("mtb_mail_template"); |
|---|
| 69 | |
|---|
| 70 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
|---|
| 71 | |
|---|
| 72 | if ( $_POST['mode'] == 'id_set'){ |
|---|
| 73 | // テンプレートプルダウン変更時 |
|---|
| 74 | |
|---|
| 75 | if ( SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){ |
|---|
| 76 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?"; |
|---|
| 77 | $result = $conn->getAll($sql, array($_POST['template_id']) ); |
|---|
| 78 | if ( $result ){ |
|---|
| 79 | $this->arrForm = $result[0]; |
|---|
| 80 | } else { |
|---|
| 81 | $this->arrForm['template_id'] = $_POST['template_id']; |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | } elseif ( $_POST['mode'] == 'regist' && SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){ |
|---|
| 86 | |
|---|
| 87 | // POSTデータの引き継ぎ |
|---|
| 88 | $this->arrForm = $this->lfConvertParam($_POST); |
|---|
| 89 | $this->arrErr = $this->fnErrorCheck($this->arrForm); |
|---|
| 90 | |
|---|
| 91 | if ( $this->arrErr ){ |
|---|
| 92 | // エラーメッセージ |
|---|
| 93 | $this->tpl_msg = "エラーが発生しました"; |
|---|
| 94 | |
|---|
| 95 | } else { |
|---|
| 96 | // 正常 |
|---|
| 97 | $this->lfRegist($conn, $this->arrForm); |
|---|
| 98 | |
|---|
| 99 | // 完了メッセージ |
|---|
| 100 | $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');"; |
|---|
| 101 | unset($this->arrForm); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | $objView->assignobj($this); |
|---|
| 107 | $objView->display(MAIN_FRAME); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | /** |
|---|
| 111 | * デストラクタ. |
|---|
| 112 | * |
|---|
| 113 | * @return void |
|---|
| 114 | */ |
|---|
| 115 | function destroy() { |
|---|
| 116 | parent::destroy(); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | function lfRegist( $conn, $data ){ |
|---|
| 120 | |
|---|
| 121 | $data['creator_id'] = $_SESSION['member_id']; |
|---|
| 122 | |
|---|
| 123 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?"; |
|---|
| 124 | $result = $conn->getAll($sql, array($_POST['template_id']) ); |
|---|
| 125 | if ( $result ){ |
|---|
| 126 | $sql_where = "template_id = ". addslashes($_POST['template_id']); |
|---|
| 127 | $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data); |
|---|
| 128 | }else{ |
|---|
| 129 | $conn->query("INSERT INTO dtb_mailtemplate (template_id,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,now(),now() )", $data); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | function lfConvertParam($array) { |
|---|
| 136 | |
|---|
| 137 | $new_array["template_id"] = $array["template_id"]; |
|---|
| 138 | $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV"); |
|---|
| 139 | $new_array["header"] = mb_convert_kana($array["header"] ,"KV"); |
|---|
| 140 | $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV"); |
|---|
| 141 | |
|---|
| 142 | return $new_array; |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | /* 入力エラーのチェック */ |
|---|
| 146 | function fnErrorCheck($array) { |
|---|
| 147 | |
|---|
| 148 | $objErr = new SC_CheckError($array); |
|---|
| 149 | |
|---|
| 150 | $objErr->doFunc(array("テンプレート",'template_id'), array("EXIST_CHECK")); |
|---|
| 151 | $objErr->doFunc(array("メールタイトル",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 152 | $objErr->doFunc(array("ヘッダー",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK")); |
|---|
| 153 | $objErr->doFunc(array("フッター",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK")); |
|---|
| 154 | |
|---|
| 155 | return $objErr->arrErr; |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | ?> |
|---|