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

Revision 12560, 3.1 KB checked in by matsumoto, 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$objPage = new LC_Page();
23$objView = new SC_AdminView();
24$objSess = new SC_Session();
25
26// ǧ¾Ú²ÄÈݤÎȽÄê
27sfIsSuccess($objSess);
28
29$objPage->arrMailTEMPLATE = $arrMAILTEMPLATE;
30
31if ( $_POST['mode'] == 'id_set'){
32    // ¥Æ¥ó¥×¥ì¡¼¥È¥×¥ë¥À¥¦¥óÊѹ¹»þ
33   
34    if ( sfCheckNumLength( $_POST['template_id']) ){
35        $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
36        $result = $conn->getAll($sql, array($_POST['template_id']) );
37        if ( $result ){
38            $objPage->arrForm = $result[0];
39        } else {
40            $objPage->arrForm['template_id'] = $_POST['template_id'];
41        }
42    }
43   
44} elseif ( $_POST['mode'] == 'regist' && sfCheckNumLength( $_POST['template_id']) ){
45
46    // POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
47    $objPage->arrForm = lfConvertParam($_POST);
48    $objPage->arrErr = fnErrorCheck($objPage->arrForm);
49   
50    if ( $objPage->arrErr ){
51        // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
52        $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿";
53       
54    } else {
55        // Àµ¾ï
56        lfRegist($conn, $objPage->arrForm);
57       
58        // ´°Î»¥á¥Ã¥»¡¼¥¸
59        $objPage->tpl_onload = "window.alert('¥á¡¼¥ëÀßÄ꤬´°Î»¤·¤Þ¤·¤¿¡£¥Æ¥ó¥×¥ì¡¼¥È¤òÁªÂò¤·¤ÆÆâÍƤò¤´³Îǧ¤¯¤À¤µ¤¤¡£');";
60        unset($objPage->arrForm);
61    }
62}
63
64$objView->assignobj($objPage);
65$objView->display(MAIN_FRAME);
66
67//-----------------------------------------------------------------------------------------------------------------------------------
68
69function lfRegist( $conn, $data ){
70   
71    $data['creator_id'] = $_SESSION['member_id'];
72   
73    $sql = "SELECT * FROM dtb_mailtemplate WHERE template_id = ?";
74    $result = $conn->getAll($sql, array($_POST['template_id']) );
75    if ( $result ){
76        $sql_where = "template_id = ". addslashes($_POST['template_id']);
77        $conn->query("UPDATE dtb_mailtemplate SET template_id = ?, subject = ?,header = ?, footer = ?,creator_id = ?, update_date = now() WHERE ".$sql_where, $data);
78    }else{
79        $conn->query("INSERT INTO dtb_mailtemplate (template_id,subject,header,footer,creator_id,update_date,create_date) values ( ?,?,?,?,?,now(),now() )", $data);
80    }
81
82}
83
84
85function lfConvertParam($array) {
86   
87    $new_array["template_id"] = $array["template_id"];
88    $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
89    $new_array["header"] = mb_convert_kana($array["header"] ,"KV");
90    $new_array["footer"] = mb_convert_kana($array["footer"] ,"KV");
91   
92    return $new_array;
93}
94
95/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
96function fnErrorCheck($array) {
97   
98    $objErr = new SC_CheckError($array);
99   
100    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK"));
101    $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
102    $objErr->doFunc(array("¥Ø¥Ã¥À¡¼",'header',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
103    $objErr->doFunc(array("¥Õ¥Ã¥¿¡¼",'footer',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK"));
104
105    return $objErr->arrErr;
106}
107
108?>
Note: See TracBrowser for help on using the repository browser.