annotate forum/Themes/core/PersonalMessage.template.php @ 76:e3e11437ecea website

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