1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2012 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * メンバー削除 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_System_Delete extends LC_Page_Admin_Ex { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * Page のプロセス. |
---|
50 | * |
---|
51 | * @return void |
---|
52 | */ |
---|
53 | function process() { |
---|
54 | $this->action(); |
---|
55 | $this->sendResponse(); |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * Page のアクション. |
---|
60 | * |
---|
61 | * @return void |
---|
62 | */ |
---|
63 | function action() { |
---|
64 | |
---|
65 | $objFormParam = new SC_FormParam_Ex; |
---|
66 | |
---|
67 | // パラメーターの初期化 |
---|
68 | $this->initParam($objFormParam, $_GET); |
---|
69 | |
---|
70 | // パラメーターの検証 |
---|
71 | if ($objFormParam->checkError() |
---|
72 | || !SC_Utils_ex::sfIsInt($id = $objFormParam->getValue('id'))) { |
---|
73 | |
---|
74 | GC_Utils_Ex::gfPrintLog("error id=$id"); |
---|
75 | SC_Utils_Ex::sfDispError(INVALID_MOVE_ERRORR); |
---|
76 | } |
---|
77 | |
---|
78 | $id = $objFormParam->getValue('id'); |
---|
79 | |
---|
80 | // レコードの削除 |
---|
81 | $this->deleteMember($id); |
---|
82 | |
---|
83 | // リダイレクト |
---|
84 | $url = $this->getLocation(ADMIN_SYSTEM_URLPATH) |
---|
85 | . '?pageno=' . $objFormParam->getValue('pageno'); |
---|
86 | |
---|
87 | SC_Response_Ex::sendRedirect($url); |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * デストラクタ. |
---|
92 | * |
---|
93 | * @return void |
---|
94 | */ |
---|
95 | function destroy() { |
---|
96 | parent::destroy(); |
---|
97 | } |
---|
98 | |
---|
99 | /** |
---|
100 | * パラメーター初期化. |
---|
101 | * |
---|
102 | * @param object $objFormParam |
---|
103 | * @param array $arrParams $_GET値 |
---|
104 | * @return void |
---|
105 | */ |
---|
106 | function initParam(&$objFormParam, &$arrParams) { |
---|
107 | |
---|
108 | $objFormParam->addParam(t('c_pageno_01'), 'pageno', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK')); |
---|
109 | $objFormParam->addParam(t('PARAM_LABEL_ID_ALP'), 'id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
110 | $objFormParam->setParam($arrParams); |
---|
111 | |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * メンバー情報削除の為の制御. |
---|
116 | * |
---|
117 | * @param integer $id 削除対象のmember_id |
---|
118 | * @return void |
---|
119 | */ |
---|
120 | function deleteMember($id) { |
---|
121 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
122 | $objQuery->begin(); |
---|
123 | |
---|
124 | $this->renumberRank($objQuery, $id); |
---|
125 | $this->deleteRecode($objQuery, $id); |
---|
126 | |
---|
127 | $objQuery->commit(); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * ランキングの振り直し. |
---|
132 | * |
---|
133 | * @param object $objQuery |
---|
134 | * @param integer $id 削除対象のmember_id |
---|
135 | * @return void|UPDATE の結果フラグ |
---|
136 | */ |
---|
137 | function renumberRank(&$objQuery, $id) { |
---|
138 | |
---|
139 | // ランクの取得 |
---|
140 | $where1 = 'member_id = ?'; |
---|
141 | $rank = $objQuery->get('rank', 'dtb_member', $where1, array($id)); |
---|
142 | |
---|
143 | // Updateする値を作成する. |
---|
144 | $where2 = 'rank > ? AND del_flg <> 1'; |
---|
145 | |
---|
146 | // UPDATEの実行 - 削除したレコードより上のランキングを下げてRANKの空きを埋める。 |
---|
147 | return $objQuery->update('dtb_member', array(), $where2, array($rank), array('rank' => 'rank-1')); |
---|
148 | } |
---|
149 | |
---|
150 | /** |
---|
151 | * レコードの削除(削除フラグをONにする). |
---|
152 | * |
---|
153 | * @param object $objQuery |
---|
154 | * @param integer $id 削除対象のmember_id |
---|
155 | * @return void|UPDATE の結果フラグ |
---|
156 | */ |
---|
157 | function deleteRecode(&$objQuery, $id) { |
---|
158 | |
---|
159 | // Updateする値を作成する. |
---|
160 | $sqlVal = array(); |
---|
161 | $sqlVal['rank'] = 0; |
---|
162 | $sqlVal['del_flg'] = 1; |
---|
163 | $where = 'member_id = ?'; |
---|
164 | |
---|
165 | // UPDATEの実行 - ランクを最下位にする、DELフラグON |
---|
166 | return $objQuery->update('dtb_member', $sqlVal, $where, array($id)); |
---|
167 | } |
---|
168 | } |
---|