Ticket #5513: bulk_notifications_management.2.diff
File bulk_notifications_management.2.diff, 7.2 KB (added by , 10 years ago) |
---|
-
src/bp-templates/bp-legacy/js/buddypress.js
1525 1525 return false; 1526 1526 }); 1527 1527 1528 /* Selecting/Deselecting all notifications */ 1529 jq('#select-all-notifications').click(function(event) { 1530 if( this.checked ) { 1531 jq('.notification-check').each(function() { 1532 this.checked = true; 1533 }); 1534 } else { 1535 jq('.notification-check').each(function() { 1536 this.checked = false; 1537 }); 1538 } 1539 }); 1540 1528 1541 /* Close site wide notices in the sidebar */ 1529 1542 jq('#close-notice').on( 'click', function() { 1530 1543 jq(this).addClass('loading'); -
src/bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php
1 <table class="notifications"> 2 <thead> 3 <tr> 4 <th class="icon"></th> 5 <th class="title"><?php _e( 'Notification', 'buddypress' ); ?></th> 6 <th class="date"><?php _e( 'Date Received', 'buddypress' ); ?></th> 7 <th class="actions"><?php _e( 'Actions', 'buddypress' ); ?></th> 8 </tr> 9 </thead> 1 <form action="" method="post" id="notifications-bulk-management"> 2 <table class="notifications"> 3 <thead> 4 <tr> 5 <th class="icon"></th> 6 <th><?php _e( 'Select all', 'buddypress' ); ?> <input id="select-all-notifications" type="checkbox"></th> 7 <th class="title"><?php _e( 'Notification', 'buddypress' ); ?></th> 8 <th class="date"><?php _e( 'Date Received', 'buddypress' ); ?></th> 9 <th class="actions"><?php _e( 'Actions', 'buddypress' ); ?></th> 10 </tr> 11 </thead> 10 12 11 <tbody>13 <tbody> 12 14 13 <?php while ( bp_the_notifications() ) : bp_the_notification(); ?>15 <?php while ( bp_the_notifications() ) : bp_the_notification(); ?> 14 16 15 <tr> 16 <td></td> 17 <td><?php bp_the_notification_description(); ?></td> 18 <td><?php bp_the_notification_time_since(); ?></td> 19 <td><?php bp_the_notification_action_links(); ?></td> 20 </tr> 17 <tr> 18 <td></td> 19 <td><input id="<?php bp_the_notification_id(); ?>" type="checkbox" name="notifications[]" value="<?php bp_the_notification_id(); ?>" class="notification-check"></td> 20 <td><?php bp_the_notification_description(); ?></td> 21 <td><?php bp_the_notification_time_since(); ?></td> 22 <td><?php bp_the_notification_action_links(); ?></td> 23 </tr> 21 24 22 <?php endwhile; ?>25 <?php endwhile; ?> 23 26 24 </tbody> 25 </table> 26 No newline at end of file 27 </tbody> 28 </table> 29 <div class="notifications-options-nav"> 30 <?php bp_notifications_bulk_management_dropdown(); ?> 31 </div><!-- .notifications-options-nav --> 32 <?php wp_nonce_field( 'notifications_bulk_nonce', 'notifications_bulk_nonce' ); ?> 33 </form> -
src/bp-notifications/bp-notifications-template.php
1049 1049 1050 1050 <?php 1051 1051 } 1052 1053 /** 1054 * Output the dropdown for bulk management of notifications 1055 * 1056 * @since BuddyPress (2.2.0) 1057 */ 1058 function bp_notifications_bulk_management_dropdown() { 1059 ?> 1060 1061 <select name="notification_bulk_action" id="notification-select"> 1062 <?php if ( bp_current_action() == 'unread' ) { ?> 1063 <option value="read"><?php _e( 'Mark selected as read', 'buddypress' ); ?></option> 1064 <?php } elseif ( bp_current_action() == 'read' ) { ?> 1065 <option value="unread"><?php _e( 'Mark selected as unread', 'buddypress' ); ?></option> 1066 <?php } ?> 1067 <option value="delete"><?php _e( 'Delete selected', 'buddypress' ); ?></option> 1068 </select> 1069 <input type="submit" id="notification-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>"> 1070 <?php 1071 } -
src/bp-notifications/bp-notifications-actions.php
121 121 bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' ); 122 122 } 123 123 add_action( 'bp_actions', 'bp_notifications_action_delete' ); 124 125 /** 126 * Handles bulk management (mark as read/unread, delete) of notifications. 127 * 128 * @since BuddyPress (2.2) 129 * 130 * @return bool 131 */ 132 function bp_notifications_action_bulk_manage() { 133 134 // Bail if not the read or unread screen 135 if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) { 136 return false; 137 } 138 139 // Get the action 140 $action = !empty( $_POST['notification_bulk_action'] ) ? $_POST['notification_bulk_action'] : ''; 141 $nonce = !empty( $_POST['notifications_bulk_nonce'] ) ? $_POST['notifications_bulk_nonce'] : ''; 142 $notifications = !empty( $_POST['notifications'] ) ? $_POST['notifications'] : ''; 143 144 // Bail if no action or no IDs 145 if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) { 146 return false; 147 } 148 149 // Check the nonce 150 if ( ! wp_verify_nonce( $nonce, 'notifications_bulk_nonce' ) ) { 151 bp_core_add_message( __( 'There was a problem managing your notifications.', 'buddypress' ) ); 152 return false; 153 } 154 155 // Delete, mark as read or unread depending on the user 'action' 156 switch ( $action ) : 157 158 case 'delete' : 159 foreach ( $notifications as $notification ) { 160 bp_notifications_delete_notification( (int) $notification ); 161 } 162 bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) ); 163 break; 164 165 case 'read' : 166 foreach ( $notifications as $notification ) { 167 bp_notifications_mark_notification( (int) $notification, false ); 168 } 169 bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) ); 170 break; 171 172 case 'unread' : 173 foreach ( $notifications as $notification ) { 174 bp_notifications_mark_notification( (int) $notification, true ); 175 } 176 bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) ); 177 break; 178 179 endswitch; 180 181 // Redirect 182 bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' ); 183 } 184 add_action( 'bp_actions', 'bp_notifications_action_bulk_manage' ); 185 No newline at end of file -
src/bp-templates/bp-legacy/css/buddypress.css
731 731 #buddypress .standard-form #blog-details-section { 732 732 clear: left; 733 733 } 734 #buddypress #notifications-bulk-management { 735 clear: left; 736 } 737 body.no-js #buddypress #notifications-bulk-management #select-all-notifications { 738 display: none; 739 } 734 740 #buddypress .standard-form input:focus, 735 741 #buddypress .standard-form textarea:focus, 736 742 #buddypress .standard-form select:focus {