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

Revision 22856, 4.4 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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