Skip to content

Commit

Permalink
Merge branch '1.6.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Mar 25, 2014
2 parents 5d38a43 + f0739f1 commit ba44b4d
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 50 deletions.
7 changes: 6 additions & 1 deletion includes/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function generate_rewrite_rules() {
);
}

return $rules;
return apply_filters( 'bp_docs_attachments_generate_rewrite_rules', $rules, $this );
}

/**
Expand Down Expand Up @@ -733,6 +733,11 @@ public function admin_notice() {
&lt;/rule> </code></pre>';
}

if ( $is_apache ) {
$help_url = 'https://github.com/boonebgorges/buddypress-docs/wiki/Attachment-Privacy#apache';
$help_p = __( 'It looks like you are running <strong>Apache</strong>. The most likely cause of your problem is that the <code>AllowOverride</code> directive has been disabled, either globally (<code>httpd.conf</code>) or in a <code>VirtualHost</code> definition. Contact your host for assistance.', 'bp-docs' );
}

?>

<div class="message error">
Expand Down
1 change: 1 addition & 0 deletions includes/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ function enqueue_scripts() {
'upload_title' => __( 'Upload File', 'bp-docs' ),
'upload_button' => __( 'OK', 'bp-docs' ),
'still_working' => __( 'Still working?', 'bp-docs' ),
'and_x_more' => __( 'and %d more', 'bp-docs' ),
);

if ( bp_docs_is_doc_edit() ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/css/screen.css

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,42 @@ function bp_docs_get_access_options( $settings_field, $doc_id = 0, $group_id = 0

return $options;
}
/**
* Saves the settings associated with a given Doc
*
* @since 1.6.1
* @param int $doc_id The numeric ID of the doc
* @return null
*/
function bp_docs_save_doc_access_settings( $doc_id ) {
// Two cases:
// 1. User is saving a doc for which he can update the access settings
if ( isset( $_POST['settings'] ) ) {
$settings = ! empty( $_POST['settings'] ) ? $_POST['settings'] : array();
$verified_settings = bp_docs_verify_settings( $settings, $doc_id, bp_loggedin_user_id() );

$new_settings = array();
foreach ( $verified_settings as $verified_setting_name => $verified_setting ) {
$new_settings[ $verified_setting_name ] = $verified_setting['verified_value'];
if ( $verified_setting['verified_value'] != $verified_setting['original_value'] ) {
$result['message'] = __( 'Your Doc was successfully saved, but some of your access settings have been changed to match the Doc\'s permissions.', 'bp-docs' );
}
}
update_post_meta( $doc_id, 'bp_docs_settings', $new_settings );

// The 'read' setting must also be saved to a taxonomy, for
// easier directory queries
$read_setting = isset( $new_settings['read'] ) ? $new_settings['read'] : 'anyone';
bp_docs_update_doc_access( $doc_id, $read_setting );

// 2. User is saving a doc for which he can't manage the access settings
// isset( $_POST['settings'] ) is false; the access settings section
// isn't included on the edit form
} else {
// Do nothing.
// Leave the access settings intact.
}
}

