source: branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_TemplateInput.php @ 19715

Revision 19715, 5.2 KB checked in by nanasess, 13 years ago (diff)

#382(管理画面XHTMLに変更)

  • UI を改善
  • 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_PATH . "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_Mail_TemplateInput 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 = 'mail/template_input.tpl';
47        $this->tpl_mainno = 'mail';
48        $this->tpl_subnavi = 'mail/subnavi.tpl';
49        $this->tpl_subtitle = 'テンプレート設定';
50        $this->tpl_subno = "template";
51        $masterData = new SC_DB_MasterData_Ex();
52        $this->arrMagazineType = $masterData->getMasterData("mtb_magazine_type");
53        // arrMagazineTypAll ではないため, unset する.
54        unset($this->arrMagazineType['3']);
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のアクション.
69     *
70     * @return void
71     */
72    function action() {
73        $objQuery = new SC_Query();
74        $objSess = new SC_Session();
75
76        // 認証可否の判定
77        SC_Utils_Ex::sfIsSuccess($objSess);
78
79
80        $this->mode = "regist";
81
82        // idが指定されているときは「編集」表示
83        if (!isset($_REQUEST['template_id'])) $_REQUEST['template_id'] = "";
84        if ( $_REQUEST['template_id'] ){
85            $this->title = "編集";
86        } else {
87            $this->title = "新規登録";
88        }
89
90        if (!isset($_GET['mode'])) $_GET['mode'] = "";
91        if (!isset($_POST['mode'])) $_POST['mode'] = "";
92        // モードによる処理分岐
93        if ( $_GET['mode'] == 'edit' && SC_Utils_Ex::sfCheckNumLength($_GET['template_id'])===true ){
94
95            // 編集
96            $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? AND del_flg = 0";
97            $result = $objQuery->getAll($sql, array($_GET['template_id']));
98            $this->arrForm = $result[0];
99
100
101        } elseif ( $_POST['mode'] == 'regist' ) {
102
103            // 新規登録
104            $this->arrForm = $this->lfConvData( $_POST );
105            $this->arrErr = $this->lfErrorCheck($this->arrForm);
106
107            if ( ! $this->arrErr ){
108                // エラーが無いときは登録・編集
109                $this->lfRegistData( $this->arrForm, $_POST['template_id']);
110                // 自分を再読込して、完了画面へ遷移
111                $this->objDisplay->reload(array("mode" => "complete"));
112            }
113
114        } elseif ( $_GET['mode'] == 'complete' ) {
115
116            // 完了画面表示
117            $this->tpl_mainpage = 'mail/template_complete.tpl';
118        }
119    }
120
121    /**
122     * デストラクタ.
123     *
124     * @return void
125     */
126    function destroy() {
127        parent::destroy();
128    }
129
130    function lfRegistData( $arrVal, $id = null ){
131
132        $query = new SC_Query();
133
134        $sqlval['subject'] = $arrVal['subject'];
135        $sqlval['mail_method'] = $arrVal['mail_method'];
136        $sqlval['creator_id'] = $_SESSION['member_id'];
137        $sqlval['body'] = $arrVal['body'];
138        $sqlval['update_date'] = "now()";
139
140        if ( $id ){
141            $query->update("dtb_mailmaga_template", $sqlval, "template_id=".$id );
142        } else {
143            $sqlval['create_date'] = "now()";
144            $query->insert("dtb_mailmaga_template", $sqlval);
145        }
146    }
147
148    function lfConvData( $data ){
149
150        // 文字列の変換(mb_convert_kanaの変換オプション)
151        $arrFlag = array(
152                         "subject" => "KV"
153                         ,"body" => "KV"
154                         );
155
156        if ( is_array($data) ){
157            foreach ($arrFlag as $key=>$line) {
158                $data[$key] = mb_convert_kana($data[$key], $line);
159            }
160        }
161
162        return $data;
163    }
164
165    // 入力エラーチェック
166    function lfErrorCheck() {
167        $objErr = new SC_CheckError();
168
169        $objErr->doFunc(array("メール形式", "mail_method"), array("EXIST_CHECK", "ALNUM_CHECK"));
170        $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
171        $objErr->doFunc(array("本文", 'body', LLTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
172
173        return $objErr->arrErr;
174    }
175}
176?>
Note: See TracBrowser for help on using the repository browser.