It would be nice to have a views filter which says "ACL: current user has persmissions to:
READ|WRITE|DELETE" and you could multiple select... :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

salvis’s picture

Status: Active » Closed (won't fix)

Sorry, this is about as specific as "it would be nice if the sun were shining." I can't do anything with this.

Look at devel_node_access in debug mode. If you still think some must-have information is missing, then reopen and be more specific.

mr.andrey’s picture

Version: 5.x-1.6 » 6.x-1.2
Status: Closed (won't fix) » Needs review
FileSize
845 bytes

Hey, the sun is shining!

Here is the "patch" to provide view/update/delete views filters (see under Node).

(Sorry, I don't know how to do multi-file patches, so this is copy/paste + tar.gz)

In acl.module, add this:

function acl_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'acl') . '/includes',
  );
}

Then unzip the attached .tar.gz file in acl (it will create "includes" directory with the necessary views files).

The reason why I wrote this is because we have a setup where a node that has general view permission is different than a node that has explicit ACL permission, and it's important for us to show them separately.

Tutorial on how to write a Views filter

Best,
Andrey.

salvis’s picture

Well, how about that! Thanks for sharing this!

(Sorry, I don't know how to do multi-file patches, so this is copy/paste + tar.gz)

Sorry, this puts it into the do-later pile...

Multi-file patches are easy: just diff directories:

diff -up acl.ori acl >acl.patch
mr.andrey’s picture

FileSize
4.05 KB

Here's the actual patch. And just for reference, here's the command for creating recursive multi-file/folder patches:

diff -uprN folder.orig folder.new > new.patch
salvis’s picture

Status: Needs review » Needs work

Ah, -uprN — thanks!

Dreditor reports a number of white space issues:

+++ acl/acl.module	2010-05-14 10:53:20.000000000 -0600
@@ -207,3 +207,9 @@ function acl_node_access_explain($row) {
\ No newline at end of file

Many of the files end without a newline. This may confuse patch — in the code repository I end up with

function acl_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'acl') . '/includes',
  );
}/**
 * Implementation of hook_node_access_explain().
 */
function acl_node_access_explain($row) {

and I'm unable to undo the patch. In a test installation, where the acl directory looks identical, patch can't match the acl.module file at all. Maybe this is also related to confusion about the acl.ori directory — can you try

diff -uprN modules.ori/acl modules/acl >acl.patch

i.e. branch the directory structure one level higher so that both directories are called 'acl'?

+++ acl/includes/acl.views.inc	2010-05-14 10:53:20.000000000 -0600
@@ -0,0 +1,57 @@
+function acl_views_data() {
+  $data = array();
+
+  if(module_exists('acl')) {
+	
+	$data['node']['acl_view'] = array(
+      'title' => t('ACL: view'),
+      'help' => t('Current user has ACL view permission.'),
+	  'filter' => array(
+		'handler' => 'acl_handler_filter_view',
+      ),
+    );
+ ¶
+	$data['node']['acl_update'] = array(
+      'title' => t('ACL: update'),
+      'help' => t('Current user has ACL update permission.'),
+	  'filter' => array(
+		'handler' => 'acl_handler_filter_update',
+      ),
+    );
+ ¶
+	$data['node']['acl_delete'] = array(
+      'title' => t('ACL: delete'),
+      'help' => t('Current user has ACL delete permission.'),
+	  'filter' => array(
+		'handler' => 'acl_handler_filter_delete',
+      ),
+    );
+ ¶
+  }
+  return $data;
+}

You have a lots of lines that start with tabs as well as lines that have only a tab or space on them.

+++ acl/includes/acl.views.inc	2010-05-14 10:53:20.000000000 -0600
@@ -0,0 +1,57 @@
+/* ?> */

Please remove these, they're unnecessary.

The other three new files also have tab and space issues.

Can you set your editor to never use tabs and to remove trailing white space? Or make white space visible? This will avoid endless trouble with the Drupal coding guidelines as well as Dreditor and Coder.

Just so I get this right: What will I be able to do once I can apply the patch? Create a node list that shows only the nodes where the current user has, say, Delete permission through ACL, right?

Is there any chance that you'll port this to D7 anytime soon?

mr.andrey’s picture

Can you set your editor to never use tabs and to remove trailing white space? Or make white space visible? This will avoid endless trouble with the Drupal coding guidelines as well as Dreditor and Coder.

Is there an easy way to do this tab fix in Dreamweaver?

Just so I get this right: What will I be able to do once I can apply the patch? Create a node list that shows only the nodes where the current user has, say, Delete permission through ACL, right?

That's right.

Is there any chance that you'll port this to D7 anytime soon?

I don't use D7 on any of my sites, so probably not.

Best,
Andrey.

torgosPizza’s picture

Subscribing. I'm in the process of creating a "User portal" where each "subscriber" has a View of all of the content they've signed up for. Views integration is exactly what we need. So thanks for the patch, I'll be checking it out.

jonaswouters’s picture

subscribing

ckng’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Status: Needs work » Needs review
FileSize
4.9 KB

Should probably patch for D7 first, but have urgent need on D6.
This should be straight forward to port.

This is based on @mr.andrey patch in #4
- Fixed coder formatting
- Fixed update filter class name

salvis’s picture

Thank you for the updated patch, but...

Should probably patch for D7 first

Yes. We can't commit new features to D6 and risk forcing a downgrade on upgrade to D7.

I'm leaving this as NR — testing and reviews are welcome — but I need to see a D7 version first.

Allan Walker’s picture

Issue summary: View changes
FileSize
25.81 KB

I have started trying to port the changes from this patch to Drupal 7 and Views 3. It's my first time trying to do such a thing so I'm not sure if I've done it right.

I've attached the full module that I'm working on, as I'm not too sure how to create a patch from the changes I've made. Anyway, I have managed to get the views filter handlers coming up as a filter in views. I can apply the filter, but then this error appears:

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 '.acl_idWHEREacl_node.grant_view1ANDacl_user.uid1 IS NULL ) ))) subquery' at line 1

The sql is pretty much straight from what was supplied above, so I'm assuming it's some sort of D6 to D7 issue, but I haven't had any luck getting to the bottom of it in google. Here is the query:

  function query() {
    $this->ensure_my_table();
    $this->query->add_where($this->options['group'], "node.nid IN (SELECT nid FROM {acl_node} INNER JOIN {acl_user} ON acl_node.acl_id = acl_user.acl_id WHERE acl_node.grant_view = 1 AND acl_user.uid = ***CURRENT_USER*** )");
  }

Any suggestions would be greatly appreciated.

salvis’s picture

Version: 6.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Active

You are passing the numeric uid of the current user in the place of ***CURRENT_USER***, right?

However, as I wrote in #10, all development has to go to the current version first, which is now D8.

I think your chances for getting feedback would be better with a patch than a zip file. You can create a directory 'contrib' in the 'acl' directory and a directory for your module inside that, and then create a patch from the 'acl' directory.

Allan Walker’s picture

Thanks for your reply Salvis, and thanks for the tips about creating a patch

I have managed to get this working now, I changed the function to add_where_expression() and it works perfectly. I will work on a D8 patch once I get my head around it, but here is one for D7

Allan Walker’s picture

Whoops, I included a debugging line by mistake, I've removed it in this patch

joegl’s picture

Allan, what version of the D7 module is the patch in #14 for? I keep getting rejected hunks and a malformed error (at line #141). I have version 7.x-1.1 of the module. Thanks!

salvis’s picture

Status: Active » Closed (outdated)