/**
* Verifies the settings associated with a given Doc
Expand Down
6 changes: 3 additions & 3 deletions includes/integration-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1442,10 +1442,10 @@ function bp_docs_get_associated_group_id( $doc_id, $doc = false, $single_array =
}

function bp_docs_set_associated_group_id( $doc_id, $group_id = 0 ) {
if ( 0 == intval( $group_id ) ) {
$term = array();
} else {
if ( ! empty( $group_id ) ) {
$term = bp_docs_get_group_term( $group_id );
} else {
$term = array();
}

wp_set_post_terms( $doc_id, $term, bp_docs_get_associated_item_tax_name(), false );
Expand Down
37 changes: 21 additions & 16 deletions includes/js/bp-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jQuery(document).ready(function($){
// If this is an edit page, set the lock
if ( $( 'body' ).hasClass( 'bp-docs-edit' ) ) {
var lock_data = {
action: 'add_edit_lock',
action: 'add_edit_lock',
doc_id: doc_id
};

Expand All @@ -33,13 +33,13 @@ jQuery(document).ready(function($){

// Fix the wonky tabindex on Text mode
$('input#doc-permalink').on('keydown',function(e){
focus_in_content_area(e);
focus_in_content_area(e);
});

// When a Doc is created new, there is no Permalink input
$('input#doc-title').on('keydown',function(e){
if ( ! document.getElementById( 'doc-permalink' ) ) {
focus_in_content_area(e);
if ( ! document.getElementById( 'doc-permalink' ) ) {
focus_in_content_area(e);
}
});

Expand All @@ -66,15 +66,15 @@ jQuery(document).ready(function($){
}

// Slide the tags up or down
var rclass, aclass;
var rclass, aclass;
if ( $pom.hasClass('show-pane') ) {
rclass = 'show-pane';
aclass = 'hide-pane';
$toggleable.removeClass( 'toggle-open' ).addClass( 'toggle-closed' );
$toggleable.removeClass( 'toggle-open' ).addClass( 'toggle-closed' );
} else {
rclass = 'hide-pane';
aclass = 'show-pane';
$toggleable.removeClass( 'toggle-closed' ).addClass( 'toggle-open' );
$toggleable.removeClass( 'toggle-closed' ).addClass( 'toggle-open' );
}

$pom.removeClass(rclass);
Expand All @@ -83,8 +83,13 @@ jQuery(document).ready(function($){
return false;
});

$('#bp-docs-group-enable').click(function(){
$('#group-doc-options').slideToggle(400);
var $group_enable_toggle = $( '#bp-docs-group-enable' );
$group_enable_toggle.click(function(){
if ( $group_enable_toggle.is( ':checked' ) ) {
$('#group-doc-options').show();
} else {
$('#group-doc-options').hide();
}
});

/* Permissions snapshot toggle */
Expand Down Expand Up @@ -128,7 +133,7 @@ jQuery(document).ready(function($){

$dfsection_tags.on( 'click', 'a.tags-action-button', function( e ) {
$dfsection_tags.slideUp( 300, function() {
tag_button_action = $( e.target ).hasClass( 'tags-unhide' ) ? 'expand' : 'collapse';
tag_button_action = $( e.target ).hasClass( 'tags-unhide' ) ? 'expand' : 'collapse';

if ( 'expand' == tag_button_action ) {
tags_section_expand( $dfsection_tags );
Expand All @@ -147,7 +152,7 @@ jQuery(document).ready(function($){
var filter_id = filter_title_id.split('-').pop();
var filter_to_show_id = 'docs-filter-section-' + filter_id;
var showing_filter_id = $('.docs-filter-section-open').attr('id');

$('.docs-filter-title').removeClass( 'current' );
filter_title.addClass( 'current' );

Expand Down Expand Up @@ -204,12 +209,12 @@ jQuery(document).ready(function($){
} );

// Add an ellipses item
var st = '&hellip; and %d more';
st = st.replace( /%d/, hidden_tag_counter );
var st = '<span class="and-x-more">&hellip; <a href="#" class="tags-unhide tags-action-button">' + bp_docs.and_x_more + '</a></span>';
st = st.replace( /%d/, hidden_tag_counter );

$dfsection_tags_list.append( '<li class="tags-ellipses">' + st + '</li>' );

$dfsection_tags.prepend( '<a class="tags-unhide tags-action-button" href="#">show all tags</a>' );
$dfsection_tags.prepend( '<a class="tags-unhide tags-action-button tags-spanning-button" href="#">show all tags</a>' );
}

/**
Expand All @@ -219,7 +224,7 @@ jQuery(document).ready(function($){
$section.find( 'a.tags-unhide' ).remove();
$section.find( '.tags-ellipses' ).remove();
$dfsection_tags_items.removeClass( 'hidden-tag' );
$dfsection_tags.prepend( '<a class="tags-hide tags-action-button" href="#">show fewer tags</a>' );
$dfsection_tags.prepend( '<a class="tags-hide tags-action-button tags-spanning-button" href="#">show fewer tags</a>' );
hidden_tag_counter = 0;
}

Expand All @@ -229,7 +234,7 @@ jQuery(document).ready(function($){
$doc_content = $('textarea#doc_content');
if ( $doc_content.is(':visible') ) {
var doccontent = $doc_content.val();
$doc_content.val('');
$doc_content.val('');
$doc_content.focus();
$doc_content.val(doccontent);
return false;
Expand Down
25 changes: 6 additions & 19 deletions includes/query-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@ function save( $args = false ) {
// Check group associations
// @todo Move into group integration piece
if ( bp_is_active( 'groups' ) ) {
$associated_group_id = isset( $_POST['associated_group_id'] ) ? intval( $_POST['associated_group_id'] ) : 0;
// This group id is only used to check whether the user can associate the doc with the group.
$associated_group_id = isset( $_POST['associated_group_id'] ) ? intval( $_POST['associated_group_id'] ) : null;

if ( $associated_group_id && ! BP_Docs_Groups_Integration::user_can_associate_doc_with_group( bp_loggedin_user_id(), $associated_group_id ) ) {
if ( ! empty( $associated_group_id ) && ! BP_Docs_Groups_Integration::user_can_associate_doc_with_group( bp_loggedin_user_id(), $associated_group_id ) ) {
$retval = array(
'message_type' => 'error',
'message' => __( 'You are not allowed to associate a Doc with that group.', 'bp-docs' ),
Expand Down Expand Up @@ -518,6 +519,7 @@ function save( $args = false ) {
} else {
// Remove the edit lock
delete_post_meta( $this->doc_id, '_edit_lock' );
delete_post_meta( $this->doc_id, '_bp_docs_last_pinged' );

// When the post has been autosaved, we need to leave a
// special success message
Expand All @@ -538,7 +540,7 @@ function save( $args = false ) {
if ( ! empty( $post_id ) ) {

// Add to a group, if necessary
if ( isset( $associated_group_id ) ) {
if ( ! is_null( $associated_group_id ) ) {
bp_docs_set_associated_group_id( $post_id, $associated_group_id );
}

Expand All @@ -549,22 +551,7 @@ function save( $args = false ) {
update_post_meta( $this->doc_id, 'bp_docs_last_editor', bp_loggedin_user_id() );

// Save settings
$settings = ! empty( $_POST['settings'] ) ? $_POST['settings'] : array();
$verified_settings = bp_docs_verify_settings( $settings, $post_id, bp_loggedin_user_id() );

$new_settings = array();
foreach ( $verified_settings as $verified_setting_name => $verified_setting ) {
$new_settings[ $verified_setting_name ] = $verified_setting['verified_value'];
if ( $verified_setting['verified_value'] != $verified_setting['original_value'] ) {
$result['message'] = __( 'Your Doc was successfully saved, but some of your access settings have been changed to match the Doc\'s permissions.', 'bp-docs' );
}
}
update_post_meta( $this->doc_id, 'bp_docs_settings', $new_settings );

// The 'read' setting must also be saved to a taxonomy, for
// easier directory queries
$read_setting = isset( $new_settings['read'] ) ? $new_settings['read'] : 'anyone';
bp_docs_update_doc_access( $this->doc_id, $read_setting );
bp_docs_save_doc_access_settings( $this->doc_id );

// Increment the revision count
$revision_count = get_post_meta( $this->doc_id, 'bp_docs_revision_count', true );
Expand Down
14 changes: 10 additions & 4 deletions includes/scss/screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ body.js .bp-docs-attachment-drawer {

& > ul > li {
margin-left: 0;
clear: left;
padding-bottom: 0.8em;
}
}

Expand Down Expand Up @@ -530,8 +532,8 @@ a.docs-filter-title.current {
position: relative;
}

#docs-filter-section-tags a.tags-action-button,
#docs-filter-section-tags a.tags-action-button:visited {
#docs-filter-section-tags a.tags-spanning-button,
#docs-filter-section-tags a.tags-spanning-button:visited {
display: inline;
line-height: 3em;
text-decoration: none;
Expand All @@ -541,6 +543,10 @@ a.docs-filter-title.current {
border-radius: 3px;
}

#docs-filter-section-tags .and-x-more {
white-space: nowrap;
}

body.js .docs-filter-section {
display: none;
}
Expand Down Expand Up @@ -845,8 +851,8 @@ table#post-revisions {

//Media query for most screens, unseen by IE 7 or 8
@media screen and (min-width:4em) {
#docs-filter-section-tags a.tags-action-button,
#docs-filter-section-tags a.tags-action-button:visited {
#docs-filter-section-tags a.tags-spanning-button,
#docs-filter-section-tags a.tags-spanning-button:visited {
display: block; // Let the button span the entire box
margin-bottom: 1em;
padding: 0;
Expand Down
4 changes: 2 additions & 2 deletions loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: BuddyPress Docs
Plugin URI: http://github.com/boonebgorges/buddypress-docs
Description: Adds collaborative Docs to BuddyPress
Version: 1.6.0
Version: 1.6.1
Author: Boone B Gorges
Author URI: http://boone.gorg.es
Licence: GPLv3
Expand All @@ -13,7 +13,7 @@
It's on like Donkey Kong
*/

define( 'BP_DOCS_VERSION', '1.6.0' );
define( 'BP_DOCS_VERSION', '1.6.1' );

// BuddyPress Docs introduces a lot of overhead. Unless otherwise specified,
// don't load the plugin on subsites of an MS install
Expand Down
15 changes: 12 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Donate link: http://teleogistic.net/donate
Tags: buddypress, docs, wiki, documents, collaboration
Requires at least: WordPress 3.3, BuddyPress 1.5
Tested up to: WordPress 3.9, BuddyPress 2.0.0
Stable tag: 1.6.0
Stable tag: 1.6.1

Adds collaborative Docs to BuddyPress.

== Description ==
Expand Down Expand Up @@ -33,6 +33,15 @@ This plugin is in active development. For feature requests and bug reports, visi

== Changelog ==

= 1.6.1 =
* Fix a bug where group associations could be lost when Docs were edited by non-admins
* Add a filter for auto-generated Apache attachment rewrite rules
* Better error notice for Apache users with AllowOverride issues
* Improved layout of attachment drawer
* Improved appearance and localizability for "and x more" tags link
* More reliable toggling of settings during group creation
* Fix bug that prevented edit lock from being cleared on doc save

= 1.6.0 =
* Overhaul of the way group/user tag clouds work
* Improved support for attachments on nginx and IIS
Expand Down Expand Up @@ -193,7 +202,7 @@ This plugin is in active development. For feature requests and bug reports, visi
* Fixes bug that prevented front-end doc deletion
* Removes temporarily non-functional doc counts from group tabs

= 1.2.3 =
= 1.2.3 =
* Fixes bug with bp-pages

= 1.2.2 =
Expand Down
2 changes: 1 addition & 1 deletion tests/test-bp-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function test_delete_group_association() {
$this->go_to( $permalink );

// Just to be sure
unset( $_POST['associated_group_id'] );
$_POST['associated_group_id'] = '';

// We need this dummy $_POST data to make the save go through. Ugh
$doc = $this->factory->doc->get_object_by_id( $doc_id );
Expand Down

0 comments on commit ba44b4d

Please sign in to comment.