I'm using Domain Access to run two sites that occasionally share content and media. To organize and implement the media I am using the Media module. Is there any way to restrict an uploaded image or video to one of the domains? I haven't seen it mentioned anywhere...

Comments

agentrickard’s picture

Category: support » feature
Status: Active » Postponed

No. That would require the File Access API to be completed first.

kapow99504’s picture

Ok, thanks, I thought I had missed something

agentrickard’s picture

mstrelan’s picture

Status: Postponed » Active

File entity access API was committed in October 2012.

agentrickard’s picture

So that suggests a Domain Files module. Anyone care to write it?

mstrelan’s picture

I'm working on a project that may require it, so I may be able to take a stab at it. Will probably need some guidance. Any idea off the top of your head what's required / where to start?

agentrickard’s picture

It would be a Domain Files module, and it needs the following elements (at the least).

* Data storage for the file access records. You could, perhaps, use Field API, though DA does not. If you don't use Field API, you need a {domain_file} table that stores your access information. Model it on {node_access}.

* A UI for selecting file access. Either a custom field or a FieldAPI field. Custom fields are easier to control, IMO.

* Implement hook_file_entity_access() for individual file actions.

* Implement hook_query_file_entity_access_alter() for file listings.

* Optional: a listing page for viewing files per domain.

mstrelan’s picture

Version: 7.x-3.3 » 7.x-3.x-dev

I've started a sandbox project over at http://drupal.org/sandbox/mstrelan/1987490 which is working under the most basic conditions. Any feedback would be greatly appreciated.

TODO list

  • Default behaviour when user doesn't have access to set domain access
  • Implement hook_query_file_entity_access_alter() for file listings
  • "Restrict node views for administrators" doesn't apply to files and perhaps should
  • Allow for different defaults per file type

Other considerations

  • Review if any additional code from domain_form_alter() is relevant, didn't copy it all across. I suspect most of it is handling for edge cases which I'll eventually need.
  • Does this module need to do anything about create/delete/update actions in hook_file_entity_access()?
  • What happens to media files added from YouTube, etc, or from remote URLs?
  • Perhaps media files added from nodes should inherit domain access settings from the node. Not sure I want to get in to that especially since files will be saved before the node is saved.
  • Perhaps media files should just default to "all affiliates" and can be overridden after saving.
agentrickard’s picture

You probably also need hook_field_extra_fields, assuming you don't use FieldAPI fields for data storage.

bluegeek9’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support of this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project, including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.