Example #1
0
function template_main()
{
    global $context, $settings, $options, $txt, $scripturl, $modSettings, $counter;
    // Start the javascript... and boy is there a lot.
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[';
    // When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
    if ($context['browser']['is_firefox']) {
        echo '
			function reActivate()
			{
				document.forms.postmodify.message.readOnly = false;
			}
			window.addEventListener("pageshow", reActivate, false);';
    }
    // Start with message icons - and any missing from this theme.
    echo '
			var icon_urls = {';
    foreach ($context['icons'] as $icon) {
        echo '
				\'', $icon['value'], '\': \'', $settings['images_url'] . '/post/' . $icon['value'], '.png\'', $icon['is_last'] ? '' : ',';
    }
    echo '
			};';
    // The actual message icon selector.
    echo '
			function showimage()
			{
				document.images.icons.src = icon_urls[document.forms.postmodify.icon.options[document.forms.postmodify.icon.selectedIndex].value];
			}';
    // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
    if ($context['make_poll']) {
        echo '
			function pollOptions()
			{
				var expire_time = document.getElementById(\'poll_expire\');

				if (isEmptyText(expire_time) || expire_time.value == 0)
				{
					document.forms.postmodify.poll_hide[2].disabled = true;
					if (document.forms.postmodify.poll_hide[2].checked)
						document.forms.postmodify.poll_hide[1].checked = true;
				}
				else
					document.forms.postmodify.poll_hide[2].disabled = false;
			}

			var pollOptionNum = 0, pollTabIndex;
			function addPollOption()
			{
				if (pollOptionNum == 0)
				{
					for (var i = 0, n = document.forms.postmodify.elements.length; i < n; i++)
						if (document.forms.postmodify.elements[i].id.substr(0, 8) == \'options-\')
						{
							pollOptionNum++;
							pollTabIndex = document.forms.postmodify.elements[i].tabIndex;
						}
				}
				pollOptionNum++

				setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<li><label for="options-'), ' + pollOptionNum + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>: <input type="text" name="options['), ' + pollOptionNum + ', JavaScriptEscape(']" id="options-'), ' + pollOptionNum + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text" /></li><li id="pollMoreOptions"></li>'), ');
			}';
    }
    // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
    if ($context['make_event']) {
        echo '
			var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

			function generateDays()
			{
				var dayElement = document.getElementById(\'day\'), yearElement = document.getElementById(\'year\'), monthElement = document.getElementById(\'month\');
				var days, selected = dayElement.selectedIndex;

				monthLength[1] = yearElement.options[yearElement.selectedIndex].value % 4 == 0 ? 29 : 28;
				days = monthLength[monthElement.value - 1];

				while (dayElement.options.length)
					dayElement.options[0] = null;

				for (i = 1; i <= days; i++)
					dayElement.options[dayElement.length] = new Option(i, i);

				if (selected < days)
					dayElement.selectedIndex = selected;
			}';
    }
    // End of the javascript, start the form and display the link tree.
    echo '
		// ]]></script>
		<form action="', $scripturl, '?action=', $context['destination'], ';', empty($context['current_board']) ? '' : 'board=' . $context['current_board'], '" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="', $context['becomes_approved'] ? '' : 'alert(\'' . $txt['js_post_will_require_approval'] . '\');', 'submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'', $context['post_box_name'], '\', \'guestname\', \'evtitle\', \'question\'], \'options\');" enctype="multipart/form-data">';
    // If the user wants to see how their message looks - the preview section is where it's at!
    echo '
			<div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
				<div class="cat_bar">
					<h3 class="catbg">
						<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
					</h3>
				</div>
				<div class="windowbg">
					<span class="topslice"><span></span></span>
					<div class="content">
						<div class="post" id="preview_body">
							', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
						</div>
					</div>
					<span class="botslice"><span></span></span>
				</div>
			</div><br />';
    if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
        echo '
			<input type="hidden" name="eventid" value="', $context['event']['id'], '" />';
    }
    // Start the main table.
    echo '
			<div class="cat_bar">
				<h3 class="catbg">', $context['page_title'], '</h3>
			</div>
			<div>
				<span class="upperframe"><span></span></span>
				<div class="roundframe">', isset($context['current_topic']) ? '
					<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />' : '';
    // If an error occurred, explain what happened.
    echo '
					<div class="errorbox"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
						<dl class="settings narrow">
							<dt>
								<strong style="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'display: none;' : '', '" id="error_serious">', $txt['error_while_submitting'], '</strong>
							</dt>
							<dt class="error" id="error_list">
								', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
							</dt>
						</dl>
					</div>';
    // If this won't be approved let them know!
    if (!$context['becomes_approved']) {
        echo '
					<p class="information">
						<em>', $txt['wait_for_approval'], '</em>
						<input type="hidden" name="not_approved" value="1" />
					</p>';
    }
    // If it's locked, show a message to warn the replyer.
    echo '
					<p class="information"', $context['locked'] ? '' : ' style="display: none"', ' id="lock_warning">
						', $txt['topic_locked_no_reply'], '
					</p>';
    // The post header... important stuff
    echo '
					<dl id="post_header" class="settings narrow">';
    // Guests have to put in their name and email...
    if (isset($context['name']) && isset($context['email'])) {
        echo '
						<dt>
							<span', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '', ' id="caption_guestname">', $txt['name'], ':</span>
						</dt>
						<dd>
							<input type="text" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
						</dd>';
        if (empty($modSettings['guest_post_no_email'])) {
            echo '
						<dt>
							<span', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '', ' id="caption_email">', $txt['email'], ':</span>
						</dt>
						<dd>
							<input type="text" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
						</dd>';
        }
    }
    // Now show the subject box for this post.
    echo '
						<dt>
							<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
						</dt>
						<dd>
							<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80" class="input_text" />
						</dd>
						<dt class="clear_left">
							', $txt['message_icon'], ':
						</dt>
						<dd>
							<select name="icon" id="icon" onchange="showimage()">';
    // Loop through each message icon allowed, adding it to the drop down list.
    foreach ($context['icons'] as $icon) {
        echo '
								<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';
    }
    echo '
							</select>
							
							<img src="', $settings['images_url'] . '/post/' . $context['icon'], '.png" name="icons" alt="" style="display: inline-block; vertical-align: middle;margin-left: 1rem;" />
						</dd>
					</dl><hr class="clear" />';
    // Are you posting a calendar event?
    if ($context['make_event']) {
        echo '
					<div id="post_event">
						<fieldset id="event_main">
							<legend><span', isset($context['post_error']['no_event']) ? ' class="error"' : '', ' id="caption_evtitle">', $txt['calendar_event_title'], '</span></legend>
							<input type="text" name="evtitle" maxlength="255" size="60" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
							<div class="smalltext">
								<input type="hidden" name="calendar" value="1" />', $txt['calendar_year'], '
								<select name="year" id="year" tabindex="', $context['tabindex']++, '" onchange="generateDays();">';
        // Show a list of all the years we allow...
        for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) {
            echo '
									<option value="', $year, '"', $year == $context['event']['year'] ? ' selected="selected"' : '', '>', $year, '&nbsp;</option>';
        }
        echo '
								</select>
								', $txt['calendar_month'], '
								<select name="month" id="month" onchange="generateDays();">';
        // There are 12 months per year - ensure that they all get listed.
        for ($month = 1; $month <= 12; $month++) {
            echo '
									<option value="', $month, '"', $month == $context['event']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '&nbsp;</option>';
        }
        echo '
								</select>
								', $txt['calendar_day'], '
								<select name="day" id="day">';
        // This prints out all the days in the current month - this changes dynamically as we switch months.
        for ($day = 1; $day <= $context['event']['last_day']; $day++) {
            echo '
									<option value="', $day, '"', $day == $context['event']['day'] ? ' selected="selected"' : '', '>', $day, '&nbsp;</option>';
        }
        echo '
								</select>
							</div>
						</fieldset>';
        if (!empty($modSettings['cal_allowspan']) || $context['event']['new'] && $context['is_new_post']) {
            echo '
						<fieldset id="event_options">
							<legend>', $txt['calendar_event_options'], '</legend>
							<div class="event_options smalltext">
								<ul class="event_options">';
            // If events can span more than one day then allow the user to select how long it should last.
            if (!empty($modSettings['cal_allowspan'])) {
                echo '
									<li>
										', $txt['calendar_numb_days'], '
										<select name="span">';
                for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++) {
                    echo '
											<option value="', $days, '"', $days == $context['event']['span'] ? ' selected="selected"' : '', '>', $days, '&nbsp;</option>';
                }
                echo '
										</select>
									</li>';
            }
            // If this is a new event let the user specify which board they want the linked post to be put into.
            if ($context['event']['new'] && $context['is_new_post']) {
                echo '
									<li>
										', $txt['calendar_post_in'], '
										<select name="board">';
                foreach ($context['event']['categories'] as $category) {
                    echo '
											<optgroup label="', $category['name'], '">';
                    foreach ($category['boards'] as $board) {
                        echo '
												<option value="', $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
                    }
                    echo '
											</optgroup>';
                }
                echo '
										</select>
									</li>';
            }
            echo '
								</ul>
							</div>
						</fieldset>';
        }
        echo '
					</div>';
    }
    // If this is a poll then display all the poll options!
    if ($context['make_poll']) {
        echo '
					<div id="edit_poll">
						<fieldset id="poll_main">
							<legend><span ', isset($context['poll_error']['no_question']) ? ' class="error"' : '', '>', $txt['poll_question'], '</span></legend>
							<input type="text" name="question" value="', isset($context['question']) ? $context['question'] : '', '" tabindex="', $context['tabindex']++, '" size="80" class="input_text" />
							<ul class="poll_main">';
        // Loop through all the choices and print them out.
        foreach ($context['choices'] as $choice) {
            echo '
								<li>
									<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
									<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255" class="input_text" />
								</li>';
        }
        echo '
								<li id="pollMoreOptions"></li>
							</ul>
							<strong><a href="javascript:addPollOption(); void(0);">(', $txt['poll_add_option'], ')</a></strong>
						</fieldset>
						<fieldset id="poll_options">
							<legend>', $txt['poll_options'], '</legend>
							<dl class="settings narrow poll_options">
								<dt>
									<label for="poll_max_votes">', $txt['poll_max_votes'], ':</label>
								</dt>
								<dd>
									<input type="text" name="poll_max_votes" id="poll_max_votes" size="2" value="', $context['poll_options']['max_votes'], '" class="input_text" />
								</dd>
								<dt>
									<label for="poll_expire">', $txt['poll_run'], ':</label><br />
									<em class="smalltext">', $txt['poll_run_limit'], '</em>
								</dt>
								<dd>
									<input type="text" name="poll_expire" id="poll_expire" size="2" value="', $context['poll_options']['expire'], '" onchange="pollOptions();" maxlength="4" class="input_text" /> ', $txt['days_word'], '
								</dd>
								<dt>
									<label for="poll_change_vote">', $txt['poll_do_change_vote'], ':</label>
								</dt>
								<dd>
									<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked="checked"' : '', ' class="input_check" />
								</dd>';
        if ($context['poll_options']['guest_vote_enabled']) {
            echo '
								<dt>
									<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
								</dt>
								<dd>
									<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked="checked"' : '', ' class="input_check" />
								</dd>';
        }
        echo '
								<dt>
									', $txt['poll_results_visibility'], ':
								</dt>
								<dd>
									<input type="radio" name="poll_hide" id="poll_results_anyone" value="0"', $context['poll_options']['hide'] == 0 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_anyone">', $txt['poll_results_anyone'], '</label><br />
									<input type="radio" name="poll_hide" id="poll_results_voted" value="1"', $context['poll_options']['hide'] == 1 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_voted">', $txt['poll_results_voted'], '</label><br />
									<input type="radio" name="poll_hide" id="poll_results_expire" value="2"', $context['poll_options']['hide'] == 2 ? ' checked="checked"' : '', empty($context['poll_options']['expire']) ? 'disabled="disabled"' : '', ' class="input_radio" /> <label for="poll_results_expire">', $txt['poll_results_after'], '</label>
								</dd>
							</dl>
						</fieldset>
					</div>';
    }
    echo '		<div class="bwgrid">
						<div class="bwcell16">';
    // Show the actual posting area...
    if ($context['show_bbc']) {
        echo '
					<div id="bbcBox_message"></div>';
    }
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
					<div id="smileyBox_message"></div>';
    }
    echo '			</div>
						<div class="bwcell16">
					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '<br>
						</div>
					</div>
					<div class="bwgrid">
						<div class="bwcell4"><div class="inner_right"> ';
    // If this message has been edited in the past - display when it was.
    if (isset($context['last_modified'])) {
        echo '
					<div class="padding smalltext">
						<strong>', $txt['last_edit'], ':</strong>
						', $context['last_modified'], '
					</div>';
    }
    echo '
						</div></div>
						<div class="bwcell12">';
    // If the admin has enabled the hiding of the additional options - show a link and image for it.
    if (!empty($settings['additional_options_collapsable'])) {
        echo '
					<div id="postAdditionalOptionsHeader">
						<img src="', $settings['images_url'], '/collapse.gif" alt="-" id="postMoreExpand" style="display: none;" /> <strong><a href="#" id="postMoreExpandLink">', $txt['post_additionalopt'], '</a></strong>
					</div>';
    }
    // Display the check boxes for all the standard options - if they are available to the user!
    echo '
					<div id="postMoreOptions" class="smalltext">
						<ul class="post_options nolist">
							', $context['can_notify'] ? '<li><input type="hidden" name="notify" value="0" /><label for="check_notify"><input type="checkbox" name="notify" id="check_notify"' . ($context['notify'] || !empty($options['auto_notify']) ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['notify_replies'] . '</label></li>' : '', '
							', $context['can_lock'] ? '<li><input type="hidden" name="lock" value="0" /><label for="check_lock"><input type="checkbox" name="lock" id="check_lock"' . ($context['locked'] ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['lock_topic'] . '</label></li>' : '', '
							<li><label for="check_back"><input type="checkbox" name="goback" id="check_back"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['back_to_topic'] . '</label></li>
							', $context['can_sticky'] ? '<li><input type="hidden" name="sticky" value="0" /><label for="check_sticky"><input type="checkbox" name="sticky" id="check_sticky"' . ($context['sticky'] ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['sticky_after'] . '</label></li>' : '', '
							<li><label for="check_smileys"><input type="checkbox" name="ns" id="check_smileys"', $context['use_smileys'] ? '' : ' checked="checked"', ' value="NS" class="input_check" /> ', $txt['dont_use_smileys'], '</label></li>', '
							', $context['can_move'] ? '<li><input type="hidden" name="move" value="0" /><label for="check_move"><input type="checkbox" name="move" id="check_move" value="1" class="input_check" ' . (!empty($context['move']) ? 'checked="checked" ' : '') . '/> ' . $txt['move_after2'] . '</label></li>' : '', '
							', $context['can_announce'] && $context['is_first_post'] ? '<li><label for="check_announce"><input type="checkbox" name="announce_topic" id="check_announce" value="1" class="input_check" ' . (!empty($context['announce']) ? 'checked="checked" ' : '') . '/> ' . $txt['announce_topic'] . '</label></li>' : '', '
							', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
						</ul>
					</div>
						</div>
					</div>';
    // If this post already has attachments on it - give information about them.
    if (!empty($context['current_attachments'])) {
        echo '
					<dl id="postAttachment">
						<dt>
							', $txt['attached'], ':
						</dt>
						<dd class="smalltext">
							<input type="hidden" name="attach_del[]" value="0" />
							', $txt['uncheck_unwatchd_attach'], ':
						</dd>';
        foreach ($context['current_attachments'] as $attachment) {
            echo '
						<dd class="smalltext">
							<label for="attachment_', $attachment['id'], '"><input type="checkbox" id="attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check" /> ', $attachment['name'], empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : '', '
							', in_array(substr($attachment['name'], strlen($attachment['name']) - 4, 4), array('.jpg', '.png', '.gif')) ? '<br><img src="' . $scripturl . '?action=dlattach;topic=' . $context['current_topic'] . '.0;attach=' . $attachment['id'] . ';image" style="max-width: 120px;" alt="" />' : '', '
							</label>
						</dd>';
        }
        echo '
					</dl>';
    }
    // Is the user allowed to post any additional ones? If so give them the boxes to do it!
    if ($context['can_post_attachment']) {
        echo '
					<dl id="postAttachment2">
						<dt>
							', $txt['attach'], ':
						</dt>
						<dd class="smalltext">
							<input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
        // Show more boxes only if they aren't approaching their limit.
        if ($context['num_allowed_attachments'] > 1) {
            echo '
							<script type="text/javascript"><!-- // --><![CDATA[
								var allowed_attachments = ', $context['num_allowed_attachments'], ';
								var current_attachment = 1;

								function addAttachment()
								{
									allowed_attachments = allowed_attachments - 1;
									current_attachment = current_attachment + 1;
									if (allowed_attachments <= 0)
										return alert("', $txt['more_attachments_error'], '");

									setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)\' + \'</dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd>\');

									return true;
								}
							// ]]></script>
						</dd>
						<dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
        }
        echo '
						<dd class="smalltext">';
        // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
        if (!empty($modSettings['attachmentCheckExtensions'])) {
            echo '
							', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br />';
        }
        if (!empty($context['attachment_restrictions'])) {
            echo '
							', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br />';
        }
        if (!$context['can_post_attachment_unapproved']) {
            echo '
							<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br />';
        }
        echo '
						</dd>
					</dl>';
    }
    // Is visual verification enabled?
    if ($context['require_verification']) {
        echo '
					<div class="post_verification">
						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
							<strong>', $txt['verification'], ':</strong>
						</span>
						', template_control_verification($context['visual_verification_id'], 'all'), '
					</div>';
    }
    // Finally, the submit buttons.
    echo '
					<p class="smalltext" id="shortcuts">
						', $context['browser']['is_firefox'] ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
					</p>
					<p id="post_confirm_buttons" class="righttext">
						', template_control_richedit_buttons($context['post_box_name']);
    // Option to delete an event if user is editing one.
    if ($context['make_event'] && !$context['event']['new']) {
        echo '
						<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['event_delete_confirm'], '\');" class="button_submit" />';
    }
    echo '
					</p>
				</div>
				<span class="lowerframe"><span></span></span>
			</div>
			<br class="clear" />';
    // Assuming this isn't a new topic pass across the last message id.
    if (isset($context['topic_last_message'])) {
        echo '
			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />';
    }
    echo '
			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '" />
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
			<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
		</form>';
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[';
    // The functions used to preview a posts without loading a new page.
    echo '
			var current_board = ', empty($context['current_board']) ? 'null' : $context['current_board'], ';
			var make_poll = ', $context['make_poll'] ? 'true' : 'false', ';
			var txt_preview_title = "', $txt['preview_title'], '";
			var txt_preview_fetch = "', $txt['preview_fetch'], '";
			var new_replies = new Array();
			var reply_counter = ', empty($counter) ? 0 : $counter, ';
			function previewPost()
			{';
    if ($context['browser']['is_firefox']) {
        echo '
				// Firefox doesn\'t render <marquee> that have been put it using javascript
				if (document.forms.postmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
				{
					return submitThisOnce(document.forms.postmodify);
				}';
    }
    echo '
				if (window.XMLHttpRequest)
				{
					// Opera didn\'t support setRequestHeader() before 8.01.
					if (\'opera\' in window)
					{
						var test = new XMLHttpRequest();
						if (!(\'setRequestHeader\' in test))
							return submitThisOnce(document.forms.postmodify);
					}
					// !!! Currently not sending poll options and option checkboxes.
					var x = new Array();
					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', \'icon\', \'guestname\', \'email\', \'evtitle\', \'question\', \'topic\', ', JavaScriptEscape($context['session_var']), '];
					var numericFields = [
						\'board\', \'topic\', \'last_msg\',
						\'eventid\', \'calendar\', \'year\', \'month\', \'day\',
						\'poll_max_votes\', \'poll_expire\', \'poll_change_vote\', \'poll_hide\'
					];
					var checkboxFields = [
						\'ns\'
					];

					for (var i = 0, n = textFields.length; i < n; i++)
						if (textFields[i] in document.forms.postmodify)
						{
							// Handle the WYSIWYG editor.
							if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
								x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
							else
								x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
						}
					for (var i = 0, n = numericFields.length; i < n; i++)
						if (numericFields[i] in document.forms.postmodify && \'value\' in document.forms.postmodify[numericFields[i]])
							x[x.length] = numericFields[i] + \'=\' + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
					for (var i = 0, n = checkboxFields.length; i < n; i++)
						if (checkboxFields[i] in document.forms.postmodify && document.forms.postmodify.elements[checkboxFields[i]].checked)
							x[x.length] = checkboxFields[i] + \'=\' + document.forms.postmodify.elements[checkboxFields[i]].value;

					sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=post2\' + (current_board ? \';board=\' + current_board : \'\') + (make_poll ? \';poll\' : \'\') + \';preview;xml\', x.join(\'&\'), onDocSent);

					document.getElementById(\'preview_section\').style.display = \'\';
					setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
					setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);

					return false;
				}
				else
					return submitThisOnce(document.forms.postmodify);
			}
			function onDocSent(XMLDoc)
			{
				if (!XMLDoc)
				{
					document.forms.postmodify.preview.onclick = new function ()
					{
						return true;
					}
					document.forms.postmodify.preview.click();
				}

				// Show the preview section.
				var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
				setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);

				var bodyText = \'\';
				for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
					bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;

				setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
				document.getElementById(\'preview_body\').className = \'post\';

				// Show a list of errors (if any).
				var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
				var errorList = new Array();
				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
				document.getElementById(\'error_serious\').style.display = errors.getAttribute(\'serious\') == 1 ? \'\' : \'none\';
				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));

				// Show a warning if the topic has been locked.
				document.getElementById(\'lock_warning\').style.display = errors.getAttribute(\'topic_locked\') == 1 ? \'\' : \'none\';

				// Adjust the color of captions if the given data is erroneous.
				var captions = errors.getElementsByTagName(\'caption\');
				for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
					if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
						document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');

				if (errors.getElementsByTagName(\'post_error\').length == 1)
					document.forms.postmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
				else if (document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
				{
					if (\'runtimeStyle\' in document.forms.postmodify.', $context['post_box_name'], ')
						document.forms.postmodify.', $context['post_box_name'], '.style.borderColor = \'\';
					else
						document.forms.postmodify.', $context['post_box_name'], '.style.border = null;
				}

				// Set the new last message id.
				if (\'last_msg\' in document.forms.postmodify)
					document.forms.postmodify.last_msg.value = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'last_msg\')[0].firstChild.nodeValue;

				// Remove the new image from old-new replies!
				for (i = 0; i < new_replies.length; i++)
					document.getElementById(\'image_new_\' + new_replies[i]).style.display = \'none\';
				new_replies = new Array();

				var ignored_replies = new Array(), ignoring;
				var newPosts = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'new_posts\')[0] ? XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'new_posts\')[0].getElementsByTagName(\'post\') : {length: 0};
				var numNewPosts = newPosts.length;
				if (numNewPosts != 0)
				{
					var newPostsHTML = \'<span id="new_replies"><\' + \'/span>\';
					for (var i = 0; i < numNewPosts; i++)
					{
						new_replies[new_replies.length] = newPosts[i].getAttribute("id");

						ignoring = false;
						if (newPosts[i].getElementsByTagName("is_ignored")[0].firstChild.nodeValue != 0)
							ignored_replies[ignored_replies.length] = ignoring = newPosts[i].getAttribute("id");

						newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \' core_posts"><span class="topslice"><span></span></span><div class="content" id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <img src="\' + smf_images_url + \'/', $context['user']['language'], '/new.gif" alt="', $txt['preview_new'], '" id="image_new_\' + newPosts[i].getAttribute("id") + \'" /></div>\';';
    if ($context['can_quote']) {
        echo '
						newPostsHTML += \'<ul class="reset smalltext quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li class="quote_button"><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');"><span>', $txt['bbc_quote'], '</span><\' + \'/a></li></ul>\';';
    }
    echo '
						newPostsHTML += \'<br class="clear" />\';

						if (ignoring)
							newPostsHTML += \'<div id="msg_\' + newPosts[i].getAttribute("id") + \'_ignored_prompt" class="smalltext">', $txt['ignoring_user'], '<a href="#" id="msg_\' + newPosts[i].getAttribute("id") + \'_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a></div>\';

						newPostsHTML += \'<div class="list_posts smalltext" id="msg_\' + newPosts[i].getAttribute("id") + \'_body">\' + newPosts[i].getElementsByTagName("message")[0].firstChild.nodeValue + \'<\' + \'/div></div><span class="botslice"><span></span></span></div>\';
					}
					setOuterHTML(document.getElementById(\'new_replies\'), newPostsHTML);
				}

				var numIgnoredReplies = ignored_replies.length;
				if (numIgnoredReplies != 0)
				{
					for (var i = 0; i < numIgnoredReplies; i++)
					{
						aIgnoreToggles[ignored_replies[i]] = new smc_Toggle({
							bToggleEnabled: true,
							bCurrentlyCollapsed: true,
							aSwappableContainers: [
								\'msg_\' + ignored_replies[i] + \'_body\',
								\'msg_\' + ignored_replies[i] + \'_quote\',
							],
							aSwapLinks: [
								{
									sId: \'msg_\' + ignored_replies[i] + \'_ignored_link\',
									msgExpanded: \'\',
									msgCollapsed: ', JavaScriptEscape($txt['show_ignore_user_post']), '
								}
							]
						});
					}
				}

				if (typeof(smf_codeFix) != \'undefined\')
					smf_codeFix();
			}';
    // Code for showing and hiding additional options.
    if (!empty($settings['additional_options_collapsable'])) {
        echo '
			var oSwapAdditionalOptions = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
				funcOnBeforeCollapse: function () {
					document.getElementById(\'additional_options\').value = \'0\';
				},
				funcOnBeforeExpand: function () {
					document.getElementById(\'additional_options\').value = \'1\';
				},
				aSwappableContainers: [
					\'postMoreOptions\',
					\'postAttachment\',
					\'postAttachment2\',
					\'postAttachment3\'
				],
				aSwapImages: [
					{
						sId: \'postMoreExpand\',
						srcExpanded: smf_images_url + \'/collapse.gif\',
						altExpanded: \'-\',
						srcCollapsed: smf_images_url + \'/expand.gif\',
						altCollapsed: \'+\'
					}
				],
				aSwapLinks: [
					{
						sId: \'postMoreExpandLink\',
						msgExpanded: ', JavaScriptEscape($txt['post_additionalopt']), ',
						msgCollapsed: ', JavaScriptEscape($txt['post_additionalopt']), '
					}
				]
			});';
    }
    echo '
		// ]]></script>';
    // If the user is replying to a topic show the previous posts.
    if (isset($context['previous_posts']) && count($context['previous_posts']) > 0) {
        echo '
		<div id="recent" class="flow_hidden main_section">
			<div class="cat_bar">
				<h3 class="catbg">', $txt['topic_summary'], '</h3>
			</div>
			<span id="new_replies"></span>';
        $ignored_posts = array();
        foreach ($context['previous_posts'] as $post) {
            $ignoring = false;
            if (!empty($post['is_ignored'])) {
                $ignored_posts[] = $ignoring = $post['id'];
            }
            echo '
				<div class="', $post['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
				<span class="topslice"><span></span></span>
				<div class="content" id="msg', $post['id'], '">
					<div class="floatleft">
						<h5>', $txt['posted_by'], ': ', $post['poster'], '</h5>
						<span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $post['time'], '&nbsp;&#187;</span>
					</div>';
            if ($context['can_quote']) {
                echo '
					<ul class="reset smalltext quickbuttons" id="msg_', $post['id'], '_quote">
						<li class="quote_button"><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');"><span>', $txt['bbc_quote'], '</span></a></li>
					</ul>';
            }
            echo '
					<br class="clear" />';
            if ($ignoring) {
                echo '
					<div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
						', $txt['ignoring_user'], '
						<a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
					</div>';
            }
            echo '
					<div class="list_posts smalltext" id="msg_', $post['id'], '_body">', $post['message'], '</div>
				</div>
				<span class="botslice"><span></span></span>
			</div>';
        }
        echo '
		</div>
		<script type="text/javascript"><!-- // --><![CDATA[
			var aIgnoreToggles = new Array();';
        foreach ($ignored_posts as $post_id) {
            echo '
			aIgnoreToggles[', $post_id, '] = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: true,
				aSwappableContainers: [
					\'msg_', $post_id, '_body\',
					\'msg_', $post_id, '_quote\',
				],
				aSwapLinks: [
					{
						sId: \'msg_', $post_id, '_ignored_link\',
						msgExpanded: \'\',
						msgCollapsed: ', JavaScriptEscape($txt['show_ignore_user_post']), '
					}
				]
			});';
        }
        echo '
			function insertQuoteFast(messageid)
			{
				if (window.XMLHttpRequest)
					getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), onDocReceived);
				else
					reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), 240, 90);
				return true;
			}
			function onDocReceived(XMLDoc)
			{
				var text = \'\';
				for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
					text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
				oEditorHandle_', $context['post_box_name'], '.insertText(text, false, true);
			}
		// ]]></script>';
    }
}
Example #2
0
/**
 * The main template for the post page.
 */
function template_post_page()
{
    global $context, $txt;
    // Show the actual posting area...
    echo '
					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    // A placeholder for our mention box if needed
    if (!empty($context['member_ids'])) {
        echo '
							<div id="mentioned" style="display:none">';
        foreach ($context['member_ids'] as $id) {
            echo '
								<input type="hidden" name="uid[]" value="', $id, '" />';
        }
        echo '
							</div>';
    }
    // Show our submit buttons before any more options
    echo '
						<div id="post_confirm_buttons" class="submitbutton">
							', template_control_richedit_buttons($context['post_box_name']);
    // Option to delete an event if user is editing one.
    if ($context['make_event'] && !$context['event']['new']) {
        echo '
							<input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['event_delete_confirm'], '\');" class="button_submit" />';
    }
    // Option to add a poll (javascript if enabled, otherwise preview with poll)
    if (!$context['make_poll'] && $context['can_add_poll']) {
        echo '
							<input type="submit" name="poll" value="', $txt['add_poll'], '" onclick="return loadAddNewPoll(this, ', empty($context['current_board']) ? '0' : $context['current_board'], ', \'postmodify\');" class="button_submit" />';
    }
    echo '
						</div>';
}
Example #3
0
/**
 * Template for the section to compose an email to members
 */
function template_email_members_compose()
{
    global $context, $txt, $scripturl;
    echo '
	<div id="admincenter">
		<form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="UTF-8">
			<h3 class="category_header">
				<a class="hdicon cat_img_helptopics help" href="', $scripturl, '?action=quickhelp;help=email_members" onclick="return reqOverlayDiv(this.href);" title="', $txt['help'], '"></a> ', $txt['admin_newsletters'], '
			</h3>
			<div class="information">
				', str_replace('{help_emailmembers}', $scripturl . '?action=quickhelp;help=emailmembers" onclick="return reqOverlayDiv(this.href);', $txt['email_variables']), '
			</div>';
    // The preview section
    echo '
			<div id="preview_section" class="forumposts"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
				<h3 class="category_header">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
				<div class="post" id="preview_body">
					', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
				</div>
			</div>';
    // Any errors to speak of?
    echo '
			<div class="windowbg">
				<div id="post_error" class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'warningbox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', '>
					<dl>
						<dt>
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
						</dt>
						<dd>
							<ul class="error" id="post_error_list">
								', empty($context['post_error']['messages']) ? '' : '<li>' . implode('</li><li>', $context['post_error']['messages']) . '</li>', '
							</ul>
						</dd>
					</dl>
				</div>';
    // Show the editor area
    echo '
				<div class="editor_wrapper">
					<dl id="post_header">
						<dt class="clear_left">
							<label for="subject"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</label>
						</dt>
						<dd id="pm_subject">
							<input type="text" id="subject" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
						</dd>
					</dl>
					<hr class="clear" />';
    // Show BBC buttons, smileys and textbox.
    echo '
					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    echo '
					<ul>
						<li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], '</label></li>
						<li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], '</label></li>
						<li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" class="input_check" /> ', $txt['email_parsed_html'], '</label></li>
					</ul>
					<div class="submitbutton">
						', template_control_richedit_buttons($context['post_box_name']), '
					</div>
				</div>
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="email_force" value="', $context['email_force'], '" />
				<input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
				<input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />
			</div>';
    foreach ($context['recipients'] as $key => $values) {
        echo '
			<input type="hidden" name="', $key, '" value="', implode($key == 'emails' ? ';' : ',', $values), '" />';
    }
    // The vars used to preview a newsletter without loading a new page, used by post.js previewControl()
    addInlineJavascript('
		var form_name = "newsmodify",
			preview_area = "news",
			txt_preview_title = "' . $txt['preview_title'] . '",
			txt_preview_fetch = "' . $txt['preview_fetch'] . '";

		function checkboxes_status (item)
		{
			if (item.id == \'send_html\')
				document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled;

			if (item.id == \'send_pm\')
			{
				if (!document.getElementById(\'send_html\').checked)
					document.getElementById(\'parse_html\').disabled = true;
				else
					document.getElementById(\'parse_html\').disabled = false;

				document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled;
			}
		}', true);
    echo '
		</form>
	</div>';
}
function template_send()
{
    global $context, $settings, $options, $scripturl, $modSettings, $txt;
    // Show which messages were sent successfully and which failed.
    if (!empty($context['send_log'])) {
        echo '
			<div class="cat_bar">
				<h3 class="catbg">', $txt['pm_send_report'], '</h3>
			</div>
			<div class="windowbg">
			<span class="topslice"><span></span></span>
				<div class="content">';
        if (!empty($context['send_log']['sent'])) {
            foreach ($context['send_log']['sent'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        if (!empty($context['send_log']['failed'])) {
            foreach ($context['send_log']['failed'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        echo '
				</div>
			<span class="botslice"><span></span></span>
			</div>
			<br />';
    }
    // Show the preview of the personal message.
    if (isset($context['preview_message'])) {
        echo '
		<div class="cat_bar">
			<h3 class="catbg">', $context['preview_subject'], '</h3>
		</div>
		<div class="windowbg">
		<span class="topslice"><span></span></span>
			<div class="content">
				', $context['preview_message'], '
			</div>
		<span class="botslice"><span></span></span>
		</div>
		<br />';
    }
    // Main message editing box.
    echo '
		<div class="cat_bar">
			<h3 class="catbg">
					<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/im_newmsg.gif" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '</span>
			</h3>
		</div>';
    echo '
	<form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
		<div>
			<span class="upperframe"><span></span></span>
			<div class="roundframe">';
    // If there were errors for sending the PM, show them.
    if (!empty($context['post_error']['messages'])) {
        echo '
				<div class="errorbox">
					<strong>', $txt['error_while_submitting'], '</strong>
					<ul>';
        foreach ($context['post_error']['messages'] as $error) {
            echo '
						<li class="error">', $error, '</li>';
        }
        echo '
					</ul>
				</div>';
    }
    echo '
				<dl id="post_header">';
    // To and bcc. Include a button to search for members.
    echo '
					<dt>
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : '', '>', $txt['pm_to'], ':</span>
					</dt>';
    // Autosuggest will be added by the JavaScript later on.
    echo '
					<dd>
						<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
    // A link to add BCC, only visible with JavaScript enabled.
    echo '
						<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
    // A div that'll contain the items found by the autosuggest.
    echo '
						<div id="to_item_list_container"></div>';
    echo '
					</dd>';
    // This BCC row will be hidden by default if JavaScript is enabled.
    echo '
					<dt id="bcc_div">
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : '', '>', $txt['pm_bcc'], ':</span>
					</dt>
					<dd id="bcc_div2">
						<input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
						<div id="bcc_item_list_container"></div>
					</dd>';
    // The subject of the PM.
    echo '
					<dt>
						<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', '>', $txt['subject'], ':</span>
					</dt>
					<dd>
						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="40" maxlength="50" />
					</dd>
				</dl>';
    // Showing BBC?
    if ($context['show_bbc']) {
        echo '
				<div id="bbcBox_message"></div>';
    }
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
				<div id="smileyBox_message"></div>';
    }
    // Show BBC buttons, smileys and textbox.
    echo '
				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    // Require an image to be typed to save spamming?
    if ($context['require_verification']) {
        echo '
				<div class="post_verification">
					<strong>', $txt['pm_visual_verification_label'], ':</strong>
					', template_control_verification($context['visual_verification_id'], 'all'), '
				</div>';
    }
    // Send, Preview, spellcheck buttons.
    echo '
				<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>
				<p id="shortcuts" class="smalltext">
					', $context['browser']['is_firefox'] ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
				</p>
				<p id="post_confirm_strip" class="righttext">
					', template_control_richedit_buttons($context['post_box_name']), '
				</p>
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
				<input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
				<input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
				<input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
				<input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
			</div>
			<span class="lowerframe"><span></span></span>
		</div>
	</form>';
    // Show the message you're replying to.
    if ($context['reply']) {
        echo '
	<br />
	<br />
	<div class="cat_bar">
		<h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
	</div>
	<div class="title_bar">
		<h3 class="titlebg">
			<span class="floatleft">', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</span>
			<span class="floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
		</h3>
	</div>
	<div class="windowbg2">
		<span class="topslice"><span></span></span>
		<div class="content">
			', $context['quoted_message']['body'], '
		</div>
		<span class="botslice"><span></span></span>
	</div>';
    }
    echo '
		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?fin20"></script>
		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
		<script type="text/javascript"><!-- // --><![CDATA[
			var oPersonalMessageSend = new smf_PersonalMessageSend({
				sSelf: \'oPersonalMessageSend\',
				sSessionId: \'', $context['session_id'], '\',
				sSessionVar: \'', $context['session_var'], '\',
				sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
				sToControlId: \'to_control\',
				aToRecipients: [';
    foreach ($context['recipients']['to'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
    }
    echo '
				],
				aBccRecipients: [';
    foreach ($context['recipients']['bcc'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
    }
    echo '
				],
				sBccControlId: \'bcc_control\',
				sBccDivId: \'bcc_div\',
				sBccDivId2: \'bcc_div2\',
				sBccLinkId: \'bcc_link\',
				sBccLinkContainerId: \'bcc_link_container\',
				bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
				sShowBccLinkTemplate: ', JavaScriptEscape('
					<a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqWin(this.href);">(?)</a>'), '
			});
		';
    echo '
		// ]]></script>';
}
Example #5
0
function template_email_members_compose()
{
    global $context, $settings, $options, $txt, $scripturl;
    echo '
		<div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
			<div class="cat_bar">
				<h3 class="catbg">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<div class="post" id="preview_body">
						', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
					</div>
				</div>
			</div>
		</div><br />';
    echo '
	<div id="admincenter">
		<form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '">
			<div class="cat_bar">
				<h3 class="catbg">
					<a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="icon" /></a> ', $txt['admin_newsletters'], '
				</h3>
			</div>
			<div class="information">
				', $txt['email_variables'], '
			</div>
			<div class="windowbg">
				<div class="content">
				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
					<dl>
						<dt>
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
						</dt>
						<dd class="error" id="error_list">
							', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
						</dd>
					</dl>
				</div>
				<dl id="post_header">
					<dt class="clear_left">
						<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
					</dt>
					<dd id="pm_subject">
						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
					</dd>
				</dl><hr class="clear" />
				<div id="bbcBox_message"></div>';
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
				<div id="smileyBox_message"></div>';
    }
    // Show BBC buttons, smileys and textbox.
    echo '
				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    echo '
					<ul class="reset">
						<li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], '</label></li>
						<li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], '</label></li>
						<li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" class="input_check" /> ', $txt['email_parsed_html'], '</label></li>
					</ul>
				<p id="shortcuts" class="smalltext">
					', isBrowser('is_firefox') ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
				</p>
				<p id="post_confirm_strip" class="righttext">
					', template_control_richedit_buttons($context['post_box_name']), '
				</p>
				</div>
			</div>
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
			<input type="hidden" name="email_force" value="', $context['email_force'], '" />
			<input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
			<input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />';
    foreach ($context['recipients'] as $key => $values) {
        echo '
			<input type="hidden" name="', $key, '" value="', implode($key == 'emails' ? ';' : ',', $values), '" />';
    }
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[';
    // The functions used to preview a posts without loading a new page.
    echo '
			var txt_preview_title = "', $txt['preview_title'], '";
			var txt_preview_fetch = "', $txt['preview_fetch'], '";
			function previewPost()
			{';
    if (isBrowser('is_firefox')) {
        echo '
				// Firefox doesn\'t render <marquee> that have been put it using javascript
				if (document.forms.newsmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
				{
					return submitThisOnce(document.forms.newsmodify);
				}';
    }
    echo '
				if (window.XMLHttpRequest)
				{
					// Opera didn\'t support setRequestHeader() before 8.01.
					// @todo Remove support for old browsers
					if (\'opera\' in window)
					{
						var test = new XMLHttpRequest();
						if (!(\'setRequestHeader\' in test))
							return submitThisOnce(document.forms.newsmodify);
					}
					// @todo Currently not sending poll options and option checkboxes.
					var x = new Array();
					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), '];
					var checkboxFields = [\'send_html\', \'send_pm\'];

					for (var i = 0, n = textFields.length; i < n; i++)
						if (textFields[i] in document.forms.newsmodify)
						{
							// Handle the WYSIWYG editor.
							if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
								x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
							else
								x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
						}
					for (var i = 0, n = checkboxFields.length; i < n; i++)
						if (checkboxFields[i] in document.forms.newsmodify && document.forms.newsmodify.elements[checkboxFields[i]].checked)
							x[x.length] = checkboxFields[i] + \'=\' + document.forms.newsmodify.elements[checkboxFields[i]].value;

					x[x.length] = \'item=newsletterpreview\';

					sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=previews;xml\', x.join(\'&\'), onDocSent);

					document.getElementById(\'preview_section\').style.display = \'\';
					setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
					setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);

					return false;
				}
				else
					return submitThisOnce(document.forms.newsmodify);
			}
			function onDocSent(XMLDoc)
			{
				if (!XMLDoc)
				{
					document.forms.newsmodify.preview.onclick = new function ()
					{
						return true;
					}
					document.forms.newsmodify.preview.click();
				}

				// Show the preview section.
				var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
				setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);

				var bodyText = \'\';
				for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
					bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;

				setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
				document.getElementById(\'preview_body\').className = \'post\';

				// Show a list of errors (if any).
				var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
				var errorList = new Array();
				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));

				// Adjust the color of captions if the given data is erroneous.
				var captions = errors.getElementsByTagName(\'caption\');
				for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
					if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
						document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');

				if (errors.getElementsByTagName(\'post_error\').length == 1)
					document.forms.newsmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
				else if (document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
				{
					if (\'runtimeStyle\' in document.forms.newsmodify.', $context['post_box_name'], ')
						document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor = \'\';
					else
						document.forms.newsmodify.', $context['post_box_name'], '.style.border = null;
				}
				location.hash = \'#\' + \'preview_section\';
			}';
    echo '
		// ]]></script>';
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[
			function checkboxes_status (item)
			{
				if (item.id == \'send_html\')
					document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled;
				if (item.id == \'send_pm\')
				{
					if (!document.getElementById(\'send_html\').checked)
						document.getElementById(\'parse_html\').disabled = true;
					else
						document.getElementById(\'parse_html\').disabled = false;
					document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled;
				}
			}
		// ]]></script>
		</form>
	</div>';
}
Example #6
0
function template_main()
{
    global $context, $settings, $options, $txt, $scripturl, $modSettings, $counter;
    echo '
	<form action="', $scripturl, '?action=', $context['destination'], ';', empty($context['current_board']) ? '' : 'board=' . $context['current_board'], '" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" enctype="multipart/form-data">';
    // If the user wants to see how their message looks - the preview section is where it's at!
    echo '
		<ul data-role="listview" data-inset="true" ', isset($context['preview_message']) ? '' : 'style="display: none;"', '>
			<li>
				<h3>
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
			</li>
			<li>
				<div class="post" id="preview_body">
					', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
				</div>
			</li>
		</ul>';
    if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board']))) {
        echo '
		<input type="hidden" name="eventid" value="', $context['event']['id'], '" />';
    }
    if (isset($context['current_topic'])) {
        echo '
		<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />';
    }
    // If an error occurred, explain what happened.
    echo '
		<ul data-role="listview" data-inset="true" ', empty($context['post_error']['messages']) ? 'style="display: none"' : '', '>
			<li>
				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '" id="errors">
					<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
					', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
				</div>
			</li>
		</ul>';
    // If this won't be approved let them know!
    if (!$context['becomes_approved']) {
        echo '
		<ul data-role="listview" data-inset="true">	
			<li class="information">
				<em>', $txt['wait_for_approval'], '</em>
				<input type="hidden" name="not_approved" value="1" />
			</li>
		</ul>';
    }
    // If it's locked, show a message to warn the replyer.
    echo '
		<ul data-role="listview" data-inset="true">
			<li class="information"', $context['locked'] ? '' : ' style="display: none"', ' id="lock_warning">
				', $txt['topic_locked_no_reply'], '
			</pli>
		</ul>';
    // The post header... important stuff
    // Start the main table.
    echo '<ul data-role="listview" data-inset="true">
			<li data-role="list-divider">', $context['page_title'], '</li>';
    // Guests have to put in their name and email...
    if (isset($context['name']) && isset($context['email'])) {
        echo '
			<li>
				<label for="guestname">', $txt['name'], ':</label>
				<input type="text" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '" class="input_text" />';
        if (empty($modSettings['guest_post_no_email'])) {
            echo '
				<label for="email">', $txt['email'], ':</label>
				<input type="text" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" />';
        }
        echo '
			</li>';
    }
    // Now show the subject box for this post.
    echo '
			<li>
				<label for="subject" >', $txt['subject'], ':</label>
				<input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', ' placeholder="', $txt['subject'], '" />
			</li>';
    echo '
			<li>
				<label for="icon">', $txt['message_icon'], ':<span><img src="', $context['icon_url'], '" name="icons" id="message_icon" hspace="15" alt="" /></span></label>
				
				<select name="icon" id="icon">';
    // Loop through each message icon allowed, adding it to the drop down list.
    foreach ($context['icons'] as $icon) {
        echo '
					<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';
    }
    echo '
				</select>
				<script><!-- // --><![CDATA[
						$(document).ready ( function () {
							$("#icon").bind("change", function () {
								// Get the value of the selected option
								var img_name = $(this).val();
								var url = "' . $settings['images_url'] . '/post/";
								if (img_name) {	
									$("#message_icon").attr("src", url + img_name + ".png");
								}
								return false;
							});
						});
				// ]]></script>
			</li>';
    // If this is a poll then display all the poll options!
    if ($context['make_poll']) {
        echo '
			<li>
				<span ', isset($context['poll_error']['no_question']) ? ' class="error"' : '', '>', $txt['poll_question'], '</span>
				<input type="text" name="question" value="', isset($context['question']) ? $context['question'] : '', '" tabindex="', $context['tabindex']++, '" size="80" class="input_text" />
			</li>
			<li id="pollMoreOptions">';
        // Loop through all the choices and print them out.
        foreach ($context['choices'] as $choice) {
            echo '
			
				<label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], ':</label>
				<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255" class="input_text" />';
        }
        // Some javascript for adding more options.
        echo '	
				<script>
					var pollOptionNum = 0;
					var pollOptionId = ', $context['last_choice_id'], ';

					function addPollOption()
					{
						if (pollOptionNum == 0)
						{
							for (var i = 0; i < document.forms.postmodify.elements.length; i++)
								if (document.forms.postmodify.elements[i].id.substr(0, 8) == "options-")
									pollOptionNum++;
						}
						pollOptionNum++
						pollOptionId++

						$("#pollMoreOptions").append(\'<label class="ui-input-text" for="options-\' + pollOptionId + \'" ', isset($context['poll_error']['no_question']) ? ' class="error"' : '', '>', $txt['option'], ' \' + pollOptionNum + \':</label><input class="input_text ui-input-text ui-body-c ui-corner-all ui-shadow-inset" type="text" name="options[\' + (pollOptionId) + \']" id="options-\' + (pollOptionId) + \'" value="" size="80" maxlength="255" class="input_text" />\');
					}
				</script>
			</li>
			<li><strong><a href="javascript:addPollOption(); void(0);">(', $txt['poll_add_option'], ')</a></strong></li>
			
			<li>	
				<fieldset id="poll_options">
					<legend>', $txt['poll_options'], '</legend>

					<label for="poll_max_votes">', $txt['poll_max_votes'], ':</label>
					<input type="text" name="poll_max_votes" id="poll_max_votes" size="2" value="', $context['poll_options']['max_votes'], '" class="input_text" />

					<label for="poll_expire">', $txt['poll_run'], ': (', $txt['days_word'], ')</label>
					<span>', $txt['poll_run_limit'], '</span>
					<input type="text" name="poll_expire" id="poll_expire" size="2" value="', $context['poll_options']['expire'], '" onchange="pollOptions();" maxlength="4" class="input_text" />

					<label for="poll_change_vote">', $txt['poll_do_change_vote'], ':</label>
					<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked="checked"' : '', ' class="input_check" />';
        if ($context['poll_options']['guest_vote_enabled']) {
            echo '

					<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
					<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked="checked"' : '', ' class="input_check" />';
        }
        echo '
					', $txt['poll_results_visibility'], ':

					<input type="radio" name="poll_hide" id="poll_results_anyone" value="0"', $context['poll_options']['hide'] == 0 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_anyone">', $txt['poll_results_anyone'], '</label>
					<input type="radio" name="poll_hide" id="poll_results_voted" value="1"', $context['poll_options']['hide'] == 1 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_voted">', $txt['poll_results_voted'], '</label>
					<input type="radio" name="poll_hide" id="poll_results_expire" value="2"', $context['poll_options']['hide'] == 2 ? ' checked="checked"' : '', empty($context['poll_options']['expire']) ? 'disabled="disabled"' : '', ' class="input_radio" /> <label for="poll_results_expire">', $txt['poll_results_after'], '</label>
				</fieldset>
			</li>';
    }
    echo '
			<li>
			', template_control_richedit($context['post_box_name']), '
			</li>
		</ul>
	<div data-role="collapsible" data-theme="b" data-content-theme="d">
		<h3>', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</h3>';
    // Display the check boxes for all the standard options - if they are available to the user!
    if ($context['can_notify']) {
        echo '
		<div data-role="fieldcontain">
			<input type="hidden" name="notify" value="0" />	
			<label for="notify">', $txt['notify_replies'], '</label>
			<select name="notify" id="notify" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . ($context['notify'] || !empty($options['auto_notify']) ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    if ($context['can_lock']) {
        echo '
		<div data-role="fieldcontain">
			<input type="hidden" name="lock" value="0" />				
			<label for="check_lock">', $txt['lock_topic'], '</label>
			<select name="lock" id="check_lock" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . ($context['locked'] ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    echo '
		<div data-role="fieldcontain">				
			<label for="check_back">', $txt['back_to_topic'], '</label>
			<select name="goback" id="check_back" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    if ($context['can_sticky']) {
        echo '
		<div data-role="fieldcontain">			
			<label for="check_sticky">', $txt['sticky_after'], '</label>
			<select name="sticky" id="check_sticky" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . ($context['sticky'] ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    echo '
		<div data-role="fieldcontain">
			<input type="hidden" name="check_smileys" value="0" />				
			<label for="check_smileys">', $txt['dont_use_smileys'], '</label>
			<select name="ns" id="check_smileys" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"', $context['use_smileys'] ? '' : ' selected="selected"', '>', $txt['yes'], '</option>
			</select>
		</div>';
    if ($context['can_move']) {
        echo '
		<div data-role="fieldcontain">				
			<label for="check_move">', $txt['move_after2'], '</label>
			<select name="move" id="check_move" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . (!empty($context['move']) ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    if ($context['can_announce'] && $context['is_first_post']) {
        echo '
		<div data-role="fieldcontain">			
			<label for="check_announce">', $txt['announce_topic'], '</label>
			<select name="announce_topic" id="check_announce" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . (!empty($context['announce']) ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    if ($context['show_approval']) {
        echo '
		<div data-role="fieldcontain">				
			<label for="check_announce">', $txt['announce_topic'], '</label>
			<select name="announce_topic" id="check_announce" data-role="slider" data-theme="c">
				<option value="0">', $txt['no'], '</option>
				<option value="1"' . ($context['show_approval'] === 2 ? ' selected="selected"' : '') . '>', $txt['yes'], '</option>
			</select>
		</div>';
    }
    echo '
		<div id="postMoreOptions" class="smalltext">
			<ul class="post_options">
				', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
			</ul>
		</div>';
    // If this post already has attachments on it - give information about them.
    if (!empty($context['current_attachments'])) {
        echo '
		<dl id="postAttachment">
			<dt>
				', $txt['attached'], ':
			</dt>
			<dd class="smalltext">
				<input type="hidden" name="attach_del[]" value="0" />
				', $txt['uncheck_unwatchd_attach'], ':
			</dd>';
        foreach ($context['current_attachments'] as $attachment) {
            echo '
			<dd class="smalltext">
				<label for="attachment_', $attachment['id'], '"><input type="checkbox" id="attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check" /> ', $attachment['name'], empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : '', !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label>
			</dd>';
        }
        if (!empty($context['files_in_session_warning'])) {
            echo '
			<dd class="smalltext">', $context['files_in_session_warning'], '</dd>';
        }
        echo '
		</dl>';
    }
    // Is the user allowed to post any additional ones? If so give them the boxes to do it!
    if ($context['can_post_attachment']) {
        echo '
		<dl id="postAttachment2">';
        // But, only show them if they haven't reached a limit. Or a mod author hasn't hidden them.
        if ($context['num_allowed_attachments'] > 0 || !empty($context['dont_show_them'])) {
            echo '
			<dt>
				', $txt['attach'], ':
			</dt>
			<dd class="smalltext">
				', empty($modSettings['attachmentSizeLimit']) ? '' : '<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '" />', '
				<input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
            // Show more boxes if they aren't approaching that limit.
            if ($context['num_allowed_attachments'] > 1) {
                echo '
				<script type="text/javascript"><!-- // --><![CDATA[
					var allowed_attachments = ', $context['num_allowed_attachments'], ';
					var current_attachment = 1;

					function addAttachment()
					{
						allowed_attachments = allowed_attachments - 1;
						current_attachment = current_attachment + 1;
						if (allowed_attachments <= 0)
							return alert("', $txt['more_attachments_error'], '");

						setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '<\\/a>)\' + \'<\\/dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd>\');

						return true;
					}
				// ]]></script>
			</dd>
			<dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
            } else {
                echo '
			</dd>';
            }
        }
        // Add any template changes for an alternative upload system here.
        call_integration_hook('integrate_upload_template', array());
        echo '
			<dd class="smalltext">';
        // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
        if (!empty($modSettings['attachmentCheckExtensions'])) {
            echo '
				', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br />';
        }
        if (!empty($context['attachment_restrictions'])) {
            echo '
				', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br />';
        }
        if ($context['num_allowed_attachments'] == 0) {
            echo '
				', $txt['attach_limit_nag'], '<br />';
        }
        if (!$context['can_post_attachment_unapproved']) {
            echo '
				<span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br />';
        }
        echo '
			</dd>
		</dl>';
    }
    echo '
	</div>';
    // Is visual verification enabled?
    if ($context['require_verification']) {
        echo '
					<div class="post_verification">
						<span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
							<strong>', $txt['verification'], ':</strong>
						</span>
						', template_control_verification($context['visual_verification_id'], 'all'), '
					</div>';
    }
    // Finally, the submit buttons.
    echo template_control_richedit_buttons($context['post_box_name']);
    // Assuming this isn't a new topic pass across the last message id.
    if (isset($context['topic_last_message'])) {
        echo '
			<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />';
    }
    echo '
			<input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '" />
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
			<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
		</form>';
}
function template_send()
{
    global $context, $settings, $options, $scripturl, $modSettings, $txt;
    // Show which messages were sent successfully and which failed.
    if (!empty($context['send_log'])) {
        echo '
			<div class="cat_bar">
				<h3 class="catbg">', $txt['pm_send_report'], '</h3>
			</div>
			<div class="windowbg">
				<div class="content">';
        if (!empty($context['send_log']['sent'])) {
            foreach ($context['send_log']['sent'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        if (!empty($context['send_log']['failed'])) {
            foreach ($context['send_log']['failed'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        echo '
				</div>
			</div>
			<br />';
    }
    // Show the preview of the personal message.
    echo '
		<div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
			<div class="cat_bar">
				<h3 class="catbg">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<div class="post" id="preview_body">
						', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
					</div>
				</div>
			</div>
		</div><br />';
    // Main message editing box.
    echo '
		<div class="cat_bar">
			<h3 class="catbg">
					<img src="', $settings['images_url'], '/icons/im_newmsg.png" class="icon" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '
			</h3>
		</div>';
    echo '
	<form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
		<div>
			<div class="roundframe">
				<br class="clear" />';
    // If there were errors for sending the PM, show them.
    echo '
				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
					<dl>
						<dt>
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
						</dt>
						<dd class="error" id="error_list">
							', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
						</dd>
					</dl>
				</div>';
    if (!empty($modSettings['drafts_pm_enabled'])) {
        echo '
				<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
				</div>';
    }
    echo '
				<dl id="post_header">';
    // To and bcc. Include a button to search for members.
    echo '
					<dt>
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : '', ' id="caption_to">', $txt['pm_to'], ':</span>
					</dt>';
    // Autosuggest will be added by the JavaScript later on.
    echo '
					<dd id="pm_to" class="clear_right">
						<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
    // A link to add BCC, only visible with JavaScript enabled.
    echo '
						<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
    // A div that'll contain the items found by the autosuggest.
    echo '
						<div id="to_item_list_container"></div>';
    echo '
					</dd>';
    // This BCC row will be hidden by default if JavaScript is enabled.
    echo '
					<dt  class="clear_left" id="bcc_div">
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : '', ' id="caption_bbc">', $txt['pm_bcc'], ':</span>
					</dt>
					<dd id="bcc_div2">
						<input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
						<div id="bcc_item_list_container"></div>
					</dd>';
    // The subject of the PM.
    echo '
					<dt class="clear_left">
						<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
					</dt>
					<dd id="pm_subject">
						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
					</dd>
				</dl><hr class="clear" />';
    // Showing BBC?
    if ($context['show_bbc']) {
        echo '
				<div id="bbcBox_message"></div>';
    }
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
				<div id="smileyBox_message"></div>';
    }
    // Show BBC buttons, smileys and textbox.
    echo '
				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    // Require an image to be typed to save spamming?
    if ($context['require_verification']) {
        echo '
				<div class="post_verification">
					<strong>', $txt['pm_visual_verification_label'], ':</strong>
					', template_control_verification($context['visual_verification_id'], 'all'), '
				</div>';
    }
    // Send, Preview, spellcheck buttons.
    echo '
				<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>
				<hr class="hrcolor" />
				<span id="shortcuts" class="smalltext">
					', isBrowser('is_firefox') ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
				</span>
				<span id="post_confirm_strip" class="righttext">
					', template_control_richedit_buttons($context['post_box_name']), '
				</span>
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
				<input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
				<input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
				<input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
				<input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
				<br class="clear_right" />
			</div>
		</div>
	</form>';
    // If the admin enabled the pm drafts feature, show a draft selection box
    if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled'])) {
        echo '
			<br />
			<div id="postDraftOptionsHeader" class="title_bar">
				<h4 class="titlebg">
					<img id="postDraftExpand" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/collapse.png" alt="-" /> <strong><a href="#" id="postDraftExpandLink">', $txt['draft_load'], '</a></strong>
				</h4>
			</div>
			<div id="postDraftOptions" class="load_drafts padding">
				<dl class="settings">
					<dt><strong>', $txt['subject'], '</strong></dt>
					<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
        foreach ($context['drafts'] as $draft) {
            echo '
					<dt>', $draft['link'], '</dt>
					<dd>', $draft['poster_time'], '</dd>';
        }
        echo '
				</dl>
			</div>';
    }
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[';
    // The functions used to preview a personal message without loading a new page.
    echo '
			var txt_preview_title = "', $txt['preview_title'], '";
			var txt_preview_fetch = "', $txt['preview_fetch'], '";
			function previewPost()
			{';
    if (isBrowser('is_firefox')) {
        echo '
				// Firefox doesn\'t render <marquee> that have been put it using javascript
				if (document.forms.postmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
				{
					return submitThisOnce(document.forms.postmodify);
				}';
    }
    echo '
				if (window.XMLHttpRequest)
				{
					// Opera didn\'t support setRequestHeader() before 8.01.
					// @todo Remove support for old browsers
					if (\'opera\' in window)
					{
						var test = new XMLHttpRequest();
						if (!(\'setRequestHeader\' in test))
							return submitThisOnce(document.forms.postmodify);
					}
					// @todo Currently not sending poll options and option checkboxes.
					var x = new Array();
					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', \'to\', \'bcc\'];
					var numericFields = [\'recipient_to[]\', \'recipient_bcc[]\'];
					var checkboxFields = [\'outbox\'];

					for (var i = 0, n = textFields.length; i < n; i++)
						if (textFields[i] in document.forms.postmodify)
						{
							// Handle the WYSIWYG editor.
							if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
								x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
							else
								x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
						}
					for (var i = 0, n = numericFields.length; i < n; i++)
						if (numericFields[i] in document.forms.postmodify && \'value\' in document.forms.postmodify[numericFields[i]])
							x[x.length] = numericFields[i] + \'=\' + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
					for (var i = 0, n = checkboxFields.length; i < n; i++)
						if (checkboxFields[i] in document.forms.postmodify && document.forms.postmodify.elements[checkboxFields[i]].checked)
							x[x.length] = checkboxFields[i] + \'=\' + document.forms.postmodify.elements[checkboxFields[i]].value;

					sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=pm;sa=send2;preview;xml\', x.join(\'&\'), onDocSent);

					document.getElementById(\'preview_section\').style.display = \'\';
					setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
					setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);

					return false;
				}
				else
					return submitThisOnce(document.forms.postmodify);
			}
			function onDocSent(XMLDoc)
			{
				if (!XMLDoc)
				{
					document.forms.postmodify.preview.onclick = new function ()
					{
						return true;
					}
					document.forms.postmodify.preview.click();
				}

				// Show the preview section.
				var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
				setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);

				var bodyText = \'\';
				for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
					bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;

				setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
				document.getElementById(\'preview_body\').className = \'post\';

				// Show a list of errors (if any).
				var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
				var errorList = new Array();
				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));

				// Adjust the color of captions if the given data is erroneous.
				var captions = errors.getElementsByTagName(\'caption\');
				for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
					if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
						document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');

				if (errors.getElementsByTagName(\'post_error\').length == 1)
					document.forms.postmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
				else if (document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
				{
					if (\'runtimeStyle\' in document.forms.postmodify.', $context['post_box_name'], ')
						document.forms.postmodify.', $context['post_box_name'], '.style.borderColor = \'\';
					else
						document.forms.postmodify.', $context['post_box_name'], '.style.border = null;
				}
				location.hash = \'#\' + \'preview_section\';
			}';
    // Code for showing and hiding drafts
    if (!empty($context['drafts'])) {
        echo '
			var oSwapDraftOptions = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: true,
				aSwappableContainers: [
					\'postDraftOptions\',
				],
				aSwapImages: [
					{
						sId: \'postDraftExpand\',
						srcExpanded: smf_images_url + \'/collapse.png\',
						altExpanded: \'-\',
						srcCollapsed: smf_images_url + \'/expand.png\',
						altCollapsed: \'+\'
					}
				],
				aSwapLinks: [
					{
						sId: \'postDraftExpandLink\',
						msgExpanded: ', JavaScriptEscape($txt['draft_hide']), ',
						msgCollapsed: ', JavaScriptEscape($txt['draft_load']), '
					}
				]
			});';
    }
    echo '
		// ]]></script>';
    // Show the message you're replying to.
    if ($context['reply']) {
        echo '
	<br />
	<br />
	<div class="cat_bar">
		<h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
	</div>
	<div class="windowbg2">
		<div class="content">
			<div class="clear">
				<span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
				<strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong>
			</div>
			<hr />
			', $context['quoted_message']['body'], '
		</div>
	</div><br class="clear" />';
    }
    echo '
		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?alp21"></script>
		<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
		<script type="text/javascript"><!-- // --><![CDATA[
			var oPersonalMessageSend = new smf_PersonalMessageSend({
				sSelf: \'oPersonalMessageSend\',
				sSessionId: smf_session_id,
				sSessionVar: smf_session_var,
				sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
				sToControlId: \'to_control\',
				aToRecipients: [';
    foreach ($context['recipients']['to'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
    }
    echo '
				],
				aBccRecipients: [';
    foreach ($context['recipients']['bcc'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
    }
    echo '
				],
				sBccControlId: \'bcc_control\',
				sBccDivId: \'bcc_div\',
				sBccDivId2: \'bcc_div2\',
				sBccLinkId: \'bcc_link\',
				sBccLinkContainerId: \'bcc_link_container\',
				bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
				sShowBccLinkTemplate: ', JavaScriptEscape('
					<a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqOverlayDiv(this.href);">(?)</a>'), '
			});
		';
    echo '
		// ]]></script>';
}
/**
 * Show the send a new pm form, including the editor, preview section and load
 * drafts if enabled.
 */
function template_send()
{
    global $context, $scripturl, $modSettings, $settings, $txt;
    // Show which messages were sent successfully and which failed.
    if (!empty($context['send_log'])) {
        echo '
			<div class="forumposts">
				<h3 class="category_header">', $txt['pm_send_report'], '</h3>
				<div class="windowbg">
					<div class="content">';
        if (!empty($context['send_log']['sent'])) {
            foreach ($context['send_log']['sent'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        if (!empty($context['send_log']['failed'])) {
            foreach ($context['send_log']['failed'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        echo '
					</div>
				</div>
			</div>';
    }
    // Show the preview of the personal message.
    echo '
		<div id="preview_section" class="forumposts"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
			<h3 class="category_header">
				<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
			</h3>
			<div class="post" id="preview_body">
				', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
			</div>
		</div>';
    // Main message editing box.
    echo '
	<form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="UTF-8" name="pmFolder" id="pmFolder" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'pmFolder\', [\'subject\', \'message\']);">
		<div class="forumposts">
			<h3 class="category_header hdicon cat_img_write">
				', $txt['new_message'], '
			</h3>';
    echo '
			<div class="windowbg">
				<div class="editor_wrapper">';
    // If there were errors for sending the PM, show them.
    template_show_error('post_error');
    if (!empty($modSettings['drafts_pm_enabled'])) {
        echo '
					<div id="draft_section" class="successbox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
					</div>';
    }
    echo '
					<dl id="post_header">';
    // To and bcc. Include a button to search for members.
    echo '
						<dt>
							<label for="to_control"', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : '', ' id="caption_to">', $txt['pm_to'], ':</label>
						</dt>';
    // Autosuggest will be added by the javascript later on.
    echo '
						<dd id="pm_to" class="clear_right">
							<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
    // A link to add BCC, only visible with javascript enabled.
    echo '
							<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
    // A div that'll contain the items found by the autosuggest.
    echo '
							<div id="to_item_list_container"></div>';
    echo '
						</dd>';
    // This BCC row will be hidden by default if javascript is enabled.
    echo '
						<dt  class="clear_left" id="bcc_div">
							<label for="bcc_control"', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : '', ' id="caption_bbc">', $txt['pm_bcc'], ':</label>
						</dt>
						<dd id="bcc_div2">
							<input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
							<div id="bcc_item_list_container"></div>
						</dd>';
    // The subject of the PM.
    echo '
						<dt class="clear_left">
							<label for="subject"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</label>
						</dt>
						<dd id="pm_subject">
							<input type="text" id="subject" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', ' placeholder="', $txt['subject'], '" required="required" />
						</dd>
					</dl>';
    // Show BBC buttons, smileys and textbox.
    echo '
					', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    // Require an image to be typed to save spamming?
    if ($context['require_verification']) {
        template_verification_controls($context['visual_verification_id'], '
					<div class="post_verification">
						<strong>' . $txt['pm_visual_verification_label'] . ':</strong>
						', '
					</div>');
    }
    // Send, Preview, spellchecker buttons.
    echo '
					<div id="post_confirm_buttons" class="submitbutton">
						', template_control_richedit_buttons($context['post_box_name']), '
					</div>
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
					<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
					<input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
					<input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
					<input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
					<input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />';
    // If the admin enabled the pm drafts feature, show a draft selection box
    if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts_pm_save']) && !empty($context['drafts'])) {
        echo '
			<h3 id="postDraftOptionsHeader" class="category_header">
				<span id="category_toggle">&nbsp;
					<span id="postDraftExpand" class="', empty($context['minmax_preferences']['pmdraft']) ? 'collapse' : 'expand', '" style="display: none;" title="', $txt['hide'], '"></span>
				</span>
				<a href="#" id="postDraftExpandLink">', $txt['draft_load'], '</a>
			</h3>
			<div id="postDraftOptions" class="load_drafts padding"', empty($context['minmax_preferences']['pmdraft']) ? '' : ' style="display: none;"', '>
				<dl class="settings">
					<dt><strong>', $txt['subject'], '</strong></dt>
					<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
        foreach ($context['drafts'] as $draft) {
            echo '
					<dt>', $draft['link'], '</dt>
					<dd>', $draft['poster_time'], '</dd>';
        }
        echo '
				</dl>
			</div>';
    }
    echo '
				</div>
			</div>
		</div>
	</form>';
    // The vars used to preview a personal message without loading a new page.
    echo '
		<script><!-- // --><![CDATA[
			var form_name = "pmFolder",
				preview_area = "pm",
				txt_preview_title = "', $txt['preview_title'], '",
				txt_preview_fetch = "', $txt['preview_fetch'], '";';
    // Code for showing and hiding drafts
    if (!empty($context['drafts'])) {
        echo '
			var oSwapDraftOptions = new elk_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: ', empty($context['minmax_preferences']['pmdraft']) ? 'false' : 'true', ',
				aSwappableContainers: [
					\'postDraftOptions\',
				],
				aSwapClasses: [
					{
						sId: \'postDraftExpand\',
						classExpanded: \'collapse\',
						titleExpanded: ', JavaScriptEscape($txt['hide']), ',
						classCollapsed: \'expand\',
						titleCollapsed: ', JavaScriptEscape($txt['show']), '
					}
				],
				aSwapLinks: [
					{
						sId: \'postDraftExpandLink\',
						msgExpanded: ', JavaScriptEscape($txt['draft_hide']), ',
						msgCollapsed: ', JavaScriptEscape($txt['draft_load']), '
					}
				],
				oThemeOptions: {
					bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
					sOptionName: \'minmax_preferences\',
					sSessionId: elk_session_id,
					sSessionVar: elk_session_var,
					sAdditionalVars: \';minmax_key=pmdraft\'
				},
			});';
    }
    echo '
		// ]]></script>';
    // Show the message you're replying to.
    if ($context['reply']) {
        echo '

	<div class="forumposts">
		<h3 class="category_header">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
		<div class="windowbg2">
			<div class="content">
				<div class="clear">
					<span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
					<strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong>
				</div>
				<hr />
				', $context['quoted_message']['body'], '
			</div>
		</div>
	</div>';
    }
    echo '
		<script><!-- // --><![CDATA[
			var oPersonalMessageSend = new elk_PersonalMessageSend({
				sSelf: \'oPersonalMessageSend\',
				sSessionId: elk_session_id,
				sSessionVar: elk_session_var,
				sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
				sToControlId: \'to_control\',
				aToRecipients: [';
    foreach ($context['recipients']['to'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
    }
    echo '
				],
				aBccRecipients: [';
    foreach ($context['recipients']['bcc'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
    }
    echo '
				],
				sBccControlId: \'bcc_control\',
				sBccDivId: \'bcc_div\',
				sBccDivId2: \'bcc_div2\',
				sBccLinkId: \'bcc_link\',
				sBccLinkContainerId: \'bcc_link_container\',
				bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
				sShowBccLinkTemplate: ', JavaScriptEscape('
					<a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=quickhelp;help=pm_bcc" onclick="return reqOverlayDiv(this.href);"><img class="icon" src="' . $settings['images_url'] . '/helptopics.png" alt="(?)" /></a>'), '
			});
		// ]]></script>';
}
function template_send()
{
    global $context, $settings, $options, $scripturl, $modSettings, $txt;
    // Show which messages were sent successfully and which failed.
    if (!empty($context['send_log'])) {
        echo '
			<div class="cat_bar">
				<h3 class="catbg">', $txt['pm_send_report'], '</h3>
			</div>
			<div class="windowbg">
				<div class="content">';
        if (!empty($context['send_log']['sent'])) {
            foreach ($context['send_log']['sent'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        if (!empty($context['send_log']['failed'])) {
            foreach ($context['send_log']['failed'] as $log_entry) {
                echo '<span class="error">', $log_entry, '</span><br />';
            }
        }
        echo '
				</div>
			</div>
			<br />';
    }
    // Show the preview of the personal message.
    echo '
		<div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
			<div class="cat_bar">
				<h3 class="catbg">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<div class="post" id="preview_body">
						', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
					</div>
				</div>
			</div>
		</div>';
    // Main message editing box.
    echo '
		<div class="cat_bar">
			<h3 class="catbg">
					<img src="', $settings['images_url'], '/icons/im_newmsg.png" class="icon" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '
			</h3>
		</div>';
    echo '
	<form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
		<div>
			<div class="roundframe">
				<br class="clear" />';
    // If there were errors for sending the PM, show them.
    echo '
				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
					<dl>
						<dt>
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
						</dt>
						<dd class="error" id="error_list">
							', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
						</dd>
					</dl>
				</div>';
    if (!empty($modSettings['drafts_pm_enabled'])) {
        echo '
				<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>', sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
				</div>';
    }
    echo '
				<dl id="post_header">';
    // To and bcc. Include a button to search for members.
    echo '
					<dt>
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : '', ' id="caption_to">', $txt['pm_to'], ':</span>
					</dt>';
    // Autosuggest will be added by the JavaScript later on.
    echo '
					<dd id="pm_to" class="clear_right">
						<input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
    // A link to add BCC, only visible with JavaScript enabled.
    echo '
						<span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
    // A div that'll contain the items found by the autosuggest.
    echo '
						<div id="to_item_list_container"></div>';
    echo '
					</dd>';
    // This BCC row will be hidden by default if JavaScript is enabled.
    echo '
					<dt  class="clear_left" id="bcc_div">
						<span', isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : '', ' id="caption_bbc">', $txt['pm_bcc'], ':</span>
					</dt>
					<dd id="bcc_div2">
						<input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
						<div id="bcc_item_list_container"></div>
					</dd>';
    // The subject of the PM.
    echo '
					<dt class="clear_left">
						<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
					</dt>
					<dd id="pm_subject">
						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
					</dd>
				</dl><hr class="clear" />';
    // Showing BBC?
    if ($context['show_bbc']) {
        echo '
				<div id="bbcBox_message"></div>';
    }
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
				<div id="smileyBox_message"></div>';
    }
    // Show BBC buttons, smileys and textbox.
    echo '
				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    // Require an image to be typed to save spamming?
    if ($context['require_verification']) {
        echo '
				<div class="post_verification">
					<strong>', $txt['pm_visual_verification_label'], ':</strong>
					', template_control_verification($context['visual_verification_id'], 'all'), '
				</div>';
    }
    // Send, Preview, spellcheck buttons.
    echo '
				<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>
				<hr class="hrcolor" />
				<span id="post_confirm_strip" class="righttext">
					', template_control_richedit_buttons($context['post_box_name']), '
				</span>
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
				<input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
				<input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
				<input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
				<input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
				<br class="clear_right" />
			</div>
		</div>
	</form>';
    // If the admin enabled the pm drafts feature, show a draft selection box
    if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled'])) {
        echo '
			<br />
			<div id="postDraftOptionsHeader" class="title_bar">
				<h4 class="titlebg">
					<img id="postDraftExpand" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/collapse.png" alt="-" /> <strong><a href="#" id="postDraftExpandLink">', $txt['draft_load'], '</a></strong>
				</h4>
			</div>
			<div id="postDraftOptions" class="load_drafts padding">
				<dl class="settings">
					<dt><strong>', $txt['subject'], '</strong></dt>
					<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
        foreach ($context['drafts'] as $draft) {
            echo '
					<dt>', $draft['link'], '</dt>
					<dd>', $draft['poster_time'], '</dd>';
        }
        echo '
				</dl>
			</div>';
    }
    // The vars used to preview a personal message without loading a new page.
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[
			var post_box_name = "', $context['post_box_name'], '";
			var form_name = "postmodify";
			var preview_area = "pm";
			var txt_preview_title = "', $txt['preview_title'], '";
			var txt_preview_fetch = "', $txt['preview_fetch'], '";';
    // Code for showing and hiding drafts
    if (!empty($context['drafts'])) {
        echo '
			var oSwapDraftOptions = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: true,
				aSwappableContainers: [
					\'postDraftOptions\',
				],
				aSwapImages: [
					{
						sId: \'postDraftExpand\',
						srcExpanded: smf_images_url + \'/collapse.png\',
						altExpanded: \'-\',
						srcCollapsed: smf_images_url + \'/expand.png\',
						altCollapsed: \'+\'
					}
				],
				aSwapLinks: [
					{
						sId: \'postDraftExpandLink\',
						msgExpanded: ', JavaScriptEscape($txt['draft_hide']), ',
						msgCollapsed: ', JavaScriptEscape($txt['draft_load']), '
					}
				]
			});';
    }
    echo '
		// ]]></script>';
    // Show the message you're replying to.
    if ($context['reply']) {
        echo '
	<br />
	<br />
	<div class="cat_bar">
		<h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
	</div>
	<div class="windowbg2">
		<div class="content">
			<div class="clear">
				<span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
				<strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong>
			</div>
			<hr />
			', $context['quoted_message']['body'], '
		</div>
	</div><br class="clear" />';
    }
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[
			var oPersonalMessageSend = new smf_PersonalMessageSend({
				sSelf: \'oPersonalMessageSend\',
				sSessionId: smf_session_id,
				sSessionVar: smf_session_var,
				sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
				sToControlId: \'to_control\',
				aToRecipients: [';
    foreach ($context['recipients']['to'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
    }
    echo '
				],
				aBccRecipients: [';
    foreach ($context['recipients']['bcc'] as $i => $member) {
        echo '
					{
						sItemId: ', JavaScriptEscape($member['id']), ',
						sItemName: ', JavaScriptEscape($member['name']), '
					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
    }
    echo '
				],
				sBccControlId: \'bcc_control\',
				sBccDivId: \'bcc_div\',
				sBccDivId2: \'bcc_div2\',
				sBccLinkId: \'bcc_link\',
				sBccLinkContainerId: \'bcc_link_container\',
				bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
				sShowBccLinkTemplate: ', JavaScriptEscape('
					<a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=quickhelp;help=pm_bcc" onclick="return reqOverlayDiv(this.href);">(?)</a>'), '
			});
		';
    echo '
		// ]]></script>';
}