diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9501566..6da4321 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,22 +3,21 @@ on: branches: - main - master - - availability pull_request: branches: - main - master - - availability 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 +27,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' ] @@ -44,6 +43,7 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 @@ -91,46 +91,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 @@ -138,7 +145,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 @@ -147,13 +154,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 diff --git a/Controller/ReservationFrameSettingsController.php b/Controller/ReservationFrameSettingsController.php index 1bcac62..f9441ac 100644 --- a/Controller/ReservationFrameSettingsController.php +++ b/Controller/ReservationFrameSettingsController.php @@ -120,6 +120,11 @@ public function edit() { $this->view = 'nolocation'; return; } + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $locations = $openText->openTextAdd($locations); + $this->set('locations', $locations); // 設定情報取り出し diff --git a/Controller/ReservationImportController.php b/Controller/ReservationImportController.php index b1fd4f8..07b6078 100644 --- a/Controller/ReservationImportController.php +++ b/Controller/ReservationImportController.php @@ -131,6 +131,11 @@ public function beforeFilter() { public function edit() { // 施設情報 $locations = $this->ReservationLocation->getReservableLocations(); + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $locations = $openText->openTextAdd($locations); + $this->set('locations', $locations); $frameId = Current::read('Frame.id'); diff --git a/Controller/ReservationLocationsController.php b/Controller/ReservationLocationsController.php index dddb01a..029081d 100644 --- a/Controller/ReservationLocationsController.php +++ b/Controller/ReservationLocationsController.php @@ -94,6 +94,11 @@ public function index() { 'ReservationLocation' => $query ]; $reservationLocations = $this->Paginator->paginate('ReservationLocation'); + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $reservationLocations = $openText->openTextAdd($reservationLocations); + $this->set('reservationLocations', $reservationLocations); } @@ -377,6 +382,11 @@ public function sort() { 'ReservationLocation' => $query ]; $reservationLocations = $this->Paginator->paginate('ReservationLocation'); + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $reservationLocations = $openText->openTextAdd($reservationLocations); + $this->set('reservationLocations', $reservationLocations); $this->request->data['ReservationLocations'] = $reservationLocations; diff --git a/Controller/ReservationPlansController.php b/Controller/ReservationPlansController.php index 5d54673..3922f10 100644 --- a/Controller/ReservationPlansController.php +++ b/Controller/ReservationPlansController.php @@ -153,7 +153,7 @@ public function beforeFilter() { ReservationPermissiveRooms::setRoomPermRoles($this->roomPermRoles); // 表示のための各種共通パラメータ設定 - $this->_vars = $this->getVarsForShow(); + $this->_vars = $this->__getVarsForShow(); } /** @@ -288,6 +288,11 @@ public function delete() { public function add() { // 施設情報 $locations = $this->ReservationLocation->getReservableLocations(); + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $locations = $openText->openTextAdd($locations); + $locations = $this->__mergeApprovalUserName($locations); $this->set('locations', $locations); @@ -330,6 +335,10 @@ public function add() { */ public function edit() { if ($this->request->is('post')) { + $editRrule = $this->ReservationActionPlan->getEditRruleForUpdate($this->request->data); + if ($editRrule == ReservationAppBehavior::CALENDAR_PLAN_EDIT_THIS) { + $this->request->data['ReservationActionPlan']['is_repeat'] = '0'; + } $this->_reservationPost(); } // 表示のための処理 @@ -343,6 +352,11 @@ public function edit() { // 施設情報 $locations = $this->ReservationLocation->getReservableLocations(); + + // openTextの追加 + $openText = new ReservationLocationOpenText(); + $locations = $openText->openTextAdd($locations); + $locations = $this->__mergeApprovalUserName($locations); $this->set('locations', $locations); @@ -617,7 +631,7 @@ public function view() { * @return void * @throws InternalErrorException */ - public function getVarsForShow() { + private function __getVarsForShow() { $vars = array(); $this->setReservationCommonVars($vars); diff --git a/Controller/ReservationsController.php b/Controller/ReservationsController.php index bce74ec..b06c2e5 100644 --- a/Controller/ReservationsController.php +++ b/Controller/ReservationsController.php @@ -119,6 +119,11 @@ public function index() { } $categoryId = Hash::get($this->request->params['named'], 'category_id'); + if ($categoryId === '') { + // タブ切り替えや前後ページングで'カテゴリ選択'だとcategory_idが空文字になるので + // そのときはnull(カテゴリの指定無し)にする + $categoryId = null; + } $locations = $this->ReservationLocation->getLocations($categoryId); @@ -163,6 +168,7 @@ public function index() { $frameId = Current::read('Frame.id'); $languageId = Current::read('Language.id'); $this->set(compact('frameId', 'languageId', 'vars')); + $this->set('unselectedCategory', $this->ReservationLocation->getCountUnselectedCategory()); $this->render($ctpName); //$roomId = Current::read('Room.id'); @@ -232,7 +238,7 @@ protected function _getWeeklyVars($vars) { * @param array $vars カレンンダー情報 * @return array $vars 日単位(一覧)データ */ - public function getDailyListVars($vars) { + protected function _getDailyListVars($vars) { $this->setReservationCommonVars($vars); $vars['tab'] = 'list'; return $vars; @@ -261,7 +267,7 @@ protected function _getDailyVars($vars) { //if ($tab === 'timeline') { $vars = $this->_getDailyTimelineVars($vars); //} else { - // $vars = $this->getDailyListVars($vars); + // $vars = $this->_getDailyListVars($vars); //} $vars['selectRooms'] = array(); //マージ前の暫定 diff --git a/Lib/ReservationLocationOpenText.php b/Lib/ReservationLocationOpenText.php index 63b0535..845e531 100644 --- a/Lib/ReservationLocationOpenText.php +++ b/Lib/ReservationLocationOpenText.php @@ -78,4 +78,22 @@ public function openText($reservationLocation) { } return $ret; } + +/** + * openTextをセットした施設データを返す + * + * @param array $reservationLocations 施設データ + * @return array + */ + public function openTextAdd($reservationLocations) { + foreach ($reservationLocations as $key => $value) { + if (array_key_exists('time_table', $value['ReservationLocation']) && + array_key_exists('start_time', $value['ReservationLocation']) && + array_key_exists('end_time', $value['ReservationLocation']) && + array_key_exists('timezone', $value['ReservationLocation'])) { + $reservationLocations[$key]['ReservationLocation']['openText'] = $this->openText($value); + } + } + return $reservationLocations; + } } \ No newline at end of file diff --git a/Model/Behavior/ReservationPlanGenerationBehavior.php b/Model/Behavior/ReservationPlanGenerationBehavior.php index 730a9eb..2b08ed8 100644 --- a/Model/Behavior/ReservationPlanGenerationBehavior.php +++ b/Model/Behavior/ReservationPlanGenerationBehavior.php @@ -69,18 +69,22 @@ public function makeCurGenPlan(Model $model, $data, * @param string $status status 変更時の施設予約独自の新status * @param int $createdUserWhenUpd createdUserWhenUpd * @param bool $isMyPrivateRoom isMyPrivateRoom + * @param string|int $editRrule 編集ルール(この予約のみ、これ以降に指定した全ての予約、設定した全ての予約) * @return int 生成成功時 新しく生成した次世代予定($plan)を返す。失敗時 InternalErrorExceptionを投げる。 * @throws InternalErrorException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function makeNewGenPlan(Model $model, $data, $status, - $createdUserWhenUpd, $isMyPrivateRoom) { + $createdUserWhenUpd, $isMyPrivateRoom, $editRrule) { $action = 'update'; $plan = $this->__makeCommonGenPlan($model, $action, $data, $data['ReservationActionPlan']['origin_rrule_id']); //keyが同じrrule -> key同一のevents -> eventsの各子供をcopy保存する - $plan = $this->__copyRruleData($model, $plan, $createdUserWhenUpd); + $plan = $this->__copyRruleData($model, $plan, $createdUserWhenUpd, $editRrule); + + $baseDate = str_replace('-', '', $data['ReservationActionPlanForDisp']['detail_start_datetime']); unset($plan['new_event_id']); //念のため変数クリア $effectiveEvents = array(); //有効なeventだけを格納する配列を用意 @@ -90,6 +94,17 @@ public function makeNewGenPlan(Model $model, $data, $status, if ($event['exception_event_id'] >= 1) { continue; } + if ($editRrule == self::CALENDAR_PLAN_EDIT_THIS && + $data['ReservationActionPlan']['origin_event_id'] != $event['id']) { + //この予約のみの場合、自分自身の予約以外は無視する。 + continue; + } + if ($editRrule == self::CALENDAR_PLAN_EDIT_AFTER && + $data['ReservationActionPlan']['origin_event_id'] != $event['id'] && + $baseDate > $event['start_date']) { + //これ以降に指定した全ての予約の場合、基準日より過去のものは無視する。 + continue; + } $newEventId = $newEventKey = null; list($event, $newEventId, $newEventKey) = $this->__copyEventData($model, @@ -123,10 +138,11 @@ public function makeNewGenPlan(Model $model, $data, $status, * @param Model $model 実際のモデル名 * @param array $plan plan * @param int $createdUserWhenUpd createdUserWhenUpd + * @param string|int $editRrule 編集ルール(この予約のみ、これ以降に指定した全ての予約、設定した全ての予約) * @return int 生成成功時 新しい$planを返す。失敗時 InternalErrorExceptionを投げる。 * @throws InternalErrorException */ - private function __copyRruleData(Model $model, $plan, $createdUserWhenUpd) { + private function __copyRruleData(Model $model, $plan, $createdUserWhenUpd, $editRrule) { //ReservationRruleには、status, is_latest, is_activeはない。 $rruleData = array(); @@ -135,6 +151,9 @@ private function __copyRruleData(Model $model, $plan, $createdUserWhenUpd) { //次世代データの新規登録 $originRruleId = $rruleData['ReservationRrule']['id']; $rruleData['ReservationRrule']['id'] = null; + if ($editRrule == self::CALENDAR_PLAN_EDIT_THIS) { + $rruleData['ReservationRrule']['rrule'] = ''; + } //作成者・作成日は原則、元予定のデータを引き継ぐ、、、が!例外がある。 //例外追加1) @@ -249,6 +268,8 @@ private function __copyEventData(Model $model, $event, $reservationRruleId, $sta //セットするようにした。 $model->ReservationEvent->prepareLatestCreatedForIns($eventData, $createdUserWhenUpd); + // $eventDataがprepareLatestCreatedForIns()で変更されるので、再度setする + $model->ReservationEvent->set($eventData); //子もsave()で返ってくる。 $eventData = $model->ReservationEvent->save(null, false); //aaaaaaaaaaaaa if (!$eventData) { //保存のみ diff --git a/Model/Behavior/ReservationUpdatePlanBehavior.php b/Model/Behavior/ReservationUpdatePlanBehavior.php index 1abe057..d9e9b53 100644 --- a/Model/Behavior/ReservationUpdatePlanBehavior.php +++ b/Model/Behavior/ReservationUpdatePlanBehavior.php @@ -398,6 +398,8 @@ public function updateDtstartData(Model $model, $planParams, $rruleData, $eventD //is_active調整処理を行う。(eventDataの値が一部変更されます) $model->ReservationEvent->prepareActiveForUpd($eventData); + // $eventDataがprepareActiveForUpd()で変更されるので、再度setする + $model->ReservationEvent->set($eventData); if (!$model->ReservationEvent->save(null, array( 'validate' => false, diff --git a/Model/Behavior/ReservationWorkflowBehavior.php b/Model/Behavior/ReservationWorkflowBehavior.php index e67df2d..9a15ea1 100644 --- a/Model/Behavior/ReservationWorkflowBehavior.php +++ b/Model/Behavior/ReservationWorkflowBehavior.php @@ -33,9 +33,16 @@ public function beforeValidate(Model $model, $options = array()) { * * @param Model $model Model using this behavior * @param array $conditions Model::find conditions default value + * @param bool $useCommentCreatable コメントの作成権限でもチェックするかどうか * @return array Conditions data + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function getWorkflowConditions(Model $model, $conditions = array()) { + public function getWorkflowConditions( + Model $model, + $conditions = array(), + $useCommentCreatable = false + ) { // is_active = 1は常に表示 $activeConditions = [ $model->alias . '.is_active' => true, @@ -88,14 +95,21 @@ public function getWorkflowConditions(Model $model, $conditions = array()) { * @param Model $model Model using this behavior * @param string $type Type of find operation (all / first / count / neighbors / list / threaded) * @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks) + * @param bool $useCommentCreatable コメントの作成権限でもチェックするかどうか * @return array Conditions data + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function getWorkflowContents(Model $model, $type, $query = array()) { + public function getWorkflowContents( + Model $model, + $type, + $query = array(), + $useCommentCreatable = false + ) { //$this->log(var_export(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5), true), 'debug'); $query = Hash::merge(array( 'recursive' => -1, - 'conditions' => $this->getWorkflowConditions($model) + 'conditions' => $this->getWorkflowConditions($model, [], $useCommentCreatable) ), $query); return $model->find($type, $query); diff --git a/Model/ReservationActionPlan.php b/Model/ReservationActionPlan.php index 2dc8c52..72e05cc 100644 --- a/Model/ReservationActionPlan.php +++ b/Model/ReservationActionPlan.php @@ -574,7 +574,7 @@ public function validteNotExistReservation($check) { // 全ての予約を更新 $ignoreConditions = [ 'NOT' => [ - 'ReservationEvent.rrule_id' => + 'ReservationEvent.reservation_rrule_id' => Hash::get($this->data, 'ReservationActionPlan.origin_rrule_id'), 'ReservationEvent.recurrence_event_id !=' => 0, 'ReservationEvent.exception_event_id !=' => 0, @@ -910,9 +910,14 @@ public function saveReservationPlan($data, $procMode, //3. isMyPrivateRoomは、変更後の公開ルームidが「編集者・承認者(=ログイン者)のプライベート」以外の場合、 //仲間の予定はプライベートの時のみ許される子情報なので、これらはcopy対象から外す(stripする)例外処理用。 // - $newPlan = $this->makeNewGenPlan($data, $status, $createdUserWhenUpd, $isMyPrivateRoom); - $editRrule = $this->getEditRruleForUpdate($data); + $newPlan = $this->makeNewGenPlan( + $data, + $status, + $createdUserWhenUpd, + $isMyPrivateRoom, + $editRrule + ); $isInfoArray = array($isOriginRepeat, $isTimeMod, $isRepeatMod, $isMyPrivateRoom); $eventId = $this->updatePlan($planParam, $newPlan, $status, $isInfoArray, $editRrule, diff --git a/Model/ReservationLocation.php b/Model/ReservationLocation.php index 180b309..9866a4e 100644 --- a/Model/ReservationLocation.php +++ b/Model/ReservationLocation.php @@ -188,32 +188,6 @@ public function beforeFind($query) { return true; } -/** - * Called after each find operation. Can be used to modify any results returned by find(). - * Return value should be the (modified) results. - * - * @param mixed $results The results of the find operation - * @param bool $primary Whether this model is being queried directly (vs. being queried as an association) - * @return mixed Result of the find operation - * @SuppressWarnings(PHPMD.BooleanArgumentFlag) - * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#afterfind - */ - public function afterFind($results, $primary = false) { - if (!isset($results[0][$this->alias])) { - return $results; - } - foreach ($results as $key => $value) { - if (array_key_exists('time_table', $results[$key][$this->alias]) && - array_key_exists('start_time', $results[$key][$this->alias]) && - array_key_exists('end_time', $results[$key][$this->alias]) && - array_key_exists('timezone', $results[$key][$this->alias])) { - $openText = new ReservationLocationOpenText(); - $results[$key][$this->alias]['openText'] = $openText->openText($value); - } - } - return $results; - } - /** * Called before each save operation, after validation. Return a non-true result * to halt the save. @@ -662,6 +636,19 @@ protected function _prepareData($data) { return $data; } +/** + * カテゴリーをセットしていない施設件数を取得する + * + * @return int + */ + public function getCountUnselectedCategory() { + $count = $this->find('count', [ + 'conditions' => ['category_id' => null], + ]); + + return $count; + } + /** * getAliveCondition * 現在使用中状態であるか判断する。CleanUpプラグインで使用 diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.7 diff --git a/View/Elements/Reservations/dropdown_category.ctp b/View/Elements/Reservations/dropdown_category.ctp index e507de6..d34a899 100644 --- a/View/Elements/Reservations/dropdown_category.ctp +++ b/View/Elements/Reservations/dropdown_category.ctp @@ -13,6 +13,9 @@ // '' => 'カテゴリ選択' // '0' => カテゴリ無し // となるように事前準備 +if (! isset($unselectedCategory)) { + $unselectedCategory = true; +} $categories = $this->get('categories'); array_unshift($categories, [ @@ -23,15 +26,28 @@ array_unshift($categories, 'name' => __d('categories', 'Select Category') ] ], - [ - 'Category' => [ - 'id' => '0', +); +if ($unselectedCategory) { + array_unshift($categories, + [ + 'Category' => [ + 'id' => null, + ], + 'CategoriesLanguage' => [ + 'name' => __d('categories', 'Select Category') + ] ], - 'CategoriesLanguage' => [ - 'name' => __d('reservations', 'no category') + [ + 'Category' => [ + 'id' => '0', + ], + 'CategoriesLanguage' => [ + 'name' => __d('reservations', 'no category') + ] ] - ] ); +} + $this->set('categories', $categories); // CategoryHelper用にムリヤリcategory_id=""をセット if (!isset($this->request->params['named']['category_id'])) { @@ -55,4 +71,4 @@ echo $this->Category->dropDownToggle(array( // ムリヤリnamedを書き換えたので元にもどす if (isset($isOverwrite)) { unset($this->request->params['named']['category_id']); -} \ No newline at end of file +} diff --git a/View/Elements/Reservations/weekly_timeline_element.ctp b/View/Elements/Reservations/weekly_timeline_element.ctp index aedf192..c5e8bd8 100644 --- a/View/Elements/Reservations/weekly_timeline_element.ctp +++ b/View/Elements/Reservations/weekly_timeline_element.ctp @@ -98,6 +98,7 @@
';
diff --git a/View/Helper/ReservationWeeklyTimelineHelper.php b/View/Helper/ReservationWeeklyTimelineHelper.php
index 1b877ab..7319de0 100644
--- a/View/Helper/ReservationWeeklyTimelineHelper.php
+++ b/View/Helper/ReservationWeeklyTimelineHelper.php
@@ -47,6 +47,15 @@ public function getTimelineData() {
return $this->_timelineData;
}
+/**
+ * TimelineDataをクリア
+ *
+ * @return array
+ */
+ public function clearTimelineData() {
+ $this->_timelineData = [];
+ }
+
/**
* getPlanSummariesHtml
*
diff --git a/View/Reservations/all_weekly.ctp b/View/Reservations/all_weekly.ctp
index 600ac57..cdace31 100644
--- a/View/Reservations/all_weekly.ctp
+++ b/View/Reservations/all_weekly.ctp
@@ -25,7 +25,7 @@ echo $this->element('Reservations.scripts');
ReservationTurnReservation->getTurnReservationOperationsWrap('week',
'top', $vars); ?>
-
@@ -174,3 +159,15 @@ echo $this->NetCommonsHtml->script(array(
+
diff --git a/View/Reservations/weekly_by_location.ctp b/View/Reservations/weekly_by_location.ctp
index 615b5ae..70876af 100644
--- a/View/Reservations/weekly_by_location.ctp
+++ b/View/Reservations/weekly_by_location.ctp
@@ -39,7 +39,8 @@ echo $this->element('Reservations.scripts');
$startTime = date('G', strtotime($userNow) - 60 * 60);
}
?>
-