Changeset 13275
- Timestamp:
- 04/29/2022 08:00:56 PM (3 years ago)
- Location:
- branches/10.0/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/10.0/src/bp-messages/classes/class-bp-messages-component.php
r13196 r13275 269 269 ); 270 270 271 // Show certain screens only if the current user is the displayed user. 272 if ( bp_is_my_profile() ) { 273 274 // Show "Compose" on the logged-in user's profile only. 275 $sub_nav[] = array( 276 'name' => __( 'Compose', 'buddypress' ), 277 'slug' => 'compose', 278 'parent_url' => $messages_link, 279 'parent_slug' => $slug, 280 'screen_function' => 'messages_screen_compose', 281 'position' => 30, 282 'user_has_access' => $access 283 ); 284 285 /* 286 * Show "Notices" on the logged-in user's profile only 287 * and then only if the user can create notices. 288 */ 289 if ( bp_current_user_can( 'bp_moderate' ) ) { 290 $sub_nav[] = array( 291 'name' => __( 'Notices', 'buddypress' ), 292 'slug' => 'notices', 293 'parent_url' => $messages_link, 294 'parent_slug' => $slug, 295 'screen_function' => 'messages_screen_notices', 296 'position' => 90, 297 'user_has_access' => true 298 ); 299 } 300 } 271 // Show "Compose" on the logged-in user's profile only. 272 $sub_nav[] = array( 273 'name' => __( 'Compose', 'buddypress' ), 274 'slug' => 'compose', 275 'parent_url' => $messages_link, 276 'parent_slug' => $slug, 277 'screen_function' => 'messages_screen_compose', 278 'position' => 30, 279 'user_has_access' => bp_is_my_profile(), 280 ); 281 282 // Show "Notices" to community admins only. 283 $sub_nav[] = array( 284 'name' => __( 'Notices', 'buddypress' ), 285 'slug' => 'notices', 286 'parent_url' => $messages_link, 287 'parent_slug' => $slug, 288 'screen_function' => 'messages_screen_notices', 289 'position' => 90, 290 'user_has_access' => bp_current_user_can( 'bp_moderate' ) 291 ); 301 292 302 293 parent::setup_nav( $main_nav, $sub_nav ); -
branches/10.0/src/bp-templates/bp-nouveau/includes/messages/functions.php
r13036 r13275 4 4 * 5 5 * @since 3.0.0 6 * @version 10. 0.06 * @version 10.3.0 7 7 */ 8 8 … … 91 91 } 92 92 93 $bp = buddypress(); 94 $slug = bp_nouveau_get_component_slug( 'messages' ); 95 96 // Use the primary nav to get potential custom slugs. 97 $primary_nav = $bp->members->nav->get( $slug ); 98 if ( isset( $primary_nav->link ) && $primary_nav->link ) { 99 $root_url = $primary_nav->link; 100 101 // Make sure to use the displayed user domain. 102 if ( bp_loggedin_user_domain() ) { 103 $root_url = str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $root_url ); 104 } 105 } else { 106 $root_url = trailingslashit( bp_displayed_user_domain() . $slug ); 107 } 108 109 // Build default routes list. 110 $routes = array( 111 'inbox' => 'inbox', 112 'sentbox' => 'sentbox', 113 'compose' => 'compose', 114 ); 115 116 if ( bp_is_active( 'messages', 'star' ) ) { 117 $routes['starred'] = 'starred'; 118 } 119 120 // Use the secondary nav to get potential custom slugs. 121 $secondary_nav = $bp->members->nav->get_secondary( array( 'parent_slug' => $slug ), false ); 122 123 // Resets the routes list using link slugs. 124 if ( $secondary_nav ) { 125 foreach ( $secondary_nav as $subnav_item ) { 126 $routes[ $subnav_item->slug ] = trim( str_replace( $root_url, '', $subnav_item->link ), '/' ); 127 128 if ( ! $routes[ $subnav_item->slug ] ) { 129 $routes[ $subnav_item->slug ] = $subnav_item->slug; 130 } 131 } 132 } 133 93 134 $params['messages'] = array( 94 'errors' => array(135 'errors' => array( 95 136 'send_to' => __( 'Please add at least one recipient.', 'buddypress' ), 96 137 'subject' => __( 'Please add a subject to your message.', 'buddypress' ), 97 138 'message_content' => __( 'Please add some content to your message.', 'buddypress' ), 98 139 ), 99 'nonces' => array(140 'nonces' => array( 100 141 'send' => wp_create_nonce( 'messages_send_message' ), 101 142 ), 102 'loading' => __( 'Loading messages. Please wait.', 'buddypress' ),103 'doingAction' => array(143 'loading' => __( 'Loading messages. Please wait.', 'buddypress' ), 144 'doingAction' => array( 104 145 'read' => __( 'Marking messages as read. Please wait.', 'buddypress' ), 105 146 'unread' => __( 'Marking messages as unread. Please wait.', 'buddypress' ), … … 108 149 'unstar' => __( 'Unstarring messages. Please wait.', 'buddypress' ), 109 150 ), 110 'bulk_actions' => bp_nouveau_messages_get_bulk_actions(),111 'howto' => __( 'Click on the message title to preview it in the Active conversation box below.', 'buddypress' ),112 'howtoBulk' => __( 'Use the select box to define your bulk action and click on the ✓ button to apply.', 'buddypress' ),113 'toOthers' => array(151 'bulk_actions' => bp_nouveau_messages_get_bulk_actions(), 152 'howto' => __( 'Click on the message title to preview it in the Active conversation box below.', 'buddypress' ), 153 'howtoBulk' => __( 'Use the select box to define your bulk action and click on the ✓ button to apply.', 'buddypress' ), 154 'toOthers' => array( 114 155 'one' => __( '(and 1 other)', 'buddypress' ), 115 156 … … 117 158 'more' => __( '(and %d others)', 'buddypress' ), 118 159 ), 119 'rootUrl' => parse_url( trailingslashit( bp_displayed_user_domain() . bp_nouveau_get_component_slug( 'messages' ) ), PHP_URL_PATH ), 160 'rootUrl' => parse_url( $root_url, PHP_URL_PATH ), 161 'supportedRoutes' => $routes, 120 162 ); 121 163 -
branches/10.0/src/bp-templates/bp-nouveau/js/buddypress-messages.js
r13260 r13275 2 2 /* jshint devel: true */ 3 3 /* @since 3.0.0 */ 4 /* @version 10. 2.0 */4 /* @version 10.3.0 */ 5 5 window.wp = window.wp || {}; 6 6 window.bp = window.bp || {}; … … 37 37 this.box = 'inbox'; 38 38 39 // Set up supported routes. 40 this.supportedRoutes = BP_Nouveau.messages.supportedRoutes; 41 39 42 this.setupNav(); 40 43 … … 54 57 $( '#subnav a' ).on( 'click', function( event ) { 55 58 var view_id = $( event.target ).prop( 'id' ), 56 supportedView = [ 'inbox', 'starred', 'sentbox', 'compose' ];59 supportedView = _.keys( self.supportedRoutes ); 57 60 58 61 if ( -1 === _.indexOf( supportedView, view_id ) || 'unsupported' === self.box ) { … … 79 82 80 83 // Navigate back to current box. 81 self.router.navigate( self. box+ '/', { trigger: true } );84 self.router.navigate( self.supportedRoutes[ self.box ] + '/', { trigger: true } ); 82 85 83 86 // Otherwise load it. 84 87 } else { 85 self.router.navigate( 'compose/', { trigger: true } );88 self.router.navigate( self.supportedRoutes.compose + '/', { trigger: true } ); 86 89 } 87 90 … … 92 95 self.clearViews(); 93 96 94 self.router.navigate( view_id+ '/', { trigger: true } );97 self.router.navigate( self.supportedRoutes[ view_id ] + '/', { trigger: true } ); 95 98 } 96 99 } … … 677 680 bp.Nouveau.Messages.views.remove( { id: 'compose', view: form } ); 678 681 679 bp.Nouveau.Messages.router.navigate( 'sentbox/', { trigger: true } );682 bp.Nouveau.Messages.router.navigate( bp.Nouveau.Messages.supportedRoutes.sentbox + '/', { trigger: true } ); 680 683 } ).fail( function( response ) { 681 684 if ( response.feedback ) { … … 1401 1404 bp.Nouveau.Messages.Router = Backbone.Router.extend( { 1402 1405 routes: { 1403 'compose/' : 'composeMessage',1404 1406 'view/:id/' : 'viewMessage', 1405 'sentbox/' : 'sentboxView',1406 'starred/' : 'starredView',1407 'inbox/' : 'inboxView',1408 1407 '' : 'inboxView', 1409 1408 '*unSupported': 'unSupported' 1409 }, 1410 1411 initialize: function() { 1412 var self = this; 1413 1414 _.each( BP_Nouveau.messages.supportedRoutes, function( route, slug ) { 1415 self.route( route + '/', slug + 'Route', function() { 1416 if ( 'compose' === slug ) { 1417 self.composeMessage(); 1418 } else if ( 'sentbox' === slug ) { 1419 self.sentboxView(); 1420 } else if ( 'starred' === slug ) { 1421 self.starredView(); 1422 } else if ( 'inbox' === slug ) { 1423 self.inboxView(); 1424 } 1425 } ); 1426 } ); 1410 1427 }, 1411 1428
Note: See TracChangeset
for help on using the changeset viewer.