I've created a patch to do just that.

CommentFileSizeAuthor
#5 669646-2.diff2.47 KBdarrick
#3 669646-fix.diff949 bytesdarrick
#1 669646.diff2.28 KBdarrick

Comments

darrick’s picture

StatusFileSize
new2.28 KB
balleyne’s picture

Assigned: Unassigned » balleyne
Status: Active » Fixed

Thanks! Applied the patch, just committed.

darrick’s picture

Status: Fixed » Active
StatusFileSize
new949 bytes

Cool. Thanks. I did just notice today a slight error in the patch. At the last minute I changed the class name creativecommons_views_handler_filter_license to creativecommons_views_handler_filter_license_uri to make the naming all nice and proper. However, I didn't test it. This new attached patch fixes the error.

balleyne’s picture

Status: Active » Needs work

Ah, thanks.

On further review though, I'm wondering if you know how we could filter by license type rather than license uri. The current filter doesn't work across jurisdictions or license versions. I'm not very familiar with the Views API, which is why I hadn't added this filter before (thanks for your help!), but I'm not sure how to go about making the change.

The problem: I can filter by BY-SA 3.0 Unported, which adds this to the query: (creativecommons_node.license_uri in ('http://creativecommons.org/licenses/by-sa/3.0/')) -- but that won't match against my content that's licensed BY-SA 2.5 Canada, or when 3.5/4.0 comes out, it will only match one particular version of the license. (I have made another adjustment to your code so that it loads the default jurisdiction for the filter value options properly.)

There are a couple functions in the module which might be useful...
* creativecommons_get_license_type_from_uri($uri)
* creativecommons_generic_license_name($full_name)

Those functions can easily be used to make the value options generic license types rather than specific license names and URIs. It's easy enough to change the value options, but I don't know how to change the way that the filter determines matches... I think it needs to do something like in line 1943 of the main module file, that is, the resulting SQL should be something along the lines of "WHERE license_uri LIKE 'http://creativecommons.org/%/%s/%" with the license type as %s.

Do you know how to do this? I imagine it could be done by either customizing the license_uri filter in some way to make a more sophisticated match, or by creating a license type field and performing a filter on that? I'd be happy to do the work, just not quite sure how to do it... any ideas?

For now, I've applied your fix and my jurisdiction change. A filter on license URIs is still a nice step in the right direction.

darrick’s picture

StatusFileSize
new2.47 KB

Okay. Try this out.

balleyne’s picture

Status: Needs work » Fixed

Wow, thanks. Applied the patch, with a couple minor modifications -- that's exactly what I was trying to do! Much appreciated.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.