Table_File::findByItem()
Files, unlike Items, by default, do not have a private / public setting.
But you can easily modify the related views to display download
links based on the Items private/public settings and user
permissions.
Something along the lines of:
<?php
$user = current_user();
if(!$item['public'] && $user) : ?>
<!-- download
link goes here -->
<?php endif; ?>
All the best,
Anurag
Dear Luk,
I'd be hesitant to modify the DB and/or Omeka core, as this could
make upgrading a real nightmare. Since a file can have associated
metadata - at least DublinCore - I am wondering whether you could
utilize one of those, because it would be fairly easy to filter by
that. For example in the extended DC set there is an Audience
field (as per description: A class of entity for whom the
resource is intended or useful. ). Although this approach is
perhaps not the cleanest approach in terms of archival standards
;)
All the best,
Anurag
$select = apply_filters($this->_getHookName('select_sql'), $select);
Dear Luk,
Maybe I am misunderstanding what you are trying to achieve, but
isn't the following scenario what you want to do?
In the DC metadata associated to the file you use the Audience field to contain your desired audience i.e. "public" / "private"
Then in the relevant views you simply check what the metadata
status is for each file and if the item is set to "private"
and there is no logged in user, the link or image does not get
displayed. Since the check happens server side, a "private"
image would never get displayed on the site for a not authorized
i.e. not logged in user.
The code in items/view could look something along these
lines (I am assuming as I did not test it):
// get user
$user = current_user();
// get associated files
$itemFiles = $item->Files;
foreach($itemFiles as $file) {
$audience = metadata($file, array('Dublin Core', 'Audience');
if($audience == "public" ) {
// display "public" file or output link to download
} else {
if($user) {
// display "private" file or output link to download
}
}
}
All the best,--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omeka-dev+...@googlegroups.com.
To post to this group, send email to omek...@googlegroups.com.
Visit this group at https://groups.google.com/group/omeka-dev.
For more options, visit https://groups.google.com/d/optout.