Skip to content

Commit a6dc51c

Browse files
authored
Merge branch 'master' into 2
2 parents ce6bded + 4d2a026 commit a6dc51c

28 files changed

+860
-19
lines changed

app/Http/Controllers/Auth/LoginController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,18 @@ public function showLoginForm()
201201
$path = parse_url($_SERVER['HTTP_REFERER']); // URLを分解
202202
if (array_key_exists('host', $path)) {
203203
if ($path['host'] == $_SERVER['HTTP_HOST']) { // ホスト部分が自ホストと同じ
204-
session(['url.intended' => $_SERVER['HTTP_REFERER']]);
204+
//session(['url.intended' => $_SERVER['HTTP_REFERER']]);
205+
session()->flash('url.intended', $_SERVER['HTTP_REFERER']);
205206
}
206207
}
207208
}
208209
} elseif ($base_login_redirect_previous_page == BaseLoginRedirectPage::specified_page) {
209210
// 指定したページに遷移
210211
$base_login_redirect_select_page = Configs::getConfigsValue($configs, 'base_login_redirect_select_page', RouteServiceProvider::HOME);
211-
session(['url.intended' => $base_login_redirect_select_page]);
212+
// セッションへの保持の場合、トップページに置いたログイン・プラグインの「ログイン後に移動する指定ページ」が影響してうまく移動しない場合があったのでフラッシュ・セッションへ変更
213+
// ログイン画面は表示された後、ログイン ⇒ ページ移動の流れになるため、フラッシュ・セッションで問題ないと判断した。
214+
//session(['url.intended' => $base_login_redirect_select_page]);
215+
session()->flash('url.intended', $base_login_redirect_select_page);
212216
}
213217

214218
// サイトテーマ詰込

app/Models/User/Logins/Login.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Models\User\Logins;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\SoftDeletes;
7+
8+
use App\UserableNohistory;
9+
10+
/**
11+
* ログイン・プラグイン
12+
*
13+
* @author 永原 篤 <nagahara@opensource-workshop.jp>
14+
* @copyright OpenSource-WorkShop Co.,Ltd. All Rights Reserved
15+
* @category ログイン・プラグイン
16+
* @package Model
17+
*/
18+
class Login extends Model
19+
{
20+
// 論理削除
21+
use SoftDeletes;
22+
23+
// 保存時のユーザー関連データの保持(履歴なしUserable)
24+
use UserableNohistory;
25+
26+
// 更新する項目の定義
27+
protected $fillable = ['bucket_id', 'name', 'redirect_page'];
28+
}

app/Plugins/User/Calendars/CalendarsPlugin.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
use App\Rules\CustomValiWysiwygMax;
2222

2323
use App\Utilities\File\FileUtils;
24+
use Carbon\Carbon;
25+
use Carbon\CarbonImmutable;
26+
use Carbon\Exceptions\Exception;
2427

