Workbench Access is a module that lets you control user content creation and editing permissions via taxonomy or menus.

I am trying to make IMCE use the sections created by Workbench Access the same way it uses Roles.

Currently I have it generating a form on the IMCE admin page of the vocabularies and terms that I am using as sections in Workbench Access. I can select what profile I want to use for the section, and set the weight if I desire. Unfortunately when I save my changes they don't get saved.

I am using Workbench Access 7.x-1.0-beta5 patched with http://drupal.org/node/1121124.

Attached are the two files I've created/ modified in IMCE.

So, what function actually saves the relationship between role and profile?

And where does it get saved to?

What do I need to do to save the relationship between section and profile?

Any screw ups in how I've coded things?

Anything else?

Comments

jerrac’s picture

Ah, solved it. I was variable_set'ing the wrong variable in imce_admin_submit.

Still would like feedback on my code.

Also, isn't there a way I could do this all in a custom module? So that I wouldn't have to modify IMCE core code.

ufku’s picture

IMCE uses Drupal forms. You can try FormsAPI.

jerrac’s picture

Forms API should work for the forms, I had thought about it, but not tried.

What about functions like imce_user_profile()? I had to modify that function.

jerrac’s picture

Specifically, I had to add:

if(imce_workbench_access_exists ())
  { 
    $imce_workbench_sections_profiles = variable_get('imce_workbench_sections_profiles', array());
    $workbench_access_user_sections = workbench_access_get_user_tree();
    foreach ($imce_workbench_sections_profiles as $sid => $section) {
        if(isset($workbench_access_user_sections[$sid]))
        {
            $conf = $section;
            break;
        }
    }
  }

after:

//handle regular users
  $roles_profiles = variable_get('imce_roles_profiles', array());
  $conf = array();
  foreach ($roles_profiles as $rid => $role) {
    if (isset($user->roles[$rid])) {
      $conf = $role;
      break;
    }
  }

in imce_user_profile().

jerrac’s picture

Here are the diff files for imce.module and imce.admin.inc. Also, a new file called imce.workbench.inc.

What works on my dev instance:

  • Assigning profiles to Workbench Access taxonomy sections.
  • IMCE File Browser only showing the directory assigned to the profile for the section a user is an editor in.

What I am working on, and would love help with:

  • Pulling what I've done in IMCE core out and creating a custom module.
  • Showing users multiple directories when they are assigned to mulitple sections in Workbench Access (currently, it only shows the first one that has a profile assigned to it.)
  • Dealing with sections created from menus.
ufku’s picture

You can run imce using a custom menu path, e.g workbench/imce. You just need to define the menu item and access callback similar to imce menu item. You can include imce.page.inc to use the functions defined in it.

jerrac’s picture

ok, I have a custom admin page set up and working. Thanks for that tip.

Now, I'm trying to figure out how to get my access control logic into imce_user_profile(). Maybe I've just been staring at the code for too long, but I don't see how adding a custom menu item would help with that. Unless I wanted to totally override all the code in the function. I just want it to check variable_get('imce_workbench_sections_profiles') for access rights.

Thanks again!

ufku’s picture

Status: Active » Closed (fixed)
nmillin’s picture

Issue summary: View changes

So I know this is an old issue, but I created a module to solve this issue for me. Hopefully it helps someone else if they stumble across this old thread.

https://www.drupal.org/project/workbench_access_imce