Source for file LC_Page_CampaignEntry.php

Documentation is available at LC_Page_CampaignEntry.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_CampaignEntry.php 17795 2009-02-17 06:57:50Z Seasoft $
  33.  */
  34. class LC_Page_CampaignEntry extends LC_Page {
  35.  
  36.     // }}}
  37.     // {{{ functions
  38.  
  39.     /**
  40.      * Page を初期化する.
  41.      *
  42.      * @return void 
  43.      */
  44.     function init({
  45.         parent::init();
  46.         $this->tpl_mainpage = 'entry/index.tpl';                // メインテンプレート
  47.         $this->tpl_title .= '会員登録(入力ページ)';             // ページタイトル
  48.  
  49.         $masterData new SC_DB_MasterData_Ex();
  50.         $this->arrPref $masterData->getMasterData("mtb_pref",
  51.                                 array("pref_id""pref_name""rank"));
  52.         $this->arrJob $masterData->getMasterData("mtb_job");
  53.         $this->arrReminder $masterData->getMasterData("mtb_reminder");
  54.         
  55.         // 生年月日選択肢の取得
  56.         $objDate new SC_Date(START_BIRTH_YEARdate("Y",strtotime("now")));
  57.         $this->arrYear $objDate->getYear(''1950'');
  58.         $this->arrMonth $objDate->getMonth(true);
  59.         $this->arrDay $objDate->getDay(true);
  60.     }
  61.  
  62.     /**
  63.      * Page のプロセス.
  64.      *
  65.      * @return void 
  66.      */
  67.     function process({
  68.         global $objCampaignSess;
  69.  
  70.         $objConn new SC_DbConn();
  71.         $objQuery new SC_Query();
  72.         $objView new SC_SiteView();
  73.         $CONF $objView->objSiteInfo->data;
  74.         $objCampaignSess new SC_CampaignSession();
  75.  
  76.         // レイアウトデザインを取得
  77.         $objLayout new SC_Helper_PageLayout_Ex();
  78.         $objLayout->sfGetPageLayout($thisfalseDEF_LAYOUT);
  79.  
  80.         //---- 登録用カラム配列
  81.         $arrRegistColumn array(
  82.                                  array(  "column" => "name01""convert" => "aKV" ),
  83.                                  array(  "column" => "name02""convert" => "aKV" ),
  84.                                  array(  "column" => "kana01""convert" => "CKV" ),
  85.                                  array(  "column" => "kana02""convert" => "CKV" ),
  86.                                  array(  "column" => "zip01""convert" => "n" ),
  87.                                  array(  "column" => "zip02""convert" => "n" ),
  88.                                  array(  "column" => "pref""convert" => "n" ),
  89.                                  array(  "column" => "addr01""convert" => "aKV" ),
  90.                                  array(  "column" => "addr02""convert" => "aKV" ),
  91.                                  array(  "column" => "email""convert" => "a" ),
  92.                                  array(  "column" => "email2""convert" => "a" ),
  93.                                  array(  "column" => "email_mobile""convert" => "a" ),
  94.                                  array(  "column" => "email_mobile2""convert" => "a" ),
  95.                                  array(  "column" => "tel01""convert" => "n" ),
  96.                                  array(  "column" => "tel02""convert" => "n" ),
  97.                                  array(  "column" => "tel03""convert" => "n" ),
  98.                                  array(  "column" => "fax01""convert" => "n" ),
  99.                                  array(  "column" => "fax02""convert" => "n" ),
  100.                                  array(  "column" => "fax03""convert" => "n" ),
  101.                                  array(  "column" => "sex""convert" => "n" ),
  102.                                  array(  "column" => "job""convert" => "n" ),
  103.                                  array(  "column" => "birth""convert" => "n" ),
  104.                                  array(  "column" => "reminder""convert" => "n" ),
  105.                                  array(  "column" => "reminder_answer""convert" => "aKV"),
  106.                                  array(  "column" => "password""convert" => "a" ),
  107.                                  array(  "column" => "password02""convert" => "a" ),
  108.                                  array(  "column" => "mailmaga_flg""convert" => "n" )
  109.                                  );
  110.  
  111.         //---- 登録除外用カラム配列
  112.         $arrRejectRegistColumn array("year""month""day""email02""email_mobile02""password02");
  113.  
  114.         if ($_SERVER["REQUEST_METHOD"== "POST"{
  115.  
  116.             //-- POSTデータの引き継ぎ
  117.             $this->arrForm $_POST;
  118.  
  119.             $this->arrForm['email'strtolower($this->arrForm['email']);        // emailはすべて小文字で処理
  120.             $this->arrForm['email02'strtolower($this->arrForm['email02']);    // emailはすべて小文字で処理
  121.  
  122.             //-- 入力データの変換
  123.             $this->arrForm $this->lfConvertParam($this->arrForm$arrRegistColumn);
  124.  
  125.             //-- 入力エラーチェック
  126.             $this->arrErr $this->lfErrorCheck($this->arrForm);
  127.  
  128.             if ($this->arrErr || $_POST["mode"== "return"{        // 入力エラーのチェック
  129.                 foreach($this->arrForm as $key => $val{
  130.                     $this->$key $val;
  131.                 }
  132.  
  133.             else {
  134.  
  135.                 //-- 確認
  136.                 if ($_POST["mode"== "confirm"{
  137.                     foreach($this->arrForm as $key => $val{
  138.                         if ($key != "mode" && $key != "subm"$this->list_data$key $val;
  139.                     }
  140.                     //パスワード表示
  141.                     $passlen strlen($this->arrForm['password']);
  142.                     $this->passlen $this->lfPassLen($passlen);
  143.  
  144.                     $this->tpl_mainpage = 'entry/confirm.tpl';
  145.                     $this->tpl_title = '会員登録(確認ページ)';
  146.  
  147.                 }
  148.  
  149.                 //--仮登録と完了画面
  150.                 if ($_POST["mode"== "complete"{
  151.                     $this->uniqid $this->lfRegistData ($this->arrForm$arrRegistColumn$arrRejectRegistColumn);
  152.  
  153.                     if($objCampaignSess->getIsCampaign()) {
  154.                         $this->etc_value "&cp=".$objCampaignSess->getCampaignId();
  155.                     }
  156.  
  157.                     $this->tpl_css = '/css/layout/entry/complete.css';
  158.                     $this->tpl_mainpage = 'entry/complete.tpl';
  159.                     $this->tpl_title = '会員登録(完了ページ)';
  160.  
  161.  
  162.                     // 仮登録完了メール送信
  163.                     $this->CONF $CONF;
  164.                     $this->name01 $_POST['name01'];
  165.                     $this->name02 $_POST['name02'];
  166.                     $objMailText new SC_SiteView();
  167.                     $objMailText->assignobj($this);
  168.                     $objHelperMail new SC_Helper_Mail_Ex();
  169.                     $objQuery new SC_Query();
  170.  
  171.                     $subject $objHelperMail->sfMakeSubject('会員登録のご確認');
  172.  
  173.                     $toCustomerMail $objMailText->fetch("mail_templates/customer_mail.tpl");
  174.                     $objMail new SC_SendMail();
  175.                     $objMail->setItem(
  176.                                       ''                                    // 宛先
  177.                                       $subject                            // サブジェクト
  178.                                       $toCustomerMail                    // 本文
  179.                                       $CONF["email03"]                    // 配送元アドレス
  180.                                       $CONF["shop_name"]                // 配送元 名前
  181.                                       $CONF["email03"]                    // reply_to
  182.                                       $CONF["email04"]                    // return_path
  183.                                       $CONF["email04"]                    //  Errors_to
  184.                                       $CONF["email01"]                    //  Bcc
  185.                                       );
  186.                     // 宛先の設定
  187.                     $name $_POST["name01"$_POST["name02"." 様";
  188.                     $objMail->setTo($_POST["email"]$name);
  189.                     $objMail->sendMail();
  190.  
  191.                     // キャンペーン受注情報を登録
  192.                     $this->lfRegistCampaignOrder($this->uniqid$objQuery);
  193.  
  194.                     // 完了ページに移動させる。
  195.                     $this->sendRedirect($this->getLocation("./complete.php"));
  196.                     exit;
  197.                 }
  198.             }
  199.         }
  200.  
  201.         //---- ページ表示
  202.         $objView->assignobj($this);
  203.         // フレームを選択(キャンペーンページから遷移なら変更)
  204.         $objCampaignSess->pageView($objView);
  205.  
  206.     }
  207.  
  208.     /**
  209.      * デストラクタ.
  210.      *
  211.      * @return void 
  212.      */
  213.     function destroy({
  214.         parent::destroy();
  215.     }
  216.  
  217.     //---- function群
  218.     function lfRegistData ($array$arrRegistColumn$arrRejectRegistColumn{
  219.         $objConn new SC_DbConn();
  220.  
  221.         // 仮登録
  222.         foreach ($arrRegistColumn as $data{
  223.             if (strlen($array$data["column"] ]&& in_array($data["column"]$arrRejectRegistColumn)) {
  224.                 $arrRegist$data["column"] ] $array$data["column"] ];
  225.             }
  226.         }
  227.  
  228.         // 誕生日が入力されている場合
  229.         if (strlen($array["year"]{
  230.             $arrRegist["birth"$array["year"."/"$array["month"."/"$array["day"." 00:00:00";
  231.         }
  232.  
  233.         // パスワードの暗号化
  234.         $arrRegist["password"sha1($arrRegist["password"":" AUTH_MAGIC);
  235.  
  236.         $count 1;
  237.         while ($count != 0{
  238.             $uniqid SC_Utils_Ex::sfGetUniqRandomId("t");
  239.             $count $objConn->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?"array($uniqid));
  240.         }
  241.  
  242.         $arrRegist["secret_key"$uniqid;        // 仮登録ID発行
  243.         $arrRegist["create_date""now()";     // 作成日
  244.         $arrRegist["update_date""now()";     // 更新日
  245.         $arrRegist["first_buy_date""";         // 最初の購入日
  246.  
  247.         //-- 仮登録実行
  248.         $objConn->query("BEGIN");
  249.  
  250.         $objQuery new SC_Query();
  251.         $objQuery->insert("dtb_customer"$arrRegist);
  252.  
  253.         /* メルマガ会員機能は現在停止中 2007/03/07
  254.  
  255.         //-- 非会員でメルマガ登録しているかの判定
  256.         $sql = "SELECT count(*) FROM dtb_customer_mail WHERE email = ?";
  257.         $mailResult = $objConn->getOne($sql, array($arrRegist["email"]));
  258.  
  259.         //-- メルマガ仮登録実行
  260.         $arrRegistMail["email"] = $arrRegist["email"];
  261.         if ($array["mailmaga_flg"] == 1) {
  262.         $arrRegistMail["mailmaga_flg"] = 4;
  263.         } elseif ($array["mailmaga_flg"] == 2) {
  264.         $arrRegistMail["mailmaga_flg"] = 5;
  265.         } else {
  266.         $arrRegistMail["mailmaga_flg"] = 6;
  267.         }
  268.         $arrRegistMail["update_date"] = "now()";
  269.  
  270.         // 非会員でメルマガ登録している場合
  271.         if ($mailResult == 1) {
  272.         $objQuery->update("dtb_customer_mail", $arrRegistMail, "email = '" .addslashes($arrRegistMail["email"]). "'");
  273.         } else {                // 新規登録の場合
  274.         $arrRegistMail["create_date"] = "now()";
  275.         $objQuery->insert("dtb_customer_mail", $arrRegistMail);
  276.         }
  277.         */
  278.         $objConn->query("COMMIT");
  279.  
  280.         return $uniqid;
  281.     }
  282.  
  283.     //---- 取得文字列の変換
  284.     function lfConvertParam($array$arrRegistColumn{
  285.         /*
  286.          *    文字列の変換
  287.          *    K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
  288.          *    C :  「全角ひら仮名」を「全角かた仮名」に変換
  289.          *    V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
  290.          *    n :  「全角」数字を「半角(ハンカク)」に変換
  291.          *  a :  全角英数字を半角英数字に変換する
  292.          */
  293.         // カラム名とコンバート情報
  294.         foreach ($arrRegistColumn as $data{
  295.             $arrConvList$data["column"] ] $data["convert"];
  296.         }
  297.         // 文字変換
  298.         foreach ($arrConvList as $key => $val{
  299.             // POSTされてきた値のみ変換する。
  300.             if(strlen(($array[$key])) 0{
  301.                 $array[$keymb_convert_kana($array[$key,$val);
  302.             }
  303.         }
  304.         return $array;
  305.     }
  306.  
  307.     //---- 入力エラーチェック
  308.     function lfErrorCheck($array{
  309.  
  310.         $objErr new SC_CheckError($array);
  311.  
  312.         $objErr->doFunc(array("お名前(姓)"'name01'STEXT_LEN)array("EXIST_CHECK""NO_SPTAB""SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
  313.         $objErr->doFunc(array("お名前(名)"'name02'STEXT_LEN)array("EXIST_CHECK""NO_SPTAB""SPTAB_CHECK" "MAX_LENGTH_CHECK"));
  314.         $objErr->doFunc(array("フリガナ(セイ)"'kana01'STEXT_LEN)array("EXIST_CHECK""NO_SPTAB""SPTAB_CHECK" ,"MAX_LENGTH_CHECK""KANA_CHECK"));
  315.         $objErr->doFunc(array("フリガナ(メイ)"'kana02'STEXT_LEN)array("EXIST_CHECK""NO_SPTAB""SPTAB_CHECK" ,"MAX_LENGTH_CHECK""KANA_CHECK"));
  316.         $objErr->doFunc(array("郵便番号1""zip01"ZIP01_LEN ,array("EXIST_CHECK""SPTAB_CHECK" ,"NUM_CHECK""NUM_COUNT_CHECK"));
  317.         $objErr->doFunc(array("郵便番号2""zip02"ZIP02_LEN ,array("EXIST_CHECK""SPTAB_CHECK" ,"NUM_CHECK""NUM_COUNT_CHECK"));
  318.         $objErr->doFunc(array("郵便番号""zip01""zip02")array("ALL_EXIST_CHECK"));
  319.         $objErr->doFunc(array("都道府県"'pref')array("SELECT_CHECK","NUM_CHECK"));
  320.         $objErr->doFunc(array("ご住所1""addr01"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
  321.         $objErr->doFunc(array("ご住所2""addr02"MTEXT_LEN)array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
  322.         $objErr->doFunc(array('メールアドレス'"email"MTEXT_LEN,array("NO_SPTAB""EXIST_CHECK""EMAIL_CHECK""SPTAB_CHECK" ,"EMAIL_CHAR_CHECK""MAX_LENGTH_CHECK"));
  323.         $objErr->doFunc(array('メールアドレス(確認)'"email02"MTEXT_LEN,array("NO_SPTAB""EXIST_CHECK""EMAIL_CHECK","SPTAB_CHECK" "EMAIL_CHAR_CHECK""MAX_LENGTH_CHECK"));
  324.         $objErr->doFunc(array('メールアドレス''メールアドレス(確認)'"email""email02",array("EQUAL_CHECK"));
  325.  
  326.         //現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
  327.         if (strlen($array["email"]0{
  328.             $array['email'strtolower($array['email']);
  329.             $objQuery new SC_Query();
  330.             $arrRet $objQuery->select("email, update_date, del_flg""dtb_customer","email = ? ORDER BY del_flg"array($array["email"]));
  331.  
  332.             if(count($arrRet0{
  333.                 if($arrRet[0]['del_flg'!= '1'{
  334.                     // 会員である場合
  335.                     $objErr->arrErr["email".= "※ すでに会員登録で使用されているメールアドレスです。<br />";
  336.                 else {
  337.                     // 退会した会員である場合
  338.                     $leave_time SC_Utils_Ex::sfDBDatetoTime($arrRet[0]['update_date']);
  339.                     $now_time time();
  340.                     $pass_time $now_time $leave_time;
  341.                     // 退会から何時間-経過しているか判定する。
  342.                     $limit_time ENTRY_LIMIT_HOUR 3600;
  343.                     if($pass_time $limit_time{
  344.                         $objErr->arrErr["email".= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
  345.                     }
  346.                 }
  347.             }
  348.         }
  349.  
  350.         $objErr->doFunc(array("お電話番号1"'tel01')array("EXIST_CHECK","SPTAB_CHECK" ));
  351.         $objErr->doFunc(array("お電話番号2"'tel02')array("EXIST_CHECK","SPTAB_CHECK" ));
  352.         $objErr->doFunc(array("お電話番号3"'tel03')array("EXIST_CHECK","SPTAB_CHECK" ));
  353.         $objErr->doFunc(array("お電話番号""tel01""tel02""tel03",TEL_ITEM_LEN,array("TEL_CHECK"));
  354.         $objErr->doFunc(array("FAX番号1"'fax01')array("SPTAB_CHECK"));
  355.         $objErr->doFunc(array("FAX番号2"'fax02')array("SPTAB_CHECK"));
  356.         $objErr->doFunc(array("FAX番号3"'fax03')array("SPTAB_CHECK"));
  357.         $objErr->doFunc(array("FAX番号""fax01""fax02""fax03"TEL_ITEM_LEN,array("TEL_CHECK"));
  358.         $objErr->doFunc(array("ご性別""sex",array("SELECT_CHECK""NUM_CHECK"));
  359.         $objErr->doFunc(array("パスワード"'password'PASSWORD_LEN1PASSWORD_LEN2)array("EXIST_CHECK""SPTAB_CHECK" ,"ALNUM_CHECK""NUM_RANGE_CHECK"));
  360.         $objErr->doFunc(array("パスワード(確認)"'password02'PASSWORD_LEN1PASSWORD_LEN2)array("EXIST_CHECK""SPTAB_CHECK" ,"ALNUM_CHECK""NUM_RANGE_CHECK"));
  361.         $objErr->doFunc(array('パスワード''パスワード(確認)'"password""password02",array("EQUAL_CHECK"));
  362.         $objErr->doFunc(array("パスワードを忘れたときのヒント 質問""reminder",array("SELECT_CHECK""NUM_CHECK"));
  363.         $objErr->doFunc(array("パスワードを忘れたときのヒント 答え""reminder_answer"STEXT_LEN,array("EXIST_CHECK","SPTAB_CHECK" "MAX_LENGTH_CHECK"));
  364.         $objErr->doFunc(array("メールマガジン""mailmaga_flg",array("SELECT_CHECK""NUM_CHECK"));
  365.         $objErr->doFunc(array("生年月日""year""month""day")array("CHECK_BIRTHDAY"));
  366.  
  367.  
  368.         return $objErr->arrErr;
  369.     }
  370.  
  371.     // キャンペーン受注テーブルへ登録
  372.     function lfRegistCampaignOrder($uniqid&$objQuery{
  373.         global $objCampaignSess;
  374.  
  375.         $campaign_id $objCampaignSess->getCampaignId();
  376.  
  377.         // 顧客データを取得
  378.         $cols "
  379.             customer_id,
  380.             name01 as order_name01,
  381.             name02 as order_name02,
  382.             kana01 as order_kana01,
  383.             kana02 as order_kana02,
  384.             zip01 as order_zip01,
  385.             zip02 as order_zip02,
  386.             pref as order_pref,
  387.             addr01 as order_addr01,
  388.             addr02 as order_addr02,
  389.             email as order_email,
  390.             tel01 as order_tel01,
  391.             tel02 as order_tel02,
  392.             tel03 as order_tel03,
  393.             fax01 as order_fax01,
  394.             fax02 as order_fax02,
  395.             fax03 as order_fax03,
  396.             sex as order_sex,
  397.             job as order_job,
  398.             birth as order_birth
  399.             ";
  400.  
  401.         $arrCustomer $objQuery->select($cols"dtb_customer""secret_key = ?"array($uniqid));
  402.  
  403.         $sqlval $arrCustomer[0];
  404.         $sqlval['campaign_id'$campaign_id;
  405.         $sqlval['create_date''now()';
  406.  
  407.         // INSERTの実行
  408.         $objQuery->insert("dtb_campaign_order"$sqlval);
  409.  
  410.         // 申し込み数の更新
  411.         $total_count $objQuery->get("dtb_campaign""total_count""campaign_id = ?"array($campaign_id));
  412.         $arrCampaign['total_count'$total_count += 1;
  413.         $objQuery->update("dtb_campaign"$arrCampaign"campaign_id = ?"array($campaign_id));
  414.     }
  415.  
  416.     //確認ページ用パスワード表示用
  417.  
  418.     function lfPassLen($passlen){
  419.         $ret "";
  420.         for ($i=0;$i<$passlen;true){
  421.             $ret.="*";
  422.             $i++;
  423.         }
  424.         return $ret;
  425.     }
  426.  
  427. }
  428. ?>

Documentation generated on Tue, 28 Apr 2009 18:12:01 +0900 by phpDocumentor 1.4.2