Source for file LC_Page_Admin_Mail_TemplateInput.php

Documentation is available at LC_Page_Admin_Mail_TemplateInput.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * This program is free software; you can redistribute it and/or
  10.  * modify it under the terms of the GNU General Public License
  11.  * as published by the Free Software Foundation; either version 2
  12.  * of the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  22.  */
  23.  
  24. // {{{ requires
  25. require_once(CLASS_PATH . "pages/LC_Page.php");
  26.  
  27. /**
  28.  * テンプレート設定 のページクラス.
  29.  *
  30.  * @package Page
  31.  * @author LOCKON CO.,LTD.
  32.  * @version $Id$
  33.  */
  34.  
  35.     // }}}
  36.     // {{{ functions
  37.  
  38.     /**
  39.      * Page を初期化する.
  40.      *
  41.      * @return void 
  42.      */
  43.     function init() {
  44.         parent::init();
  45.         $this->tpl_mainpage = 'mail/template_input.tpl';
  46.         $this->tpl_mainno = 'mail';
  47.         $this->tpl_subnavi = 'mail/subnavi.tpl';
  48.         $this->tpl_subno = "template";
  49.         $masterData = new SC_DB_MasterData_Ex();
  50.         $this->arrMagazineType = $masterData->getMasterData("mtb_magazine_type");
  51.         // arrMagazineTypAll ではないため, unset する.
  52.         unset($this->arrMagazineType['3']);
  53.     }
  54.  
  55.     /**
  56.      * Page のプロセス.
  57.      *
  58.      * @return void 
  59.      */
  60.     function process() {
  61.         $conn = new SC_DBConn();
  62.         $objView = new SC_AdminView();
  63.         $objSess = new SC_Session();
  64.  
  65.         // 認証可否の判定
  66.         SC_Utils_Ex::sfIsSuccess($objSess);
  67.  
  68.  
  69.         $this->mode = "regist";
  70.  
  71.         // idが指定されているときは「編集」表示
  72.         if (!isset($_REQUEST['template_id'])) $_REQUEST['template_id'] = "";
  73.         if ( $_REQUEST['template_id'] ){
  74.             $this->title = "編集";
  75.         } else {
  76.             $this->title = "新規登録";
  77.         }
  78.  
  79.         if (!isset($_GET['mode'])) $_GET['mode'] = "";
  80.         if (!isset($_POST['mode'])) $_POST['mode'] = "";
  81.         // モードによる処理分岐
  82.         if ( $_GET['mode'] == 'edit' && SC_Utils_Ex::sfCheckNumLength($_GET['template_id'])===true ){
  83.  
  84.             // 編集
  85.             $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? AND del_flg = 0";
  86.             $result = $conn->getAll($sql, array($_GET['template_id']));
  87.             $this->arrForm = $result[0];
  88.  
  89.  
  90.         } elseif ( $_POST['mode'] == 'regist' ) {
  91.  
  92.             // 新規登録
  93.             $this->arrForm = $this->lfConvData( $_POST );
  94.             $this->arrErr = $this->lfErrorCheck($this->arrForm);
  95.  
  96.             if ( ! $this->arrErr ){
  97.                 // エラーが無いときは登録・編集
  98.                 $this->lfRegistData( $this->arrForm, $_POST['template_id']);
  99.                 // 自分を再読込して、完了画面へ遷移
  100.                 $this->reload(array("mode" => "complete"));
  101.             }
  102.  
  103.         } elseif ( $_GET['mode'] == 'complete' ) {
  104.  
  105.             // 完了画面表示
  106.             $this->tpl_mainpage = 'mail/template_complete.tpl';
  107.         }
  108.         $objView->assignobj($this);
  109.         $objView->display(MAIN_FRAME);
  110.     }
  111.  
  112.     /**
  113.      * デストラクタ.
  114.      *
  115.      * @return void 
  116.      */
  117.     function destroy() {
  118.         parent::destroy();
  119.     }
  120.  
  121.     function lfRegistData( $arrVal, $id = null ){
  122.  
  123.         $query = new SC_Query();
  124.  
  125.         $sqlval['subject'] = $arrVal['subject'];
  126.         $sqlval['mail_method'] = $arrVal['mail_method'];
  127.         $sqlval['creator_id'] = $_SESSION['member_id'];
  128.         $sqlval['body'] = $arrVal['body'];
  129.         $sqlval['update_date'] = "now()";
  130.  
  131.         if ( $id ){
  132.             $query->update("dtb_mailmaga_template", $sqlval, "template_id=".$id );
  133.         } else {
  134.             $sqlval['create_date'] = "now()";
  135.             $query->insert("dtb_mailmaga_template", $sqlval);
  136.         }
  137.     }
  138.  
  139.     function lfConvData( $data ){
  140.  
  141.         // 文字列の変換(mb_convert_kanaの変換オプション)
  142.         $arrFlag = array(
  143.                          "subject" => "KV"
  144.                          ,"body" => "KV"
  145.                          );
  146.  
  147.         if ( is_array($data) ){
  148.             foreach ($arrFlag as $key=>$line) {
  149.                 $data[$key] = mb_convert_kana($data[$key], $line);
  150.             }
  151.         }
  152.  
  153.         return $data;
  154.     }
  155.  
  156.     // 入力エラーチェック
  157.     function lfErrorCheck() {
  158.         $objErr = new SC_CheckError();
  159.  
  160.         $objErr->doFunc(array("メール形式", "mail_method"), array("EXIST_CHECK", "ALNUM_CHECK"));
  161.         $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
  162.         $objErr->doFunc(array("本文", 'body', LLTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK"));
  163.  
  164.         return $objErr->arrErr;
  165.     }
  166. }
  167. ?>

Documentation generated on Tue, 28 Apr 2009 18:11:19 +0900 by phpDocumentor 1.4.2