Changeset 10304 for trunk/src/bp-messages/bp-messages-actions.php
- Timestamp:
- 10/22/2015 06:12:16 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-messages/bp-messages-actions.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-actions.php
r10286 r10304 23 23 function bp_messages_action_create_message() { 24 24 25 // Bail if not posting to the compose message screen 25 // Bail if not posting to the compose message screen. 26 26 if ( ! bp_is_post_request() || ! bp_is_messages_component() || ! bp_is_current_action( 'compose' ) ) { 27 27 return false; 28 28 } 29 29 30 // Check the nonce 30 // Check the nonce. 31 31 check_admin_referer( 'messages_send_message' ); 32 32 33 // Define local variables 33 // Define local variables. 34 34 $redirect_to = ''; 35 35 $feedback = ''; 36 36 $success = false; 37 37 38 // Missing subject or content 38 // Missing subject or content. 39 39 if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) { 40 40 $success = false; … … 46 46 } 47 47 48 // Subject and content present 48 // Subject and content present. 49 49 } else { 50 50 51 // Setup the link to the logged-in user's messages 51 // Setup the link to the logged-in user's messages. 52 52 $member_messages = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); 53 53 54 // Site-wide notice 54 // Site-wide notice. 55 55 if ( isset( $_POST['send-notice'] ) ) { 56 56 57 // Attempt to save the notice and redirect to notices 57 // Attempt to save the notice and redirect to notices. 58 58 if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) { 59 59 $success = true; … … 61 61 $redirect_to = trailingslashit( $member_messages . 'notices' ); 62 62 63 // Notice could not be sent 63 // Notice could not be sent. 64 64 } else { 65 65 $success = false; … … 67 67 } 68 68 69 // Private conversation 69 // Private conversation. 70 70 } else { 71 71 72 // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) 72 // Filter recipients into the format we need - array( 'username/userid', 'username/userid' ). 73 73 $autocomplete_recipients = (array) explode( ',', $_POST['send-to-input'] ); 74 74 $typed_recipients = (array) explode( ' ', $_POST['send_to_usernames'] ); … … 84 84 $recipients = apply_filters( 'bp_messages_recipients', $recipients ); 85 85 86 // Attempt to send the message 86 // Attempt to send the message. 87 87 $send = messages_new_message( array( 88 88 'recipients' => $recipients, … … 92 92 ) ); 93 93 94 // Send the message and redirect to it 94 // Send the message and redirect to it. 95 95 if ( true === is_int( $send ) ) { 96 96 $success = true; … … 99 99 $redirect_to = trailingslashit( $view . $send ); 100 100 101 // Message could not be sent 101 // Message could not be sent. 102 102 } else { 103 103 $success = false; … … 107 107 } 108 108 109 // Feedback 109 // Feedback. 110 110 if ( ! empty( $feedback ) ) { 111 111 112 // Determine message type 112 // Determine message type. 113 113 $type = ( true === $success ) 114 114 ? 'success' 115 115 : 'error'; 116 116 117 // Add feedback message 117 // Add feedback message. 118 118 bp_core_add_message( $feedback, $type ); 119 119 } 120 120 121 // Maybe redirect 121 // Maybe redirect. 122 122 if ( ! empty( $redirect_to ) ) { 123 123 bp_core_redirect( $redirect_to ); … … 127 127 128 128 /** 129 * Handle editing of sitewide notices 129 * Handle editing of sitewide notices. 130 130 * 131 131 * @since 2.4.0 This function was split from messages_screen_notices(). See #6505. … … 138 138 global $notice_id; 139 139 140 // Bail if not viewing a single notice URL 140 // Bail if not viewing a single notice URL. 141 141 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'notices' ) || ! bp_action_variable( 1 ) ) { 142 142 return false; 143 143 } 144 144 145 // Get action variables 146 $action = bp_action_variable( 0 ); // deactivate|activate|delete 145 // Get action variables. 146 $action = bp_action_variable( 0 ); // deactivate|activate|delete. 147 147 $notice_id = bp_action_variable( 1 ); // 1|2|3|etc... 148 148 149 // Bail if notice ID is not numeric 149 // Bail if notice ID is not numeric. 150 150 if ( ! is_numeric( $notice_id ) ) { 151 151 return; 152 152 } 153 153 154 // Define local variables 154 // Define local variables. 155 155 $redirect_to = ''; 156 156 $feedback = ''; 157 157 $success = false; 158 158 159 // Get the notice from database 159 // Get the notice from database. 160 160 $notice = new BP_Messages_Notice( $notice_id ); 161 161 162 // Take action 162 // Take action. 163 163 switch ( $action ) { 164 164 165 // Deactivate 165 // Deactivate. 166 166 case 'deactivate' : 167 167 $success = $notice->deactivate(); … … 171 171 break; 172 172 173 // Activate 173 // Activate. 174 174 case 'activate' : 175 175 $success = $notice->activate(); … … 179 179 break; 180 180 181 // Delete 181 // Delete. 182 182 case 'delete' : 183 183 $success = $notice->delete(); … … 188 188 } 189 189 190 // Feedback 190 // Feedback. 191 191 if ( ! empty( $feedback ) ) { 192 192 193 // Determine message type 193 // Determine message type. 194 194 $type = ( true === $success ) 195 195 ? 'success' 196 196 : 'error'; 197 197 198 // Add feedback message 198 // Add feedback message. 199 199 bp_core_add_message( $feedback, $type ); 200 200 } 201 201 202 // Redirect 202 // Redirect. 203 203 $member_notices = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ); 204 204 $redirect_to = trailingslashit( $member_notices . 'notices' ); … … 213 213 function messages_action_conversation() { 214 214 215 // Bail if not viewing a single conversation 215 // Bail if not viewing a single conversation. 216 216 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) { 217 217 return false; 218 218 } 219 219 220 // Get the thread ID from the action variable 220 // Get the thread ID from the action variable. 221 221 $thread_id = (int) bp_action_variable( 0 ); 222 222 … … 225 225 } 226 226 227 // Check if a new reply has been submitted 227 // Check if a new reply has been submitted. 228 228 if ( isset( $_POST['send'] ) ) { 229 229 230 // Check the nonce 230 // Check the nonce. 231 231 check_admin_referer( 'messages_send_message', 'send_message_nonce' ); 232 232 … … 237 237 ) ); 238 238 239 // Send the reply 239 // Send the reply. 240 240 if ( ! empty( $new_reply ) ) { 241 241 bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) ); … … 247 247 } 248 248 249 // Mark message read 249 // Mark message read. 250 250 messages_mark_thread_read( $thread_id ); 251 251 … … 279 279 } 280 280 281 // Delete message 281 // Delete message. 282 282 if ( !messages_delete_thread( $thread_id ) ) { 283 283 bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
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)