Version Description
- Added: Access restriction capabilities shown for enabled post types on overview screens.
- WordPress 3.7.1 compatibility checked.
- Fixed: Error caused by typo when obtaining group_ids_deep property for a Groups_User.
- Changed: Replaced some __get calls by properties.
- Added: Filter by access restriction capabilities for enabled post types on overview screens.
Download this release
Release Info
Developer | itthinx |
Plugin | Groups |
Version | 1.4.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.4.2
- groups.php +2 -2
- lib/access/class-groups-access-meta-boxes.php +0 -2
- lib/admin/class-groups-admin-post-columns.php +111 -0
- lib/admin/class-groups-admin-posts.php +231 -0
- lib/core/class-groups-user.php +1 -1
- lib/core/wp-init.php +2 -0
- lib/views/class-groups-shortcodes.php +5 -5
- readme.txt +12 -2
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.2
|
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.2' );
|
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
@@ -207,7 +207,6 @@ class Groups_Access_Meta_Boxes {
|
|
207 |
} else {
|
208 |
$label_title = __( 'No groups grant access through this capability. To grant access to group members using this capability, you should assign it to a group and enable the capability for access restriction.', GROUPS_PLUGIN_DOMAIN );
|
209 |
}
|
210 |
-
$checked = in_array( $capability->capability, $read_caps ) ? ' checked="checked" ' : '';
|
211 |
$output .= sprintf( '<option value="%s" %s>', esc_attr( $capability->capability_id ), in_array( $capability->capability, $read_caps ) ? ' selected="selected" ' : '' );
|
212 |
$output .= wp_filter_nohtml_kses( $capability->capability );
|
213 |
if ( $show_groups ) {
|
@@ -528,7 +527,6 @@ class Groups_Access_Meta_Boxes {
|
|
528 |
} else {
|
529 |
$label_title = __( 'No groups grant access through this capability. To grant access to group members using this capability, you should assign it to a group and enable the capability for access restriction.', GROUPS_PLUGIN_DOMAIN );
|
530 |
}
|
531 |
-
$checked = in_array( $capability->capability, $read_caps ) ? ' checked="checked" ' : '';
|
532 |
$output .= sprintf( '<option value="%s" %s>', esc_attr( $capability->capability_id ), in_array( $capability->capability, $read_caps ) ? ' selected="selected" ' : '' );
|
533 |
$output .= wp_filter_nohtml_kses( $capability->capability );
|
534 |
if ( $show_groups ) {
|
207 |
} else {
|
208 |
$label_title = __( 'No groups grant access through this capability. To grant access to group members using this capability, you should assign it to a group and enable the capability for access restriction.', GROUPS_PLUGIN_DOMAIN );
|
209 |
}
|
|
|
210 |
$output .= sprintf( '<option value="%s" %s>', esc_attr( $capability->capability_id ), in_array( $capability->capability, $read_caps ) ? ' selected="selected" ' : '' );
|
211 |
$output .= wp_filter_nohtml_kses( $capability->capability );
|
212 |
if ( $show_groups ) {
|
527 |
} else {
|
528 |
$label_title = __( 'No groups grant access through this capability. To grant access to group members using this capability, you should assign it to a group and enable the capability for access restriction.', GROUPS_PLUGIN_DOMAIN );
|
529 |
}
|
|
|
530 |
$output .= sprintf( '<option value="%s" %s>', esc_attr( $capability->capability_id ), in_array( $capability->capability, $read_caps ) ? ' selected="selected" ' : '' );
|
531 |
$output .= wp_filter_nohtml_kses( $capability->capability );
|
532 |
if ( $show_groups ) {
|
lib/admin/class-groups-admin-post-columns.php
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* class-groups-admin-custom-posts.php
|
4 |
+
*
|
5 |
+
* Copyright (c) 2012 "kento" Karim Rahimpur www.itthinx.com
|
6 |
+
*
|
7 |
+
* This code is released under the GNU General Public License.
|
8 |
+
* See COPYRIGHT.txt and LICENSE.txt.
|
9 |
+
*
|
10 |
+
* This code is distributed in the hope that it will be useful,
|
11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
* GNU General Public License for more details.
|
14 |
+
*
|
15 |
+
* This header and all notices must be kept intact.
|
16 |
+
*
|
17 |
+
* @author Antonio Blanco
|
18 |
+
* @package groups
|
19 |
+
* @since groups 1.4.2
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Post column extensions.
|
24 |
+
*/
|
25 |
+
class Groups_Admin_Post_Columns {
|
26 |
+
|
27 |
+
const CAPABILITIES = 'capabilities';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Adds an admin_init action.
|
31 |
+
*/
|
32 |
+
public static function init() {
|
33 |
+
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Adds the filters and actions only for users who have the right
|
38 |
+
* Groups permissions and for the post types that have access
|
39 |
+
* restrictions enabled.
|
40 |
+
*/
|
41 |
+
public static function admin_init() {
|
42 |
+
if ( current_user_can( GROUPS_ACCESS_GROUPS ) ) {
|
43 |
+
$post_types = get_post_types( array( 'public' => true ) );
|
44 |
+
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
|
45 |
+
foreach ( $post_types as $post_type ) {
|
46 |
+
if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) {
|
47 |
+
if ( ( $post_type == 'attachment' ) ) {
|
48 |
+
// filters to display the media's access restriction capabilities
|
49 |
+
add_filter( 'manage_media_columns', array( __CLASS__, 'columns' ) );
|
50 |
+
// args: string $column_name, int $media_id
|
51 |
+
add_action( 'manage_media_custom_column', array( __CLASS__, 'custom_column' ), 10, 2 );
|
52 |
+
} else {
|
53 |
+
// filters to display the posts' access restriction capabilities
|
54 |
+
add_filter( 'manage_' . $post_type . '_posts_columns', array( __CLASS__, 'columns' ) );
|
55 |
+
// args: string $column_name, int $post_id
|
56 |
+
add_action( 'manage_' . $post_type . '_posts_custom_column', array( __CLASS__, 'custom_column' ), 10, 2 );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Adds a new column to the post type's table showing the access
|
65 |
+
* restriction capabilities.
|
66 |
+
*
|
67 |
+
* @param array $column_headers
|
68 |
+
* @return array column headers
|
69 |
+
*/
|
70 |
+
public static function columns( $column_headers ) {
|
71 |
+
$column_headers[self::CAPABILITIES] = sprintf(
|
72 |
+
__( '<span title="%s">Access Restrictions</span>', GROUPS_PLUGIN_DOMAIN ),
|
73 |
+
esc_attr( __( 'One ore more capabilities required to read the entry.', GROUPS_PLUGIN_DOMAIN ) )
|
74 |
+
);
|
75 |
+
return $column_headers;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Renders custom column content.
|
80 |
+
*
|
81 |
+
* @param string $column_name
|
82 |
+
* @param int $post_id
|
83 |
+
* @return string custom column content
|
84 |
+
*/
|
85 |
+
public static function custom_column( $column_name, $post_id ) {
|
86 |
+
$output = '';
|
87 |
+
switch ( $column_name ) {
|
88 |
+
case self::CAPABILITIES :
|
89 |
+
$read_caps = get_post_meta( $post_id, Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY );
|
90 |
+
$valid_read_caps = Groups_Options::get_option( Groups_Post_Access::READ_POST_CAPABILITIES, array( Groups_Post_Access::READ_POST_CAPABILITY ) );
|
91 |
+
if ( count( $valid_read_caps ) > 0 ) {
|
92 |
+
$output = '<ul>';
|
93 |
+
foreach( $valid_read_caps as $valid_read_cap ) {
|
94 |
+
if ( $capability = Groups_Capability::read_by_capability( $valid_read_cap ) ) {
|
95 |
+
if ( in_array( $valid_read_cap, $read_caps ) ) {
|
96 |
+
$output .= '<li>';
|
97 |
+
$output .= wp_strip_all_tags( $capability->capability );
|
98 |
+
$output .= '</li>';
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
$output .= '</ul>';
|
103 |
+
} else {
|
104 |
+
$output .= __( '', GROUPS_PLUGIN_DOMAIN );
|
105 |
+
}
|
106 |
+
break;
|
107 |
+
}
|
108 |
+
echo $output;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
Groups_Admin_Post_Columns::init();
|
lib/admin/class-groups-admin-posts.php
ADDED
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* class-groups-admin-posts.php
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 "kento" Karim Rahimpur www.itthinx.com
|
6 |
+
*
|
7 |
+
* This code is released under the GNU General Public License.
|
8 |
+
* See COPYRIGHT.txt and LICENSE.txt.
|
9 |
+
*
|
10 |
+
* This code is distributed in the hope that it will be useful,
|
11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
* GNU General Public License for more details.
|
14 |
+
*
|
15 |
+
* This header and all notices must be kept intact.
|
16 |
+
*
|
17 |
+
* @author Karim Rahimpur
|
18 |
+
* @package groups
|
19 |
+
* @since groups 1.4.2
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Additions to post overview admin screens.
|
24 |
+
*/
|
25 |
+
class Groups_Admin_Posts {
|
26 |
+
|
27 |
+
const NOT_RESTRICTED = "#not-restricted#";
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Sets up an admin_init hook where our actions and filters are added.
|
31 |
+
*/
|
32 |
+
public static function init() {
|
33 |
+
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Adds actions and filters to handle filtering by access restriction
|
38 |
+
* capability.
|
39 |
+
*/
|
40 |
+
public static function admin_init() {
|
41 |
+
if ( current_user_can( GROUPS_ACCESS_GROUPS ) ) {
|
42 |
+
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) );
|
43 |
+
add_action( 'admin_head', array( __CLASS__, 'admin_head' ) );
|
44 |
+
add_action( 'restrict_manage_posts', array( __CLASS__, 'restrict_manage_posts' ) );
|
45 |
+
add_filter( 'parse_query', array( __CLASS__, 'parse_query' ) );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Enqueues the select script.
|
51 |
+
*/
|
52 |
+
public static function admin_enqueue_scripts() {
|
53 |
+
|
54 |
+
global $pagenow;
|
55 |
+
|
56 |
+
if ( $pagenow == 'edit.php' ) {
|
57 |
+
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post';
|
58 |
+
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
|
59 |
+
if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) {
|
60 |
+
Groups_UIE::enqueue( 'select' );
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Adds CSS rules to display our access restriction filter coherently.
|
67 |
+
*/
|
68 |
+
public static function admin_head() {
|
69 |
+
|
70 |
+
global $pagenow;
|
71 |
+
|
72 |
+
if ( $pagenow == 'edit.php' ) {
|
73 |
+
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post';
|
74 |
+
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
|
75 |
+
if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) {
|
76 |
+
echo '<style type="text/css">';
|
77 |
+
echo '.groups-capabilities-container { display: inline-block; line-height: 24px; padding-bottom: 1em; vertical-align: top; margin-left: 4px; margin-right: 4px; }';
|
78 |
+
echo '.groups-capabilities-container .groups-select-container { display: inline-block; vertical-align: top; }';
|
79 |
+
echo '.groups-capabilities-container .groups-select-container select, .groups-bulk-container select.groups-action { float: none; margin-right: 4px; vertical-align: top; }';
|
80 |
+
echo '.groups-capabilities-container .selectize-control { min-width: 128px; }';
|
81 |
+
echo '.groups-capabilities-container .selectize-control, .groups-bulk-container select.groups-action { margin-right: 4px; vertical-align: top; }';
|
82 |
+
echo '.groups-capabilities-container .selectize-input { font-size: inherit; line-height: 18px; padding: 1px 2px 2px 2px; vertical-align: middle; }';
|
83 |
+
echo '.groups-capabilities-container .selectize-input input[type="text"] { font-size: inherit; vertical-align: middle; }';
|
84 |
+
echo '.groups-capabilities-container input.button { margin-top: 1px; vertical-align: top; }';
|
85 |
+
echo '.tablenav .actions { overflow: visible; }'; // this is important so that the selectize options aren't hidden
|
86 |
+
echo '</style>';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Renders the access restriction field.
|
93 |
+
*/
|
94 |
+
public static function restrict_manage_posts() {
|
95 |
+
|
96 |
+
global $pagenow, $wpdb;
|
97 |
+
|
98 |
+
if ( is_admin() ) {
|
99 |
+
|
100 |
+
if ( $pagenow == 'edit.php' ) { // check that we're on the right screen
|
101 |
+
|
102 |
+
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post';
|
103 |
+
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
|
104 |
+
|
105 |
+
if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) {
|
106 |
+
|
107 |
+
$output = '';
|
108 |
+
|
109 |
+
// capabilities select
|
110 |
+
$output .= '<div class="groups-capabilities-container">';
|
111 |
+
$applicable_read_caps = Groups_Options::get_option( Groups_Post_Access::READ_POST_CAPABILITIES, array( Groups_Post_Access::READ_POST_CAPABILITY ) );
|
112 |
+
$output .= sprintf(
|
113 |
+
'<select class="select capability" name="%s[]" multiple="multiple" placeholder="%s" data-placeholder="%s">',
|
114 |
+
esc_attr( Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY ),
|
115 |
+
esc_attr( __( 'Access restrictions …', GROUPS_PLUGIN_DOMAIN ) ) ,
|
116 |
+
esc_attr( __( 'Access restrictions …', GROUPS_PLUGIN_DOMAIN ) )
|
117 |
+
);
|
118 |
+
|
119 |
+
$previous_selected = array();
|
120 |
+
if ( !empty( $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY] ) ) {
|
121 |
+
$previous_selected = $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY];
|
122 |
+
if ( !is_array( $previous_selected ) ) {
|
123 |
+
$previous_selected = array();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
$selected = in_array( self::NOT_RESTRICTED, $previous_selected ) ? ' selected="selected" ' : '';
|
127 |
+
$output .= sprintf( '<option value="%s" %s >%s</option>', self::NOT_RESTRICTED, esc_attr( $selected ), esc_attr( __( '(only unrestricted)', GROUPS_PLUGIN_DOMAIN ) ) );
|
128 |
+
|
129 |
+
foreach( $applicable_read_caps as $capability ) {
|
130 |
+
$selected = in_array( $capability, $previous_selected ) ? ' selected="selected" ' : '';
|
131 |
+
$output .= sprintf( '<option value="%s" %s >%s</option>', esc_attr( $capability ), esc_attr( $selected ), wp_filter_nohtml_kses( $capability ) );
|
132 |
+
}
|
133 |
+
$output .= '</select>';
|
134 |
+
$output .= '</div>';
|
135 |
+
$output .= Groups_UIE::render_select( '.select.capability' );
|
136 |
+
|
137 |
+
echo $output;
|
138 |
+
}
|
139 |
+
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Query modifier to take the selected access restriction capability into
|
147 |
+
* account.
|
148 |
+
*
|
149 |
+
* @param WP_Query $query query object passed by reference
|
150 |
+
*/
|
151 |
+
public static function parse_query( &$query ) {
|
152 |
+
|
153 |
+
global $pagenow;
|
154 |
+
|
155 |
+
if ( is_admin() ) {
|
156 |
+
|
157 |
+
if ( $pagenow == 'edit.php' ) { // check that we're on the right screen
|
158 |
+
|
159 |
+
$post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : 'post';
|
160 |
+
$post_types_option = Groups_Options::get_option( Groups_Post_Access::POST_TYPES, array() );
|
161 |
+
|
162 |
+
if ( !isset( $post_types_option[$post_type]['add_meta_box'] ) || $post_types_option[$post_type]['add_meta_box'] ) {
|
163 |
+
|
164 |
+
if ( !empty( $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY] ) &&
|
165 |
+
is_array( $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY] )
|
166 |
+
) {
|
167 |
+
|
168 |
+
$include_unrestricted = false;
|
169 |
+
if ( in_array( self::NOT_RESTRICTED, $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY] ) ) {
|
170 |
+
$include_unrestricted = true;
|
171 |
+
}
|
172 |
+
|
173 |
+
$capabilities = array();
|
174 |
+
foreach ( $_GET[Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY] as $capability ) {
|
175 |
+
if ( Groups_Capability::read_by_capability( $capability ) ) {
|
176 |
+
$capabilities[] = $capability;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
if ( !empty( $capabilities ) ) {
|
181 |
+
if ( $include_unrestricted ) {
|
182 |
+
// meta_query does not handle a conjunction
|
183 |
+
// on the same meta field correctly
|
184 |
+
// (at least not up to WordPress 3.7.1)
|
185 |
+
// $query->query_vars['meta_query'] = array (
|
186 |
+
// 'relation' => 'OR',
|
187 |
+
// array (
|
188 |
+
// 'key' => Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY,
|
189 |
+
// 'value' => $capabilities,
|
190 |
+
// 'compare' => 'IN'
|
191 |
+
// ),
|
192 |
+
// array (
|
193 |
+
// 'key' => Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY,
|
194 |
+
// 'compare' => 'NOT EXISTS'
|
195 |
+
// )
|
196 |
+
// );
|
197 |
+
// we'll limit it to show just unrestricted entries
|
198 |
+
// until the above is solved
|
199 |
+
$query->query_vars['meta_query'] = array (
|
200 |
+
array (
|
201 |
+
'key' => Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY,
|
202 |
+
'compare' => 'NOT EXISTS'
|
203 |
+
)
|
204 |
+
);
|
205 |
+
} else {
|
206 |
+
$query->query_vars['meta_query'] = array (
|
207 |
+
array (
|
208 |
+
'key' => Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY,
|
209 |
+
'value' => $capabilities,
|
210 |
+
'compare' => 'IN'
|
211 |
+
)
|
212 |
+
);
|
213 |
+
}
|
214 |
+
} else if ( $include_unrestricted ) {
|
215 |
+
$query->query_vars['meta_query'] = array (
|
216 |
+
array (
|
217 |
+
'key' => Groups_Post_Access::POSTMETA_PREFIX . Groups_Post_Access::READ_POST_CAPABILITY,
|
218 |
+
'compare' => 'NOT EXISTS'
|
219 |
+
)
|
220 |
+
);
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
}
|
231 |
+
Groups_Admin_Posts::init();
|
lib/core/class-groups-user.php
CHANGED
@@ -155,7 +155,7 @@ class Groups_User implements I_Capable {
|
|
155 |
|
156 |
case 'group_ids_deep' :
|
157 |
if ( $this->user !== null ) {
|
158 |
-
$
|
159 |
if ( $group_ids === false ) {
|
160 |
$this->init_cache( $capability_ids, $capabilities, $group_ids );
|
161 |
}
|
155 |
|
156 |
case 'group_ids_deep' :
|
157 |
if ( $this->user !== null ) {
|
158 |
+
$group_ids = wp_cache_get( self::GROUP_IDS . $this->user->ID, self::CACHE_GROUP );
|
159 |
if ( $group_ids === false ) {
|
160 |
$this->init_cache( $capability_ids, $capabilities, $group_ids );
|
161 |
}
|
lib/core/wp-init.php
CHANGED
@@ -56,6 +56,8 @@ if ( is_admin() ) {
|
|
56 |
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-user-profile.php' );
|
57 |
}
|
58 |
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-users.php' );
|
|
|
|
|
59 |
}
|
60 |
|
61 |
// help
|
56 |
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-user-profile.php' );
|
57 |
}
|
58 |
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-users.php' );
|
59 |
+
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-posts.php' );
|
60 |
+
require_once( GROUPS_ADMIN_LIB . '/class-groups-admin-post-columns.php' );
|
61 |
}
|
62 |
|
63 |
// help
|
lib/views/class-groups-shortcodes.php
CHANGED
@@ -161,7 +161,7 @@ class Groups_Shortcodes {
|
|
161 |
}
|
162 |
if ( $user_id !== null ) {
|
163 |
$user = new Groups_User( $user_id );
|
164 |
-
$groups = $user->
|
165 |
if ( !empty( $groups ) ) {
|
166 |
switch( $options['order_by'] ) {
|
167 |
case 'group_id' :
|
@@ -193,10 +193,10 @@ class Groups_Shortcodes {
|
|
193 |
case 'list' :
|
194 |
case 'ul' :
|
195 |
case 'ol' :
|
196 |
-
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->
|
197 |
break;
|
198 |
default :
|
199 |
-
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->
|
200 |
}
|
201 |
}
|
202 |
switch( $options['format'] ) {
|
@@ -302,10 +302,10 @@ class Groups_Shortcodes {
|
|
302 |
case 'list' :
|
303 |
case 'ul' :
|
304 |
case 'ol' :
|
305 |
-
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->
|
306 |
break;
|
307 |
default :
|
308 |
-
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->
|
309 |
}
|
310 |
}
|
311 |
switch( $options['format'] ) {
|
161 |
}
|
162 |
if ( $user_id !== null ) {
|
163 |
$user = new Groups_User( $user_id );
|
164 |
+
$groups = $user->groups;
|
165 |
if ( !empty( $groups ) ) {
|
166 |
switch( $options['order_by'] ) {
|
167 |
case 'group_id' :
|
193 |
case 'list' :
|
194 |
case 'ul' :
|
195 |
case 'ol' :
|
196 |
+
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->name . '</li>';
|
197 |
break;
|
198 |
default :
|
199 |
+
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->name . '</div>';
|
200 |
}
|
201 |
}
|
202 |
switch( $options['format'] ) {
|
302 |
case 'list' :
|
303 |
case 'ul' :
|
304 |
case 'ol' :
|
305 |
+
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->name . '</li>';
|
306 |
break;
|
307 |
default :
|
308 |
+
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->name . '</div>';
|
309 |
}
|
310 |
}
|
311 |
switch( $options['format'] ) {
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: itthinx
|
|
3 |
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.
|
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,13 @@ See also [Groups](http://www.itthinx.com/plugins/groups/)
|
|
177 |
|
178 |
== Changelog ==
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
= 1.4.1 =
|
181 |
* Added: Better group-assignment on the Users admin screen, allows to assign/remove multiple users to/from multiple groups along with a better UI.
|
182 |
* Changed: Groups requires at least WordPress 3.5 now, although this only affects the group-action functionality on the Users admin screen, the restrict_manage_users action which is now used to render the UI elements needed, was introduced with WordPress 3.5.
|
@@ -342,6 +349,9 @@ Some installations wouldn't work correctly, showing no capabilities and making i
|
|
342 |
|
343 |
== Upgrade Notice ==
|
344 |
|
|
|
|
|
|
|
345 |
= 1.4.1 =
|
346 |
* From this release on, Groups requires at least WordPress 3.5. It includes improved group-actions for the Users admin screen, where multiple users can now be added to or removed from multiple groups at once.
|
347 |
|
3 |
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.7.1
|
7 |
+
Stable tag: 1.4.2
|
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.2 =
|
181 |
+
* Added: Access restriction capabilities shown for enabled post types on overview screens.
|
182 |
+
* WordPress 3.7.1 compatibility checked.
|
183 |
+
* Fixed: Error caused by typo when obtaining group_ids_deep property for a Groups_User.
|
184 |
+
* Changed: Replaced some __get calls by properties.
|
185 |
+
* Added: Filter by access restriction capabilities for enabled post types on overview screens.
|
186 |
+
|
187 |
= 1.4.1 =
|
188 |
* Added: Better group-assignment on the Users admin screen, allows to assign/remove multiple users to/from multiple groups along with a better UI.
|
189 |
* Changed: Groups requires at least WordPress 3.5 now, although this only affects the group-action functionality on the Users admin screen, the restrict_manage_users action which is now used to render the UI elements needed, was introduced with WordPress 3.5.
|
349 |
|
350 |
== Upgrade Notice ==
|
351 |
|
352 |
+
= 1.4.2 =
|
353 |
+
* Improved views and filters regarding access restrictions which are now shown in overviews for enabled post types. Checked WordPress 3.7.1 compatibility. Some bug fixes and internal improvements.
|
354 |
+
|
355 |
= 1.4.1 =
|
356 |
* From this release on, Groups requires at least WordPress 3.5. It includes improved group-actions for the Users admin screen, where multiple users can now be added to or removed from multiple groups at once.
|
357 |
|