comparison forum/Themes/Vamp/PersonalMessage.template.php @ 76:e3e11437ecea website

Add forum code
author Chris Cannam
date Sun, 07 Jul 2013 11:25:48 +0200
parents
children
comparison
equal deleted inserted replaced
75:72f59aa7e503 76:e3e11437ecea
1 <?php
2 /**
3 * Simple Machines Forum (SMF)
4 *
5 * @package SMF
6 * @author Simple Machines
7 * @copyright 2011 Simple Machines
8 * @license http://www.simplemachines.org/about/smf/license.php BSD
9 *
10 * @version 2.0
11 */
12
13 // This is the main sidebar for the personal messages section.
14 function template_pm_above()
15 {
16 global $context, $settings, $options, $txt;
17
18 echo '
19 <div id="personal_messages">';
20
21 // Show the capacity bar, if available.
22 if (!empty($context['limit_bar']))
23 echo '
24 <div class="title_bar">
25 <h3 class="titlebg">
26 <span class="floatleft">', $txt['pm_capacity'], ':</span>
27 <span class="floatleft capacity_bar">
28 <span class="', $context['limit_bar']['percent'] > 85 ? 'full' : ($context['limit_bar']['percent'] > 40 ? 'filled' : 'empty'), '" style="width: ', $context['limit_bar']['percent'] / 10, 'em;"></span>
29 </span>
30 <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
31 </h3>
32 </div>';
33
34 // Message sent? Show a small indication.
35 if (isset($context['pm_sent']))
36 echo '
37 <div class="windowbg" id="profile_success">
38 ', $txt['pm_sent'], '
39 </div>';
40 }
41
42 // Just the end of the index bar, nothing special.
43 function template_pm_below()
44 {
45 global $context, $settings, $options;
46
47 echo '
48 </div>';
49 }
50
51 function template_folder()
52 {
53 global $context, $settings, $options, $scripturl, $modSettings, $txt;
54
55 // The every helpful javascript!
56 echo '
57 <script type="text/javascript"><!-- // --><![CDATA[
58 var allLabels = {};
59 var currentLabels = {};
60 function loadLabelChoices()
61 {
62 var listing = document.forms.pmFolder.elements;
63 var theSelect = document.forms.pmFolder.pm_action;
64 var add, remove, toAdd = {length: 0}, toRemove = {length: 0};
65
66 if (theSelect.childNodes.length == 0)
67 return;';
68
69 // This is done this way for internationalization reasons.
70 echo '
71 if (!(\'-1\' in allLabels))
72 {
73 for (var o = 0; o < theSelect.options.length; o++)
74 if (theSelect.options[o].value.substr(0, 4) == "rem_")
75 allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text;
76 }
77
78 for (var i = 0; i < listing.length; i++)
79 {
80 if (listing[i].name != "pms[]" || !listing[i].checked)
81 continue;
82
83 var alreadyThere = [], x;
84 for (x in currentLabels[listing[i].value])
85 {
86 if (!(x in toRemove))
87 {
88 toRemove[x] = allLabels[x];
89 toRemove.length++;
90 }
91 alreadyThere[x] = allLabels[x];
92 }
93
94 for (x in allLabels)
95 {
96 if (!(x in alreadyThere))
97 {
98 toAdd[x] = allLabels[x];
99 toAdd.length++;
100 }
101 }
102 }
103
104 while (theSelect.options.length > 2)
105 theSelect.options[2] = null;
106
107 if (toAdd.length != 0)
108 {
109 theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", "");
110 setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '");
111 theSelect.options[theSelect.options.length - 1].disabled = true;
112
113 for (i in toAdd)
114 {
115 if (i != "length")
116 theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i);
117 }
118 }
119
120 if (toRemove.length != 0)
121 {
122 theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", "");
123 setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '");
124 theSelect.options[theSelect.options.length - 1].disabled = true;
125
126 for (i in toRemove)
127 {
128 if (i != "length")
129 theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i);
130 }
131 }
132 }
133 // ]]></script>';
134
135 echo '
136 <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">';
137
138 // If we are not in single display mode show the subjects on the top!
139 if ($context['display_mode'] != 1)
140 {
141 template_subject_list();
142 echo '<div class="clear_right"><br /></div>';
143 }
144
145 // Got some messages to display?
146 if ($context['get_pmessage']('message', true))
147 {
148 // Show the helpful titlebar - generally.
149 if ($context['display_mode'] != 1)
150 echo '
151 <div class="cat_bar">
152 <h3 class="catbg">
153 <span id="author">', $txt['author'], '</span>
154 <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
155 </h3>
156 </div>';
157
158 // Show a few buttons if we are in conversation mode and outputting the first message.
159 if ($context['display_mode'] == 2)
160 {
161 // Build the normal button array.
162 $conversation_buttons = array(
163 'reply' => array('text' => 'reply_to_all', 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all', 'active' => true),
164 'delete' => array('text' => 'delete_conversation', 'image' => 'delete.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'),
165 );
166
167 // Show the conversation buttons.
168 echo '
169 <div class="pagesection">';
170
171 template_button_strip($conversation_buttons, 'right');
172
173 echo '
174 </div>';
175 }
176
177 while ($message = $context['get_pmessage']('message'))
178 {
179 $window_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2';
180
181 echo '
182 <div class="', $window_class, ' clear">
183 <span class="topslice"><span></span></span>
184 <div class="poster">
185 <a id="msg', $message['id'], '"></a>
186 <h4>';
187
188 // Show online and offline buttons?
189 if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
190 echo '
191 <img src="', $message['member']['online']['image_href'], '" alt="', $message['member']['online']['text'], '" />';
192
193 echo '
194 ', $message['member']['link'], '
195 </h4>
196 <ul class="reset smalltext" id="msg_', $message['id'], '_extra_info">';
197
198 // Show the member's custom title, if they have one.
199 if (isset($message['member']['title']) && $message['member']['title'] != '')
200 echo '
201 <li class="title">', $message['member']['title'], '</li>';
202
203 // Show the member's primary group (like 'Administrator') if they have one.
204 if (isset($message['member']['group']) && $message['member']['group'] != '')
205 echo '
206 <li class="membergroup">', $message['member']['group'], '</li>';
207
208 // Don't show these things for guests.
209 if (!$message['member']['is_guest'])
210 {
211 // 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.
212 if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
213 echo '
214 <li class="postgroup">', $message['member']['post_group'], '</li>';
215 echo '
216 <li class="stars">', $message['member']['group_stars'], '</li>';
217
218 // Show avatars, images, etc.?
219 if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
220 echo '
221 <li class="avatar">
222 <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
223 ', $message['member']['avatar']['image'], '
224 </a>
225 </li>';
226
227 // Show how many posts they have made.
228 if (!isset($context['disabled_fields']['posts']))
229 echo '
230 <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
231
232 // Is karma display enabled? Total or +/-?
233 if ($modSettings['karmaMode'] == '1')
234 echo '
235 <li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
236 elseif ($modSettings['karmaMode'] == '2')
237 echo '
238 <li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
239
240 // Is this user allowed to modify this member's karma?
241 if ($message['member']['karma']['allow'])
242 echo '
243 <li class="karma_allow">
244 <a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a> <a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a>
245 </li>';
246
247 // Show the member's gender icon?
248 if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
249 echo '
250 <li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
251
252 // Show their personal text?
253 if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
254 echo '
255 <li class="blurb">', $message['member']['blurb'], '</li>';
256
257 // Any custom fields to show as icons?
258 if (!empty($message['member']['custom_fields']))
259 {
260 $shown = false;
261 foreach ($message['member']['custom_fields'] as $custom)
262 {
263 if ($custom['placement'] != 1 || empty($custom['value']))
264 continue;
265 if (empty($shown))
266 {
267 $shown = true;
268 echo '
269 <li class="im_icons">
270 <ul>';
271 }
272 echo '
273 <li>', $custom['value'], '</li>';
274 }
275 if ($shown)
276 echo '
277 </ul>
278 </li>';
279 }
280
281 // This shows the popular messaging icons.
282 if ($message['member']['has_messenger'] && $message['member']['can_view_profile'])
283 echo '
284 <li class="im_icons">
285 <ul>', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '
286 <li>' . $message['member']['icq']['link'] . '</li>' : '', !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ? '
287 <li>' . $message['member']['msn']['link'] . '</li>' : '', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '
288 <li>' . $message['member']['aim']['link'] . '</li>' : '', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '
289 <li>' . $message['member']['yim']['link'] . '</li>' : '', '
290 </ul>
291 </li>';
292
293 // Show the profile, website, email address, and personal message buttons.
294 if ($settings['show_profile_buttons'])
295 {
296 echo '
297 <li class="profile">
298 <ul>';
299
300 // Show the profile button
301 echo '
302 <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '" />' : $txt['view_profile']), '</a></li>';
303
304 // Don't show an icon if they haven't specified a website.
305 if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
306 echo '
307 <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $message['member']['website']['title'] . '" />' : $txt['www']), '</a></li>';
308
309 // Don't show the email address if they want it hidden.
310 if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')))
311 echo '
312 <li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $message['member']['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';
313
314 // Since we know this person isn't a guest, you *can* message them.
315 if ($context['can_send_pm'])
316 echo '
317 <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '" />' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
318
319 echo '
320 </ul>
321 </li>';
322 }
323
324 // Any custom fields for standard placement?
325 if (!empty($message['member']['custom_fields']))
326 {
327 foreach ($message['member']['custom_fields'] as $custom)
328 if (empty($custom['placement']) || empty($custom['value']))
329 echo '
330 <li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
331 }
332
333 // Are we showing the warning status?
334 if ($message['member']['can_see_warning'])
335 echo '
336 <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<img src="', $settings['images_url'], '/warning_', $message['member']['warning_status'], '.gif" alt="', $txt['user_warn_' . $message['member']['warning_status']], '" />', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
337 }
338
339 // Done with the information about the poster... on to the post itself.
340 echo '
341 </ul>
342 </div>
343 <div class="postarea">
344 <div class="flow_hidden">
345 <div class="keyinfo">
346 <h5 id="subject_', $message['id'], '">
347 ', $message['subject'], '
348 </h5>';
349
350 // Show who the message was sent to.
351 echo '
352 <span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
353
354 // People it was sent directly to....
355 if (!empty($message['recipients']['to']))
356 echo implode(', ', $message['recipients']['to']);
357 // Otherwise, we're just going to say "some people"...
358 elseif ($context['folder'] != 'sent')
359 echo '(', $txt['pm_undisclosed_recipients'], ')';
360
361 echo '
362 <strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
363 </span>';
364
365 // If we're in the sent items, show who it was sent to besides the "To:" people.
366 if (!empty($message['recipients']['bcc']))
367 echo '
368 <br /><span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
369
370 if (!empty($message['is_replied_to']))
371 echo '
372 <br /><span class="smalltext">&#171; ', $txt['pm_is_replied_to'], ' &#187;</span>';
373
374 echo '
375 </div>
376 <ul class="reset smalltext quickbuttons">';
377
378 // Show reply buttons if you have the permission to send PMs.
379 if ($context['can_send_pm'])
380 {
381 // You can't really reply if the member is gone.
382 if (!$message['member']['is_guest'])
383 {
384 // Is there than more than one recipient you can reply to?
385 if ($message['number_recipients'] > 1 && $context['display_mode'] != 2)
386 echo '
387 <li class="reply_all_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all">', $txt['reply_to_all'], '</a></li>';
388
389 echo '
390 <li class="reply_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $txt['reply'], '</a></li>
391 <li class="quote_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '">', $txt['quote'], '</a></li>';
392 }
393 // This is for "forwarding" - even if the member is gone.
394 else
395 echo '
396 <li class="forward_button"><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $txt['reply_quote'], '</a></li>';
397 }
398 echo '
399 <li class="remove_button"><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions[', $message['id'], ']=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', addslashes($txt['remove_message']), '?\');">', $txt['delete'], '</a></li>';
400
401 if (empty($context['display_mode']))
402 echo '
403 <li class="inline_mod_check"><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check" /></li>';
404
405 echo '
406 </ul>
407 </div>
408 <div class="post">
409 <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>
410 <div class="smalltext reportlinks">
411 ', (!empty($modSettings['enableReportPM']) && $context['folder'] != 'sent' ? '<div class="righttext"><a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '">' . $txt['pm_report_to_admin'] . '</a></div>' : '');
412
413 echo '
414 </div>';
415
416 // Are there any custom profile fields for above the signature?
417 if (!empty($message['member']['custom_fields']))
418 {
419 $shown = false;
420 foreach ($message['member']['custom_fields'] as $custom)
421 {
422 if ($custom['placement'] != 2 || empty($custom['value']))
423 continue;
424 if (!$shown)
425 {
426 $shown = true;
427 echo '
428 <div class="custom_fields_above_signature">
429 <ul class="reset nolist">';
430 }
431 echo '
432 <li>', $custom['value'], '</li>';
433 }
434 if ($shown)
435 echo '
436 </ul>
437 </div>';
438 }
439
440 // Show the member's signature?
441 if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
442 echo '
443 <div class="signature">', $message['member']['signature'], '</div>';
444
445 // Add an extra line at the bottom if we have labels enabled.
446 if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2)
447 {
448 echo '
449 <div class="labels righttext">';
450 // Add the label drop down box.
451 if (!empty($context['currently_using_labels']))
452 {
453 echo '
454 <select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();">
455 <option value="">', $txt['pm_msg_label_title'], ':</option>
456 <option value="" disabled="disabled">---------------</option>';
457
458 // Are there any labels which can be added to this?
459 if (!$message['fully_labeled'])
460 {
461 echo '
462 <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
463 foreach ($context['labels'] as $label)
464 if (!isset($message['labels'][$label['id']]))
465 echo '
466 <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
467 }
468 // ... and are there any that can be removed?
469 if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
470 {
471 echo '
472 <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
473 foreach ($message['labels'] as $label)
474 echo '
475 <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
476 }
477 echo '
478 </select>
479 <noscript>
480 <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
481 </noscript>';
482 }
483 echo '
484 </div>';
485 }
486
487 echo '
488 </div>
489 <br class="clear" />
490 </div>
491 <div class="moderatorbar">
492 </div>
493 <span class="botslice"><span></span></span>
494 </div>';
495 }
496
497 if (empty($context['display_mode']))
498 echo '
499
500 <div class="pagesection">
501 <div class="floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
502 <div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" /></div>
503 </div>';
504
505 // Show a few buttons if we are in conversation mode and outputting the first message.
506 elseif ($context['display_mode'] == 2 && isset($conversation_buttons))
507 {
508 echo '
509
510 <div class="pagesection">';
511
512 template_button_strip($conversation_buttons, 'right');
513
514 echo '
515 </div>';
516 }
517
518 echo '
519 <br />';
520 }
521
522 // Individual messages = buttom list!
523 if ($context['display_mode'] == 1)
524 {
525 template_subject_list();
526 echo '<br />';
527 }
528
529 echo '
530 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
531 </form>';
532 }
533
534 // Just list all the personal message subjects - to make templates easier.
535 function template_subject_list()
536 {
537 global $context, $options, $settings, $modSettings, $txt, $scripturl;
538
539 echo '
540 <table width="100%" class="table_grid">
541 <thead>
542 <tr class="catbg">
543 <th align="center" width="4%" class="first_th">
544 <a href="', $scripturl, '?action=pm;view;f=', $context['folder'], ';start=', $context['start'], ';sort=', $context['sort_by'], ($context['sort_direction'] == 'up' ? '' : ';desc'), ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''), '"><img src="', $settings['images_url'], '/im_switch.gif" alt="', $txt['pm_change_view'], '" title="', $txt['pm_change_view'], '" width="16" height="16" /></a>
545 </th>
546 <th class="lefttext" width="22%">
547 <a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=date', $context['sort_by'] == 'date' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['date'], $context['sort_by'] == 'date' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
548 </th>
549 <th class="lefttext" width="46%">
550 <a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
551 </th>
552 <th class="lefttext">
553 <a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', ($context['from_or_to'] == 'from' ? $txt['from'] : $txt['to']), $context['sort_by'] == 'name' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
554 </th>
555 <th align="center" width="4%" class="last_th">
556 <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />
557 </th>
558 </tr>
559 </thead>
560 <tbody>';
561 if (!$context['show_delete'])
562 echo '
563 <tr class="windowbg2">
564 <td colspan="5">', $txt['msg_alert_none'], '</td>
565 </tr>';
566 $next_alternate = false;
567
568 while ($message = $context['get_pmessage']('subject'))
569 {
570 echo '
571 <tr class="', $next_alternate ? 'windowbg' : 'windowbg2', '">
572 <td align="center" width="4%">
573 <script type="text/javascript"><!-- // --><![CDATA[
574 currentLabels[', $message['id'], '] = {';
575
576 if (!empty($message['labels']))
577 {
578 $first = true;
579 foreach ($message['labels'] as $label)
580 {
581 echo $first ? '' : ',', '
582 "', $label['id'], '": "', $label['name'], '"';
583 $first = false;
584 }
585 }
586
587 echo '
588 };
589 // ]]></script>
590 ', $message['is_replied_to'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.gif" style="margin-right: 4px;" alt="' . $txt['pm_replied'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.gif" style="margin-right: 4px;" alt="' . $txt['pm_read'] . '" />', '</td>
591 <td>', $message['time'], '</td>
592 <td>', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt="*" />' : ''), '<a href="', ($context['display_mode'] == 0 || $context['current_pm'] == $message['id'] ? '' : ($scripturl . '?action=pm;pmid=' . $message['id'] . ';kstart;f=' . $context['folder'] . ';start=' . $context['start'] . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';' : ';desc') . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''))), '#msg', $message['id'], '">', $message['subject'], '</a>', $message['is_unread'] ? '&nbsp;<img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" />' : '', '</td>
593 <td>', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '</td>
594 <td align="center" width="4%"><input type="checkbox" name="pms[]" id="deletelisting', $message['id'], '" value="', $message['id'], '"', $message['is_selected'] ? ' checked="checked"' : '', ' onclick="if (document.getElementById(\'deletedisplay', $message['id'], '\')) document.getElementById(\'deletedisplay', $message['id'], '\').checked = this.checked;" class="input_check" /></td>
595 </tr>';
596 $next_alternate = !$next_alternate;
597 }
598
599 echo '
600 </tbody>
601 </table>
602 <div class="pagesection">
603 <div class="floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
604 <div class="floatright">&nbsp;';
605
606 if ($context['show_delete'])
607 {
608 if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent')
609 {
610 echo '
611 <select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();">
612 <option value="">', $txt['pm_sel_label_title'], ':</option>
613 <option value="" disabled="disabled">---------------</option>';
614
615 echo '
616 <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
617 foreach ($context['labels'] as $label)
618 if ($label['id'] != $context['current_label_id'])
619 echo '
620 <option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
621 echo '
622 <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
623 foreach ($context['labels'] as $label)
624 echo '
625 <option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
626 echo '
627 </select>
628 <noscript>
629 <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
630 </noscript>';
631 }
632
633 echo '
634 <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" />';
635 }
636
637 echo '
638 </div>
639 </div>';
640 }
641
642 function template_search()
643 {
644 global $context, $settings, $options, $scripturl, $modSettings, $txt;
645
646 echo '
647 <script type="text/javascript"><!-- // --><![CDATA[
648 function expandCollapseLabels()
649 {
650 var current = document.getElementById("searchLabelsExpand").style.display != "none";
651
652 document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
653 document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
654 }
655 // ]]></script>
656 <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
657 <div class="cat_bar">
658 <h3 class="catbg">', $txt['pm_search_title'], '</h3>
659 </div>';
660
661 if (!empty($context['search_errors']))
662 {
663 echo '
664 <div class="errorbox">
665 ', implode('<br />', $context['search_errors']['messages']), '
666 </div>';
667 }
668
669 if ($context['simple_search'])
670 {
671 echo '
672 <fieldset id="simple_search">
673 <span class="upperframe"><span></span></span>
674 <div class="roundframe">
675 <div id="search_term_input">
676 <strong>', $txt['pm_search_text'], ':</strong>
677 <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
678 <input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit" />
679 </div>
680 <a href="', $scripturl, '?action=pm;sa=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['pm_search_advanced'], '</a>
681 <input type="hidden" name="advanced" value="0" />
682 </div>
683 <span class="lowerframe"><span></span></span>
684 </fieldset>';
685 }
686
687 // Advanced search!
688 else
689 {
690 echo '
691 <fieldset id="advanced_search">
692 <span class="upperframe"><span></span></span>
693 <div class="roundframe">
694 <input type="hidden" name="advanced" value="1" />
695 <span class="enhanced">
696 <strong>', $txt['pm_search_text'], ':</strong>
697 <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
698 <script type="text/javascript"><!-- // --><![CDATA[
699 function initSearch()
700 {
701 if (document.forms.searchform.search.value.indexOf("%u") != -1)
702 document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
703 }
704 createEventListener(window);
705 window.addEventListener("load", initSearch, false);
706 // ]]></script>
707 <select name="searchtype">
708 <option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_all'], '</option>
709 <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_any'], '</option>
710 </select>
711 </span>
712 <dl id="search_options">
713 <dt>', $txt['pm_search_user'], ':</dt>
714 <dd><input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
715 <dt>', $txt['pm_search_order'], ':</dt>
716 <dd>
717 <select name="sort">
718 <option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option>
719 <option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option>
720 <option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option>
721 </select>
722 </dd>
723 <dt class="options">', $txt['pm_search_options'], ':</dt>
724 <dd class="options">
725 <label for="show_complete"><input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_show_complete'], '</label><br />
726 <label for="subject_only"><input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_subject_only'], '</label>
727 </dd>
728 <dt class="between">', $txt['pm_search_post_age'], ':</dt>
729 <dd>', $txt['pm_search_between'], ' <input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" class="input_text" />&nbsp;', $txt['pm_search_between_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" class="input_text" /> ', $txt['pm_search_between_days'], '</dd>
730 </dl>';
731 if (!$context['currently_using_labels'])
732 echo '
733 <input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit floatright" />';
734 echo '
735 <br class="clear" />
736 </div>
737 <span class="lowerframe"><span></span></span>
738 </fieldset>';
739
740 // Do we have some labels setup? If so offer to search by them!
741 if ($context['currently_using_labels'])
742 {
743 echo '
744 <fieldset class="labels">
745 <span class="upperframe"><span></span></span>
746 <div class="roundframe">
747 <div class="title_bar">
748 <h4 class="titlebg">
749 <span class="ie6_header floatleft"><a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><img src="', $settings['images_url'], '/expand.gif" id="expandLabelsIcon" alt="" /></a> <a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><strong>', $txt['pm_search_choose_label'], '</strong></a></span>
750 </h4>
751 </div>
752 <ul id="searchLabelsExpand" class="reset" ', $context['check_all'] ? 'style="display: none;"' : '', '>';
753
754 foreach ($context['search_labels'] as $label)
755 echo '
756 <li>
757 <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '" ', $label['checked'] ? 'checked="checked"' : '', ' class="input_check" />
758 ', $label['name'], '</label>
759 </li>';
760
761 echo '
762 </ul>
763 <p>
764 <span class="floatleft"><input type="checkbox" name="all" id="check_all" value="" ', $context['check_all'] ? 'checked="checked"' : '', ' onclick="invertAll(this, this.form, \'searchlabel\');" class="input_check" /><em> <label for="check_all">', $txt['check_all'], '</label></em></span>
765 <input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit floatright" />
766 </p><br class="clear" />
767 </div>
768 <span class="lowerframe"><span></span></span>
769 </fieldset>';
770 }
771 }
772
773 echo '
774 </form>';
775 }
776
777 function template_search_results()
778 {
779 global $context, $settings, $options, $scripturl, $modSettings, $txt;
780
781 echo '
782 <div class="cat_bar">
783 <h3 class="catbg">', $txt['pm_search_results'], '</h3>
784 </div>
785 <div class="pagesection">
786 <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
787 </div>';
788
789 // complete results ?
790 if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
791 echo '
792 <table width="100%" class="table_grid">
793 <thead>
794 <tr class="catbg">
795 <th class="lefttext first_th" width="30%">', $txt['date'], '</th>
796 <th class="lefttext" width="50%">', $txt['subject'], '</th>
797 <th class="lefttext last_th" width="20%">', $txt['from'], '</th>
798 </tr>
799 </thead>
800 <tbody>';
801
802 $alternate = true;
803 // Print each message out...
804 foreach ($context['personal_messages'] as $message)
805 {
806 // We showing it all?
807 if (!empty($context['search_params']['show_complete']))
808 {
809 echo '
810 <div class="title_bar">
811 <h3 class="titlebg">
812 <span class="floatright">', $txt['search_on'], ': ', $message['time'], '</span>
813 <span class="floatleft">', $message['counter'], '&nbsp;&nbsp;<a href="', $message['href'], '">', $message['subject'], '</a></span>
814 </h3>
815 </div>
816 <div class="cat_bar">
817 <h3 class="catbg">', $txt['from'], ': ', $message['member']['link'], ', ', $txt['to'], ': ';
818
819 // Show the recipients.
820 // !!! This doesn't deal with the sent item searching quite right for bcc.
821 if (!empty($message['recipients']['to']))
822 echo implode(', ', $message['recipients']['to']);
823 // Otherwise, we're just going to say "some people"...
824 elseif ($context['folder'] != 'sent')
825 echo '(', $txt['pm_undisclosed_recipients'], ')';
826
827 echo '
828 </h3>
829 </div>
830 <div class="windowbg', $alternate ? '2': '', '">
831 <span class="topslice"><span></span></span>
832 <div class="content">
833 ', $message['body'], '
834 <p class="pm_reply righttext middletext">';
835
836 if ($context['can_send_pm'])
837 {
838 $quote_button = create_button('quote.gif', 'reply_quote', 'reply_quote', 'align="middle"');
839 $reply_button = create_button('im_reply.gif', 'reply', 'reply', 'align="middle"');
840 // You can only reply if they are not a guest...
841 if (!$message['member']['is_guest'])
842 echo '
843 <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
844 <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
845 // This is for "forwarding" - even if the member is gone.
846 else
847 echo '
848 <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
849 }
850
851 echo '
852 </p>
853 </div>
854 <span class="botslice"><span></span></span>
855 </div>';
856 }
857 // Otherwise just a simple list!
858 else
859 {
860 // !!! No context at all of the search?
861 echo '
862 <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" valign="top">
863 <td>', $message['time'], '</td>
864 <td>', $message['link'], '</td>
865 <td>', $message['member']['link'], '</td>
866 </tr>';
867 }
868
869 $alternate = !$alternate;
870 }
871
872 // Finish off the page...
873 if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
874 echo '
875 </tbody>
876 </table>';
877
878 // No results?
879 if (empty($context['personal_messages']))
880 echo '
881 <div class="windowbg">
882 <span class="topslice"><span></span></span>
883 <div class="content">
884 <p class="centertext">', $txt['pm_search_none_found'], '</p>
885 </div>
886 <span class="botslice"><span></span></span>
887 </div>';
888
889 echo '
890 <div class="pagesection">
891 <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
892 </div>';
893
894 }
895
896 function template_send()
897 {
898 global $context, $settings, $options, $scripturl, $modSettings, $txt;
899
900 // Show which messages were sent successfully and which failed.
901 if (!empty($context['send_log']))
902 {
903 echo '
904 <div class="cat_bar">
905 <h3 class="catbg">', $txt['pm_send_report'], '</h3>
906 </div>
907 <div class="windowbg">
908 <span class="topslice"><span></span></span>
909 <div class="content">';
910 if (!empty($context['send_log']['sent']))
911 foreach ($context['send_log']['sent'] as $log_entry)
912 echo '<span class="error">', $log_entry, '</span><br />';
913 if (!empty($context['send_log']['failed']))
914 foreach ($context['send_log']['failed'] as $log_entry)
915 echo '<span class="error">', $log_entry, '</span><br />';
916 echo '
917 </div>
918 <span class="botslice"><span></span></span>
919 </div>
920 <br />';
921 }
922
923 // Show the preview of the personal message.
924 if (isset($context['preview_message']))
925 echo '
926 <div class="cat_bar">
927 <h3 class="catbg">', $context['preview_subject'], '</h3>
928 </div>
929 <div class="windowbg">
930 <span class="topslice"><span></span></span>
931 <div class="content">
932 ', $context['preview_message'], '
933 </div>
934 <span class="botslice"><span></span></span>
935 </div>
936 <br />';
937
938 // Main message editing box.
939 echo '
940 <div class="cat_bar">
941 <h3 class="catbg">
942 <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/im_newmsg.gif" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '</span>
943 </h3>
944 </div>';
945
946 echo '
947 <form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
948 <div>
949 <span class="upperframe"><span></span></span>
950 <div class="roundframe"><br class="clear" />';
951
952 // If there were errors for sending the PM, show them.
953 if (!empty($context['post_error']['messages']))
954 {
955 echo '
956 <div class="errorbox">
957 <strong>', $txt['error_while_submitting'], '</strong>
958 <ul class="reset">';
959
960 foreach ($context['post_error']['messages'] as $error)
961 echo '
962 <li class="error">', $error, '</li>';
963
964 echo '
965 </ul>
966 </div>';
967 }
968
969 echo '
970 <dl id="post_header">';
971
972 // To and bcc. Include a button to search for members.
973 echo '
974 <dt>
975 <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
976 </dt>';
977
978 // Autosuggest will be added by the JavaScript later on.
979 echo '
980 <dd id="pm_to" class="clear_right">
981 <input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
982
983 // A link to add BCC, only visible with JavaScript enabled.
984 echo '
985 <span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
986
987 // A div that'll contain the items found by the autosuggest.
988 echo '
989 <div id="to_item_list_container"></div>';
990
991 echo '
992 </dd>';
993
994 // This BCC row will be hidden by default if JavaScript is enabled.
995 echo '
996 <dt class="clear_left" id="bcc_div">
997 <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), '>', $txt['pm_bcc'], ':</span>
998 </dt>
999 <dd id="bcc_div2">
1000 <input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
1001 <div id="bcc_item_list_container"></div>
1002 </dd>';
1003
1004 // The subject of the PM.
1005 echo '
1006 <dt class="clear_left">
1007 <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), '>', $txt['subject'], ':</span>
1008 </dt>
1009 <dd id="pm_subject">
1010 <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60" />
1011 </dd>
1012 </dl><hr class="clear" />';
1013
1014 // Showing BBC?
1015 if ($context['show_bbc'])
1016 {
1017 echo '
1018 <div id="bbcBox_message"></div>';
1019 }
1020
1021 // What about smileys?
1022 if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
1023 echo '
1024 <div id="smileyBox_message"></div>';
1025
1026 // Show BBC buttons, smileys and textbox.
1027 echo '
1028 ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
1029
1030 // Require an image to be typed to save spamming?
1031 if ($context['require_verification'])
1032 {
1033 echo '
1034 <div class="post_verification">
1035 <strong>', $txt['pm_visual_verification_label'], ':</strong>
1036 ', template_control_verification($context['visual_verification_id'], 'all'), '
1037 </div>';
1038 }
1039
1040 // Send, Preview, spellcheck buttons.
1041 echo '
1042 <p><label for="outbox"><input type="checkbox" name="outbox" id="outbox" value="1" tabindex="', $context['tabindex']++, '"', $context['copy_to_outbox'] ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_save_outbox'], '</label></p>
1043 <p id="shortcuts" class="smalltext">
1044 ', $context['browser']['is_firefox'] ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
1045 </p>
1046 <p id="post_confirm_strip" class="righttext">
1047 ', template_control_richedit_buttons($context['post_box_name']), '
1048 </p>
1049 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1050 <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
1051 <input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
1052 <input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
1053 <input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
1054 <input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
1055 <br class="clear" />
1056 </div>
1057 <span class="lowerframe"><span></span></span>
1058 </div>
1059 </form>';
1060
1061 // Show the message you're replying to.
1062 if ($context['reply'])
1063 echo '
1064 <br />
1065 <br />
1066 <div class="cat_bar">
1067 <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
1068 </div>
1069 <div class="windowbg2">
1070 <span class="topslice"><span></span></span>
1071 <div class="content">
1072 <div class="clear">
1073 <span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
1074 <strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong>
1075 </div><hr />
1076 ', $context['quoted_message']['body'], '
1077 </div>
1078 <span class="botslice"><span></span></span>
1079 </div><br class="clear" />';
1080
1081 echo '
1082 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?fin20"></script>
1083 <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
1084 <script type="text/javascript"><!-- // --><![CDATA[
1085 var oPersonalMessageSend = new smf_PersonalMessageSend({
1086 sSelf: \'oPersonalMessageSend\',
1087 sSessionId: \'', $context['session_id'], '\',
1088 sSessionVar: \'', $context['session_var'], '\',
1089 sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
1090 sToControlId: \'to_control\',
1091 aToRecipients: [';
1092 foreach ($context['recipients']['to'] as $i => $member)
1093 echo '
1094 {
1095 sItemId: ', JavaScriptEscape($member['id']), ',
1096 sItemName: ', JavaScriptEscape($member['name']), '
1097 }', $i == count($context['recipients']['to']) - 1 ? '' : ',';
1098
1099 echo '
1100 ],
1101 aBccRecipients: [';
1102 foreach ($context['recipients']['bcc'] as $i => $member)
1103 echo '
1104 {
1105 sItemId: ', JavaScriptEscape($member['id']), ',
1106 sItemName: ', JavaScriptEscape($member['name']), '
1107 }', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
1108
1109 echo '
1110 ],
1111 sBccControlId: \'bcc_control\',
1112 sBccDivId: \'bcc_div\',
1113 sBccDivId2: \'bcc_div2\',
1114 sBccLinkId: \'bcc_link\',
1115 sBccLinkContainerId: \'bcc_link_container\',
1116 bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
1117 sShowBccLinkTemplate: ', JavaScriptEscape('
1118 <a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqWin(this.href);">(?)</a>'
1119 ), '
1120 });
1121 ';
1122
1123 echo '
1124 // ]]></script>';
1125 }
1126
1127 // This template asks the user whether they wish to empty out their folder/messages.
1128 function template_ask_delete()
1129 {
1130 global $context, $settings, $options, $scripturl, $modSettings, $txt;
1131
1132 echo '
1133 <div class="cat_bar">
1134 <h3 class="catbg">', ($context['delete_all'] ? $txt['delete_message'] : $txt['delete_all']), '</h3>
1135 </div>
1136 <div class="windowbg">
1137 <span class="topslice"><span></span></span>
1138 <div class="content">
1139 <p>', $txt['delete_all_confirm'], '</p><br />
1140 <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>
1141 </div>
1142 <span class="botslice"><span></span></span>
1143 </div>';
1144 }
1145
1146 // This template asks the user what messages they want to prune.
1147 function template_prune()
1148 {
1149 global $context, $settings, $options, $scripturl, $txt;
1150
1151 echo '
1152 <form action="', $scripturl, '?action=pm;sa=prune" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['pm_prune_warning'], '\');">
1153 <div class="cat_bar">
1154 <h3 class="catbg">', $txt['pm_prune'], '</h3>
1155 </div>
1156 <div class="windowbg">
1157 <span class="topslice"><span></span></span>
1158 <div class="content">
1159 <p>', $txt['pm_prune_desc1'], ' <input type="text" name="age" size="3" value="14" class="input_text" /> ', $txt['pm_prune_desc2'], '</p>
1160 <div class="righttext">
1161 <input type="submit" value="', $txt['delete'], '" class="button_submit" />
1162 </div>
1163 </div>
1164 <span class="botslice"><span></span></span>
1165 </div>
1166 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1167 </form>';
1168 }
1169
1170 // Here we allow the user to setup labels, remove labels and change rules for labels (i.e, do quite a bit)
1171 function template_labels()
1172 {
1173 global $context, $settings, $options, $scripturl, $txt;
1174
1175 echo '
1176 <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '">
1177 <div class="cat_bar">
1178 <h3 class="catbg">', $txt['pm_manage_labels'], '</h3>
1179 </div>
1180 <div class="description">
1181 ', $txt['pm_labels_desc'], '
1182 </div>
1183 <table width="100%" class="table_grid">
1184 <thead>
1185 <tr class="catbg">
1186 <th class="lefttext first_th">
1187 ', $txt['pm_label_name'], '
1188 </th>
1189 <th class="centertext last_th" width="4%">';
1190
1191 if (count($context['labels']) > 2)
1192 echo '
1193 <input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />';
1194
1195 echo '
1196 </th>
1197 </tr>
1198 </thead>
1199 <tbody>';
1200 if (count($context['labels']) < 2)
1201 echo '
1202 <tr class="windowbg2">
1203 <td colspan="2" align="center">', $txt['pm_labels_no_exist'], '</td>
1204 </tr>';
1205 else
1206 {
1207 $alternate = true;
1208 foreach ($context['labels'] as $label)
1209 {
1210 if ($label['id'] == -1)
1211 continue;
1212
1213 echo '
1214 <tr class="', $alternate ? 'windowbg2' : 'windowbg', '">
1215 <td>
1216 <input type="text" name="label_name[', $label['id'], ']" value="', $label['name'], '" size="30" maxlength="30" class="input_text" />
1217 </td>
1218 <td width="4%" align="center"><input type="checkbox" class="input_check" name="delete_label[', $label['id'], ']" /></td>
1219 </tr>';
1220
1221 $alternate = !$alternate;
1222 }
1223 }
1224 echo '
1225 </tbody>
1226 </table>';
1227
1228 if (!count($context['labels']) < 2)
1229 echo '
1230 <div class="padding righttext">
1231 <input type="submit" name="save" value="', $txt['save'], '" class="button_submit" />
1232 <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" onclick="return confirm(\'', $txt['pm_labels_delete'], '\');" class="button_submit" />
1233 </div>';
1234
1235 echo '
1236 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1237 </form>
1238 <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '" style="margin-top: 1ex;">
1239 <div class="cat_bar">
1240 <h3 class="catbg">', $txt['pm_label_add_new'], '</h3>
1241 </div>
1242 <div class="windowbg">
1243 <span class="topslice"><span></span></span>
1244 <div class="content">
1245 <dl class="settings">
1246 <dt>
1247 <strong><label for="add_label">', $txt['pm_label_name'], '</label>:</strong>
1248 </dt>
1249 <dd>
1250 <input type="text" id="add_label" name="label" value="" size="30" maxlength="30" class="input_text" />
1251 </dd>
1252 </dl>
1253 <div class="righttext">
1254 <input type="submit" name="add" value="', $txt['pm_label_add_new'], '" class="button_submit" />
1255 </div>
1256 </div>
1257 <span class="botslice"><span></span></span>
1258 </div>
1259 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1260 </form><br />';
1261 }
1262
1263 // Template for reporting a personal message.
1264 function template_report_message()
1265 {
1266 global $context, $settings, $options, $txt, $scripturl;
1267
1268 echo '
1269 <form action="', $scripturl, '?action=pm;sa=report;l=', $context['current_label_id'], '" method="post" accept-charset="', $context['character_set'], '">
1270 <input type="hidden" name="pmsg" value="', $context['pm_id'], '" />
1271 <div class="cat_bar">
1272 <h3 class="catbg">', $txt['pm_report_title'], '</h3>
1273 </div>
1274 <div class="description">
1275 ', $txt['pm_report_desc'], '
1276 </div>
1277 <div class="windowbg">
1278 <span class="topslice"><span></span></span>
1279 <div class="content">
1280 <dl class="settings">';
1281
1282 // If there is more than one admin on the forum, allow the user to choose the one they want to direct to.
1283 // !!! Why?
1284 if ($context['admin_count'] > 1)
1285 {
1286 echo '
1287 <dt>
1288 <strong>', $txt['pm_report_admins'], ':</strong>
1289 </dt>
1290 <dd>
1291 <select name="ID_ADMIN">
1292 <option value="0">', $txt['pm_report_all_admins'], '</option>';
1293 foreach ($context['admins'] as $id => $name)
1294 echo '
1295 <option value="', $id, '">', $name, '</option>';
1296 echo '
1297 </select>
1298 </dd>';
1299 }
1300
1301 echo '
1302 <dt>
1303 <strong>', $txt['pm_report_reason'], ':</strong>
1304 </dt>
1305 <dd>
1306 <textarea name="reason" rows="4" cols="70" style="' . ($context['browser']['is_ie8'] ? 'width: 635px; max-width: 80%; min-width: 80%' : 'width: 80%') . ';"></textarea>
1307 </dd>
1308 </dl>
1309 <div class="righttext">
1310 <input type="submit" name="report" value="', $txt['pm_report_message'], '" class="button_submit" />
1311 </div>
1312 </div>
1313 <span class="botslice"><span></span></span>
1314 </div>
1315 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1316 </form>';
1317 }
1318
1319 // Little template just to say "Yep, it's been submitted"
1320 function template_report_message_complete()
1321 {
1322 global $context, $settings, $options, $txt, $scripturl;
1323
1324 echo '
1325 <div class="cat_bar">
1326 <h3 class="catbg">', $txt['pm_report_title'], '</h3>
1327 </div>
1328 <div class="windowbg">
1329 <span class="topslice"><span></span></span>
1330 <div class="content">
1331 <p>', $txt['pm_report_done'], '</p>
1332 <a href="', $scripturl, '?action=pm;l=', $context['current_label_id'], '">', $txt['pm_report_return'], '</a>
1333 </div>
1334 <span class="botslice"><span></span></span>
1335 </div>';
1336 }
1337
1338 // Manage rules.
1339 function template_rules()
1340 {
1341 global $context, $settings, $options, $txt, $scripturl;
1342
1343 echo '
1344 <form action="', $scripturl, '?action=pm;sa=manrules" method="post" accept-charset="', $context['character_set'], '" name="manRules" id="manrules">
1345 <div class="cat_bar">
1346 <h3 class="catbg">', $txt['pm_manage_rules'], '</h3>
1347 </div>
1348 <div class="description">
1349 ', $txt['pm_manage_rules_desc'], '
1350 </div>
1351 <table width="100%" class="table_grid">
1352 <thead>
1353 <tr class="catbg">
1354 <th class="lefttext first_th">
1355 ', $txt['pm_rule_title'], '
1356 </th>
1357 <th width="4%" class="centertext last_th">';
1358
1359 if (!empty($context['rules']))
1360 echo '
1361 <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />';
1362
1363 echo '
1364 </th>
1365 </tr>
1366 </thead>
1367 <tbody>';
1368
1369 if (empty($context['rules']))
1370 echo '
1371 <tr class="windowbg2">
1372 <td colspan="2" align="center">
1373 ', $txt['pm_rules_none'], '
1374 </td>
1375 </tr>';
1376
1377 $alternate = false;
1378 foreach ($context['rules'] as $rule)
1379 {
1380 echo '
1381 <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
1382 <td>
1383 <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a>
1384 </td>
1385 <td width="4%" align="center">
1386 <input type="checkbox" name="delrule[', $rule['id'], ']" class="input_check" />
1387 </td>
1388 </tr>';
1389 $alternate = !$alternate;
1390 }
1391
1392 echo '
1393 </tbody>
1394 </table>
1395 <div class="righttext">
1396 [<a href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>]';
1397
1398 if (!empty($context['rules']))
1399 echo '
1400 [<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>]';
1401
1402 if (!empty($context['rules']))
1403 echo '
1404 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1405 <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" onclick="return confirm(\'', $txt['pm_js_delete_rule_confirm'], '\');" class="button_submit smalltext" />';
1406
1407 echo '
1408 </div>
1409 </form>';
1410
1411 }
1412
1413 // Template for adding/editing a rule.
1414 function template_add_rule()
1415 {
1416 global $context, $settings, $options, $txt, $scripturl;
1417
1418 echo '
1419 <script type="text/javascript"><!-- // --><![CDATA[
1420 var criteriaNum = 0;
1421 var actionNum = 0;
1422 var groups = new Array()
1423 var labels = new Array()';
1424
1425 foreach ($context['groups'] as $id => $title)
1426 echo '
1427 groups[', $id, '] = "', addslashes($title), '";';
1428
1429 foreach ($context['labels'] as $label)
1430 if ($label['id'] != -1)
1431 echo '
1432 labels[', ($label['id'] + 1), '] = "', addslashes($label['name']), '";';
1433
1434 echo '
1435 function addCriteriaOption()
1436 {
1437 if (criteriaNum == 0)
1438 {
1439 for (var i = 0; i < document.forms.addrule.elements.length; i++)
1440 if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
1441 criteriaNum++;
1442 }
1443 criteriaNum++
1444
1445 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>&nbsp;<span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value="" class="input_text" /><\' + \'/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>';
1446
1447 foreach ($context['groups'] as $id => $group)
1448 echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1449
1450 echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
1451 }
1452
1453 function addActionOption()
1454 {
1455 if (actionNum == 0)
1456 {
1457 for (var i = 0; i < document.forms.addrule.elements.length; i++)
1458 if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
1459 actionNum++;
1460 }
1461 actionNum++
1462
1463 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>&nbsp;<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>';
1464
1465 foreach ($context['labels'] as $label)
1466 if ($label['id'] != -1)
1467 echo '<option value="', ($label['id'] + 1), '">', addslashes($label['name']), '<\' + \'/option>';
1468
1469 echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
1470 }
1471
1472 function updateRuleDef(optNum)
1473 {
1474 if (document.getElementById("ruletype" + optNum).value == "gid")
1475 {
1476 document.getElementById("defdiv" + optNum).style.display = "none";
1477 document.getElementById("defseldiv" + optNum).style.display = "";
1478 }
1479 else if (document.getElementById("ruletype" + optNum).value == "bud" || document.getElementById("ruletype" + optNum).value == "")
1480 {
1481 document.getElementById("defdiv" + optNum).style.display = "none";
1482 document.getElementById("defseldiv" + optNum).style.display = "none";
1483 }
1484 else
1485 {
1486 document.getElementById("defdiv" + optNum).style.display = "";
1487 document.getElementById("defseldiv" + optNum).style.display = "none";
1488 }
1489 }
1490
1491 function updateActionDef(optNum)
1492 {
1493 if (document.getElementById("acttype" + optNum).value == "lab")
1494 {
1495 document.getElementById("labdiv" + optNum).style.display = "";
1496 }
1497 else
1498 {
1499 document.getElementById("labdiv" + optNum).style.display = "none";
1500 }
1501 }
1502
1503 // Rebuild the rule description!
1504 function rebuildRuleDesc()
1505 {
1506 // Start with nothing.
1507 var text = "";
1508 var joinText = "";
1509 var actionText = "";
1510 var hadBuddy = false;
1511 var foundCriteria = false;
1512 var foundAction = false;
1513 var curNum, curVal, curDef;
1514
1515 for (var i = 0; i < document.forms.addrule.elements.length; i++)
1516 {
1517 if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
1518 {
1519 if (foundCriteria)
1520 joinText = document.getElementById("logic").value == \'and\' ? ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ' : ', JavaScriptEscape(' ' . $txt['pm_readable_or'] . ' '), ';
1521 else
1522 joinText = \'\';
1523 foundCriteria = true;
1524
1525 curNum = document.forms.addrule.elements[i].id.match(/\d+/);
1526 curVal = document.forms.addrule.elements[i].value;
1527 if (curVal == "gid")
1528 curDef = document.getElementById("ruledefgroup" + curNum).value.php_htmlspecialchars();
1529 else if (curVal != "bud")
1530 curDef = document.getElementById("ruledef" + curNum).value.php_htmlspecialchars();
1531 else
1532 curDef = "";
1533
1534 // What type of test is this?
1535 if (curVal == "mid" && curDef)
1536 text += joinText + ', JavaScriptEscape($txt['pm_readable_member']), '.replace("{MEMBER}", curDef);
1537 else if (curVal == "gid" && curDef && groups[curDef])
1538 text += joinText + ', JavaScriptEscape($txt['pm_readable_group']), '.replace("{GROUP}", groups[curDef]);
1539 else if (curVal == "sub" && curDef)
1540 text += joinText + ', JavaScriptEscape($txt['pm_readable_subject']), '.replace("{SUBJECT}", curDef);
1541 else if (curVal == "msg" && curDef)
1542 text += joinText + ', JavaScriptEscape($txt['pm_readable_body']), '.replace("{BODY}", curDef);
1543 else if (curVal == "bud" && !hadBuddy)
1544 {
1545 text += joinText + ', JavaScriptEscape($txt['pm_readable_buddy']), ';
1546 hadBuddy = true;
1547 }
1548 }
1549 if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
1550 {
1551 if (foundAction)
1552 joinText = ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ';
1553 else
1554 joinText = "";
1555 foundAction = true;
1556
1557 curNum = document.forms.addrule.elements[i].id.match(/\d+/);
1558 curVal = document.forms.addrule.elements[i].value;
1559 if (curVal == "lab")
1560 curDef = document.getElementById("labdef" + curNum).value.php_htmlspecialchars();
1561 else
1562 curDef = "";
1563
1564 // Now pick the actions.
1565 if (curVal == "lab" && curDef && labels[curDef])
1566 actionText += joinText + ', JavaScriptEscape($txt['pm_readable_label']), '.replace("{LABEL}", labels[curDef]);
1567 else if (curVal == "del")
1568 actionText += joinText + ', JavaScriptEscape($txt['pm_readable_delete']), ';
1569 }
1570 }
1571
1572 // If still nothing make it default!
1573 if (text == "" || !foundCriteria)
1574 text = "', $txt['pm_rule_not_defined'], '";
1575 else
1576 {
1577 if (actionText != "")
1578 text += ', JavaScriptEscape(' ' . $txt['pm_readable_then'] . ' '), ' + actionText;
1579 text = ', JavaScriptEscape($txt['pm_readable_start']), ' + text + ', JavaScriptEscape($txt['pm_readable_end']), ';
1580 }
1581
1582 // Set the actual HTML!
1583 setInnerHTML(document.getElementById("ruletext"), text);
1584 }
1585 // ]]></script>';
1586
1587 echo '
1588 <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">
1589 <div class="cat_bar">
1590 <h3 class="catbg">', $context['rid'] == 0 ? $txt['pm_add_rule'] : $txt['pm_edit_rule'], '</h3>
1591 </div>
1592 <div class="windowbg">
1593 <span class="topslice"><span></span></span>
1594 <div class="content">
1595 <dl class="addrules">
1596 <dt class="floatleft">
1597 <strong>', $txt['pm_rule_name'], ':</strong><br />
1598 <span class="smalltext">', $txt['pm_rule_name_desc'], '</span>
1599 </dt>
1600 <dd class="floatleft">
1601 <input type="text" name="rule_name" value="', empty($context['rule']['name']) ? $txt['pm_rule_name_default'] : $context['rule']['name'], '" size="50" class="input_text" />
1602 </dd>
1603 </dl>
1604 <fieldset>
1605 <legend>', $txt['pm_rule_criteria'], '</legend>';
1606
1607 // Add a dummy criteria to allow expansion for none js users.
1608 $context['rule']['criteria'][] = array('t' => '', 'v' => '');
1609
1610 // For each criteria print it out.
1611 $isFirst = true;
1612 foreach ($context['rule']['criteria'] as $k => $criteria)
1613 {
1614 if (!$isFirst && $criteria['t'] == '')
1615 echo '<div id="removeonjs1">';
1616 elseif (!$isFirst)
1617 echo '<br />';
1618
1619 echo '
1620 <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
1621 <option value="">', $txt['pm_rule_criteria_pick'], ':</option>
1622 <option value="mid" ', $criteria['t'] == 'mid' ? 'selected="selected"' : '', '>', $txt['pm_rule_mid'], '</option>
1623 <option value="gid" ', $criteria['t'] == 'gid' ? 'selected="selected"' : '', '>', $txt['pm_rule_gid'], '</option>
1624 <option value="sub" ', $criteria['t'] == 'sub' ? 'selected="selected"' : '', '>', $txt['pm_rule_sub'], '</option>
1625 <option value="msg" ', $criteria['t'] == 'msg' ? 'selected="selected"' : '', '>', $txt['pm_rule_msg'], '</option>
1626 <option value="bud" ', $criteria['t'] == 'bud' ? 'selected="selected"' : '', '>', $txt['pm_rule_bud'], '</option>
1627 </select>
1628 <span id="defdiv', $k, '" ', !in_array($criteria['t'], array('gid', 'bud')) ? '' : 'style="display: none;"', '>
1629 <input type="text" name="ruledef[', $k, ']" id="ruledef', $k, '" onkeyup="rebuildRuleDesc();" value="', in_array($criteria['t'], array('mid', 'sub', 'msg')) ? $criteria['v'] : '', '" class="input_text" />
1630 </span>
1631 <span id="defseldiv', $k, '" ', $criteria['t'] == 'gid' ? '' : 'style="display: none;"', '>
1632 <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
1633 <option value="">', $txt['pm_rule_sel_group'], '</option>';
1634
1635 foreach ($context['groups'] as $id => $group)
1636 echo '
1637 <option value="', $id, '" ', $criteria['t'] == 'gid' && $criteria['v'] == $id ? 'selected="selected"' : '', '>', $group, '</option>';
1638 echo '
1639 </select>
1640 </span>';
1641
1642 // If this is the dummy we add a means to hide for non js users.
1643 if ($isFirst)
1644 $isFirst = false;
1645 elseif ($criteria['t'] == '')
1646 echo '</div>';
1647 }
1648
1649 echo '
1650 <span id="criteriaAddHere"></span><br />
1651 <a href="#" onclick="addCriteriaOption(); return false;" id="addonjs1" style="display: none;">(', $txt['pm_rule_criteria_add'], ')</a>
1652 <br /><br />
1653 ', $txt['pm_rule_logic'], ':
1654 <select name="rule_logic" id="logic" onchange="rebuildRuleDesc();">
1655 <option value="and" ', $context['rule']['logic'] == 'and' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_and'], '</option>
1656 <option value="or" ', $context['rule']['logic'] == 'or' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_or'], '</option>
1657 </select>
1658 </fieldset>
1659 <fieldset>
1660 <legend>', $txt['pm_rule_actions'], '</legend>';
1661
1662 // As with criteria - add a dummy action for "expansion".
1663 $context['rule']['actions'][] = array('t' => '', 'v' => '');
1664
1665 // Print each action.
1666 $isFirst = true;
1667 foreach ($context['rule']['actions'] as $k => $action)
1668 {
1669 if (!$isFirst && $action['t'] == '')
1670 echo '<div id="removeonjs2">';
1671 elseif (!$isFirst)
1672 echo '<br />';
1673
1674 echo '
1675 <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
1676 <option value="">', $txt['pm_rule_sel_action'] , ':</option>
1677 <option value="lab" ', $action['t'] == 'lab' ? 'selected="selected"' : '', '>', $txt['pm_rule_label'] , '</option>
1678 <option value="del" ', $action['t'] == 'del' ? 'selected="selected"' : '', '>', $txt['pm_rule_delete'] , '</option>
1679 </select>
1680 <span id="labdiv', $k, '">
1681 <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
1682 <option value="">', $txt['pm_rule_sel_label'], '</option>';
1683 foreach ($context['labels'] as $label)
1684 if ($label['id'] != -1)
1685 echo '
1686 <option value="', ($label['id'] + 1), '" ', $action['t'] == 'lab' && $action['v'] == $label['id'] ? 'selected="selected"' : '', '>', $label['name'], '</option>';
1687
1688 echo '
1689 </select>
1690 </span>';
1691
1692 if ($isFirst)
1693 $isFirst = false;
1694 elseif ($action['t'] == '')
1695 echo '
1696 </div>';
1697 }
1698
1699 echo '
1700 <span id="actionAddHere"></span><br />
1701 <a href="#" onclick="addActionOption(); return false;" id="addonjs2" style="display: none;">(', $txt['pm_rule_add_action'], ')</a>
1702 </fieldset>
1703 </div>
1704 <span class="botslice"><span></span></span>
1705 </div><br class="clear" />
1706 <div class="cat_bar">
1707 <h3 class="catbg">', $txt['pm_rule_description'], '</h3>
1708 </div>
1709 <div class="information">
1710 <div id="ruletext">', $txt['pm_rule_js_disabled'], '</div>
1711 </div>
1712 <div class="righttext">
1713 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
1714 <input type="submit" name="save" value="', $txt['pm_rule_save'], '" class="button_submit" />
1715 </div>
1716 </form>';
1717
1718 // Now setup all the bits!
1719 echo '
1720 <script type="text/javascript"><!-- // --><![CDATA[';
1721
1722 foreach ($context['rule']['criteria'] as $k => $c)
1723 echo '
1724 updateRuleDef(', $k, ');';
1725
1726 foreach ($context['rule']['actions'] as $k => $c)
1727 echo '
1728 updateActionDef(', $k, ');';
1729
1730 echo '
1731 rebuildRuleDesc();';
1732
1733 // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
1734 if ($context['rid'])
1735 echo '
1736 document.getElementById("removeonjs1").style.display = "none";
1737 document.getElementById("removeonjs2").style.display = "none";';
1738
1739 echo '
1740 document.getElementById("addonjs1").style.display = "";
1741 document.getElementById("addonjs2").style.display = "";';
1742
1743 echo '
1744 // ]]></script>';
1745 }
1746
1747 ?>