source: branches/dev/html/admin/basis/mail.php @ 13699

Revision 13699, 3.3 KB checked in by nakanishi, 17 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9class LC_Page {
10    var $arrSession;
11    var $tpl_mode;
12    function LC_Page() {
13        $this->tpl_mainpage = 'basis/mail.tpl';
14        $this->tpl_subnavi = 'basis/subnavi.tpl';
15        $this->tpl_mainno = 'basis';
16        $this->tpl_subno = 'mail';
17        $this->tpl_subtitle = '¥á¡¼¥ëÀßÄê';
18    }
19}
20
21$conn = new SC_DBConn();
22$objQuery = new SC_Query();
23$objPage = new LC_Page();
24$objView = new SC_AdminView();
25$objSess = new SC_Session();
26
27//ǧ¾Ú²ÄÈݤÎȽÄê
28sfIsSuccess($objSess);
29
30$objPage->arrMailTEMPLATE = $arrMAILTEMPLATE;
31
32
33
34
35if ( $_GET['mode'] == 'edit' && sfCheckNumLength($_GET['template_id'])===true ){
36   
37    if ( sfCheckNumLength( $_GET['template_id']) ){
38        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
39        $result = $conn->getAll($sql, array($_GET['template_id']) );
40        print_r($result);
41        if ( $result ){
42            $objPage->arrForm = $result[0];
43        } else {
44            $objPage->arrForm['template_id'] = $_GET['template_id'];
45        }
46    }
47   
48} elseif ( $_GET['mode'] == 'regist' && sfCheckNumLength( $_GET['template_id']) ){
49
50    // POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
51    $objPage->arrForm = lfConvertParam($_GET);
52    $objPage->arrErr = fnErrorCheck($objPage->arrForm);
53   
54    if ( $objPage->arrErr ){
55        // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
56        $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿";
57       
58    } else {
59        // Àµ¾ï
60        lfRegist($conn, $objPage->arrForm);
61       
62        // ´°Î»¥á¥Ã¥»¡¼¥¸
63        $objPage->tpl_onload = "window.alert('¥á¡¼¥ëÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£¥Æ¥ó¥×¥ì¡¼¥È¤òÁªÂò¤·¤ÆÆâÍƤò¤´³Îǧ¤¯¤À¤µ¤¤¡£');";
64        unset($objPage->arrForm);
65    }
66}
67
68$objView->assignobj($objPage);
69$objView->display(MAIN_FRAME);
70
71//-----------------------------------------------------------------------------------------------------------------------------------
72
73function lfRegist( $conn, $data ){
74   
75    $data['creator_id'] = $_SESSION['member_id'];
76   
77    $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
78    $result = $conn->getAll($sql, array($_POST['template_id']) );
79    if ( $result ){
80        $sql_where = "template_id = ". addslashes($_POST['template_id']);
81        $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, template_name = ?,subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data);
82    }else{
83        $conn->query("INSERT INTO dtb_mailtemplate (template_id,template_name,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,?,now(),now() )", $data);
84    }
85
86}
87
88
89function lfConvertParam($array) {
90   
91    $new_array["template_id"] = $array["template_id"];
92    $new_array["template_name"] = $array["template_name"];
93    $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
94    $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
95    $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
96   
97    return $new_array;
98}
99
100/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
101function fnErrorCheck($array) {
102   
103    $objErr = new SC_CheckError($array);
104   
105    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK"));
106    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_name'), array("EXIST_CHECK"));
107    $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
108    $objErr->doFunc(array("¥Ø¥Ã¥À¡¼",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
109    $objErr->doFunc(array("¥Õ¥Ã¥¿¡¼",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
110
111    return $objErr->arrErr;
112}
113
114?>
Note: See TracBrowser for help on using the repository browser.