mirror of
https://gh.wpcy.net/https://github.com/buddypress/buddypress.git
synced 2026-05-31 05:04:29 +08:00
git-svn-id: https://buddypress.svn.wordpress.org/trunk@1032 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
91 lines
No EOL
2.7 KiB
PHP
91 lines
No EOL
2.7 KiB
PHP
<?php
|
|
|
|
function messages_ajax_send_reply() {
|
|
global $bp;
|
|
|
|
check_ajax_referer( 'messages_send_message' );
|
|
|
|
$result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
|
|
|
|
if ( $result['status'] ) { ?>
|
|
<div class="avatar-box">
|
|
<?php if ( function_exists('bp_core_get_avatar') )
|
|
echo bp_core_get_avatar($result['reply']->sender_id, 1);
|
|
?>
|
|
|
|
<h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
|
|
<small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
|
|
</div>
|
|
<?php echo stripslashes( apply_filters( 'bp_message_content', $result['reply']->message ) ) ?>
|
|
<div class="clear"></div>
|
|
<?php
|
|
} else {
|
|
$result['message'] = '<img src="' . $bp->messages->image_base . '/warning.gif" alt="Warning" /> ' . $result['message'];
|
|
echo "-1[[split]]" . $result['message'];
|
|
}
|
|
}
|
|
add_action( 'wp_ajax_messages_send_reply', 'messages_ajax_send_reply' );
|
|
|
|
function messages_ajax_markunread() {
|
|
global $bp;
|
|
|
|
if ( !isset($_POST['thread_ids']) ) {
|
|
echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
|
|
} else {
|
|
$thread_ids = explode( ',', $_POST['thread_ids'] );
|
|
|
|
for ( $i = 0; $i < count($thread_ids); $i++ ) {
|
|
BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
|
|
}
|
|
}
|
|
}
|
|
add_action( 'wp_ajax_messages_markunread', 'messages_ajax_markunread' );
|
|
|
|
function messages_ajax_markread() {
|
|
global $bp;
|
|
|
|
if ( !isset($_POST['thread_ids']) ) {
|
|
echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
|
|
} else {
|
|
$thread_ids = explode( ',', $_POST['thread_ids'] );
|
|
|
|
for ( $i = 0; $i < count($thread_ids); $i++ ) {
|
|
BP_Messages_Thread::mark_as_read($thread_ids[$i]);
|
|
}
|
|
}
|
|
}
|
|
add_action( 'wp_ajax_messages_markread', 'messages_ajax_markread' );
|
|
|
|
function messages_ajax_delete() {
|
|
global $bp;
|
|
|
|
if ( !isset($_POST['thread_ids']) ) {
|
|
echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
|
|
} else {
|
|
$thread_ids = explode( ',', $_POST['thread_ids'] );
|
|
|
|
for ( $i = 0; $i < count($thread_ids); $i++ ) {
|
|
BP_Messages_Thread::delete($thread_ids[$i]);
|
|
}
|
|
|
|
_e('Messages deleted.', 'buddypress');
|
|
}
|
|
}
|
|
add_action( 'wp_ajax_messages_delete', 'messages_ajax_delete' );
|
|
|
|
function messages_ajax_close_notice() {
|
|
global $userdata;
|
|
|
|
if ( !isset($_POST['notice_id']) ) {
|
|
echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
|
|
} else {
|
|
$notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
|
|
|
|
$notice_ids[] = (int) $_POST['notice_id'];
|
|
|
|
update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
|
|
}
|
|
}
|
|
add_action( 'wp_ajax_messages_close_notice', 'messages_ajax_close_notice' );
|
|
|
|
?>
|