source: branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Delete.php @ 20534

Revision 20534, 4.5 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)
#628(未使用処理・定義などの削除)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
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
25require_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 */
34class 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        $objFormParam = new SC_FormParam;
65
66        // パラメータの初期化
67        $this->initParam($objFormParam, $_GET);
68
69        // パラメータの検証
70        if ($objFormParam->checkError()
71            || !SC_Utils_ex::sfIsInt($id = $objFormParam->getValue('id'))) {
72
73            GC_Utils_Ex::gfPrintLog("error id=$id");
74            SC_Utils_Ex::sfDispError(INVALID_MOVE_ERRORR);
75        }
76
77        $id = $objFormParam->getValue('id');
78
79        // レコードの削除
80        $this->deleteMember($id);
81
82        // リダイレクト
83        $url = $this->getLocation(ADMIN_SYSTEM_URLPATH)
84             . '?pageno=' . $objFormParam->getValue('pageno');
85        SC_Response_Ex::sendRedirect($url);
86    }
87
88    /**
89     * デストラクタ.
90     *
91     * @return void
92     */
93    function destroy() {
94        parent::destroy();
95    }
96
97
98    /**
99     * パラメータ初期化.
100     *
101     * @param object $objFormParam
102     * @param array  $arrParams  $_GET値
103     * @return void
104     */
105    function initParam(&$objFormParam, &$arrParams) {
106
107        $objFormParam->addParam('pageno', 'pageno', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK'));
108        $objFormParam->addParam('id', 'id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
109        $objFormParam->setParam($arrParams);
110
111    }
112
113    /**
114     * メンバー情報削除の為の制御.
115     *
116     * @param integer $id 削除対象のmember_id
117     * @return void
118     */
119    function deleteMember($id) {
120        $objQuery =& SC_Query_Ex::getSingletonInstance();
121        $objQuery->begin();
122
123        $this->renumberRank($objQuery, $id);
124        $this->deleteRecode($objQuery, $id);
125
126        $objQuery->commit();
127    }
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    /**
152     * レコードの削除(削除フラグをONにする).
153     *
154     * @param object $objQuery
155     * @param integer $id 削除対象のmember_id
156     * @return void|UPDATE の結果フラグ
157     */
158    function deleteRecode(&$objQuery, $id) {
159
160        // Updateする値を作成する.
161        $sqlVal = array();
162        $sqlVal['rank'] = 0;
163        $sqlVal['del_flg'] = 1;
164        $where = "member_id = ?";
165
166        // UPDATEの実行 - ランクを最下位にする、DELフラグON
167        return $objQuery->update("dtb_member", $sqlVal, $where, array($id));
168    }
169}
170?>
Note: See TracBrowser for help on using the repository browser.