source: branches/version-2_12-dev/html/test/upgrade/index.php @ 21867

Revision 21867, 4.2 KB checked in by nakanishi, 12 years ago (diff)

#1831 Copyright Update

  • 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-2012 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 '../../require.php';
26
27/**
28 * モジュール一覧を出力するテストスクリプト
29 *
30 * 新しいモジュールを管理画面に表示する場合は、下の配列の値を書き換える.
31 * 追加する際には、新しく配列を追加すればよい.
32 *
33 * installed_flgとdownload_flgを1にすると「設定」ボタンが出るので、
34 * data/downloads/module/mdl_***にモジュールが設置してあれば、
35 * ダウンロードしなくてもすぐに使用可能な状態となります.
36 * (codeがモジュールファイル設定先になります)
37 *
38 * product_idは重複しない値を設定してください.
39 * 本番商品との重複を避けるためにも大きめの値を設定しておくとよいかもしれません.
40 */
41$GLOBALS['productsList'] = array(
42    // サンプルモジュール
43    array(
44        'name' => 'サンプルモジュール',
45        'code' => 'mdl_sample',
46        'main_list_comment' => 'モジュール開発テスト用です。',
47        'main_list_image' => 'no_image.jpg',
48        'version' => '開発版',
49        'last_update_date' => '9999/99/99 00:00:00',
50        'product_id' => '100',
51        'status' => '使用可能です',
52        'installed_flg' => '1',
53        'installed_version' => '開発版',
54        'download_flg' => '1',
55        'version_up_flg' => '0'
56    ),
57);
58
59switch (getMode()) {
60
61case 'products_list':
62    displayProductsList();
63    break;
64
65default:
66    displayProductsList();
67    break;
68}
69
70/**
71 * モード取得.
72 *
73 * @return string
74 */
75function getMode() {
76    if (isset($_GET['mode'])) {
77        return $_GET['mode'];
78    } elseif (isset($_POST['mode'])) {
79        return $_POST['mode'];
80    }
81    return '';
82}
83
84/**
85 * モジュールリスト一覧をjson出力する
86 *
87 */
88function displayProductsList() {
89    $arrRet = array(
90        'status' => 'SUCCESS',
91        'data'   => $GLOBALS['productsList']
92    );
93
94    // FIXME 一覧を取得するたびに更新されるのは微妙かも..
95    updateModuleTable($GLOBALS['productsList']);
96
97    echo SC_Utils_Ex::jsonEncode($arrRet);
98}
99
100/**
101 * dtb_moduleを更新する.
102 *
103 * @param array $arrProductsList
104 */
105function updateModuleTable($arrProductsList) {
106    $table = 'dtb_module';
107    $where = 'module_id = ?';
108    $objQuery =& SC_Query_Ex::getSingletonInstance();
109
110    $objQuery->begin();
111    foreach ($arrProductsList as $arrProduct) {
112        $count = $objQuery->count($table, $where, array($arrProduct['product_id']));
113        if ($count) {
114            $arrUpdate = array(
115                'module_code' => $arrProduct['code'],
116                'module_name' => $arrProduct['name'],
117                'auto_update_flg' => '0',
118                'del_flg' => '0',
119                'update_date' => 'CURRENT_TIMESTAMP',
120            );
121            $objQuery->update($table, $arrUpdate, $where, array($arrProduct['product_id']));
122        } else {
123            $arrInsert = array(
124                'module_id'   => $arrProduct['product_id'],
125                'module_code' => $arrProduct['code'],
126                'module_name' => $arrProduct['name'],
127                'auto_update_flg' => '0',
128                'del_flg' => '0',
129                'update_date' => 'CURRENT_TIMESTAMP',
130                'create_date' => 'CURRENT_TIMESTAMP',
131            );
132            $objQuery->insert($table, $arrInsert);
133        }
134    }
135    $objQuery->commit();
136}
Note: See TracBrowser for help on using the repository browser.