Not sure if this is a Save Draft or Views issue... I think it comes down to permissions, but any help is much appreciated:

I've given all my users the permission to view their own unpublished content. If they have the direct link to this content, they're able to view it.

However, it's impossible to give them the direct link (as far as I can tell) unless I create a view listing all the user's created nodes (published and unpublished). I've done this, using a UID argument to ensure each user can only see their own saved drafts and edit them. However, they're not able to see the unpublished nodes listed in the view.

Admin users, who have all permissions, can view these nodes, but other users can't.

I know I'm missing something (probably something obvious). Any ideas?

Comments

kscott22’s picture

Project: Save Draft » Views (for Drupal 7)
Version: 7.x-1.4 » 7.x-3.x-dev
Component: Documentation » Code

I found this thread, which leads me to believe this is a views issue: http://drupal.org/node/1162404

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

In general please provide an export of the view. Perhaps you have set a published filter.

In general the access might be also denied by your node access module.

kscott22’s picture

Thanks -- I appreciate your patience. Below is the export of my view. The only access control module I'm using is Simple Access, so I don't think that's causing the problem (but I could be wrong).

When authenticated users use the direct URL, they can view their own unpublished content. But this content isn't appearing for them on the view. However, if an admin user (with all permissions) accesses the view, they can see unpublished content.

