Resources

My Agape try

Your Agape try


Support Forum

Current User: Guest Login Register
Please consider registering

Search 
Search Forums:


 




Flutter Write Panels and Role Scoper

UserPost

3:23 pm
August 18, 2009


jenswedin

New Member

jenswedin

posts 1

1

Hi

This is my first try on Role Scoper and I really think it would help me out.

I am trying out Flutter Write Panels on a site. I have created Custom Write Panels that are mapped to categories. I know want a group of users to only have access to these Custom Write Panels and not other Categories or Pages.

Could anyone help me out or point me in a direction how to set this up. Role Scoper seem like a really good way of doing this but it's rather complex.

Thanks in advance,

/Jens

11:20 pm
August 31, 2009


Kevin

Admin

posts 1385

2

Planning to look into this soon. Thanks for your patience.

12:46 am
September 19, 2009


Kevin

Admin

posts 1385

3

In honor of this request's one month anniversary, I have written some code to make Flutter Write Post Panel access match RS-defined Category Restrictions / Roles! It requires the addition of a couple hooks in the Flutter code, which I have submitted a support request for.

Once those hooks are in place, you can wait for the next RS release or make it work now by adding this at the top of role-scoper/admin/admin_rs.php. Just below require_once( 'admin_ui_lib_rs.php' ); would be fine:

if ( is_admin() && defined( 'FLUTTER_NAME' ) ) {
	add_filter( 'panels_where_fp', array( 'ScoperFlutterHelper', 'flt_panels_where_fp' ) );
	add_action('admin_head-post-new.php', array('ScoperFlutterHelper', 'act_flutter_panel_access') );
	add_action('admin_head-page-new.php', array('ScoperFlutterHelper', 'act_flutter_panel_access') );
}

Class ScoperFlutterHelper {
	function flt_panels_where_fp ( $where ) {
		global $scoper;

		if ( $cat_ids = $scoper->get_terms( 'category', true, COL_ID_RS ) )
			$where .= " AND type != 'post' OR id IN ( SELECT panel_id FROM " . RC_CWP_TABLE_PANEL_CATEGORY . " WHERE cat_id IN ('" . implode( "','", $cat_ids ) . "') )";
		else
			$where .= " AND type != 'post' ";

		return $where;
	}

	function act_flutter_panel_access() {
		if ( ! isset( $_GET['custom-write-panel-id'] ) || is_administrator_rs() )
			return;

		if ( ! $panel = RCCWP_CustomWritePanel::Get( $_GET['custom-write-panel-id'] ) )
                  return;		

                // we currently only filter for post panels
                if ( 'post' != $panel->type )
		  return;

		global $scoper;
		if ( $cat_ids = $scoper->get_terms( 'category', true, COL_ID_RS ) )
			if ( scoper_get_var( "SELECT panel_id FROM " . RC_CWP_TABLE_PANEL_CATEGORY . " WHERE cat_id IN ('" . implode( "','", $cat_ids ) . "') AND panel_id = '{$panel->id}'" ) )
				return;

		// don't block panel access if it's explicitly assigned via Panel cap
		if ( current_user_can( $panel->capability_name ) )
			return;

		// user doesn't have access based on category or panel capability for requested custom Write Panel, so redirect to generic Write Post form
		wp_redirect( 'post-new.php' );
	}
}


Reply to Topic: Flutter Write Panels and Role Scoper

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 9 + 10        (Required)

Topic Reply:


 

About the Agapetry forum

Currently Online:

10 Guests

Maximum Online: 88

Forums:

Groups: 2

Forums: 7

Topics: 707

Posts: 3193

Members:

There are 642 members

There are 1 guests


Kevin has made 1385 posts

Top Posters:

metal450 - 98

YikYak - 58

Ragnar - 36

Daisy - 35

victar - 33

Administrator: Kevin | Moderators: Kevin