Changeset 9947 for trunk/src/bp-messages/bp-messages-screens.php
- Timestamp:
- 06/15/2015 11:54:42 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-messages/bp-messages-screens.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-screens.php
r9946 r9947 17 17 /** 18 18 * Load the Messages > Inbox screen. 19 * 20 * @since BuddyPress (1.0.0) 19 21 */ 20 22 function messages_screen_inbox() { 23 21 24 if ( bp_action_variables() ) { 22 25 bp_do_404(); … … 43 46 /** 44 47 * Load the Messages > Sent screen. 48 * 49 * @since BuddyPress (1.0.0) 45 50 */ 46 51 function messages_screen_sentbox() { 52 47 53 if ( bp_action_variables() ) { 48 54 bp_do_404(); … … 69 75 /** 70 76 * Load the Messages > Compose screen. 77 * 78 * @since BuddyPress (1.0.0) 71 79 */ 72 80 function messages_screen_compose() { … … 80 88 messages_remove_callback_values(); 81 89 82 // Check if the message form has been submitted83 if ( isset( $_POST['send'] ) ) {84 85 // Check the nonce86 check_admin_referer( 'messages_send_message' );87 88 // Check we have what we need89 if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {90 bp_core_add_message( __( 'There was an error sending that message. Please try again.', 'buddypress' ), 'error' );91 } else {92 // If this is a notice, send it93 if ( isset( $_POST['send-notice'] ) ) {94 if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) {95 bp_core_add_message( __( 'Notice sent successfully!', 'buddypress' ) );96 bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/' );97 } else {98 bp_core_add_message( __( 'There was an error sending that notice. Please try again.', 'buddypress' ), 'error' );99 }100 } else {101 // Filter recipients into the format we need - array( 'username/userid', 'username/userid' )102 $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );103 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );104 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );105 106 /**107 * Filters the array of recipients to receive the composed message.108 *109 * @since BuddyPress (1.2.10)110 *111 * @param array $recipients Array of recipients to receive message.112 */113 $recipients = apply_filters( 'bp_messages_recipients', $recipients );114 $thread_id = messages_new_message( array(115 'recipients' => $recipients,116 'subject' => $_POST['subject'],117 'content' => $_POST['content']118 ) );119 120 // Send the message121 if ( ! empty( $thread_id ) ) {122 bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );123 bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );124 } else {125 bp_core_add_message( __( 'There was an error sending that message. Please try again.', 'buddypress' ), 'error' );126 }127 }128 }129 }130 131 90 /** 132 91 * Fires right before the loading of the Messages compose screen template file. … … 149 108 * Load an individual conversation screen. 150 109 * 110 * @since BuddyPress (1.0.0) 111 * 151 112 * @return bool|null False on failure. 152 113 */ … … 154 115 155 116 // Bail if not viewing a single message 156 if ( ! bp_is_messages_component() || !bp_is_current_action( 'view' ) ) {117 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) { 157 118 return false; 158 119 } … … 160 121 $thread_id = (int) bp_action_variable( 0 ); 161 122 162 if ( empty( $thread_id ) || ! messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access( $thread_id ) && !bp_current_user_can( 'bp_moderate' ) ) ) {123 if ( empty( $thread_id ) || ! messages_is_valid_thread( $thread_id ) || ( ! messages_check_thread_access( $thread_id ) && ! bp_current_user_can( 'bp_moderate' ) ) ) { 163 124 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ) ); 164 125 } … … 191 152 * Load the Messages > Notices screen. 192 153 * 154 * @since BuddyPress (1.0.0) 155 * 193 156 * @return false|null False on failure. 194 157 */ 195 158 function messages_screen_notices() { 196 global $notice_id;197 198 $notice_id = (int) bp_action_variable( 1 );199 200 if ( !empty( $notice_id ) && is_numeric( $notice_id ) ) {201 $notice = new BP_Messages_Notice( $notice_id );202 203 if ( bp_is_action_variable( 'deactivate', 0 ) ) {204 if ( !$notice->deactivate() ) {205 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );206 } else {207 bp_core_add_message( __('Notice deactivated.', 'buddypress') );208 }209 } elseif ( bp_is_action_variable( 'activate', 0 ) ) {210 if ( !$notice->activate() ) {211 bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );212 } else {213 bp_core_add_message( __('Notice activated.', 'buddypress') );214 }215 } elseif ( bp_is_action_variable( 'delete' ) ) {216 if ( !$notice->delete() ) {217 bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );218 } else {219 bp_core_add_message( __('Notice deleted.', 'buddypress') );220 }221 }222 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices' ) );223 }224 159 225 160 if ( bp_action_variables() ) { … … 247 182 /** 248 183 * Render the markup for the Messages section of Settings > Notifications. 184 * 185 * @since BuddyPress (1.0.0) 249 186 */ 250 187 function messages_screen_notification_settings() { 188 251 189 if ( bp_action_variables() ) { 252 190 bp_do_404();
Note: See TracChangeset
for help on using the changeset viewer.