Hi,
I would like to have the following situation:
I want to configure imagepicker so that when a new user is created and added to a certain role, all his images will be public or at least automatically added to a public group.
Unless I'm missing something the user now needs to select explicitely to add it to a public group. Also if he has no group yet, he has to create it himself.
This is too much hassle. I just want to create this user and all images he uploads should be put into a certain group by default, which should be seen by all other users in the same group.
I hope something like this is possible :)
----------------------------
JGO | http://www.e2s.be
----------------------------
Comments
Comment #1
hutch commentedAs this is a very specific requirement for a very specific site I would suggest that you need to a a site-specific module that utilises hook_user_insert and any other related hooks. This 'glue' module would carry out the work you need whenever a user is created.
See http://api.drupal.org/api/group/hooks/6 for details.
You might also be able to do this using Drupal 'actions'.
Comment #2
JGO commentedNot sure if it's very specific. I'm just looking for an easy way to share images between all users within a certain role.
I think this should be possible by default.
Anyway I could probably hide the checkmark from the group and always check it myself in the code. But I don't know which hook I need to alter to get into the data of the iframe.
To do this in a form I normally use hook_form_alter. You know where I can get to the iframe data ?
Comment #3
hutch commentedYou can define a group as public and define which roles can see 'public', this ability is already there, you may need to configure it under admin/settings.
You can identify which form to alter by finding the form_id which can be seen in the iframe source code, for instance the form_id for the upload form is
Another approach might be to add module_invoke_all() to function imagepicker_upload_form_submit() circa line 256
old code:
new code:
Then create a function in your module, eg function mymodule_imagepicker_upload_extra($img_id) and do stuff there
If you do try the module_invoke_all method and it works let me know and I'll add the
module_invoke_all('imagepicker_upload_extra', $nextimgid);line to the development version.Comment #4
JGO commentedHi,
Thank you for your input :)
I was thinking of a better method:
Add an option to imagepicker: Share images between roles.
Which would list all images under "browse" if you're from the same role. So then the users in the same role can edit/delete the images if they are in the same role as the uploader.
I can hardly image that there don't exist any other sites where you have multiple webadmins, and in that case all are able do update the site's content.
So when my colleague updates a page with an image, he probably wants to be able to take or delete the image too on updating a topic.
Another way would be to have groups that are automatically shared between roles with an extra option to give all permissions.
Comment #5
JGO commentedHi,
Could you please add:
// external functions
module_invoke_all('imagepicker_upload_extra', $nextimgid);
It's better than have no control at all ;)
Comment #6
hutch commentedWell yes, but where?
Comment #7
JGO commentedHi,
I added is as you suggested in your previous posting (#3)
This seems to do what I want.
If you could now add an option that other users can edit public images, than it would rock and 100% do what I want.
Isn't this a possible feature to let other users edit public images as well? Don't see what would be wrong with adding this as an optional setting for a group for example.
Something like: Images in this group can be editted by everyone.
Other ideas are welcome too, to achieve the same result.
Comment #8
hutch commentedSorry, I had my mind on other things. I will add the module_invoke_all lines to the next dev release and I will see what I can do with public images, possibly another permission or extend groups.
Comment #9
Rustan commentedIt would be great to have a global public group, so that each user does not have to add it. Ideal would be that the admin could choose to activate that global public group or not.
A setting for each user for what group should be premarked for each new upload would also be great.
For example on a site with a group of editors that should be allowed to edit all images this would be very useful.
Comment #10
Rustan commentedPerhaps related is the display of public images. When browsing your own images you can sort on groups, but that option is not available for the public files. Can this be added?
Taking this a bit further, if the administrator can create several global public groups this option would be even more useful.
Comment #11
hutch commentedI have added external hook 'imagepicker_upload_extra' so that other modules can do things to the uploaded image. The image id is passed to any functions using this feature. This is available in 2.x-dev
As far as global public groups goes, there are all sorts of permissions issues.
Every image has an owner and so does every group. The 'global public groups' concept does not fit in at all as far as I can see, if anyone can think of a way to do that without breaking existing sites I will be happy to review a patch.
I will look into adding a dropdown to select public groups. If anyone would like to attempt it I'll be happy to review any patches.
Comment #12
hutch commentedAdding a dropdown to select public groups is in 2.x-dev along with a number of other fixes and improvements.
Comment #13
Rustan commentedThanks! #12 works fine for me, very useful.
Another variant of public groups:
In settings for groups, add another set of checkboxes for roles like "Add public group roles". The new option would be "Allow these roles to upload images to this group".
With this an admin could set up a number of public groups without having duplication of groups (10 different "logo" categories from different editors would defeat the purpose of having easy access through categorization in groups).
Could this work?
Comment #14
hutch commentedAt the moment we have 2 types of group, 'private' (0) and 'public' (1) It *might* be possible to add a third, let's call it 'global public' (3)
Only an administrator in or under admin/settings/imagepicker/groups couild create this type of group and give it role permissions.
These groups would appear along with the existing group choices (but specially marked) wherever users add/edit images. Under browse/list images these would appear under Browse public.
So the images categorized in this way continue to have an owner (whoever uploaded them in the first place) but the new group type would always belong to admin with user id 1.
Is this what you have in mind?
Comment #15
Rustan commentedNot quite what I had in mind I think.
I was thinking that a role gets permission to upload to a group, and when members in that role upload an image it will be treated like if the group owner had uploaded it. This would make the group owner have access to make changes to it, or delete it. I hoped it would be easy to integrate with the current system :)
Your way would be useful as well, just a bit different.
Comment #16
hutch commentedYou said:
This of course means that the original uploader would no longer be able to edit/delete. Admin can edit/delete anything anyway, I can see conflict on the horizon if you deny the original uploader the right to edit/delete. The existing code uploads the file, creates thumbnails and writes the thumbnails, the resized image and the original to the 'home' of the user. If the image is subsequently added to a global_public category it would have to be copied over to admin's 'home' and deleted from the original home and the database entry rewritten as well as any other group relationships deleted. If subsequent to that a change of mind takes place you have lost the original owner so you have in effect an orphan image.
I can see a use for an ownership change function some time in the future, possibly as part of a 'bulk ops' feature. If a user leaves for instance their images could be transferred to someone else. But that's in the future.
Anyway I will probably make a start at a global_public feature, If I can get it to work sensibly.
Comment #17
Rustan commentedOk, big thanks!
Comment #18
JGO commentedI'm glad people are working on this :)
It would indeed be handy if for example a certain Group is linked to user group. So that all user from a certain usergroup have full rights to the images posted.
This comes in handy when multiple people in the same usergroup are allowed to edit each other's site content.
Comment #19
JGO commentedHi,
I tested the new features.
What I'm still missing is some sort of global setting to make all images uploaded be automatically available to everyone (in same role or something).
When a user now forgets to select the checkbox to add it to a group, then the image is not available for other users.
I added this myself using your hook. But it would be nice if a more generic way was available for this.
Something like global groups. Now every group is linked to a user.
If a group could be linked to a role, that would be awesome. So that people in the same roles see the same group(s).
For example I add a group "All Images"
Now I assign it to the roles: Webadmin1 and Webadmin2
Whenever someone with one of those roles upload an image, it will be shared between users in these roles
Each user in this role can have full access to the image (edit/add/delete/etc)
Some additional checkbox that will automatically do the above, so that the users don't need to explicitly add it to a group each time
----------------------------
JGO | http://www.e2s.be
----------------------------
Comment #20
hutch commented