[15308] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15308] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15308] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[19805] | 25 | require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php"); |
---|
[15308] | 26 | |
---|
| 27 | /** |
---|
| 28 | * メール設定 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[19661] | 34 | class LC_Page_Admin_Basis_Mail extends LC_Page_Admin { |
---|
[15308] | 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() { |
---|
[19661] | 59 | $this->action(); |
---|
| 60 | $this->sendResponse(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * Page のアクション. |
---|
| 65 | * |
---|
| 66 | * @return void |
---|
| 67 | */ |
---|
| 68 | function action() { |
---|
[20164] | 69 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
[15308] | 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"); |
---|
[20044] | 78 | switch ($this->getMode()) { |
---|
| 79 | case 'id_set': |
---|
[15308] | 80 | // テンプレートプルダウン変更時 |
---|
| 81 | |
---|
| 82 | if ( SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){ |
---|
| 83 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?"; |
---|
[18772] | 84 | $result = $objQuery->getAll($sql, array($_POST['template_id']) ); |
---|
[15308] | 85 | if ( $result ){ |
---|
| 86 | $this->arrForm = $result[0]; |
---|
| 87 | } else { |
---|
| 88 | $this->arrForm['template_id'] = $_POST['template_id']; |
---|
| 89 | } |
---|
| 90 | } |
---|
[20044] | 91 | break; |
---|
| 92 | case 'regist': |
---|
| 93 | if (SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){ |
---|
[15308] | 94 | |
---|
[20044] | 95 | // POSTデータの引き継ぎ |
---|
| 96 | $this->arrForm = $this->lfConvertParam($_POST); |
---|
| 97 | $this->arrErr = $this->fnErrorCheck($this->arrForm); |
---|
[15308] | 98 | |
---|
[20044] | 99 | if ( $this->arrErr ){ |
---|
| 100 | // エラーメッセージ |
---|
| 101 | $this->tpl_msg = "エラーが発生しました"; |
---|
[15308] | 102 | |
---|
[20044] | 103 | } else { |
---|
| 104 | // 正常 |
---|
| 105 | $this->lfRegist($objQuery, $this->arrForm); |
---|
[15308] | 106 | |
---|
[20044] | 107 | // 完了メッセージ |
---|
| 108 | $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');"; |
---|
| 109 | unset($this->arrForm); |
---|
| 110 | } |
---|
[15308] | 111 | } |
---|
[20044] | 112 | break; |
---|
| 113 | default: |
---|
| 114 | break; |
---|
[15308] | 115 | } |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * デストラクタ. |
---|
| 120 | * |
---|
| 121 | * @return void |
---|
| 122 | */ |
---|
| 123 | function destroy() { |
---|
| 124 | parent::destroy(); |
---|
| 125 | } |
---|
| 126 | |
---|
[18772] | 127 | function lfRegist(&$objQuery, $data ){ |
---|
[15308] | 128 | |
---|
| 129 | $data['creator_id'] = $_SESSION['member_id']; |
---|
| 130 | |
---|
| 131 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?"; |
---|
[18772] | 132 | $result = $objQuery->getAll($sql, array($_POST['template_id']) ); |
---|
[15308] | 133 | if ( $result ){ |
---|
[19974] | 134 | $sql_where = "template_id = ?"; |
---|
| 135 | $objQuery->update("dtb_mailtemplate", $data, $sql_where, array(addslashes($_POST['template_id']))); |
---|
[15308] | 136 | }else{ |
---|
[19974] | 137 | $objQuery->insert("dtb_mailtemplate", $data); |
---|
[15308] | 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 | ?> |
---|