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..eb2068b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,170 @@ +on: + push: + branches: + - main + - master + - availability + pull_request: + branches: + - main + - master + - availability + +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 108e0da..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: "gfM6LvQaWwrQEtqTT3eXv4RNKXF1UBZWuGlO8DHe8X+S/ocpM5oMPBI7pYzCEheIsRhRccciBUFOaXVcI/bFkUCWsgEarimZBkCpTisKX7MwlFSuJX+rX8QNhGqXrn5aUZZ6K8F92aLipsi+j3gwccgebgTh7wHWYtfkLAxdLUw=" - - GIT_COMMITTER_NAME=kitalab - - GIT_COMMITTER_EMAIL=kitatsuji.yuto@withone.co.jp - - GIT_AUTHOR_NAME=kitalab - - GIT_AUTHOR_EMAIL=kitatsuji.yuto@withone.co.jp - -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/Controller/CircularNoticesAnswerController.php b/Controller/CircularNoticesAnswerController.php index d8c2ded..0f901fd 100644 --- a/Controller/CircularNoticesAnswerController.php +++ b/Controller/CircularNoticesAnswerController.php @@ -87,14 +87,16 @@ public function edit() { } } - $data = array_merge($this->params['data'], [ - 'CircularNoticeTargetUser' => [ + $data = $this->params['data']; + $data['CircularNoticeTargetUser'] = array_merge( + $this->params['data']['CircularNoticeTargetUser'], + [ 'is_reply' => true, 'reply_datetime' => date('Y-m-d H:i:s'), 'reply_text_value' => $replyTextValue, 'reply_selection_value' => $replySelectionValue ] - ]); + ); if ($this->CircularNoticeTargetUser->saveCircularNoticeTargetUser($data)) { //新着データを回答済みにする @@ -115,6 +117,6 @@ public function edit() { } // 元の画面を表示 - $this->redirect($this->request->referer()); + $this->redirect($this->request->referer(true)); } } diff --git a/Controller/CircularNoticesController.php b/Controller/CircularNoticesController.php index f169056..f7f9b8a 100644 --- a/Controller/CircularNoticesController.php +++ b/Controller/CircularNoticesController.php @@ -50,7 +50,7 @@ class CircularNoticesController extends CircularNoticesAppController { 'NetCommons.Permission' => array( //アクセスの権限 'allow' => array( - 'index,view,downloads' => 'content_readable', + //'index,view,downloads' => 'content_readable', 'add,edit,delete' => 'content_creatable', ), ), @@ -89,7 +89,7 @@ public function beforeFilter() { * index action * * @return void - * + * * 速度改善の修正に伴って発生したため抑制 * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) @@ -100,13 +100,13 @@ public function index() { } // コンテンツステータスの絞り込み値チェック - if (isset($this->params['named']['content_status']) + if (!empty($this->params['named']['content_status']) && ! $this->CircularNotice->existsContentStatus($this->params['named']['content_status'])) { return $this->throwBadRequest(); } // 回答状況の絞り込み値チェック - if (isset($this->params['named']['reply_status']) + if (!empty($this->params['named']['reply_status']) && ! $this->CircularNotice->existsReplyStatus($this->params['named']['reply_status'])) { return $this->throwBadRequest(); } @@ -139,7 +139,7 @@ public function index() { $currentSort = isset($this->params['named']['sort']) ? $this->params['named']['sort'] : 'CircularNoticeContent.modified'; - $currentDirection = isset($this->params['named']['sort']) + $currentDirection = isset($this->params['named']['direction']) ? $this->params['named']['direction'] : 'desc'; if (! isset($sortOptions[$currentSort . '.' . $currentDirection])) { @@ -347,6 +347,7 @@ public function add() { * edit action * * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function edit() { $userId = Current::read('User.id'); @@ -359,6 +360,12 @@ public function edit() { return $this->throwBadRequest(); } + // フレームから取得したCircularNoticeSetting.keyとコンテンツのcircular_notice_setting_keyが一致しない場合はBadRequest + $settingKey = $this->viewVars['circularNoticeSetting']['CircularNoticeSetting']['key'] ?? null; + if ($content['CircularNoticeContent']['circular_notice_setting_key'] !== $settingKey) { + return $this->throwBadRequest(); + } + if ($this->CircularNoticeContent->canEditWorkflowContent($content) === false) { return $this->throwBadRequest(); } @@ -428,6 +435,15 @@ public function edit() { )); $this->set('circularNoticeContent', $results['CircularNoticeContent']); $this->set('circularNoticeChoice', $results['CircularNoticeChoice']); + + // 回覧板の記事が削除できないため、削除Formの$this->NetCommonsForm->hidden('Frame.id')等を配置してる項目は + // リクエストにセットする。 + // リクエストにセットすると、$this->NetCommonsForm->hidden('Frame.id')のvalueに自動的にセットされる。 + // 削除Form: app/Plugin/CircularNotices/View/Elements/CircularNotices/delete_form.ctp + // @see https://github.com/NetCommons3/NetCommons3/issues/1547 + $this->request->data['CircularNoticeContent'] = $results['CircularNoticeContent']; + $this->request->data['Frame'] = Current::read('Frame'); + $this->request->data['Block'] = Current::read('Block'); } /** @@ -497,9 +513,13 @@ public function download() { $csvFile->add($header); // 回答データ整形 + $choices = array(); + foreach ($content['CircularNoticeChoice'] as $choice) { + $choices[$choice['id']] = $choice; + } $content = $content['CircularNoticeContent']; foreach ($targetUsers as $targetUser) { - $answer = $this->__parseAnswer($content['reply_type'], $targetUser); + $answer = $this->__parseAnswer($content['reply_type'], $targetUser, $choices); $readDatetime = __d('circular_notices', 'Unread'); if ($targetUser['CircularNoticeTargetUser']['read_datetime']) { @@ -541,9 +561,10 @@ public function download() { * * @param string $replyType 回答種別 * @param array $targetUser 回答者 + * @param array $choices 選択肢情報 * @return null|string */ - private function __parseAnswer($replyType, $targetUser) { + private function __parseAnswer($replyType, $targetUser, $choices) { $answer = null; switch ($replyType) { case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_TEXT: @@ -553,6 +574,10 @@ private function __parseAnswer($replyType, $targetUser) { case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_MULTIPLE_SELECTION: $selectionValues = explode(CircularNoticeComponent::SELECTION_VALUES_DELIMITER, $targetUser['CircularNoticeTargetUser']['reply_selection_value']); + // 取り出したreply_selection_valueの値を選択肢のラベルに変換する + foreach ($selectionValues as &$selectVal) { + $selectVal = $choices[$selectVal]['value'] ?? ''; + } $answer = implode(__d('circular_notices', 'Answer separator'), $selectionValues); break; } diff --git a/Model/Behavior/CircularNoticeTargetUserBehavior.php b/Model/Behavior/CircularNoticeTargetUserBehavior.php index 0c9e377..b0e2210 100644 --- a/Model/Behavior/CircularNoticeTargetUserBehavior.php +++ b/Model/Behavior/CircularNoticeTargetUserBehavior.php @@ -38,7 +38,7 @@ public function beforeValidate(Model $model, $options = array()) { 'User' => 'Users.User', )); - if (! $model->data['CircularNoticeContent']['is_room_target']) { + if (empty($model->data['CircularNoticeContent']['is_room_target'])) { // 回覧先ユーザのバリデーション処理 if (! isset($model->data['CircularNoticeTargetUser'])) { $model->data['CircularNoticeTargetUser'] = array(); diff --git a/Model/CircularNoticeContent.php b/Model/CircularNoticeContent.php index 69dd218..c9c2131 100644 --- a/Model/CircularNoticeContent.php +++ b/Model/CircularNoticeContent.php @@ -276,8 +276,7 @@ public function validateNotEmptyChoices($check) { $this->data['CircularNoticeContent']['reply_type'] == CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_MULTIPLE_SELECTION ) { - if (! isset($this->data['CircularNoticeChoices']) || - count($this->data['CircularNoticeChoices']) == 0) { + if (empty($this->data['CircularNoticeChoices'])) { return false; } } @@ -376,7 +375,7 @@ public function getCircularNoticeContentsForPaginate($blockKey, $userId, $pagina ), ); - if (isset($paginatorParams['reply_status'])) { + if (!empty($paginatorParams['reply_status'])) { // 未回答の場合 if ($paginatorParams['reply_status'] == CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_STATUS_NOT_REPLIED) { @@ -388,7 +387,7 @@ public function getCircularNoticeContentsForPaginate($blockKey, $userId, $pagina $conditions['CircularNoticeContent.reply_status'] = (int)$paginatorParams['reply_status']; } } - if (isset($paginatorParams['content_status'])) { + if (!empty($paginatorParams['content_status'])) { $conditions['CircularNoticeContent.content_status'] = (int)$paginatorParams['content_status']; } @@ -444,7 +443,8 @@ public function saveCircularNoticeContent($data) { 'RolesRoomsUser' => 'Rooms.RolesRoomsUser', ]); $rolesRoomsUsers = $this->RolesRoomsUser->getRolesRoomsUsers(array( - 'Room.id' => Current::read('Room.id') + 'Room.id' => Current::read('Room.id'), + 'User.status' => UserAttributeChoice::STATUS_CODE_ACTIVE )); $userIdArr = []; @@ -493,7 +493,11 @@ public function saveCircularNoticeContent($data) { } // 保存されたCircularNoticeContentでデータを差し替え - $data['CircularNoticeContent'] = $content['CircularNoticeContent']; + if (isset($content['CircularNoticeContent'])) { + $data['CircularNoticeContent'] = $content['CircularNoticeContent']; + } else { + $data['CircularNoticeContent'] = null; + } // CircularNoticeChoices・CircularNoticeTargetUsersを保存 if (! $this->__saveChoiceAndTargetUsers($data)) { diff --git a/Model/CircularNoticeTargetUser.php b/Model/CircularNoticeTargetUser.php index a24cfc2..f9f0846 100644 --- a/Model/CircularNoticeTargetUser.php +++ b/Model/CircularNoticeTargetUser.php @@ -56,7 +56,6 @@ public function beforeValidate($options = array()) { * @return bool */ public function validateNotEmptyReplyValue($check) { - CakeLog::error(var_export($this->data['CircularNoticeTargetUser'], true)); if (! $this->data['CircularNoticeTargetUser']['reply_text_value'] && ! $this->data['CircularNoticeTargetUser']['reply_selection_value'] ) { @@ -82,7 +81,8 @@ public function validateNotEmptyReplyValue($check) { 'User' => array( 'className' => 'Users.User', 'foreignKey' => 'user_id', - 'conditions' => '', + 'conditions' => ['status' => UserAttributeChoice::STATUS_CODE_ACTIVE], + 'type' => 'inner', 'fields' => '', 'order' => '' ), @@ -151,7 +151,7 @@ public function getCircularNoticeTargetUserCount($contentId) { // 回覧先件数を取得 $targetCount = $this->find('count', array( - 'recursive' => -1, + 'recursive' => 1, 'conditions' => $conditions, )); @@ -162,7 +162,7 @@ public function getCircularNoticeTargetUserCount($contentId) { // 閲覧済件数を取得 $readCount = $this->find('count', array( - 'recursive' => -1, + 'recursive' => 1, 'conditions' => $conditions, )); @@ -173,7 +173,7 @@ public function getCircularNoticeTargetUserCount($contentId) { // 回答済件数を取得 $replyCount = $this->find('count', array( - 'recursive' => -1, + 'recursive' => 1, 'conditions' => $conditions, )); diff --git a/README.md b/README.md index 9a2a20b..46a9136 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,6 @@ CircularNotices ======= -CircularNotices for NetComomns3 - -[![Build Status](https://travis-ci.org/NetCommons3/CircularNotices.svg?branch=master)](https://travis-ci.org/NetCommons3/CircularNotices) -[![Coverage Status](https://img.shields.io/coveralls/NetCommons3/CircularNotices.svg)](https://coveralls.io/r/NetCommons3/CircularNotices?branch=master) - -| dependencies | status | -| ------------ | ------ | -| composer.json | [![Dependency Status](https://www.versioneye.com/user/projects/54d34c21ee3836ec1000002a/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54d34c21ee3836ec1000002a) | - - - +[![Tests Status](https://github.com/NetCommons3/CircularNotices/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/CircularNotices/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/CircularNotices/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/CircularNotices?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/circular-notices.svg?label=stable)](https://packagist.org/packages/netcommons/circular-notices) diff --git a/Test/Case/AllCircularNoticesTest.php b/Test/Case/AllCircularNoticesTest.php index 2eb94dc..18e66eb 100644 --- a/Test/Case/AllCircularNoticesTest.php +++ b/Test/Case/AllCircularNoticesTest.php @@ -9,6 +9,8 @@ * @copyright Copyright 2014, NetCommons Project */ +App::uses('NetCommonsTestSuite', 'NetCommons.TestSuite'); + /** * CircularNotices All Test Case * @@ -25,7 +27,7 @@ class AllCircularNoticesTest extends CakeTestSuite { */ public static function suite() { $plugin = preg_replace('/^All([\w]+)Test$/', '$1', __CLASS__); - $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin)); + $suite = new NetCommonsTestSuite(sprintf('All %s Plugin tests', $plugin)); $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case'); return $suite; } diff --git a/Test/Case/Config/RoutesTest.php b/Test/Case/Config/RoutesTest.php deleted file mode 100644 index 4b0800a..0000000 --- a/Test/Case/Config/RoutesTest.php +++ /dev/null @@ -1,78 +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 = 'circular_notices'; - -/** - * DataProvider - * - * ### 戻り値 - * - url URL - * - expected 期待値 - * - * @return array テストデータ - */ - public function dataProvider() { - return array( - array( - 'url' => '/circular_notices/circular_notices/view/1/content_key', - 'expected' => array( - 'plugin' => 'circular_notices', 'controller' => 'circular_notices', 'action' => 'view', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - array( - 'url' => '/circular_notices/circular_notices/edit/1/content_key', - 'expected' => array( - 'plugin' => 'circular_notices', 'controller' => 'circular_notices', 'action' => 'edit', - 'block_id' => '1', 'key' => 'content_key' - ) - ), - array( - 'url' => '/circular_notices/circular_notices/delete/1/content_key', - 'expected' => array( - 'plugin' => 'circular_notices', 'controller' => 'circular_notices', 'action' => 'delete', - 'block_id' => '1', 'key' => 'content_key' - ) - ), - array( - 'url' => '/circular_notices/circular_notices/download/1/content_key', - 'expected' => array( - 'plugin' => 'circular_notices', 'controller' => 'circular_notices', 'action' => 'download', - 'block_id' => '1', 'key' => 'content_key', - ) - ), - ); - } - -} diff --git a/Test/Case/Controller/CircularNoticesController/DownloadTest.php b/Test/Case/Controller/CircularNoticesController/DownloadTest.php index e2d5793..351fc33 100644 --- a/Test/Case/Controller/CircularNoticesController/DownloadTest.php +++ b/Test/Case/Controller/CircularNoticesController/DownloadTest.php @@ -190,7 +190,10 @@ public function testDownload($urlOptions, $data, $assert, $exception = null, $re ); $this->controller->request->params['key'] = $urlOptions['key']; $this->controller->request->data = $data; - Current::initialize($this->controller); + + $instance = Current::getInstance(); + $instance->initialize($this->controller); + $id = empty($urlOptions['frame_id']) ? '6' : $urlOptions['frame_id']; Current::write('Frame', [ 'id' => $id, diff --git a/Test/Case/Controller/CircularNoticesController/EditTest.php b/Test/Case/Controller/CircularNoticesController/EditTest.php index 5c48253..0f52d19 100644 --- a/Test/Case/Controller/CircularNoticesController/EditTest.php +++ b/Test/Case/Controller/CircularNoticesController/EditTest.php @@ -93,6 +93,7 @@ public function dataProviderEdit() { $results[0] = array( 'urlOptions' => Hash::insert($data, 'frame_id', ''), 'assert' => null, + 'exception' => 'BadRequestException' ); $results[1] = array( 'urlOptions' => Hash::insert($data, 'key', 'A'), @@ -105,7 +106,8 @@ public function dataProviderEdit() { ); $results[3] = array( 'urlOptions' => Hash::insert($data, 'key', 'circular_notice_content_4'), - 'assert' => array('method' => 'assertNotEmpty'), + 'assert' => null, + 'exception' => 'BadRequestException' ); return $results; diff --git a/Test/Case/Controller/CircularNoticesController/ParseAnswerTest.php b/Test/Case/Controller/CircularNoticesController/ParseAnswerTest.php index 8741440..a458e11 100644 --- a/Test/Case/Controller/CircularNoticesController/ParseAnswerTest.php +++ b/Test/Case/Controller/CircularNoticesController/ParseAnswerTest.php @@ -65,6 +65,7 @@ public function dataProviderParseAnswer() { 'reply_text_value' => 'Lorem ipsum dolor sit amet' ), ), + 'choices' => array() ), 'assert' => 'Lorem ipsum dolor sit amet' ); @@ -78,8 +79,14 @@ public function dataProviderParseAnswer() { 'reply_selection_value' => '1|3', ), ), + 'choices' => array( + 1 => array('id' => 1, 'value' => 'AAA'), + 2 => array('id' => 2, 'value' => 'BBB'), + 3 => array('id' => 3, 'value' => 'CCC'), + 4 => array('id' => 4, 'value' => 'DDD') + ) ), - 'assert' => '1、3' + 'assert' => 'AAA、CCC' ); return $results; @@ -103,7 +110,8 @@ public function testParseAnswer($data, $assert, $exception = null) { $result = $method->invoke( $stub, $data['CircularNoticeContent']['reply_type'], - $data['CircularNoticeTargetUser'] + $data['CircularNoticeTargetUser'], + $data['choices'] ); $this->assertEquals($result, $assert); } diff --git a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticeFrameSettingsEditFormController.php b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticeFrameSettingsEditFormController.php index 72f92c6..6c4f6dd 100644 --- a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticeFrameSettingsEditFormController.php +++ b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticeFrameSettingsEditFormController.php @@ -27,6 +27,7 @@ class TestViewElementsCircularNoticeFrameSettingsEditFormController extends AppC public $helpers = array( 'Mails.MailsHtml', 'Mails.MailForm', + 'NetCommons.DisplayNumber', ); /** diff --git a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesSubjectEditFormController.php b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesSubjectEditFormController.php index d7ce550..6fd88fb 100644 --- a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesSubjectEditFormController.php +++ b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesSubjectEditFormController.php @@ -19,6 +19,15 @@ */ class TestViewElementsCircularNoticesSubjectEditFormController extends AppController { +/** + * use helpers + * + * @var array + */ + public $helpers = array( + 'NetCommons.TitleIcon', + ); + /** * subject_edit_form * diff --git a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesTargetEditFormController.php b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesTargetEditFormController.php index fa7fdb4..d6fa86a 100644 --- a/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesTargetEditFormController.php +++ b/Test/test_app/Plugin/TestCircularNotices/Controller/TestViewElementsCircularNoticesTargetEditFormController.php @@ -19,6 +19,15 @@ */ class TestViewElementsCircularNoticesTargetEditFormController extends AppController { +/** + * use helpers + * + * @var array + */ + public $helpers = array( + 'Groups.GroupUserList', + ); + /** * target_edit_form * 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/CircularNotices/edit.ctp b/View/CircularNotices/edit.ctp index 82bddc4..a0fecc9 100644 --- a/View/CircularNotices/edit.ctp +++ b/View/CircularNotices/edit.ctp @@ -57,6 +57,11 @@ 'value' => Current::read('Block.id'), )); ?> + + NetCommonsForm->hidden('Block.key', array( + 'value' => Current::read('Block.key'), + )); ?> + NetCommonsForm->hidden('CircularNoticeContent.id', array( 'value' => isset($circularNoticeContent['id']) ? $circularNoticeContent['id'] : null, )); ?> diff --git a/View/CircularNotices/index.ctp b/View/CircularNotices/index.ctp index 1f7ea24..5451225 100644 --- a/View/CircularNotices/index.ctp +++ b/View/CircularNotices/index.ctp @@ -79,6 +79,15 @@ element('CircularNotices/status_label', array( 'circularNoticeContent' => $circularNoticeContent['CircularNoticeContent']) ); ?> + + + +
+ + + CircularNotice->displayDate($circularNoticeContent['CircularNoticeContent']['reply_deadline']); ?> + +
diff --git a/View/CircularNotices/view.ctp b/View/CircularNotices/view.ctp index 3cae1fd..9fbf2fa 100644 --- a/View/CircularNotices/view.ctp +++ b/View/CircularNotices/view.ctp @@ -24,6 +24,12 @@ ) ); ?> +
@@ -179,10 +185,8 @@ )); break; case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_SELECTION: - $selections = array(); $selected = ''; foreach ($circularNoticeChoice as $choice) : - $selections[$choice['id']] = $choice['value']; if ($choice['id'] === $myAnswer['CircularNoticeTargetUser']['reply_selection_value']) : $selected = $choice['id']; endif; @@ -197,11 +201,9 @@ )); break; case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_MULTIPLE_SELECTION: - $selections = array(); $selected = explode(CircularNoticeComponent::SELECTION_VALUES_DELIMITER, $myAnswer['CircularNoticeTargetUser']['reply_selection_value']); $selectedValue = array(); foreach ($circularNoticeChoice as $choices) : - $selections[$choices['id']] = $choices['value']; if (in_array($choices['id'], $selected, true)) : $selectedValue[] = $choices['value']; endif; @@ -331,7 +333,7 @@ $answer = null; switch ($circularNoticeContent['reply_type']) { case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_TEXT: - $answer = nl2br(h($circularNoticeTargetUser['CircularNoticeTargetUser']['reply_text_value'])); + $answer = $circularNoticeTargetUser['CircularNoticeTargetUser']['reply_text_value']; break; case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_SELECTION: case CircularNoticeComponent::CIRCULAR_NOTICE_CONTENT_REPLY_TYPE_MULTIPLE_SELECTION: @@ -362,7 +364,7 @@ $this->NetCommonsHtml->handleLink($circularNoticeTargetUser, array('avatar' => true), array(), 'User'), array($readDatetime, array('class' => 'row-datetime')), array($replyDatetime, array('class' => 'row-datetime')), - array(h($answer), array('class' => 'circular-notices-reply-col circular-notices-word-break')), + array(nl2br(h($answer)), array('class' => 'circular-notices-reply-col circular-notices-word-break')), )); endforeach; ?> diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b16e5da..1154cd3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,8 @@ + + + app/Plugin/CircularNotices @@ -14,6 +17,6 @@ - +