Ticket #6005: no_js_bulk_delete_messages.6.diff
File no_js_bulk_delete_messages.6.diff, 18.9 KB (added by , 10 years ago) |
---|
-
src/bp-messages/bp-messages-actions.php
92 92 add_action( 'bp_actions', 'messages_action_delete_message' ); 93 93 94 94 /** 95 * Handle marking single message thread as read. 96 * 97 * @since BuddyPress (2.2) 98 * 99 * @return bool 100 */ 101 function bp_messages_action_mark_read() { 102 103 if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'read', 0 ) ) { 104 return false; 105 } 106 107 // Get the action 108 $action = !empty( $_GET['action'] ) ? $_GET['action'] : ''; 109 $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 110 $id = !empty( $_GET['message_id'] ) ? $_GET['message_id'] : ''; 111 112 // Bail if no action or no ID 113 if ( ( 'read' !== $action ) || empty( $id ) || empty( $nonce ) ) { 114 return false; 115 } 116 117 //check nonce 118 if ( ! bp_verify_nonce_request( 'bp_message_thread_mark_read_' . $id ) ) { 119 return false; 120 } 121 122 // Check access to the message 123 if ( messages_check_thread_access( $id ) ) { 124 messages_mark_thread_read( $id ); 125 bp_core_add_message( __( 'Message marked read.', 'buddypress' ) ); 126 } else { 127 bp_core_add_message( __( 'There was a problem marking that message.', 'buddypress' ), 'error' ); 128 } 129 130 // Redirect 131 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ); 132 } 133 add_action( 'bp_actions', 'bp_messages_action_mark_read' ); 134 135 /** 136 * Handle marking single message thread as unread. 137 * 138 * @since BuddyPress (2.2) 139 * 140 * @return bool 141 */ 142 function bp_messages_action_mark_unread() { 143 144 if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'unread', 0 ) ) { 145 return false; 146 } 147 148 // Get the action 149 $action = !empty( $_GET['action'] ) ? $_GET['action'] : ''; 150 $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 151 $id = !empty( $_GET['message_id'] ) ? $_GET['message_id'] : ''; 152 153 // Bail if no action or no ID 154 if ( ( 'unread' !== $action ) || empty( $id ) || empty( $nonce ) ) { 155 return false; 156 } 157 158 //check nonce 159 if ( ! bp_verify_nonce_request( 'bp_message_thread_mark_unread_' . $id ) ) { 160 return false; 161 } 162 163 // Check access to the message 164 if ( messages_check_thread_access( $id ) ) { 165 messages_mark_thread_unread( $id ); 166 bp_core_add_message( __( 'Message marked unread.', 'buddypress' ) ); 167 } else { 168 bp_core_add_message( __( 'There was a problem marking that message.', 'buddypress' ), 'error' ); 169 } 170 171 // Redirect 172 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ); 173 } 174 add_action( 'bp_actions', 'bp_messages_action_mark_unread' ); 175 176 /** 177 * Handles bulk management (mark as read/unread, delete) of message threads. 178 * 179 * @since BuddyPress (2.2) 180 * 181 * @return bool 182 */ 183 function bp_messages_action_bulk_manage() { 184 185 if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'bulk-manage', 0 ) ) { 186 return false; 187 } 188 189 // Get the action 190 $action = !empty( $_POST['messages_bulk_action'] ) ? $_POST['messages_bulk_action'] : ''; 191 $nonce = !empty( $_POST['messages_bulk_nonce'] ) ? $_POST['messages_bulk_nonce'] : ''; 192 $messages = !empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : ''; 193 194 // Bail if no action or no IDs. 195 if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $messages ) || empty( $nonce ) ) { 196 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' ); 197 return false; 198 } 199 200 $messages = wp_parse_id_list( $messages ); 201 202 // Check the nonce. 203 if ( ! wp_verify_nonce( $nonce, 'messages_bulk_nonce' ) ) { 204 return false; 205 } 206 207 //make sure the user has access to all notifications before managing them 208 foreach ( $messages as $message ) { 209 if ( ! messages_check_thread_access( $message ) ) { 210 bp_core_add_message( __( 'There was a problem managing your messages.', 'buddypress' ), 'error' ); 211 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' ); 212 return false; 213 } 214 } 215 216 // Delete, mark as read or unread depending on the user 'action'. 217 switch ( $action ) { 218 case 'delete' : 219 foreach ( $messages as $message ) { 220 messages_delete_thread( $message ); 221 } 222 bp_core_add_message( __( 'Messages deleted.', 'buddypress' ) ); 223 break; 224 225 case 'read' : 226 foreach ( $messages as $message ) { 227 messages_mark_thread_read( $message ); 228 } 229 bp_core_add_message( __( 'Messages marked as read', 'buddypress' ) ); 230 break; 231 232 case 'unread' : 233 foreach ( $messages as $message ) { 234 messages_mark_thread_unread( $message ); 235 } 236 bp_core_add_message( __( 'Messages marked as unread.', 'buddypress' ) ); 237 break; 238 } 239 240 // Redirect 241 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' ); 242 } 243 add_action( 'bp_actions', 'bp_messages_action_bulk_manage' ); 244 245 /** 95 246 * Process a request to bulk delete messages. 96 247 * 97 248 * @return bool False on failure. -
src/bp-messages/bp-messages-template.php
561 561 } 562 562 563 563 /** 564 * Output the URL used for marking a single message thread as unread 565 * 566 * Since this function directly outputs a URL, it is escaped. 567 * 568 * @since BuddyPress (2.2) 569 * 570 */ 571 function bp_the_message_thread_mark_unread_url() { 572 echo esc_url( bp_get_the_message_thread_mark_unread_url() ); 573 } 574 /** 575 * Return the URL used for marking a single message thread as unread 576 * 577 * @since BuddyPress (2.2) 578 */ 579 function bp_get_the_message_thread_mark_unread_url() { 580 581 // Get the message ID 582 $id = bp_get_message_thread_id(); 583 584 // Get the args to add to the URL 585 $args = array( 586 'action' => 'unread', 587 'message_id' => $id 588 ); 589 590 // Base unread-URL 591 $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/unread' ); 592 593 // Add the args to the URL 594 $url = add_query_arg( $args, $url ); 595 596 // Add the nonce 597 $url = wp_nonce_url( $url, 'bp_message_thread_mark_unread_' . $id ); 598 599 // Filter and return 600 return apply_filters( 'bp_get_the_message_thread_mark_unread_url', $url ); 601 } 602 603 /** 604 * Output the URL used for marking a single message thread as read 605 * 606 * Since this function directly outputs a URL, it is escaped. 607 * 608 * @since BuddyPress (2.2) 609 * 610 */ 611 function bp_the_message_thread_mark_read_url() { 612 echo esc_url( bp_get_the_message_thread_mark_read_url() ); 613 } 614 /** 615 * Return the URL used for marking a single message thread as read 616 * 617 * @since BuddyPress (2.2) 618 */ 619 function bp_get_the_message_thread_mark_read_url() { 620 621 // Get the message ID 622 $id = bp_get_message_thread_id(); 623 624 // Get the args to add to the URL 625 $args = array( 626 'action' => 'read', 627 'message_id' => $id 628 ); 629 630 // Base read-URL 631 $url = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/read' ); 632 633 // Add the args to the URL 634 $url = add_query_arg( $args, $url ); 635 636 // Add the nonce 637 $url = wp_nonce_url( $url, 'bp_message_thread_mark_read_' . $id ); 638 639 // Filter and return 640 return apply_filters( 'bp_get_the_message_thread_mark_read_url', $url ); 641 } 642 643 /** 564 644 * Output the CSS class for the current thread. 565 645 */ 566 646 function bp_message_css_class() { … … 620 700 } 621 701 622 702 /** 703 * Output the current thread's total count. 704 * @since Buddypress (2.2) 705 */ 706 function bp_message_thread_total_count( $thread_id ) { 707 echo bp_get_message_thread_total_count( $thread_id ); 708 } 709 /** 710 * Get the current thread's total count. 711 * 712 * @return int 713 */ 714 function bp_get_message_thread_total_count( $thread_id ) { 715 $thread_template = new BP_Messages_Thread_Template( $thread_id, 'ASC' ); 716 717 $count = ! empty( $thread_template->message_count ) 718 ? (int) $thread_template->message_count 719 : false; 720 721 return apply_filters( 'bp_get_message_thread_total_count', $count ); 722 } 723 724 /** 725 * Output the current thread's total and unread count. 726 * @since Buddypress (2.2) 727 */ 728 function bp_message_thread_total_and_unread_count( $thread_id ) { 729 echo bp_get_message_thread_total_and_unread_count( $thread_id ); 730 } 731 /** 732 * Get the current thread's total and unread count. 733 * 734 * @return html 735 */ 736 function bp_get_message_thread_total_and_unread_count( $thread_id ) { 737 $total = bp_get_message_thread_total_count( $thread_id ) ? bp_get_message_thread_total_count( $thread_id ) : 0; 738 $unread = bp_get_message_thread_unread_count() ? bp_get_message_thread_unread_count() : 0; 739 return sprintf( '<span class="thread-count">(%d)</span> <span class="bp-screen-reader-text">%s %d %s</span>', 740 $total, _n( 'message', 'messages', $total, 'buddypress' ), $unread, __( 'unread' , 'buddypress' ) 741 ); 742 } 743 744 /** 623 745 * Output the unformatted date of the last post in the current thread. 624 746 */ 625 747 function bp_message_thread_last_post_date_raw() { … … 856 978 function bp_messages_options() { 857 979 ?> 858 980 859 <?php _e( 'Select:', 'buddypress' ) ?> 981 <label for="message-type-select" class="bp-screen-reader-text"> 982 <?php _e( 'Select:', 'buddypress' ) ?> 983 </label> 860 984 861 985 <select name="message-type-select" id="message-type-select"> 862 <option value="">< /option>986 <option value=""><?php _e( 'Select', 'buddypress' ); ?></option> 863 987 <option value="read"><?php _ex('Read', 'Message dropdown filter', 'buddypress') ?></option> 864 988 <option value="unread"><?php _ex('Unread', 'Message dropdown filter', 'buddypress') ?></option> 865 989 <option value="all"><?php _ex('All', 'Message dropdown filter', 'buddypress') ?></option> … … 878 1002 } 879 1003 880 1004 /** 1005 * Output the dropdown for bulk management of messages. 1006 * 1007 * @since BuddyPress (2.2.0) 1008 */ 1009 function bp_messages_bulk_management_dropdown() { 1010 ?> 1011 <label class="bp-screen-reader-text" for="messages-select"><?php _e( 'Select Bulk Action', 'buddypress' ); ?></label> 1012 <select name="messages_bulk_action" id="messages-select"> 1013 <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option> 1014 <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option> 1015 <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option> 1016 <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option> 1017 </select> 1018 <input type="submit" id="messages-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>"> 1019 <?php 1020 } 1021 1022 /** 881 1023 * Return whether or not the notice is currently active. 882 1024 * 883 1025 * @since BuddyPress (1.6.0) -
src/bp-templates/bp-legacy/buddypress/members/single/messages/messages-loop.php
16 16 17 17 <?php do_action( 'bp_after_member_messages_pagination' ); ?> 18 18 19 <?php do_action( 'bp_before_member_messages_threads' 19 <?php do_action( 'bp_before_member_messages_threads' ); ?> 20 20 21 <table id="message-threads" class="messages-notices"> 22 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 21 <form action="<?php echo bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ?>/bulk-manage/" method="post" id="messages-bulk-management"> 23 22 24 <tr id="m-<?php bp_message_thread_id(); ?>" class="<?php bp_message_css_class(); ?><?php if ( bp_message_thread_has_unread() ) : ?> unread<?php else: ?> read<?php endif; ?>"> 25 <td width="1%" class="thread-count"> 26 <span class="unread-count"><?php bp_message_thread_unread_count(); ?></span> 27 </td> 28 <td width="1%" class="thread-avatar"><?php bp_message_thread_avatar(); ?></td> 23 <table id="message-threads" class="messages-notices"> 29 24 30 <?php if ( 'sentbox' != bp_current_action() ) : ?> 31 <td width="30%" class="thread-from"> 32 <?php _e( 'From:', 'buddypress' ); ?> <?php bp_message_thread_from(); ?><br /> 33 <span class="activity"><?php bp_message_thread_last_post_date(); ?></span> 34 </td> 35 <?php else: ?> 36 <td width="30%" class="thread-from"> 37 <?php _e( 'To:', 'buddypress' ); ?> <?php bp_message_thread_to(); ?><br /> 38 <span class="activity"><?php bp_message_thread_last_post_date(); ?></span> 39 </td> 40 <?php endif; ?> 25 <thead> 26 <tr> 27 <th scope="col"><label class="bp-screen-reader-text" for="select-all-messages"><?php _e( 'Select all', 'buddypress' ); ?></label><input id="select-all-messages" type="checkbox"></th> 28 <th scope="col"><?php _e( 'From', 'buddypress' ); ?></th> 29 <th scope="col"><?php _e( 'Subject', 'buddypress' ); ?></th> 30 <th scope="col"><?php _e( 'Actions', 'buddypress' ); ?></th> 31 </tr> 32 </thead> 41 33 42 <td width="50%" class="thread-info"> 43 <p><a href="<?php bp_message_thread_view_link(); ?>" title="<?php esc_attr_e( "View Message", "buddypress" ); ?>"><?php bp_message_thread_subject(); ?></a></p> 44 <p class="thread-excerpt"><?php bp_message_thread_excerpt(); ?></p> 45 </td> 34 <tbody> 46 35 47 <?php do_action( 'bp_messages_inbox_list_item'); ?>36 <?php while ( bp_message_threads() ) : bp_message_thread(); ?> 48 37 49 <td width="13%" class="thread-options"> 50 <input type="checkbox" name="message_ids[]" value="<?php bp_message_thread_id(); ?>" /> 51 <a class="button confirm" href="<?php bp_message_thread_delete_link(); ?>" title="<?php esc_attr_e( "Delete Conversation", "buddypress" ); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a> 52 </td> 53 </tr> 38 <tr id="m-<?php bp_message_thread_id(); ?>" class="<?php bp_message_css_class(); ?><?php if ( bp_message_thread_has_unread() ) : ?> unread<?php else: ?> read<?php endif; ?>"> 39 <td> 40 <input type="checkbox" name="message_ids[]" class="message-check" value="<?php bp_message_thread_id(); ?>" /> 41 </td> 54 42 55 <?php endwhile; ?> 56 </table><!-- #message-threads --> 43 <?php if ( 'sentbox' != bp_current_action() ) : ?> 44 <td class="thread-from"> 45 <?php bp_message_thread_avatar( array( 'width' => 25, 'height' => 25 ) ); ?> 46 <span class="from"><?php _e( 'From:', 'buddypress' ); ?></span> <?php bp_message_thread_from(); ?> 47 <?php bp_message_thread_total_and_unread_count( bp_get_message_thread_id() ); ?> 48 <span class="activity"><?php bp_message_thread_last_post_date(); ?></span> 49 </td> 50 <?php else: ?> 51 <td class="thread-from"> 52 <?php bp_message_thread_avatar( array( 'width' => 25, 'height' => 25 ) ); ?> 53 <span class="to"><?php _e( 'To:', 'buddypress' ); ?></span> <?php bp_message_thread_to(); ?> 54 <?php bp_message_thread_total_and_unread_count( bp_get_message_thread_id() ); ?> 55 <span class="activity"><?php bp_message_thread_last_post_date(); ?></span> 56 </td> 57 <?php endif; ?> 57 58 58 <div class="messages-options-nav"> 59 <?php bp_messages_options(); ?> 60 </div><!-- .messages-options-nav --> 59 <td class="thread-info"> 60 <p><a href="<?php bp_message_thread_view_link(); ?>" title="<?php esc_attr_e( "View Message", "buddypress" ); ?>"><?php bp_message_thread_subject(); ?></a></p> 61 <p class="thread-excerpt"><?php bp_message_thread_excerpt(); ?></p> 62 </td> 61 63 64 <?php do_action( 'bp_messages_inbox_list_item' ); ?> 65 66 <td class="thread-options"> 67 <?php if ( bp_message_thread_has_unread() ) : ?> 68 <a class="read" href="<?php bp_the_message_thread_mark_read_url();?>"><?php _e( 'Read', 'buddypress' ); ?></a> 69 <?php else : ?> 70 <a class="unread" href="<?php bp_the_message_thread_mark_unread_url();?>"><?php _e( 'Unread', 'buddypress' ); ?></a> 71 <?php endif; ?> 72 | 73 <a class="delete" href="<?php bp_message_thread_delete_link(); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a> 74 </td> 75 </tr> 76 77 <?php endwhile; ?> 78 79 </tbody> 80 81 </table><!-- #message-threads --> 82 83 <div class="messages-options-nav"> 84 <?php bp_messages_bulk_management_dropdown(); ?> 85 </div><!-- .messages-options-nav --> 86 87 <?php wp_nonce_field( 'messages_bulk_nonce', 'messages_bulk_nonce' ); ?> 88 </form> 89 62 90 <?php do_action( 'bp_after_member_messages_threads' ); ?> 63 91 64 92 <?php do_action( 'bp_after_member_messages_options' ); ?> -
src/bp-templates/bp-legacy/css/buddypress.css
737 737 body.no-js #buddypress #message-type-select, 738 738 body.no-js #buddypress #delete_inbox_messages, 739 739 body.no-js #buddypress #delete_sentbox_messages, 740 body.no-js #buddypress # notifications-bulk-management #select-all-notifications {740 body.no-js #buddypress #messages-bulk-management #select-all-messages { 741 741 display: none; 742 742 } 743 743 #buddypress .standard-form input:focus, … … 973 973 } 974 974 #buddypress table#message-threads { 975 975 clear: both; 976 margin: 0;977 976 width: auto; 978 977 } 979 978 #buddypress table.profile-fields { … … 1383 1382 border-bottom: 1px solid #ffe8c4; 1384 1383 font-weight: bold; 1385 1384 } 1385 #buddypress table#message-threads tr.unread td .thread-excerpt, 1386 #buddypress table#message-threads tr.unread td .activity, 1387 #buddypress table#message-threads tr.unread td.thread-options { 1388 font-weight: normal; 1389 } 1386 1390 #buddypress li span.unread-count, 1387 1391 #buddypress tr.unread span.unread-count { 1388 1392 background: #dd0000; … … 1394 1398 padding: 1px 6px; 1395 1399 color: #fff; 1396 1400 } 1397 #buddypress div.messages-options-nav {1398 background: #eee;1399 font-size: 80%;1400 margin: 0;1401 padding: 5px 15px;1402 text-align: right;1403 }1404 1401 #buddypress div#message-thread div.message-box { 1405 1402 margin: 0; 1406 1403 padding: 15px; -
src/bp-templates/bp-legacy/js/buddypress.js
1525 1525 return false; 1526 1526 }); 1527 1527 1528 /* Selecting/Deselecting all messaes */ 1529 jq('#select-all-messages').click(function(event) { 1530 if( this.checked ) { 1531 jq('.message-check').each(function() { 1532 this.checked = true; 1533 }); 1534 } else { 1535 jq('.message-check').each(function() { 1536 this.checked = false; 1537 }); 1538 } 1539 }); 1540 1541 /* Make sure a 'Bulk Action' is selected before submiting the messages bulk action form */ 1542 jq('#messages-bulk-manage').attr('disabled', 'disabled'); 1543 1544 /* Remove the disabled attribute from the messages form submit button when bulk action has a value */ 1545 jq('#messages-select').on('change', function(){ 1546 jq('#messages-bulk-manage').attr('disabled', jq(this).val().length <= 0); 1547 }); 1548 1528 1549 /* Selecting/Deselecting all notifications */ 1529 1550 jq('#select-all-notifications').click(function(event) { 1530 1551 if( this.checked ) {