Skip to:
Content

BuddyPress.org

Ticket #6331: 6331.suggestions.patch

File 6331.suggestions.patch, 5.3 KB (added by imath, 10 years ago)
  • src/bp-messages/bp-messages-star.php

    diff --git src/bp-messages/bp-messages-star.php src/bp-messages/bp-messages-star.php
    index 9d75b5c..ad42c3f 100644
    function bp_the_message_star_action_link( $args = array() ) { 
    8484         *                                       Only applicable if $message_id is set and if $url_only is false.
    8585         *     @type string $title_star_thread   Link title for the 'star' action when displayed in a thread loop.
    8686         *                                       Only applicable if $message_id is set and if $url_only is false.
    87          }
     87         * }
    8888         * @return string
    8989         */
    9090        function bp_get_the_message_star_action_link( $args = array() ) {
    function bp_messages_star_action_handler() { 
    356356                wp_die( "Oops!  That's a no-no!" );
    357357        }
    358358
     359        // Check capability
     360        if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) {
     361                return;
     362        }
     363
    359364        // mark the star
    360365        bp_messages_star_set_action( array(
    361366                'action'     => bp_current_action(),
    function bp_messages_star_bulk_manage_handler() { 
    385390                return;
    386391        }
    387392
     393        // Check capability
     394        if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) {
     395                return;
     396        }
     397
    388398        $action  = ! empty( $_POST['messages_bulk_action'] ) ? $_POST['messages_bulk_action'] : '';
    389399        $threads = ! empty( $_POST['message_ids'] ) ? $_POST['message_ids'] : '';
    390400        $threads = wp_parse_id_list( $threads );
    function bp_messages_star_enqueue_scripts() { 
    448458                return;
    449459        }
    450460
    451         wp_enqueue_style( 'dashicons' );
     461        /**
     462         * Use this filter to use your theme icon stylesheet as soon as it's already
     463         * registered (see wp_register_style())
     464         *
     465         * eg: genericons
     466         *
     467         * @since  BuddyPress (2.3.0)
     468         *
     469         * @param  string the stylesheet handler
     470         */
     471        wp_enqueue_style( apply_filters( 'bp_messages_star_icons_stylesheet', 'dashicons' ) );
    452472}
    453 add_action( 'wp_enqueue_scripts', 'bp_messages_star_enqueue_scripts' );
     473add_action( 'bp_enqueue_scripts', 'bp_messages_star_enqueue_scripts' );
    454474
    455475/**
    456476 * Add the "Add star" and "Remove star" options to the bulk management list.
  • src/bp-templates/bp-legacy/buddypress-functions.php

    diff --git src/bp-templates/bp-legacy/buddypress-functions.php src/bp-templates/bp-legacy/buddypress-functions.php
    index 020b2d0..36800de 100644
    function bp_legacy_theme_ajax_messages_star_handler() { 
    17131713                return;
    17141714        }
    17151715
     1716        // Check nonce
    17161717        check_ajax_referer( 'bp-messages-star-' . (int) $_POST['message_id'], 'nonce' );
    17171718
     1719        // Check capability
     1720        if ( ! is_user_logged_in() || ( ! bp_is_my_profile() && ! bp_current_user_can( 'bp_moderate' ) ) ) {
     1721                return;
     1722        }
     1723
    17181724        if ( true === bp_messages_star_set_action( array(
    17191725                'action'     => $_POST['star_status'],
    17201726                'message_id' => (int) $_POST['message_id'],
  • tests/phpunit/testcases/core/functions.php

    diff --git tests/phpunit/testcases/core/functions.php tests/phpunit/testcases/core/functions.php
    index 41d77a3..8fcc301 100644
    class BP_Tests_Core_Functions extends BP_UnitTestCase { 
    598598                        date_default_timezone_set( $tz_backup );
    599599                }
    600600        }
     601
     602        /**
     603         * @group bp_is_active
     604         */
     605        public function test_bp_is_active_component() {
     606                $bp = buddypress();
     607                $reset_active_components = $bp->active_components;
     608
     609                $this->assertTrue( bp_is_active( 'members' ) );
     610
     611                $this->assertFalse( bp_is_active( 'foo' ) );
     612
     613                // Create and activate the foo component
     614                $bp->foo = new BP_Component;
     615                $bp->foo->id   = 'foo';
     616                $bp->foo->slug = 'foo';
     617                $bp->foo->name = 'Foo';
     618                $bp->active_components[ $bp->foo->id ] = 1;
     619
     620                $this->assertTrue( bp_is_active( 'foo' ) );
     621
     622                add_filter( 'bp_is_active', '__return_false' );
     623
     624                $this->assertFalse( bp_is_active( 'foo' ) );
     625
     626                remove_filter( 'bp_is_active', '__return_false' );
     627
     628                // Reset buddypress() vars
     629                $bp->active_components = $reset_active_components;
     630        }
     631
     632        /**
     633         * @group bp_is_active
     634         */
     635        public function test_bp_is_active_feature() {
     636                $bp = buddypress();
     637                $reset_active_components = $bp->active_components;
     638
     639                $this->assertTrue( bp_is_active( 'messages', 'star' ) );
     640
     641                add_filter( 'bp_is_messages_star_active', '__return_false' );
     642
     643                $this->assertFalse( bp_is_active( 'messages', 'star' ) );
     644
     645                remove_filter( 'bp_is_messages_star_active', '__return_false' );
     646
     647                add_filter( 'bp_is_active', '__return_false' );
     648
     649                $this->assertFalse( bp_is_active( 'messages', 'star' ) );
     650
     651                remove_filter( 'bp_is_active', '__return_false' );
     652
     653                $this->assertFalse( bp_is_active( 'foo', 'bar' ) );
     654
     655                // Create and activate the foo component
     656                $bp->foo = new BP_Component;
     657                $bp->foo->id   = 'foo';
     658                $bp->foo->slug = 'foo';
     659                $bp->foo->name = 'Foo';
     660                $bp->active_components[ $bp->foo->id ] = 1;
     661
     662                $this->assertTrue( bp_is_active( 'foo', 'bar' ) );
     663
     664                add_filter( 'bp_is_foo_bar_active', '__return_false' );
     665
     666                $this->assertFalse( bp_is_active( 'foo', 'bar' ) );
     667
     668                remove_filter( 'bp_is_foo_bar_active', '__return_false' );
     669
     670                add_filter( 'bp_is_active', '__return_false' );
     671
     672                $this->assertFalse( bp_is_active( 'foo', 'bar' ) );
     673
     674                remove_filter( 'bp_is_active', '__return_false' );
     675
     676                // Reset buddypress() vars
     677                $bp->active_components = $reset_active_components;
     678        }
    601679}