source: branches/version-2_13-dev/html/test/upgrade/index.php @ 23546

Revision 23546, 4.2 KB checked in by shutta, 12 years ago (diff)

#2580 Copyrightを更新
Copyrightを2014に更新

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