source: branches/feature-module-update/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php @ 15308

Revision 15308, 4.3 KB checked in by nanasess, 17 years ago (diff)

クラス化対応

  • Property svn:keywords set to Id Revision Date
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * メール設定 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Admin_Basis_Mail extends LC_Page {
19
20    // }}}
21    // {{{ functions
22
23    /**
24     * Page を初期化する.
25     *
26     * @return void
27     */
28    function init() {
29        parent::init();
30        $this->tpl_mainpage = 'basis/mail.tpl';
31        $this->tpl_subnavi = 'basis/subnavi.tpl';
32        $this->tpl_mainno = 'basis';
33        $this->tpl_subno = 'mail';
34        $this->tpl_subtitle = 'メール設定';
35    }
36
37    /**
38     * Page のプロセス.
39     *
40     * @return void
41     */
42    function process() {
43        $conn = new SC_DBConn();
44        $objView = new SC_AdminView();
45        $objSess = new SC_Session();
46        $masterData = new SC_DB_MasterData_Ex();
47
48        // 認証可否の判定
49        SC_Utils_Ex::sfIsSuccess($objSess);
50
51
52        $this->arrMailTEMPLATE = $masterData->getMasterData("mtb_mail_template");
53
54        if (!isset($_POST['mode'])) $_POST['mode'] = "";
55
56        if ( $_POST['mode'] == 'id_set'){
57            // テンプレートプルダウン変更時
58
59            if ( SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){
60                $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
61                $result = $conn->getAll($sql, array($_POST['template_id']) );
62                if ( $result ){
63                    $this->arrForm = $result[0];
64                } else {
65                    $this->arrForm['template_id'] = $_POST['template_id'];
66                }
67            }
68
69        } elseif ( $_POST['mode'] == 'regist' && SC_Utils_Ex::sfCheckNumLength( $_POST['template_id']) ){
70
71            // POSTデータの引き継ぎ
72            $this->arrForm = $this->lfConvertParam($_POST);
73            $this->arrErr = $this->fnErrorCheck($this->arrForm);
74
75            if ( $this->arrErr ){
76                // エラーメッセージ
77                $this->tpl_msg = "エラーが発生しました";
78
79            } else {
80                // 正常
81                $this->lfRegist($conn, $this->arrForm);
82
83                // 完了メッセージ
84                $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');";
85                unset($this->arrForm);
86            }
87
88        }
89
90        $objView->assignobj($this);
91        $objView->display(MAIN_FRAME);
92    }
93
94    /**
95     * デストラクタ.
96     *
97     * @return void
98     */
99    function destroy() {
100        parent::destroy();
101    }
102
103    function lfRegist( $conn, $data ){
104
105        $data['creator_id'] = $_SESSION['member_id'];
106
107        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
108        $result = $conn->getAll($sql, array($_POST['template_id']) );
109        if ( $result ){
110            $sql_where = "template_id = ". addslashes($_POST['template_id']);
111            $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data);
112        }else{
113            $conn->query("INSERT INTO dtb_mailtemplate (template_id,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,now(),now() )", $data);
114        }
115
116    }
117
118
119    function lfConvertParam($array) {
120
121        $new_array["template_id"] = $array["template_id"];
122        $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
123        $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
124        $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
125
126        return $new_array;
127    }
128
129    /* 入力エラーのチェック */
130    function fnErrorCheck($array) {
131
132        $objErr = new SC_CheckError($array);
133
134        $objErr->doFunc(array("テンプレート",'template_id'), array("EXIST_CHECK"));
135        $objErr->doFunc(array("メールタイトル",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
136        $objErr->doFunc(array("ヘッダー",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
137        $objErr->doFunc(array("フッター",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
138
139        return $objErr->arrErr;
140    }
141}
142?>
Note: See TracBrowser for help on using the repository browser.