From a40da8f2dec43112dabb108f3c20f47f66a312e1 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Wed, 1 Nov 2017 10:32:32 +0900 Subject: [PATCH 01/49] =?UTF-8?q?modified=E3=82=92unset=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=83=95=E3=83=A9=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/CabinetFile.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index 269bc81..58d6424 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -271,7 +271,8 @@ public function afterSave($created, $options = array()) { public function save($data = null, $validate = true, $fieldList = array()) { // 保存前に modified フィールドをクリアする $this->set($data); - if (isset($this->data[$this->alias]['modified'])) { + $isNoUnsetModified = Hash::get($this->data, $this->alias . '._is_no_unset_modified'); + if (isset($this->data[$this->alias]['modified']) && !$isNoUnsetModified) { unset($this->data[$this->alias]['modified']); } return parent::save($this->data, $validate, $fieldList); From fc90f6a48f663acd6f0c0e01642e247c96d35eac Mon Sep 17 00:00:00 2001 From: kteraguchi Date: Fri, 26 Jan 2018 17:02:28 +0900 Subject: [PATCH 02/49] Change license value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Packagistで以下エラーが発生したため Importing branch master (dev-master) Skipped branch master, Invalid package information: License "NetCommons License" is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license. If the software is closed-source, you may use "proprietary" as license. --- composer.json | 86 +++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/composer.json b/composer.json index fe2a9b2..2072cd6 100644 --- a/composer.json +++ b/composer.json @@ -1,46 +1,46 @@ { - "name": "netcommons/cabinets", - "description": "Cabinets for NetCommons Plugin", - "homepage": "http://www.netcommons.org/", - "extra": { - "installer-paths": { - "app/Plugin/{$name}": [ - "type:cakephp-plugin" - ] - } - }, - "require": { - "cakedc/migrations": "~2.2", - "netcommons/authorization-keys": "@dev", - "netcommons/blocks": "@dev", - "netcommons/files": "@dev", - "netcommons/mails": "@dev", - "netcommons/net-commons": "@dev", - "netcommons/pages": "@dev", - "netcommons/plugin-manager": "@dev", - "netcommons/topics": "@dev", - "netcommons/workflow": "@dev" - }, - "license": "NetCommons License", - "authors": [ - { - "name": "Ryuji AMANO (RYUS INC.)", - "email": "ryuji@ryus.co.jp", - "homepage": "http://ryus.co.jp/", - "role": "Developer" + "name": "netcommons/cabinets", + "description": "Cabinets for NetCommons Plugin", + "homepage": "http://www.netcommons.org/", + "extra": { + "installer-paths": { + "app/Plugin/{$name}": [ + "type:cakephp-plugin" + ] + } + }, + "require": { + "cakedc/migrations": "~2.2", + "netcommons/authorization-keys": "@dev", + "netcommons/blocks": "@dev", + "netcommons/files": "@dev", + "netcommons/mails": "@dev", + "netcommons/net-commons": "@dev", + "netcommons/pages": "@dev", + "netcommons/plugin-manager": "@dev", + "netcommons/topics": "@dev", + "netcommons/workflow": "@dev" }, - { - "name": "NetCommons Community", - "homepage": "http://www.netcommons.org" + "license": "LicenseRef-NetCommons", + "license-ref-net-commons": "https://raw.githubusercontent.com/NetCommons3/NetCommons3/master/license.txt", + "authors": [ + { + "name": "Ryuji AMANO (RYUS INC.)", + "email": "ryuji@ryus.co.jp", + "homepage": "http://ryus.co.jp/", + "role": "Developer" + }, + { + "name": "NetCommons Community", + "homepage": "http://www.netcommons.org" + } + ], + "type": "cakephp-plugin", + "keywords": [ + "cakephp", + "cabinets" + ], + "config": { + "vendor-dir": "vendors" } - ], - "type": "cakephp-plugin", - "keywords": [ - "cakephp", - "cabinets" - ], - "config": { - "vendor-dir": "vendors" - } -} - +} \ No newline at end of file From 86fa910cf2a5cb6feac25942e9ac39202f3eda61 Mon Sep 17 00:00:00 2001 From: RyujiAMANO Date: Sun, 6 May 2018 08:54:22 +0900 Subject: [PATCH 03/49] =?UTF-8?q?#refs=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1228=20=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=A9=E3=81=8C=E8=A8=AD=E5=AE=9A=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?X-URL=E3=81=A7=E3=82=B3=E3=83=B3=E3=83=88=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=A9=E3=82=92=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/CabinetFile.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index bb8133d..256771a 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -59,6 +59,9 @@ class CabinetFile extends CabinetsAppModel { 'embedTags' => array( 'X-SUBJECT' => 'CabinetFile.filename', 'X-BODY' => 'CabinetFile.description', + 'X-URL' => array( + 'controller' => 'cabinet_files' + ) ), ), //多言語 From 254ae2c6fd1e227d5f85e92f6fcc80c148068fb5 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Sat, 8 Dec 2018 08:56:38 +0900 Subject: [PATCH 04/49] Update CabinetUnzipBehavior.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: zip解凍処理をアップロードファイル格納位置変更に対応 https://github.com/NetCommons3/NetCommons3/issues/1389 --- Model/Behavior/CabinetUnzipBehavior.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Behavior/CabinetUnzipBehavior.php b/Model/Behavior/CabinetUnzipBehavior.php index f20a367..e0234a3 100644 --- a/Model/Behavior/CabinetUnzipBehavior.php +++ b/Model/Behavior/CabinetUnzipBehavior.php @@ -25,7 +25,7 @@ public function unzip(Model $model, $cabinetFile) { try { // テンポラリフォルダにunzip - $zipPath = WWW_ROOT . $cabinetFile['UploadFile']['file']['path'] . + $zipPath = UPLOADS_ROOT . $cabinetFile['UploadFile']['file']['path'] . $cabinetFile['UploadFile']['file']['id'] . DS . $cabinetFile['UploadFile']['file']['real_file_name']; //debug($zipPath); From 6dfa8124b4d970bacc4b751adb5cc6d76b60fc0f Mon Sep 17 00:00:00 2001 From: RyujiAMANO Date: Wed, 19 Dec 2018 11:58:20 +0900 Subject: [PATCH 05/49] =?UTF-8?q?=E7=B6=99=E6=89=BF=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=83=97=E3=83=A9=E3=82=B0=E3=82=A4=E3=83=B3=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E6=99=82=E3=81=AB=E5=95=8F=E9=A1=8C=E3=81=AB=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E7=AE=87=E6=89=80=E3=82=92=E4=BF=AE=E6=AD=A3=20Controller?= =?UTF-8?q?=E3=81=A7render()=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=88=A9?= =?UTF-8?q?=E7=94=A8=E3=82=92=E3=81=A8=E3=82=8A=E3=82=84=E3=82=81=E3=80=82?= =?UTF-8?q?$this->render('xxx')=20->=20$this->view=20=3D=20'xxx'=20ctp?= =?UTF-8?q?=E3=81=A7element=E5=88=A9=E7=94=A8=E6=99=82=E3=81=AB=E3=83=97?= =?UTF-8?q?=E3=83=A9=E3=82=B0=E3=82=A4=E3=83=B3=E5=90=8D=E3=82=92=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E3=81=97=E3=81=AA=E3=81=84=E3=81=A7=E6=98=8E=E8=A8=98?= =?UTF-8?q?=20=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AE=E3=83=89?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=83=97=E3=83=80=E3=82=A6=E3=83=B3=E3=83=A1?= =?UTF-8?q?=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=92=E5=88=A5element=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 9 +- View/CabinetFiles/folder_detail.ctp | 2 +- View/CabinetFiles/index.ctp | 8 +- View/CabinetFiles/tree.ctp | 2 +- View/CabinetFiles/view.ctp | 2 +- View/CabinetFilesEdit/add.ctp | 2 +- View/CabinetFilesEdit/folder_form.ctp | 2 +- View/CabinetFilesEdit/form.ctp | 2 +- View/Elements/CabinetFiles/file_dropdown.ctp | 138 ++++++++++++++++++ View/Elements/CabinetFiles/file_row.ctp | 140 +------------------ View/Elements/CabinetFiles/folder_row.ctp | 5 +- 11 files changed, 159 insertions(+), 153 deletions(-) create mode 100644 View/Elements/CabinetFiles/file_dropdown.ctp diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index 1aa50d2..bf5b1d3 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -269,7 +269,8 @@ public function edit() { $this->set('cabinetFile', $cabinetFile); $this->set('isDeletable', $this->CabinetFile->canDeleteWorkflowContent($cabinetFile)); - $this->render('form'); + $this->view = 'form'; + //$this->render('form'); } /** @@ -337,7 +338,8 @@ public function add_folder() { ]; $this->set('folderPath', $folderPath); - $this->render('folder_form'); + $this->view = 'folder_form'; + //$this->render('folder_form'); } /** @@ -417,7 +419,8 @@ public function edit_folder() { $this->set('cabinetFile', $cabinetFile); $this->set('isDeletable', $this->CabinetFile->canDeleteWorkflowContent($cabinetFile)); - $this->render('folder_form'); + $this->view = 'folder_form'; + //$this->render('folder_form'); } /** diff --git a/View/CabinetFiles/folder_detail.ctp b/View/CabinetFiles/folder_detail.ctp index 2801f01..306eeca 100644 --- a/View/CabinetFiles/folder_detail.ctp +++ b/View/CabinetFiles/folder_detail.ctp @@ -68,7 +68,7 @@ echo $this->Html->script(
-
element('file_path'); ?>
+
element('Cabinets.file_path'); ?>
Number->toReadableSize( diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp index 1b30f05..2c4226e 100644 --- a/View/CabinetFiles/index.ctp +++ b/View/CabinetFiles/index.ctp @@ -26,7 +26,7 @@
- element('file_path', ['currentFile' => $currentFolder]); ?> + element('Cabinets.file_path', ['currentFile' => $currentFolder]); ?>
@@ -92,7 +92,7 @@ @@ -181,10 +181,10 @@ - element('CabinetFiles/folder_row', + element('Cabinets.CabinetFiles/folder_row', ['cabinetFile' => $cabinetFile]); ?> - element('CabinetFiles/file_row', + element('Cabinets.CabinetFiles/file_row', ['cabinetFile' => $cabinetFile]); ?> diff --git a/View/CabinetFiles/tree.ctp b/View/CabinetFiles/tree.ctp index 7da26f7..c44881a 100644 --- a/View/CabinetFiles/tree.ctp +++ b/View/CabinetFiles/tree.ctp @@ -1 +1 @@ -element('CabinetFiles/folder_tree'); \ No newline at end of file +element('Cabinets.CabinetFiles/folder_tree'); \ No newline at end of file diff --git a/View/CabinetFiles/view.ctp b/View/CabinetFiles/view.ctp index 8269e2d..8c1e382 100644 --- a/View/CabinetFiles/view.ctp +++ b/View/CabinetFiles/view.ctp @@ -70,7 +70,7 @@ echo $this->Html->script(
-
element('file_path'); ?>
+
element('Cabinets.file_path'); ?>
Number->toReadableSize( diff --git a/View/CabinetFilesEdit/add.ctp b/View/CabinetFilesEdit/add.ctp index 075e6a3..347ce66 100644 --- a/View/CabinetFilesEdit/add.ctp +++ b/View/CabinetFilesEdit/add.ctp @@ -19,7 +19,7 @@ echo $this->NetCommonsHtml->script( >
- element('file_path'); ?> + element('Cabinets.file_path'); ?>
diff --git a/View/CabinetFilesEdit/folder_form.ctp b/View/CabinetFilesEdit/folder_form.ctp index 88b97f5..e0bf966 100644 --- a/View/CabinetFilesEdit/folder_form.ctp +++ b/View/CabinetFilesEdit/folder_form.ctp @@ -61,7 +61,7 @@ echo $this->NetCommonsHtml->script( __d('cabinets', 'Path') ); ?>
- element('file_path'); ?> + element('Cabinets.file_path'); ?> diff --git a/View/CabinetFilesEdit/form.ctp b/View/CabinetFilesEdit/form.ctp index 0f0562f..64c7dc1 100644 --- a/View/CabinetFilesEdit/form.ctp +++ b/View/CabinetFilesEdit/form.ctp @@ -114,7 +114,7 @@ echo $this->NetCommonsHtml->script( __d('cabinets', 'Path') ); ?>
- element('file_path'); ?> + element('Cabinets.file_path'); ?> \ No newline at end of file diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp index 8ad05b7..2e60f12 100644 --- a/View/Elements/CabinetFiles/file_row.ctp +++ b/View/Elements/CabinetFiles/file_row.ctp @@ -70,143 +70,5 @@ ) ?> - - + element('Cabinets.CabinetFiles/file_dropdown', ['cabinetFile' => $cabinetFile]); ?> diff --git a/View/Elements/CabinetFiles/folder_row.ctp b/View/Elements/CabinetFiles/folder_row.ctp index 1b1e447..332d5aa 100644 --- a/View/Elements/CabinetFiles/folder_row.ctp +++ b/View/Elements/CabinetFiles/folder_row.ctp @@ -5,7 +5,10 @@ echo $icon; echo $this->NetCommonsHtml->link( h($cabinetFile['CabinetFile']['filename']), - ['key' => $cabinetFile['CabinetFile']['key']], + [ + 'action' => 'index', + 'key' => $cabinetFile['CabinetFile']['key'] + ], ['escape' => false] ); ?> From 6909ca00efe186afce364d9de0c883781fe1051b Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 23 Jan 2019 18:06:08 +0900 Subject: [PATCH 06/49] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E3=81=8C=E3=81=82=E3=82=8B=E3=81=9F=E3=82=81=E5=89=8A?= =?UTF-8?q?=E9=99=A4=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?438?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/CabinetFilesEdit/folder_form.ctp | 1 - View/CabinetFilesEdit/form.ctp | 3 --- 2 files changed, 4 deletions(-) diff --git a/View/CabinetFilesEdit/folder_form.ctp b/View/CabinetFilesEdit/folder_form.ctp index e0bf966..3efe7b2 100644 --- a/View/CabinetFilesEdit/folder_form.ctp +++ b/View/CabinetFilesEdit/folder_form.ctp @@ -127,7 +127,6 @@ echo $this->NetCommonsHtml->script( Button->delete('', __d('net_commons', 'Deleting the %s. Are you sure to proceed?', __d('cabinets', 'Folder')));?> - NetCommonsForm->end() ?>
diff --git a/View/CabinetFilesEdit/form.ctp b/View/CabinetFilesEdit/form.ctp index 64c7dc1..889d150 100644 --- a/View/CabinetFilesEdit/form.ctp +++ b/View/CabinetFilesEdit/form.ctp @@ -174,9 +174,6 @@ echo $this->NetCommonsHtml->script( Button->delete('', __d('net_commons', 'Deleting the %s. Are you sure to proceed?', __d('cabinets', 'File')));?> - - - NetCommonsForm->end() ?>
From d2de00c728e265bbfd809a92c32ad11ccb75a98e Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 4 Feb 2019 18:34:09 +0900 Subject: [PATCH 07/49] =?UTF-8?q?Exception=E3=81=8C=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E3=81=9F=E3=82=81=E3=80=81?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97?= =?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AB=E3=80=81message=E3=82=92=E3=83=95?= =?UTF-8?q?=E3=83=A9=E3=83=83=E3=82=B7=E3=83=A5=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webroot/js/cabinets.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js index 275fb0e..b65b6ce 100644 --- a/webroot/js/cabinets.js +++ b/webroot/js/cabinets.js @@ -81,7 +81,7 @@ NetCommonsApp.controller('CabinetFile.index', // フォルダを動かしたらリロード location.reload(); } else { - $scope.flashMessage(data.name, data.class, data.interval); + $scope.flashMessage(data.message, data.class, data.interval); // 違うフォルダへ移動なので、今のフォルダ内ファイル一覧から非表示にする $scope.moved[cabinetFileKey] = true; } @@ -89,14 +89,14 @@ NetCommonsApp.controller('CabinetFile.index', function(response) { var data = response.data; // エラー処理 - $scope.flashMessage(data.name, 'danger', 0); + $scope.flashMessage(data.message, 'danger', 0); }); }, function(response) { //Token error condition // エラー処理 var data = response.data; - $scope.flashMessage(data.name, 'danger', 0); + $scope.flashMessage(data.message, 'danger', 0); }); } }); @@ -128,20 +128,20 @@ NetCommonsApp.controller('CabinetFile.index', // エラーがなかったらリロードする location.reload(); } else { - $scope.flashMessage(data.name, data.class, 0); + $scope.flashMessage(data.message, data.class, 0); } }, function(response) { // エラー処理 var data = response.data; - $scope.flashMessage(data.name, data.class, 0); + $scope.flashMessage(data.message, data.class, 0); }); }, function(response) { //Token error condition // エラー処理 var data = response.data; - $scope.flashMessage(data.name, 'danger', 3); + $scope.flashMessage(data.message, 'danger', 3); }); }; }] @@ -290,7 +290,7 @@ NetCommonsApp.controller('CabinetFile.edit', $scope.folderPath = result; }) .error(function(data, status, headers, config) { - $scope.flashMessage(data.name, 'danger', 0); + $scope.flashMessage(data.message, 'danger', 0); }); }); }; From d3ddd853da08bf8934d7f5055893caf8d6a4eaac Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Thu, 9 May 2019 11:22:51 +0900 Subject: [PATCH 08/49] =?UTF-8?q?change:=20beforeValidate()=E3=82=92?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=99=E3=81=9F=E3=81=B3=E3=81=AB?= =?UTF-8?q?Hash::merge=E3=81=A7=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=83=AB=E3=83=BC=E3=83=AB=E3=81=8C?= =?UTF-8?q?=E5=A2=97=E3=81=88=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82ValidateM?= =?UTF-8?q?erge::merge=E3=81=B8=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= =?UTF-8?q?=E3=81=9F=20Refs=20https://github.com/NetCommons3/NetCommons3/i?= =?UTF-8?q?ssues/1486?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Cabinet.php | 2 +- Model/CabinetFile.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Cabinet.php b/Model/Cabinet.php index e2f819c..bde41d5 100644 --- a/Model/Cabinet.php +++ b/Model/Cabinet.php @@ -91,7 +91,7 @@ class Cabinet extends CabinetsAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge( + $this->validate = ValidateMerge::merge( $this->validate, array( //'block_id' => array( diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index 256771a..c0bdcf1 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -162,7 +162,7 @@ public function beforeValidate($options = array()) { ]; } - $this->validate = Hash::merge($this->validate, $validate); + $this->validate = ValidateMerge::merge($this->validate, $validate); return parent::beforeValidate($options); } From 173b836c30dd3d5a3513c9a7a8092fb064b8ec46 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Wed, 26 Jun 2019 07:44:15 +0900 Subject: [PATCH 09/49] =?UTF-8?q?fix:=20=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E8=BF=BD=E5=8A=A0=E6=99=82=E3=81=AB=E3=83=90=E3=83=AA?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=81=A8?= =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E5=B4=A9=E3=82=8C?= =?UTF-8?q?=E3=82=92=E8=B5=B7=E3=81=93=E3=81=97=E3=81=A6=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index bf5b1d3..c5a70b4 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -110,7 +110,6 @@ private function __getParentFolderUrl($parentId) { public function add() { //レイアウトの設定 $this->viewClass = 'View'; - $this->layout = 'NetCommons.modal'; $this->set('isEdit', false); @@ -152,6 +151,7 @@ public function add() { $this->NetCommons->handleValidationError($this->CabinetFile->validationErrors); } else { + $this->layout = 'NetCommons.modal'; $this->request->data = $cabinetFile; $this->request->data['CabinetFileTree']['parent_id'] = Hash::get( $this->request->named, From 3d684b35ad74afbed916604f90e60262d4dac412 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 4 Aug 2019 22:54:17 +0900 Subject: [PATCH 10/49] =?UTF-8?q?fix:=20test:=20UniteTest=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?468?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Case/Config/RoutesTest.php | 99 ------------------- .../EditTest.php | 2 +- .../CabinetBlocksController/EditTest.php | 4 +- Test/Case/Model/Cabinet/SaveCabinetTest.php | 4 +- 4 files changed, 5 insertions(+), 104 deletions(-) delete mode 100644 Test/Case/Config/RoutesTest.php diff --git a/Test/Case/Config/RoutesTest.php b/Test/Case/Config/RoutesTest.php deleted file mode 100644 index 8a1a621..0000000 --- a/Test/Case/Config/RoutesTest.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @author Shohei Nakajima - * @link http://www.netcommons.org NetCommons Project - * @license http://www.netcommons.org/license.txt NetCommons License - * @copyright Copyright 2014, NetCommons Project - */ - -App::uses('NetCommonsRoutesTestCase', 'NetCommons.TestSuite'); - -/** - * Config/routes.phpのテスト - * - * @author Shohei Nakajima - * @package NetCommons\Pages\Test\Case\Routing\Route\SlugRoute - */ -class RoutesTest extends NetCommonsRoutesTestCase { - -/** - * Fixtures - * - * @var array - */ - public $fixtures = array(); - -/** - * Plugin name - * - * @var string - */ - public $plugin = 'cabinets'; - -/** - * DataProvider - * - * ### 戻り値 - * - url URL - * - expected 期待値 - * - * @return array テストデータ - */ - public function dataProvider() { - return array( - array( - 'url' => '/cabinets/cabinet_files/index/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files', 'action' => 'index', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/cabinets/cabinet_files/folder_detail/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files', 'action' => 'folder_detail', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/cabinets/cabinet_files/view/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files', 'action' => 'view', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/cabinets/cabinet_files/download/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files', 'action' => 'download', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/cabinets/cabinet_files/download_folder/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files', 'action' => 'download_folder', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/cabinets/cabinet_files_edit/edit/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files_edit', 'action' => 'edit', - 'block_id' => '1', 'key' => 'content_key' - ) - ), - array( - 'url' => '/cabinets/cabinet_files_edit/edit_folder/1/content_key', - 'expected' => array( - 'plugin' => 'cabinets', 'controller' => 'cabinet_files_edit', 'action' => 'edit_folder', - 'block_id' => '1', 'key' => 'content_key' - ) - ), - ); - } - -} diff --git a/Test/Case/Controller/CabinetBlockRolePermissionsController/EditTest.php b/Test/Case/Controller/CabinetBlockRolePermissionsController/EditTest.php index be8e932..7081417 100644 --- a/Test/Case/Controller/CabinetBlockRolePermissionsController/EditTest.php +++ b/Test/Case/Controller/CabinetBlockRolePermissionsController/EditTest.php @@ -72,7 +72,7 @@ private function __data() { 'CabinetSetting' => array( 'id' => 2, 'cabinet_key' => 'cabinet_key_2', - 'use_workflow' => true, + 'use_workflow' => '1', //'use_comment_approval' => true, //'approval_type' => true, ) diff --git a/Test/Case/Controller/CabinetBlocksController/EditTest.php b/Test/Case/Controller/CabinetBlocksController/EditTest.php index 8e183eb..48005a4 100644 --- a/Test/Case/Controller/CabinetBlocksController/EditTest.php +++ b/Test/Case/Controller/CabinetBlocksController/EditTest.php @@ -65,8 +65,8 @@ private function __data($isEdit) { $frameId = '6'; //$frameKey = 'frame_3'; if ($isEdit) { - $blockId = '4'; - $blockKey = 'block_2'; + $blockId = '2'; + $blockKey = 'block_1'; $cabinetId = '3'; $cabinetKey = 'cabinet_key_2'; } else { diff --git a/Test/Case/Model/Cabinet/SaveCabinetTest.php b/Test/Case/Model/Cabinet/SaveCabinetTest.php index 3db129a..1b77b35 100644 --- a/Test/Case/Model/Cabinet/SaveCabinetTest.php +++ b/Test/Case/Model/Cabinet/SaveCabinetTest.php @@ -62,8 +62,8 @@ public function setUp() { Current::$current['Block']['id'] = '2'; Current::$current['Room']['id'] = '1'; - Current::$current['Permission']['content_editable']['value'] = true; - Current::$current['Permission']['content_publishable']['value'] = true; + Current::writePermission('1', 'content_editable', true); + Current::writePermission('1', 'content_publishable', true); } /** From ba8531a1b0de4b6e5871b766bc8684a2d903ce70 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 4 Aug 2019 23:24:02 +0900 Subject: [PATCH 11/49] =?UTF-8?q?add:=20test:=20travis=20php7.2=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?451?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index af3b7b8..99022da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,10 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 sudo: false +dist: trusty env: matrix: From 14eaa1fa192b70c953df9ab07521397810907fe2 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 7 Aug 2019 23:38:46 +0900 Subject: [PATCH 12/49] =?UTF-8?q?fix:=20test:=20travis=20php7.2=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?451?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4ef9896..76775c7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,5 @@ - From 0d88ba9c53d2342c5c6bd923b116fb673946e830 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 29 Oct 2019 18:04:30 +0900 Subject: [PATCH 13/49] =?UTF-8?q?fix:=20ForbiddenException=E3=81=A7?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E3=81=97=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=80=8C=E3=81=93=E3=81=AE=E3=82=A2=E3=82=AB=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=81=A7=E3=81=AF=E3=80=81=E3=83=BB=E3=83=BB=E3=83=BB?= =?UTF-8?q?=E3=80=8D=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=20https://github.com/researchmap/Rm?= =?UTF-8?q?NetCommons3/issues/1444?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index c5a70b4..14ebf8d 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -369,7 +369,7 @@ public function edit_folder() { throw new InternalErrorException(); } if ($this->CabinetFile->canEditWorkflowContent($cabinetFile) === false) { - throw new ForbiddenException(__d('net_commons', 'Permission denied')); + throw new ForbiddenException(); } $treeId = $cabinetFile['CabinetFileTree']['id']; @@ -519,7 +519,7 @@ public function move() { // フォルダの移動は公開権限が必要 if ($cabinetFile['CabinetFile']['is_folder']) { if (!Current::permission('content_publishable')) { - throw new ForbiddenException(__d('net_commons', 'Permission denied')); + throw new ForbiddenException(); } } From 50e588f00430d7ef8593a2c568976be5f5e63bb7 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Fri, 29 Nov 2019 17:19:25 +0900 Subject: [PATCH 14/49] =?UTF-8?q?change:=20add()=E3=81=A7viewClass?= =?UTF-8?q?=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B=E3=81=AE=E3=82=92?= =?UTF-8?q?=E3=82=84=E3=82=81=E3=81=A6=E3=80=81=E3=83=A2=E3=83=BC=E3=83=80?= =?UTF-8?q?=E3=83=AB=E3=82=92=E9=96=8B=E3=81=8F=E5=89=8D=E3=81=AB=E3=83=98?= =?UTF-8?q?=E3=83=83=E3=83=80=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=ABAccept=20text/html=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82=E3=83=90?= =?UTF-8?q?=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=A7=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E3=81=8C=E3=81=8F=E3=81=9A=E3=82=8C=E3=82=8B=E3=81=93?= =?UTF-8?q?=E3=81=A8=E3=81=8C=E3=81=82=E3=82=8B=E3=81=9F=E3=82=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 3 --- webroot/js/cabinets.js | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index 14ebf8d..b83ba88 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -108,9 +108,6 @@ private function __getParentFolderUrl($parentId) { * @return void */ public function add() { - //レイアウトの設定 - $this->viewClass = 'View'; - $this->set('isEdit', false); $cabinetFile = $this->CabinetFile->getNew(); diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js index b65b6ce..fe08b2e 100644 --- a/webroot/js/cabinets.js +++ b/webroot/js/cabinets.js @@ -163,7 +163,9 @@ NetCommonsApp.controller('CabinetFile.addFile', url = url + '/parent_id:' + $scope.parent_id; } url = url + '?frame_id=' + frameId; - var modal = NetCommonsModal.show($scope, 'CabinetFile.addFileModal', url); + + $http.defaults.headers.common['Accept'] = 'text/html'; + var modal = NetCommonsModal.show($scope, 'CabinetFile.addFileModal', url); }; } ] From a0f0fb7ac8587b6ee4a493162b3c0947d2aab779 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 30 Nov 2019 09:45:10 +0900 Subject: [PATCH 15/49] style: fix gjslint --- webroot/js/cabinets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js index fe08b2e..79cbea4 100644 --- a/webroot/js/cabinets.js +++ b/webroot/js/cabinets.js @@ -164,8 +164,8 @@ NetCommonsApp.controller('CabinetFile.addFile', } url = url + '?frame_id=' + frameId; - $http.defaults.headers.common['Accept'] = 'text/html'; - var modal = NetCommonsModal.show($scope, 'CabinetFile.addFileModal', url); + $http.defaults.headers.common['Accept'] = 'text/html'; + var modal = NetCommonsModal.show($scope, 'CabinetFile.addFileModal', url); }; } ] From 27823000e59b97d3014e3a4d0fce83b4dbb756ce Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Mar 2020 08:13:29 +0900 Subject: [PATCH 16/49] =?UTF-8?q?change:=20test:=20travis.yml=E3=81=8B?= =?UTF-8?q?=E3=82=89php5.4,5.5=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82php7.3,7?= =?UTF-8?q?.4=E3=82=92=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/?= =?UTF-8?q?NetCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99022da..8d273ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 + - 7.3 + - 7.4 sudo: false dist: trusty From 176978dbe87b97c0352ad7d1346f0da3f02dea00 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 11:45:31 +0900 Subject: [PATCH 17/49] =?UTF-8?q?fix:=20=E3=82=AD=E3=83=A3=E3=83=93?= =?UTF-8?q?=E3=83=8D=E3=83=83=E3=83=88=E3=81=AE=E5=9C=A7=E7=B8=AE=E3=83=80?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=82=92GET?= =?UTF-8?q?=E3=81=8B=E3=82=89POST=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82=20?= =?UTF-8?q?=E3=81=BE=E3=81=9F=E3=80=81=E5=9C=A7=E7=B8=AE=E3=83=80=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7=E3=83=91=E3=82=B9?= =?UTF-8?q?=E3=83=AF=E3=83=BC=E3=83=89=E4=BB=98=E3=81=8D=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=8C=E3=81=82=E3=82=8B=E3=81=A8=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=8C=E9=80=94?= =?UTF-8?q?=E4=B8=AD=E3=81=BE=E3=81=A7=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88?= =?UTF-8?q?UP=E3=81=95=E3=82=8C=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=80=81=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B=E5=89=8D=E3=81=AB=E3=83=81?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E6=94=B9=E4=BF=AE=20=E3=81=95=E3=82=89=E3=81=ABExcept?= =?UTF-8?q?ion=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97=E3=81=9F=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=80=81Exception=E3=81=AF500=E3=81=AA=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E3=80=81400=E3=81=AEBadRequest=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=80=82=20https://github.com/researchmap/RmNetCommon?= =?UTF-8?q?s3/issues/2144=20https://github.com/NetCommons3/NetCommons3/iss?= =?UTF-8?q?ues/1589?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesController.php | 93 ++++++++++++--- .../DownloadFolderTest.php | 10 +- View/CabinetFiles/folder_detail.ctp | 14 +-- View/CabinetFiles/index.ctp | 9 +- View/Elements/CabinetFiles/folder_row.ctp | 12 +- View/Helper/CabinetFileHelper.php | 93 +++++++++++++++ webroot/js/cabinets_zip_download.js | 112 ++++++++++++++++++ 7 files changed, 301 insertions(+), 42 deletions(-) create mode 100644 webroot/js/cabinets_zip_download.js diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php index ae9d80e..8f71218 100644 --- a/Controller/CabinetFilesController.php +++ b/Controller/CabinetFilesController.php @@ -100,7 +100,8 @@ public function beforeFilter() { 'view', 'folder_detail', 'download', - 'download_folder' + 'download_folder', + 'check_download_folder' ); parent::beforeFilter(); $this->_cabinet = $this->Cabinet->find('first', array( @@ -271,8 +272,6 @@ public function download() { //$this->set('cabinetFile', $cabinetFile); // ここまで元コンテンツを取得する処理 - //$this->AuthorizationKey->guard('popup', 'BlogEntry', $blogEntry); - $this->AuthorizationKey->guard('popup', 'CabinetFile', $cabinetFile); // ダウンロード実行 @@ -297,8 +296,11 @@ public function download() { * @return CakeResponse|string|void */ public function download_folder() { + if (! $this->request->is('post')) { + return $this->throwBadRequest(); + } // フォルダを取得 - $folderKey = Hash::get($this->request->params, 'key', null); + $folderKey = Hash::get($this->request->data, 'CabinetFile.key', null); $conditions = [ 'CabinetFile.key' => $folderKey, 'CabinetFile.cabinet_key' => $this->_cabinet['Cabinet']['key'] @@ -309,10 +311,12 @@ public function download_folder() { $tmpFolder = new TemporaryFolder(); try { $this->_prepareDownload($tmpFolder->path, $cabinetFolder); - } catch (Exception $e) { - $this->set('error', $e->getMessage()); - - return; + } catch (BadRequestException $e) { + //先にcheck_download_folderでチェックしているため、この処理は基本通らない + //もしタイムラグでダウンロードパスワードが設定されたら、フラッシュメッセージを表示して、 + //ブラウザをリフレッシュする + $this->NetCommons->setFlashNotification($e->getMessage(), [], $e->getCode()); + return $this->redirect($this->referer()); } $zipDownloader = $this->_getZipDownloader(); @@ -323,23 +327,37 @@ public function download_folder() { foreach ($files as $file) { $zipDownloader->addFile($file); } + return $zipDownloader->download($cabinetFolder['CabinetFile']['filename'] . '.zip'); + } - //$zipDownloader->addFolder($tmpFolder->path); +/** + * フォルダのZIPダウンロードができるか否かチェック + * + * @return void + */ + public function check_download_folder() { + if (! $this->request->is('post') || ! $this->request->is('ajax')) { + return $this->throwBadRequest(); + } + // フォルダを取得 + $folderKey = Hash::get($this->request->data, 'CabinetFile.key', null); + $conditions = [ + 'CabinetFile.key' => $folderKey, + 'CabinetFile.cabinet_key' => $this->_cabinet['Cabinet']['key'] + ]; + $conditions = $this->CabinetFile->getWorkflowConditions($conditions); + $cabinetFolder = $this->CabinetFile->find('first', ['conditions' => $conditions]); - //$this->response = $zipDownloader->download($cabinetFolder['CabinetFile']['filename'] . '.zip'); - //return $this->response; - return $zipDownloader->download($cabinetFolder['CabinetFile']['filename'] . '.zip'); + $this->_checkDownloadFolder($cabinetFolder); } /** - * フォルダのZIPダウンロード前処理 + * 圧縮ダウンロード用のCabinetFileデータを取得 * - * @param string $path ダウンロード処理用テンポラリフォルダのカレントパス * @param array $cabinetFolder CabinetFileデータ 処理するフォルダ - * @throws Exception - * @return void + * @return array */ - protected function _prepareDownload($path, $cabinetFolder) { + protected function _findCabinetFilesByFolderDownload($cabinetFolder) { // フォルダのファイル取得 $files = $this->CabinetFile->find( 'all', @@ -352,13 +370,27 @@ protected function _prepareDownload($path, $cabinetFolder) { ) ] ); + return $files; + } + +/** + * フォルダのZIPダウンロード前処理 + * + * @param string $path ダウンロード処理用テンポラリフォルダのカレントパス + * @param array $cabinetFolder CabinetFileデータ 処理するフォルダ + * @throws BadRequestException + * @return void + */ + protected function _prepareDownload($path, $cabinetFolder) { + // フォルダのファイル取得 + $files = $this->_findCabinetFilesByFolderDownload($cabinetFolder); foreach ($files as $file) { if ($file['CabinetFile']['is_folder']) { mkdir($path . DS . $file['CabinetFile']['filename']); $this->_prepareDownload($path . DS . $file['CabinetFile']['filename'], $file); } else { if (isset($file['AuthorizationKey'])) { - throw new Exception( + throw new BadRequestException( __d( 'cabinets', 'Folder that contains the files that are password is set can not be downloaded ZIP.' @@ -375,7 +407,32 @@ protected function _prepareDownload($path, $cabinetFolder) { // $file['UploadFile']['file']['id'] . // DS . $file['UploadFile']['file']['real_file_name']; copy($filePath, $path . DS . $file['CabinetFile']['filename']); + } + } + } +/** + * フォルダのZIPダウンロードができるか否かチェックする + * + * @param array $cabinetFolder CabinetFileデータ 処理するフォルダ + * @throws BadRequestException + * @return void + */ + protected function _checkDownloadFolder($cabinetFolder) { + // フォルダのファイル取得 + $files = $this->_findCabinetFilesByFolderDownload($cabinetFolder); + foreach ($files as $file) { + if ($file['CabinetFile']['is_folder']) { + $this->_checkDownloadFolder($file); + } else { + if (isset($file['AuthorizationKey'])) { + throw new BadRequestException( + __d( + 'cabinets', + 'Folder that contains the files that are password is set can not be downloaded ZIP.' + ) + ); + } } } } diff --git a/Test/Case/Controller/CabinetFilesController/DownloadFolderTest.php b/Test/Case/Controller/CabinetFilesController/DownloadFolderTest.php index ee2837d..fff8a3d 100644 --- a/Test/Case/Controller/CabinetFilesController/DownloadFolderTest.php +++ b/Test/Case/Controller/CabinetFilesController/DownloadFolderTest.php @@ -84,9 +84,9 @@ public function testDownloadFolder() { 'methods' => [ '_getZipDownloader' ], - //'components' => [ - // 'Download' - //] + 'components' => [ + 'Security', + ] ] ); $zipDownloaderMock = $this->getMock('ZipDownloader', ['download']); @@ -109,6 +109,8 @@ public function testDownloadFolder() { $urlOptions = $this->__data(); //テスト実施 - $this->_testGetAction($urlOptions, array('method' => 'assertEmpty'), null, 'result'); + $this->_testPostAction('post', ['CabinetFile' => ['key' => $urlOptions['key']]], + $urlOptions, null, 'result' + ); } } \ No newline at end of file diff --git a/View/CabinetFiles/folder_detail.ctp b/View/CabinetFiles/folder_detail.ctp index 306eeca..9e6348c 100644 --- a/View/CabinetFiles/folder_detail.ctp +++ b/View/CabinetFiles/folder_detail.ctp @@ -115,13 +115,13 @@ echo $this->Html->script( ) ?> - NetCommonsHtml->link( - __d('cabinets', 'Download'), - ['action' => 'download_folder', 'key' => $cabinetFile['CabinetFile']['key']], - ['class' => 'btn btn-primary'] - ) - ?> + CabinetFile->zipDownload( + $cabinetFile, + __d('cabinets', 'Download'), + ['class' => 'btn btn-primary'] + ); + ?>
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp index 2c4226e..130ecf1 100644 --- a/View/CabinetFiles/index.ctp +++ b/View/CabinetFiles/index.ctp @@ -152,17 +152,14 @@ 0) { - echo $this->NetCommonsHtml->link( + echo $this->CabinetFile->zipDownload( + $currentFolder, __d('cabinets', 'Zip download'), [ - 'action' => 'download_folder', - 'key' => $currentFolder['CabinetFile']['key'] - ], - ['class' => 'btn btn-xs btn-default', + 'class' => 'btn btn-xs btn-default', 'style' => 'margin-left:0px;' ] ); - } ?> diff --git a/View/Elements/CabinetFiles/folder_row.ctp b/View/Elements/CabinetFiles/folder_row.ctp index 332d5aa..6454805 100644 --- a/View/Elements/CabinetFiles/folder_row.ctp +++ b/View/Elements/CabinetFiles/folder_row.ctp @@ -118,13 +118,11 @@
  • NetCommonsHtml->link( - __d('cabinets', 'Zip download'), - [ - 'action' => 'download_folder', - 'key' => $cabinetFile['CabinetFile']['key'] - ] - ); + echo $this->CabinetFile->zipDownload( + $cabinetFile, + __d('cabinets', 'Zip download'), + [] + ); ?>
  • diff --git a/View/Helper/CabinetFileHelper.php b/View/Helper/CabinetFileHelper.php index b9d2a3a..f6cd631 100644 --- a/View/Helper/CabinetFileHelper.php +++ b/View/Helper/CabinetFileHelper.php @@ -9,9 +9,33 @@ /** * Class CabinetsFormatHelper + * + * @property NetCommonsHtmlHelper $NetCommonsHtml + * @property TokenHelper $Token */ class CabinetFileHelper extends AppHelper { +/** + * @var array helpers + */ + public $helpers = [ + 'NetCommons.NetCommonsHtml', + 'NetCommons.Token', + ]; + +/** + * Before render callback. beforeRender is called before the view file is rendered. + * + * Overridden in subclasses. + * + * @param string $viewFile The view file that is going to be rendered + * @return void + */ + public function beforeRender($viewFile) { + $this->NetCommonsHtml->script('/cabinets/js/cabinets_zip_download.js'); + parent::beforeRender($viewFile); + } + /** * 解凍してよいか * @@ -22,4 +46,73 @@ public function isAllowUnzip($cabinetFile) { $CabinetFile = ClassRegistry::init('Cabinets.CabinetFile'); return $CabinetFile->isAllowUnzip($cabinetFile); } + +/** + * 圧縮ダウンロードリンク + * + * @param array $cabinetFile CabinetFile data + * @param string $label ボタン(リンク)のラベル + * @param string $options ボタン(リンク)のオプション + * @return string + */ + public function zipDownload($cabinetFile, $label, $options) { + $html = ''; + + //アクションURL生成 + $action = [ + 'action' => 'download_folder', + 'key' => $cabinetFile['CabinetFile']['key'] + ]; + $downloadUrl = $this->NetCommonsHtml->url($action); + + $action = [ + 'action' => 'check_download_folder', + 'key' => $cabinetFile['CabinetFile']['key'] + ]; + $checkUrl = $this->NetCommonsHtml->url($action); + + //POSTデータ生成 + $requestData = [ + 'CabinetFile' => [ + 'key' => $cabinetFile['CabinetFile']['key'] + ], + ]; + $currentData = $this->_View->request->data; + $tokenFields = Hash::flatten($requestData); + $hiddenFields = array_keys($tokenFields); + // * チェック用のToken作成 + $this->_View->request->data = $requestData; + $checkToken = $this->Token->getToken( + 'CabinetFile', $checkUrl, $tokenFields, $hiddenFields + ); + $checkToken['_Token']['key'] = ''; + // * ダウンロード用のToken作成 + $this->_View->request->data = $requestData; + $downloadToken = $this->Token->getToken( + 'CabinetFile', $downloadUrl, $tokenFields, $hiddenFields + ); + $downloadToken['_Token']['key'] = ''; + // * $thisi->request->dataを元に戻す + $this->_View->request->data = $currentData; + + $requestData['Check'] = [ + 'action' => $checkUrl, + 'token' => $checkToken['_Token'], + ]; + + $requestData['Download'] = [ + 'action' => $downloadUrl, + 'token' => $downloadToken['_Token'], + ]; + //アンカータグ生成 + $options['ng-controller'] = 'CabinetFiles.zipDownload'; + $options['ng-init'] = "initialize(" . json_encode($requestData) . ")"; + $options['ng-click'] = 'download($event)'; + $options['href'] = ''; + $attributes = $this->_parseAttributes($options); + + $html .= "" . h($label) . ""; + return $html; + } + } diff --git a/webroot/js/cabinets_zip_download.js b/webroot/js/cabinets_zip_download.js new file mode 100644 index 0000000..5656039 --- /dev/null +++ b/webroot/js/cabinets_zip_download.js @@ -0,0 +1,112 @@ +/** + * Cabinets Javascript + */ + + +/** + * 圧縮ダウンロード + */ +NetCommonsApp.controller('CabinetFiles.zipDownload', + ['$scope', '$http', 'NC3_URL', 'ajaxSendPost', + function($scope, $http, NC3_URL, ajaxSendPost) { + + /** + * ファイル(フォルダ)キー + * + * @type {object} + */ + $scope.postData = {}; + + /** + * イニシャライズ処理 + * + * @return {void} + */ + $scope.initialize = function(postData) { + $scope.postData = postData; + }; + + /** + * ダウンロード処理 + * + * @return {void} + */ + $scope.download = function($event) { + if ($scope.$parent.sending) { + event.preventDefault(); + return; + } + $scope.$parent.sending = true; + $event.preventDefault(); + + var postData = { + CabinetFile: $scope.postData['CabinetFile'], + _Token: $scope.postData['Check']['token'] + }; + ajaxSendPost('POST', $scope.postData['Check']['action'], postData) + .success(function(response) { + $scope.__submitDownload(); + }) + .error(function(response) { + //エラー処理 + var data = response.data; + $scope.flashMessage(data.message, 'danger', data.interval); + $scope.$parent.sending = false; + }); + }; + + /** + * ダウンロードするためのformエレメントを作成する + * + * @return {void} + */ + $scope.__submitDownload = function() { + $http.get(NC3_URL + '/net_commons/net_commons/csrfToken.json') + .then(function(response) { + var token = response.data; + $scope.postData['Download']['token']['key'] = token.data._Token.key; + var formId = 'CabinetFileZipDownload' + Math.random().toString(36).slice(2); + var formElement = $scope.__createFormElement(formId); + formElement.appendTo(document.body).submit(); + $('#' + formId).remove(); + $scope.$parent.sending = false; + }, + function(response) { + $scope.$parent.sending = false; + }); + }; + + /** + * ダウンロードするためのformエレメントを作成する + * + * @return {void} + */ + $scope.__createFormElement = function(formId) { + var formElement = $('
    ', { + id: formId, + target: '_blank', + action: $scope.postData['Download']['action'], + method: 'post' + }); + + angular.forEach($scope.postData['Download']['token'], function(value, key) { + var inputElement = $('', { + type: 'hidden', + name: 'data[_Token][' + key + ']', + value: value + }); + formElement.append(inputElement); + }); + angular.forEach($scope.postData['CabinetFile'], function(value, key) { + var inputElement = $('', { + type: 'hidden', + name: 'data[CabinetFile][' + key + ']', + value: value + }); + formElement.append(inputElement); + }); + + return formElement; + }; + + }]); From 2577cf8d9f91faee62fb0a414ac6bc345c3e9319 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 11:50:32 +0900 Subject: [PATCH 18/49] =?UTF-8?q?change:=20test:=20Travis=E3=81=8B?= =?UTF-8?q?=E3=82=89PHP5.6=E3=82=92=E5=89=8A=E9=99=A4=E3=80=81PHP7.4?= =?UTF-8?q?=E3=81=A7ZipArchive=E3=83=BBimagecreatefromgif=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 +++- phpunit.xml.dist | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d273ed..27cd995 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: php +before_install: + - sudo apt-get -y install php-pecl-zip php-gd + php: - - 5.6 - 7.0 - 7.1 - 7.2 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 76775c7..64df10e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,8 @@ + + + app/Plugin/Cabinets From 0b3e0ac56d2fafdefa118587421129e9e71225f5 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 12:06:03 +0900 Subject: [PATCH 19/49] =?UTF-8?q?change:=20test:=20before=5Finstall?= =?UTF-8?q?=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 27cd995..dc1faaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: php -before_install: - - sudo apt-get -y install php-pecl-zip php-gd - php: - 7.0 - 7.1 From 80074a534c6a267f493193410b96df96c2da78eb Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 12:37:24 +0900 Subject: [PATCH 20/49] =?UTF-8?q?change:=20test:=20PHP7.4=E3=81=A7ZipArchi?= =?UTF-8?q?ve=E3=83=BBimagecreatefromgif=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index dc1faaa..0e5f429 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,12 @@ env: - GIT_AUTHOR_NAME=RyujiAMANO - GIT_AUTHOR_EMAIL=ryuji@ryus.co.jp +matrix: + allow_failures: + # PHP 7.4 testing is allowed to fail because the GD extension and ZipArchive is not packaged on Travis CI yet. + # See https://travis-ci.community/t/some-extensions-are-missing-in-php-7-4-0-zip-gmp-sodium/6320/9 + - php: 7.4 + before_script: - export NETCOMMONS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/NetCommons3 - git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR From 46eb149cf56b48b72ac7c5d0b8df6f09f51725b2 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 31 Jul 2020 23:10:09 +0900 Subject: [PATCH 21/49] =?UTF-8?q?change:=20test:=20Travis=E3=81=8B?= =?UTF-8?q?=E3=82=89PHP5.6=E3=82=92=E5=89=8A=E9=99=A4,php72=E4=BB=A5?= =?UTF-8?q?=E9=99=8D=E3=81=A7UnitTest=E3=81=A7Warning=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpunit.xml.dist | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 64df10e..ddb3b95 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,11 @@ - - - + + + + + + app/Plugin/Cabinets From 41b7e795d041227246f19cf8e762ea46e356fc1f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 26 Aug 2020 20:16:45 +0900 Subject: [PATCH 22/49] change: Version number to 3.3.2 --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..4772543 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +3.3.2 From 957d249255df4d19f8131199210ed9a12888d038 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 29 Aug 2020 22:20:52 +0900 Subject: [PATCH 23/49] =?UTF-8?q?fix:=20=E3=82=B5=E3=83=96=E3=83=87?= =?UTF-8?q?=E3=82=A3=E3=83=AC=E3=82=AF=E3=83=88=E3=83=AA=E3=81=A7=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=81=99=E3=82=8B=E3=81=A8=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=81=AA=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=20https://github.com/researchmap/RmNetCommons3/issues/2144?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/Helper/CabinetFileHelper.php | 6 ++++-- webroot/js/cabinets_zip_download.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/View/Helper/CabinetFileHelper.php b/View/Helper/CabinetFileHelper.php index f6cd631..eaf8d42 100644 --- a/View/Helper/CabinetFileHelper.php +++ b/View/Helper/CabinetFileHelper.php @@ -58,18 +58,20 @@ public function isAllowUnzip($cabinetFile) { public function zipDownload($cabinetFile, $label, $options) { $html = ''; + $rootUrl = substr(Router::url('/'), 0, -1); + //アクションURL生成 $action = [ 'action' => 'download_folder', 'key' => $cabinetFile['CabinetFile']['key'] ]; - $downloadUrl = $this->NetCommonsHtml->url($action); + $downloadUrl = substr($this->NetCommonsHtml->url($action), strlen($rootUrl)); $action = [ 'action' => 'check_download_folder', 'key' => $cabinetFile['CabinetFile']['key'] ]; - $checkUrl = $this->NetCommonsHtml->url($action); + $checkUrl = substr($this->NetCommonsHtml->url($action), strlen($rootUrl)); //POSTデータ生成 $requestData = [ diff --git a/webroot/js/cabinets_zip_download.js b/webroot/js/cabinets_zip_download.js index 5656039..a7f2885 100644 --- a/webroot/js/cabinets_zip_download.js +++ b/webroot/js/cabinets_zip_download.js @@ -85,7 +85,7 @@ NetCommonsApp.controller('CabinetFiles.zipDownload', var formElement = $('', { id: formId, target: '_blank', - action: $scope.postData['Download']['action'], + action: NC3_URL + $scope.postData['Download']['action'], method: 'post' }); From 5eddb3318cf851997b8c197f3f914036978e5407 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 13 Dec 2020 16:50:42 +0900 Subject: [PATCH 24/49] =?UTF-8?q?fix:=20test:=20TravisCI=E3=81=AEphp7.3?= =?UTF-8?q?=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E5=87=BA=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1618?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0e5f429..4de7e4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.0 - 7.1 - 7.2 - - 7.3 + - 7.3.24 - 7.4 sudo: false From 04d01c77f06907a5b1815c01f3fcf8c1f2004685 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Wed, 23 Dec 2020 17:08:47 +0900 Subject: [PATCH 25/49] =?UTF-8?q?change:=20=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=80=E7=94=A8=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE?= =?UTF-8?q?=20\CabinetFolderBehavior::hasChildren()=E3=81=AE=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E6=99=82=E3=81=AFAttachmentBehavior,AuthorizationKeyB?= =?UTF-8?q?ehavior=E3=81=AF=E4=B8=8D=E8=A6=81=EF=BC=88=E3=81=93=E3=81=AE2?= =?UTF-8?q?=E3=81=A4=E3=81=AF=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=97=E3=81=A6=E5=88=A9=E7=94=A8=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=EF=BC=89=E3=81=AA=E3=81=AE=E3=81=A7find?= =?UTF-8?q?=E5=89=8D=E3=81=ABdisable=E3=81=97=E3=81=A6find=E5=BE=8C?= =?UTF-8?q?=E3=81=ABenable=E3=81=AB=E6=88=BB=E3=81=99=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F=20\CabinetFolderB?= =?UTF-8?q?ehavior::getTotalSizeByFolder()=E3=81=A7=E3=81=AFAuthorizationK?= =?UTF-8?q?eyBehavior=E3=81=AE=E3=81=BF=E4=B8=8D=E8=A6=81=E3=81=A8?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=AE=E3=81=A7=E3=81=93=E3=81=A1=E3=82=89?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E4=B8=80=E6=99=82=E7=84=A1=E5=8A=B9=E5=8C=96?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= =?UTF-8?q?=20Refs=20https://github.com/researchmap/RmNetCommons3/issues/2?= =?UTF-8?q?094?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/CabinetFolderBehavior.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Model/Behavior/CabinetFolderBehavior.php b/Model/Behavior/CabinetFolderBehavior.php index 46d6f89..d178d59 100644 --- a/Model/Behavior/CabinetFolderBehavior.php +++ b/Model/Behavior/CabinetFolderBehavior.php @@ -41,7 +41,14 @@ public function hasChildren(Model $model, $cabinetFile) { 'CabinetFileTree.parent_id' => $cabinetFile['CabinetFileTree']['id'], ]; $conditions = $model->getWorkflowConditions($conditions); + + $model->Behaviors->disable('AuthorizationKey'); + $model->Behaviors->disable('Attachment'); + $count = $model->find('count', ['conditions' => $conditions]); + + $model->Behaviors->enable('AuthorizationKey'); + $model->Behaviors->enable('Attachment'); return ($count > 0); } @@ -183,7 +190,11 @@ public function getTotalSizeByFolder(Model $model, $folder) { 'CabinetFileTree.rght <' => $folder['CabinetFileTree']['rght'], 'CabinetFile.is_folder' => false, ]; + $model->Behaviors->disable('AuthorizationKey'); + $files = $model->find('all', ['conditions' => $conditions]); + + $model->Behaviors->enable('AuthorizationKey'); $total = 0; foreach ($files as $file) { $total += Hash::get($file, 'UploadFile.file.size', 0); From d81ce591ca4f65ec0ff88c5ecf1769547bd9138f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 13:52:30 +0900 Subject: [PATCH 26/49] =?UTF-8?q?add:=20release=E3=82=BF=E3=82=B0=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=81=AEgithub=20action=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/NetCommons3/NetCommons3/issues/1619 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a3225bc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - '3*' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: | + NetCommons ${{ github.ref }} released. + draft: false + prerelease: false From f08da23f0bf18e1015a38dd68fb975ee664bb7dd Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 13:52:40 +0900 Subject: [PATCH 27/49] change: Version number to 3.3.3 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 4772543..619b537 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.2 +3.3.3 From 0bcf2b3812a7abe34c5a89c57fba4c61099f2d84 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Mon, 14 Jun 2021 16:24:22 +0900 Subject: [PATCH 28/49] =?UTF-8?q?change:=20=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=82=92FIND=E3=81=99=E3=82=8B=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AFAttachment=E3=83=93=E3=83=98=E3=82=A4=E3=83=93?= =?UTF-8?q?=E3=82=A2=E3=82=82AuthorizationKey=E3=83=93=E3=83=98=E3=82=A4?= =?UTF-8?q?=E3=83=93=E3=82=A2=E3=82=82=E4=B8=8D=E8=A6=81=E3=81=AA=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E9=80=9F=E5=BA=A6=E3=82=AB=E3=82=A4=E3=82=BC=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E3=81=ABFIND=E5=89=8D=E3=81=AB?= =?UTF-8?q?=E3=83=93=E3=83=98=E3=82=A4=E3=83=93=E3=82=A2=E3=82=92disable?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesController.php | 6 ++++++ Model/Behavior/CabinetFolderBehavior.php | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php index 8f71218..352d9e5 100644 --- a/Controller/CabinetFilesController.php +++ b/Controller/CabinetFilesController.php @@ -449,6 +449,10 @@ protected function _getCurrentFolder($folderKey) { $currentFolder = $this->CabinetFile->getRootFolder($this->_cabinet); return $currentFolder; } else { + // Hack: findFolderとかメソッドはやしたほうがいいかな。CabinetFolderってモデルつくるのがいいか? + $this->CabinetFile->Behaviors->disable('AuthorizationKey'); + $this->CabinetFile->Behaviors->disable('Attachment'); + $currentFolder = $this->CabinetFile->find( 'first', [ @@ -459,6 +463,8 @@ protected function _getCurrentFolder($folderKey) { ] ] ); + $this->CabinetFile->Behaviors->enable('AuthorizationKey'); + $this->CabinetFile->Behaviors->enable('Attachment'); return $currentFolder; } } diff --git a/Model/Behavior/CabinetFolderBehavior.php b/Model/Behavior/CabinetFolderBehavior.php index d178d59..86e03a5 100644 --- a/Model/Behavior/CabinetFolderBehavior.php +++ b/Model/Behavior/CabinetFolderBehavior.php @@ -60,7 +60,10 @@ public function hasChildren(Model $model, $cabinetFile) { * @return array|null */ public function getRootFolder(Model $model, $cabinet) { - return $model->find('first', [ + $model->Behaviors->disable('AuthorizationKey'); + $model->Behaviors->disable('Attachment'); + + $rootFolder = $model->find('first', [ 'conditions' => $this->_getRootFolderConditions( $cabinet, array( @@ -71,6 +74,11 @@ public function getRootFolder(Model $model, $cabinet) { ) ) ]); + + $model->Behaviors->enable('AuthorizationKey'); + $model->Behaviors->enable('Attachment'); + + return $rootFolder; } /** From 6e04975b3fb0e83999b76d3448d8329ab161d102 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Mon, 21 Jun 2021 20:09:57 +0900 Subject: [PATCH 29/49] =?UTF-8?q?change:=20=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=AE=E9=9B=86=E8=A8=88?= =?UTF-8?q?=E3=81=AE=E3=81=9F=E3=82=81=E3=81=ABafterFind=E3=81=A7=E5=8F=96?= =?UTF-8?q?=E5=BE=97=E3=81=95=E3=82=8C=E3=82=8BUploadFile=E3=82=92?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=9B=E3=81=9A=E3=81=AB=E8=87=AA=E5=89=8D?= =?UTF-8?q?=E3=81=A7UploadFile=E3=82=92Find=E3=81=97=E3=81=A6=E9=9B=86?= =?UTF-8?q?=E8=A8=88=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/CabinetFolderBehavior.php | 69 +++++++++++--- .../UpdateCabinetTotalSizeTest.php | 91 +++++++++++++++++++ 2 files changed, 145 insertions(+), 15 deletions(-) create mode 100644 Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php diff --git a/Model/Behavior/CabinetFolderBehavior.php b/Model/Behavior/CabinetFolderBehavior.php index 86e03a5..751a2f7 100644 --- a/Model/Behavior/CabinetFolderBehavior.php +++ b/Model/Behavior/CabinetFolderBehavior.php @@ -188,9 +188,7 @@ public function rootFolderExist(Model $model, $cabinet) { * @return int 合計サイズ */ public function getTotalSizeByFolder(Model $model, $folder) { - // ベタパターン - // 配下全てのファイルを取得する - //$this->CabinetFileTree->setup(]); + // 配下全てのファイル key を取得する $cabinetKey = $folder['Cabinet']['key']; $conditions = [ 'CabinetFileTree.cabinet_key' => $cabinetKey, @@ -200,15 +198,44 @@ public function getTotalSizeByFolder(Model $model, $folder) { ]; $model->Behaviors->disable('AuthorizationKey'); - $files = $model->find('all', ['conditions' => $conditions]); + // HACK: ファイルサイズをCabinetsに持つようにすればFilesプラグインのテーブルを参照する必要はなくなるが、 + // テーブル変更すると移行ツールも改修する必要があるので、 + // ひとまずトータル取得ロジックのカイゼンだけにとどめた。 + $files = $model->find('all', [ + 'conditions' => $conditions, + //'fields' => ['CabinetFile.key'] + 'fields' => ['CabinetFile.id'] + ]); + $contentIds = array_column(array_column($files, 'CabinetFile'), 'id'); - $model->Behaviors->enable('AuthorizationKey'); - $total = 0; - foreach ($files as $file) { - $total += Hash::get($file, 'UploadFile.file.size', 0); - } + /** @var UploadFilesContent $uploadFilesContent */ + $uploadFilesContent = ClassRegistry::init('Files.UploadFilesContent'); + $conditions = [ + 'UploadFilesContent.plugin_key' => 'cabinets', + 'UploadFilesContent.content_id' => $contentIds, + ]; + $links = $uploadFilesContent->find('all', [ + 'conditions' => $conditions, + 'recursive' => -1, + 'fields' => ['UploadFilesContent.upload_file_id'] + ]); + $uploadFileIds = array_column(array_column($links, 'UploadFilesContent'), 'upload_file_id'); + + /** @var UploadFile $uploadFile */ + $uploadFile = ClassRegistry::init('Files.UploadFile'); + $conditions = [ + 'UploadFile.id' => $uploadFileIds + ]; + $uploadFile->virtualFields['cabinet_folder_size'] = 'sum(size)'; + $result = $uploadFile->find('first', [ + 'conditions' => $conditions, + 'fields' => ['cabinet_folder_size' ], + //'recursive' => 0 + ]); + unset($uploadFile->virtualFields['cabinet_folder_size']); + + $total = (int)$result['UploadFile']['cabinet_folder_size']; return $total; - // sumパターンはUploadFileの構造をしらないと厳しい… がんばってsumするより合計サイズをキャッシュした方がいいかも } /** @@ -243,12 +270,8 @@ public function updateCabinetTotalSize(Model $model, $cabinetKey) { 'recursive' => -1, 'conditions' => array('key' => $cabinetKey), )); + $totalSize = $this->calcCabinetTotalSize($model, $cabinet); - // トータルサイズ取得 - $rootFolder = $model->getRootFolder($cabinet); - $totalSize = $model->getTotalSizeByFolder( - $rootFolder - ); // キャビネット更新 $update = array( 'Cabinet.total_size' => $totalSize @@ -264,4 +287,20 @@ public function updateCabinetTotalSize(Model $model, $cabinetKey) { //$model->Cabinet->id = $cabinetId; //$model->Cabinet->saveField('total_size', $totalSize, ['callbacks' => false]); } + + /** + * calcCabinetTotalSize + * + * @param Model $model + * @param $cabinet + * @return mixed + */ + public function calcCabinetTotalSize(Model $model, $cabinet) { + // トータルサイズ取得 + $rootFolder = $model->getRootFolder($cabinet); + $totalSize = $model->getTotalSizeByFolder( + $rootFolder + ); + return $totalSize; + } } \ No newline at end of file diff --git a/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php b/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php new file mode 100644 index 0000000..2897d14 --- /dev/null +++ b/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php @@ -0,0 +1,91 @@ + [ + 'id' => 2, + 'block_id' => '2', + 'name' => 'Cabinet1', + 'key' => 'content_block_1', + 'total_size' => '1' + ] + ]; + /** @see \CabinetFolderBehavior::calcCabinetTotalSize */ + $totalSize = $cabinetFile->calcCabinetTotalSize($cabinet); + + $expectedTotal = 13638761; + self::assertSame($expectedTotal, $totalSize); + } + +/** + * testUpdateCabinetTotalSize + * + * @return void + */ + public function testUpdateCabinetTotalSize() { + $cabinetFile = \ClassRegistry::init('Cabinets.CabinetFile'); + /** @see \CabinetFolderBehavior::updateCabinetTotalSize() */ + $cabinetFile->updateCabinetTotalSize('content_block_1'); + + $cabinetModel = ClassRegistry::init('Cabinets.Cabinet'); + $cabinet = $cabinetModel->find('first', [ + 'Cabinet.id' => '2' + ]); + $totalSize = $cabinet['Cabinet']['total_size']; + + // total_sizeはmysqlのfloatで保存されてるので、頭5桁だけで比較する + $expectedTotal = '13638761'; + $expectedFloatLeft5 = $this->__truncate5($expectedTotal); + + $floatLeft5TotalSize = $this->__truncate5($totalSize); + self::assertSame($expectedFloatLeft5, $floatLeft5TotalSize); + } + +/** + * 上位5桁だけでのこし、端数を切り捨てる + * + * @param float $floatSize + * @return float + */ + private function __truncate5(float $floatSize) { + $roundNumber = 5 - strlen($floatSize); + return round($floatSize, $roundNumber, PHP_ROUND_HALF_DOWN); + } + +} \ No newline at end of file From 6b0d6863bcbac967c64afd0ca6b2cfdf1fea7c55 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 22 Jun 2021 08:56:06 +0900 Subject: [PATCH 30/49] =?UTF-8?q?change:=20=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=80=E3=82=B5=E3=82=A4=E3=82=BA=E9=9B=86=E8=A8=88=E6=99=82?= =?UTF-8?q?=E3=81=AB=E8=A9=B2=E5=BD=93=E3=83=87=E3=83=BC=E3=82=BF=E3=81=AA?= =?UTF-8?q?=E3=81=91=E3=82=8C=E3=81=B0=E6=97=A9=E6=9C=9F=E3=83=AA=E3=82=BF?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/CabinetFolderBehavior.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Model/Behavior/CabinetFolderBehavior.php b/Model/Behavior/CabinetFolderBehavior.php index 751a2f7..257c42d 100644 --- a/Model/Behavior/CabinetFolderBehavior.php +++ b/Model/Behavior/CabinetFolderBehavior.php @@ -207,6 +207,9 @@ public function getTotalSizeByFolder(Model $model, $folder) { 'fields' => ['CabinetFile.id'] ]); $contentIds = array_column(array_column($files, 'CabinetFile'), 'id'); + if (empty($contentIds)) { + return 0; + } /** @var UploadFilesContent $uploadFilesContent */ $uploadFilesContent = ClassRegistry::init('Files.UploadFilesContent'); @@ -220,6 +223,9 @@ public function getTotalSizeByFolder(Model $model, $folder) { 'fields' => ['UploadFilesContent.upload_file_id'] ]); $uploadFileIds = array_column(array_column($links, 'UploadFilesContent'), 'upload_file_id'); + if (empty($uploadFileIds)) { + return 0; + } /** @var UploadFile $uploadFile */ $uploadFile = ClassRegistry::init('Files.UploadFile'); From b68743beea158f91a3098f0bc39e1a186feba890 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 22 Jun 2021 08:56:26 +0900 Subject: [PATCH 31/49] =?UTF-8?q?change:=20README=E3=81=AEtravis=E3=81=AEU?= =?UTF-8?q?RL=E3=82=92travis-ci.com=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e09278..89769cf 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Cabinets for NetComomns3 -[![Build Status](https://travis-ci.org/NetCommons3/Cabinets.svg?branch=master)](https://travis-ci.org/NetCommons3/Cabinets) +[![Build Status](https://travis-ci.com/NetCommons3/Cabinets.svg?branch=master)](https://travis-ci.com/NetCommons3/Cabinets) [![Coverage Status](https://img.shields.io/coveralls/NetCommons3/Cabinets.svg)](https://coveralls.io/r/NetCommons3/Cabinets?branch=master) | dependencies | status | From 0d1f91deb031c47c882571d025616b7266285c87 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 30 Jul 2021 15:17:56 +0900 Subject: [PATCH 32/49] =?UTF-8?q?change:=20test:=20TravisCI=E3=81=8B?= =?UTF-8?q?=E3=82=89GithubAction=E3=81=AB=E5=A4=89=E6=9B=B4=20https://gith?= =?UTF-8?q?ub.com/NetCommons3/NetCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 137 ++++++++++++++++++++++++++++++++++++ .travis.yml | 48 ------------- README.md | 15 ++-- phpunit.xml.dist | 4 +- 4 files changed, 142 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d6bd01e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,137 @@ +on: + push: + branches: + - main + - master + - availability + pull_request: + branches: + - main + - master + - availability + +name: tests + +jobs: + tests: + name: tests + runs-on: ubuntu-18.04 + strategy: + matrix: + php: [ '7.1', '7.2', '7.3', '7.4' ] + + env: + NC3_BUILD_DIR: "/opt/nc3" + NC3_DOCKER_DIR: "/opt/docker" + NC3_GIT_URL: "git://github.com/NetCommons3/NetCommons3.git" + NC3_GIT_BRANCH: "master" + PLUGIN_BUILD_DIR: ${{ github.workspace }} + PHP_VERSION: ${{ matrix.php }} + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: cakephp_test + + steps: + - uses: actions/checkout@v2 + + - name: environment + run: | + echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" + echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" + echo "PHP_VERSION=${PHP_VERSION}" + ls -al ${PLUGIN_BUILD_DIR} + + - name: docker-compose install + run: | + curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + chmod +x ~/docker-compose + sudo mv ~/docker-compose /usr/local/bin/docker-compose + docker-compose --version + + - name: git clone nc3 + run: git clone -b ${NC3_GIT_BRANCH} ${NC3_GIT_URL} ${NC3_BUILD_DIR} + + - name: git clone nc3_docker + run: git clone https://github.com/NetCommons3/nc3app-docker.git ${NC3_DOCKER_DIR} + + - name: docker-compose start + run: | + cd ${NC3_DOCKER_DIR} + docker-compose up -d + docker-compose start + + - run: docker ps + + - name: check libraries + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/start-on-docker.sh + + - name: nc3 build + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/app-build.sh + + - name: phpcs (PHP CodeSniffer) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh + + - name: phpmd (PHP Mess Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh + + - name: phpcpd (PHP Copy/Paste Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh + + - name: gjslint (JavaScript Style Check) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh + + - name: phpdoc (PHP Documentor) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh + + - name: phpunit (PHP UnitTest) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh + sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build + + - name: push coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.php }} + run: | + cd ${NC3_BUILD_DIR} + ls -la ${NC3_BUILD_DIR} + vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v + + - name: docker-compose remove + run: | + cd ${NC3_DOCKER_DIR} + docker-compose rm -f + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: good + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: danger diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4de7e4e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,48 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3.24 - - 7.4 - -sudo: false -dist: trusty - -env: - matrix: - - NETCOMMONS_VERSION=master DB=mysql - global: - - secure: "mF+LYvAgZauto0g3knD6wqd3wz3TEiIFEc1IhJDHWsqSjTr371xxk8n1RmrbqoRYpcRutxBtdItvp531SbLjyuo7WJ/yW4VG9k0vh8p1Vxa6x9OreqFmwibDCtO0qwewrqNJzsH4ktPlWracMv6tLNdIJyEhmp8zLQ7etzmoAJ+YGwI7Jtib7r2Mrrplfyf/AK7Vn59QNIKV33vZ7FhCPON6+N2gsuvDG2qS0ulrc/SKujXHyVfaVB7j3ZEQNpuaZC5ZANl5y3FbsgpjUWJPjAt+O9o4Xq+rFGzaoVGsB5IwRLIDiNQye4tgvFDKWzEruslGtfXxOFbOAeD9og+jSoACQ62/vzNwzp8J68+ppDtY0KPp9iOMjAivErv/niF0Ed7059tjR3Z5fyZBr1mxPXY6v3ZKlJ+1IKy+sJcSho/rGhBrfQW8UOMzi08O/ZrXyMMeCZuqByR8BGQtLmEmNZGt0fIGBV4L3NlGG6KaBHUJVpfru2rHkSjM6u1/+v5YUt5f79eyt+BnVNaaTx0Tn8HbE9tcouk2h4VeocGHpskO0oHx5kcxNRJ0Tj9oiJZ0zcRrU0K1ulpLaUAVvszqPTbV88U5UoaggJ987SAeM3xrhG0yBHvrG0gRQfJ5BUouVehadEVEWBgD37UIhKnd8rC2uISwXfxYxaoi2UiqJvM=" - - GIT_COMMITTER_NAME=RyujiAMANO - - GIT_COMMITTER_EMAIL=ryuji@ryus.co.jp - - GIT_AUTHOR_NAME=RyujiAMANO - - GIT_AUTHOR_EMAIL=ryuji@ryus.co.jp - -matrix: - allow_failures: - # PHP 7.4 testing is allowed to fail because the GD extension and ZipArchive is not packaged on Travis CI yet. - # See https://travis-ci.community/t/some-extensions-are-missing-in-php-7-4-0-zip-gmp-sodium/6320/9 - - php: 7.4 - -before_script: - - export NETCOMMONS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/NetCommons3 - - git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR - - cd $NETCOMMONS_BUILD_DIR - - git checkout $NETCOMMONS_VERSION - - travis_wait . tools/build/plugins/cakephp/travis/pre.sh - - . tools/build/plugins/cakephp/travis/environment.sh - -script: - - . tools/build/plugins/cakephp/travis/main.sh - -after_script: - - . tools/build/plugins/cakephp/travis/post.sh - -notifications: - email: - recipients: - - netcommons3@googlegroups.com - on_success: never # default: change - on_failure: always # default: always diff --git a/README.md b/README.md index 89769cf..5c49a76 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,6 @@ -# Cabinets +Cabinets ======= -Cabinets for NetComomns3 - -[![Build Status](https://travis-ci.com/NetCommons3/Cabinets.svg?branch=master)](https://travis-ci.com/NetCommons3/Cabinets) -[![Coverage Status](https://img.shields.io/coveralls/NetCommons3/Cabinets.svg)](https://coveralls.io/r/NetCommons3/Cabinets?branch=master) - -| dependencies | status | -| ------------ | ------ | -| composer.json | [![Dependency Status](https://www.versioneye.com/user/projects/57060976fcd19a004543fc60/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57060976fcd19a004543fc60) | - - +[![Tests Status](https://github.com/NetCommons3/Cabinets/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/Cabinets/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/Cabinets/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/Cabinets?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/cabinets.svg?label=stable)](https://packagist.org/packages/netcommons/cabinets) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ddb3b95..8b00f4b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,6 @@ - - - app/Plugin/Cabinets @@ -20,5 +17,6 @@ + From 18d90cb153b1f550a25a6fb3ae119dfd262ca424 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 30 Jul 2021 15:48:10 +0900 Subject: [PATCH 33/49] =?UTF-8?q?change:=20test:=20phpunit.xml=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20https://github.com/NetCommons3/NetCommons3/issues/1?= =?UTF-8?q?650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8b00f4b..c5d658f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -17,6 +17,6 @@ - + From b7e1b4faf297df7a2786d05cd60027c050d16b44 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 30 Jul 2021 16:59:54 +0900 Subject: [PATCH 34/49] =?UTF-8?q?change:=20test:=20phpcs,phpdoc=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/CabinetFolderBehavior.php | 14 +++++++------- .../UpdateCabinetTotalSizeTest.php | 11 ++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Model/Behavior/CabinetFolderBehavior.php b/Model/Behavior/CabinetFolderBehavior.php index 257c42d..1d9af31 100644 --- a/Model/Behavior/CabinetFolderBehavior.php +++ b/Model/Behavior/CabinetFolderBehavior.php @@ -294,13 +294,13 @@ public function updateCabinetTotalSize(Model $model, $cabinetKey) { //$model->Cabinet->saveField('total_size', $totalSize, ['callbacks' => false]); } - /** - * calcCabinetTotalSize - * - * @param Model $model - * @param $cabinet - * @return mixed - */ +/** + * calcCabinetTotalSize + * + * @param Model $model モデル + * @param array $cabinet Cabinetデータ + * @return mixed + */ public function calcCabinetTotalSize(Model $model, $cabinet) { // トータルサイズ取得 $rootFolder = $model->getRootFolder($cabinet); diff --git a/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php b/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php index 2897d14..7650543 100644 --- a/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php +++ b/Test/Case/Model/Behavior/CabinetFolderBehavior/UpdateCabinetTotalSizeTest.php @@ -2,12 +2,11 @@ /** * UpdateCabinetTotalSizeTest.php * - * @author Japan Science and Technology Agency - * @author National Institute of Informatics - * @link http://researchmap.jp researchmap Project + * @author Noriko Arai + * @author Ryuji AMANO * @link http://www.netcommons.org NetCommons Project - * @license http://researchmap.jp/public/terms-of-service/ researchmap license - * @copyright Copyright 2017, researchmap Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project */ @@ -19,6 +18,8 @@ final class UpdateCabinetTotalSizeTest extends \NetCommonsModelTestCase { /** + * Fixture + * * @var string[] */ public $fixtures = [ From 452668105856199ccd61c455aedf25222bb9cd34 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 30 Jul 2021 22:35:08 +0900 Subject: [PATCH 35/49] =?UTF-8?q?change:=20test:=20phpunit=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Case/Model/CabinetFileTree/SaveTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Test/Case/Model/CabinetFileTree/SaveTest.php b/Test/Case/Model/CabinetFileTree/SaveTest.php index 048dda5..9456a54 100644 --- a/Test/Case/Model/CabinetFileTree/SaveTest.php +++ b/Test/Case/Model/CabinetFileTree/SaveTest.php @@ -64,6 +64,9 @@ public function testSave() { $data['modified'] = '2000-01-01 00:00:00'; $result = $this->CabinetFileTree->save($data); - $this->assertNotEquals($result['CabinetFileTree']['modified'], $data['modified']); + $this->assertNotEquals( + $this->CabinetFileTree->data['CabinetFileTree']['modified'], + $data['modified'] + ); } } From d4a9e17d81779c490bdb13e837485d01730f5cc9 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 31 Jul 2021 00:01:42 +0900 Subject: [PATCH 36/49] =?UTF-8?q?change:=20test:=20phpmd=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/Case/Model/CabinetFileTree/SaveTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/Case/Model/CabinetFileTree/SaveTest.php b/Test/Case/Model/CabinetFileTree/SaveTest.php index 9456a54..799dde4 100644 --- a/Test/Case/Model/CabinetFileTree/SaveTest.php +++ b/Test/Case/Model/CabinetFileTree/SaveTest.php @@ -63,7 +63,7 @@ public function testSave() { $data = (new CabinetFileTreeFixture())->records[0]; $data['modified'] = '2000-01-01 00:00:00'; - $result = $this->CabinetFileTree->save($data); + $this->CabinetFileTree->save($data); $this->assertNotEquals( $this->CabinetFileTree->data['CabinetFileTree']['modified'], $data['modified'] From 268fc6b0b630f3cb770bdbf72110f8566736b9db Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 10 Aug 2021 22:09:05 +0900 Subject: [PATCH 37/49] =?UTF-8?q?change:=20test:=20Slack=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3,=20mysql8.0=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 35 ++++++++++++++++++++++++-- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3225bc..592d72f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,16 +4,25 @@ on: tags: - '3*' -name: Create Release +name: create_release jobs: build: - name: Create Release + name: create_release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + SLACK_MESSAGE: "Start Job" + - name: Create Release id: create_release uses: actions/create-release@v1 @@ -26,3 +35,25 @@ jobs: NetCommons ${{ github.ref }} released. draft: false prerelease: false + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Finish + uses: rtCamp/action-slack-notify@v2.2.0 + if: success() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good + SLACK_MESSAGE: "Job Success" + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: danger + SLACK_MESSAGE: "Job Failure" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d6bd01e..1477ea2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,12 +13,26 @@ on: name: tests jobs: + setup: + name: setup + runs-on: ubuntu-18.04 + steps: + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + tests: name: tests + needs: setup runs-on: ubuntu-18.04 strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] + mysql: [ '5.7', '8.0' ] env: NC3_BUILD_DIR: "/opt/nc3" @@ -27,6 +41,7 @@ jobs: NC3_GIT_BRANCH: "master" PLUGIN_BUILD_DIR: ${{ github.workspace }} PHP_VERSION: ${{ matrix.php }} + MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test @@ -38,6 +53,7 @@ jobs: echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" echo "PHP_VERSION=${PHP_VERSION}" + echo "MYSQL_VERSION=${MYSQL_VERSION}" ls -al ${PLUGIN_BUILD_DIR} - name: docker-compose install @@ -116,22 +132,27 @@ jobs: cd ${NC3_DOCKER_DIR} docker-compose rm -f - # テスト成功時はこちらのステップが実行される - - name: Slack Notification on Success - if: success() - uses: rtCamp/action-slack-notify@v2.2.0 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" - SLACK_COLOR: good - # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 if: failure() env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}(php${{ matrix.php }}, mysql${{ matrix.mysql }})" SLACK_COLOR: danger + + teardown: + name: teardown + runs-on: ubuntu-18.04 + needs: tests + steps: + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good From 7a4ce5fe313e72f87c6f1e9eb36905a0853979d7 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 13 Aug 2021 14:47:48 +0900 Subject: [PATCH 38/49] change: Version number to 3.3.4 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 619b537..a0891f5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.3 +3.3.4 From 295bf54ce4227642069e504ee8b09bbc7eeef9f1 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 11 Feb 2022 18:19:49 +0900 Subject: [PATCH 39/49] change: Version number to 3.3.5 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index a0891f5..fa7adc7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.4 +3.3.5 From 891a45ed88affb00592d80c338c51dc8e78e388f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Apr 2022 08:37:11 +0900 Subject: [PATCH 40/49] =?UTF-8?q?test:=20github=20actions=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1477ea2..9501566 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,9 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix up git URLs + run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig + - name: environment run: | echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" @@ -58,7 +61,7 @@ jobs: - name: docker-compose install run: | - curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose chmod +x ~/docker-compose sudo mv ~/docker-compose /usr/local/bin/docker-compose docker-compose --version From d8d2e8c03873564c7cc6f9306d3bed577b44bb00 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 27 Apr 2022 10:08:34 +0900 Subject: [PATCH 41/49] =?UTF-8?q?test:=20github=20actions=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1477ea2..9501566 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,6 +48,9 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Fix up git URLs + run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig + - name: environment run: | echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" @@ -58,7 +61,7 @@ jobs: - name: docker-compose install run: | - curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose chmod +x ~/docker-compose sudo mv ~/docker-compose /usr/local/bin/docker-compose docker-compose --version From b2de440fc08c05aa82760bbe8e35e98b9503a7cd Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 27 Apr 2022 10:10:40 +0900 Subject: [PATCH 42/49] =?UTF-8?q?fix:=20select=5Ffolder=E7=AD=89=E3=81=AE?= =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E8=BF=BD=E5=8A=A0=20https:?= =?UTF-8?q?//github.com/researchmap/RmNetCommons3/issues/2722?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index b83ba88..48b0fd6 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -39,7 +39,7 @@ class CabinetFilesEditController extends CabinetsAppController { 'NetCommons.Permission' => array( //アクセスの権限 'allow' => array( - 'add,edit,delete,move' => 'content_creatable', + 'add,edit,delete,move,get_folder_path,select_folder' => 'content_creatable', // フォルダの作成・編集は公開権限以上 'add_folder,edit_folder' => 'content_publishable', 'unzip' => 'content_publishable' From a854ab46fed7c8497a2f424f260ed94520924939 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 27 Nov 2022 14:52:58 +0900 Subject: [PATCH 43/49] fix: edit problem --- Controller/CabinetFilesEditController.php | 26 +++++++++++++++++++ Model/CabinetFile.php | 17 ++++++++++++ .../AddFolderTest.php | 1 + .../CabinetFilesEditController/AddTest.php | 5 +++- .../BeforeFilterTest.php | 2 +- View/Elements/CabinetFiles/folder_row.ctp | 2 +- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index 48b0fd6..2f7b155 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -63,6 +63,11 @@ class CabinetFilesEditController extends CabinetsAppController { //'Likes.Like', ); +/** + * @var array Cabinet + */ + protected $_cabinet; + /** * beforeFilter * @@ -108,6 +113,10 @@ private function __getParentFolderUrl($parentId) { * @return void */ public function add() { + if (!$this->__isExistsParentFolder()) { + return $this->throwBadRequest(); + } + $this->set('isEdit', false); $cabinetFile = $this->CabinetFile->getNew(); @@ -276,6 +285,10 @@ public function edit() { * @return void */ public function add_folder() { + if (!$this->__isExistsParentFolder()) { + return $this->throwBadRequest(); + } + $this->set('isEdit', false); $cabinetFile = $this->CabinetFile->getNew(); @@ -691,4 +704,17 @@ protected function _isAllowUnzip($cabinetFile) { return true; } + +/** + * __isExistsParentFolder + * + * @return bool + */ + private function __isExistsParentFolder() { + $parentId = $this->request->data['CabinetFileTree']['parent_id'] ?? Hash::get( + $this->request->named, + 'parent_id' + ); + return $this->CabinetFile->isExists($this->_cabinet['Cabinet']['key'], $parentId); + } } diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index c0bdcf1..fd1e85b 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -567,4 +567,21 @@ public function isAllowUnzip($cabinetFile) { return true; } + +/** + * isExists + * + * @param string $cabinetKey Caibnet.key + * @param string|int $cabinetFileId CabinetFile.id + * @return bool + */ + public function isExists($cabinetKey, $cabinetFileId) { + $conditions = [ + 'CabinetFile.cabinet_key' => $cabinetKey, + 'CabinetFile.id' => $cabinetFileId, + ]; + $conditions = $this->getWorkflowConditions($conditions); + $count = $this->find('count', ['conditions' => $conditions]); + return ($count > 0); + } } diff --git a/Test/Case/Controller/CabinetFilesEditController/AddFolderTest.php b/Test/Case/Controller/CabinetFilesEditController/AddFolderTest.php index accb7b7..5b7407c 100644 --- a/Test/Case/Controller/CabinetFilesEditController/AddFolderTest.php +++ b/Test/Case/Controller/CabinetFilesEditController/AddFolderTest.php @@ -297,6 +297,7 @@ public function testViewFileByPublishable() { 'action' => 'add_folder', 'frame_id' => $data['Frame']['id'], 'block_id' => $data['Block']['id'], + 'parent_id' => $data['CabinetFileTree']['parent_id'], ), array('method' => 'assertNotEmpty') ); diff --git a/Test/Case/Controller/CabinetFilesEditController/AddTest.php b/Test/Case/Controller/CabinetFilesEditController/AddTest.php index bd7e106..aa2b059 100644 --- a/Test/Case/Controller/CabinetFilesEditController/AddTest.php +++ b/Test/Case/Controller/CabinetFilesEditController/AddTest.php @@ -157,7 +157,7 @@ public function dataProviderAddGet() { $results[0] = array( 'urlOptions' => array( 'frame_id' => $data['Frame']['id'], - 'block_id' => $data['Block']['id'] + 'block_id' => $data['Block']['id'], ), 'assert' => null, 'exception' => 'ForbiddenException', ); @@ -185,6 +185,7 @@ public function dataProviderAddGetByCreatable() { 'urlOptions' => array( 'frame_id' => $data['Frame']['id'], 'block_id' => $data['Block']['id'], + 'parent_id' => $data['CabinetFileTree']['parent_id'], ), 'assert' => array('method' => 'assertNotEmpty'), ); @@ -313,6 +314,7 @@ public function testViewFileByCreatable() { 'action' => 'add', 'frame_id' => $data['Frame']['id'], 'block_id' => $data['Block']['id'], + 'parent_id' => $data['CabinetFileTree']['parent_id'], ), array('method' => 'assertNotEmpty') ); @@ -344,6 +346,7 @@ public function testViewFileByPublishable() { 'action' => 'add', 'frame_id' => $data['Frame']['id'], 'block_id' => $data['Block']['id'], + 'parent_id' => $data['CabinetFileTree']['parent_id'], ), array('method' => 'assertNotEmpty') ); diff --git a/Test/Case/Controller/CabinetFilesEditController/BeforeFilterTest.php b/Test/Case/Controller/CabinetFilesEditController/BeforeFilterTest.php index 8f60d39..fe8dfa5 100644 --- a/Test/Case/Controller/CabinetFilesEditController/BeforeFilterTest.php +++ b/Test/Case/Controller/CabinetFilesEditController/BeforeFilterTest.php @@ -78,7 +78,7 @@ public function testBeforeFilterGet() { //テスト実行 $blockId = '2'; - $this->_testGetAction(array('action' => 'add', 'block_id' => $blockId), array('method' => + $this->_testGetAction(array('action' => 'add', 'block_id' => $blockId, 'parent_id' => 11), array('method' => 'assertNotEmpty'), null, 'view'); diff --git a/View/Elements/CabinetFiles/folder_row.ctp b/View/Elements/CabinetFiles/folder_row.ctp index 6454805..604694b 100644 --- a/View/Elements/CabinetFiles/folder_row.ctp +++ b/View/Elements/CabinetFiles/folder_row.ctp @@ -64,7 +64,7 @@ ); ?> - +
  • Date: Sun, 27 Nov 2022 16:06:23 +0900 Subject: [PATCH 44/49] =?UTF-8?q?comment:=20phpmd=E6=8A=91=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/CabinetFile.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index fd1e85b..d89019f 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -13,6 +13,8 @@ /** * Summary for CabinetFile Model + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class CabinetFile extends CabinetsAppModel { From 29e3c9ad98a2ddd982a336409a44beefb665c633 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Fri, 6 Jan 2023 13:56:32 +0900 Subject: [PATCH 45/49] =?UTF-8?q?fix:=20=E8=A6=AA=E3=83=95=E3=82=A9?= =?UTF-8?q?=E3=83=AB=E3=83=80=E3=81=AE=E5=AD=98=E5=9C=A8=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E6=99=82=E3=81=AB=E4=BD=BF=E3=81=86ID?= =?UTF-8?q?=E3=81=8C=E9=96=93=E9=81=95=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/CabinetFilesEditController.php | 2 +- Model/CabinetFile.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/CabinetFilesEditController.php b/Controller/CabinetFilesEditController.php index 2f7b155..39758fb 100644 --- a/Controller/CabinetFilesEditController.php +++ b/Controller/CabinetFilesEditController.php @@ -715,6 +715,6 @@ private function __isExistsParentFolder() { $this->request->named, 'parent_id' ); - return $this->CabinetFile->isExists($this->_cabinet['Cabinet']['key'], $parentId); + return $this->CabinetFile->isExistsByTreeId($this->_cabinet['Cabinet']['key'], $parentId); } } diff --git a/Model/CabinetFile.php b/Model/CabinetFile.php index d89019f..d0ebb0e 100644 --- a/Model/CabinetFile.php +++ b/Model/CabinetFile.php @@ -574,13 +574,13 @@ public function isAllowUnzip($cabinetFile) { * isExists * * @param string $cabinetKey Caibnet.key - * @param string|int $cabinetFileId CabinetFile.id + * @param string|int $cabinetFileTreeId CabinetFile.id * @return bool */ - public function isExists($cabinetKey, $cabinetFileId) { + public function isExistsByTreeId($cabinetKey, $cabinetFileTreeId) { $conditions = [ 'CabinetFile.cabinet_key' => $cabinetKey, - 'CabinetFile.id' => $cabinetFileId, + 'CabinetFile.cabinet_file_tree_id' => $cabinetFileTreeId, ]; $conditions = $this->getWorkflowConditions($conditions); $count = $this->find('count', ['conditions' => $conditions]); From 7b63a409930f6056d811f548f28a22dfd1f443e3 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 24 Feb 2023 13:33:17 +0900 Subject: [PATCH 46/49] =?UTF-8?q?test:=20Github=20Action=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9501566..7cfa881 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,6 +44,7 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 From 25c8e30e7ffefc90a975803b460c042f80a8e1ff Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 25 Feb 2023 21:17:17 +0900 Subject: [PATCH 47/49] change: Version number to 3.3.6 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..9c25013 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.6 From 0e3ea2b469440ad216c91690c9cfdbc0f75f2bbf Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Thu, 5 Oct 2023 16:39:54 +0900 Subject: [PATCH 48/49] =?UTF-8?q?test:=20github=20action=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7cfa881..eb2068b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,10 +15,11 @@ name: tests jobs: setup: name: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Slack Notification on Start uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -28,7 +29,7 @@ jobs: tests: name: tests needs: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] @@ -92,46 +93,53 @@ jobs: docker-compose exec -T nc3app bash /opt/scripts/app-build.sh - name: phpcs (PHP CodeSniffer) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh - name: phpmd (PHP Mess Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh - name: phpcpd (PHP Copy/Paste Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh - name: gjslint (JavaScript Style Check) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh - name: phpdoc (PHP Documentor) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh - name: phpunit (PHP UnitTest) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build - - name: push coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: ${{ matrix.php }} - run: | - cd ${NC3_BUILD_DIR} - ls -la ${NC3_BUILD_DIR} - vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v +# - name: push coveralls +# env: +# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# COVERALLS_FLAG_NAME: ${{ matrix.php }} +# run: | +# cd ${NC3_BUILD_DIR} +# ls -la ${NC3_BUILD_DIR} +# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v - name: docker-compose remove + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose rm -f @@ -139,7 +147,7 @@ jobs: # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 - if: failure() + if: env.SLACK_WEBHOOK != '' && failure() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -148,13 +156,13 @@ jobs: teardown: name: teardown - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: tests steps: # テスト成功時はこちらのステップが実行される - name: Slack Notification on Success - if: success() uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' && success() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests From 0a67809d4d11c3afd9a7769765977c796b837516 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Oct 2023 15:33:46 +0900 Subject: [PATCH 49/49] change: Version number to 3.3.7 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 9c25013..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.6 +3.3.7