Posted by AD-DA on July 9, 2008 at 3:49pm
| Project: | IMCE |
| Version: | 6.x-2.0-beta3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
In the current version, when a user has multiple roles with IMCE enabled, IMCE will only display the folder for the role with the highest priority (which is I believe the role with the role with the smallest ID.
This is logical for personal folders: this way ensure that a user only use a single personal folder.
However, for roles which are assigned to shared folders, a user should be able to contribute to all the shared folders for the roles which are assigned to them, especially have a personal folder, and be able to contribute to a shared folder.
Would it be possible to implement this?
Comments
#1
Is there a way to get it working ?
#2
Here is a patch to merge all allowed directories from multiple assigned roles.
Permissions and allowed extensions are those from the smaller weight.
Please review
#3
subscribe
#4
This may result in complete rewrite of the configuration profiles.
1 to 1 relation is simpler, which is better.
#5
... which is far from real life !
To achieve such a result with 1 to 1 relation need too much deep and complex configuration profiles which is not really better.
If I transpose your comment for users and roles, a user should have only one role in a 1 to 1 simpler relation too, which would be better...
I don't think RBAC patterns go that way.
Please, can you think about it ?
#6
I don't know if this will help the discussion, but I found a way to do what I need without the patch. Just had to view the problem from a different angle. The approach I have taken is to have multiple shared folders under a single Profile. I define a single profile for all my authors and in the profile I define the folder path with:
php: $names = array(); foreach($user->og_groups as $group){array_push($names,$group[title]);}return $names;
With this configuration, each author sees a single folder for each Organic Group which they are a member. In the end, I like this better than the multiple profiles and roles because the configuration is taken care of in OG.
#7
subscribe
#8
Patch in Comment #2 works for me against 6.x-2.0-beta3 also. Thanks @heltem!
#9
@pgillis : Thank you very much for the great hint.
I changed it to this code :
php: $names = array(); foreach($user->roles as $group){array_push($names,$group);}return $names;
Now a user has access to his shared folder(s) corresponding the role(s) he belongs to.
#10
Hi, I've tried the code from #6 and #9 but I get the following error:
Undefined property: stdClass::$og_groups in eval() (line 1 of /var/www/getloc/sites/all/modules/imce/inc/imce.page.inc(767) : eval()'d code).
It looks like og_groups isn't loaded.
#11
#5: Agree - see as well my comment here:
http://drupal.org/node/1093734#comment-5193938
#12
#10: Drupal7? I had the same error there.
I managed to get it working in Drupal 7 with OG 7.x-dev from 15th of November 2011 (that one introduced og_get_groups_by_user()). In og/og.module I added a function at the end (take care: I have no idea of PHP actually, it fires a DB query for each group, but it works[TM])
<?php
function og_get_group_labels_by_user($account = NULL) {
if (empty($account)) {
global $user;
$account = $user;
}
$labels = array();
$gids = og_get_groups_by_user();
foreach ($gids as $group => $gid) {
$group = db_select('og', 'o')
->fields('o', array('label'))
->condition('gid', $gid)
->execute()
->fetchObject();
$labels[] = $group->label;
}
return $labels;
}
?>
And in IMCE I used:
php: $groups = og_get_group_labels_by_user(); return $groups;Tokens would be really nice in IMCE, really.