Source for file LC_Page_Admin_Basis_Kiyaku.php

Documentation is available at LC_Page_Admin_Basis_Kiyaku.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: LC_Page_Admin_Basis_Kiyaku.php 16741 2007-11-08 00:43:24Z adachi $
  33.  */
  34.  
  35.     // }}}
  36.     // {{{ functions
  37.  
  38.     /**
  39.      * Page を初期化する.
  40.      *
  41.      * @return void 
  42.      */
  43.     function init() {
  44.         parent::init();
  45.         $this->tpl_mainpage = 'basis/kiyaku.tpl';
  46.         $this->tpl_subnavi = 'basis/subnavi.tpl';
  47.         $this->tpl_subno = 'kiyaku';
  48.         $this->tpl_subtitle = '会員規約登録';
  49.         $this->tpl_mainno = 'basis';
  50.     }
  51.  
  52.     /**
  53.      * Page のプロセス.
  54.      *
  55.      * @return void 
  56.      */
  57.     function process() {
  58.         $conn = new SC_DBConn();
  59.         $objView = new SC_AdminView();
  60.         $objSess = new SC_Session();
  61.         $objQuery = new SC_Query();
  62.         $objDb = new SC_Helper_DB_Ex();
  63.  
  64.         // 認証可否の判定
  65.         SC_Utils_Ex::sfIsSuccess($objSess);
  66.  
  67.         if (!isset($_POST['mode'])) $_POST['mode'] = "";
  68.  
  69.         // 要求判定
  70.         switch($_POST['mode']) {
  71.         // 編集処理
  72.         case 'edit':
  73.             // POST値の引き継ぎ
  74.             $this->arrForm = $_POST;
  75.             // 入力文字の変換
  76.             $this->arrForm = $this->lfConvertParam($this->arrForm);
  77.  
  78.             // エラーチェック
  79.             $this->arrErr = $this->lfErrorCheck();
  80.             if(count($this->arrErr) <= 0) {
  81.                 if($_POST['kiyaku_id'] == "") {
  82.                     $this->lfInsertClass($this->arrForm);    // 新規作成
  83.                 } else {
  84.                     $this->lfUpdateClass($this->arrForm);    // 既存編集
  85.                 }
  86.                 // 再表示
  87.                 $this->reload();
  88.             } else {
  89.                 // POSTデータを引き継ぐ
  90.                 $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
  91.             }
  92.             break;
  93.         // 削除
  94.         case 'delete':
  95.             $objDb->sfDeleteRankRecord("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id'], "", true);
  96.             // 再表示
  97.             $this->reload();
  98.             break;
  99.         // 編集前処理
  100.         case 'pre_edit':
  101.             // 編集項目をDBより取得する。
  102.             $where = "kiyaku_id = ?";
  103.             $arrRet = $objQuery->select("kiyaku_text, kiyaku_title", "dtb_kiyaku", $where, array($_POST['kiyaku_id']));
  104.             // 入力項目にカテゴリ名を入力する。
  105.             $this->arrForm['kiyaku_title'] = $arrRet[0]['kiyaku_title'];
  106.             $this->arrForm['kiyaku_text'] = $arrRet[0]['kiyaku_text'];
  107.             // POSTデータを引き継ぐ
  108.             $this->tpl_kiyaku_id = $_POST['kiyaku_id'];
  109.         break;
  110.         case 'down':
  111.             $objDb->sfRankDown("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
  112.             // 再表示
  113.             $this->reload();
  114.             break;
  115.         case 'up':
  116.             $objDb->sfRankUp("dtb_kiyaku", "kiyaku_id", $_POST['kiyaku_id']);
  117.             // 再表示
  118.             $this->reload();
  119.             break;
  120.         default:
  121.             break;
  122.         }
  123.  
  124.         // 規格の読込
  125.         $where = "del_flg <> 1";
  126.         $objQuery->setorder("rank DESC");
  127.         $this->arrKiyaku = $objQuery->select("kiyaku_title, kiyaku_text, kiyaku_id", "dtb_kiyaku", $where);
  128.  
  129.         $objView->assignobj($this);
  130.         $objView->display(MAIN_FRAME);
  131.     }
  132.  
  133.     /**
  134.      * デストラクタ.
  135.      *
  136.      * @return void 
  137.      */
  138.     function destroy() {
  139.         parent::destroy();
  140.     }
  141.  
  142.     /* DBへの挿入 */
  143.     function lfInsertClass($arrData) {
  144.         $objQuery = new SC_Query();
  145.         // INSERTする値を作成する。
  146.         $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
  147.         $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
  148.         $sqlval['creator_id'] = $_SESSION['member_id'];
  149.         $sqlval['rank'] = $objQuery->max("dtb_kiyaku", "rank") + 1;
  150.         $sqlval['update_date'] = "Now()";
  151.         $sqlval['create_date'] = "Now()";
  152.         // INSERTの実行
  153.         $ret = $objQuery->insert("dtb_kiyaku", $sqlval);
  154.         return $ret;
  155.     }
  156.  
  157.     /* DBへの更新 */
  158.     function lfUpdateClass($arrData) {
  159.         $objQuery = new SC_Query();
  160.         // UPDATEする値を作成する。
  161.         $sqlval['kiyaku_title'] = $arrData['kiyaku_title'];
  162.         $sqlval['kiyaku_text'] = $arrData['kiyaku_text'];
  163.         $sqlval['update_date'] = "Now()";
  164.         $where = "kiyaku_id = ?";
  165.         // UPDATEの実行
  166.         $ret = $objQuery->update("dtb_kiyaku", $sqlval, $where, array($_POST['kiyaku_id']));
  167.         return $ret;
  168.     }
  169.  
  170.     /* 取得文字列の変換 */
  171.     function lfConvertParam($array) {
  172.         // 文字変換
  173.         $arrConvList['kiyaku_title'] = "KVa";
  174.         $arrConvList['kiyaku_text'] = "KVa";
  175.  
  176.         foreach ($arrConvList as $key => $val) {
  177.             // POSTされてきた値のみ変換する。
  178.             if(isset($array[$key])) {
  179.                 $array[$key] = mb_convert_kana($array[$key] ,$val);
  180.             }
  181.         }
  182.         return $array;
  183.     }
  184.  
  185.     /* 入力エラーチェック */
  186.     function lfErrorCheck() {
  187.         $objErr = new SC_CheckError();
  188.         $objErr->doFunc(array("規約タイトル", "kiyaku_title", SMTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  189.         $objErr->doFunc(array("規約内容", "kiyaku_text", MLTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
  190.         if(!isset($objErr->arrErr['name'])) {
  191.             $objQuery = new SC_Query();
  192.             $arrRet = $objQuery->select("kiyaku_id, kiyaku_title", "dtb_kiyaku", "del_flg = 0 AND kiyaku_title = ?", array($_POST['kiyaku_title']));
  193.             // 編集中のレコード以外に同じ名称が存在する場合
  194.             if ($arrRet[0]['kiyaku_id'] != $_POST['kiyaku_id'] && $arrRet[0]['kiyaku_title'] == $_POST['kiyaku_title']) {
  195.                 $objErr->arrErr['name'] = "※ 既に同じ内容の登録が存在します。<br>";
  196.             }
  197.         }
  198.         return $objErr->arrErr;
  199.     }
  200. }
  201. ?>

Documentation generated on Tue, 28 Apr 2009 18:10:44 +0900 by phpDocumentor 1.4.2