1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 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_FILE_PATH . "pages/admin/LC_Page_Admin.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * XXX のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Admin_System_Delete extends LC_Page_Admin { |
---|
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 | $objSess = new SC_Session(); |
---|
66 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
67 | |
---|
68 | $this->initParam(); |
---|
69 | |
---|
70 | // パラメータの検証 |
---|
71 | if ($this->objForm->checkError() |
---|
72 | || !SC_Utils_ex::sfIsInt($id = $this->objForm->getValue('id'))) { |
---|
73 | |
---|
74 | GC_Utils_Ex::gfPrintLog("error id=$id"); |
---|
75 | SC_Utils_Ex::sfDispError(INVALID_MOVE_ERRORR); |
---|
76 | } |
---|
77 | |
---|
78 | $id = $this->objForm->getValue('id'); |
---|
79 | |
---|
80 | // レコードの削除 |
---|
81 | $objQuery =& new SC_Query; |
---|
82 | $objQuery->begin(); |
---|
83 | |
---|
84 | $this->renumberRank($objQuery, $id); |
---|
85 | $this->deleteRecode($objQuery, $id); |
---|
86 | |
---|
87 | $objQuery->commit(); |
---|
88 | |
---|
89 | // リダイレクト |
---|
90 | $url = $this->getLocation(URL_SYSTEM_TOP) |
---|
91 | . '?pageno=' . $this->objForm->getValue('pageno'); |
---|
92 | $this->objDisplay->redirect($url); |
---|
93 | } |
---|
94 | |
---|
95 | /** |
---|
96 | * デストラクタ. |
---|
97 | * |
---|
98 | * @return void |
---|
99 | */ |
---|
100 | function destroy() { |
---|
101 | parent::destroy(); |
---|
102 | } |
---|
103 | |
---|
104 | function initParam() { |
---|
105 | $objForm = new SC_FormParam; |
---|
106 | $objForm->addParam('pageno', 'pageno', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK')); |
---|
107 | $objForm->addParam('id', 'id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
108 | $objForm->setParam($_GET); |
---|
109 | |
---|
110 | $this->objForm = $objForm; |
---|
111 | } |
---|
112 | |
---|
113 | // ランキングの振り直し |
---|
114 | function renumberRank(&$objQuery, $id) { |
---|
115 | $where = "member_id = ?"; |
---|
116 | // ランクの取得 |
---|
117 | $rank = $objQuery->get("rank", "dtb_member", $where, array($id)); |
---|
118 | |
---|
119 | // 削除したレコードより上のランキングを下げてRANKの空きを埋める。 |
---|
120 | $sqlup =<<<END |
---|
121 | UPDATE |
---|
122 | dtb_member |
---|
123 | SET |
---|
124 | rank = (rank - 1) |
---|
125 | WHERE |
---|
126 | rank > ? AND del_flg <> 1 |
---|
127 | END; |
---|
128 | // UPDATEの実行 |
---|
129 | return $objQuery->query($sqlup, array($rank)); |
---|
130 | } |
---|
131 | |
---|
132 | // レコードの削除(削除フラグをONにする) |
---|
133 | function deleteRecode(&$objQuery, $id) { |
---|
134 | // ランクを最下位にする、DELフラグON |
---|
135 | $sqlup =<<<END |
---|
136 | UPDATE |
---|
137 | dtb_member |
---|
138 | SET |
---|
139 | rank = 0, |
---|
140 | del_flg = 1 |
---|
141 | WHERE |
---|
142 | member_id = ? |
---|
143 | END; |
---|
144 | // UPDATEの実行 |
---|
145 | return $objQuery->query($sqlup, array($id)); |
---|
146 | } |
---|
147 | |
---|
148 | |
---|
149 | } |
---|
150 | /* |
---|
151 | * Local variables: |
---|
152 | * coding: utf-8 |
---|
153 | * End: |
---|
154 | */ |
---|
155 | ?> |
---|