diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..592d72f --- /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: | + 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 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 4cbc364..0000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - -env: - matrix: - - NETCOMMONS_VERSION=master DB=mysql - global: - - secure: "N73W4JE9Aw8zs41xROcKwTfoRtSLe6Us+BKQESjF/2J+T2+jvfClp0GaxJZppzcfnl73ZsX9kIwyRnwWrKCeAtO5gMvze8vciHRmwm9IvEw8zHUhGO1T4TaDNwxu4uOpH+OkZjAAZbqHO82bOBS1sjrUZu51LKLejadlpp/tgjc=" - - 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/1634459814_update_mail_answer_receivable.php b/Config/Migration/1634459814_update_mail_answer_receivable.php new file mode 100644 index 0000000..63c3516 --- /dev/null +++ b/Config/Migration/1634459814_update_mail_answer_receivable.php @@ -0,0 +1,72 @@ + + * @link http://www.netcommons.org NetCommons Project + * @license http://www.netcommons.org/license.txt NetCommons License + * @copyright Copyright 2014, NetCommons Project + */ + +App::uses('NetCommonsMigration', 'NetCommons.Config/Migration'); + +/** + * 登録フォームのフォーム投稿の通知をルーム管理には通知せずに本人のみに設定できるようにする + * + * @author Shohei Nakajima + * @package NetCommons\Roles\Config\Migration + * @see https://github.com/NetCommons3/NetCommons3/issues/1669 + */ +class UpdateMailAnswerReceivable extends NetCommonsMigration { + +/** + * Migration description + * + * @var string + */ + public $description = 'update_mail_answer_receivable'; + +/** + * Actions to be performed + * + * @var array $migration + */ + public $migration = array( + 'up' => array( + ), + 'down' => array( + ), + ); + +/** + * Before migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function before($direction) { + return true; + } + +/** + * After migration callback + * + * @param string $direction Direction of migration process (up or down) + * @return bool Should process continue + */ + public function after($direction) { + if ($direction === 'up') { + $update = array( + 'fixed' => '\'0\'', + 'modified' => '\'' . gmdate('Y-m-d H:i:s') . '\'' + ); + $conditions = array( + 'role_key' => 'room_administrator', + 'permission' => 'mail_answer_receivable', + ); + $DefaultRolePermission = $this->generateModel('DefaultRolePermission'); + $DefaultRolePermission->updateAll($update, $conditions); + } + return true; + } +} diff --git a/Model/DefaultRolePermission.php b/Model/DefaultRolePermission.php index 4ca4a9b..f84d32b 100644 --- a/Model/DefaultRolePermission.php +++ b/Model/DefaultRolePermission.php @@ -40,6 +40,15 @@ class DefaultRolePermission extends RolesAppModel { */ public $validate = array(); +/** + * Behaviors + * + * @var array + */ + public $actsAs = array( + 'NetCommons.NetCommonsCache', + ); + /** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. @@ -50,7 +59,7 @@ class DefaultRolePermission extends RolesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge($this->validate, array( + $this->validate = ValidateMerge::merge($this->validate, array( 'role_key' => array( 'notBlank' => array( 'rule' => array('notBlank'), @@ -95,7 +104,7 @@ public function beforeValidate($options = array()) { * @return array */ public function getDefaultRolePermissions($roleKey, $permission, $type = self::TYPE_ROOM_ROLE) { - $result = $this->find('all', array( + $permissions = $this->cacheFindQuery('all', array( 'recursive' => -1, 'conditions' => array( 'permission' => $permission, @@ -104,13 +113,16 @@ public function getDefaultRolePermissions($roleKey, $permission, $type = self::T ) )); - if (! $result) { - return $result; + if (! $permissions) { + return $permissions; } - return Hash::combine( - $result, '{n}.DefaultRolePermission.permission', '{n}.DefaultRolePermission' - ); + $result = []; + foreach ($permissions as $permission) { + $key = $permission['DefaultRolePermission']['permission']; + $result[$key] = $permission['DefaultRolePermission']; + } + return $result; } } diff --git a/Model/Role.php b/Model/Role.php index 9768438..79f2dea 100644 --- a/Model/Role.php +++ b/Model/Role.php @@ -86,7 +86,7 @@ class Role extends RolesAppModel { * @see Model::save() */ public function beforeValidate($options = array()) { - $this->validate = Hash::merge(array( + $this->validate = ValidateMerge::merge(array( 'language_id' => array( 'numeric' => array( 'rule' => array('numeric'), diff --git a/README.md b/README.md index 2e9f678..7df7dc2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ Roles ======= -Roles for NetComomns3 - -[![Build Status](https://api.travis-ci.org/NetCommons3/Roles.png?branch=master)](https://travis-ci.org/NetCommons3/Roles) -[![Coverage Status](https://coveralls.io/repos/NetCommons3/Roles/badge.png?branch=master)](https://coveralls.io/r/NetCommons3/Roles?branch=master) - -| dependencies | status | -| ------------ | ------ | -| composer.json | [![Dependency Status](https://www.versioneye.com/user/projects/53fa007be09da37e52000473/badge.png)](https://www.versioneye.com/user/projects/53fa007be09da37e52000473) | \ No newline at end of file +[![Tests Status](https://github.com/NetCommons3/Roles/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/Roles/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/Roles/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/Roles?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/roles.svg?label=stable)](https://packagist.org/packages/netcommons/roles) 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/phpunit.xml.dist b/phpunit.xml.dist index 66baff5..b8ba2de 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,8 @@ + + + app/Plugin/Roles @@ -14,6 +17,6 @@ - +