$view = new view;
$view->name = 'tracker_my_posts';
$view->description = 'Shows all new activity on system.';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Tracker: My Posts';
$view->core = 0;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'My posts';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '25';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'status' => 'status',
  'type' => 'type',
  'name' => 'name',
  'comment_count' => 'comment_count',
  'timestamp' => 'title',
  'new_comments' => 'comment_count',
  'created' => 'created',
);
$handler->display->display_options['style_options']['default'] = 'created';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => ' ',
  ),
  'status' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'type' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'name' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
  ),
  'comment_count' => array(
    'sortable' => 1,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '<br />',
  ),
  'timestamp' => array(
    'align' => '',
    'separator' => '',
  ),
  'new_comments' => array(
    'align' => '',
    'separator' => '',
  ),
  'created' => array(
    'sortable' => 1,
    'default_sort_order' => 'desc',
    'align' => '',
    'separator' => '',
  ),
);
$handler->display->display_options['style_options']['override'] = 1;
$handler->display->display_options['style_options']['sticky'] = 0;
$handler->display->display_options['style_options']['order'] = 'desc';
$handler->display->display_options['style_options']['empty_table'] = 0;
/* Relationship: Content: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'node';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
/* Field: Content: Published */
$handler->display->display_options['fields']['status']['id'] = 'status';
$handler->display->display_options['fields']['status']['table'] = 'node';
$handler->display->display_options['fields']['status']['field'] = 'status';
$handler->display->display_options['fields']['status']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['status']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['status']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['status']['alter']['external'] = 0;
$handler->display->display_options['fields']['status']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['status']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['status']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['status']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['status']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['status']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['status']['alter']['trim'] = 0;
$handler->display->display_options['fields']['status']['alter']['html'] = 0;
$handler->display->display_options['fields']['status']['element_label_colon'] = 0;
$handler->display->display_options['fields']['status']['element_default_classes'] = 1;
$handler->display->display_options['fields']['status']['hide_empty'] = 0;
$handler->display->display_options['fields']['status']['empty_zero'] = 0;
$handler->display->display_options['fields']['status']['type'] = 'published-notpublished';
$handler->display->display_options['fields']['status']['not'] = 0;
/* Field: Content: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'node';
$handler->display->display_options['fields']['type']['field'] = 'type';
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
$handler->display->display_options['fields']['name']['label'] = 'Author';
/* Field: Content: Comment count */
$handler->display->display_options['fields']['comment_count']['id'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['table'] = 'node_comment_statistics';
$handler->display->display_options['fields']['comment_count']['field'] = 'comment_count';
$handler->display->display_options['fields']['comment_count']['label'] = 'Replies';
/* Field: Content: Has new content */
$handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['table'] = 'history';
$handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['label'] = '';
$handler->display->display_options['fields']['timestamp']['link_to_node'] = 0;
$handler->display->display_options['fields']['timestamp']['comments'] = 1;
/* Field: Content: New comments */
$handler->display->display_options['fields']['new_comments']['id'] = 'new_comments';
$handler->display->display_options['fields']['new_comments']['table'] = 'node';
$handler->display->display_options['fields']['new_comments']['field'] = 'new_comments';
$handler->display->display_options['fields']['new_comments']['label'] = '';
$handler->display->display_options['fields']['new_comments']['hide_empty'] = TRUE;
$handler->display->display_options['fields']['new_comments']['suffix'] = ' new';
$handler->display->display_options['fields']['new_comments']['link_to_comment'] = 1;
/* Field: Content: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['created']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['created']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['created']['alter']['external'] = 0;
$handler->display->display_options['fields']['created']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['created']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['created']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['created']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['created']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['created']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['created']['alter']['trim'] = 0;
$handler->display->display_options['fields']['created']['alter']['html'] = 0;
$handler->display->display_options['fields']['created']['element_label_colon'] = 0;
$handler->display->display_options['fields']['created']['element_default_classes'] = 1;
$handler->display->display_options['fields']['created']['hide_empty'] = 0;
$handler->display->display_options['fields']['created']['empty_zero'] = 0;
$handler->display->display_options['fields']['created']['date_format'] = 'time ago';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['uid']['not'] = 0;

/* Display: Page: My Posts */
$handler = $view->new_display('page', 'Page: My Posts', 'page');
$handler->display->display_options['path'] = 'tracker/%';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'My posts';
$handler->display->display_options['menu']['weight'] = '0';
dawehner’s picture

Can you please disable the module to test it?

In general it could be a missconfiguration of the module.

kscott22’s picture

Project: Views (for Drupal 7) » Simple Access
Version: 7.x-3.x-dev » 7.x-2.0-beta1

Ah-ha! You're brilliant. And, as usual, I was wrong.

Once I disabled Simple Access, it worked. Thanks! Sorry to have wasted your time on such a simple fix.

kscott22’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I figured out a fix, without having to disable Simple Access.

Simple Access makes edits to Drupal's node_access table. So within the View, under Advanced > Query Settings, I checked the box to disable SQL rewriting. This removes all node access settings, so be careful with it. It works for me, since I'm using a UID contextual filter to ensure that users can only see their OWN created content. And I want this view to be accessible to all users. But it might not work if you want to still control node access within this view.

christophedg’s picture

I have a few questions. When adding a UID contextual filter, I have to choose between 4 possibilities:

User: Authentication module
The name of the module managing the authentication entry.
User: Authentication name
The unique authentication name.
User: Authmap ID
The Authmap ID.
User: Roles
Roles that a user belongs to.

Is the idea to choose Authmap ID?
Anyway, whatever I choose leads to the error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1' ) ))) subquery' at line 1

So I'm kind of stuck now.
And the only simple thing I'm actually trying to do is making sure a user sees his own created content through use of a view.

Can anyone see what's happening here?

christophedg’s picture

Never mind, http://drupal.org/node/1200322 answered my question!

adelayde’s picture

Thanks this solved my problem too. I was using the Content Access module in combination with Views under Drupal 7 and this was causing me a headache. Disabling SQL rewriting did the trick. Am not convinced that this is a proper solution: for me it wasn't important that I had to disable node access permissions for the content type in question, but for others if they needed both together, wouldn't they be rather stuffed? Weirdly I don't understand quite why it should happen as there's nothing in the config, perms or per content type set-up for the Content Access module that mentions this issue, or any setting ... anyhow I wrote a short post on my blog about it too http://mbharris.co.uk/node/30

wickwood’s picture

In the Content Access issue queue I found a patch that I think properly fixes the problem sited in #10 with the Content Access module without having to disable SQL rewriting in views.

You can find the patch here: https://drupal.org/node/1225520#comment-7209666

JanKanis’s picture

Issue summary: View changes

I've created a module here that solves this issue for me. In my case the above patch applied all the same visibilities and permissions to unpublished content rather than just making it visible to their owner.