Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/22/2015 06:12:16 AM (11 years ago)
Author:
tw2113
Message:

Second pass at Messages Component docs cleanup.

See #6403.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-actions.php

    r10286 r10304  
    2323function bp_messages_action_create_message() {
    2424
    25         // Bail if not posting to the compose message screen
     25        // Bail if not posting to the compose message screen.
    2626        if ( ! bp_is_post_request() || ! bp_is_messages_component() || ! bp_is_current_action( 'compose' ) ) {
    2727                return false;
    2828        }
    2929
    30         // Check the nonce
     30        // Check the nonce.
    3131        check_admin_referer( 'messages_send_message' );
    3232
    33         // Define local variables
     33        // Define local variables.
    3434        $redirect_to = '';
    3535        $feedback    = '';
    3636        $success     = false;
    3737
    38         // Missing subject or content
     38        // Missing subject or content.
    3939        if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
    4040                $success  = false;
     
    4646                }
    4747
    48         // Subject and content present
     48        // Subject and content present.
    4949        } else {
    5050
    51                 // Setup the link to the logged-in user's messages
     51                // Setup the link to the logged-in user's messages.
    5252                $member_messages = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() );
    5353
    54                 // Site-wide notice
     54                // Site-wide notice.
    5555                if ( isset( $_POST['send-notice'] ) ) {
    5656
    57                         // Attempt to save the notice and redirect to notices
     57                        // Attempt to save the notice and redirect to notices.
    5858                        if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) {
    5959                                $success     = true;
     
    6161                                $redirect_to = trailingslashit( $member_messages . 'notices' );
    6262
    63                         // Notice could not be sent
     63                        // Notice could not be sent.
    6464                        } else {
    6565                                $success  = false;
     
    6767                        }
    6868
    69                 // Private conversation
     69                // Private conversation.
    7070                } else {
    7171
    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' ).
    7373                        $autocomplete_recipients = (array) explode( ',', $_POST['send-to-input']     );
    7474                        $typed_recipients        = (array) explode( ' ', $_POST['send_to_usernames'] );
     
    8484                        $recipients = apply_filters( 'bp_messages_recipients', $recipients );
    8585
    86                         // Attempt to send the message
     86                        // Attempt to send the message.
    8787                        $send = messages_new_message( array(
    8888                                'recipients' => $recipients,
     
    9292                        ) );
    9393
    94                         // Send the message and redirect to it
     94                        // Send the message and redirect to it.
    9595                        if ( true === is_int( $send ) ) {
    9696                                $success     = true;
     
    9999                                $redirect_to = trailingslashit( $view . $send );
    100100
    101                         // Message could not be sent
     101                        // Message could not be sent.
    102102                        } else {
    103103                                $success  = false;
     
    107107        }
    108108
    109         // Feedback
     109        // Feedback.
    110110        if ( ! empty( $feedback ) ) {
    111111
    112                 // Determine message type
     112                // Determine message type.
    113113                $type = ( true === $success )
    114114                        ? 'success'
    115115                        : 'error';
    116116
    117                 // Add feedback message
     117                // Add feedback message.
    118118                bp_core_add_message( $feedback, $type );
    119119        }
    120120
    121         // Maybe redirect
     121        // Maybe redirect.
    122122        if ( ! empty( $redirect_to ) ) {
    123123                bp_core_redirect( $redirect_to );
     
    127127
    128128/**
    129  * Handle editing of sitewide notices
     129 * Handle editing of sitewide notices.
    130130 *
    131131 * @since 2.4.0 This function was split from messages_screen_notices(). See #6505.
     
    138138        global $notice_id;
    139139
    140         // Bail if not viewing a single notice URL
     140        // Bail if not viewing a single notice URL.
    141141        if ( ! bp_is_messages_component() || ! bp_is_current_action( 'notices' ) || ! bp_action_variable( 1 ) ) {
    142142                return false;
    143143        }
    144144
    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.
    147147        $notice_id = bp_action_variable( 1 ); // 1|2|3|etc...
    148148
    149         // Bail if notice ID is not numeric
     149        // Bail if notice ID is not numeric.
    150150        if ( ! is_numeric( $notice_id ) ) {
    151151                return;
    152152        }
    153153
    154         // Define local variables
     154        // Define local variables.
    155155        $redirect_to = '';
    156156        $feedback    = '';
    157157        $success     = false;
    158158
    159         // Get the notice from database
     159        // Get the notice from database.
    160160        $notice = new BP_Messages_Notice( $notice_id );
    161161
    162         // Take action
     162        // Take action.
    163163        switch ( $action ) {
    164164
    165                 // Deactivate
     165                // Deactivate.
    166166                case 'deactivate' :
    167167                        $success  = $notice->deactivate();
     
    171171                        break;
    172172
    173                 // Activate
     173                // Activate.
    174174                case 'activate' :
    175175                        $success  = $notice->activate();
     
    179179                        break;
    180180
    181                 // Delete
     181                // Delete.
    182182                case 'delete' :
    183183                        $success  = $notice->delete();
     
    188188        }
    189189
    190         // Feedback
     190        // Feedback.
    191191        if ( ! empty( $feedback ) ) {
    192192
    193                 // Determine message type
     193                // Determine message type.
    194194                $type = ( true === $success )
    195195                        ? 'success'
    196196                        : 'error';
    197197
    198                 // Add feedback message
     198                // Add feedback message.
    199199                bp_core_add_message( $feedback, $type );
    200200        }
    201201
    202         // Redirect
     202        // Redirect.
    203203        $member_notices = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() );
    204204        $redirect_to    = trailingslashit( $member_notices . 'notices' );
     
    213213function messages_action_conversation() {
    214214
    215         // Bail if not viewing a single conversation
     215        // Bail if not viewing a single conversation.
    216216        if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) {
    217217                return false;
    218218        }
    219219
    220         // Get the thread ID from the action variable
     220        // Get the thread ID from the action variable.
    221221        $thread_id = (int) bp_action_variable( 0 );
    222222
     
    225225        }
    226226
    227         // Check if a new reply has been submitted
     227        // Check if a new reply has been submitted.
    228228        if ( isset( $_POST['send'] ) ) {
    229229
    230                 // Check the nonce
     230                // Check the nonce.
    231231                check_admin_referer( 'messages_send_message', 'send_message_nonce' );
    232232
     
    237237                ) );
    238238
    239                 // Send the reply
     239                // Send the reply.
    240240                if ( ! empty( $new_reply ) ) {
    241241                        bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
     
    247247        }
    248248
    249         // Mark message read
     249        // Mark message read.
    250250        messages_mark_thread_read( $thread_id );
    251251
     
    279279                }
    280280
    281                 // Delete message
     281                // Delete message.
    282282                if ( !messages_delete_thread( $thread_id ) ) {
    283283                        bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
Note: See TracChangeset for help on using the changeset viewer.