[16949] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[16949] | 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 |
---|
| 25 | require_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 | */ |
---|
[20652] | 41 | $GLOBALS['productsList'] = array( |
---|
[16949] | 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 | |
---|
| 59 | switch(getMode()) { |
---|
| 60 | |
---|
| 61 | case 'products_list': |
---|
| 62 | displayProductsList(); |
---|
| 63 | break; |
---|
| 64 | |
---|
| 65 | default: |
---|
| 66 | displayProductsList(); |
---|
| 67 | break; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | * モード取得. |
---|
| 72 | * |
---|
| 73 | * @return string |
---|
| 74 | */ |
---|
| 75 | function 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 | */ |
---|
| 88 | function displayProductsList() { |
---|
| 89 | $arrRet = array( |
---|
| 90 | 'status' => 'SUCCESS', |
---|
[20652] | 91 | 'data' => $GLOBALS['productsList'] |
---|
[16949] | 92 | ); |
---|
| 93 | |
---|
| 94 | // FIXME 一覧を取得するたびに更新されるのは微妙かも.. |
---|
[20652] | 95 | updateModuleTable($GLOBALS['productsList']); |
---|
[16949] | 96 | |
---|
[20434] | 97 | echo SC_Utils_Ex::jsonEncode($arrRet); |
---|
[16949] | 98 | } |
---|
| 99 | |
---|
| 100 | /** |
---|
| 101 | * dtb_moduleを更新する. |
---|
| 102 | * |
---|
| 103 | * @param array $arrProductsList |
---|
| 104 | */ |
---|
| 105 | function updateModuleTable($arrProductsList) { |
---|
| 106 | $table = 'dtb_module'; |
---|
| 107 | $where = 'module_id = ?'; |
---|
[20652] | 108 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[16949] | 109 | |
---|
[20652] | 110 | $objQuery->begin(); |
---|
[16949] | 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', |
---|
[17011] | 118 | 'del_flg' => '0', |
---|
[16949] | 119 | 'update_date' => 'NOW()', |
---|
| 120 | ); |
---|
| 121 | $objQuery->update($table, $arrUpdate, $where, array($arrProduct['product_id'])); |
---|
| 122 | } else { |
---|
| 123 | $arrInsert = array( |
---|
[16954] | 124 | 'module_id' => $arrProduct['product_id'], |
---|
[16949] | 125 | 'module_code' => $arrProduct['code'], |
---|
| 126 | 'module_name' => $arrProduct['name'], |
---|
| 127 | 'auto_update_flg' => '0', |
---|
[17011] | 128 | 'del_flg' => '0', |
---|
[16949] | 129 | 'update_date' => 'NOW()', |
---|
| 130 | 'create_date' => 'NOW()', |
---|
| 131 | ); |
---|
| 132 | $objQuery->insert($table, $arrInsert); |
---|
| 133 | } |
---|
| 134 | } |
---|
[20652] | 135 | $objQuery->commit(); |
---|
[16949] | 136 | } |
---|
| 137 | ?> |
---|