Commit 1aebbd78 by Cyrille37

student role capabilities #68

parent 50e35599
......@@ -36,20 +36,20 @@ class CommunityProject
$this->settings = new Settings();
$userRoleController = new UserRoleController();
add_action( 'init', array( $userRoleController, 'create_student_role' ) );
add_action( 'init', array( $userRoleController, 'set_user_role_permission' ) );
$projectCustomTypeCreator = new ProjectCustomTypeCreator() ;
add_action( 'init', array( $projectCustomTypeCreator, 'create_project_post_type' ) );
add_action( 'init', array( $projectCustomTypeCreator, 'create_status_taxonomy' ) );
add_action( 'init', array( $projectCustomTypeCreator, 'create_default_status_terms' ) );
$userRoleController = new UserRoleController();
add_action( 'init', array( $userRoleController, 'create_student_role' ) );
add_action( 'init', array( $userRoleController, 'set_user_role_permission' ) );
add_action( 'after_setup_theme', array( $this, 'remove_admin_bar') );
if( is_admin() )
{
add_action( 'admin_menu', array( $this, 'redirect_if_not_author' ) );
//add_action( 'admin_menu', array( $this, 'redirect_if_not_author' ) );
add_action( 'admin_menu', array( $this, 'remove_meta_boxes' ) );
add_action( 'do_meta_boxes', array( $this, 'remove_edit_flow_metabox' ) );
......
......@@ -61,7 +61,7 @@ class ProjectCustomTypeCreator
'not_found_in_trash'=> 'Pas de projet dans la corbeille'
],
'capability_type' => 'post',
'map_meta_cap'=>true,
'capabilities' => [
'publish_posts' => 'publish_projects',
'edit_posts' => 'edit_projects',
......@@ -72,6 +72,7 @@ class ProjectCustomTypeCreator
'edit_post' => 'edit_project',
'delete_post' => 'delete_project',
'read_post' => 'read_project',
'edit_published_posts' => 'edit_published_projects',
],
'supports' => [
'title',
......
......@@ -38,30 +38,34 @@ class UserRoleController
$role->add_cap( 'edit_others_projects' );
$role->add_cap( 'delete_others_projects' );
$role->add_cap( 'read_private_projects' );
$role->add_cap( 'edit_published_projects' );
}
function create_student_role()
{
add_role(
remove_role( self::STUDENT_ROLE );
$role = add_role(
self::STUDENT_ROLE,
'Etudiant',
[
'delete_posts' => false,
'edit_posts' => false,
//'delete_posts' => false,
//'edit_posts' => false,
'edit_projects' => true,
'delete_projects' => false,
'delete_projects' => true,
'publish_projects' => true,
'read_private_projects' => false,
'edit_others_projects' => false,
'edit_published_projects'=>true,
'edit_project' => true,
'read_project' => false,
'delete_project' => false,
'read_project' => true,
'delete_project' => true,
'upload_files' => true,
'read' => true,
'level_1' => true
//'level_1' => true
]
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment