diff --git a/app/Http/Controllers/Gallery/PhotoCommentController.php b/app/Http/Controllers/Gallery/PhotoCommentController.php
index e146532..0642147 100644
--- a/app/Http/Controllers/Gallery/PhotoCommentController.php
+++ b/app/Http/Controllers/Gallery/PhotoCommentController.php
@@ -273,8 +273,6 @@ class PhotoCommentController extends Controller
{
Mail::to($moderator)->send(new ModeratePhotoComment($moderator, $album, $photo, $comment));
}
-
- dd($moderators);
}
private function stripDisallowedHtmlTags($commentText)
@@ -314,13 +312,18 @@ class PhotoCommentController extends Controller
// Replace the matched string with the inner string
$commentText = substr_replace($commentText, $endingTagMatches[2], $disallowedStringOffset, strlen($endingTagMatches[0]));
- // Find out what difference in lengths the string are post-replacement (we will have only replaced the tags, not the entire string, so we just use)
- // the length of the captured start tag
- $differenceAfterReplacement = strlen($endingTagMatches[1]);
-
// Adjust the offsets for strings after the one we're processing, so the offsets match up with the string correctly
for ($index2 = $index + 1; $index2 < count($htmlTagMatches); $index2++)
{
+ // If this string appears entirely BEFORE the next one starts, we need to subtract the entire length.
+ // Otherwise, we only need to substract the length of the start tag, as the next one starts within it.
+ $differenceAfterReplacement = strlen($endingTagMatches[1]);
+
+ if ($htmlTagMatch[0][1] + strlen($endingTagMatches[0]) < $htmlTagMatches[$index2][0][1])
+ {
+ $differenceAfterReplacement = strlen($endingTagMatches[0]) - strlen($endingTagMatches[2]);
+ }
+
$htmlTagMatches[$index2][0][1] -= $differenceAfterReplacement;
$htmlTagMatches[$index2][1][1] -= $differenceAfterReplacement;
}
diff --git a/app/Mail/ModeratePhotoComment.php b/app/Mail/ModeratePhotoComment.php
index d2ab490..db6db37 100644
--- a/app/Mail/ModeratePhotoComment.php
+++ b/app/Mail/ModeratePhotoComment.php
@@ -4,14 +4,12 @@ namespace App\Mail;
use App\Album;
use App\Facade\Theme;
-use App\Facade\UserConfig;
use App\Photo;
use App\PhotoComment;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-use Illuminate\Contracts\Queue\ShouldQueue;
class ModeratePhotoComment extends Mailable
{
@@ -30,6 +28,9 @@ class ModeratePhotoComment extends Mailable
public function __construct(User $user, Album $album, Photo $photo, PhotoComment $comment)
{
$this->user = $user;
+ $this->album = $album;
+ $this->photo = $photo;
+ $this->comment = $comment;
}
/**
@@ -39,12 +40,15 @@ class ModeratePhotoComment extends Mailable
*/
public function build()
{
- $subject = trans('email.change_email_required_subject', ['app_name' => UserConfig::get('app_name')]);
+ $subject = trans('email.moderate_photo_comment_subject', ['album_name' => $this->album->name]);
return $this
->subject($subject)
- ->markdown(Theme::viewName('email.user_change_email_required'))
+ ->markdown(Theme::viewName('email.moderate_photo_comment'))
->with([
+ 'album' => $this->album,
+ 'comment' => $this->comment,
+ 'photo' => $this->photo,
'subject' => $subject,
'user' => $this->user
]);
diff --git a/resources/lang/en/email.php b/resources/lang/en/email.php
index 15d7776..764cefc 100644
--- a/resources/lang/en/email.php
+++ b/resources/lang/en/email.php
@@ -9,5 +9,11 @@ return [
'change_email_required_subject' => 'Confirm the e-mail change to your :app_name account',
'generic_intro' => 'Hi :user_name,',
'generic_regards' => 'Regards,',
+ 'moderate_photo_comment_comment_label' => 'Comments:',
+ 'moderate_photo_comment_email_label' => 'Author e-mail:',
+ 'moderate_photo_comment_name_label' => 'Author name:',
+ 'moderate_photo_comment_p1' => 'A new comment has been posted in the :album_name album.',
+ 'moderate_photo_comment_p2' => 'Click the button below to open the photo\'s page and approve or reject the comment. You will need to login to see unapproved comments.',
+ 'moderate_photo_comment_subject' => 'New comment requires moderation in :album_name',
'test_email_subject' => 'Test e-mail from :app_name'
];
\ No newline at end of file
diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php
index f7687fd..affcb26 100644
--- a/resources/lang/en/forms.php
+++ b/resources/lang/en/forms.php
@@ -48,6 +48,7 @@ return [
'register_action' => 'Create account',
'remember_me_label' => 'Remember me',
'remove_action' => 'Remove',
+ 'review_photo_comment_action' => 'Approve/reject comment',
'save_action' => 'Save Changes',
'select' => 'Select',
'select_current_text' => '(current)',
diff --git a/resources/views/themes/base/email/moderate_photo_comment.blade.php b/resources/views/themes/base/email/moderate_photo_comment.blade.php
new file mode 100644
index 0000000..5c7d8ef
--- /dev/null
+++ b/resources/views/themes/base/email/moderate_photo_comment.blade.php
@@ -0,0 +1,26 @@
+@component('mail::message')
+@lang('email.generic_intro', ['user_name' => $user->name])
+
+
+@lang('email.moderate_photo_comment_p1', ['album_name' => $album->name])
+
+
+@lang('email.moderate_photo_comment_p2')
+
+
+@lang('email.moderate_photo_comment_name_label') {{ $comment->name }}
+
+@lang('email.moderate_photo_comment_email_label') {{ $comment->email }}
+
+@lang('email.moderate_photo_comment_comment_label')
+
+{!! $comment->comment !!}
+
+@component('mail::button', ['url' => $photo->url(), 'color' => 'blue'])
+ @lang('forms.review_photo_comment_action')
+@endcomponent
+
+@lang('email.generic_regards')
+{{ UserConfig::get('app_name') }}
+{{ route('home') }}
+@endcomponent
\ No newline at end of file