Restrict back-end post and page view - Role restriction


I have created a function that only allow the user "author" to see his/her own posts. The post view is based on the users ID. However, is there any bright person that knows how I can make the restriction role based - so that all authors only can see their post, so editors only can see their posts and so on.

Here is my code:

I tried with $wp_query->set( 'role', 'editor' ); however, that doesn't seems to do the trick.