diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..c55f5d1
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,59 @@
+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: 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
+ 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: |
+ ${{ 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
new file mode 100644
index 0000000..6da4321
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,168 @@
+on:
+ push:
+ branches:
+ - main
+ - master
+ pull_request:
+ branches:
+ - main
+ - master
+
+name: tests
+
+jobs:
+ setup:
+ name: setup
+ 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
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: "#f0ad4e"
+
+ tests:
+ name: tests
+ needs: setup
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ php: [ '7.1', '7.2', '7.3', '7.4' ]
+ mysql: [ '5.7', '8.0' ]
+
+ 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_VERSION: ${{ matrix.mysql }}
+ MYSQL_ROOT_PASSWORD: root
+ MYSQL_DATABASE: cakephp_test
+ COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ 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}"
+ 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
+ run: |
+ 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
+
+ - 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)
+ 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: docker-compose remove
+ if: always()
+ run: |
+ cd ${NC3_DOCKER_DIR}
+ docker-compose rm -f
+
+ # テスト失敗時はこちらのステップが実行される
+ - name: Slack Notification on Failure
+ uses: rtCamp/action-slack-notify@v2.2.0
+ if: env.SLACK_WEBHOOK != '' && failure()
+ env:
+ 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-latest
+ needs: tests
+ steps:
+ # テスト成功時はこちらのステップが実行される
+ - name: Slack Notification on 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
+ SLACK_TITLE: "${{ github.repository }}"
+ SLACK_COLOR: good
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d16e57b..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-language: php
-
-php:
- - 5.4
- - 5.5
- - 5.6
- - 7.0
- - 7.1
-
-sudo: false
-
-env:
- matrix:
- - NETCOMMONS_VERSION=master DB=mysql
- global:
- - secure: "h6sSqr4r8WDkKFHHu5fdjav1V2P4aZ9JY/422gXmyYJeAEVxXcnVN02jwNlR+M+vZ3fbKjJbr4tYqdKQ/DB29z0dGXFoPeaMhfkdEGdFIRYUTQm4Qb2jCYjLbRSRq2Y/KdX7SkaZqqkRiTSB1OSedYU9SmPEKs+WV3IbLSzAlohhGTRoMh6+RCkxkEH/LnW1rTPv6N+cehSZlGLIvg1//4Jy8yAiHDRmY9NIoZ1N8jdOOKkGIQu4f3u108qr8DxSP5Q4MkVLgcDUYGHYuE/w5/nVGTMeD4QCjnYCDZVqEFpKWz0qquKJR+ygWR7D+oqfXvAOK8NJbk1GDsSgHBBHAnrdUJy7d9hpQ5hrzP4czXKWmLlg4rbSfdnUQKTH4857jn23KGH79ARcYE0j/qDC0tr7AmzVsLqQbarJXNUke8oPPbnBt+6pkPV7O4ocB1hgSXYgwpv/sCRaBpQHSl4+XGFG/VWRQHXtVTOS6IDjzsRlxz1MC3YtQl4hNQpp6K9VwWem5D4u8cMx6Q4yiB35nI+vTdF/l0uPK/miyqPOdjuCkviIFpacRwRuGbI1P5VNLBxuxE7iboA7ugeWk14Vy71ZrXd7S7eEhQDi390/qt/8fuA8LxuCM/unCwgA3VBH7OpLmlC4mFpM00oNxSsqeftEwhjmwAM01rpLQexyTcU="
- - GIT_COMMITTER_NAME=s-nakajima
- - GIT_COMMITTER_EMAIL=nakajimashouhei@gmail.com
- - GIT_AUTHOR_NAME=s-nakajima
- - GIT_AUTHOR_EMAIL=nakajimashouhei@gmail.com
-
-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/Config/Migration/1469687773_site_manager_records.php b/Config/Migration/1469687773_site_manager_records.php
index e77aee5..e21e7cb 100644
--- a/Config/Migration/1469687773_site_manager_records.php
+++ b/Config/Migration/1469687773_site_manager_records.php
@@ -180,7 +180,7 @@ class SiteManagerRecords extends NetCommonsMigration {
array(
'language_id' => 0,
'key' => 'Meta.copyright',
- 'value' => 'Copyright © 2016',
+ 'value' => 'Copyright 2016',
),
// * キーワード
array(
diff --git a/Controller/UseLanguagesController.php b/Controller/UseLanguagesController.php
index 260cc8b..98fad7a 100644
--- a/Controller/UseLanguagesController.php
+++ b/Controller/UseLanguagesController.php
@@ -76,7 +76,7 @@ public function edit() {
}
}
- $plugins = $this->Plugin->find('list', array(
+ $plugins = $this->Plugin->cacheFindQuery('list', array(
'recursive' => -1,
'fields' => array('key', 'name'),
'conditions' => array(
@@ -87,7 +87,7 @@ public function edit() {
));
$this->set('plugins', $plugins);
- $plugins = $this->Plugin->find('list', array(
+ $plugins = $this->Plugin->cacheFindQuery('list', array(
'recursive' => -1,
'fields' => array('key', 'key'),
'conditions' => array(
diff --git a/Model/Behavior/IpAddressManagerBehavior.php b/Model/Behavior/IpAddressManagerBehavior.php
index c6a16ad..89c9457 100644
--- a/Model/Behavior/IpAddressManagerBehavior.php
+++ b/Model/Behavior/IpAddressManagerBehavior.php
@@ -11,6 +11,7 @@
App::uses('SiteSettingValidateBehavior', 'SiteManager.Model/Behavior');
App::uses('Current', 'NetCommons.Utility');
+App::uses('NetCommonsSecurity', 'NetCommons.Utility');
/**
* IpAddress管理 Behavior
@@ -20,6 +21,28 @@
*/
class IpAddressManagerBehavior extends SiteSettingValidateBehavior {
+/**
+ * NetCommonsSecurityユーティリティ
+ *
+ * @var object
+ */
+ public $NetCommonsSecurity;
+
+/**
+ * ビヘイビアの設定処理
+ *
+ * @param Model $model ビヘイビア呼び出し元モデル
+ * @param array $config $modelのためのコンフィグ設定
+ * @return void
+ */
+ public function setup(Model $model, $config = array()) {
+ parent::setup($model, $config);
+
+ if (! $this->NetCommonsSecurity) {
+ $this->NetCommonsSecurity = new NetCommonsSecurity();
+ }
+ }
+
/**
* IPアドレスのアクセス拒否のValidate処理
*
@@ -97,7 +120,7 @@ public function validateAllowSystemPluginIps(Model $model, $data) {
* @return string
*/
public function getCurrentIp(Model $model) {
- return Hash::get($_SERVER, 'HTTP_X_FORWARDED_FOR', Hash::get($_SERVER, 'REMOTE_ADDR'));
+ return $this->NetCommonsSecurity->getCurrentIp();
}
/**
@@ -108,33 +131,7 @@ public function getCurrentIp(Model $model) {
* @return bool
*/
public function hasCurrentIp(Model $model, $ips) {
- if (! $ips) {
- return false;
- }
-
- if (is_string($ips)) {
- $ips = explode('|', $ips);
- }
-
- $currentIp = $this->getCurrentIp($model);
- if (! $currentIp) {
- return false;
- }
- foreach ($ips as $accept) {
- if (strpos($accept, '/')) {
- list($acceptIp, $mask) = explode('/', $accept);
- } else {
- $acceptIp = $accept;
- $mask = 32;
- }
- $acceptLong = ip2long($acceptIp) >> (32 - $mask);
- $currentLong = ip2long($currentIp) >> (32 - $mask);
- if ($acceptLong === $currentLong) {
- return true;
- }
- }
-
- return false;
+ return $this->NetCommonsSecurity->hasCurrentIp($ips);
}
/**
diff --git a/Model/Behavior/SiteManagerValidateBehavior.php b/Model/Behavior/SiteManagerValidateBehavior.php
index 5d94ea3..22de02f 100644
--- a/Model/Behavior/SiteManagerValidateBehavior.php
+++ b/Model/Behavior/SiteManagerValidateBehavior.php
@@ -74,6 +74,7 @@ public function validateSiteClose(Model $model, $data) {
);
foreach ($settingKeys as $key) {
if (Hash::get($data[$model->alias]['App.close_site'], '0.value')) {
+ $data = $this->_cleansingWysiwyg($model, $data, $key);
$data = $this->_validateRequired($model, $data, $key);
} else {
unset($data[$model->alias][$key]);
@@ -184,6 +185,9 @@ private function __validateMembershipAutoRegist(Model $model, $data) {
// __d('net_commons', 'Invalid request.'));
//}
+ //利用規約文
+ $data = $this->_cleansingWysiwyg($model, $data, 'AutoRegist.disclaimer');
+
//会員登録承認メール、会員登録受付メール
$settingKeys = array(
'AutoRegist.approval_mail_subject',
@@ -256,6 +260,9 @@ private function __validateMembershipUserCancel(Model $model, $data) {
__d('net_commons', 'Invalid request.'));
}
+ //退会規約文
+ $data = $this->_cleansingWysiwyg($model, $data, 'UserCancel.disclaimer');
+
//退会完了メール
$settingKeys = array(
'UserCancel.mail_subject',
diff --git a/Model/Behavior/SiteSettingValidateBehavior.php b/Model/Behavior/SiteSettingValidateBehavior.php
index a30546f..9ebe983 100644
--- a/Model/Behavior/SiteSettingValidateBehavior.php
+++ b/Model/Behavior/SiteSettingValidateBehavior.php
@@ -55,6 +55,33 @@ protected function _validateRequired(Model $model, $data, $key) {
return $data;
}
+/**
+ * Wysiwygのクレンジング
+ *
+ * @param Model $model ビヘイビア呼び出し元モデル
+ * @param array $data リクエストデータ配列
+ * @param string $key キー
+ * @return array リクエストデータ
+ */
+ protected function _cleansingWysiwyg(Model $model, $data, $key) {
+ if (! isset($data[$model->alias][$key])) {
+ return $data;
+ }
+
+ $model->Behaviors->load('Wysiwyg.Purifiable', [
+ 'fields' => [$model->alias => ['value']],
+ ]);
+
+ foreach ($data[$model->alias][$key] as $langId => $check) {
+ $model->create($check);
+ $model->validates();
+ $data[$model->alias][$key][$langId] = $model->data[$model->alias];
+ }
+
+ $model->Behaviors->unload('Wysiwyg.Purifiable');
+ return $data;
+ }
+
/**
* validationMessageの有無
*
diff --git a/Model/Behavior/SystemManagerSaveBehavior.php b/Model/Behavior/SystemManagerSaveBehavior.php
index cfd09aa..dc51c0a 100644
--- a/Model/Behavior/SystemManagerSaveBehavior.php
+++ b/Model/Behavior/SystemManagerSaveBehavior.php
@@ -28,8 +28,10 @@ class SystemManagerSaveBehavior extends ModelBehavior {
* @throws InternalErrorException
*/
public function saveRoomDiskSize(Model $model, $data) {
- if (! isset($data[$model->alias]['App.disk_for_group_room']) ||
- ! isset($data[$model->alias]['App.disk_for_private_room'])) {
+ if (! isset($data[$model->alias]['App.disk_for_public_room']) ||
+ ! isset($data[$model->alias]['App.disk_for_group_room']) ||
+ ! isset($data[$model->alias]['App.disk_for_private_room'])
+ ) {
return $data;
}
$model->loadModels([
@@ -37,6 +39,7 @@ public function saveRoomDiskSize(Model $model, $data) {
]);
$spaces = array(
+ 'App.disk_for_public_room' => Space::PUBLIC_SPACE_ID,
'App.disk_for_group_room' => Space::COMMUNITY_SPACE_ID,
'App.disk_for_private_room' => Space::PRIVATE_SPACE_ID,
);
@@ -46,9 +49,10 @@ public function saveRoomDiskSize(Model $model, $data) {
$value = null;
}
$model->Space->id = $spaceId;
- if (! $model->Space->saveField('room_disk_size', $value)) {
+ if (! $model->Space->saveField('room_disk_size', $value, ['callbacks' => false])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
+ $model->Space->cacheClear();
unset($data[$model->alias][$key]);
}
diff --git a/Model/Behavior/SystemManagerValidateBehavior.php b/Model/Behavior/SystemManagerValidateBehavior.php
index c5ba45b..ba03c69 100644
--- a/Model/Behavior/SystemManagerValidateBehavior.php
+++ b/Model/Behavior/SystemManagerValidateBehavior.php
@@ -69,6 +69,13 @@ public function validateSystemSetting(Model $model, $data) {
__d('net_commons', 'Invalid request.'));
}
+ //パブリックルームの容量
+ $value = (int)Hash::get($data[$model->alias]['App.disk_for_public_room'], '0.value');
+ if (! in_array($value, $model->SiteSetting->diskSpace, true)) {
+ $this->_setValidationMessage($model, 'App.disk_for_public_room', '0',
+ __d('net_commons', 'Invalid request.'));
+ }
+
//グループルームの容量
$value = (int)Hash::get($data[$model->alias]['App.disk_for_group_room'], '0.value');
if (! in_array($value, $model->SiteSetting->diskSpace, true)) {
diff --git a/Model/SiteSetting.php b/Model/SiteSetting.php
index 4ac42cb..e396fe9 100644
--- a/Model/SiteSetting.php
+++ b/Model/SiteSetting.php
@@ -313,7 +313,7 @@ public function getDefaultStartPage() {
return '/';
}
- $space = $this->Space->find('first', array(
+ $space = $this->Space->cacheFindQuery('first', array(
'recursive' => -1,
'conditions' => array('id' => $room['Room']['space_id'])
));
@@ -494,7 +494,7 @@ public function saveSiteSettingByKey($key, $value) {
$this->id = $siteSetting['SiteSetting']['id'];
//登録処理
- if (! $this->SiteSetting->saveField('value', $value)) {
+ if (! $this->SiteSetting->saveField('value', $value, ['callbacks' => false])) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}
diff --git a/README.md b/README.md
index cfb5af9..9446260 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,6 @@
SiteManager
==============
-SiteManager for NetComomns3
-
-[](https://travis-ci.org/NetCommons3/SiteManager)
-[](https://coveralls.io/r/NetCommons3/SiteManager?branch=master)
-
-| dependencies | status |
-| ------------- | ------ |
-| composer.json | [](https://www.versioneye.com/user/projects/56738e8184f9b4000c0011e9) |
+[](https://github.com/NetCommons3/SiteManager/actions/workflows/tests.yml)
+[](https://coveralls.io/r/NetCommons3/SiteManager?branch=master)
+[](https://packagist.org/packages/netcommons/site-manager)
diff --git a/VERSION.txt b/VERSION.txt
new file mode 100644
index 0000000..86fb650
--- /dev/null
+++ b/VERSION.txt
@@ -0,0 +1 @@
+3.3.7
diff --git a/View/Helper/SiteManagerHelper.php b/View/Helper/SiteManagerHelper.php
index d2863c4..ff9f41a 100644
--- a/View/Helper/SiteManagerHelper.php
+++ b/View/Helper/SiteManagerHelper.php
@@ -377,7 +377,7 @@ public function helpSiteClose($placement = 'bottom') {
$html .= __d('net_commons', 'Can use an embedded keyword.') . ' ';
$html .= '';
- $html .= '';
+ $html .= '';
$html .= '';
$html .= '';
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 18b7c21..01fe4d6 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,5 +1,8 @@