source: branches/comu-ver2/data/class/pages/admin/system/LC_Page_Admin_System_Delete.php @ 18701

Revision 18701, 3.7 KB checked in by nanasess, 14 years ago (diff)

Copyright の更新(#601)

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