Version Description
- Added shortcode & API functions [groups_user_group] / [groups_user_groups] that allows to show the list of groups the current user or a specific user belongs to
- Added shortcode & API functions [groups_groups]to show the site's list of groups
- Class comments.
Download this release
Release Info
Developer | itthinx |
Plugin | Groups |
Version | 1.1.5 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.1.5
- groups.php +2 -2
- lib/access/class-groups-access-shortcodes.php +4 -0
- lib/access/class-groups-post-access.php +4 -0
- lib/admin/class-groups-admin-users.php +4 -0
- lib/admin/class-groups-admin.php +4 -0
- lib/admin/groups-admin-groups.php +2 -0
- lib/admin/groups-admin-options.php +3 -0
- lib/auto/class-groups-registered.php +4 -0
- lib/core/class-groups-capability.php +3 -0
- lib/core/class-groups-controller.php +4 -0
- lib/core/class-groups-group-capability.php +4 -0
- lib/core/class-groups-group.php +3 -0
- lib/core/class-groups-help.php +4 -0
- lib/core/class-groups-options.php +1 -1
- lib/core/class-groups-user-capability.php +4 -0
- lib/core/class-groups-user-group.php +4 -0
- lib/core/class-groups-user.php +3 -0
- lib/core/class-groups-utility.php +4 -0
- lib/core/interface-i-capable.php +4 -0
- lib/core/wp-init.php +1 -0
- lib/views/class-groups-shortcodes.php +218 -0
- lib/wp/class-groups-wordpress.php +4 -0
- readme.txt +43 -21
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.1.
|
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.1.
|
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.1.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.1.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-shortcodes.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Access_Shortcodes {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Shortcode handlers.
|
24 |
+
*/
|
25 |
class Groups_Access_Shortcodes {
|
26 |
|
27 |
/**
|
lib/access/class-groups-post-access.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Post_Access {
|
22 |
|
23 |
const POSTMETA_PREFIX = 'groups-';
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Post access restrictions.
|
24 |
+
*/
|
25 |
class Groups_Post_Access {
|
26 |
|
27 |
const POSTMETA_PREFIX = 'groups-';
|
lib/admin/class-groups-admin-users.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Admin_Users {
|
22 |
|
23 |
const GROUPS = 'groups_user_groups';
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Users admin integration with Groups.
|
24 |
+
*/
|
25 |
class Groups_Admin_Users {
|
26 |
|
27 |
const GROUPS = 'groups_user_groups';
|
lib/admin/class-groups-admin.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Admin {
|
22 |
public static function init() {
|
23 |
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Groups admin sections initialization.
|
24 |
+
*/
|
25 |
class Groups_Admin {
|
26 |
public static function init() {
|
27 |
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
|
lib/admin/groups-admin-groups.php
CHANGED
@@ -18,6 +18,8 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
21 |
define( 'GROUPS_GROUPS_PER_PAGE', 10 );
|
22 |
define( 'GROUPS_ADMIN_GROUPS_NONCE_1', 'groups-nonce-1');
|
23 |
define( 'GROUPS_ADMIN_GROUPS_NONCE_2', 'groups-nonce-2');
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
// admin defines
|
23 |
define( 'GROUPS_GROUPS_PER_PAGE', 10 );
|
24 |
define( 'GROUPS_ADMIN_GROUPS_NONCE_1', 'groups-nonce-1');
|
25 |
define( 'GROUPS_ADMIN_GROUPS_NONCE_2', 'groups-nonce-2');
|
lib/admin/groups-admin-options.php
CHANGED
@@ -24,6 +24,9 @@
|
|
24 |
*/
|
25 |
define( 'GROUPS_ADMIN_OPTIONS_NONCE', 'groups-admin-nonce' );
|
26 |
|
|
|
|
|
|
|
27 |
function groups_admin_options() {
|
28 |
|
29 |
global $wpdb, $wp_roles;
|
24 |
*/
|
25 |
define( 'GROUPS_ADMIN_OPTIONS_NONCE', 'groups-admin-nonce' );
|
26 |
|
27 |
+
/**
|
28 |
+
* Options admin screen.
|
29 |
+
*/
|
30 |
function groups_admin_options() {
|
31 |
|
32 |
global $wpdb, $wp_roles;
|
lib/auto/class-groups-registered.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Registered {
|
22 |
|
23 |
const REGISTERED_GROUP_NAME = 'Registered';
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* "Registered" group automation.
|
24 |
+
*/
|
25 |
class Groups_Registered {
|
26 |
|
27 |
const REGISTERED_GROUP_NAME = 'Registered';
|
lib/core/class-groups-capability.php
CHANGED
@@ -19,6 +19,9 @@
|
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
|
|
|
|
|
|
|
22 |
class Groups_Capability {
|
23 |
|
24 |
/**
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
|
22 |
+
/**
|
23 |
+
* Capability OPM
|
24 |
+
*/
|
25 |
class Groups_Capability {
|
26 |
|
27 |
/**
|
lib/core/class-groups-controller.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Controller {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Plugin controller
|
24 |
+
*/
|
25 |
class Groups_Controller {
|
26 |
|
27 |
/**
|
lib/core/class-groups-group-capability.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Group_Capability {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Group Capability OPM
|
24 |
+
*/
|
25 |
class Groups_Group_Capability {
|
26 |
|
27 |
/**
|
lib/core/class-groups-group.php
CHANGED
@@ -20,6 +20,9 @@
|
|
20 |
*/
|
21 |
require_once( GROUPS_CORE_LIB . "/interface-i-capable.php" );
|
22 |
|
|
|
|
|
|
|
23 |
class Groups_Group implements I_Capable {
|
24 |
|
25 |
/**
|
20 |
*/
|
21 |
require_once( GROUPS_CORE_LIB . "/interface-i-capable.php" );
|
22 |
|
23 |
+
/**
|
24 |
+
* Group OPM.
|
25 |
+
*/
|
26 |
class Groups_Group implements I_Capable {
|
27 |
|
28 |
/**
|
lib/core/class-groups-help.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Help {
|
22 |
|
23 |
public static function init() {
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Help renderer.
|
24 |
+
*/
|
25 |
class Groups_Help {
|
26 |
|
27 |
public static function init() {
|
lib/core/class-groups-options.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
-
* Groups options
|
24 |
*/
|
25 |
class Groups_Options {
|
26 |
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
+
* Groups options handler
|
24 |
*/
|
25 |
class Groups_Options {
|
26 |
|
lib/core/class-groups-user-capability.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_User_Capability {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* User Capability OPM.
|
24 |
+
*/
|
25 |
class Groups_User_Capability {
|
26 |
|
27 |
/**
|
lib/core/class-groups-user-group.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_User_Group {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* User Group OPM.
|
24 |
+
*/
|
25 |
class Groups_User_Group {
|
26 |
|
27 |
/**
|
lib/core/class-groups-user.php
CHANGED
@@ -22,6 +22,9 @@
|
|
22 |
require_once( GROUPS_CORE_LIB . "/interface-i-capable.php" );
|
23 |
require_once( GROUPS_CORE_LIB . "/class-groups-capability.php" );
|
24 |
|
|
|
|
|
|
|
25 |
class Groups_User implements I_Capable {
|
26 |
|
27 |
/**
|
22 |
require_once( GROUPS_CORE_LIB . "/interface-i-capable.php" );
|
23 |
require_once( GROUPS_CORE_LIB . "/class-groups-capability.php" );
|
24 |
|
25 |
+
/**
|
26 |
+
* User OPM.
|
27 |
+
*/
|
28 |
class Groups_User implements I_Capable {
|
29 |
|
30 |
/**
|
lib/core/class-groups-utility.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Utility {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Utility functions.
|
24 |
+
*/
|
25 |
class Groups_Utility {
|
26 |
|
27 |
/**
|
lib/core/interface-i-capable.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
interface I_Capable {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Capable interface OPM.
|
24 |
+
*/
|
25 |
interface I_Capable {
|
26 |
|
27 |
/**
|
lib/core/wp-init.php
CHANGED
@@ -19,6 +19,7 @@
|
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
|
|
|
22 |
global $groups_version, $groups_admin_messages;
|
23 |
|
24 |
if ( !isset( $groups_admin_messages ) ) {
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
|
22 |
+
// startup
|
23 |
global $groups_version, $groups_admin_messages;
|
24 |
|
25 |
if ( !isset( $groups_admin_messages ) ) {
|
lib/views/class-groups-shortcodes.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_Shortcodes {
|
22 |
|
23 |
/**
|
@@ -26,6 +30,10 @@ class Groups_Shortcodes {
|
|
26 |
public static function init() {
|
27 |
// group info
|
28 |
add_shortcode( 'groups_group_info', array( __CLASS__, 'groups_group_info' ) );
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
/**
|
@@ -81,5 +89,215 @@ class Groups_Shortcodes {
|
|
81 |
}
|
82 |
return $output;
|
83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
Groups_Shortcodes::init();
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Shortcode handlers
|
24 |
+
*/
|
25 |
class Groups_Shortcodes {
|
26 |
|
27 |
/**
|
30 |
public static function init() {
|
31 |
// group info
|
32 |
add_shortcode( 'groups_group_info', array( __CLASS__, 'groups_group_info' ) );
|
33 |
+
// user groups
|
34 |
+
add_shortcode( 'groups_user_groups', array( __CLASS__, 'groups_user_groups' ) );
|
35 |
+
// groups
|
36 |
+
add_shortcode( 'groups_groups', array( __CLASS__, 'groups_groups' ) );
|
37 |
}
|
38 |
|
39 |
/**
|
89 |
}
|
90 |
return $output;
|
91 |
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Renders the current or a specific user's groups.
|
95 |
+
* Attributes:
|
96 |
+
* - "user_id" OR "user_login" OR "user_email" to identify the user, if none given assumes the current user
|
97 |
+
* - "format" : one of "list" "div" "ul" or "ol" - "list" and "ul" are equivalent
|
98 |
+
* - "list_class" : defaults to "groups"
|
99 |
+
* - "item_class" : defaults to "name"
|
100 |
+
* - "order_by" : defaults to "name", also accepts "group_id"
|
101 |
+
* - "order" : default to "ASC", also accepts "asc", "desc" and "DESC"
|
102 |
+
*
|
103 |
+
* @param array $atts attributes
|
104 |
+
* @param string $content not used
|
105 |
+
* @return rendered groups for current user
|
106 |
+
*/
|
107 |
+
public static function groups_user_groups( $atts, $content = null ) {
|
108 |
+
$output = "";
|
109 |
+
$options = shortcode_atts(
|
110 |
+
array(
|
111 |
+
'user_id' => null,
|
112 |
+
'user_login' => null,
|
113 |
+
'user_email' => null,
|
114 |
+
'format' => 'list',
|
115 |
+
'list_class' => 'groups',
|
116 |
+
'item_class' => 'name',
|
117 |
+
'order_by' => 'name',
|
118 |
+
'order' => 'ASC'
|
119 |
+
),
|
120 |
+
$atts
|
121 |
+
);
|
122 |
+
$user_id = null;
|
123 |
+
if ( $options['user_id'] !== null ) {
|
124 |
+
if ( $user = get_user_by( 'id', $options['user_id'] ) ) {
|
125 |
+
$user_id = $user->ID;
|
126 |
+
}
|
127 |
+
} else if ( $options['user_id'] !== null ) {
|
128 |
+
if ( $user = get_user_by( 'login', $options['user_login'] ) ) {
|
129 |
+
$user_id = $user->ID;
|
130 |
+
}
|
131 |
+
} else if ( $options['user_email'] !== null ) {
|
132 |
+
if ( $user = get_user_by( 'email', $options['user_login'] ) ) {
|
133 |
+
$user_id = $user->ID;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
if ( $user_id === null ) {
|
137 |
+
$user_id = get_current_user_id();
|
138 |
+
}
|
139 |
+
if ( $user_id !== null ) {
|
140 |
+
$user = new Groups_User( $user_id );
|
141 |
+
$groups = $user->__get( 'groups' );
|
142 |
+
if ( !empty( $groups ) ) {
|
143 |
+
switch( $options['order_by'] ) {
|
144 |
+
case 'group_id' :
|
145 |
+
usort( $groups, array( __CLASS__, 'sort_id' ) );
|
146 |
+
break;
|
147 |
+
default :
|
148 |
+
usort( $groups, array( __CLASS__, 'sort_name' ) );
|
149 |
+
}
|
150 |
+
switch( $options['order'] ) {
|
151 |
+
case 'desc' :
|
152 |
+
case 'DESC' :
|
153 |
+
$groups = array_reverse( $groups );
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
|
157 |
+
switch( $options['format'] ) {
|
158 |
+
case 'list' :
|
159 |
+
case 'ul' :
|
160 |
+
$output .= '<ul class="' . esc_attr( $options['list_class'] ) . '">';
|
161 |
+
break;
|
162 |
+
case 'ol' :
|
163 |
+
$output .= '<ol class="' . esc_attr( $options['list_class'] ) . '">';
|
164 |
+
break;
|
165 |
+
default :
|
166 |
+
$output .= '<div class="' . esc_attr( $options['list_class'] ) . '">';
|
167 |
+
}
|
168 |
+
foreach( $groups as $group ) {
|
169 |
+
switch( $options['format'] ) {
|
170 |
+
case 'list' :
|
171 |
+
case 'ul' :
|
172 |
+
case 'ol' :
|
173 |
+
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->__get( 'name' ) . '</li>';
|
174 |
+
break;
|
175 |
+
default :
|
176 |
+
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->__get( 'name' ) . '</div>';
|
177 |
+
}
|
178 |
+
}
|
179 |
+
switch( $options['format'] ) {
|
180 |
+
case 'list' :
|
181 |
+
case 'ul' :
|
182 |
+
$output .= '</ul>';
|
183 |
+
break;
|
184 |
+
case 'ol' :
|
185 |
+
$output .= '</ol>';
|
186 |
+
break;
|
187 |
+
default :
|
188 |
+
$output .= '</div>';
|
189 |
+
}
|
190 |
+
}
|
191 |
+
}
|
192 |
+
return $output;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Group comparison by group_id.
|
197 |
+
*
|
198 |
+
* @param Groups_Group $a
|
199 |
+
* @param Groups_Group $b
|
200 |
+
* @return int
|
201 |
+
*/
|
202 |
+
public static function sort_id( $a, $b ) {
|
203 |
+
return $a->group_id - $b->group_id;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Group comparison by name.
|
208 |
+
*
|
209 |
+
* @param Groups_Group $a
|
210 |
+
* @param Groups_Group $b
|
211 |
+
* @return int
|
212 |
+
*/
|
213 |
+
public static function sort_name( $a, $b ) {
|
214 |
+
return strcmp( $a->name, $b->name );
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Renders a list of the site's groups.
|
219 |
+
* Attributes:
|
220 |
+
* - "format" : one of "list" "div" "ul" or "ol" - "list" and "ul" are equivalent
|
221 |
+
* - "list_class" : defaults to "groups"
|
222 |
+
* - "item_class" : defaults to "name"
|
223 |
+
* - "order_by" : defaults to "name", also accepts "group_id"
|
224 |
+
* - "order" : default to "ASC", also accepts "asc", "desc" and "DESC"
|
225 |
+
*
|
226 |
+
* @param array $atts attributes
|
227 |
+
* @param string $content not used
|
228 |
+
* @return rendered groups
|
229 |
+
*/
|
230 |
+
public static function groups_groups( $atts, $content = null ) {
|
231 |
+
global $wpdb;
|
232 |
+
$output = "";
|
233 |
+
$options = shortcode_atts(
|
234 |
+
array(
|
235 |
+
'format' => 'list',
|
236 |
+
'list_class' => 'groups',
|
237 |
+
'item_class' => 'name',
|
238 |
+
'order_by' => 'name',
|
239 |
+
'order' => 'ASC'
|
240 |
+
),
|
241 |
+
$atts
|
242 |
+
);
|
243 |
+
switch( $options['order_by'] ) {
|
244 |
+
case 'group_id' :
|
245 |
+
case 'name' :
|
246 |
+
$order_by = $options['order_by'];
|
247 |
+
break;
|
248 |
+
default :
|
249 |
+
$order_by = 'name';
|
250 |
+
}
|
251 |
+
switch( $options['order'] ) {
|
252 |
+
case 'asc' :
|
253 |
+
case 'ASC' :
|
254 |
+
case 'desc' :
|
255 |
+
case 'DESC' :
|
256 |
+
$order = strtoupper( $options['order'] );
|
257 |
+
break;
|
258 |
+
default :
|
259 |
+
$order = 'ASC';
|
260 |
+
}
|
261 |
+
$group_table = _groups_get_tablename( "group" );
|
262 |
+
if ( $groups = $wpdb->get_results( $wpdb->prepare(
|
263 |
+
"SELECT group_id FROM $group_table ORDER BY $order_by $order"
|
264 |
+
) ) ) {
|
265 |
+
switch( $options['format'] ) {
|
266 |
+
case 'list' :
|
267 |
+
case 'ul' :
|
268 |
+
$output .= '<ul class="' . esc_attr( $options['list_class'] ) . '">';
|
269 |
+
break;
|
270 |
+
case 'ol' :
|
271 |
+
$output .= '<ol class="' . esc_attr( $options['list_class'] ) . '">';
|
272 |
+
break;
|
273 |
+
default :
|
274 |
+
$output .= '<div class="' . esc_attr( $options['list_class'] ) . '">';
|
275 |
+
}
|
276 |
+
foreach( $groups as $group ) {
|
277 |
+
$group = new Groups_Group( $group->group_id );
|
278 |
+
switch( $options['format'] ) {
|
279 |
+
case 'list' :
|
280 |
+
case 'ul' :
|
281 |
+
case 'ol' :
|
282 |
+
$output .= '<li class="' . esc_attr( $options['item_class'] ) . '">' . $group->__get( 'name' ) . '</li>';
|
283 |
+
break;
|
284 |
+
default :
|
285 |
+
$output .= '<div class="' . esc_attr( $options['item_class'] ) . '">' . $group->__get( 'name' ) . '</div>';
|
286 |
+
}
|
287 |
+
}
|
288 |
+
switch( $options['format'] ) {
|
289 |
+
case 'list' :
|
290 |
+
case 'ul' :
|
291 |
+
$output .= '</ul>';
|
292 |
+
break;
|
293 |
+
case 'ol' :
|
294 |
+
$output .= '</ol>';
|
295 |
+
break;
|
296 |
+
default :
|
297 |
+
$output .= '</div>';
|
298 |
+
}
|
299 |
+
}
|
300 |
+
return $output;
|
301 |
+
}
|
302 |
}
|
303 |
Groups_Shortcodes::init();
|
lib/wp/class-groups-wordpress.php
CHANGED
@@ -18,6 +18,10 @@
|
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
|
|
|
|
|
|
|
|
21 |
class Groups_WordPress {
|
22 |
|
23 |
/**
|
18 |
* @package groups
|
19 |
* @since groups 1.0.0
|
20 |
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* WordPress capabilities integration.
|
24 |
+
*/
|
25 |
class Groups_WordPress {
|
26 |
|
27 |
/**
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Groups ===
|
2 |
Contributors: itthinx
|
3 |
Donate link: http://www.itthinx.com/plugins/groups
|
4 |
-
Tags: access, access control, capability, capabilities, content, group, groups, member, members, membership, permission, permissions
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.2
|
7 |
-
Stable tag: 1.1.
|
8 |
|
9 |
Groups provides group-based user membership management, group-based capabilities and content access control.
|
10 |
|
@@ -13,27 +13,31 @@ Groups provides group-based user membership management, group-based capabilities
|
|
13 |
Groups provides group-based user membership management, group-based capabilities and content access control.
|
14 |
It integrates standard WordPress capabilities and application-specific capabilities along with an extensive API.
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
|
20 |
- Supports an unlimited number of groups
|
21 |
- Provides a Registered group which is automatically maintained
|
22 |
- Users can be assigned to any group
|
23 |
- Users are added automatically to the Registered group
|
24 |
|
25 |
-
|
26 |
|
27 |
- Supports group hierarchies with capability inheritance
|
28 |
|
29 |
-
|
30 |
|
31 |
- Integrates standard WordPress capabilities which can be assigned to groups and users
|
32 |
- Supports custom capabilities: allows to define new capabilities for usage in plugins and web applications
|
33 |
- Users inherit capabilities of the groups they belong to
|
34 |
- Groups inherit capabilities of their parent groups
|
35 |
|
36 |
-
|
37 |
|
38 |
- Built-in access control that allows to restrict access to posts, pages and custom content types to specific groups and users only
|
39 |
- control access to content by groups: shortcodes allow to control who can access content on posts, show parts to members of certain groups or to those who are not members
|
@@ -41,7 +45,7 @@ It integrates standard WordPress capabilities and application-specific capabilit
|
|
41 |
- control access to content by capabilities: show (or do not show) content to users who have certain capabilities
|
42 |
Shortcodes: [groups_can], [groups_can_not]
|
43 |
|
44 |
-
|
45 |
|
46 |
- integrates nicely with the standard WordPress Users menu
|
47 |
- provides an intuitive Groups menu
|
@@ -49,34 +53,28 @@ It integrates standard WordPress capabilities and application-specific capabilit
|
|
49 |
- quick filters
|
50 |
- bulk-actions where needed, for example apply capabilities to groups, bulk-add users to groups, bulk-remove users from groups
|
51 |
|
52 |
-
|
53 |
|
54 |
- administrator overrides can be turned off
|
55 |
- optional tree view for groups can be shown only when needed
|
56 |
- provides its own set of permissions
|
57 |
- cleans up after testing with a "delete all plugin data" option
|
58 |
|
59 |
-
|
60 |
|
61 |
Groups defines some capabilities of its own. The groups_read_post capability
|
62 |
is used to restrict access to certain posts or pages to groups (and users)
|
63 |
-
with that capability only.
|
64 |
|
65 |
-
|
66 |
|
67 |
- Solid and sound data-model with a complete API that allows developers to create group-oriented web applications and plugins
|
68 |
|
69 |
-
|
70 |
|
71 |
- All features are supported independently for each blog in multisite installations
|
72 |
|
73 |
-
###
|
74 |
-
|
75 |
-
#### You & Groups ####
|
76 |
-
|
77 |
-
Beta-testers and developers who need to integrate group-based features in their plugins and web applications: please use it and provide your feedback.
|
78 |
-
|
79 |
-
#### Feedback ###
|
80 |
|
81 |
Feedback is welcome!
|
82 |
|
@@ -86,7 +84,7 @@ Please try to solve problems there before you rate this plugin or say it doesn't
|
|
86 |
|
87 |
#### Twitter ####
|
88 |
|
89 |
-
[Follow
|
90 |
|
91 |
### Introduction ###
|
92 |
|
@@ -200,6 +198,22 @@ Examples:
|
|
200 |
|
201 |
* There [groups_group_info group="1" show="count" single="is one member" plural="are %d members"] in the [groups_group_info group="1" show="name"] group.
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
== Installation ==
|
204 |
|
205 |
1. Upload or extract the `groups` folder to your site's `/wp-content/plugins/` directory. You can also use the *Add new* option found in the *Plugins* menu in WordPress.
|
@@ -230,6 +244,11 @@ See also [Groups](http://www.itthinx.com/plugins/groups/)
|
|
230 |
|
231 |
== Changelog ==
|
232 |
|
|
|
|
|
|
|
|
|
|
|
233 |
= 1.1.4 =
|
234 |
* Reduced plugin admin footer.
|
235 |
|
@@ -275,6 +294,9 @@ Some installations wouldn't work correctly, showing no capabilities and making i
|
|
275 |
|
276 |
== Upgrade Notice ==
|
277 |
|
|
|
|
|
|
|
278 |
= 1.1.4 =
|
279 |
* Several bug fixes and improvements.
|
280 |
|
1 |
=== Groups ===
|
2 |
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, permission, permissions
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.2
|
7 |
+
Stable tag: 1.1.5
|
8 |
|
9 |
Groups provides group-based user membership management, group-based capabilities and content access control.
|
10 |
|
13 |
Groups provides group-based user membership management, group-based capabilities and content access control.
|
14 |
It integrates standard WordPress capabilities and application-specific capabilities along with an extensive API.
|
15 |
|
16 |
+
### Extensions ###
|
17 |
|
18 |
+
- [Groups File Access](http://www.itthinx.com/plugins/groups-file-access/) Groups File Access is an extension that allows to provide file download links for authorized users. Access to files is restricted to users by their group membership.
|
19 |
+
|
20 |
+
### Features ###
|
21 |
+
|
22 |
+
#### User groups ####
|
23 |
|
24 |
- Supports an unlimited number of groups
|
25 |
- Provides a Registered group which is automatically maintained
|
26 |
- Users can be assigned to any group
|
27 |
- Users are added automatically to the Registered group
|
28 |
|
29 |
+
#### Groups hierarchy ####
|
30 |
|
31 |
- Supports group hierarchies with capability inheritance
|
32 |
|
33 |
+
#### Group capabilities ####
|
34 |
|
35 |
- Integrates standard WordPress capabilities which can be assigned to groups and users
|
36 |
- Supports custom capabilities: allows to define new capabilities for usage in plugins and web applications
|
37 |
- Users inherit capabilities of the groups they belong to
|
38 |
- Groups inherit capabilities of their parent groups
|
39 |
|
40 |
+
#### Access control ####
|
41 |
|
42 |
- Built-in access control that allows to restrict access to posts, pages and custom content types to specific groups and users only
|
43 |
- control access to content by groups: shortcodes allow to control who can access content on posts, show parts to members of certain groups or to those who are not members
|
45 |
- control access to content by capabilities: show (or do not show) content to users who have certain capabilities
|
46 |
Shortcodes: [groups_can], [groups_can_not]
|
47 |
|
48 |
+
#### Easy user interface ####
|
49 |
|
50 |
- integrates nicely with the standard WordPress Users menu
|
51 |
- provides an intuitive Groups menu
|
53 |
- quick filters
|
54 |
- bulk-actions where needed, for example apply capabilities to groups, bulk-add users to groups, bulk-remove users from groups
|
55 |
|
56 |
+
#### Sensible options ####
|
57 |
|
58 |
- administrator overrides can be turned off
|
59 |
- optional tree view for groups can be shown only when needed
|
60 |
- provides its own set of permissions
|
61 |
- cleans up after testing with a "delete all plugin data" option
|
62 |
|
63 |
+
#### Access Control ####
|
64 |
|
65 |
Groups defines some capabilities of its own. The groups_read_post capability
|
66 |
is used to restrict access to certain posts or pages to groups (and users)
|
67 |
+
with that capability only.
|
68 |
|
69 |
+
#### Framework ####
|
70 |
|
71 |
- Solid and sound data-model with a complete API that allows developers to create group-oriented web applications and plugins
|
72 |
|
73 |
+
#### Multisite ####
|
74 |
|
75 |
- All features are supported independently for each blog in multisite installations
|
76 |
|
77 |
+
### Feedback ###
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
Feedback is welcome!
|
80 |
|
84 |
|
85 |
#### Twitter ####
|
86 |
|
87 |
+
[Follow @itthinx on Twitter](http://twitter.com/itthinx) for updates on this and other plugins.
|
88 |
|
89 |
### Introduction ###
|
90 |
|
198 |
|
199 |
* There [groups_group_info group="1" show="count" single="is one member" plural="are %d members"] in the [groups_group_info group="1" show="name"] group.
|
200 |
|
201 |
+
#### Show user groups ####
|
202 |
+
|
203 |
+
- [groups_user_groups]
|
204 |
+
|
205 |
+
This shortcode lists the current user's or a specific user's groups.
|
206 |
+
|
207 |
+
For detailed information about this shortcode, please refer to the [Groups plugin page](http://www.itthinx.com/plugins/groups/).
|
208 |
+
|
209 |
+
#### Show site groups ####
|
210 |
+
|
211 |
+
- [groups_groups]
|
212 |
+
|
213 |
+
This shortcode lists the site's groups.
|
214 |
+
|
215 |
+
For detailed information about this shortcode, please refer to the [Groups plugin page](http://www.itthinx.com/plugins/groups/).
|
216 |
+
|
217 |
== Installation ==
|
218 |
|
219 |
1. Upload or extract the `groups` folder to your site's `/wp-content/plugins/` directory. You can also use the *Add new* option found in the *Plugins* menu in WordPress.
|
244 |
|
245 |
== Changelog ==
|
246 |
|
247 |
+
= 1.1.5 =
|
248 |
+
* Added shortcode & API functions [groups_user_group] / [groups_user_groups] that allows to show the list of groups the current user or a specific user belongs to
|
249 |
+
* Added shortcode & API functions [groups_groups]to show the site's list of groups
|
250 |
+
* Class comments.
|
251 |
+
|
252 |
= 1.1.4 =
|
253 |
* Reduced plugin admin footer.
|
254 |
|
294 |
|
295 |
== Upgrade Notice ==
|
296 |
|
297 |
+
= 1.1.5 =
|
298 |
+
...
|
299 |
+
|
300 |
= 1.1.4 =
|
301 |
* Several bug fixes and improvements.
|
302 |
|