Changeset 9132
- Timestamp:
- 11/11/2014 01:53:34 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-actions.php
r9025 r9132 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' ), 'error' ); 152 return false; 153 } 154 155 $notifications = wp_parse_id_list( $notifications ); 156 157 // Delete, mark as read or unread depending on the user 'action'. 158 switch ( $action ) { 159 case 'delete' : 160 foreach ( $notifications as $notification ) { 161 bp_notifications_delete_notification( $notification ); 162 } 163 bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) ); 164 break; 165 166 case 'read' : 167 foreach ( $notifications as $notification ) { 168 bp_notifications_mark_notification( $notification, false ); 169 } 170 bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) ); 171 break; 172 173 case 'unread' : 174 foreach ( $notifications as $notification ) { 175 bp_notifications_mark_notification( $notification, true ); 176 } 177 bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) ); 178 break; 179 } 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' ); -
trunk/src/bp-notifications/bp-notifications-template.php
r9025 r9132 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 <select name="notification_bulk_action" id="notification-select"> 1061 <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option> 1062 1063 <?php if ( bp_is_current_action( 'unread' ) ) : ?> 1064 <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option> 1065 <?php elseif ( bp_is_current_action( 'read' ) ) : ?> 1066 <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option> 1067 <?php endif; ?> 1068 <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option> 1069 </select> 1070 <input type="submit" id="notification-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>"> 1071 <?php 1072 } -
trunk/src/bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php
r8958 r9132 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><label for="select-all-notifications"><?php _e( 'Select all', 'buddypress' ); ?></label><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> 27 </tbody> 28 </table> 29 30 <div class="notifications-options-nav"> 31 <?php bp_notifications_bulk_management_dropdown(); ?> 32 </div><!-- .notifications-options-nav --> 33 34 <?php wp_nonce_field( 'notifications_bulk_nonce', 'notifications_bulk_nonce' ); ?> 35 </form> -
trunk/src/bp-templates/bp-legacy/css/buddypress.css
r8926 r9132 732 732 clear: left; 733 733 } 734 #buddypress label[for="select-all-notifications"] { 735 display: none; 736 } 737 #buddypress #notifications-bulk-management { 738 clear: left; 739 } 740 body.no-js #buddypress #notifications-bulk-management #select-all-notifications { 741 display: none; 742 } 734 743 #buddypress .standard-form input:focus, 735 744 #buddypress .standard-form textarea:focus, -
trunk/src/bp-templates/bp-legacy/js/buddypress.js
r9129 r9132 1524 1524 1525 1525 return false; 1526 }); 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 } 1526 1539 }); 1527 1540
Note: See TracChangeset
for help on using the changeset viewer.