Hey there, had a project requirement where the individual privacy type dropdowns needed to be displayed and allow a user to set the state of each without leaving the page. So, in a separate module I implemented the appropriate Drupal behaviors, AJAX, page callback, and . I could always just keep it custom or submit a separate module, but I thought this would be a great feature for the core module and something that others are likely to want.
For a themer or developer, outputting this individual privacy type setting is easy:
<?php print theme('privacypu_change_state', 'privacy_type_machine_name'); ?>
There is an optional additional parameter for $label to optionally display the privacy type's human readable name, presently defaulted to false.
If this sounds like something that you might like to include into the core of this module, lemme know and I'll migrate the changes and bake up a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | privacypu_change_state.zip | 2.56 KB | vishun |
Comments
Comment #1
vishun commented*and form.
Comment #2
gilgabar commentedThat sounds awesome. Without seeing it I would say it sounds like it can live in a submodule that can be enabled for folks that want to use it, though if it makes more sense directly integrated that would be fine too. Definitely upload some code and we can go from there.
Comment #3
vishun commentedAttached is the functionality separated into it's own module. I re-added the specification of a UID so that you can provide context in situations like user profile templates. Also, the default for outputting labels has been switched to true as that is likely more common.
When a privacy type is set to null or not provided, it will output all privacy type dropdowns. When a UID is not provided, it will assume the output of the dropdown is supposed to relate to the current user.
Development of this functionality was sponsored by Pint Head
Outputs all privacy type dropdowns for the current user with labels
Outputs a specific privacy type with a UID for context and no labels. Providing the UID ensures that the privacy state will only appear if the current user is the same as the user profile being viewed, for instance.
An example implementation that checks if the current user should be able to view an area of content and also attempts to display the privacy setting dropdown when necessary.
user-profile.tpl.php