2528
/**
2629
* カレンダー・プラグイン
@@ -350,8 +353,7 @@ public function edit($request, $page_id, $frame_id, $post_id = null)
350353

351354
// id が空なら、新規オブジェクトとみなして、デフォルトの日付を設定して画面を表示する。
352355
if (empty($post->id) && $request->filled("date")) {
353-
$post->start_date = $request->date;
354-
$post->end_date = $request->date;
356+
$post = $this->setInitDatetime($post, $request->date);
355357
}
356358

357359
// 変更画面を呼び出す。
@@ -672,4 +674,40 @@ public function changeBuckets($request, $page_id, $frame_id)
672674

673675
return;
674676
}
677+
678+
/**
679+
* 初期日時を設定する
680+
*
681+
* @param CalendarPost $post
682+
* @param string $date
683+
* @return CalendarPost
684+
*/
685+
private function setInitDatetime(CalendarPost $post, string $date): CalendarPost
686+
{
687+
// 想定しない形式の日付だったら初期日時を設定しない
688+
try {
689+
$init_date = Carbon::parse($date);
690+
} catch (Exception $e) {
691+
return $post;
692+
}
693+
694+
if ($init_date->isToday()) {
695+
// 当日は現在時刻から近い時刻を設定する
696+
$init_date = CarbonImmutable::now();
697+
$start_date = $init_date->addHour(1);
698+
$end_date = $init_date->addHour(2);
699+
$post->start_date = $start_date->format('Y-m-d');
700+
$post->start_time = $start_date->format('H:00');
701+
$post->end_date = $end_date->format('Y-m-d');
702+
$post->end_time = $end_date->format('H:00');
703+
} else {
704+
// 当日以外は9:00-10:00を設定する
705+
$post->start_date = $init_date->format('Y-m-d');
706+
$post->start_time = $init_date->format('09:00');
707+
$post->end_date = $init_date->format('Y-m-d');
708+
$post->end_time = $init_date->format('10:00');
709+
}
710+
711+
return $post;
712+
}
675713
}
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
<?php
2+
3+
namespace App\Plugins\User\Logins;
4+
5+
use Illuminate\Support\Collection;
6+
use Illuminate\Support\Facades\Log;
7+
use Illuminate\Support\Facades\Validator;
8+
9+
use App\Models\Common\Buckets;
10+
use App\Models\Common\Frame;
11+
use App\Models\Common\Page;
12+
use App\Models\User\Logins\Login;
13+
14+
use App\Plugins\User\UserPluginBase;
15+
16+
/**
17+
* ログイン・プラグイン
18+
* ログインのためのプラグイン
19+
*
20+
* @author 永原 篤 <nagahara@opensource-workshop.jp>
21+
* @copyright OpenSource-WorkShop Co.,Ltd. All Rights Reserved
22+
* @category ログイン・プラグイン
23+
* @package Plugin
24+
* @plugin_title ログイン
25+
* @plugin_desc 任意の場所にログイン画面を表示するプラグインです。
26+
*/
27+
class LoginsPlugin extends UserPluginBase
28+
{
29+
/* オブジェクト変数 */
30+
31+
/**
32+
* POST チェックに使用する getPost() 関数を使うか
33+
*/
34+
public $use_getpost = false;
35+
36+
/* コアから呼び出す関数 */
37+
38+
/**
39+
* 関数定義(コアから呼び出す)
40+
*/
41+
public function getPublicFunctions()
42+
{
43+
// 標準関数以外で画面などから呼ばれる関数の定義
44+
$functions = array();
45+
return $functions;
46+
}
47+
48+
/**
49+
* 追加の権限定義(コアから呼び出す)
50+
*/
51+
public function declareRole()
52+
{
53+
// 標準権限以外で設定画面などから呼ばれる権限の定義
54+
// 標準権限は右記で定義 config/cc_role.php
55+
//
56+
// 権限チェックテーブル
57+
$role_check_table = [];
58+
59+
return $role_check_table;
60+
}
61+
62+
/**
63+
* プラグインのバケツ取得関数
64+
*/
65+
private function getPluginBucket($bucket_id)
66+
{
67+
// プラグインのメインデータを取得する。
68+
return Login::firstOrNew(['bucket_id' => $bucket_id]);
69+
}
70+
71+
/* 画面アクション関数 */
72+
73+
/**
74+
* 初期表示取得関数
75+
*
76+
* @return view
77+
* @method_title ログイン表示
78+
* @method_desc オリジナルのログイン画面を作ることができます。
79+
* @method_detail ログイン後に移動する画面を指定することもできます。
80+
*/
81+
public function index($request, $page_id, $frame_id)
82+
{
83+
// ログイン後の指定画面があれば、指定画面へ
84+
if (!empty($this->buckets)) {
85+
$login = $this->getPluginBucket($this->buckets->id);
86+
if (!empty($login->redirect_page)) {
87+
session()->flash('url.intended', $login->redirect_page);
88+
}
89+
}
90+
91+
return $this->view('logins', [
92+
'page_id' => $page_id,
93+
]);
94+
}
95+
96+
/**
97+
* プラグインのバケツ選択表示関数
98+
*
99+
* @method_title 選択
100+
* @method_desc このフレームに表示するログインを選択します。
101+
* @method_detail
102+
*/
103+
public function listBuckets($request, $page_id, $frame_id, $id = null)
104+
{
105+
// 表示テンプレートを呼び出す。
106+
return $this->view('login_buckets', [
107+
'plugin_buckets' => Login::orderBy('created_at', 'desc')->paginate(10),
108+
]);
109+
}
110+
111+
/**
112+
* バケツ新規作成画面
113+
*
114+
* @method_title 作成
115+
* @method_desc ログインを新しく作成します。
116+
* @method_detail ログイン名を入力してログインを作成できます。
117+
*/
118+
public function createBuckets($request, $page_id, $frame_id)
119+
{
120+
// 処理的には編集画面を呼ぶ
121+
return $this->editBuckets($request, $page_id, $frame_id);
122+
}
123+
124+
/**
125+
* バケツ設定変更画面の表示
126+
*/
127+
public function editBuckets($request, $page_id, $frame_id)
128+
{
129+
// コアがbucket_id なしで呼び出してくるため、bucket_id は frame_id から探す。
130+
if ($this->action == 'createBuckets') {
131+
$bucket_id = null;
132+
} else {
133+
$bucket_id = $this->getBucketId();
134+
}
135+
136+
// ページデータの取得(laravel-nestedset 使用)
137+
$return_obj = 'flat';
138+
$pages_select = Page::defaultOrderWithDepth($return_obj);
139+
140+
// 表示テンプレートを呼び出す。
141+
return $this->view('bucket', [
142+
// 表示中のバケツデータ
143+
'login' => $this->getPluginBucket($bucket_id),
144+
'pages_select' => $pages_select,
145+
]);
146+
}
147+
148+
/**
149+
* バケツ登録処理
150+
*/
151+
public function saveBuckets($request, $page_id, $frame_id, $bucket_id = null)
152+
{
153+
// 項目のエラーチェック
154+
$validator = Validator::make($request->all(), [
155+
'name' => ['required'],
156+
]);
157+
$validator->setAttributeNames([
158+
'name' => 'ログイン名',
159+
]);
160+
161+
// エラーがあった場合は入力画面に戻る。
162+
if ($validator->fails()) {
163+
return back()->withErrors($validator)->withInput();
164+
}
165+
166+
// バケツの取得。なければ登録。
167+
$bucket = Buckets::updateOrCreate(
168+
['id' => $bucket_id],
169+
['bucket_name' => $request->name, 'plugin_name' => 'logins'],
170+
);
171+
172+
// フレームにバケツの紐づけ
173+
$frame = Frame::find($frame_id)->update(['bucket_id' => $bucket->id]);
174+
175+
// プラグインバケツを取得(なければ新規オブジェクト)
176+
// プラグインバケツにデータを設定して保存
177+
$login = $this->getPluginBucket($bucket->id);
178+
$login->name = $request->name;
179+
$login->redirect_page = $request->redirect_page;
180+
$login->save();
181+
182+
// 登録後はリダイレクトして編集ページを開く。
183+
return new Collection(['redirect_path' => url('/') . "/plugin/logins/editBuckets/" . $page_id . "/" . $frame_id . "/" . $bucket->id . "#frame-" . $frame_id]);
184+
}
185+
186+
/**
187+
* 削除処理
188+
*/
189+
public function destroyBuckets($request, $page_id, $frame_id, $id)
190+
{
191+
// deleted_id, deleted_nameを自動セットするため、複数件削除する時はdestroy()を利用する。
192+
193+
// プラグインバケツの取得
194+
$login = Login::find($id);
195+
if (empty($login)) {
196+
return;
197+
}
198+
199+
// FrameのバケツIDの更新
200+
Frame::where('bucket_id', $login->bucket_id)->update(['bucket_id' => null]);
201+
202+
// バケツ削除
203+
Buckets::destroy($login->bucket_id);
204+
205+
// プラグインデータ削除
206+
$login->delete();
207+
208+
return;
209+
}
210+
211+
/**
212+
* データ紐づけ変更関数
213+
*/
214+
public function changeBuckets($request, $page_id, $frame_id)
215+
{
216+
// FrameのバケツIDの更新
217+
Frame::where('id', $frame_id)->update(['bucket_id' => $request->select_bucket]);
218+
219+
return;
220+
}
221+
}

app/Plugins/User/Logins/plugin.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[plugin_base]
2+
plugin_name_full = ログイン

app/Plugins/User/Slideshows/SlideshowsPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ public function editItem($request, $page_id, $frame_id, $id = null, $message = n
765765
'slideshows_items.*',
766766
'uploads.client_original_name'
767767
)
768-
->join('uploads', 'uploads.id', '=', 'slideshows_items.uploads_id')
768+
->leftjoin('uploads', 'uploads.id', '=', 'slideshows_items.uploads_id')
769769
->where('slideshows_items.slideshows_id', $slideshows_id)
770770
->orderby('slideshows_items.display_sequence')
771771
->get();

0 commit comments

Comments
 (0)