Changeset 2077 for trunk/bp-messages/deprecated/bp-messages-deprecated.php
- Timestamp:
- 11/02/2009 07:54:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages/deprecated/bp-messages-deprecated.php
r1957 r2077 4 4 * 5 5 * This file contains functions that are deprecated. 6 * You should not under any circumstance use these functions as they are 6 * You should not under any circumstance use these functions as they are 7 7 * either no longer valid, or have been replaced with something much more awesome. 8 8 * … … 13 13 * Of course, things will still work if you use these functions but you will 14 14 * be the laughing stock of the BuddyPress community. We will all point and laugh at 15 * you. You'll also be making things harder for yourself in the long run, 15 * you. You'll also be making things harder for yourself in the long run, 16 16 * and you will miss out on lovely performance and functionality improvements. 17 * 17 * 18 18 * If you've checked you are not using any deprecated functions and finished your little 19 19 * dance, you can add the following line to your wp-config.php file to prevent any of … … 24 24 function messages_deprecated_globals() { 25 25 global $bp; 26 26 27 27 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 28 28 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) … … 31 31 $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images'; 32 32 } 33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 ); 33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 ); 34 34 add_action( 'admin_menu', 'messages_deprecated_globals', 2 ); 35 35 … … 50 50 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 51 51 return $template; 52 52 53 53 /* Enqueue the structure CSS file to give basic positional formatting for components */ 54 wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' ); 54 wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' ); 55 55 } 56 56 add_action( 'bp_styles', 'messages_add_structure_css' ); … … 62 62 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 63 63 return false; 64 64 65 65 check_ajax_referer( 'messages_send_message' ); 66 67 $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 66 67 $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 68 68 69 69 if ( $result['status'] ) { ?> 70 70 <div class="avatar-box"> 71 71 <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?> 72 72 73 73 <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3> 74 74 <small><?php echo bp_format_time($result['reply']->date_sent) ?></small> … … 90 90 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 91 91 return false; 92 92 93 93 if ( !isset($_POST['thread_ids']) ) { 94 94 echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress'); 95 95 } else { 96 96 $thread_ids = explode( ',', $_POST['thread_ids'] ); 97 97 98 98 for ( $i = 0; $i < count($thread_ids); $i++ ) { 99 99 BP_Messages_Thread::mark_as_unread($thread_ids[$i]); … … 108 108 /* If we are using a BuddyPress 1.1+ theme ignore this. */ 109 109 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 110 return false; 111 110 return false; 111 112 112 if ( !isset($_POST['thread_ids']) ) { 113 113 echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress'); … … 128 128 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 129 129 return false; 130 130 131 131 if ( !isset($_POST['thread_ids']) ) { 132 132 echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' ); … … 137 137 BP_Messages_Thread::delete($thread_ids[$i]); 138 138 } 139 139 140 140 _e('Messages deleted.', 'buddypress'); 141 141 } … … 149 149 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 150 150 return false; 151 151 152 152 if ( !isset($_POST['notice_id']) ) { 153 153 echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress'); 154 154 } else { 155 155 $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' ); 156 156 157 157 $notice_ids[] = (int) $_POST['notice_id']; 158 158 159 159 update_usermeta( $userdata->ID, 'closed_notices', $notice_ids ); 160 160 } … … 168 168 if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) 169 169 return false; 170 170 171 171 $friends = false; 172 172 … … 183 183 echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ') 184 184 '; 185 } 185 } 186 186 } 187 187 } … … 193 193 global $message, $type; 194 194 global $bp, $current_user; 195 195 196 196 messages_add_callback_values( $recipients, $subject, $content ); 197 197 198 198 if ( isset( $_POST['send-notice'] ) ) { 199 199 if ( messages_send_notice( $subject, $content, $from_template ) ) { 200 200 bp_core_add_message( __('Notice posted successfully.', 'buddypress') ); 201 201 } else { 202 bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' ); 202 bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' ); 203 203 } 204 204 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' ); 205 205 return true; 206 206 } 207 207 208 208 $recipients = explode( ' ', $recipients ); 209 209 210 210 // If there are no recipients 211 211 if ( count( $recipients ) < 1 ) { 212 if ( !$from_ajax ) { 212 if ( !$from_ajax ) { 213 213 bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' ); 214 214 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); … … 216 216 return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress')); 217 217 } 218 218 219 219 // If there is only 1 recipient and it is the logged in user. 220 220 } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) { 221 221 bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' ); 222 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 223 222 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 223 224 224 // If the subject or content boxes are empty. 225 225 } else if ( empty( $subject ) || empty( $content ) ) { … … 230 230 return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress')); 231 231 } 232 232 233 233 // Passed validation continue. 234 234 } else { … … 237 237 if ( $key = array_search( $current_user->user_login, $recipients ) ) 238 238 unset( $recipients[$key] ); 239 239 240 240 $pmessage = new BP_Messages_Message; 241 241 … … 245 245 $pmessage->thread_id = $thread_id; 246 246 $pmessage->date_sent = time(); 247 247 248 248 if ( $is_reply ) { 249 249 $thread = new BP_Messages_Thread($thread_id); … … 257 257 $message = __('Message could not be sent, please try again.', 'buddypress'); 258 258 $type = 'error'; 259 259 260 260 if ( $from_ajax ) { 261 261 return array('status' => 0, 'message' => $message); … … 263 263 bp_core_add_message( $message, $type ); 264 264 bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' ); 265 } 265 } 266 266 } else { 267 267 $message = __('Message sent successfully!', 'buddypress'); 268 268 $type = 'success'; 269 269 270 270 // Send screen notifications to the recipients 271 271 for ( $i = 0; $i < count($pmessage->recipients); $i++ ) { 272 272 if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) { 273 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 273 bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' ); 274 274 } 275 275 } 276 276 277 277 // Send email notifications to the recipients 278 278 require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' ); … … 280 280 281 281 do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) ); 282 282 283 283 if ( $from_ajax ) { 284 284 return array('status' => 1, 'message' => $message, 'reply' => $pmessage); … … 291 291 $message = __('Message could not be sent, please try again.', 'buddypress'); 292 292 $type = 'error'; 293 293 294 294 if ( $from_ajax ) { 295 295 return array('status' => 0, 'message' => $message);
Note: See TracChangeset
for help on using the changeset viewer.