source: branches/comu-ver2/data/class/pages/admin/mail/LC_Page_Admin_Mail_TemplateInput.php @ 18234

Revision 18234, 5.0 KB checked in by Seasoft, 15 years ago (diff)

#528(改行コードが混在している)

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