Changeset 3300 for trunk/bp-messages.php
- Timestamp:
- 10/24/2010 09:22:29 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-messages.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-messages.php
r2941 r3300 6 6 7 7 function messages_setup_globals() { 8 global $bp , $wpdb;8 global $bp; 9 9 10 10 if ( !defined( 'BP_MESSAGES_SLUG' ) ) … … 14 14 $bp->messages->id = 'messages'; 15 15 16 $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages'; 17 $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients'; 18 $bp->messages->table_name_notices = $wpdb->base_prefix . 'bp_messages_notices'; 16 $bp->messages->slug = BP_MESSAGES_SLUG; 17 $bp->messages->table_name_notices = $bp->table_prefix . 'bp_messages_notices'; 18 $bp->messages->table_name_messages = $bp->table_prefix . 'bp_messages_messages'; 19 $bp->messages->table_name_recipients = $bp->table_prefix . 'bp_messages_recipients'; 19 20 $bp->messages->format_notification_function = 'messages_format_notifications'; 20 $bp->messages->slug = BP_MESSAGES_SLUG;21 21 22 22 /* Register this in the active components array */ … … 45 45 bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) ); 46 46 47 if ( is_s ite_admin() )48 bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_s ite_admin() ) );47 if ( is_super_admin() ) 48 bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) ); 49 49 50 50 if ( $bp->current_component == $bp->messages->slug ) { … … 85 85 messages_remove_callback_values(); 86 86 87 / * Check if the message form has been submitted */87 // Check if the message form has been submitted 88 88 if ( isset( $_POST['send'] ) ) { 89 89 90 / * Check the nonce */90 // Check the nonce 91 91 check_admin_referer( 'messages_send_message' ); 92 92 93 / * Check we have what we need */93 // Check we have what we need 94 94 if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { 95 95 bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' ); 96 96 } else { 97 / * If this is a notice, send it */97 // If this is a notice, send it 98 98 if ( isset( $_POST['send-notice'] ) ) { 99 99 if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) { … … 104 104 } 105 105 } else { 106 / * Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) */106 // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) 107 107 $autocomplete_recipients = explode( ',', $_POST['send-to-input'] ); 108 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] ); 109 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients ); 110 111 /* Send the message */ 108 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] ); 109 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients ); 110 $recipients = apply_filters( 'bp_messages_recipients', $recipients ); 111 112 // Send the message 112 113 if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) { 113 114 bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) ); … … 118 119 } 119 120 } 120 121 121 } 122 122 … … 129 129 global $bp, $notice_id; 130 130 131 if ( !is_s ite_admin() )131 if ( !is_super_admin() ) 132 132 return false; 133 133 … … 166 166 function messages_screen_notification_settings() { 167 167 global $current_user; ?> 168 <table class="notification-settings" id="messages-notification-settings"> 169 <tr> 170 <th class="icon"></th> 171 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th> 172 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 173 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 174 </tr> 175 <tr> 176 <td></td> 177 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td> 178 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_message' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td> 179 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td> 180 </tr> 181 <tr> 182 <td></td> 183 <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td> 184 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_notice' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td> 185 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td> 186 </tr> 187 188 <?php do_action( 'messages_screen_notification_settings' ) ?> 168 <table class="notification-settings zebra" id="messages-notification-settings"> 169 <thead> 170 <tr> 171 <th class="icon"></th> 172 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th> 173 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 174 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 175 </tr> 176 </thead> 177 178 <tbody> 179 <tr> 180 <td></td> 181 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td> 182 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_message', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td> 183 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td> 184 </tr> 185 <tr> 186 <td></td> 187 <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td> 188 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td> 189 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td> 190 </tr> 191 192 <?php do_action( 'messages_screen_notification_settings' ) ?> 193 </tbody> 189 194 </table> 190 195 <?php … … 209 214 $thread_id = $bp->action_variables[0]; 210 215 211 if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_s ite_admin() ) )216 if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_super_admin() ) ) 212 217 bp_core_redirect( $bp->displayed_user->domain . $bp->current_component ); 213 218 … … 328 333 'subject' => false, 329 334 'content' => false, 330 'date_sent' => time()335 'date_sent' => bp_core_current_time() 331 336 ); 332 337 … … 345 350 $message->date_sent = $date_sent; 346 351 347 / * If we have a thread ID, use the existing recipients, otherwise use the recipients passed */352 // If we have a thread ID, use the existing recipients, otherwise use the recipients passed 348 353 if ( $thread_id ) { 349 354 $thread = new BP_Messages_Thread( $thread_id ); 350 355 $message->recipients = $thread->get_recipients(); 351 356 357 // Strip the sender from the recipient list if they exist 358 if ( isset( $message->recipients[$sender_id] ) ) 359 unset( $message->recipients[$sender_id] ); 360 352 361 if ( empty( $message->subject ) ) 353 362 $message->subject = sprintf( __( 'Re: %s', 'buddypress' ), $thread->messages[0]->subject ); 354 363 364 // No thread ID, so make some adjustments 355 365 } else { 356 366 if ( empty( $recipients ) ) … … 406 416 407 417 function messages_send_notice( $subject, $message ) { 408 if ( !is_s ite_admin() || empty( $subject ) || empty( $message ) ) {418 if ( !is_super_admin() || empty( $subject ) || empty( $message ) ) { 409 419 return false; 410 420 } else { … … 413 423 $notice->subject = $subject; 414 424 $notice->message = $message; 415 $notice->date_sent = time();425 $notice->date_sent = bp_core_current_time(); 416 426 $notice->is_active = 1; 417 427 $notice->save(); // send it.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)