-
Notifications
You must be signed in to change notification settings - Fork 1
/
PersonalMessage.template.php
1749 lines (1546 loc) · 69.9 KB
/
PersonalMessage.template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines
* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
*/
// This is the main sidebar for the personal messages section.
function template_pm_above()
{
global $context, $settings, $options, $txt;
echo '
<div id="personal_messages">';
// Show the capacity bar, if available.
if (!empty($context['limit_bar']))
echo '
<div class="title_bar">
<h3 class="titlebg">
<span class="floatleft">', $txt['pm_capacity'], ':</span>
<span class="floatleft capacity_bar">
<span class="', $context['limit_bar']['percent'] > 85 ? 'full' : ($context['limit_bar']['percent'] > 40 ? 'filled' : 'empty'), '" style="width: ', $context['limit_bar']['percent'] / 10, 'em;"></span>
</span>
<span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
</h3>
</div>';
// Message sent? Show a small indication.
if (isset($context['pm_sent']))
echo '
<div class="windowbg" id="profile_success">
', $txt['pm_sent'], '
</div>';
}
// Just the end of the index bar, nothing special.
function template_pm_below()
{
global $context, $settings, $options;
echo '
</div>';
}
function template_folder()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;
// The every helpful javascript!
echo '
<script type="text/javascript"><!-- // --><![CDATA[
var allLabels = {};
var currentLabels = {};
function loadLabelChoices()
{
var listing = document.forms.pmFolder.elements;
var theSelect = document.forms.pmFolder.pm_action;
var add, remove, toAdd = {length: 0}, toRemove = {length: 0};
if (theSelect.childNodes.length == 0)
return;';
// This is done this way for internationalization reasons.
echo '
if (!(\'-1\' in allLabels))
{
for (var o = 0; o < theSelect.options.length; o++)
if (theSelect.options[o].value.substr(0, 4) == "rem_")
allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text;
}
for (var i = 0; i < listing.length; i++)
{
if (listing[i].name != "pms[]" || !listing[i].checked)
continue;
var alreadyThere = [], x;
for (x in currentLabels[listing[i].value])
{
if (!(x in toRemove))
{
toRemove[x] = allLabels[x];
toRemove.length++;
}
alreadyThere[x] = allLabels[x];
}
for (x in allLabels)
{
if (!(x in alreadyThere))
{
toAdd[x] = allLabels[x];
toAdd.length++;
}
}
}
while (theSelect.options.length > 2)
theSelect.options[2] = null;
if (toAdd.length != 0)
{
theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", "");
setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '");
theSelect.options[theSelect.options.length - 1].disabled = true;
for (i in toAdd)
{
if (i != "length")
theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i);
}
}
if (toRemove.length != 0)
{
theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", "");
setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '");
theSelect.options[theSelect.options.length - 1].disabled = true;
for (i in toRemove)
{
if (i != "length")
theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i);
}
}
}
// ]]></script>';
echo '
<form class="flow_hidden" action="', $scripturl, '?action=pm;sa=pmactions;', $context['display_mode'] == 2 ? 'conversation;' : '', 'f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '" method="post" accept-charset="', $context['character_set'], '" name="pmFolder">';
// If we are not in single display mode show the subjects on the top!
if ($context['display_mode'] != 1)
{
template_subject_list();
echo '<div class="clear_right"><br /></div>';
}
// Got some messages to display?
if ($context['get_pmessage']('message', true))
{
// Show the helpful titlebar - generally.
if ($context['display_mode'] != 1)
echo '
<div class="cat_bar">
<h3 class="catbg">
<span id="author">', $txt['author'], '</span>
<span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
</h3>
</div>';
// Show a few buttons if we are in conversation mode and outputting the first message.
if ($context['display_mode'] == 2)
{
// Build the normal button array.
$conversation_buttons = array(
'reply' => array('text' => 'reply_to_all', 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all', 'active' => true),
'delete' => array('text' => 'delete_conversation', 'image' => 'delete.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'),
);
// Show the conversation buttons.
echo '
<div class="pagesection">';
template_button_strip($conversation_buttons, 'right');
echo '
</div>';
}
echo '<div id="messagelist">';
while ($message = $context['get_pmessage']('message'))
{
$window_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2';
echo '
<div class="', $window_class, ' clear">
<span class="topslice"><span></span></span>
<div class="poster">
<a id="msg', $message['id'], '"></a>
<h4>';
// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
echo '
<img src="', $message['member']['online']['image_href'], '" alt="', $message['member']['online']['text'], '" />';
echo '
', $message['member']['link'], '
</h4>
<ul class="reset smalltext" id="msg_', $message['id'], '_extra_info">';
// Show the member's custom title, if they have one.
if (isset($message['member']['title']) && $message['member']['title'] != '')
echo '
<li class="title">', $message['member']['title'], '</li>';
// Show the member's primary group (like 'Administrator') if they have one.
if (isset($message['member']['group']) && $message['member']['group'] != '')
echo '
<li class="membergroup">', $message['member']['group'], '</li>';
// Don't show these things for guests.
if (!$message['member']['is_guest'])
{
// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
echo '
<li class="postgroup">', $message['member']['post_group'], '</li>';
echo '
<li class="stars">', $message['member']['group_stars'], '</li>';
// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
<li class="avatar">
<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
', $message['member']['avatar']['image'], '
</a>
</li>';
// Show how many posts they have made.
if (!isset($context['disabled_fields']['posts']))
echo '
<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
// Is karma display enabled? Total or +/-?
if ($modSettings['karmaMode'] == '1')
echo '
<li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
elseif ($modSettings['karmaMode'] == '2')
echo '
<li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
// Is this user allowed to modify this member's karma?
if ($message['member']['karma']['allow'])
echo '
<li class="karma_allow">
<a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a> <a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a>
</li>';
// Show the member's gender icon?
if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
echo '
<li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
// Show their personal text?
if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
echo '
<li class="blurb">', $message['member']['blurb'], '</li>';
// Any custom fields to show as icons?
if (!empty($message['member']['custom_fields']))
{
$shown = false;
foreach ($message['member']['custom_fields'] as $custom)
{
if ($custom['placement'] != 1 || empty($custom['value']))
continue;
if (empty($shown))
{
$shown = true;
echo '
<li class="im_icons">
<ul>';
}
echo '
<li>', $custom['value'], '</li>';
}
if ($shown)
echo '
</ul>
</li>';
}
// This shows the popular messaging icons.
if ($message['member']['has_messenger'] && $message['member']['can_view_profile'])
echo '
<li class="im_icons">
<ul>', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '
<li>' . $message['member']['icq']['link'] . '</li>' : '', !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ? '
<li>' . $message['member']['msn']['link'] . '</li>' : '', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '
<li>' . $message['member']['aim']['link'] . '</li>' : '', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '
<li>' . $message['member']['yim']['link'] . '</li>' : '', '
</ul>
</li>';
// Show the profile, website, email address, and personal message buttons.
if ($settings['show_profile_buttons'])
{
echo '
<li class="profile">
<ul>';
// Show the profile button
echo '
<li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '" />' : $txt['view_profile']), '</a></li>';
// Don't show an icon if they haven't specified a website.
if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
echo '
<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $message['member']['website']['title'] . '" />' : $txt['www']), '</a></li>';
// Don't show the email address if they want it hidden.
if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')))
echo '
<li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $message['member']['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';
// Since we know this person isn't a guest, you *can* message them.
if ($context['can_send_pm'])
echo '
<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '" />' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
echo '
</ul>
</li>';
}
// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
echo '
<li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
}
// Are we showing the warning status?
if ($message['member']['can_see_warning'])
echo '
<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<img src="', $settings['images_url'], '/warning_', $message['member']['warning_status'], '.gif" alt="', $txt['user_warn_' . $message['member']['warning_status']], '" />', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
}
// Done with the information about the poster... on to the post itself.
echo '
</ul>
</div>
<div class="postarea">
<div class="flow_hidden">
<div class="keyinfo">
<h5 id="subject_', $message['id'], '">
', $message['subject'], '
</h5>';
// Show who the message was sent to.
echo '
<span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> ';
// People it was sent directly to....
if (!empty($message['recipients']['to']))
echo implode(', ', $message['recipients']['to']);
// Otherwise, we're just going to say "some people"...
elseif ($context['folder'] != 'sent')
echo '(', $txt['pm_undisclosed_recipients'], ')';
echo '
<strong> ', $txt['on'], ':</strong> ', $message['time'], ' »
</span>';
// If we're in the sent items, show who it was sent to besides the "To:" people.
if (!empty($message['recipients']['bcc']))
echo '
<br /><span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>';
if (!empty($message['is_replied_to']))
echo '
<br /><span class="smalltext">« ', $txt['pm_is_replied_to'], ' »</span>';
echo '
</div>
<ul class="reset smalltext quickbuttons">';
// Show reply buttons if you have the permission to send PMs.
if ($context['can_send_pm'])
{
// You can't really reply if the member is gone.
if (!$message['member']['is_guest'])
{
// Is there than more than one recipient you can reply to?
if ($message['number_recipients'] > 1 && $context['display_mode'] != 2)
echo '
<li class="reply_all_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all">', $txt['reply_to_all'], '</a></li>';
echo '
<li class="reply_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $txt['reply'], '</a></li>
<li class="quote_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '">', $txt['quote'], '</a></li>';
}
// This is for "forwarding" - even if the member is gone.
else
echo '
<li class="forward_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $txt['reply_quote'], '</a></li>';
}
echo '
<li class="remove_button"><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions[', $message['id'], ']=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', addslashes($txt['remove_message']), '?\');">', $txt['delete'], '</a></li>';
if (empty($context['display_mode']))
echo '
<li class="inline_mod_check"><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check" /></li>';
echo '
</ul>
</div>
<div class="post">
<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
<div class="smalltext reportlinks">
', (!empty($modSettings['enableReportPM']) && $context['folder'] != 'sent' ? '<div class="righttext"><a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '">' . $txt['pm_report_to_admin'] . '</a></div>' : '');
echo '
</div>';
// Are there any custom profile fields for above the signature?
if (!empty($message['member']['custom_fields']))
{
$shown = false;
foreach ($message['member']['custom_fields'] as $custom)
{
if ($custom['placement'] != 2 || empty($custom['value']))
continue;
if (!$shown)
{
$shown = true;
echo '
<div class="custom_fields_above_signature">
<ul class="reset nolist">';
}
echo '
<li>', $custom['value'], '</li>';
}
if ($shown)
echo '
</ul>
</div>';
}
// Show the member's signature?
if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
echo '
<div class="signature">', $message['member']['signature'], '</div>';
// Add an extra line at the bottom if we have labels enabled.
if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2)
{
echo '
<div class="labels righttext">';
// Add the label drop down box.
if (!empty($context['currently_using_labels']))
{
echo '
<select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();">
<option value="">', $txt['pm_msg_label_title'], ':</option>
<option value="" disabled="disabled">---------------</option>';
// Are there any labels which can be added to this?
if (!$message['fully_labeled'])
{
echo '
<option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
foreach ($context['labels'] as $label)
if (!isset($message['labels'][$label['id']]))
echo '
<option value="', $label['id'], '"> ', $label['name'], '</option>';
}
// ... and are there any that can be removed?
if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
{
echo '
<option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
foreach ($message['labels'] as $label)
echo '
<option value="', $label['id'], '"> ', $label['name'], '</option>';
}
echo '
</select>
<noscript>
<input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
</noscript>';
}
echo '
</div>';
}
echo '
</div>
<br class="clear" />
</div>
<div class="moderatorbar">
</div>
<span class="botslice"><span></span></span>
</div>';
}
echo '</div>';
if (empty($context['display_mode']))
echo '
<div class="pagesection">
<div class="floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
<div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" /></div>
</div>';
// Show a few buttons if we are in conversation mode and outputting the first message.
elseif ($context['display_mode'] == 2 && isset($conversation_buttons))
{
echo '
<div class="pagesection">';
template_button_strip($conversation_buttons, 'right');
echo '
</div>';
}
echo '
<br />';
}
// Individual messages = buttom list!
if ($context['display_mode'] == 1)
{
template_subject_list();
echo '<br />';
}
echo '
<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
</form>';
}
// Just list all the personal message subjects - to make templates easier.
function template_subject_list()
{
global $context, $options, $settings, $modSettings, $txt, $scripturl;
echo '
<div>
<table width="100%" class="table_grid">
<thead>
<tr class="catbg">
<th align="center" width="4%" class="first_th">
<a href="', $scripturl, '?action=pm;view;f=', $context['folder'], ';start=', $context['start'], ';sort=', $context['sort_by'], ($context['sort_direction'] == 'up' ? '' : ';desc'), ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''), '"><img src="', $settings['images_url'], '/im_switch.gif" alt="', $txt['pm_change_view'], '" title="', $txt['pm_change_view'], '" width="16" height="16" /></a>
</th>
<th class="lefttext" width="22%">
<a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=date', $context['sort_by'] == 'date' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['date'], $context['sort_by'] == 'date' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
</th>
<th class="lefttext" width="46%">
<a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
</th>
<th class="lefttext">
<a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', ($context['from_or_to'] == 'from' ? $txt['from'] : $txt['to']), $context['sort_by'] == 'name' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
</th>
<th align="center" width="4%" class="last_th">
<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />
</th>
</tr>
</thead>
<tbody>';
if (!$context['show_delete'])
echo '
<tr class="windowbg2">
<td colspan="5">', $txt['msg_alert_none'], '</td>
</tr>';
$next_alternate = false;
while ($message = $context['get_pmessage']('subject'))
{
echo '
<tr class="', $next_alternate ? 'windowbg' : 'windowbg2', '">
<td align="center" width="4%">
<script type="text/javascript"><!-- // --><![CDATA[
currentLabels[', $message['id'], '] = {';
if (!empty($message['labels']))
{
$first = true;
foreach ($message['labels'] as $label)
{
echo $first ? '' : ',', '
"', $label['id'], '": "', $label['name'], '"';
$first = false;
}
}
echo '
};
// ]]></script>
', $message['is_replied_to'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.gif" style="margin-right: 4px;" alt="' . $txt['pm_replied'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.gif" style="margin-right: 4px;" alt="' . $txt['pm_read'] . '" />', '</td>
<td>', $message['time'], '</td>
<td>', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt="*" />' : ''), '<a href="', ($context['display_mode'] == 0 || $context['current_pm'] == $message['id'] ? '' : ($scripturl . '?action=pm;pmid=' . $message['id'] . ';kstart;f=' . $context['folder'] . ';start=' . $context['start'] . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';' : ';desc') . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''))), '#msg', $message['id'], '">', $message['subject'], '</a>', $message['is_unread'] ? ' <img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" />' : '', '</td>
<td>', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '</td>
<td align="center" width="4%"><input type="checkbox" name="pms[]" id="deletelisting', $message['id'], '" value="', $message['id'], '"', $message['is_selected'] ? ' checked="checked"' : '', ' onclick="if (document.getElementById(\'deletedisplay', $message['id'], '\')) document.getElementById(\'deletedisplay', $message['id'], '\').checked = this.checked;" class="input_check" /></td>
</tr>';
$next_alternate = !$next_alternate;
}
echo '
</tbody>
</table>
</div>
<div class="pagesection">
<div class="floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
<div class="floatright"> ';
if ($context['show_delete'])
{
if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent')
{
echo '
<select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();">
<option value="">', $txt['pm_sel_label_title'], ':</option>
<option value="" disabled="disabled">---------------</option>';
echo '
<option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
foreach ($context['labels'] as $label)
if ($label['id'] != $context['current_label_id'])
echo '
<option value="add_', $label['id'], '"> ', $label['name'], '</option>';
echo '
<option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
foreach ($context['labels'] as $label)
echo '
<option value="rem_', $label['id'], '"> ', $label['name'], '</option>';
echo '
</select>
<noscript>
<input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
</noscript>';
}
echo '
<input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" />';
}
echo '
</div>
</div>';
}
function template_search()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;
echo '
<script type="text/javascript"><!-- // --><![CDATA[
function expandCollapseLabels()
{
var current = document.getElementById("searchLabelsExpand").style.display != "none";
document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
}
// ]]></script>
<form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
<div class="cat_bar">
<h3 class="catbg">', $txt['pm_search_title'], '</h3>
</div>';
if (!empty($context['search_errors']))
{
echo '
<div class="errorbox">
', implode('<br />', $context['search_errors']['messages']), '
</div>';
}
if ($context['simple_search'])
{
echo '
<fieldset id="simple_search">
<span class="upperframe"><span></span></span>
<div class="roundframe">
<div id="search_term_input">
<strong>', $txt['pm_search_text'], ':</strong>
<input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
<input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit" />
</div>
<a href="', $scripturl, '?action=pm;sa=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['pm_search_advanced'], '</a>
<input type="hidden" name="advanced" value="0" />
</div>
<span class="lowerframe"><span></span></span>
</fieldset>';
}
// Advanced search!
else
{
echo '
<fieldset id="advanced_search">
<span class="upperframe"><span></span></span>
<div class="roundframe">
<input type="hidden" name="advanced" value="1" />
<span class="enhanced">
<strong>', $txt['pm_search_text'], ':</strong>
<input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
<script type="text/javascript"><!-- // --><![CDATA[
function initSearch()
{
if (document.forms.searchform.search.value.indexOf("%u") != -1)
document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
}
createEventListener(window);
window.addEventListener("load", initSearch, false);
// ]]></script>
<select name="searchtype">
<option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_all'], '</option>
<option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_any'], '</option>
</select>
</span>
<dl id="search_options">
<dt>', $txt['pm_search_user'], ':</dt>
<dd><input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
<dt>', $txt['pm_search_order'], ':</dt>
<dd>
<select name="sort">
<option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option>
<option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option>
<option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option>
</select>
</dd>
<dt class="options">', $txt['pm_search_options'], ':</dt>
<dd class="options">
<label for="show_complete"><input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_show_complete'], '</label><br />
<label for="subject_only"><input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_subject_only'], '</label>
</dd>
<dt class="between">', $txt['pm_search_post_age'], ':</dt>
<dd>', $txt['pm_search_between'], ' <input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" class="input_text" /> ', $txt['pm_search_between_and'], ' <input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" class="input_text" /> ', $txt['pm_search_between_days'], '</dd>
</dl>';
if (!$context['currently_using_labels'])
echo '
<input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit floatright" />';
echo '
<br class="clear" />
</div>
<span class="lowerframe"><span></span></span>
</fieldset>';
// Do we have some labels setup? If so offer to search by them!
if ($context['currently_using_labels'])
{
echo '
<fieldset class="labels">
<span class="upperframe"><span></span></span>
<div class="roundframe">
<div class="title_bar">
<h4 class="titlebg">
<span class="ie6_header floatleft"><a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><img src="', $settings['images_url'], '/expand.gif" id="expandLabelsIcon" alt="" /></a> <a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><strong>', $txt['pm_search_choose_label'], '</strong></a></span>
</h4>
</div>
<ul id="searchLabelsExpand" class="reset" ', $context['check_all'] ? 'style="display: none;"' : '', '>';
foreach ($context['search_labels'] as $label)
echo '
<li>
<label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '" ', $label['checked'] ? 'checked="checked"' : '', ' class="input_check" />
', $label['name'], '</label>
</li>';
echo '
</ul>
<p>
<span class="floatleft"><input type="checkbox" name="all" id="check_all" value="" ', $context['check_all'] ? 'checked="checked"' : '', ' onclick="invertAll(this, this.form, \'searchlabel\');" class="input_check" /><em> <label for="check_all">', $txt['check_all'], '</label></em></span>
<input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit floatright" />
</p><br class="clear" />
</div>
<span class="lowerframe"><span></span></span>
</fieldset>';
}
}
echo '
</form>';
}
function template_search_results()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;
echo '
<div class="cat_bar">
<h3 class="catbg">', $txt['pm_search_results'], '</h3>
</div>
<div class="pagesection">
<strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
</div>';
// complete results ?
if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
echo '
<table width="100%" class="table_grid">
<thead>
<tr class="catbg">
<th class="lefttext first_th" width="30%">', $txt['date'], '</th>
<th class="lefttext" width="50%">', $txt['subject'], '</th>
<th class="lefttext last_th" width="20%">', $txt['from'], '</th>
</tr>
</thead>
<tbody>';
$alternate = true;
// Print each message out...
foreach ($context['personal_messages'] as $message)
{
// We showing it all?
if (!empty($context['search_params']['show_complete']))
{
echo '
<div class="title_bar">
<h3 class="titlebg">
<span class="floatright">', $txt['search_on'], ': ', $message['time'], '</span>
<span class="floatleft">', $message['counter'], ' <a href="', $message['href'], '">', $message['subject'], '</a></span>
</h3>
</div>
<div class="cat_bar">
<h3 class="catbg">', $txt['from'], ': ', $message['member']['link'], ', ', $txt['to'], ': ';
// Show the recipients.
// !!! This doesn't deal with the sent item searching quite right for bcc.
if (!empty($message['recipients']['to']))
echo implode(', ', $message['recipients']['to']);
// Otherwise, we're just going to say "some people"...
elseif ($context['folder'] != 'sent')
echo '(', $txt['pm_undisclosed_recipients'], ')';
echo '
</h3>
</div>
<div class="windowbg', $alternate ? '2': '', '">
<span class="topslice"><span></span></span>
<div class="content">
', $message['body'], '
<p class="pm_reply righttext middletext">';
if ($context['can_send_pm'])
{
$quote_button = create_button('quote.gif', 'reply_quote', 'reply_quote', 'align="middle"');
$reply_button = create_button('im_reply.gif', 'reply', 'reply', 'align="middle"');
// You can only reply if they are not a guest...
if (!$message['member']['is_guest'])
echo '
<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
// This is for "forwarding" - even if the member is gone.
else
echo '
<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
}
echo '
</p>
</div>
<span class="botslice"><span></span></span>
</div>';
}
// Otherwise just a simple list!
else
{
// !!! No context at all of the search?
echo '
<tr class="', $alternate ? 'windowbg' : 'windowbg2', '" valign="top">
<td>', $message['time'], '</td>
<td>', $message['link'], '</td>
<td>', $message['member']['link'], '</td>
</tr>';
}
$alternate = !$alternate;
}
// Finish off the page...
if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
echo '
</tbody>
</table>';
// No results?
if (empty($context['personal_messages']))
echo '
<div class="windowbg">
<span class="topslice"><span></span></span>
<div class="content">
<p class="centertext">', $txt['pm_search_none_found'], '</p>
</div>
<span class="botslice"><span></span></span>
</div>';
echo '
<div class="pagesection">
<strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
</div>';
}
function template_send()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;
// Show which messages were sent successfully and which failed.
if (!empty($context['send_log']))
{
echo '
<div class="cat_bar">
<h3 class="catbg">', $txt['pm_send_report'], '</h3>
</div>
<div class="windowbg">
<span class="topslice"><span></span></span>
<div class="content">';
if (!empty($context['send_log']['sent']))
foreach ($context['send_log']['sent'] as $log_entry)
echo '<span class="error">', $log_entry, '</span><br />';
if (!empty($context['send_log']['failed']))
foreach ($context['send_log']['failed'] as $log_entry)
echo '<span class="error">', $log_entry, '</span><br />';
echo '
</div>
<span class="botslice"><span></span></span>
</div>
<br />';
}
// Show the preview of the personal message.
if (isset($context['preview_message']))
echo '
<div class="cat_bar">
<h3 class="catbg">', $context['preview_subject'], '</h3>
</div>
<div class="windowbg">
<span class="topslice"><span></span></span>
<div class="content">
', $context['preview_message'], '
</div>
<span class="botslice"><span></span></span>
</div>
<br />';
// Main message editing box.
echo '
<div class="cat_bar">
<h3 class="catbg">
<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/im_newmsg.gif" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" /> ', $txt['new_message'], '</span>
</h3>
</div>';
echo '
<form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
<div>
<span class="upperframe"><span></span></span>
<div class="roundframe"><br class="clear" />';
// If there were errors for sending the PM, show them.
if (!empty($context['post_error']['messages']))
{
echo '
<div class="errorbox">
<strong>', $txt['error_while_submitting'], '</strong>
<ul class="reset">';
foreach ($context['post_error']['messages'] as $error)
echo '
<li class="error">', $error, '</li>';
echo '
</ul>
</div>';
}
echo '
<dl id="post_header">';
// To and bcc. Include a button to search for members.
echo '
<dt>
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
</dt>';
// Autosuggest will be added by the JavaScript later on.
echo '
<dd id="pm_to" class="clear_right">
<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
// A link to add BCC, only visible with JavaScript enabled.
echo '
<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
// A div that'll contain the items found by the autosuggest.
echo '
<div id="to_item_list_container"></div>';
echo '
</dd>';
// This BCC row will be hidden by default if JavaScript is enabled.
echo '
<dt class="clear_left" id="bcc_div">
<span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), '>', $txt['pm_bcc'], ':</span>
</dt>