Last active
August 29, 2015 14:22
-
-
Save kurozumi/279422fa580b47ba7b0a to your computer and use it in GitHub Desktop.
【EC-CUBE2.13】メンバー管理の項目を住所と電話番号とメールアドレスを追加する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This file is part of EC-CUBE | |
* | |
* Copyright(c) 2000-2014 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. | |
*/ | |
require_once CLASS_REALDIR . 'pages/admin/system/LC_Page_Admin_System_Input.php'; | |
/** | |
* システム管理 のページクラス(拡張). | |
* | |
* LC_Page_Admin_System_Input をカスタマイズする場合はこのクラスを編集する. | |
* | |
* @package Page | |
* @author LOCKON CO.,LTD. | |
* @version $Id: LC_Page_Admin_System_Input_Ex.php 23546 2014-06-12 14:47:59Z shutta $ | |
*/ | |
class LC_Page_Admin_System_Input_Ex extends LC_Page_Admin_System_Input { | |
/** | |
* Page を初期化する. | |
* | |
* @return void | |
*/ | |
function init() | |
{ | |
parent::init(); | |
$masterData = new SC_DB_MasterData_Ex(); | |
$this->arrPref = $masterData->getMasterData('mtb_pref'); | |
} | |
/** | |
* Page のプロセス. | |
* | |
* @return void | |
*/ | |
function process() | |
{ | |
parent::process(); | |
} | |
/** | |
* フォームパラメーター初期化 | |
* | |
* @param SC_FormParam_Ex $objFormParam | |
* @param array $arrParams $_POST値 | |
* @param string $mode editの時は指定 | |
* @return void | |
*/ | |
public function initForm(&$objFormParam, &$arrParams, $mode = '') | |
{ | |
parent::initForm($objFormParam, $arrParams, $mode); | |
$objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); | |
$objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); | |
$objFormParam->addParam('都道府県', 'pref', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK')); | |
$objFormParam->addParam('住所1', 'addr01', MTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); | |
$objFormParam->addParam('住所2', 'addr02', MTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); | |
$objFormParam->addParam('メールアドレス', 'email', null, 'a', array('NO_SPTAB', 'EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK')); | |
$objFormParam->addParam('お電話番号1', 'tel01', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); | |
$objFormParam->addParam('お電話番号2', 'tel02', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); | |
$objFormParam->addParam('お電話番号3', 'tel03', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); | |
$objFormParam->setParam($arrParams); | |
$objFormParam->convParam(); | |
} | |
/** | |
* DBからmember_idに対応する管理者データを取得する | |
* | |
* @param integer $id メンバーID | |
* @return array 管理者データの連想配列, 無い場合は空の配列を返す | |
*/ | |
public function getMemberData($id) | |
{ | |
$table = 'dtb_member'; | |
$columns = <<< __EOS__ | |
name, | |
department, | |
login_id, | |
authority, | |
work, | |
zip01, | |
zip02, | |
pref, | |
addr01, | |
addr02, | |
email, | |
tel01, | |
tel02, | |
tel03 | |
__EOS__; | |
$where = 'member_id = ?'; | |
$objQuery = & SC_Query_Ex::getSingletonInstance(); | |
return $objQuery->getRow($columns, $table, $where, array($id)); | |
} | |
/** | |
* 入力された管理者データをInsertする. | |
* | |
* @param array 管理者データの連想配列 | |
* @return void | |
*/ | |
public function insertMemberData($arrMemberData) | |
{ | |
$objQuery = & SC_Query_Ex::getSingletonInstance(); | |
// INSERTする値を作成する. | |
$salt = SC_Utils_Ex::sfGetRandomString(10); | |
$sqlVal = array(); | |
$sqlVal['name'] = $arrMemberData['name']; | |
$sqlVal['department'] = $arrMemberData['department']; | |
$sqlVal['login_id'] = $arrMemberData['login_id']; | |
$sqlVal['password'] = SC_Utils_Ex::sfGetHashString($arrMemberData['password'], $salt); | |
$sqlVal['salt'] = $salt; | |
$sqlVal['authority'] = $arrMemberData['authority']; | |
$sqlVal['rank'] = $objQuery->max('rank', 'dtb_member') + 1; | |
$sqlVal['work'] = $arrMemberData['work']; | |
$sqlVal['del_flg'] = '0'; // 削除フラグをOFFに設定 | |
$sqlVal['creator_id'] = $_SESSION['member_id']; | |
$sqlVal['create_date'] = 'CURRENT_TIMESTAMP'; | |
$sqlVal['update_date'] = 'CURRENT_TIMESTAMP'; | |
$sqlVal['zip01'] = $arrMemberData['zip01']; | |
$sqlVal['zip02'] = $arrMemberData['zip02']; | |
$sqlVal['pref'] = $arrMemberData['pref']; | |
$sqlVal['addr01'] = $arrMemberData['addr01']; | |
$sqlVal['addr02'] = $arrMemberData['addr02']; | |
$sqlVal['email'] = $arrMemberData['email']; | |
$sqlVal['tel01'] = $arrMemberData['tel01']; | |
$sqlVal['tel02'] = $arrMemberData['tel02']; | |
$sqlVal['tel03'] = $arrMemberData['tel03']; | |
// INSERTの実行 | |
$sqlVal['member_id'] = $objQuery->nextVal('dtb_member_member_id'); | |
$objQuery->insert('dtb_member', $sqlVal); | |
} | |
/** | |
* 管理者データをUpdateする. | |
* | |
* @param array 管理者データの連想配列 | |
* @return void | |
*/ | |
public function updateMemberData($member_id, $arrMemberData) | |
{ | |
$objQuery = & SC_Query_Ex::getSingletonInstance(); | |
// Updateする値を作成する. | |
$sqlVal = array(); | |
$sqlVal['name'] = $arrMemberData['name']; | |
$sqlVal['department'] = $arrMemberData['department']; | |
$sqlVal['login_id'] = $arrMemberData['login_id']; | |
$sqlVal['authority'] = $arrMemberData['authority']; | |
$sqlVal['work'] = $arrMemberData['work']; | |
$sqlVal['update_date'] = 'CURRENT_TIMESTAMP'; | |
$sqlVal['zip01'] = $arrMemberData['zip01']; | |
$sqlVal['zip02'] = $arrMemberData['zip02']; | |
$sqlVal['pref'] = $arrMemberData['pref']; | |
$sqlVal['addr01'] = $arrMemberData['addr01']; | |
$sqlVal['addr02'] = $arrMemberData['addr02']; | |
$sqlVal['email'] = $arrMemberData['email']; | |
$sqlVal['tel01'] = $arrMemberData['tel01']; | |
$sqlVal['tel02'] = $arrMemberData['tel02']; | |
$sqlVal['tel03'] = $arrMemberData['tel03']; | |
if ($arrMemberData['password'] != DEFAULT_PASSWORD) { | |
$salt = SC_Utils_Ex::sfGetRandomString(10); | |
$sqlVal['salt'] = $salt; | |
$sqlVal['password'] = SC_Utils_Ex::sfGetHashString($arrMemberData['password'], $salt); | |
} | |
$where = 'member_id = ?'; | |
// UPDATEの実行 | |
$objQuery->update('dtb_member', $sqlVal, $where, array($member_id)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment