source: branches/beta/html/admin/basis/mail_edit.php @ 16801

Revision 16801, 3.2 KB checked in by satou, 16 years ago (diff)

#132
複数のバグが混在していました。
修正完了です。

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_edit.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$objQuery = new SC_Query();
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$objPage->arrSendType = $arrMailType;
31
32// ÊÔ½¸/¿·µ¬
33if ($_POST['mode'] == "edit") {
34    if (sfCheckNumLength($_POST['template_id']) === true) {
35        $result = $objQuery->select("*", "dtb_mailtemplate", "template_id = ?", array($_POST['template_id']));
36        if ($result) {
37            $objPage->arrForm = $result[0];
38        } else {
39            $objPage->arrForm['template_id'] = $_POST['template_id'];
40        }
41    } else {
42        $objPage->arrForm['template_id'] = 0;
43    }
44
45// ÅÐÏ¿
46} elseif ($_POST['mode'] == "regist" && sfCheckNumLength($_POST['template_id']) === true) {
47    // POST¥Ç¡¼¥¿¤Î°ú¤­·Ñ¤®
48    $objPage->arrForm = lfConvertParam($_POST);
49    $objPage->arrErr = fnErrorCheck($objPage->arrForm);
50    if ($objPage->arrErr) {
51        // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
52        $objPage->tpl_msg = "¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿";
53    } else {
54        // Àµ¾ï
55        lfRegist($objQuery, $objPage->arrForm, $_POST['template_id']);
56        // ´°Î»¥Ú¡¼¥¸
57        $objPage->tpl_mainpage = "basis/mail_complete.tpl";
58    }
59}
60
61$objView->assignobj($objPage);
62$objView->display(MAIN_FRAME);
63
64//-----------------------------------------------------------------------------------------------------------------------------------
65
66function lfRegist($objQuery, $arrVal, $id) {
67    $sqlval['template_name'] = $arrVal['template_name'];
68    $sqlval['subject'] = $arrVal['subject'];
69    $sqlval['creator_id'] = $_SESSION['member_id'];
70    $sqlval['body'] = $arrVal['body'];
71    $sqlval['send_type'] = $arrVal['send_type'];
72    $sqlval['update_date'] = "now()";
73   
74    $result = $objQuery->count("dtb_mailtemplate", "template_id=?", array($id));
75    if ($result > 0) {
76        $objQuery->update("dtb_mailtemplate", $sqlval, "template_id=?", array($id));
77    } else {
78        $sqlval['create_date'] = "now()";
79        $objQuery->insert("dtb_mailtemplate", $sqlval);
80    }
81}
82
83function lfConvertParam($array) {
84    $new_array["send_type"] = $array["send_type"];
85    $new_array["template_id"] = $array["template_id"];
86    $new_array["template_name"] = mb_convert_kana($array["template_name"],"KV");
87    $new_array["subject"] = mb_convert_kana($array["subject"] ,"KV");
88    $new_array["body"] = mb_convert_kana($array["body"] ,"KV");
89   
90    return $new_array;
91}
92
93/* ÆþÎÏ¥¨¥é¡¼¤Î¥Á¥§¥Ã¥¯ */
94function fnErrorCheck($array) {
95    $objErr = new SC_CheckError($array);
96    $objErr->doFunc(array("¥á¡¼¥ë¤Î¼ïÎà",'send_type'), array("EXIST_CHECK"));
97    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_id'), array("EXIST_CHECK"));
98    $objErr->doFunc(array("¥Æ¥ó¥×¥ì¡¼¥È",'template_name'), array("EXIST_CHECK"));
99    $objErr->doFunc(array("¥á¡¼¥ë¥¿¥¤¥È¥ë",'subject',MTEXT_LEN,"BIG"), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
100    $objErr->doFunc(array("¥á¡¼¥ë¤ÎÆâÍÆ",'body',LTEXT_LEN,"BIG"), array("MAX_LENGTH_CHECK","EXIST_CHECK"));
101   
102    return $objErr->arrErr;
103}
104
105?>
Note: See TracBrowser for help on using the repository browser.