Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Attachments of posts

UserPost

7:34 am
March 21, 2011


Vincent

Member

posts 3

1

Wordpress version: 3.1
Rolescoper version: 1.3.28

Setting: Rolescoper -> Features -> Media Libary 
Non-editors see other users' attached uploads = TRUE
Non-editors see other users' unattached uploads = TRUE

Users: Administrator, testuser01, testuser02 
Testuser01 and Testuser02 are in group: group_role_po
group_role_po has access to the Editor of customposttype PO
All posts are granted to that group 

testuser01 and testuser02 are in WordPress defined as: Subscriber 

Problem: When a post is created by administrator or by an another user (named: testuser01)
testuser02 cannot edit/view attachments of the post. Where there are normally 4 tabs there are displayed 3 tabs (Upload from PC, Upload from URL, Gallery, Libary)
Gallery is missing from the tabs, but when manually entered the URL in the browser, i just get the window and can modify the attachements without problems.

What i found was de following, the query as administrator is the following: (where 1229 is the post id)

SELECT count(*) FROM wp_posts WHERE post_type = 'attachment' 
AND post_status != 'trash' AND post_parent = 1229

But when as Subscriber the query is:

SELECT COUNT( * ) FROM wp_postsWHERE (
(
wp_posts.post_parent =0
)OR (
wp_posts.post_parentIN (
SELECT wp_posts.IDFROM wp_postsWHERE 1 =1AND (
(
wp_posts.post_statusIN (
'future', 'draft', 'pending', 'private', 'publish'
)AND (
(
(
wp_posts.post_type = 'post'AND (
(
( 1 =2 )
)
)
)
)OR (
(
wp_posts.post_type = 'page'AND (
(
( 1 =2 )
)
)
)
)
)
)
)
)
)
)AND post_type = 'attachment'AND post_status != 'trash'AND post_parent =1229

And as result i get 0

So i tracked down where there is determined that post_parent = 0 and found out it was hard coded (i dont get it, but there is possibly a reason for that)
The place where it gets modified is in file: /hardway/hardway-admin_non-administrator-rs.php
In function: flt_last_resort_query($query)
It is between line: 390 and 423 

For some reason, this part:

if ( ! defined('SCOPER_BLOCK_UNATTACHED_UPLOADS') || ! SCOPER_BLOCK_UNATTACHED_UPLOADS )
   $unattached_clause = "( $wpdb->posts.post_parent = 0 $author_clause ) OR";
else
   $unattached_clause = '';

Always get in the IF part, i couldnt find a situation that caused $unattached_clause = ";

But what goes wrong? 

My workaround is before that part of code gets executed i setup: $query_saved = $query; and when the return part is reached (around line 423) i return $query_saved instead of $query, this is how i get it working as my needs.
I tried to understand the SQL query but i cannot explain what it is doing, all i know that both (there is an OR clause) results are 0, so i dont understand what the point is of that part of code.

Is this a bug or a feature? How to deal with this?

9:11 am
March 21, 2011


Kevin

Admin

posts 2503

2

Media Library editing access is filtered by design such that users cannot edit uploads which are attached to uneditable posts.

You can revert to default WP Media Library access by adding this to wp-config.php, above the "stop editing" line:

define( 'SCOPER_ALL_UPLOADS_EDITABLE', true );

By the way, the "post_parent = 0″ clause is added to ensure that unattached uploads (per your settings) remain editable.

9:23 am
March 21, 2011


Vincent

Member

posts 3

3

That did the trick

But why isnt there a way to enable this in the interface? I don't think iam the only one who likes this feature.

Thanks again

9:31 am
March 21, 2011


Kevin

Admin

posts 2503

4

Vincent said:

That did the trick

But why isnt there a way to enable this in the interface? I don't think iam the only one who likes this feature.


Role Scoper is flexible (and therefore option-laden) by design. But I still try not to overdo it. Every additional checkbox that brings convenience to some users brings clutter or confusion to others. "Too many options" is probably the #1 complaint I hear, and not just from novice users.

But I think you're right about this one and will consider covering it in Roles > Options.

9:49 am
March 21, 2011


Vincent

Member

posts 3

5

Kevin said:

Vincent said:

That did the trick

But why isnt there a way to enable this in the interface? I don't think iam the only one who likes this feature.


Role Scoper is flexible (and therefore option-laden) by design. But I still try not to overdo it. Every additional checkbox that brings convenience to some users brings clutter or confusion to others. "Too many options" is probably the #1 complaint I hear, and not just from novice users.

But I think you're right about this one and will consider covering it in Roles > Options.


Okay i understand, but is there a kind of "manual" of define('SCOPER_*');
I believe there are more interesting features with these options, but i couldnt find a kind of wiki

(Maybe a suggestion for a wiki with functions like these?)

12:42 pm
March 21, 2011


Kevin

Admin

posts 2503

6

No, there's currently no comprehensive documentation of supported constant definitions.

For now, you can find some explained within a comment block in role-scoper.php, others in the change log and change log archive. Beyond that, you can find other undocumented curiosities by searching the source code for defined(


About the Agapetry forum

Currently Online:

15 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1245

Posts: 5653

Members:

There are 1255 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin