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

Revision 23124, 4.4 KB checked in by kimoto, 11 years ago (diff)

#2043 typo修正・ソース整形・ソースコメントの改善 for 2.13.0
PHP4的な書き方の修正

  • 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    public function init()
41    {
42        parent::init();
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    public function process()
51    {
52        $this->action();
53        $this->sendResponse();
54    }
55
56    /**
57     * Page のアクション.
58     *
59     * @return void
60     */
61    public 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     * @param  object $objFormParam
91     * @param  array  $arrParams    $_GET値
92     * @return void
93     */
94    public function initParam(&$objFormParam, &$arrParams)
95    {
96        $objFormParam->addParam('pageno', 'pageno', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK', 'EXIST_CHECK'));
97        $objFormParam->addParam('id', 'id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
98        $objFormParam->setParam($arrParams);
99    }
100
101    /**
102     * メンバー情報削除の為の制御.
103     *
104     * @param  integer $id 削除対象のmember_id
105     * @return void
106     */
107    public function deleteMember($id)
108    {
109        $objQuery =& SC_Query_Ex::getSingletonInstance();
110        $objQuery->begin();
111
112        $this->renumberRank($objQuery, $id);
113        $this->deleteRecode($objQuery, $id);
114
115        $objQuery->commit();
116    }
117
118    /**
119     * ランキングの振り直し.
120     *
121     * @param  object      $objQuery
122     * @param  integer     $id       削除対象のmember_id
123     * @return void|UPDATE の結果フラグ
124     */
125    public function renumberRank(&$objQuery, $id)
126    {
127        // ランクの取得
128        $where1 = 'member_id = ?';
129        $rank = $objQuery->get('rank', 'dtb_member', $where1, array($id));
130
131        // Updateする値を作成する.
132        $where2 = 'rank > ? AND del_flg <> 1';
133
134        // UPDATEの実行 - 削除したレコードより上のランキングを下げてRANKの空きを埋める。
135        return $objQuery->update('dtb_member', array(), $where2, array($rank), array('rank' => 'rank-1'));
136    }
137
138    /**
139     * レコードの削除(削除フラグをONにする).
140     *
141     * @param  object      $objQuery
142     * @param  integer     $id       削除対象のmember_id
143     * @return void|UPDATE の結果フラグ
144     */
145    public function deleteRecode(&$objQuery, $id)
146    {
147        // Updateする値を作成する.
148        $sqlVal = array();
149        $sqlVal['rank'] = 0;
150        $sqlVal['del_flg'] = 1;
151        $where = 'member_id = ?';
152
153        // UPDATEの実行 - ランクを最下位にする、DELフラグON
154        return $objQuery->update('dtb_member', $sqlVal, $where, array($id));
155    }
156}
Note: See TracBrowser for help on using the repository browser.