Skip to content

[フレーム設定] 公開設定に ログイン後表示 を追加 OW-2077 #1885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Enums/ContentOpenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ final class ContentOpenType extends EnumsBase
const always_close = 2;
const limited_open = 3;
const login_close = 4;
const login_open = 5;

// key/valueの連想配列
const enum = [
self::always_open => '公開',
self::always_close => '非公開',
self::limited_open => '限定公開',
self::login_close => 'ログイン後非表示',
self::login_open => 'ログイン後表示',
];
}
23 changes: 15 additions & 8 deletions app/Models/Common/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,27 @@ public function isVisible($page = null, $user = null)
*/
public function isInvisiblePrivateFrame()
{
// 非ログインまたはフレーム編集権限を持たない、且つ、非表示条件(非公開、又は、限定公開、又は、ログイン後非表示)にマッチした場合はフレームを非表示にする
// 非ログインまたはフレーム編集権限を持たない、且つ、非表示条件(非公開、又は、限定公開、又は、ログイン後非表示、又は、ログイン後表示(未ログインで非表示))にマッチした場合はフレームを非表示にする

if (Auth::check() && Auth::user()->can('role_arrangement') && app('request')->input('mode') != 'preview') {
// 表示
return false;
}

if ($this->content_open_type == ContentOpenType::always_close ||
(
$this->content_open_type == ContentOpenType::limited_open &&
!Carbon::now()->between($this->content_open_date_from, $this->content_open_date_to)
) ||
(Auth::check() && $this->content_open_type == ContentOpenType::login_close)
) {
if ($this->content_open_type == ContentOpenType::always_close) {
// 非表示
return true;

} elseif ($this->content_open_type == ContentOpenType::limited_open &&
!Carbon::now()->between($this->content_open_date_from, $this->content_open_date_to)) {
// 非表示
return true;

} elseif ($this->content_open_type == ContentOpenType::login_close && Auth::check()) {
// 非表示
return true;

} elseif ($this->content_open_type == ContentOpenType::login_open && !Auth::check()) {
// 非表示
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/core/cms_frame_edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
<div id="app_{{ $frame->id }}">
{{-- コンテンツ公開区分 --}}
<div class="form-group row">
<label class="{{$frame->getSettingLabelClass(true)}}">公開設定</label>
<div class="{{$frame->getSettingInputClass(true)}}">
<label class="{{$frame->getSettingLabelClass()}} pt-0">公開設定</label>
<div class="{{$frame->getSettingInputClass()}}">
@foreach (ContentOpenType::enum as $key => $value)
<div class="custom-control custom-radio custom-control-inline">
<input
Expand Down
33 changes: 18 additions & 15 deletions resources/views/core/cms_frame_header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,24 @@
@endif
@endif

{{-- 公開以外の場合にステータス表示 ※デフォルト状態の公開もステータス表示すると画面表示が煩雑になる為、意識的な設定(非公開、又は、限定公開)のみステータス表示を行う --}}
@if (Auth::check() && $frame->content_open_type != ContentOpenType::always_open)
<small>
<span class="badge badge-warning">
<a href="{{URL::to('/')}}/plugin/{{$frame->plugin_name}}/frame_setting/{{$page->id}}/{{$frame->id}}#frame-{{$frame->id}}">
<i class="fas fa-cog"></i>
</a>
{{ ContentOpenType::getDescription($frame->content_open_type) }}
@if ($frame->content_open_type == ContentOpenType::limited_open)
{{-- 期限付き公開の場合は日付も表示 --}}
{{ '(' . Carbon::parse($frame->content_open_date_from)->format('Y/n/j H:i:s') . ' - ' . Carbon::parse($frame->content_open_date_to)->format('Y/n/j H:i:s') . ')' }}
@endif
</span>
</small>
@endif
{{-- 権限あり & 公開以外の場合にステータス表示 ※デフォルト状態の公開もステータス表示すると画面表示が煩雑になる為、意識的な設定(非公開、又は、限定公開)のみステータス表示を行う --}}
@can('frames.edit',[[null, null, null, $frame]])
@if ($frame->content_open_type != ContentOpenType::always_open)
<small>
<span class="badge badge-warning">
<a href="{{URL::to('/')}}/plugin/{{$frame->plugin_name}}/frame_setting/{{$page->id}}/{{$frame->id}}#frame-{{$frame->id}}">
<i class="fas fa-cog"></i>
</a>
{{ ContentOpenType::getDescription($frame->content_open_type) }}
@if ($frame->content_open_type == ContentOpenType::limited_open)
{{-- 期限付き公開の場合は日付も表示 --}}
{{ '(' . Carbon::parse($frame->content_open_date_from)->format('Y/n/j H:i:s') . ' - ' . Carbon::parse($frame->content_open_date_to)->format('Y/n/j H:i:s') . ')' }}
@endif
</span>
</small>
@endif
@endcan

{{-- ログインしていて、権限があれば、編集機能を有効にする --}}
{{--
@if (Auth::check() &&
Expand Down