Merge photo comments feature #114
@ -99,6 +99,7 @@ class ConfigHelper
|
||||
'albums_menu_parents_only' => false,
|
||||
'albums_menu_number_items' => 10,
|
||||
'allow_photo_comments' => false,
|
||||
'allow_photo_comments_anonymous' => true,
|
||||
'allow_self_registration' => true,
|
||||
'analytics_code' => '',
|
||||
'app_name' => trans('global.app_name'),
|
||||
|
@ -232,6 +232,7 @@ class DefaultController extends Controller
|
||||
$checkboxKeys = [
|
||||
'albums_menu_parents_only',
|
||||
'allow_photo_comments',
|
||||
'allow_photo_comments_anonymous',
|
||||
'allow_self_registration',
|
||||
'enable_visitor_hits',
|
||||
'hotlink_protection',
|
||||
|
@ -9,6 +9,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StorePhotoCommentRequest;
|
||||
use App\Photo;
|
||||
use App\PhotoComment;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -29,7 +30,7 @@ class PhotoCommentController extends Controller
|
||||
|
||||
if (!$this->loadAlbumPhotoComment($albumUrlAlias, $photoFilename, $commentID, $album, $photo, $comment))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Gate::denies('moderate-comments', $photo))
|
||||
@ -73,7 +74,13 @@ class PhotoCommentController extends Controller
|
||||
|
||||
if (!$this->loadAlbumPhotoComment($albumUrlAlias, $photoFilename, $commentID, $album, $photo, $comment))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!User::currentOrAnonymous()->can('photo:post-comment'))
|
||||
{
|
||||
App::abort(403);
|
||||
return null;
|
||||
}
|
||||
|
||||
return Theme::render('partials.photo_comments_reply_form', [
|
||||
@ -94,7 +101,13 @@ class PhotoCommentController extends Controller
|
||||
|
||||
if (!$this->loadAlbumPhotoComment($albumUrlAlias, $photoFilename, 0, $album, $photo, $comment))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!User::currentOrAnonymous()->can('photo:post-comment'))
|
||||
{
|
||||
App::abort(403);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Validate and link the parent comment, if provided
|
||||
|
@ -94,6 +94,16 @@ class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
return UserConfig::get('public_statistics') || !$user->isAnonymous();
|
||||
});
|
||||
|
||||
Gate::define('photo:post-comment', function(User $user)
|
||||
{
|
||||
if ($user->isAnonymous())
|
||||
{
|
||||
return UserConfig::get('allow_photo_comments_anonymous');
|
||||
};
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private function userHasAdminPermission(User $user, $permissionDescription)
|
||||
|
@ -52,6 +52,8 @@ return [
|
||||
'select' => 'Select',
|
||||
'select_current_text' => '(current)',
|
||||
'settings_allow_photo_comments' => 'Allow comments on photos',
|
||||
'settings_allow_photo_comments_anonymous' => 'Allow anonymous users to comment on photos',
|
||||
'settings_allow_photo_comments_anonymous_help' => 'With this option enabled, users can post comments without being logged in.',
|
||||
'settings_allow_photo_comments_help' => 'With this option enabled, users can comment on individual photos.',
|
||||
'settings_photo_comments_thread_depth' => 'Maximum depth for nested comments:',
|
||||
'settings_photo_comments_thread_depth_help' => 'Set to zero to disable nested comments.',
|
||||
|
@ -488,6 +488,14 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mt-3">
|
||||
<input type="checkbox" class="form-check-input" id="allow-photo-comments-anonymous" name="allow_photo_comments_anonymous" @if (old('allow_photo_comments_anonymous', UserConfig::get('allow_photo_comments_anonymous')))checked="checked"@endif>
|
||||
<label class="form-check-label" for="allow-photo-comments-anonymous">
|
||||
<strong>@lang('forms.settings_allow_photo_comments_anonymous')</strong><br/>
|
||||
@lang('forms.settings_allow_photo_comments_anonymous_help')
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mt-3">
|
||||
<input type="checkbox" class="form-check-input" id="photo-comments-require-login" name="photo_comments_require_login" @if (old('photo_comments_require_login', UserConfig::get('photo_comments_require_login')))checked="checked"@endif>
|
||||
<label class="form-check-label" for="photo-comments-require-login">
|
||||
|
@ -2,10 +2,12 @@
|
||||
<div class="col mt-4">
|
||||
<h2>@lang('gallery.photo_comments_heading')</h2>
|
||||
|
||||
@if (\App\User::currentOrAnonymous()->can('photo:post-comment'))
|
||||
<h3>@lang('gallery.photo_comments_reply_form_heading')</h3>
|
||||
<p>@lang('gallery.photo_comments_reply_form_p1')</p>
|
||||
<hr/>
|
||||
@include(Theme::viewName('partials.photo_comments_reply_form'))
|
||||
@endif
|
||||
|
||||
@foreach ($photo->comments()->whereNull('parent_comment_id')->get() as $comment)
|
||||
@if ($comment->isApproved())
|
||||
|
Loading…
Reference in New Issue
Block a user