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

Revision 19907, 4.4 KB checked in by Seasoft, 13 years ago (diff)

#714(パス指定によるリダイレクトの記述を簡潔にする)

  • Property svn:eol-style set to LF
  • 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_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * システム管理 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id: LC_Page_Admin_System_Rank.php 16582 2007-11-28 15:02:29Z satou $
33 */
34class LC_Page_Admin_System_Rank extends LC_Page_Admin {
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        $objQuery = new SC_Query();
64
65        // ログインチェック
66        SC_Utils::sfIsSuccess(new SC_Session());
67
68        // ランキングの変更
69        if($_GET['move'] == 'up') {
70            // 正当な数値であった場合
71            if(SC_Utils::sfIsInt($_GET['id'])){
72                $this->lfRunkUp($objQuery, $_GET['id']);
73            // エラー処理
74            } else {
75                GC_Utils::gfPrintLog("error id=".$_GET['id']);
76            }
77        } else if($_GET['move'] == 'down') {
78            if(SC_Utils::sfIsInt($_GET['id'])){
79                $this->lfRunkDown($objQuery, $_GET['id']);
80            // エラー処理
81            } else {
82                GC_Utils::gfPrintLog("error id=".$_GET['id']);
83            }
84        }
85       
86        // ページの表示
87        SC_Response_Ex::sendRedirect(ADMIN_SYSTEM_URL_PATH);
88    }
89
90    /**
91     * デストラクタ.
92     *
93     * @return void
94     */
95    function destroy() {
96        parent::destroy();
97    }
98
99    // ランキングを上げる。
100    function lfRunkUp($objQuery, $id) {
101        // 自身のランクを取得する。
102        $rank = $objQuery->getOne("SELECT rank FROM dtb_member WHERE member_id = ".$id);
103        // ランクの最大値を取得する。
104        $maxno = $objQuery->getOne("SELECT max(rank) FROM dtb_member");
105        // ランクが最大値よりも小さい場合に実行する。
106        if($rank < $maxno) {
107            // ランクがひとつ上のIDを取得する。
108            $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
109            $up_id = $objQuery->getOne($sqlse, $rank + 1);
110            // ランク入れ替えの実行
111            $objQuery->begin();
112            $sqlup = "UPDATE dtb_member SET rank = ? WHERE member_id = ?";
113            $objQuery->query($sqlup, array($rank + 1, $id));
114            $objQuery->query($sqlup, array($rank, $up_id));
115            $objQuery->commit();
116        }
117    }
118
119    // ランキングを下げる。
120    function lfRunkDown($objQuery, $id) {
121        // 自身のランクを取得する。
122        $rank = $objQuery->getOne("SELECT rank FROM dtb_member WHERE member_id = ".$id);
123        // ランクの最小値を取得する。
124        $minno = $objQuery->getOne("SELECT min(rank) FROM dtb_member");
125        // ランクが最大値よりも大きい場合に実行する。
126        if($rank > $minno) {
127            // ランクがひとつ下のIDを取得する。
128            $sqlse = "SELECT member_id FROM dtb_member WHERE rank = ?";
129            $down_id = $objQuery->getOne($sqlse, $rank - 1);
130            // ランク入れ替えの実行
131            $objQuery->begin();
132            $sqlup = "UPDATE dtb_member SET rank = ? WHERE member_id = ?";
133            $objQuery->query($sqlup, array($rank - 1, $id));
134            $objQuery->query($sqlup, array($rank, $down_id));
135            $objQuery->query("COMMIT");
136        }
137    }
138}
139?>
Note: See TracBrowser for help on using the repository browser.