Version Description
- Using a WordPress API function get_post_type_capabilities() instead of semi-hardcoded capabilities for access restriction checks (affects CPTs).
- Changed: Taking role-based capabilities into account when creating cache entries for the Groups_User object. The new groups_user_add_role_capabilities filter allows to modify this new behaviour by returning false.
- Added: groups_user_add_role_capabilities filter.
Download this release
Release Info
Developer | itthinx |
Plugin | Groups |
Version | 1.4.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.4 to 1.4.5
- groups.php +2 -2
- lib/access/class-groups-access-meta-boxes.php +16 -1
- lib/access/class-groups-post-access.php +17 -1
- lib/core/class-groups-user.php +25 -1
- readme.txt +9 -1
groups.php
CHANGED
@@ -21,13 +21,13 @@
|
|
21 |
* Plugin Name: Groups
|
22 |
* Plugin URI: http://www.itthinx.com/plugins/groups
|
23 |
* Description: Groups provides group-based user membership management, group-based capabilities and content access control.
|
24 |
-
* Version: 1.4.
|
25 |
* Author: itthinx
|
26 |
* Author URI: http://www.itthinx.com
|
27 |
* Donate-Link: http://www.itthinx.com
|
28 |
* License: GPLv3
|
29 |
*/
|
30 |
-
define( 'GROUPS_CORE_VERSION', '1.4.
|
31 |
define( 'GROUPS_FILE', __FILE__ );
|
32 |
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
|
33 |
define( 'GROUPS_CORE_DIR', WP_PLUGIN_DIR . '/groups' );
|
21 |
* Plugin Name: Groups
|
22 |
* Plugin URI: http://www.itthinx.com/plugins/groups
|
23 |
* Description: Groups provides group-based user membership management, group-based capabilities and content access control.
|
24 |
+
* Version: 1.4.5
|
25 |
* Author: itthinx
|
26 |
* Author URI: http://www.itthinx.com
|
27 |
* Donate-Link: http://www.itthinx.com
|
28 |
* License: GPLv3
|
29 |
*/
|
30 |
+
define( 'GROUPS_CORE_VERSION', '1.4.5' );
|
31 |
define( 'GROUPS_FILE', __FILE__ );
|
32 |
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
|
33 |
define( 'GROUPS_CORE_DIR', WP_PLUGIN_DIR . '/groups' );
|
lib/access/class-groups-access-meta-boxes.php
CHANGED
@@ -351,7 +351,22 @@ class Groups_Access_Meta_Boxes {
|
|
351 |
// "... Some capability checks (like 'edit_post' or 'delete_page') require this [the post ID] be provided."
|
352 |
// If the post ID is not provided, it will throw:
|
353 |
// PHP Notice: Undefined offset: 0 in /var/www/groups-forums/wp-includes/capabilities.php on line 1067
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
// quick-create ?
|
356 |
if ( current_user_can( GROUPS_ADMINISTER_GROUPS ) ) {
|
357 |
if ( !empty( $_POST['quick-group-capability'] ) ) {
|
351 |
// "... Some capability checks (like 'edit_post' or 'delete_page') require this [the post ID] be provided."
|
352 |
// If the post ID is not provided, it will throw:
|
353 |
// PHP Notice: Undefined offset: 0 in /var/www/groups-forums/wp-includes/capabilities.php on line 1067
|
354 |
+
$edit_post_type = 'edit_' . $post_type;
|
355 |
+
if ( $post_type_object = get_post_type_object( $post_type ) ) {
|
356 |
+
if ( !isset( $post_type_object->capabilities ) ) {
|
357 |
+
// get_post_type_capabilities() (WP 3.8) will throw a warning
|
358 |
+
// when trying to merge the missing property otherwise. It's either a
|
359 |
+
// bug or the function's documentation should make it clear that you
|
360 |
+
// have to provide that.
|
361 |
+
$post_type_object->capabilities = array();
|
362 |
+
}
|
363 |
+
$caps_object = get_post_type_capabilities( $post_type_object );
|
364 |
+
if ( isset( $caps_object->edit_post ) ) {
|
365 |
+
$edit_post_type = $caps_object->edit_post;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( current_user_can( $edit_post_type, $post_id ) ) {
|
370 |
// quick-create ?
|
371 |
if ( current_user_can( GROUPS_ADMINISTER_GROUPS ) ) {
|
372 |
if ( !empty( $_POST['quick-group-capability'] ) ) {
|
lib/access/class-groups-post-access.php
CHANGED
@@ -84,7 +84,23 @@ class Groups_Post_Access {
|
|
84 |
if ( isset( $args[0] ) ) {
|
85 |
if ( strpos( $cap, 'edit_' ) === 0 || strpos( $cap, 'delete_' ) === 0 ) {
|
86 |
if ( $post_type = get_post_type( $args[0] ) ) {
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
$post_id = $args[0];
|
89 |
if ( !self::user_can_read_post( $post_id, $user_id ) ) {
|
90 |
$caps[] = 'do_not_allow';
|
84 |
if ( isset( $args[0] ) ) {
|
85 |
if ( strpos( $cap, 'edit_' ) === 0 || strpos( $cap, 'delete_' ) === 0 ) {
|
86 |
if ( $post_type = get_post_type( $args[0] ) ) {
|
87 |
+
|
88 |
+
$edit_post_type = 'edit_' . $post_type;
|
89 |
+
$delete_post_type = 'delete_' . $post_type;
|
90 |
+
if ( $post_type_object = get_post_type_object( $post_type ) ) {
|
91 |
+
if ( !isset( $post_type_object->capabilities ) ) {
|
92 |
+
$post_type_object->capabilities = array();
|
93 |
+
}
|
94 |
+
$caps_object = get_post_type_capabilities( $post_type_object );
|
95 |
+
if ( isset( $caps_object->edit_post ) ) {
|
96 |
+
$edit_post_type = $caps_object->edit_post;
|
97 |
+
}
|
98 |
+
if ( isset( $caps_object->delete_post ) ) {
|
99 |
+
$delete_post_type = $caps_object->delete_post;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
if ( $cap === $edit_post_type || $cap === $delete_post_type ) {
|
104 |
$post_id = $args[0];
|
105 |
if ( !self::user_can_read_post( $post_id, $user_id ) ) {
|
106 |
$caps[] = 'do_not_allow';
|
lib/core/class-groups-user.php
CHANGED
@@ -293,9 +293,33 @@ class Groups_User implements I_Capable {
|
|
293 |
$capability_ids[] = $user_capability->capability_id;
|
294 |
}
|
295 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
// Get all groups the user belongs to directly or through
|
297 |
// inheritance along with their capabilities.
|
298 |
-
|
299 |
if ( $user_groups ) {
|
300 |
foreach( $user_groups as $user_group ) {
|
301 |
$group_ids[] = Groups_Utility::id( $user_group->group_id );
|
293 |
$capability_ids[] = $user_capability->capability_id;
|
294 |
}
|
295 |
}
|
296 |
+
|
297 |
+
if ( apply_filters( 'groups_user_add_role_capabilities', true ) ) {
|
298 |
+
// Get all capabilities from the WP_User object.
|
299 |
+
$role_caps = $this->user->get_role_caps();
|
300 |
+
if ( !empty( $role_caps ) && is_array( $role_caps ) ) {
|
301 |
+
$caps = array();
|
302 |
+
foreach( $role_caps as $role_cap => $has ) {
|
303 |
+
if ( !in_array( $role_cap, $capabilities ) ) {
|
304 |
+
$caps[] = "'" . $role_cap . "'";
|
305 |
+
}
|
306 |
+
}
|
307 |
+
if ( !empty( $caps ) ) {
|
308 |
+
// Retrieve the capabilities and only add those that are
|
309 |
+
// recognized. Note that this also effectively filters out
|
310 |
+
// all roles and that this is desired.
|
311 |
+
if ( $role_capabilities = $wpdb->get_results( "SELECT capability_id, capability FROM $capability_table c WHERE capability IN (" . implode( ',', $caps ) . ")" ) ) {
|
312 |
+
foreach( $role_capabilities as $role_capability ) {
|
313 |
+
$capabilities[] = $role_capability->capability;
|
314 |
+
$capability_ids[] = $role_capability->capability_id;
|
315 |
+
}
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
// Get all groups the user belongs to directly or through
|
322 |
// inheritance along with their capabilities.
|
|
|
323 |
if ( $user_groups ) {
|
324 |
foreach( $user_groups as $user_group ) {
|
325 |
$group_ids[] = Groups_Utility::id( $user_group->group_id );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.itthinx.com/plugins/groups
|
|
4 |
Tags: access, access control, capability, capabilities, content, download, downloads, file, file access, files, group, groups, member, members, membership, memberships, paypal, permission, permissions, subscription, subscriptions, woocommerce
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.8
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3
|
9 |
|
10 |
Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
|
@@ -177,6 +177,11 @@ See also [Groups](http://www.itthinx.com/plugins/groups/)
|
|
177 |
|
178 |
== Changelog ==
|
179 |
|
|
|
|
|
|
|
|
|
|
|
180 |
= 1.4.4 =
|
181 |
* WordPress 3.8 compatibility checked.
|
182 |
* Fixed: Access restriction options per post type when none is checked.
|
@@ -359,6 +364,9 @@ Some installations wouldn't work correctly, showing no capabilities and making i
|
|
359 |
|
360 |
== Upgrade Notice ==
|
361 |
|
|
|
|
|
|
|
362 |
= 1.4.4 =
|
363 |
* WordPress 3.8 compatibility checked and fixed a minor bug.
|
364 |
|
4 |
Tags: access, access control, capability, capabilities, content, download, downloads, file, file access, files, group, groups, member, members, membership, memberships, paypal, permission, permissions, subscription, subscriptions, woocommerce
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.8
|
7 |
+
Stable tag: 1.4.5
|
8 |
License: GPLv3
|
9 |
|
10 |
Groups is an efficient and powerful solution, providing group-based user membership management, group-based capabilities and content access control.
|
177 |
|
178 |
== Changelog ==
|
179 |
|
180 |
+
= 1.4.5 =
|
181 |
+
* Using a WordPress API function get_post_type_capabilities() instead of semi-hardcoded capabilities for access restriction checks (affects CPTs).
|
182 |
+
* Changed: Taking role-based capabilities into account when creating cache entries for the Groups_User object. The new groups_user_add_role_capabilities filter allows to modify this new behaviour by returning false.
|
183 |
+
* Added: groups_user_add_role_capabilities filter.
|
184 |
+
|
185 |
= 1.4.4 =
|
186 |
* WordPress 3.8 compatibility checked.
|
187 |
* Fixed: Access restriction options per post type when none is checked.
|
364 |
|
365 |
== Upgrade Notice ==
|
366 |
|
367 |
+
= 1.4.5 =
|
368 |
+
* Fixed incompatible access restriction checks on some custom post types. Taking role-based capabilities into account.
|
369 |
+
|
370 |
= 1.4.4 =
|
371 |
* WordPress 3.8 compatibility checked and fixed a minor bug.
|
372 |
|