WordPress.org

Plugin Directory

Changeset 626755


Ignore:
Timestamp:
11/19/12 01:18:40 (17 months ago)
Author:
boonebgorges
Message:

Pre-1.2.5 to get latest .pot

Location:
buddypress-docs/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • buddypress-docs/trunk/includes/addon-taxonomy.php

    r625943 r626755  
    203203    function show_terms() { 
    204204        foreach( $this->taxonomies as $tax_name ) { 
    205             $tagtext    = array(); 
    206             $tags       = wp_get_post_terms( get_the_ID(), $tax_name ); 
     205            $html    = ''; 
     206            $tagtext = array(); 
     207            $tags    = wp_get_post_terms( get_the_ID(), $tax_name ); 
    207208 
    208209            foreach( $tags as $tag ) { 
     
    210211            } 
    211212 
    212             $html = '<p>' . sprintf( __( 'Tags: %s', 'bp-docs' ), implode( ', ', $tagtext ) ) . '</p>'; 
     213            if ( ! empty( $tagtext ) ) { 
     214                $html = '<p>' . sprintf( __( 'Tags: %s', 'bp-docs' ), implode( ', ', $tagtext ) ) . '</p>'; 
     215            } 
    213216 
    214217            echo apply_filters( 'bp_docs_taxonomy_show_terms', $html, $tagtext ); 
  • buddypress-docs/trunk/includes/component.php

    r626699 r626755  
    489489        global $bp; 
    490490 
    491         if ( !bp_is_active( 'activity' ) ) 
     491        if ( ! bp_is_active( 'activity' ) ) { 
    492492            return false; 
    493  
    494         if ( empty( $comment_id ) ) 
     493        } 
     494 
     495        if ( empty( $comment_id ) ) { 
    495496            return false; 
    496  
    497         $comment    = get_comment( $comment_id ); 
    498         $doc        = !empty( $comment->comment_post_ID ) ? get_post( $comment->comment_post_ID ) : false; 
    499  
    500         if ( empty( $doc ) ) 
     497        } 
     498 
     499        $comment = get_comment( $comment_id ); 
     500        $doc     = !empty( $comment->comment_post_ID ) ? get_post( $comment->comment_post_ID ) : false; 
     501 
     502        if ( empty( $doc ) ) { 
    501503            return false; 
     504        } 
    502505 
    503506        // Only continue if this is a BP Docs post 
    504         if ( $doc->post_type != $bp->bp_docs->post_type_name ) 
     507        if ( $doc->post_type != bp_docs_get_post_type_name() ) { 
    505508            return; 
    506  
    507         $doc_id     = !empty( $doc->ID ) ? $doc->ID : false; 
    508  
    509         if ( !$doc_id ) 
     509        } 
     510 
     511        $doc_id = ! empty( $doc->ID ) ? $doc->ID : false; 
     512 
     513        if ( ! $doc_id ) { 
    510514            return false; 
     515        } 
    511516 
    512517        // Make sure that BP doesn't record this comment with its native functions 
     
    515520        // Until better individual activity item privacy controls are available in BP, 
    516521        // comments will only be shown in the activity stream if "Who can read comments on 
    517         // this doc?" is set to "Anyone" or "Group members" 
    518         $doc_settings   = get_post_meta( $doc_id, 'bp_docs_settings', true ); 
    519  
    520         if ( !empty( $doc_settings['read_comments'] ) && ( 'admins-mods' == $doc_settings['read_comments'] || 'no-one' == $doc_settings['read_comments'] ) ) 
     522        // this doc?" is set to "Anyone", "Logged-in Users" or "Group members" 
     523        $doc_settings = get_post_meta( $doc_id, 'bp_docs_settings', true ); 
     524 
     525        if ( ! empty( $doc_settings['read_comments'] ) && ! in_array( $doc_settings['read_comments'], array( 'anyone', 'loggedin', 'group-members' ) ) ) { 
    521526            return false; 
    522  
    523         // Get the associated item for this doc. Todo: abstract to standalone function 
    524         $items = wp_get_post_terms( $doc_id, $bp->bp_docs->associated_item_tax_name ); 
    525  
    526         // It's possible that there will be more than one item; for now, post only to the 
    527         // first one. Todo: make this extensible 
    528         $item = !empty( $items[0]->name ) ? $items[0]->name : false; 
    529  
    530         // From the item, we can obtain the component (the parent tax of the item tax) 
    531         if ( !empty( $items[0]->parent ) ) { 
    532             $parent = get_term( (int)$items[0]->parent, $bp->bp_docs->associated_item_tax_name ); 
    533  
    534             // For some reason, I named them singularly. So we have to canonicalize 
    535             switch ( $parent->slug ) { 
    536                 case 'user' : 
    537                     $component = 'profile'; 
    538                     break; 
    539  
    540                 case 'group' : 
    541                 default : 
    542                     $component = 'groups'; 
    543                     break; 
    544             } 
     527        } 
     528 
     529        // See if we're associated with a group 
     530        $group_id = bp_docs_get_associated_group_id( $doc_id ); 
     531 
     532        if ( $group_id ) { 
     533            $component = 'groups'; 
     534            $item = $group_id; 
     535        } else { 
     536            $component = bp_docs_get_slug(); 
     537            $item = 0; 
    545538        } 
    546539 
    547540        // Set the action. Filterable so that other integration pieces can alter it 
    548         $action     = ''; 
    549         $commenter  = get_user_by( 'email', $comment->comment_author_email ); 
    550         $commenter_id   = !empty( $commenter->ID ) ? $commenter->ID : false; 
     541        $action       = ''; 
     542        $commenter    = get_user_by( 'email', $comment->comment_author_email ); 
     543        $commenter_id = !empty( $commenter->ID ) ? $commenter->ID : false; 
    551544 
    552545        // Since BP Docs only allows member comments, the following should never happen 
    553         if ( !$commenter_id ) 
     546        if ( !$commenter_id ) { 
    554547            return false; 
    555  
    556         $user_link  = bp_core_get_userlink( $commenter_id ); 
    557         $doc_url    = bp_docs_get_doc_link( $doc_id ); 
    558         $comment_url    = $doc_url . '#comment-' . $comment->comment_ID; 
    559         $comment_link   = '<a href="' . $comment_url . '">' . $doc->post_title . '</a>'; 
     548        } 
     549 
     550        $user_link    = bp_core_get_userlink( $commenter_id ); 
     551        $doc_url      = bp_docs_get_doc_link( $doc_id ); 
     552        $comment_url  = $doc_url . '#comment-' . $comment->comment_ID; 
     553        $comment_link = '<a href="' . $comment_url . '">' . $doc->post_title . '</a>'; 
    560554 
    561555        $action = sprintf( __( '%1$s commented on the doc %2$s', 'bp-docs' ), $user_link, $comment_link ); 
  • buddypress-docs/trunk/includes/functions.php

    r625943 r626755  
    242242 
    243243    // Only certain actions are checked against doc_ids 
    244     $need_doc_ids_actions = apply_filters( 'bp_docs_need_doc_ids_actions', array( 'edit', 'manage', 'view_history', 'read' ) ); 
     244    $need_doc_ids_actions = apply_filters( 'bp_docs_need_doc_ids_actions', array( 'edit', 'manage', 'view_history', 'read', 'read_comments', 'post_comments' ) ); 
    245245 
    246246    $doc_id = false; 
     
    279279                break; 
    280280 
     281            case 'creator' : 
     282                $user_can = $doc->post_author == $user_id; 
     283                break; 
    281284            // Do nothing with other settings - they are passed through 
    282285        } 
  • buddypress-docs/trunk/includes/integration-groups.php

    r626699 r626755  
    7979        // Make sure the Create Doc link points to the right place 
    8080        add_filter( 'bp_docs_get_create_link',          array( $this, 'get_create_link' ) ); 
    81  
    82         // Prevent comments from being posted on expired logins (see 
    83         // https://github.com/boonebgorges/buddypress-docs/issues/108) 
    84         add_filter( 'pre_comment_on_post',      array( $this, 'check_comment_perms'     ) ); 
    8581 
    8682        // When object terms are set, delete the transient 
     
    757753 
    758754    /** 
    759      * Prevents users from commenting who do not have the correct permissions 
    760      * 
    761      * Typically, this problem is taken care of in the UI. But there are certain edge cases 
    762      * (where a user has opened a comment panel, logged out and in as a different user in a 
    763      * separate tab, and posts - see github.com/boonebgorges/buddypress-docs/issues/108 - 
    764      * or when a user attempts to post a comment directly through a POST event) where the lack 
    765      * of a visible comment form is not enough protection. This catches the comment post 
    766      * and does a manual check on the server side. 
    767      * 
    768      * @package BuddyPress Docs 
    769      * @since 1.1.5 
    770      * 
    771      * @param int $comment_post_ID The ID of the Doc being commented on 
    772      */ 
    773     function check_comment_perms( $comment_post_ID ) { 
    774         global $bp; 
    775  
    776         // Only check this for BP Docs 
    777         $post = get_post( $comment_post_ID ); 
    778         if ( $post->post_type != $bp->bp_docs->post_type_name ) 
    779             return true; 
    780  
    781         // Get the group associated with the Doc 
    782         // Todo: move some of this crap into an API function 
    783  
    784         // Get the associated item terms 
    785         $post_terms = wp_get_post_terms( $comment_post_ID, $bp->bp_docs->associated_item_tax_name ); 
    786  
    787         $can_post_comment = false; 
    788  
    789         foreach( $post_terms as $post_term ) { 
    790             // Make sure this is a group term 
    791             $parent_term = get_term( $post_term->parent, $bp->bp_docs->associated_item_tax_name ); 
    792  
    793             if ( 'group' == $parent_term->slug ) { 
    794                 // Cheating. bp_docs_user_can() requires a current group, which has 
    795                 // not been set yet 
    796                 $bp->groups->current_group = groups_get_group( array( 'group_id' => $post_term->name ) ); 
    797  
    798                 // Check to see that the user is in the group 
    799                 if ( bp_docs_user_can( 'post_comments', bp_loggedin_user_id(), $post_term->name ) ) { 
    800                     $can_post_comment = true; 
    801  
    802                     // We only need a single match 
    803                     break; 
    804                 } 
    805             } 
    806         } 
    807  
    808         if ( !$can_post_comment ) { 
    809             bp_core_add_message( __( 'You do not have permission to post comments on this doc.', 'bp-docs' ), 'error' ); 
    810  
    811             bp_core_redirect( bp_docs_get_doc_link( $comment_post_ID ) ); 
    812         } 
    813     } 
    814  
    815     /** 
    816755     * Delete transient on doc save 
    817756     */ 
  • buddypress-docs/trunk/includes/js/edit-validation.js

    r625943 r626755  
    1010function bpdv_refresh_access_settings() { 
    1111    var assoc_group = jQuery('#associated_group_id').val(); 
     12    var doc_id = jQuery('#doc_id').val(); 
    1213    jQuery.ajax({ 
    1314        type: 'POST', 
     
    1516        data: { 
    1617            'action': 'refresh_access_settings', 
    17             'group_id': assoc_group      
     18            'group_id': assoc_group, 
     19            'doc_id': doc_id 
    1820        }, 
    1921        success: function(r) { 
     
    2527function bpdv_refresh_associated_group() { 
    2628    var assoc_group = jQuery('#associated_group_id').val(); 
     29    var doc_id = jQuery('#doc_id').val(); 
    2730    jQuery.ajax({ 
    2831        type: 'POST', 
     
    3033        data: { 
    3134            'action': 'refresh_associated_group', 
    32             'group_id': assoc_group      
     35            'group_id': assoc_group, 
     36            'doc_id': doc_id 
    3337        }, 
    3438        success: function(r) { 
  • buddypress-docs/trunk/includes/templates/docs/single/edit.php

    r626699 r626755  
    136136            <?php wp_nonce_field( 'bp_docs_save' ) ?> 
    137137 
     138        <input type="hidden" id="doc_id" name="doc_id" value="<?php the_ID() ?>" /> 
    138139        <input type="submit" name="doc-edit-submit" id="doc-edit-submit" value="<?php _e( 'Save', 'bp-docs' ) ?>"> <a href="<?php bp_docs_cancel_edit_link() ?>" class="action safe"><?php _e( 'Cancel', 'bp-docs' ); ?></a> 
    139140 
  • buddypress-docs/trunk/readme.txt

    r626699 r626755  
    3535 
    3636== Changelog == 
     37 
     38= 1.2.5 = 
     39* Fixes comment posting 
     40* Fixes comment display and posting permissions 
     41* Don't show Tags: label when no tags are present 
    3742 
    3843= 1.2.4 = 
Note: See TracChangeset for help on using the changeset viewer.