1 | <?php |
||||
2 | /** |
||||
3 | * Simple Machines Forum (SMF) |
||||
4 | * |
||||
5 | * @package SMF |
||||
6 | * @author Simple Machines https://www.simplemachines.org |
||||
7 | * @copyright 2020 Simple Machines and individual contributors |
||||
8 | * @license https://www.simplemachines.org/about/smf/license.php BSD |
||||
9 | * |
||||
10 | * @version 2.1 RC2 |
||||
11 | */ |
||||
12 | |||||
13 | /** |
||||
14 | * This is for stuff above the menu in the personal messages section |
||||
15 | */ |
||||
16 | function template_pm_above() |
||||
17 | { |
||||
18 | global $context, $txt; |
||||
19 | |||||
20 | echo ' |
||||
21 | <div id="personal_messages">'; |
||||
22 | |||||
23 | // Show the capacity bar, if available. |
||||
24 | if (!empty($context['limit_bar'])) |
||||
25 | echo ' |
||||
26 | <div class="cat_bar"> |
||||
27 | <h3 class="catbg"> |
||||
28 | <span class="floatleft">', $txt['pm_capacity'], ':</span> |
||||
29 | <span class="floatleft capacity_bar"> |
||||
30 | <span class="', $context['limit_bar']['percent'] > 85 ? 'full' : ($context['limit_bar']['percent'] > 40 ? 'filled' : 'empty'), '" style="width: ', $context['limit_bar']['percent'] / 10, 'em;"></span> |
||||
31 | </span> |
||||
32 | <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span> |
||||
33 | </h3> |
||||
34 | </div>'; |
||||
35 | |||||
36 | // Message sent? Show a small indication. |
||||
37 | if (isset($context['pm_sent'])) |
||||
38 | echo ' |
||||
39 | <div class="infobox"> |
||||
40 | ', $txt['pm_sent'], ' |
||||
41 | </div>'; |
||||
42 | } |
||||
43 | |||||
44 | /** |
||||
45 | * Just the end of the index bar, nothing special. |
||||
46 | */ |
||||
47 | function template_pm_below() |
||||
48 | { |
||||
49 | echo ' |
||||
50 | </div><!-- #personal_messages -->'; |
||||
51 | } |
||||
52 | |||||
53 | /** |
||||
54 | * Displays a popup with information about your personal messages |
||||
55 | */ |
||||
56 | function template_pm_popup() |
||||
57 | { |
||||
58 | global $context, $txt, $scripturl; |
||||
59 | |||||
60 | // Unlike almost every other template, this is designed to be included into the HTML directly via $().load() |
||||
61 | echo ' |
||||
62 | <div class="pm_bar"> |
||||
63 | <div class="pm_sending block"> |
||||
64 | ', $context['can_send_pm'] ? '<a href="' . $scripturl . '?action=pm;sa=send">' . $txt['pm_new_short'] . '</a> | ' : '', ' |
||||
65 | ', $context['can_draft'] ? '<a href="' . $scripturl . '?action=pm;sa=showpmdrafts">' . $txt['pm_drafts_short'] . '</a>' : '', ' |
||||
66 | <a href="', $scripturl, '?action=pm;sa=settings" class="floatright">', $txt['pm_settings_short'], '</a> |
||||
67 | </div> |
||||
68 | <div class="pm_mailbox centertext"> |
||||
69 | <a href="', $scripturl, '?action=pm" class="button">', $txt['inbox'], '</a> |
||||
70 | </div> |
||||
71 | </div> |
||||
72 | <div class="pm_unread">'; |
||||
73 | |||||
74 | if (empty($context['unread_pms'])) |
||||
75 | echo ' |
||||
76 | <div class="no_unread">', $txt['pm_no_unread'], '</div>'; |
||||
77 | else |
||||
78 | { |
||||
79 | foreach ($context['unread_pms'] as $id_pm => $pm_details) |
||||
80 | echo ' |
||||
81 | <div class="unread_notify"> |
||||
82 | <div class="unread_notify_image"> |
||||
83 | ', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', ' |
||||
84 | </div> |
||||
85 | <div class="details"> |
||||
86 | <div class="subject">', $pm_details['pm_link'], '</div> |
||||
87 | <div class="sender"> |
||||
88 | ', $pm_details['replied_to_you'] ? '<span class="main_icons replied centericon" style="margin-right: 4px" title="' . $txt['pm_you_were_replied_to'] . '"></span>' : '<span class="main_icons im_off centericon" style="margin-right: 4px" title="' . $txt['pm_was_sent_to_you'] . '"></span>', |
||||
89 | !empty($pm_details['member']) ? $pm_details['member']['link'] : $pm_details['member_from'], ' - ', $pm_details['time'], ' |
||||
90 | </div> |
||||
91 | </div> |
||||
92 | </div>'; |
||||
93 | } |
||||
94 | |||||
95 | echo ' |
||||
96 | </div><!-- #pm_unread -->'; |
||||
97 | } |
||||
98 | |||||
99 | /** |
||||
100 | * Shows a particular folder (eg inbox or outbox), all the PMs in it, etc. |
||||
101 | */ |
||||
102 | function template_folder() |
||||
103 | { |
||||
104 | global $context, $scripturl, $txt; |
||||
105 | |||||
106 | // The every helpful javascript! |
||||
107 | echo ' |
||||
108 | <script> |
||||
109 | var allLabels = {}; |
||||
110 | var currentLabels = {}; |
||||
111 | function loadLabelChoices() |
||||
112 | { |
||||
113 | var listing = document.forms.pmFolder.elements; |
||||
114 | var theSelect = document.forms.pmFolder.pm_action; |
||||
115 | var add, remove, toAdd = {length: 0}, toRemove = {length: 0}; |
||||
116 | |||||
117 | if (theSelect.childNodes.length == 0) |
||||
118 | return; |
||||
119 | |||||
120 | // This is done this way for internationalization reasons. |
||||
121 | if (!(\'-1\' in allLabels)) |
||||
122 | { |
||||
123 | for (var o = 0; o < theSelect.options.length; o++) |
||||
124 | if (theSelect.options[o].value.substr(0, 4) == "rem_") |
||||
125 | allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text; |
||||
126 | } |
||||
127 | |||||
128 | for (var i = 0; i < listing.length; i++) |
||||
129 | { |
||||
130 | if (listing[i].name != "pms[]" || !listing[i].checked) |
||||
131 | continue; |
||||
132 | |||||
133 | var alreadyThere = [], x; |
||||
134 | for (x in currentLabels[listing[i].value]) |
||||
135 | { |
||||
136 | if (!(x in toRemove)) |
||||
137 | { |
||||
138 | toRemove[x] = allLabels[x]; |
||||
139 | toRemove.length++; |
||||
140 | } |
||||
141 | alreadyThere[x] = allLabels[x]; |
||||
142 | } |
||||
143 | |||||
144 | for (x in allLabels) |
||||
145 | { |
||||
146 | if (!(x in alreadyThere)) |
||||
147 | { |
||||
148 | toAdd[x] = allLabels[x]; |
||||
149 | toAdd.length++; |
||||
150 | } |
||||
151 | } |
||||
152 | } |
||||
153 | |||||
154 | while (theSelect.options.length > 2) |
||||
155 | theSelect.options[2] = null; |
||||
156 | |||||
157 | if (toAdd.length != 0) |
||||
158 | { |
||||
159 | theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", ""); |
||||
160 | setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '"); |
||||
161 | theSelect.options[theSelect.options.length - 1].disabled = true; |
||||
162 | |||||
163 | for (i in toAdd) |
||||
164 | { |
||||
165 | if (i != "length") |
||||
166 | theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i); |
||||
167 | } |
||||
168 | } |
||||
169 | |||||
170 | if (toRemove.length != 0) |
||||
171 | { |
||||
172 | theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", ""); |
||||
173 | setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '"); |
||||
174 | theSelect.options[theSelect.options.length - 1].disabled = true; |
||||
175 | |||||
176 | for (i in toRemove) |
||||
177 | { |
||||
178 | if (i != "length") |
||||
179 | theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i); |
||||
180 | } |
||||
181 | } |
||||
182 | } |
||||
183 | </script>'; |
||||
184 | |||||
185 | echo ' |
||||
186 | <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" id="pmFolder">'; |
||||
187 | |||||
188 | // If we are not in single display mode show the subjects on the top! |
||||
189 | if ($context['display_mode'] != 1) |
||||
190 | { |
||||
191 | template_subject_list(); |
||||
192 | |||||
193 | echo ' |
||||
194 | <div class="clear_right"><br></div>'; |
||||
195 | } |
||||
196 | |||||
197 | // Got some messages to display? |
||||
198 | if ($context['get_pmessage']('message', true)) |
||||
199 | { |
||||
200 | // Show a few buttons if we are in conversation mode and outputting the first message. |
||||
201 | if ($context['display_mode'] == 2) |
||||
202 | { |
||||
203 | // This bit uses info set in template_subject_list, so it's wrapped |
||||
204 | // in an if just in case a mod or custom theme breaks it. |
||||
205 | if (!empty($context['current_pm_subject'])) |
||||
206 | { |
||||
207 | echo ' |
||||
208 | <div class="cat_bar"> |
||||
209 | <h3 class="catbg"> |
||||
210 | <span>', $txt['conversation'], '</span> |
||||
211 | </h3> |
||||
212 | </div> |
||||
213 | <div class="roundframe"> |
||||
214 | <div class="display_title">', $context['current_pm_subject'], '</div> |
||||
215 | <p>', $txt['started_by'], ' ', $context['current_pm_author'], ', ', $context['current_pm_time'], '</p>'; |
||||
216 | } |
||||
217 | else |
||||
218 | { |
||||
219 | echo ' |
||||
220 | <div class="roundframe">'; |
||||
221 | } |
||||
222 | |||||
223 | // Show the conversation buttons. |
||||
224 | template_button_strip($context['conversation_buttons'], 'right'); |
||||
225 | |||||
226 | echo ' |
||||
227 | </div>'; |
||||
228 | } |
||||
229 | |||||
230 | while ($message = $context['get_pmessage']('message')) |
||||
231 | template_single_pm($message); |
||||
232 | |||||
233 | if (empty($context['display_mode'])) |
||||
234 | echo ' |
||||
235 | <div class="pagesection"> |
||||
236 | <div class="floatleft">', $context['page_index'], '</div> |
||||
237 | <div class="floatright"> |
||||
238 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button"> |
||||
239 | </div> |
||||
240 | </div>'; |
||||
241 | |||||
242 | // Show a few buttons if we are in conversation mode and outputting the first message. |
||||
243 | elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons'])) |
||||
244 | { |
||||
245 | echo ' |
||||
246 | <div class="pagesection">'; |
||||
247 | |||||
248 | template_button_strip($context['conversation_buttons'], 'right'); |
||||
249 | |||||
250 | echo ' |
||||
251 | </div>'; |
||||
252 | } |
||||
253 | |||||
254 | echo ' |
||||
255 | <br>'; |
||||
256 | } |
||||
257 | |||||
258 | // Individual messages = buttom list! |
||||
259 | if ($context['display_mode'] == 1) |
||||
260 | { |
||||
261 | template_subject_list(); |
||||
262 | echo '<br>'; |
||||
263 | } |
||||
264 | |||||
265 | echo ' |
||||
266 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
267 | </form>'; |
||||
268 | } |
||||
269 | |||||
270 | /** |
||||
271 | * Template for displaying a single personal message. |
||||
272 | * |
||||
273 | * @param array $message An array of information about the message to display. |
||||
274 | */ |
||||
275 | function template_single_pm($message) |
||||
276 | { |
||||
277 | global $context, $scripturl, $txt, $settings, $options, $modSettings; |
||||
278 | |||||
279 | echo ' |
||||
280 | <div class="windowbg"> |
||||
281 | <div class="post_wrapper"> |
||||
282 | <div class="poster">'; |
||||
283 | |||||
284 | // Are there any custom fields above the member name? |
||||
285 | if (!empty($message['custom_fields']['above_member'])) |
||||
286 | { |
||||
287 | echo ' |
||||
288 | <div class="custom_fields_above_member"> |
||||
289 | <ul class="nolist">'; |
||||
290 | |||||
291 | foreach ($message['custom_fields']['above_member'] as $custom) |
||||
292 | echo ' |
||||
293 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
294 | |||||
295 | echo ' |
||||
296 | </ul> |
||||
297 | </div>'; |
||||
298 | } |
||||
299 | |||||
300 | echo ' |
||||
301 | <h4> |
||||
302 | <a id="msg', $message['id'], '"></a>'; |
||||
303 | |||||
304 | // Show online and offline buttons? |
||||
305 | if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
||||
306 | echo ' |
||||
307 | <span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>'; |
||||
308 | |||||
309 | // Custom fields BEFORE the username? |
||||
310 | if (!empty($message['custom_fields']['before_member'])) |
||||
311 | foreach ($message['custom_fields']['before_member'] as $custom) |
||||
312 | echo ' |
||||
313 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
||||
314 | |||||
315 | // Show a link to the member's profile. |
||||
316 | echo ' |
||||
317 | ', $message['member']['link']; |
||||
318 | |||||
319 | // Custom fields AFTER the username? |
||||
320 | if (!empty($message['custom_fields']['after_member'])) |
||||
321 | foreach ($message['custom_fields']['after_member'] as $custom) |
||||
322 | echo ' |
||||
323 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
||||
324 | |||||
325 | echo ' |
||||
326 | </h4>'; |
||||
327 | |||||
328 | echo ' |
||||
329 | <ul class="user_info">'; |
||||
330 | |||||
331 | // Show the user's avatar. |
||||
332 | if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
||||
333 | echo ' |
||||
334 | <li class="avatar"> |
||||
335 | <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a> |
||||
336 | </li>'; |
||||
337 | |||||
338 | // Are there any custom fields below the avatar? |
||||
339 | if (!empty($message['custom_fields']['below_avatar'])) |
||||
340 | foreach ($message['custom_fields']['below_avatar'] as $custom) |
||||
341 | echo ' |
||||
342 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
343 | |||||
344 | if (!$message['member']['is_guest']) |
||||
345 | echo ' |
||||
346 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
||||
347 | // Show the member's primary group (like 'Administrator') if they have one. |
||||
348 | if (isset($message['member']['group']) && $message['member']['group'] != '') |
||||
349 | echo ' |
||||
350 | <li class="membergroup">', $message['member']['group'], '</li>'; |
||||
351 | |||||
352 | // Show the member's custom title, if they have one. |
||||
353 | if (isset($message['member']['title']) && $message['member']['title'] != '') |
||||
354 | echo ' |
||||
355 | <li class="title">', $message['member']['title'], '</li>'; |
||||
356 | |||||
357 | // Don't show these things for guests. |
||||
358 | if (!$message['member']['is_guest']) |
||||
359 | { |
||||
360 | // 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. |
||||
361 | if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') |
||||
362 | echo ' |
||||
363 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
||||
364 | |||||
365 | // Show how many posts they have made. |
||||
366 | if (!isset($context['disabled_fields']['posts'])) |
||||
367 | echo ' |
||||
368 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
||||
369 | |||||
370 | // Show their personal text? |
||||
371 | if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') |
||||
372 | echo ' |
||||
373 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
||||
374 | |||||
375 | // Any custom fields to show as icons? |
||||
376 | if (!empty($message['custom_fields']['icons'])) |
||||
377 | { |
||||
378 | echo ' |
||||
379 | <li class="im_icons"> |
||||
380 | <ol>'; |
||||
381 | |||||
382 | foreach ($message['custom_fields']['icons'] as $custom) |
||||
383 | echo ' |
||||
384 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
385 | |||||
386 | echo ' |
||||
387 | </ol> |
||||
388 | </li>'; |
||||
389 | } |
||||
390 | |||||
391 | // Show the IP to this user for this post - because you can moderate? |
||||
392 | if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
||||
393 | echo ' |
||||
394 | <li class="poster_ip"> |
||||
395 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
||||
396 | </li>'; |
||||
397 | |||||
398 | // Or, should we show it because this is you? |
||||
399 | elseif ($message['can_see_ip']) |
||||
400 | echo ' |
||||
401 | <li class="poster_ip"> |
||||
402 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
||||
403 | </li>'; |
||||
404 | |||||
405 | // Okay, you are logged in, then we can show something about why IPs are logged... |
||||
406 | else |
||||
407 | echo ' |
||||
408 | <li class="poster_ip"> |
||||
409 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
||||
410 | </li>'; |
||||
411 | |||||
412 | // Show the profile, website, email address, and personal message buttons. |
||||
413 | if ($message['member']['show_profile_buttons']) |
||||
414 | { |
||||
415 | echo ' |
||||
416 | <li class="profile"> |
||||
417 | <ol class="profile_icons">'; |
||||
418 | |||||
419 | // Show the profile button |
||||
420 | if ($message['member']['can_view_profile']) |
||||
421 | echo ' |
||||
422 | <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>'; |
||||
423 | |||||
424 | // Don't show an icon if they haven't specified a website. |
||||
425 | if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) |
||||
426 | echo ' |
||||
427 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="main_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
||||
428 | |||||
429 | // Don't show the email address if they want it hidden. |
||||
430 | if ($message['member']['show_email']) |
||||
431 | echo ' |
||||
432 | <li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="main_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
||||
433 | |||||
434 | // Since we know this person isn't a guest, you *can* message them. |
||||
435 | if ($context['can_send_pm']) |
||||
436 | echo ' |
||||
437 | <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'] ? '<span class="main_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
||||
438 | |||||
439 | echo ' |
||||
440 | </ol> |
||||
441 | </li>'; |
||||
442 | } |
||||
443 | |||||
444 | // Any custom fields for standard placement? |
||||
445 | if (!empty($message['custom_fields']['standard'])) |
||||
446 | foreach ($message['custom_fields']['standard'] as $custom) |
||||
447 | echo ' |
||||
448 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
||||
449 | |||||
450 | // Are we showing the warning status? |
||||
451 | if ($message['member']['can_see_warning']) |
||||
452 | echo ' |
||||
453 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="main_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
||||
454 | |||||
455 | // Are there any custom fields to show at the bottom of the poster info? |
||||
456 | if (!empty($message['custom_fields']['bottom_poster'])) |
||||
457 | foreach ($message['custom_fields']['bottom_poster'] as $custom) |
||||
458 | echo ' |
||||
459 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
460 | } |
||||
461 | |||||
462 | // Done with the information about the poster... on to the post itself. |
||||
463 | echo ' |
||||
464 | </ul> |
||||
465 | </div><!-- .poster --> |
||||
466 | <div class="postarea"> |
||||
467 | <div class="flow_hidden"> |
||||
468 | <div class="keyinfo"> |
||||
469 | <h5 id="subject_', $message['id'], '"> |
||||
470 | ', $message['subject'], ' |
||||
471 | </h5>'; |
||||
472 | |||||
473 | // Show who the message was sent to. |
||||
474 | echo ' |
||||
475 | <span class="smalltext">« <strong> ', $txt['sent_to'], ':</strong> '; |
||||
476 | |||||
477 | // People it was sent directly to.... |
||||
478 | if (!empty($message['recipients']['to'])) |
||||
479 | echo implode(', ', $message['recipients']['to']); |
||||
480 | |||||
481 | // Otherwise, we're just going to say "some people"... |
||||
482 | elseif ($context['folder'] != 'sent') |
||||
483 | echo '(', $txt['pm_undisclosed_recipients'], ')'; |
||||
484 | |||||
485 | echo ' |
||||
486 | <strong> ', $txt['on'], ':</strong> ', $message['time'], ' » |
||||
487 | </span>'; |
||||
488 | |||||
489 | // If we're in the sent items, show who it was sent to besides the "To:" people. |
||||
490 | if (!empty($message['recipients']['bcc'])) |
||||
491 | echo '<br> |
||||
492 | <span class="smalltext">« <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' »</span>'; |
||||
493 | |||||
494 | if (!empty($message['is_replied_to'])) |
||||
495 | echo '<br> |
||||
496 | <span class="smalltext">« ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' »</span>'; |
||||
497 | |||||
498 | echo ' |
||||
499 | </div><!-- .keyinfo --> |
||||
500 | </div><!-- .flow_hidden --> |
||||
501 | <div class="post"> |
||||
502 | <div class="inner" id="msg_', $message['id'], '"', '> |
||||
503 | ', $message['body'], ' |
||||
504 | </div> |
||||
505 | </div><!-- .post --> |
||||
506 | <div class="under_message">'; |
||||
507 | |||||
508 | // Message options |
||||
509 | template_quickbuttons($message['quickbuttons'], 'pm'); |
||||
510 | |||||
511 | echo ' |
||||
512 | </div><!-- .under_message --> |
||||
513 | </div><!-- .postarea --> |
||||
514 | <div class="moderatorbar">'; |
||||
515 | |||||
516 | // Are there any custom profile fields for above the signature? |
||||
517 | if (!empty($message['custom_fields']['above_signature'])) |
||||
518 | { |
||||
519 | echo ' |
||||
520 | <div class="custom_fields_above_signature"> |
||||
521 | <ul class="nolist">'; |
||||
522 | |||||
523 | foreach ($message['custom_fields']['above_signature'] as $custom) |
||||
524 | echo ' |
||||
525 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
526 | |||||
527 | echo ' |
||||
528 | </ul> |
||||
529 | </div>'; |
||||
530 | } |
||||
531 | |||||
532 | // Show the member's signature? |
||||
533 | if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
||||
534 | echo ' |
||||
535 | <div class="signature"> |
||||
536 | ', $message['member']['signature'], ' |
||||
537 | </div>'; |
||||
538 | |||||
539 | // Are there any custom profile fields for below the signature? |
||||
540 | if (!empty($message['custom_fields']['below_signature'])) |
||||
541 | { |
||||
542 | echo ' |
||||
543 | <div class="custom_fields_below_signature"> |
||||
544 | <ul class="nolist">'; |
||||
545 | |||||
546 | foreach ($message['custom_fields']['below_signature'] as $custom) |
||||
547 | echo ' |
||||
548 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
||||
549 | |||||
550 | echo ' |
||||
551 | </ul> |
||||
552 | </div>'; |
||||
553 | } |
||||
554 | |||||
555 | // Add an extra line at the bottom if we have labels enabled. |
||||
556 | if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2) |
||||
557 | { |
||||
558 | echo ' |
||||
559 | <div class="labels righttext flow_auto">'; |
||||
560 | |||||
561 | // Add the label drop down box. |
||||
562 | if (!empty($context['currently_using_labels'])) |
||||
563 | { |
||||
564 | echo ' |
||||
565 | <select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();"> |
||||
566 | <option value="">', $txt['pm_msg_label_title'], ':</option> |
||||
567 | <option value="" disabled>---------------</option>'; |
||||
568 | |||||
569 | // Are there any labels which can be added to this? |
||||
570 | if (!$message['fully_labeled']) |
||||
571 | { |
||||
572 | echo ' |
||||
573 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
||||
574 | |||||
575 | foreach ($context['labels'] as $label) |
||||
576 | if (!isset($message['labels'][$label['id']])) |
||||
577 | echo ' |
||||
578 | <option value="', $label['id'], '">', $label['name'], '</option>'; |
||||
579 | } |
||||
580 | |||||
581 | // ... and are there any that can be removed? |
||||
582 | if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1]))) |
||||
583 | { |
||||
584 | echo ' |
||||
585 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
||||
586 | |||||
587 | foreach ($message['labels'] as $label) |
||||
588 | echo ' |
||||
589 | <option value="', $label['id'], '"> ', $label['name'], '</option>'; |
||||
590 | } |
||||
591 | echo ' |
||||
592 | </select> |
||||
593 | <noscript> |
||||
594 | <input type="submit" value="', $txt['pm_apply'], '" class="button"> |
||||
595 | </noscript>'; |
||||
596 | } |
||||
597 | echo ' |
||||
598 | </div><!-- .labels -->'; |
||||
599 | } |
||||
600 | |||||
601 | echo ' |
||||
602 | </div><!-- .moderatorbar --> |
||||
603 | </div><!-- .post_wrapper --> |
||||
604 | </div><!-- .windowbg -->'; |
||||
605 | } |
||||
606 | |||||
607 | /** |
||||
608 | * Just list all the personal message subjects - to make templates easier. |
||||
609 | */ |
||||
610 | function template_subject_list() |
||||
611 | { |
||||
612 | global $context, $settings, $txt, $scripturl; |
||||
613 | |||||
614 | echo ' |
||||
615 | <table class="table_grid"> |
||||
616 | <thead> |
||||
617 | <tr class="title_bar"> |
||||
618 | <th class="centercol table_icon pm_icon"> |
||||
619 | <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'] : ''), '"> <span class="main_icons switch" title="', $txt['pm_change_view'], '"></span></a> |
||||
620 | </th> |
||||
621 | <th class="lefttext quarter_table pm_time"> |
||||
622 | <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' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
||||
623 | </th> |
||||
624 | <th class="lefttext half_table pm_subject"> |
||||
625 | <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' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
||||
626 | </th> |
||||
627 | <th class="lefttext pm_from_to"> |
||||
628 | <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' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
||||
629 | </th> |
||||
630 | <th class="centercol table_icon pm_moderation"> |
||||
631 | <input type="checkbox" onclick="invertAll(this, this.form);"> |
||||
632 | </th> |
||||
633 | </tr> |
||||
634 | </thead> |
||||
635 | <tbody>'; |
||||
636 | |||||
637 | if (!$context['show_delete']) |
||||
638 | echo ' |
||||
639 | <tr class="windowbg"> |
||||
640 | <td colspan="5">', $txt['pm_alert_none'], '</td> |
||||
641 | </tr>'; |
||||
642 | |||||
643 | while ($message = $context['get_pmessage']('subject')) |
||||
644 | { |
||||
645 | // Used for giving extra info in conversation view |
||||
646 | if ($context['current_pm'] == $message['id']) |
||||
647 | { |
||||
648 | $context['current_pm_subject'] = $message['subject']; |
||||
649 | $context['current_pm_time'] = $message['time']; |
||||
650 | $context['current_pm_author'] = $message['member']['link']; |
||||
651 | } |
||||
652 | |||||
653 | echo ' |
||||
654 | <tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '"> |
||||
655 | <td class="table_icon pm_icon"> |
||||
656 | <script> |
||||
657 | currentLabels[', $message['id'], '] = {'; |
||||
658 | |||||
659 | if (!empty($message['labels'])) |
||||
660 | { |
||||
661 | $first = true; |
||||
662 | foreach ($message['labels'] as $label) |
||||
663 | { |
||||
664 | echo $first ? '' : ',', ' |
||||
665 | "', $label['id'], '": "', $label['name'], '"'; |
||||
666 | $first = false; |
||||
667 | } |
||||
668 | } |
||||
669 | |||||
670 | echo ' |
||||
671 | }; |
||||
672 | </script> |
||||
673 | ', $message['is_replied_to'] ? '<span class="main_icons replied" title="' . $txt['pm_replied'] . '"></span>' : '<span class="main_icons im_off" title="' . $txt['pm_read'] . '"></span>', ' |
||||
674 | </td> |
||||
675 | <td class="pm_time">', $message['time'], '</td> |
||||
676 | <td class="pm_subject"> |
||||
677 | ', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.png" 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'], $message['is_unread'] ? ' <span class="new_posts">' . $txt['new'] . '</span>' : '', '</a> |
||||
678 | <span class="pm_inline_time"><span class="main_icons ', ($context['from_or_to'] == 'to' && count($message['recipients']['to']) > 1) ? 'people' : 'members', '"></span> ', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), ' <span class="main_icons time_online"></span> ', $message['time'], '</span> |
||||
679 | </td> |
||||
680 | <td class="pm_from_to"> |
||||
681 | ', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), ' |
||||
682 | </td> |
||||
683 | <td class="centercol table_icon pm_moderation"> |
||||
684 | <input type="checkbox" name="pms[]" id="deletelisting', $message['id'], '" value="', $message['id'], '"', $message['is_selected'] ? ' checked' : '', ' onclick="if (document.getElementById(\'deletedisplay', $message['id'], '\')) document.getElementById(\'deletedisplay', $message['id'], '\').checked = this.checked;"> |
||||
685 | </td> |
||||
686 | </tr>'; |
||||
687 | } |
||||
688 | |||||
689 | echo ' |
||||
690 | </tbody> |
||||
691 | </table> |
||||
692 | <div class="pagesection"> |
||||
693 | <div class="floatleft">', $context['page_index'], '</div> |
||||
694 | <div class="floatright"> '; |
||||
695 | |||||
696 | if ($context['show_delete']) |
||||
697 | { |
||||
698 | if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent') |
||||
699 | { |
||||
700 | echo ' |
||||
701 | <select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();"> |
||||
702 | <option value="">', $txt['pm_sel_label_title'], ':</option> |
||||
703 | <option value="" disabled>---------------</option> |
||||
704 | <option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>'; |
||||
705 | |||||
706 | foreach ($context['labels'] as $label) |
||||
707 | { |
||||
708 | if ($label['id'] != $context['current_label_id']) |
||||
709 | echo ' |
||||
710 | <option value="add_', $label['id'], '"> ', $label['name'], '</option>'; |
||||
711 | } |
||||
712 | |||||
713 | echo ' |
||||
714 | <option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>'; |
||||
715 | |||||
716 | foreach ($context['labels'] as $label) |
||||
717 | echo ' |
||||
718 | <option value="rem_', $label['id'], '"> ', $label['name'], '</option>'; |
||||
719 | |||||
720 | echo ' |
||||
721 | </select> |
||||
722 | <noscript> |
||||
723 | <input type="submit" value="', $txt['pm_apply'], '" class="button"> |
||||
724 | </noscript>'; |
||||
725 | } |
||||
726 | |||||
727 | echo ' |
||||
728 | <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button">'; |
||||
729 | } |
||||
730 | |||||
731 | echo ' |
||||
732 | </div><!-- .floatright --> |
||||
733 | </div><!-- .pagesection -->'; |
||||
734 | } |
||||
735 | |||||
736 | /** |
||||
737 | * The form for the PM search feature |
||||
738 | */ |
||||
739 | function template_search() |
||||
740 | { |
||||
741 | global $context, $scripturl, $txt; |
||||
742 | |||||
743 | if (!empty($context['search_errors'])) |
||||
744 | echo ' |
||||
745 | <div class="errorbox"> |
||||
746 | ', implode('<br>', $context['search_errors']['messages']), ' |
||||
747 | </div>'; |
||||
748 | |||||
749 | echo ' |
||||
750 | <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform"> |
||||
751 | <div class="cat_bar"> |
||||
752 | <h3 class="catbg">', $txt['pm_search_title'], '</h3> |
||||
753 | </div> |
||||
754 | <div id="advanced_search" class="roundframe"> |
||||
755 | <input type="hidden" name="advanced" value="1"> |
||||
756 | <dl id="search_options" class="settings"> |
||||
757 | <dt> |
||||
758 | <strong><label for="searchfor">', $txt['pm_search_text'], ':</label></strong> |
||||
759 | </dt> |
||||
760 | <dd> |
||||
761 | <input type="search" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40"> |
||||
762 | <script> |
||||
763 | createEventListener(window); |
||||
764 | window.addEventListener("load", initSearch, false); |
||||
765 | </script> |
||||
766 | </dd> |
||||
767 | <dt> |
||||
768 | <label for="searchtype">', $txt['search_match'], ':</label> |
||||
769 | </dt> |
||||
770 | <dd> |
||||
771 | <select name="searchtype"> |
||||
772 | <option value="1"', empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['pm_search_match_all'], '</option> |
||||
773 | <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['pm_search_match_any'], '</option> |
||||
774 | </select> |
||||
775 | </dd> |
||||
776 | <dt> |
||||
777 | <label for="userspec">', $txt['pm_search_user'], ':</label> |
||||
778 | </dt> |
||||
779 | <dd> |
||||
780 | <input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40"> |
||||
781 | </dd> |
||||
782 | <dt> |
||||
783 | <label for="sort">', $txt['pm_search_order'], ':</label> |
||||
784 | </dt> |
||||
785 | <dd> |
||||
786 | <select name="sort"> |
||||
787 | <option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option> |
||||
788 | <option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option> |
||||
789 | <option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option> |
||||
790 | </select> |
||||
791 | </dd> |
||||
792 | <dt class="options"> |
||||
793 | ', $txt['pm_search_options'], ': |
||||
794 | </dt> |
||||
795 | <dd class="options"> |
||||
796 | <label for="show_complete"> |
||||
797 | <input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked' : '', '> ', $txt['pm_search_show_complete'], ' |
||||
798 | </label><br> |
||||
799 | <label for="subject_only"> |
||||
800 | <input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked' : '', '> ', $txt['pm_search_subject_only'], ' |
||||
801 | </label> |
||||
802 | </dd> |
||||
803 | <dt class="between"> |
||||
804 | ', $txt['pm_search_post_age'], ': |
||||
805 | </dt> |
||||
806 | <dd> |
||||
807 | ', $txt['pm_search_between'], ' |
||||
808 | <input type="number" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" min="0" max="9999"> |
||||
809 | ', $txt['pm_search_between_and'], ' |
||||
810 | <input type="number" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" min="0" max="9999"> |
||||
811 | ', $txt['pm_search_between_days'], ' |
||||
812 | </dd> |
||||
813 | </dl>'; |
||||
814 | |||||
815 | if (!$context['currently_using_labels']) |
||||
816 | echo ' |
||||
817 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button floatright">'; |
||||
818 | |||||
819 | echo ' |
||||
820 | </div><!-- .roundframe -->'; |
||||
821 | |||||
822 | // Do we have some labels setup? If so offer to search by them! |
||||
823 | if ($context['currently_using_labels']) |
||||
824 | { |
||||
825 | echo ' |
||||
826 | <fieldset class="labels"> |
||||
827 | <div class="roundframe alt"> |
||||
828 | <div class="title_bar"> |
||||
829 | <h3 class="titlebg"> |
||||
830 | <span id="advanced_panel_toggle" class="toggle_up floatright" style="display: none;"></span><a href="#" id="advanced_panel_link">', $txt['pm_search_choose_label'], '</a> |
||||
831 | </h3> |
||||
832 | </div> |
||||
833 | <div id="advanced_panel_div"> |
||||
834 | <ul id="search_labels">'; |
||||
835 | |||||
836 | foreach ($context['search_labels'] as $label) |
||||
837 | echo ' |
||||
838 | <li> |
||||
839 | <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', '> |
||||
840 | ', $label['name'], '</label> |
||||
841 | </li>'; |
||||
842 | |||||
843 | echo ' |
||||
844 | </ul> |
||||
845 | </div> |
||||
846 | <br class="clear"> |
||||
847 | <div class="padding"> |
||||
848 | <input type="checkbox" name="all" id="check_all" value=""', $context['check_all'] ? ' checked' : '', ' onclick="invertAll(this, this.form, \'searchlabel\');"> |
||||
849 | <label for="check_all"><em>', $txt['check_all'], '</em></label> |
||||
850 | <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button floatright"> |
||||
851 | </div class="padding"> |
||||
852 | </div><!-- .roundframe --> |
||||
853 | </fieldset>'; |
||||
854 | |||||
855 | // Some javascript for the advanced toggling |
||||
856 | echo ' |
||||
857 | <script> |
||||
858 | var oAdvancedPanelToggle = new smc_Toggle({ |
||||
859 | bToggleEnabled: true, |
||||
860 | bCurrentlyCollapsed: true, |
||||
861 | aSwappableContainers: [ |
||||
862 | \'advanced_panel_div\' |
||||
863 | ], |
||||
864 | aSwapImages: [ |
||||
865 | { |
||||
866 | sId: \'advanced_panel_toggle\', |
||||
867 | altExpanded: ', JavaScriptEscape($txt['hide']), ', |
||||
868 | altCollapsed: ', JavaScriptEscape($txt['show']), ' |
||||
869 | } |
||||
870 | ], |
||||
871 | aSwapLinks: [ |
||||
872 | { |
||||
873 | sId: \'advanced_panel_link\', |
||||
874 | msgExpanded: ', JavaScriptEscape($txt['pm_search_choose_label']), ', |
||||
875 | msgCollapsed: ', JavaScriptEscape($txt['pm_search_choose_label']), ' |
||||
876 | } |
||||
877 | ] |
||||
878 | }); |
||||
879 | </script>'; |
||||
880 | } |
||||
881 | |||||
882 | echo ' |
||||
883 | </form>'; |
||||
884 | } |
||||
885 | |||||
886 | /** |
||||
887 | * Displays results from a PM search |
||||
888 | */ |
||||
889 | function template_search_results() |
||||
890 | { |
||||
891 | global $context, $txt; |
||||
892 | |||||
893 | echo ' |
||||
894 | <div class="cat_bar"> |
||||
895 | <h3 class="catbg">', $txt['pm_search_results'], '</h3> |
||||
896 | </div> |
||||
897 | <div class="roundframe noup"> |
||||
898 | ', sprintf($txt['pm_search_results_info'], $context['num_results'], sentence_list($context['search_in'])), ' |
||||
899 | </div> |
||||
900 | <div class="pagesection"> |
||||
901 | ', $context['page_index'], ' |
||||
902 | </div>'; |
||||
903 | |||||
904 | // Complete results? |
||||
905 | if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
||||
906 | echo ' |
||||
907 | <table class="table_grid"> |
||||
908 | <thead> |
||||
909 | <tr class="title_bar"> |
||||
910 | <th class="lefttext quarter_table">', $txt['date'], '</th> |
||||
911 | <th class="lefttext half_table">', $txt['subject'], '</th> |
||||
912 | <th class="lefttext quarter_table">', $txt['from'], '</th> |
||||
913 | </tr> |
||||
914 | </thead> |
||||
915 | <tbody>'; |
||||
916 | |||||
917 | // Print each message out... |
||||
918 | foreach ($context['personal_messages'] as $message) |
||||
919 | { |
||||
920 | // Are we showing it all? |
||||
921 | if (!empty($context['search_params']['show_complete'])) |
||||
922 | template_single_pm($message); |
||||
923 | |||||
924 | // Otherwise just a simple list! |
||||
925 | // @todo No context at all of the search? |
||||
926 | else |
||||
927 | echo ' |
||||
928 | <tr class="windowbg"> |
||||
929 | <td>', $message['time'], '</td> |
||||
930 | <td>', $message['link'], '</td> |
||||
931 | <td>', $message['member']['link'], '</td> |
||||
932 | </tr>'; |
||||
933 | } |
||||
934 | |||||
935 | // Finish off the page... |
||||
936 | if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) |
||||
937 | echo ' |
||||
938 | </tbody> |
||||
939 | </table>'; |
||||
940 | |||||
941 | // No results? |
||||
942 | if (empty($context['personal_messages'])) |
||||
943 | echo ' |
||||
944 | <div class="windowbg"> |
||||
945 | <p class="centertext">', $txt['pm_search_none_found'], '</p> |
||||
946 | </div>'; |
||||
947 | |||||
948 | echo ' |
||||
949 | <div class="pagesection"> |
||||
950 | ', $context['page_index'], ' |
||||
951 | </div>'; |
||||
952 | |||||
953 | } |
||||
954 | |||||
955 | /** |
||||
956 | * The form for sending a new PM |
||||
957 | */ |
||||
958 | function template_send() |
||||
959 | { |
||||
960 | global $context, $options, $scripturl, $modSettings, $txt; |
||||
961 | |||||
962 | // Show which messages were sent successfully and which failed. |
||||
963 | if (!empty($context['send_log'])) |
||||
964 | { |
||||
965 | echo ' |
||||
966 | <div class="cat_bar"> |
||||
967 | <h3 class="catbg">', $txt['pm_send_report'], '</h3> |
||||
968 | </div> |
||||
969 | <div class="windowbg">'; |
||||
970 | |||||
971 | if (!empty($context['send_log']['sent'])) |
||||
972 | foreach ($context['send_log']['sent'] as $log_entry) |
||||
973 | echo ' |
||||
974 | <span class="error">', $log_entry, '</span><br>'; |
||||
975 | |||||
976 | if (!empty($context['send_log']['failed'])) |
||||
977 | foreach ($context['send_log']['failed'] as $log_entry) |
||||
978 | echo ' |
||||
979 | <span class="error">', $log_entry, '</span><br>'; |
||||
980 | |||||
981 | echo ' |
||||
982 | </div> |
||||
983 | <br>'; |
||||
984 | } |
||||
985 | |||||
986 | // Show the preview of the personal message. |
||||
987 | echo ' |
||||
988 | <div id="preview_section"', isset($context['preview_message']) ? '' : ' class="hidden"', '> |
||||
989 | <div class="cat_bar"> |
||||
990 | <h3 class="catbg"> |
||||
991 | <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span> |
||||
992 | </h3> |
||||
993 | </div> |
||||
994 | <div class="windowbg"> |
||||
995 | <div class="post" id="preview_body"> |
||||
996 | ', empty($context['preview_message']) ? '<br>' : $context['preview_message'], ' |
||||
997 | </div> |
||||
998 | </div> |
||||
999 | <br class="clear"> |
||||
1000 | </div>'; |
||||
1001 | |||||
1002 | // Main message editing box. |
||||
1003 | echo ' |
||||
1004 | <form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);"> |
||||
1005 | <div class="cat_bar"> |
||||
1006 | <h3 class="catbg"> |
||||
1007 | <span class="main_icons inbox icon" title="', $txt['new_message'], '"></span> ', $txt['new_message'], ' |
||||
1008 | </h3> |
||||
1009 | </div> |
||||
1010 | <div class="roundframe">'; |
||||
1011 | |||||
1012 | // If there were errors for sending the PM, show them. |
||||
1013 | echo ' |
||||
1014 | <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '', empty($context['post_error']['messages']) ? ' hidden' : '', '" id="errors"> |
||||
1015 | <dl> |
||||
1016 | <dt> |
||||
1017 | <strong id="error_serious">', $txt['error_while_submitting'], '</strong> |
||||
1018 | </dt> |
||||
1019 | <dd class="error" id="error_list"> |
||||
1020 | ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), ' |
||||
1021 | </dd> |
||||
1022 | </dl> |
||||
1023 | </div>'; |
||||
1024 | |||||
1025 | if (!empty($modSettings['drafts_pm_enabled'])) |
||||
1026 | echo ' |
||||
1027 | <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', |
||||
1028 | sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), ' |
||||
1029 | ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), ' |
||||
1030 | </div>'; |
||||
1031 | |||||
1032 | echo ' |
||||
1033 | <dl id="post_header">'; |
||||
1034 | |||||
1035 | // To and bcc. Include a button to search for members. |
||||
1036 | echo ' |
||||
1037 | <dt> |
||||
1038 | <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), ' id="caption_to">', $txt['pm_to'], ':</span> |
||||
1039 | </dt>'; |
||||
1040 | |||||
1041 | // Autosuggest will be added by the JavaScript later on. |
||||
1042 | echo ' |
||||
1043 | <dd id="pm_to" class="clear_right"> |
||||
1044 | <input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="20">'; |
||||
1045 | |||||
1046 | // A link to add BCC, only visible with JavaScript enabled. |
||||
1047 | echo ' |
||||
1048 | <span class="smalltext" id="bcc_link_container" style="display: none;"></span>'; |
||||
1049 | |||||
1050 | // A div that'll contain the items found by the autosuggest. |
||||
1051 | echo ' |
||||
1052 | <div id="to_item_list_container"></div>'; |
||||
1053 | |||||
1054 | echo ' |
||||
1055 | </dd>'; |
||||
1056 | |||||
1057 | // This BCC row will be hidden by default if JavaScript is enabled. |
||||
1058 | echo ' |
||||
1059 | <dt class="clear_left" id="bcc_div"> |
||||
1060 | <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), ' id="caption_bbc">', $txt['pm_bcc'], ':</span> |
||||
1061 | </dt> |
||||
1062 | <dd id="bcc_div2"> |
||||
1063 | <input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="20"> |
||||
1064 | <div id="bcc_item_list_container"></div> |
||||
1065 | </dd>'; |
||||
1066 | |||||
1067 | // The subject of the PM. |
||||
1068 | echo ' |
||||
1069 | <dt class="clear_left"> |
||||
1070 | <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span> |
||||
1071 | </dt> |
||||
1072 | <dd id="pm_subject"> |
||||
1073 | <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '> |
||||
1074 | </dd> |
||||
1075 | </dl>'; |
||||
1076 | |||||
1077 | // Show BBC buttons, smileys and textbox. |
||||
1078 | echo ' |
||||
1079 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() Are you sure the usage of
template_control_richedi...age', 'bbcBox_message') is correct as it seems to always return null .
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() 'smileyBox_message' of type string is incompatible with the type boolean|null expected by parameter $smileyContainer of template_control_richedit() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
1080 | |||||
1081 | // If the admin enabled the pm drafts feature, show a draft selection box |
||||
1082 | if (!empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled'])) |
||||
1083 | { |
||||
1084 | echo ' |
||||
1085 | <div id="post_draft_options_header" class="title_bar"> |
||||
1086 | <h4 class="titlebg"> |
||||
1087 | <span id="postDraftExpand" class="toggle_up floatright" style="display: none;"></span> <strong><a href="#" id="postDraftExpandLink">', $txt['drafts_show'], '</a></strong> |
||||
1088 | </h4> |
||||
1089 | </div> |
||||
1090 | <div id="post_draft_options"> |
||||
1091 | <dl class="settings"> |
||||
1092 | <dt><strong>', $txt['subject'], '</strong></dt> |
||||
1093 | <dd><strong>', $txt['draft_saved_on'], '</strong></dd>'; |
||||
1094 | |||||
1095 | foreach ($context['drafts'] as $draft) |
||||
1096 | echo ' |
||||
1097 | <dt>', $draft['link'], '</dt> |
||||
1098 | <dd>', $draft['poster_time'], '</dd>'; |
||||
1099 | echo ' |
||||
1100 | </dl> |
||||
1101 | </div>'; |
||||
1102 | } |
||||
1103 | |||||
1104 | // Require an image to be typed to save spamming? |
||||
1105 | if ($context['require_verification']) |
||||
1106 | echo ' |
||||
1107 | <div class="post_verification"> |
||||
1108 | <strong>', $txt['pm_visual_verification_label'], ':</strong> |
||||
1109 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
||||
1110 | </div>'; |
||||
1111 | |||||
1112 | // Send, Preview, spellcheck buttons. |
||||
1113 | echo ' |
||||
1114 | <span id="post_confirm_buttons"> |
||||
1115 | ', template_control_richedit_buttons($context['post_box_name']), ' |
||||
0 ignored issues
–
show
Are you sure the usage of
template_control_richedi...ntext['post_box_name']) is correct as it seems to always return null .
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
1116 | </span> |
||||
1117 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1118 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '"> |
||||
1119 | <input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '"> |
||||
1120 | <input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '"> |
||||
1121 | <input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '"> |
||||
1122 | <input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '"> |
||||
1123 | <br class="clear_right"> |
||||
1124 | </div><!-- .roundframe --> |
||||
1125 | </form>'; |
||||
1126 | |||||
1127 | echo ' |
||||
1128 | <script>'; |
||||
1129 | |||||
1130 | // The functions used to preview a personal message without loading a new page. |
||||
1131 | echo ' |
||||
1132 | var txt_preview_title = "', $txt['preview_title'], '"; |
||||
1133 | var txt_preview_fetch = "', $txt['preview_fetch'], '"; |
||||
1134 | function previewPost() |
||||
1135 | { |
||||
1136 | if (window.XMLHttpRequest) |
||||
1137 | { |
||||
1138 | // Opera didn\'t support setRequestHeader() before 8.01. |
||||
1139 | // @todo Remove support for old browsers |
||||
1140 | if (\'opera\' in window) |
||||
1141 | { |
||||
1142 | var test = new XMLHttpRequest(); |
||||
1143 | if (!(\'setRequestHeader\' in test)) |
||||
1144 | return submitThisOnce(document.forms.postmodify); |
||||
1145 | } |
||||
1146 | // @todo Currently not sending poll options and option checkboxes. |
||||
1147 | var x = new Array(); |
||||
1148 | var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', \'to\', \'bcc\']; |
||||
1149 | var numericFields = [\'recipient_to[]\', \'recipient_bcc[]\']; |
||||
1150 | var checkboxFields = []; |
||||
1151 | |||||
1152 | for (var i = 0, n = textFields.length; i < n; i++) |
||||
1153 | if (textFields[i] in document.forms.postmodify) |
||||
1154 | { |
||||
1155 | // Handle the WYSIWYG editor. |
||||
1156 | if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled) |
||||
1157 | x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).php_to8bit().php_urlencode(); |
||||
1158 | else |
||||
1159 | x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.php_to8bit().php_urlencode(); |
||||
1160 | } |
||||
1161 | for (var i = 0, n = numericFields.length; i < n; i++) |
||||
1162 | if (numericFields[i] in document.forms.postmodify && \'value\' in document.forms.postmodify[numericFields[i]]) |
||||
1163 | x[x.length] = numericFields[i] + \'=\' + parseInt(document.forms.postmodify.elements[numericFields[i]].value); |
||||
1164 | for (var i = 0, n = checkboxFields.length; i < n; i++) |
||||
1165 | if (checkboxFields[i] in document.forms.postmodify && document.forms.postmodify.elements[checkboxFields[i]].checked) |
||||
1166 | x[x.length] = checkboxFields[i] + \'=\' + document.forms.postmodify.elements[checkboxFields[i]].value; |
||||
1167 | |||||
1168 | sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=pm;sa=send2;preview;xml\', x.join(\'&\'), onDocSent); |
||||
1169 | |||||
1170 | document.getElementById(\'preview_section\').style.display = \'\'; |
||||
1171 | setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title); |
||||
1172 | setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch); |
||||
1173 | |||||
1174 | return false; |
||||
1175 | } |
||||
1176 | else |
||||
1177 | return submitThisOnce(document.forms.postmodify); |
||||
1178 | } |
||||
1179 | function onDocSent(XMLDoc) |
||||
1180 | { |
||||
1181 | if (!XMLDoc) |
||||
1182 | { |
||||
1183 | document.forms.postmodify.preview.onclick = new function () |
||||
1184 | { |
||||
1185 | return true; |
||||
1186 | } |
||||
1187 | document.forms.postmodify.preview.click(); |
||||
1188 | } |
||||
1189 | |||||
1190 | // Show the preview section. |
||||
1191 | var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0]; |
||||
1192 | setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue); |
||||
1193 | |||||
1194 | var bodyText = \'\'; |
||||
1195 | for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++) |
||||
1196 | bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue; |
||||
1197 | |||||
1198 | setInnerHTML(document.getElementById(\'preview_body\'), bodyText); |
||||
1199 | document.getElementById(\'preview_body\').className = \'post\'; |
||||
1200 | |||||
1201 | // Show a list of errors (if any). |
||||
1202 | var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0]; |
||||
1203 | var errorList = new Array(); |
||||
1204 | for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++) |
||||
1205 | errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue; |
||||
1206 | document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\'; |
||||
1207 | setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br>\')); |
||||
1208 | |||||
1209 | // Adjust the color of captions if the given data is erroneous. |
||||
1210 | var captions = errors.getElementsByTagName(\'caption\'); |
||||
1211 | for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++) |
||||
1212 | if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\'))) |
||||
1213 | document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\'); |
||||
1214 | |||||
1215 | if (errors.getElementsByTagName(\'post_error\').length == 1) |
||||
1216 | document.forms.postmodify.', $context['post_box_name'], '.style.border = \'1px solid red\'; |
||||
1217 | else if (document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\') |
||||
1218 | { |
||||
1219 | if (\'runtimeStyle\' in document.forms.postmodify.', $context['post_box_name'], ') |
||||
1220 | document.forms.postmodify.', $context['post_box_name'], '.style.borderColor = \'\'; |
||||
1221 | else |
||||
1222 | document.forms.postmodify.', $context['post_box_name'], '.style.border = null; |
||||
1223 | } |
||||
1224 | location.hash = \'#\' + \'preview_section\'; |
||||
1225 | }'; |
||||
1226 | |||||
1227 | // Code for showing and hiding drafts |
||||
1228 | if (!empty($context['drafts'])) |
||||
1229 | echo ' |
||||
1230 | var oSwapDraftOptions = new smc_Toggle({ |
||||
1231 | bToggleEnabled: true, |
||||
1232 | bCurrentlyCollapsed: true, |
||||
1233 | aSwappableContainers: [ |
||||
1234 | \'post_draft_options\', |
||||
1235 | ], |
||||
1236 | aSwapImages: [ |
||||
1237 | { |
||||
1238 | sId: \'postDraftExpand\', |
||||
1239 | altExpanded: \'-\', |
||||
1240 | altCollapsed: \'+\' |
||||
1241 | } |
||||
1242 | ], |
||||
1243 | aSwapLinks: [ |
||||
1244 | { |
||||
1245 | sId: \'postDraftExpandLink\', |
||||
1246 | msgExpanded: ', JavaScriptEscape($txt['draft_hide']), ', |
||||
1247 | msgCollapsed: ', JavaScriptEscape($txt['drafts_show']), ' |
||||
1248 | } |
||||
1249 | ] |
||||
1250 | });'; |
||||
1251 | |||||
1252 | echo ' |
||||
1253 | </script>'; |
||||
1254 | |||||
1255 | // Show the message you're replying to. |
||||
1256 | if ($context['reply']) |
||||
1257 | echo ' |
||||
1258 | <br><br> |
||||
1259 | <div class="cat_bar"> |
||||
1260 | <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3> |
||||
1261 | </div> |
||||
1262 | <div class="windowbg"> |
||||
1263 | <div class="clear"> |
||||
1264 | <span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span> |
||||
1265 | <strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong> |
||||
1266 | </div> |
||||
1267 | <hr> |
||||
1268 | ', $context['quoted_message']['body'], ' |
||||
1269 | </div> |
||||
1270 | <br class="clear">'; |
||||
1271 | |||||
1272 | echo ' |
||||
1273 | <script> |
||||
1274 | var oPersonalMessageSend = new smf_PersonalMessageSend({ |
||||
1275 | sSelf: \'oPersonalMessageSend\', |
||||
1276 | sSessionId: smf_session_id, |
||||
1277 | sSessionVar: smf_session_var, |
||||
1278 | sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\', |
||||
1279 | sToControlId: \'to_control\', |
||||
1280 | aToRecipients: ['; |
||||
1281 | |||||
1282 | foreach ($context['recipients']['to'] as $i => $member) |
||||
1283 | echo ' |
||||
1284 | { |
||||
1285 | sItemId: ', JavaScriptEscape($member['id']), ', |
||||
1286 | sItemName: ', JavaScriptEscape($member['name']), ' |
||||
1287 | }', $i == count($context['recipients']['to']) - 1 ? '' : ','; |
||||
1288 | |||||
1289 | echo ' |
||||
1290 | ], |
||||
1291 | aBccRecipients: ['; |
||||
1292 | |||||
1293 | foreach ($context['recipients']['bcc'] as $i => $member) |
||||
1294 | echo ' |
||||
1295 | { |
||||
1296 | sItemId: ', JavaScriptEscape($member['id']), ', |
||||
1297 | sItemName: ', JavaScriptEscape($member['name']), ' |
||||
1298 | }', $i == count($context['recipients']['bcc']) - 1 ? '' : ','; |
||||
1299 | |||||
1300 | echo ' |
||||
1301 | ], |
||||
1302 | sBccControlId: \'bcc_control\', |
||||
1303 | sBccDivId: \'bcc_div\', |
||||
1304 | sBccDivId2: \'bcc_div2\', |
||||
1305 | sBccLinkId: \'bcc_link\', |
||||
1306 | sBccLinkContainerId: \'bcc_link_container\', |
||||
1307 | bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ', |
||||
1308 | sShowBccLinkTemplate: ', JavaScriptEscape(' |
||||
1309 | <a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqOverlayDiv(this.href);">(?)</a>' |
||||
1310 | ), ' |
||||
1311 | });'; |
||||
1312 | |||||
1313 | echo ' |
||||
1314 | </script>'; |
||||
1315 | } |
||||
1316 | |||||
1317 | /** |
||||
1318 | * This template asks the user whether they wish to empty out their folder/messages. |
||||
1319 | */ |
||||
1320 | function template_ask_delete() |
||||
1321 | { |
||||
1322 | global $context, $scripturl, $txt; |
||||
1323 | |||||
1324 | echo ' |
||||
1325 | <div class="cat_bar"> |
||||
1326 | <h3 class="catbg"> |
||||
1327 | ', ($context['delete_all'] ? $txt['delete_message'] : $txt['delete_all']), ' |
||||
1328 | </h3> |
||||
1329 | </div> |
||||
1330 | <div class="windowbg"> |
||||
1331 | <p>', $txt['delete_all_confirm'], '</p> |
||||
1332 | <br> |
||||
1333 | <strong><a href="', $scripturl, '?action=pm;sa=removeall2;f=', $context['folder'], ';', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="javascript:history.go(-1);">', $txt['no'], '</a></strong> |
||||
1334 | </div>'; |
||||
1335 | } |
||||
1336 | |||||
1337 | /** |
||||
1338 | * This template asks the user what messages they want to prune. |
||||
1339 | */ |
||||
1340 | function template_prune() |
||||
1341 | { |
||||
1342 | global $context, $scripturl, $txt; |
||||
1343 | |||||
1344 | echo ' |
||||
1345 | <div class="cat_bar"> |
||||
1346 | <h3 class="catbg">', $txt['pm_prune'], '</h3> |
||||
1347 | </div> |
||||
1348 | <div class="windowbg"> |
||||
1349 | <form action="', $scripturl, '?action=pm;sa=prune" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['pm_prune_warning'], '\');"> |
||||
1350 | <p>', $txt['pm_prune_desc1'], ' <input type="text" name="age" size="3" value="14"> ', $txt['pm_prune_desc2'], '</p> |
||||
1351 | <input type="submit" value="', $txt['delete'], '" class="button"> |
||||
1352 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1353 | </form> |
||||
1354 | </div> |
||||
1355 | <div class="windowbg"> |
||||
1356 | <form action="', $scripturl, '?action=pm;sa=removeall2" method="post" onsubmit="return confirm(\'', $txt['pm_remove_all_warning'], '\');"> |
||||
1357 | <p>', $txt['pm_remove_all'], '</p> |
||||
1358 | <input type="submit" value="', $txt['delete_all_prune'], '" class="button"> |
||||
1359 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1360 | </form> |
||||
1361 | </div>'; |
||||
1362 | } |
||||
1363 | |||||
1364 | /** |
||||
1365 | * Here we allow the user to setup labels, remove labels and change rules for labels (i.e, do quite a bit) |
||||
1366 | */ |
||||
1367 | function template_labels() |
||||
1368 | { |
||||
1369 | global $context, $scripturl, $txt; |
||||
1370 | |||||
1371 | echo ' |
||||
1372 | <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '"> |
||||
1373 | <div class="cat_bar"> |
||||
1374 | <h3 class="catbg">', $txt['pm_manage_labels'], '</h3> |
||||
1375 | </div> |
||||
1376 | <div class="information"> |
||||
1377 | ', $txt['pm_labels_desc'], ' |
||||
1378 | </div> |
||||
1379 | <table class="table_grid"> |
||||
1380 | <thead> |
||||
1381 | <tr class="title_bar"> |
||||
1382 | <th class="lefttext"> |
||||
1383 | ', $txt['pm_label_name'], ' |
||||
1384 | </th> |
||||
1385 | <th class="centertext table_icon">'; |
||||
1386 | |||||
1387 | if (count($context['labels']) > 2) |
||||
1388 | echo ' |
||||
1389 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
||||
1390 | |||||
1391 | echo ' |
||||
1392 | </th> |
||||
1393 | </tr> |
||||
1394 | </thead> |
||||
1395 | <tbody>'; |
||||
1396 | if (count($context['labels']) < 2) |
||||
1397 | echo ' |
||||
1398 | <tr class="windowbg"> |
||||
1399 | <td colspan="2">', $txt['pm_labels_no_exist'], '</td> |
||||
1400 | </tr>'; |
||||
1401 | else |
||||
1402 | { |
||||
1403 | foreach ($context['labels'] as $label) |
||||
1404 | { |
||||
1405 | if ($label['id'] == -1) |
||||
1406 | continue; |
||||
1407 | |||||
1408 | echo ' |
||||
1409 | <tr class="windowbg"> |
||||
1410 | <td> |
||||
1411 | <input type="text" name="label_name[', $label['id'], ']" value="', $label['name'], '" size="30" maxlength="30"> |
||||
1412 | </td> |
||||
1413 | <td class="table_icon"><input type="checkbox" name="delete_label[', $label['id'], ']"></td> |
||||
1414 | </tr>'; |
||||
1415 | } |
||||
1416 | } |
||||
1417 | echo ' |
||||
1418 | </tbody> |
||||
1419 | </table>'; |
||||
1420 | |||||
1421 | if (!count($context['labels']) < 2) |
||||
1422 | echo ' |
||||
1423 | <div class="block righttext"> |
||||
1424 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
||||
1425 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button you_sure"> |
||||
1426 | </div>'; |
||||
1427 | |||||
1428 | echo ' |
||||
1429 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1430 | </form> |
||||
1431 | <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '"> |
||||
1432 | <div class="cat_bar"> |
||||
1433 | <h3 class="catbg">', $txt['pm_label_add_new'], '</h3> |
||||
1434 | </div> |
||||
1435 | <div class="windowbg"> |
||||
1436 | <dl class="settings"> |
||||
1437 | <dt> |
||||
1438 | <strong><label for="add_label">', $txt['pm_label_name'], '</label>:</strong> |
||||
1439 | </dt> |
||||
1440 | <dd> |
||||
1441 | <input type="text" id="add_label" name="label" value="" size="30" maxlength="30"> |
||||
1442 | </dd> |
||||
1443 | </dl> |
||||
1444 | <input type="submit" name="add" value="', $txt['pm_label_add_new'], '" class="button floatright"> |
||||
1445 | </div> |
||||
1446 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1447 | </form> |
||||
1448 | <br>'; |
||||
1449 | } |
||||
1450 | |||||
1451 | /** |
||||
1452 | * Template for reporting a personal message. |
||||
1453 | */ |
||||
1454 | function template_report_message() |
||||
1455 | { |
||||
1456 | global $context, $txt, $scripturl; |
||||
1457 | |||||
1458 | echo ' |
||||
1459 | <form action="', $scripturl, '?action=pm;sa=report;l=', $context['current_label_id'], '" method="post" accept-charset="', $context['character_set'], '"> |
||||
1460 | <input type="hidden" name="pmsg" value="', $context['pm_id'], '"> |
||||
1461 | <div class="information"> |
||||
1462 | ', $txt['pm_report_desc'], ' |
||||
1463 | </div> |
||||
1464 | <div class="cat_bar"> |
||||
1465 | <h3 class="catbg">', $txt['pm_report_title'], '</h3> |
||||
1466 | </div> |
||||
1467 | <div class="windowbg"> |
||||
1468 | <dl class="settings">'; |
||||
1469 | |||||
1470 | // If there is more than one admin on the forum, allow the user to choose the one they want to direct to. |
||||
1471 | // @todo Why? |
||||
1472 | if ($context['admin_count'] > 1) |
||||
1473 | { |
||||
1474 | echo ' |
||||
1475 | <dt> |
||||
1476 | <strong>', $txt['pm_report_admins'], ':</strong> |
||||
1477 | </dt> |
||||
1478 | <dd> |
||||
1479 | <select name="id_admin"> |
||||
1480 | <option value="0">', $txt['pm_report_all_admins'], '</option>'; |
||||
1481 | |||||
1482 | foreach ($context['admins'] as $id => $name) |
||||
1483 | echo ' |
||||
1484 | <option value="', $id, '">', $name, '</option>'; |
||||
1485 | |||||
1486 | echo ' |
||||
1487 | </select> |
||||
1488 | </dd>'; |
||||
1489 | } |
||||
1490 | |||||
1491 | echo ' |
||||
1492 | <dt> |
||||
1493 | <strong>', $txt['pm_report_reason'], ':</strong> |
||||
1494 | </dt> |
||||
1495 | <dd> |
||||
1496 | <textarea name="reason" rows="4" cols="70" style="width: 80%;"></textarea> |
||||
1497 | </dd> |
||||
1498 | </dl> |
||||
1499 | <div class="righttext"> |
||||
1500 | <input type="submit" name="report" value="', $txt['pm_report_message'], '" class="button"> |
||||
1501 | </div> |
||||
1502 | </div><!-- .windowbg --> |
||||
1503 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1504 | </form>'; |
||||
1505 | } |
||||
1506 | |||||
1507 | /** |
||||
1508 | * Little template just to say "Yep, it's been submitted" |
||||
1509 | */ |
||||
1510 | function template_report_message_complete() |
||||
1511 | { |
||||
1512 | global $context, $txt, $scripturl; |
||||
1513 | |||||
1514 | echo ' |
||||
1515 | <div class="cat_bar"> |
||||
1516 | <h3 class="catbg">', $txt['pm_report_title'], '</h3> |
||||
1517 | </div> |
||||
1518 | <div class="windowbg"> |
||||
1519 | <p>', $txt['pm_report_done'], '</p> |
||||
1520 | <a href="', $scripturl, '?action=pm;l=', $context['current_label_id'], '">', $txt['pm_report_return'], '</a> |
||||
1521 | </div>'; |
||||
1522 | } |
||||
1523 | |||||
1524 | /** |
||||
1525 | * Manage rules. |
||||
1526 | */ |
||||
1527 | function template_rules() |
||||
1528 | { |
||||
1529 | global $context, $txt, $scripturl; |
||||
1530 | |||||
1531 | echo ' |
||||
1532 | <form action="', $scripturl, '?action=pm;sa=manrules" method="post" accept-charset="', $context['character_set'], '" name="manRules" id="manrules"> |
||||
1533 | <div class="cat_bar"> |
||||
1534 | <h3 class="catbg">', $txt['pm_manage_rules'], '</h3> |
||||
1535 | </div> |
||||
1536 | <div class="information"> |
||||
1537 | ', $txt['pm_manage_rules_desc'], ' |
||||
1538 | </div> |
||||
1539 | <table class="table_grid"> |
||||
1540 | <thead> |
||||
1541 | <tr class="title_bar"> |
||||
1542 | <th class="lefttext"> |
||||
1543 | ', $txt['pm_rule_title'], ' |
||||
1544 | </th> |
||||
1545 | <th class="centertext table_icon">'; |
||||
1546 | |||||
1547 | if (!empty($context['rules'])) |
||||
1548 | echo ' |
||||
1549 | <input type="checkbox" onclick="invertAll(this, this.form);">'; |
||||
1550 | |||||
1551 | echo ' |
||||
1552 | </th> |
||||
1553 | </tr> |
||||
1554 | </thead> |
||||
1555 | <tbody>'; |
||||
1556 | |||||
1557 | if (empty($context['rules'])) |
||||
1558 | echo ' |
||||
1559 | <tr class="windowbg"> |
||||
1560 | <td colspan="2"> |
||||
1561 | ', $txt['pm_rules_none'], ' |
||||
1562 | </td> |
||||
1563 | </tr>'; |
||||
1564 | |||||
1565 | foreach ($context['rules'] as $rule) |
||||
1566 | echo ' |
||||
1567 | <tr class="windowbg"> |
||||
1568 | <td> |
||||
1569 | <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a> |
||||
1570 | </td> |
||||
1571 | <td class="table_icon"> |
||||
1572 | <input type="checkbox" name="delrule[', $rule['id'], ']"> |
||||
1573 | </td> |
||||
1574 | </tr>'; |
||||
1575 | |||||
1576 | echo ' |
||||
1577 | </tbody> |
||||
1578 | </table> |
||||
1579 | <div class="righttext"> |
||||
1580 | <a class="button" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>'; |
||||
1581 | |||||
1582 | if (!empty($context['rules'])) |
||||
1583 | echo ' |
||||
1584 | [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]'; |
||||
1585 | |||||
1586 | if (!empty($context['rules'])) |
||||
1587 | echo ' |
||||
1588 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1589 | <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button smalltext you_sure">'; |
||||
1590 | |||||
1591 | echo ' |
||||
1592 | </div> |
||||
1593 | </form>'; |
||||
1594 | |||||
1595 | } |
||||
1596 | |||||
1597 | /** |
||||
1598 | * Template for adding/editing a rule. |
||||
1599 | */ |
||||
1600 | function template_add_rule() |
||||
1601 | { |
||||
1602 | global $context, $txt, $scripturl; |
||||
1603 | |||||
1604 | echo ' |
||||
1605 | <script> |
||||
1606 | var criteriaNum = 0; |
||||
1607 | var actionNum = 0; |
||||
1608 | var groups = new Array() |
||||
1609 | var labels = new Array()'; |
||||
1610 | |||||
1611 | foreach ($context['groups'] as $id => $title) |
||||
1612 | echo ' |
||||
1613 | groups[', $id, '] = "', addslashes($title), '";'; |
||||
1614 | |||||
1615 | foreach ($context['labels'] as $label) |
||||
1616 | if ($label['id'] != -1) |
||||
1617 | echo ' |
||||
1618 | labels[', ($label['id']), '] = "', addslashes($label['name']), '";'; |
||||
1619 | |||||
1620 | echo ' |
||||
1621 | function addCriteriaOption() |
||||
1622 | { |
||||
1623 | if (criteriaNum == 0) |
||||
1624 | { |
||||
1625 | for (var i = 0; i < document.forms.addrule.elements.length; i++) |
||||
1626 | if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype") |
||||
1627 | criteriaNum++; |
||||
1628 | } |
||||
1629 | |||||
1630 | if (criteriaNum++ >= ', $context['rule_limiters']['criteria'], ') |
||||
1631 | return false; |
||||
1632 | |||||
1633 | setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select> <span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value=""><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>'; |
||||
1634 | |||||
1635 | foreach ($context['groups'] as $id => $group) |
||||
1636 | echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>'; |
||||
1637 | |||||
1638 | echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\'); |
||||
1639 | |||||
1640 | if (criteriaNum + 1 > ', $context['rule_limiters']['criteria'], ') |
||||
1641 | document.getElementById(\'addonjs1\').style.display = \'none\'; |
||||
1642 | } |
||||
1643 | |||||
1644 | function addActionOption() |
||||
1645 | { |
||||
1646 | if (actionNum == 0) |
||||
1647 | { |
||||
1648 | for (var i = 0; i < document.forms.addrule.elements.length; i++) |
||||
1649 | if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype") |
||||
1650 | actionNum++; |
||||
1651 | } |
||||
1652 | if (actionNum++ >= ', $context['rule_limiters']['actions'], ') |
||||
1653 | return false; |
||||
1654 | |||||
1655 | setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select> <span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>'; |
||||
1656 | |||||
1657 | foreach ($context['labels'] as $label) |
||||
1658 | if ($label['id'] != -1) |
||||
1659 | echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>'; |
||||
1660 | |||||
1661 | echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\'); |
||||
1662 | |||||
1663 | if (actionNum + 1 > ', $context['rule_limiters']['actions'], ') |
||||
1664 | document.getElementById(\'addonjs2\').style.display = \'none\'; |
||||
1665 | } |
||||
1666 | |||||
1667 | // Rebuild the rule description! |
||||
1668 | function rebuildRuleDesc() |
||||
1669 | { |
||||
1670 | // Start with nothing. |
||||
1671 | var text = ""; |
||||
1672 | var joinText = ""; |
||||
1673 | var actionText = ""; |
||||
1674 | var hadBuddy = false; |
||||
1675 | var foundCriteria = false; |
||||
1676 | var foundAction = false; |
||||
1677 | var curNum, curVal, curDef; |
||||
1678 | |||||
1679 | for (var i = 0; i < document.forms.addrule.elements.length; i++) |
||||
1680 | { |
||||
1681 | if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype") |
||||
1682 | { |
||||
1683 | if (foundCriteria) |
||||
1684 | joinText = document.getElementById("logic").value == \'and\' ? ', JavaScriptEscape(' <em>' . $txt['pm_readable_and'] . '</em> '), ' : ', JavaScriptEscape(' <em>' . $txt['pm_readable_or'] . '</em> '), '; |
||||
1685 | else |
||||
1686 | joinText = \'\'; |
||||
1687 | foundCriteria = true; |
||||
1688 | |||||
1689 | curNum = document.forms.addrule.elements[i].id.match(/\d+/); |
||||
1690 | curVal = document.forms.addrule.elements[i].value; |
||||
1691 | if (curVal == "gid") |
||||
1692 | curDef = document.getElementById("ruledefgroup" + curNum).value.php_htmlspecialchars(); |
||||
1693 | else if (curVal != "bud") |
||||
1694 | curDef = document.getElementById("ruledef" + curNum).value.php_htmlspecialchars(); |
||||
1695 | else |
||||
1696 | curDef = ""; |
||||
1697 | |||||
1698 | // What type of test is this? |
||||
1699 | if (curVal == "mid" && curDef) |
||||
1700 | text += joinText + ', JavaScriptEscape($txt['pm_readable_member']), '.replace("{MEMBER}", curDef); |
||||
1701 | else if (curVal == "gid" && curDef && groups[curDef]) |
||||
1702 | text += joinText + ', JavaScriptEscape($txt['pm_readable_group']), '.replace("{GROUP}", groups[curDef]); |
||||
1703 | else if (curVal == "sub" && curDef) |
||||
1704 | text += joinText + ', JavaScriptEscape($txt['pm_readable_subject']), '.replace("{SUBJECT}", curDef); |
||||
1705 | else if (curVal == "msg" && curDef) |
||||
1706 | text += joinText + ', JavaScriptEscape($txt['pm_readable_body']), '.replace("{BODY}", curDef); |
||||
1707 | else if (curVal == "bud" && !hadBuddy) |
||||
1708 | { |
||||
1709 | text += joinText + ', JavaScriptEscape($txt['pm_readable_buddy']), '; |
||||
1710 | hadBuddy = true; |
||||
1711 | } |
||||
1712 | } |
||||
1713 | if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype") |
||||
1714 | { |
||||
1715 | if (foundAction) |
||||
1716 | joinText = ', JavaScriptEscape(' <em>' . $txt['pm_readable_and'] . '</em> '), '; |
||||
1717 | else |
||||
1718 | joinText = ""; |
||||
1719 | foundAction = true; |
||||
1720 | |||||
1721 | curNum = document.forms.addrule.elements[i].id.match(/\d+/); |
||||
1722 | curVal = document.forms.addrule.elements[i].value; |
||||
1723 | if (curVal == "lab") |
||||
1724 | curDef = document.getElementById("labdef" + curNum).value.php_htmlspecialchars(); |
||||
1725 | else |
||||
1726 | curDef = ""; |
||||
1727 | |||||
1728 | // Now pick the actions. |
||||
1729 | if (curVal == "lab" && curDef && labels[curDef]) |
||||
1730 | actionText += joinText + ', JavaScriptEscape($txt['pm_readable_label']), '.replace("{LABEL}", labels[curDef]); |
||||
1731 | else if (curVal == "del") |
||||
1732 | actionText += joinText + ', JavaScriptEscape($txt['pm_readable_delete']), '; |
||||
1733 | } |
||||
1734 | } |
||||
1735 | |||||
1736 | // If still nothing make it default! |
||||
1737 | if (text == "" || !foundCriteria) |
||||
1738 | text = "', $txt['pm_rule_not_defined'], '"; |
||||
1739 | else |
||||
1740 | { |
||||
1741 | if (actionText != "") |
||||
1742 | text += ', JavaScriptEscape(' <strong>' . $txt['pm_readable_then'] . '</strong> '), ' + actionText; |
||||
1743 | text = ', JavaScriptEscape($txt['pm_readable_start']), ' + text + ', JavaScriptEscape($txt['pm_readable_end']), '; |
||||
1744 | } |
||||
1745 | |||||
1746 | // Set the actual HTML! |
||||
1747 | setInnerHTML(document.getElementById("ruletext"), text); |
||||
1748 | } |
||||
1749 | </script>'; |
||||
1750 | |||||
1751 | echo ' |
||||
1752 | <form action="', $scripturl, '?action=pm;sa=manrules;save;rid=', $context['rid'], '" method="post" accept-charset="', $context['character_set'], '" name="addrule" id="addrule" class="flow_hidden"> |
||||
1753 | <div class="cat_bar"> |
||||
1754 | <h3 class="catbg">', $context['rid'] == 0 ? $txt['pm_add_rule'] : $txt['pm_edit_rule'], '</h3> |
||||
1755 | </div> |
||||
1756 | <div class="windowbg"> |
||||
1757 | <dl class="addrules"> |
||||
1758 | <dt class="floatleft"> |
||||
1759 | <strong>', $txt['pm_rule_name'], ':</strong><br> |
||||
1760 | <span class="smalltext">', $txt['pm_rule_name_desc'], '</span> |
||||
1761 | </dt> |
||||
1762 | <dd class="floatleft"> |
||||
1763 | <input type="text" name="rule_name" value="', empty($context['rule']['name']) ? $txt['pm_rule_name_default'] : $context['rule']['name'], '" size="50"> |
||||
1764 | </dd> |
||||
1765 | </dl> |
||||
1766 | <fieldset> |
||||
1767 | <legend>', $txt['pm_rule_criteria'], '</legend>'; |
||||
1768 | |||||
1769 | // Add a dummy criteria to allow expansion for none js users. |
||||
1770 | $context['rule']['criteria'][] = array('t' => '', 'v' => ''); |
||||
1771 | |||||
1772 | // For each criteria print it out. |
||||
1773 | $isFirst = true; |
||||
1774 | foreach ($context['rule']['criteria'] as $k => $criteria) |
||||
1775 | { |
||||
1776 | if (!$isFirst && $criteria['t'] == '') |
||||
1777 | echo '<div id="removeonjs1">'; |
||||
1778 | |||||
1779 | elseif (!$isFirst) |
||||
1780 | echo '<br>'; |
||||
1781 | |||||
1782 | echo ' |
||||
1783 | <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();"> |
||||
1784 | <option value="">', $txt['pm_rule_criteria_pick'], ':</option>'; |
||||
1785 | |||||
1786 | foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) |
||||
1787 | echo ' |
||||
1788 | <option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>'; |
||||
1789 | |||||
1790 | echo ' |
||||
1791 | </select> |
||||
1792 | <span id="defdiv', $k, '" ', !in_array($criteria['t'], array('gid', 'bud')) ? '' : 'style="display: none;"', '> |
||||
1793 | <input type="text" name="ruledef[', $k, ']" id="ruledef', $k, '" onkeyup="rebuildRuleDesc();" value="', in_array($criteria['t'], array('mid', 'sub', 'msg')) ? $criteria['v'] : '', '"> |
||||
1794 | </span> |
||||
1795 | <span id="defseldiv', $k, '" ', $criteria['t'] == 'gid' ? '' : 'style="display: none;"', '> |
||||
1796 | <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();"> |
||||
1797 | <option value="">', $txt['pm_rule_sel_group'], '</option>'; |
||||
1798 | |||||
1799 | foreach ($context['groups'] as $id => $group) |
||||
1800 | echo ' |
||||
1801 | <option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>'; |
||||
1802 | echo ' |
||||
1803 | </select> |
||||
1804 | </span>'; |
||||
1805 | |||||
1806 | // If this is the dummy we add a means to hide for non js users. |
||||
1807 | if ($isFirst) |
||||
1808 | $isFirst = false; |
||||
1809 | |||||
1810 | elseif ($criteria['t'] == '') |
||||
1811 | echo '</div><!-- .removeonjs1 -->'; |
||||
1812 | } |
||||
1813 | |||||
1814 | echo ' |
||||
1815 | <span id="criteriaAddHere"></span><br> |
||||
1816 | <a href="#" onclick="addCriteriaOption(); return false;" id="addonjs1" style="display: none;">(', $txt['pm_rule_criteria_add'], ')</a> |
||||
1817 | <br><br> |
||||
1818 | ', $txt['pm_rule_logic'], ': |
||||
1819 | <select name="rule_logic" id="logic" onchange="rebuildRuleDesc();"> |
||||
1820 | <option value="and"', $context['rule']['logic'] == 'and' ? ' selected' : '', '>', $txt['pm_rule_logic_and'], '</option> |
||||
1821 | <option value="or"', $context['rule']['logic'] == 'or' ? ' selected' : '', '>', $txt['pm_rule_logic_or'], '</option> |
||||
1822 | </select> |
||||
1823 | </fieldset> |
||||
1824 | <fieldset> |
||||
1825 | <legend>', $txt['pm_rule_actions'], '</legend>'; |
||||
1826 | |||||
1827 | // As with criteria - add a dummy action for "expansion". |
||||
1828 | $context['rule']['actions'][] = array('t' => '', 'v' => ''); |
||||
1829 | |||||
1830 | // Print each action. |
||||
1831 | $isFirst = true; |
||||
1832 | foreach ($context['rule']['actions'] as $k => $action) |
||||
1833 | { |
||||
1834 | if (!$isFirst && $action['t'] == '') |
||||
1835 | echo '<div id="removeonjs2">'; |
||||
1836 | elseif (!$isFirst) |
||||
1837 | echo '<br>'; |
||||
1838 | |||||
1839 | echo ' |
||||
1840 | <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();"> |
||||
1841 | <option value="">', $txt['pm_rule_sel_action'], ':</option> |
||||
1842 | <option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option> |
||||
1843 | <option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option> |
||||
1844 | </select> |
||||
1845 | <span id="labdiv', $k, '"> |
||||
1846 | <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();"> |
||||
1847 | <option value="">', $txt['pm_rule_sel_label'], '</option>'; |
||||
1848 | |||||
1849 | foreach ($context['labels'] as $label) |
||||
1850 | if ($label['id'] != -1) |
||||
1851 | echo ' |
||||
1852 | <option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>'; |
||||
1853 | |||||
1854 | echo ' |
||||
1855 | </select> |
||||
1856 | </span>'; |
||||
1857 | |||||
1858 | if ($isFirst) |
||||
1859 | $isFirst = false; |
||||
1860 | |||||
1861 | elseif ($action['t'] == '') |
||||
1862 | echo '</div><!-- .removeonjs2 -->'; |
||||
1863 | } |
||||
1864 | |||||
1865 | echo ' |
||||
1866 | <span id="actionAddHere"></span><br> |
||||
1867 | <a href="#" onclick="addActionOption(); return false;" id="addonjs2" style="display: none;">(', $txt['pm_rule_add_action'], ')</a> |
||||
1868 | </fieldset> |
||||
1869 | <div class="cat_bar"> |
||||
1870 | <h3 class="catbg">', $txt['pm_rule_description'], '</h3> |
||||
1871 | </div> |
||||
1872 | <div class="information"> |
||||
1873 | <div id="ruletext">', $txt['pm_rule_js_disabled'], '</div> |
||||
1874 | </div> |
||||
1875 | <div class="righttext"> |
||||
1876 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||||
1877 | <input type="submit" name="save" value="', $txt['pm_rule_save'], '" class="button"> |
||||
1878 | </div> |
||||
1879 | </div><!-- .windowbg --> |
||||
1880 | </form>'; |
||||
1881 | |||||
1882 | // Now setup all the bits! |
||||
1883 | echo ' |
||||
1884 | <script>'; |
||||
1885 | |||||
1886 | foreach ($context['rule']['criteria'] as $k => $c) |
||||
1887 | echo ' |
||||
1888 | updateRuleDef(', $k, ');'; |
||||
1889 | |||||
1890 | foreach ($context['rule']['actions'] as $k => $c) |
||||
1891 | echo ' |
||||
1892 | updateActionDef(', $k, ');'; |
||||
1893 | |||||
1894 | echo ' |
||||
1895 | rebuildRuleDesc();'; |
||||
1896 | |||||
1897 | // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff. |
||||
1898 | if ($context['rid']) |
||||
1899 | echo ' |
||||
1900 | document.getElementById("removeonjs1").style.display = "none"; |
||||
1901 | document.getElementById("removeonjs2").style.display = "none";'; |
||||
1902 | |||||
1903 | if (count($context['rule']['criteria']) <= $context['rule_limiters']['criteria']) |
||||
1904 | echo ' |
||||
1905 | document.getElementById("addonjs1").style.display = "";'; |
||||
1906 | |||||
1907 | if (count($context['rule']['actions']) <= $context['rule_limiters']['actions']) |
||||
1908 | echo ' |
||||
1909 | document.getElementById("addonjs2").style.display = "";'; |
||||
1910 | |||||
1911 | echo ' |
||||
1912 | </script>'; |
||||
1913 | } |
||||
1914 | |||||
1915 | /** |
||||
1916 | * Template for showing all of a user's PM drafts. |
||||
1917 | */ |
||||
1918 | function template_showPMDrafts() |
||||
1919 | { |
||||
1920 | global $context, $scripturl, $txt; |
||||
1921 | |||||
1922 | echo ' |
||||
1923 | <div class="cat_bar"> |
||||
1924 | <h3 class="catbg"> |
||||
1925 | <span class="main_icons inbox"></span> ', $txt['drafts_show'], ' |
||||
1926 | </h3> |
||||
1927 | </div> |
||||
1928 | <div class="pagesection"> |
||||
1929 | <span>', $context['page_index'], '</span> |
||||
1930 | </div>'; |
||||
1931 | |||||
1932 | // No drafts? Just show an informative message. |
||||
1933 | if (empty($context['drafts'])) |
||||
1934 | echo ' |
||||
1935 | <div class="windowbg centertext"> |
||||
1936 | ', $txt['draft_none'], ' |
||||
1937 | </div>'; |
||||
1938 | else |
||||
1939 | { |
||||
1940 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
||||
1941 | foreach ($context['drafts'] as $draft) |
||||
1942 | { |
||||
1943 | echo ' |
||||
1944 | <div class="windowbg"> |
||||
1945 | <div class="counter">', $draft['counter'], '</div> |
||||
1946 | <div class="topic_details"> |
||||
1947 | <div class="floatright smalltext righttext"> |
||||
1948 | <div class="recipient_to">« <strong>', $txt['to'], ':</strong> ', implode(', ', $draft['recipients']['to']), ' »</div>'; |
||||
1949 | |||||
1950 | if(!empty($draft['recipients']['bcc'])) |
||||
1951 | echo' |
||||
1952 | <div class="pm_bbc">« <strong>', $txt['pm_bcc'], ':</strong> ', implode(', ', $draft['recipients']['bcc']), ' »</div>'; |
||||
1953 | |||||
1954 | echo ' |
||||
1955 | </div> |
||||
1956 | <h5> |
||||
1957 | <strong>', $draft['subject'], '</strong> |
||||
1958 | </h5> |
||||
1959 | <span class="smalltext">« <strong>', $txt['draft_saved_on'], ':</strong> ', sprintf($txt['draft_days_ago'], $draft['age']), (!empty($draft['remaining']) ? ', ' . sprintf($txt['draft_retain'], $draft['remaining']) : ''), '»</span><br> |
||||
1960 | </div> |
||||
1961 | <div class="list_posts"> |
||||
1962 | ', $draft['body'], ' |
||||
1963 | </div>'; |
||||
1964 | |||||
1965 | // Draft buttons |
||||
1966 | template_quickbuttons($draft['quickbuttons'], 'pm_drafts'); |
||||
1967 | |||||
1968 | echo ' |
||||
1969 | </div><!-- .windowbg -->'; |
||||
1970 | } |
||||
1971 | } |
||||
1972 | |||||
1973 | // Show page numbers. |
||||
1974 | echo ' |
||||
1975 | <div class="pagesection"> |
||||
1976 | <span>', $context['page_index'], '</span> |
||||
1977 | </div>'; |
||||
1978 | } |
||||
1979 | |||||
1980 | ?> |