[Svn-src-all:3672] [version-2_12-dev 22584] #2164 pageクラスからdtb_mailtemplateテーブルを直接指定している箇所をなくす
pineray
admin @ mail.ec-cube.net
2013年 2月 26日 (火) 20:55:22 JST
Subversion committed to /home/svn/open 22584
http://svn.ec-cube.net/open_trac/changeset/22584
┌────────────────────────────┐
│更新者 : pineray │
│更新日時: 2013-02-26 20:55:22 +0900 (火, 26 2月 2013)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#2164 pageクラスからdtb_mailtemplateテーブルを直接指定している箇所をなくす
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php
A branches/version-2_12-dev/data/class/helper/SC_Helper_Mailtemplate.php
U branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php
U branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php
A branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Mailtemplate_Ex.php
変更: branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php 2013-02-26 00:17:24 UTC (rev 22583)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Mail.php 2013-02-26 11:55:22 UTC (rev 22584)
@@ -75,13 +75,12 @@
function sfSendTemplateMail($to, $to_name, $template_id, &$objPage, $from_address = '', $from_name = '', $reply_to = '', $bcc = '')
{
- $objQuery =& SC_Query_Ex::getSingletonInstance();
// メールテンプレート情報の取得
- $where = 'template_id = ?';
- $arrRet = $objQuery->select('subject, header, footer', 'dtb_mailtemplate', $where, array($template_id));
- $objPage->tpl_header = $arrRet[0]['header'];
- $objPage->tpl_footer = $arrRet[0]['footer'];
- $tmp_subject = $arrRet[0]['subject'];
+ $objMailtemplate = new SC_Helper_Mailtemplate_Ex();
+ $mailtemplate = $objMailtemplate->get($template_id);
+ $objPage->tpl_header = $mailtemplate['header'];
+ $objPage->tpl_footer = $mailtemplate['footer'];
+ $tmp_subject = $mailtemplate['subject'];
$arrInfo = SC_Helper_DB_Ex::sfGetBasisData();
@@ -116,11 +115,11 @@
if ($subject == '' && $header == '' && $footer == '') {
// メールテンプレート情報の取得
- $where = 'template_id = ?';
- $arrRet = $objQuery->select('subject, header, footer', 'dtb_mailtemplate', $where, array($template_id));
- $arrTplVar->tpl_header = $arrRet[0]['header'];
- $arrTplVar->tpl_footer = $arrRet[0]['footer'];
- $tmp_subject = $arrRet[0]['subject'];
+ $objMailtemplate = new SC_Helper_Mailtemplate_Ex();
+ $mailtemplate = $objMailtemplate->get($template_id);
+ $arrTplVar->tpl_header = $mailtemplate['header'];
+ $arrTplVar->tpl_footer = $mailtemplate['footer'];
+ $tmp_subject = $mailtemplate['subject'];
} else {
$arrTplVar->tpl_header = $header;
$arrTplVar->tpl_footer = $footer;
追加: branches/version-2_12-dev/data/class/helper/SC_Helper_Mailtemplate.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Mailtemplate.php (rev 0)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Mailtemplate.php 2013-02-26 11:55:22 UTC (rev 22584)
@@ -0,0 +1,102 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * メールテンプレートを管理するヘルパークラス.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Mailtemplate
+{
+ /**
+ * メールテンプレートの情報を取得.
+ *
+ * @param integer $template_id メールテンプレートID
+ * @param boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false
+ * @return array
+ */
+ public function get($template_id, $has_deleted = false)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $where = 'template_id = ?';
+ if (!$has_deleted) {
+ $where .= ' AND del_flg = 0';
+ }
+ $arrRet = $objQuery->select($col, 'dtb_mailtemplate', $where, array($template_id));
+ return $arrRet[0];
+ }
+
+ /**
+ * メールテンプレート一覧の取得.
+ *
+ * @param boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false
+ * @return array
+ */
+ public function getList($has_deleted = false)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $where = '';
+ if (!$has_deleted) {
+ $where .= 'del_flg = 0';
+ }
+ $table = 'dtb_mailtemplate';
+ $arrRet = $objQuery->select($col, $table, $where);
+ return $arrRet;
+ }
+
+ /**
+ * メールテンプレートの登録.
+ *
+ * @param array $sqlval
+ * @return multiple 登録成功:メールテンプレートID, 失敗:FALSE
+ */
+ public function save($sqlval)
+ {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+
+ $template_id = $sqlval['template_id'];
+ $sqlval['update_date'] = 'CURRENT_TIMESTAMP';
+ // 存在確認
+ $where = 'template_id = ?';
+ $exist = $objQuery->exists('dtb_mailtemplate', $where, array($template_id));
+ // 新規登録
+ if (!$exist) {
+ // INSERTの実行
+ $sqlval['create_date'] = 'CURRENT_TIMESTAMP';
+ if (!$sqlval['template_id']) {
+ $sqlval['template_id'] = $objQuery->nextVal('dtb_mailtemplate_template_id');
+ }
+ $ret = $objQuery->insert('dtb_mailtemplate', $sqlval);
+ // 既存編集
+ } else {
+ unset($sqlval['creator_id']);
+ unset($sqlval['create_date']);
+ $ret = $objQuery->update('dtb_mailtemplate', $sqlval, $where, array($template_id));
+ }
+ return ($ret) ? $sqlval['template_id'] : FALSE;
+ }
+}
変更: branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php 2013-02-26 00:17:24 UTC (rev 22583)
+++ branches/version-2_12-dev/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php 2013-02-26 11:55:22 UTC (rev 22584)
@@ -72,6 +72,7 @@
{
$masterData = new SC_DB_MasterData_Ex();
+ $objMailtemplate = new SC_Helper_Mailtemplate_Ex();
$mode = $this->getMode();
@@ -89,9 +90,9 @@
switch ($mode) {
case 'id_set':
- $result = $this->lfGetMailTemplateByTemplateID($post['template_id']);
- if ($result) {
- $this->arrForm = $result[0];
+ $mailtemplate = $objMailtemplate->get($post['template_id']);
+ if ($mailtemplate) {
+ $this->arrForm = $mailtemplate;
} else {
$this->arrForm['template_id'] = $post['template_id'];
}
@@ -105,7 +106,7 @@
} else {
// 正常
- $this->lfRegistMailTemplate($this->arrForm, $_SESSION['member_id']);
+ $this->lfRegistMailTemplate($this->arrForm, $_SESSION['member_id'], $objMailtemplate);
// 完了メッセージ
$this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');";
@@ -128,30 +129,10 @@
parent::destroy();
}
- function lfGetMailTemplateByTemplateID($template_id)
+ function lfRegistMailTemplate($post, $member_id, SC_Helper_Mailtemplate_Ex $objMailtemplate)
{
- $objQuery =& SC_Query_Ex::getSingletonInstance();
-
- $sql = 'SELECT * FROM dtb_mailtemplate WHERE template_id = ?';
- return $objQuery->getAll($sql, array($template_id));
- }
-
- function lfRegistMailTemplate($post, $member_id)
- {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
-
$post['creator_id'] = $member_id;
- $post['update_date'] = 'CURRENT_TIMESTAMP';
-
- $sql = 'SELECT * FROM dtb_mailtemplate WHERE template_id = ?';
- $template_data = $objQuery->getAll($sql, array($post['template_id']));
- if ($template_data) {
- $sql_where = 'template_id = ?';
- $objQuery->update('dtb_mailtemplate', $post, $sql_where, array(addslashes($post['template_id'])));
- } else {
- $objQuery->insert('dtb_mailtemplate', $post);
- }
-
+ $objMailtemplate->save($post);
}
function lfInitParam($mode, &$objFormParam)
変更: branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php 2013-02-26 00:17:24 UTC (rev 22583)
+++ branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php 2013-02-26 11:55:22 UTC (rev 22584)
@@ -226,8 +226,6 @@
*/
function changeData(&$objFormParam)
{
- $objQuery =& SC_Query_Ex::getSingletonInstance();
-
$template_id = $objFormParam->getValue('template_id');
// 未選択時
@@ -236,9 +234,8 @@
}
// 有効選択時
elseif (SC_Utils_Ex::sfIsInt($template_id)) {
- $where = 'template_id = ?';
- $arrWhereVal = array($template_id);
- $mailTemplates = $objQuery->getRow('subject, header, footer', 'dtb_mailtemplate', $where, $arrWhereVal);
+ $objMailtemplate = new SC_Helper_Mailtemplate_Ex();
+ $mailTemplates = $objMailtemplate->get($template_id);
}
// 不正選択時
else {
追加: branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Mailtemplate_Ex.php
===================================================================
--- branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Mailtemplate_Ex.php (rev 0)
+++ branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Mailtemplate_Ex.php 2013-02-26 11:55:22 UTC (rev 22584)
@@ -0,0 +1,39 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+// {{{ requires
+require_once CLASS_REALDIR . 'helper/SC_Helper_Mailtemplate.php';
+
+/**
+ * メールテンプレートを管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Mailtemplate をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Mailtemplate_Ex extends SC_Helper_Mailtemplate
+{
+ //put your code here
+}
Svn-src-all メーリングリストの案内