1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once("../require.php"); |
---|
8 | |
---|
9 | class 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 | //ǧ¾Ú²ÄÈݤÎȽÄê |
---|
28 | sfIsSuccess($objSess); |
---|
29 | |
---|
30 | $objPage->arrMailTEMPLATE = $arrMAILTEMPLATE; |
---|
31 | |
---|
32 | $objPage->arrSendType = array("¥Ñ¥½¥³¥ó","·ÈÂÓ"); |
---|
33 | |
---|
34 | if ( $_GET['mode'] == 'edit' && sfCheckNumLength($_GET['template_id']) === true ){ |
---|
35 | if ( sfCheckNumLength( $_GET['template_id']) ){ |
---|
36 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?"; |
---|
37 | $result = $conn->getAll($sql, array($_GET['template_id']) ); |
---|
38 | if ( $result ){ |
---|
39 | $objPage->arrForm = $result[0]; |
---|
40 | } else { |
---|
41 | $objPage->arrForm['template_id'] = $_GET['template_id']; |
---|
42 | } |
---|
43 | } |
---|
44 | } elseif ( $_POST['mode'] == 'regist' && sfCheckNumLength( $_POST['template_id']) ){ |
---|
45 | // POST¥Ç¡¼¥¿¤Î°ú¤·Ñ¤® |
---|
46 | $objPage->arrForm = lfConvertParam($_POST); |
---|
47 | $objPage->arrErr = fnErrorCheck($objPage->arrForm); |
---|
48 | if ( $objPage->arrErr ){ |
---|
49 | // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸ |
---|
50 | $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿"; |
---|
51 | } else { |
---|
52 | // Àµ¾ï |
---|
53 | lfRegist($conn, $objPage->arrForm); |
---|
54 | // ´°Î»¥á¥Ã¥»¡¼¥¸ |
---|
55 | $objPage->tpl_onload = "window.alert('¥á¡¼¥ëÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£');"; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | $objView->assignobj($objPage); |
---|
60 | $objView->display(MAIN_FRAME); |
---|
61 | |
---|
62 | //----------------------------------------------------------------------------------------------------------------------------------- |
---|
63 | |
---|
64 | function lfRegist( $conn, $data ){ |
---|
65 | |
---|
66 | $data['creator_id'] = $_SESSION['member_id']; |
---|
67 | |
---|
68 | $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ? AND del_flg = 0"; |
---|
69 | $result = $conn->getAll($sql, array($_POST['template_id']) ); |
---|
70 | if ( $result ){ |
---|
71 | $sql_where = "template_id = ". addslashes($_POST['template_id']); |
---|
72 | $conn->query("UPDATE dtb_mailtemplate SET send_type = ?,template_id = ?, template_name = ?,subject = ?,body = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data); |
---|
73 | }else{ |
---|
74 | $conn->query("INSERT INTO dtb_mailtemplate (send_type,template_id,template_name,subject,body,creator_id,update_date,create_date) values ( ?,?,?,?,?,?,now(),now() )", $data); |
---|
75 | } |
---|
76 | |
---|
77 | } |
---|
78 | |
---|
79 | function lfConvertParam($array) { |
---|
80 | |
---|
81 | $new_array["send_type"] = $array["send_type"]; |
---|
82 | $new_array["template_id"] = $array["template_id"]; |
---|
83 | $new_array["template_name"] = mb_convert_kana($array["template_name"],"KV"); |
---|
84 | $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV"); |
---|
85 | $new_array["body"] = mb_convert_kana($array["body"] ,"KV"); |
---|
86 | |
---|
87 | return $new_array; |
---|
88 | } |
---|
89 | |
---|
90 | /* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */ |
---|
91 | function fnErrorCheck($array) { |
---|
92 | |
---|
93 | $objErr = new SC_CheckError($array); |
---|
94 | $objErr->doFunc(array("¥á¡¼¥ë¤Î¼ïÎà",'send_type'), array("EXIST_CHECK")); |
---|
95 | $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK")); |
---|
96 | $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_name'), array("EXIST_CHECK")); |
---|
97 | $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
98 | $objErr->doFunc(array("¥á¡¼¥ë¤ÎÆâÍÆ",'body',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK","EXIST_CHECK")); |
---|
99 | |
---|
100 | return $objErr->arrErr; |
---|
101 | } |
---|
102 | |
---|
103 | ?> |
---|