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

Revision 20764, 5.1 KB checked in by nanasess, 13 years ago (diff)

#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-2011 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_Rank extends LC_Page_Admin_Ex {
35    // }}}
36    // {{{ functions
37
38    /**
39     * Page を初期化する.
40     *
41     * @return void
42     */
43    function init() {
44        parent::init();
45    }
46
47    /**
48     * Page のプロセス.
49     *
50     * @return void
51     */
52    function process() {
53        $this->action();
54        $this->sendResponse();
55    }
56
57    /**
58     * Page のアクション.
59     *
60     * @return void
61     */
62    function action() {
63        // チェック後のデータを格納
64        $arrClean = array();
65
66        // $_GET['move'] が想定値かどうかチェック
67        switch($_GET['move']) {
68            case 'up':
69            case 'down':
70                $arrClean['move'] = $_GET['move'];
71                break;
72            default:
73                $arrClean['move'] = "";
74                break;
75        }
76
77        // 正当な数値であればOK
78        if (SC_Utils_Ex::sfIsInt($_GET['id'])) {
79            $arrClean['id'] = $_GET['id'];
80
81            switch($arrClean['move']) {
82                case 'up':
83                    $this->lfRunkUp($arrClean['id']);
84                    break;
85
86                case 'down':
87                    $this->lfRunkDown($arrClean['id']);
88                    break;
89
90                default:
91                    break;
92            }
93        }
94
95        // エラー処理
96        else {
97            GC_Utils_Ex::gfPrintLog("error id=".$_GET['id']);
98        }
99
100        // ページの表示
101        SC_Response_Ex::sendRedirect(ADMIN_SYSTEM_URLPATH);
102    }
103
104    /**
105     * デストラクタ.
106     *
107     * @return void
108     */
109    function destroy() {
110        parent::destroy();
111    }
112
113    // ランキングを上げる。
114    function lfRunkUp($id) {
115        $objQuery =& SC_Query_Ex::getSingletonInstance();
116
117        // 自身のランクを取得する。
118        $rank = $objQuery->getOne("SELECT rank FROM dtb_member WHERE member_id = ?", array($id));
119
120        // ランクの最大値を取得する。
121        $maxno = $objQuery->getOne("SELECT max(rank) FROM dtb_member");
122        // ランクが最大値よりも小さい場合に実行する。
123        if($rank < $maxno) {
124            // ランクがひとつ上のIDを取得する。
125            $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
126            $up_id = $objQuery->getOne($sqlse, $rank + 1);
127
128            // Updateする値を作成する.
129            $sqlVal1 = array();
130            $sqlVal2 = array();
131            $sqlVal1['rank'] = $rank + 1;
132            $sqlVal2['rank'] = $rank;
133            $where = "member_id = ?";
134
135            // ランク入れ替えの実行
136            $objQuery->begin();
137            $objQuery->update("dtb_member", $sqlVal1, $where, array($id));
138            $objQuery->update("dtb_member", $sqlVal2, $where, array($up_id));
139            $objQuery->commit();
140        }
141    }
142
143    // ランキングを下げる。
144    function lfRunkDown($id) {
145        $objQuery =& SC_Query_Ex::getSingletonInstance();
146
147        // 自身のランクを取得する。
148        $rank = $objQuery->getOne("SELECT rank FROM dtb_member WHERE member_id = ?", array($id));
149        // ランクの最小値を取得する。
150        $minno = $objQuery->getOne("SELECT min(rank) FROM dtb_member");
151        // ランクが最大値よりも大きい場合に実行する。
152        if($rank > $minno) {
153            // ランクがひとつ下のIDを取得する。
154            $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
155            $down_id = $objQuery->getOne($sqlse, $rank - 1);
156
157            // Updateする値を作成する.
158            $sqlVal1 = array();
159            $sqlVal2 = array();
160            $sqlVal1['rank'] = $rank - 1;
161            $sqlVal2['rank'] = $rank;
162            $where = "member_id = ?";
163
164            // ランク入れ替えの実行
165            $objQuery->begin();
166            $objQuery->update("dtb_member", $sqlVal1, $where, array($id));
167            $objQuery->update("dtb_member", $sqlVal2, $where, array($down_id));
168            $objQuery->commit();
169        }
170    }
171}
172?>
Note: See TracBrowser for help on using the repository browser.