From what I know there is no way to set permissions for exposed filters. That makes sense because, with the exception of my case, there is probably no scenario that would call for it - maybe I'm wrong. But I am submitting it as a feature request just in case anyone else finds it useful. Or is there already some way to do it? Settings field-level CCK permissions doesn't effect the filters (it probably should).

Comments

dawehner’s picture

I don't think there is a permission currently.

If this feature comes in, there has to be a update function, which enables it for both, anonymous and authenticated users, to be sure, that the default behavior does not change.

I think i would be to write a patch until tomorrow.

beautifulmind’s picture

I think it does not make much sense.
You can set permissions on a views which covers every thing on that view.
Now say, if we have permissions on filters, how would you able to display the partial results?
You can create different views with different filters for different roles, which is easy and manageable.

dawehner’s picture

i meant for the full exposed filters.
Just a hook_perm for exposed filters.

jameswoods’s picture

Is there a way to make exposed taxonomy filters respect Tac Lite? For example, if a user does not have permission to view a term, that term should not show up in an exposed filter select list.

Here's my scenario where I think that permissions on exposed filters make sense:

I've got an inventory system set up in Drupal. I have multiple inventory managers, each managing their own department. I use Taxonomy and Tac Lite to control which Terms can be seen/used by which managers. In the node edit and add screens this works wonderfully, as the Computing department sees only computers and scanners and whatnot, while the Media department sees projectors and microphones.

I've got views set up with exposed filters. The filters themselves work great, except that the managers can see ALL terms of each vocabulary, not just the ones they're supposed to see (e.g. Media sees computers, and Computing sees microphones).

I know in the exposed filter settings, I can use 'Limit list to selected items', which "works"...but it will be a bear to manage, because I'll have to update Tac Lite and all of the exposed filters when a new term comes into play.

-James

dawehner’s picture

This is definitive not part of views, if it is not possible via hook_db_rewrite_sql tac lite should alter the views handler.

I had a very short look at the code:

<?php
    else {
      if (!empty($this->options['hierarchy']) && $this->options['limit']) {
        $tree = taxonomy_get_tree($vocabulary->vid);
        $options = array();

        if ($tree) {
          foreach ($tree as $term) {
            $choice = new stdClass();
            $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
            $options[] = $choice;
          }
        }
      }
      else {
        $options = array();
        if ($this->options['limit']) {
          $result = db_query("SELECT * FROM {term_data} WHERE vid = %d ORDER BY weight, name", $vocabulary->vid);
        }
        else {
          $result = db_query("SELECT td.* FROM {term_data} td INNER JOIN {vocabulary} v ON td.vid = v.vid ORDER BY v.weight, v.name, td.weight, td.name");
        }
        while ($term = db_fetch_object($result)) {
          $options[$term->tid] = $term->name;
        }
      }
?>

It would be possible if this code used taxonomy_get_tree or db_rewrite_sql always.

jameswoods’s picture

So...Tac Lite should alter the options that get put into the exposed filters, not Views asking Tac Lite which options the user has perms to?

Meaning that I should go ask at the Tac Lite project?

Oh, and thanks for such a quick reply. You're one more reason Drupal is awesome 8^)

-James

vannus’s picture

Settings field-level CCK permissions doesn't effect the filters (it probably should).

id consider this a bug...

if your not allowed to view a field, you shouldnt be able to filter by it. at the very least, you wouldnt have to design new views depending on permissions.

ive had a look, but cant find where i should make the change so ill have to leave this to someone else :(

dawehner’s picture

@vannus

This should be a bug of cck, not views, i think.

dawehner’s picture

Status: Active » Fixed

#611728: Domain Taxonomy terms exposed in Views

The rest is theming / hook_form_alter or a bug of cck.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

neerajskydiver’s picture

Version: 6.x-2.6 » 7.x-3.0

Spent lot of time trying to search for the solution.

This is how we got it working -

  • Expose the filters
  • Enable the exposed view search as block. EXPOSED FORM - Exposed form in block:Yes
  • Add a context - enable condition as and where you want to display the search block. Add additional condition as "User role" with specific roles. Make sure to click the check box "Require all conditions"
  • Enable Exposed form is specific block as reaction.
  • Done
gejo’s picture

Version: 7.x-3.0 » 6.x-3.0

Another workaround:

  • Clone the display, keeping the same path.
  • Override and edit Access per role in each display. Let each role see one of the displays.
  • Override filters in each display.
  • Set exposed filters per role (in the display that role can see).

Then each role will see a diferent set of exposed filters in the same url.

EDIT: Sorry, this is what #2 suggested...

krishanchandra’s picture

Thanks,
Your code help me in views filter.
global $user;
$x = user_load($user->uid);
foreach($x->tac_lite[5] as $key => $value) {
$arg .= $value . "+" ;
}
return substr($arg, 0, -1) ;

danisha’s picture

I dont know why the terms not assigned to the individual user is seen in the views filter for that term. The tac_lite module and the views module should have been merged to use this.. Not allowing the filters to control the access according to the tac_lite functionality makes the working of the views a bit difficult.

Can someone help?

Where to post this code buddy krishnchandra??

hockey2112’s picture

Issue summary: View changes

Thanks #12... it never occurred to me to simply duplicate the Page display with the same URL and different filters/role access. Worked great!

bib_boy’s picture

hmm...tried #12 but it won't let me set different roles in the permissions. I change to anonymous in one Page view and it changes to anonymous in the other Page view...machine names are different. Any ideas?