コード例 #1
0
function messages_view_thread($thread_id)
{
    global $bp;
    $thread = new BP_Messages_Thread($thread_id, true);
    if (!$thread->has_access) {
        unset($_GET['mode']);
        ?>
		<div id="message" class="error">
			<p><?php 
        _e('There was an error when viewing that message', 'buddypress');
        ?>
</p>
		</div>
	<?php 
    } else {
        if ($thread->messages) {
            ?>
			<?php 
            $thread->mark_read();
            ?>
				
			<div class="wrap">
				<h2 id="message-subject"><?php 
            echo $thread->subject;
            ?>
</h2>
				<table class="form-table">
					<tbody>
						<tr>
							<td>
								<img src="<?php 
            echo $bp->messages->image_base;
            ?>
/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
								<?php 
            _e('Sent between ', 'buddypress');
            ?>
 <?php 
            echo BP_Messages_Thread::get_recipient_links($thread->recipients);
            ?>
 
								<?php 
            _e('and', 'buddypress');
            ?>
 <?php 
            echo bp_core_get_userlink($bp->loggedin_user->id);
            ?>
. 
							</td>
						</tr>
					</tbody>
				</table>
				
		<?php 
            $counter = 0;
            foreach ($thread->messages as $message) {
                $alt = $counter % 2 == 1 ? ' alt' : '';
                ?>
					<a name="<?php 
                echo 'm-' . $message->id;
                ?>
"></a>
					<div class="message-box<?php 
                echo $alt;
                ?>
">
						<div class="avatar-box">
							<?php 
                echo apply_filters('bp_get_message_sender_avatar', bp_core_get_avatar($message->sender_id, 1));
                ?>
							<h3><?php 
                echo apply_filters('bp_get_message_sender_id', bp_core_get_userlink($message->sender_id));
                ?>
</h3>
							<small><?php 
                echo apply_filters('bp_get_message_date_sent', bp_format_time(strtotime($message->date_sent)));
                ?>
</small>
						</div>
						
						<?php 
                do_action('messages_custom_fields_output_before');
                ?>
						
						<?php 
                echo apply_filters('bp_get_message_content', stripslashes($message->message));
                ?>
						
						<?php 
                do_action('messages_custom_fields_output_after');
                ?>
		
						<div class="clear"></div>
					</div>
				<?php 
                $counter++;
            }
            ?>
				<form id="send-reply" action="<?php 
            bp_messages_form_action();
            ?>
" method="post">
					<div class="message-box">
							<div id="messagediv">
								<div class="avatar-box">
									<?php 
            if (function_exists('bp_core_get_avatar')) {
                echo bp_core_get_avatar($bp->loggedin_user->id, 1);
            }
            ?>
					
									<h3><?php 
            _e("Reply: ", 'buddypress');
            ?>
</h3>
								</div>
								<label for="reply"></label>
								<div>
									<textarea name="content" id="message_content" rows="15" cols="40"><?php 
            echo htmlspecialchars(wp_filter_kses($content));
            ?>
</textarea>
								</div>
							</div>
							<p class="submit">
								<input type="submit" name="send" value="<?php 
            _e('Send Reply', 'buddypress');
            ?>
 &rarr;" id="send_reply_button"/>
							</p>
							<input type="hidden" id="thread_id" name="thread_id" value="<?php 
            echo attribute_escape($thread->thread_id);
            ?>
" />
							<input type="hidden" name="subject" id="subject" value="<?php 
            _e('Re: ', 'buddypress');
            echo str_replace('Re: ', '', $thread->last_message_subject);
            ?>
" />
					</div>
					
					<?php 
            wp_nonce_field('messages_send_message', '_wpnonce_send_message');
            ?>
				</form>
			</div>
			<?php 
        }
    }
}