diff --git a/app/Http/Controllers/Gallery/UserController.php b/app/Http/Controllers/Gallery/UserController.php index 2820b92..92188fc 100644 --- a/app/Http/Controllers/Gallery/UserController.php +++ b/app/Http/Controllers/Gallery/UserController.php @@ -20,6 +20,56 @@ use Symfony\Component\HttpFoundation\Request; class UserController extends Controller { + public function activityFeed() + { + return Theme::render('gallery.user_activity_feed', [ + 'user' => $this->getUser() + ]); + } + + public function activityFeedJson() + { + $user = $this->getUser(); + + $result = []; + $activities = UserActivity::with('photo') + ->with('photoComment') + ->with('user') + ->join('user_followers', 'user_followers.following_user_id', '=', 'user_activity.user_id') + ->where([ + 'user_followers.user_id' => $user->id + ]) + ->orderBy('activity_at', 'desc') + ->limit(100) // TODO: make this configurable + ->select('user_activity.*') + ->get(); + + /** @var UserActivity $activity */ + foreach ($activities as $activity) + { + $userName = $activity->user->name; + $userProfileUrl = $activity->user->profileUrl(); + $userAvatar = Theme::gravatarUrl($activity->user->email, 32); + + $newItem = [ + 'activity_at' => date(UserConfig::get('date_format'), strtotime($activity->activity_at)), + 'avatar' => $userAvatar, + 'description' => trans(sprintf('gallery.user_feed_type.%s', $activity->type)) + ]; + + $params = []; + $params['user_name'] = $userName; + $params['user_url'] = $userProfileUrl; + $params['photo_name'] = $activity->photo->name; + $params['photo_url'] = $activity->photo->url(); + $newItem['params'] = $params; + + $result[] = $newItem; + } + + return response()->json($result); + } + public function confirmEmailChangeState(Request $request) { $user = $this->getUser(); diff --git a/app/UserActivity.php b/app/UserActivity.php index c504d98..78416e5 100644 --- a/app/UserActivity.php +++ b/app/UserActivity.php @@ -17,4 +17,9 @@ class UserActivity extends Model { return $this->belongsTo(PhotoComment::class); } + + public function user() + { + return $this->belongsTo(User::class); + } } diff --git a/resources/lang/en/gallery.php b/resources/lang/en/gallery.php index 2713d48..739d816 100644 --- a/resources/lang/en/gallery.php +++ b/resources/lang/en/gallery.php @@ -77,6 +77,9 @@ return [ 'title' => 'Statistics', 'uploaded_12_months' => 'Photos uploaded in the last 12 months', ], + 'user_activity_feed' => [ + 'title' => 'My Activity Feed' + ], 'user_feed_type' => [ 'photo' => [ 'comment_replied' => ':user_name replied to a comment on the :photo_name photo.', diff --git a/resources/lang/en/navigation.php b/resources/lang/en/navigation.php index 9e4daba..59bb398 100644 --- a/resources/lang/en/navigation.php +++ b/resources/lang/en/navigation.php @@ -2,6 +2,7 @@ return [ 'breadcrumb' => [ 'about' => 'About', + 'activity_feed' => 'My Activity Feed', 'admin' => 'Admin', 'albums' => 'Albums', 'approve_comment' => 'Approve comment', @@ -33,6 +34,7 @@ return [ 'users' => 'Users' ], 'navbar' => [ + 'activity_feed' => 'Activity', 'admin' => 'Manage', 'albums' => 'Albums', 'change_password' => 'Change password', diff --git a/resources/views/themes/base/gallery/user_activity_feed.blade.php b/resources/views/themes/base/gallery/user_activity_feed.blade.php new file mode 100644 index 0000000..5460a54 --- /dev/null +++ b/resources/views/themes/base/gallery/user_activity_feed.blade.php @@ -0,0 +1,52 @@ +@extends(Theme::viewName('layout')) +@section('title', trans('gallery.user_activity_feed.title')) + +@section('breadcrumb') + + +@endsection + +@section('content') +
+
+
+
+

+ @lang('global.please_wait') +

+

+ @lang('global.please_wait') +

+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+

@lang('gallery.user_activity_feed.no_activity_p1')

+

@lang('gallery.user_activity_feed.no_activity_p2', ['user_name' => $user->name])

+
+
+
+
+@endsection + +@push('scripts') + +@endpush \ No newline at end of file diff --git a/resources/views/themes/base/gallery/user_profile.blade.php b/resources/views/themes/base/gallery/user_profile.blade.php index 34f2ae6..fe50f7b 100644 --- a/resources/views/themes/base/gallery/user_profile.blade.php +++ b/resources/views/themes/base/gallery/user_profile.blade.php @@ -131,7 +131,7 @@ -
+

@lang('gallery.user_profile.no_feed_activity_p1')

@lang('gallery.user_profile.no_feed_activity_p2', ['user_name' => $user->name])

diff --git a/resources/views/themes/base/partials/navbar.blade.php b/resources/views/themes/base/partials/navbar.blade.php index 369ba68..a2dacad 100644 --- a/resources/views/themes/base/partials/navbar.blade.php +++ b/resources/views/themes/base/partials/navbar.blade.php @@ -6,6 +6,13 @@