summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-11-02 10:16:06 -0800
committerBrion Vibber <brion@pobox.com>2009-11-02 10:16:06 -0800
commit86560eeb3db60f39b0e1f3ef011819e5f3172101 (patch)
tree7b4ec8fb83d3c9d513fe20c5ef7d796ff8301260
parent1cf67f4f714be45cf93302f223a58c65402e3038 (diff)
parent58b9ce5946c5fea9b6f1a9f1c0c9641c5104d769 (diff)
Merge commit 'refs/merge-requests/1900' of git://gitorious.org/statusnet/mainline into integration
-rw-r--r--lib/util.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index ed7e10f6b..bf7282858 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1370,9 +1370,28 @@ function common_memcache()
}
}
+function common_license_terms($uri)
+{
+ if(preg_match('/creativecommons.org\/licenses\/([^\/]+)/', $uri, $matches)) {
+ return explode('-',$matches[1]);
+ }
+ return array($uri);
+}
+
function common_compatible_license($from, $to)
{
+ $from_terms = common_license_terms($from);
+ // public domain and cc-by are compatible with everything
+ if(count($from_terms) == 1 && ($from_terms[0] == 'publicdomain' || $from_terms[0] == 'by')) {
+ return true;
+ }
+ $to_terms = common_license_terms($to);
+ // sa is compatible across versions. IANAL
+ if(in_array('sa',$from_terms) || in_array('sa',$to_terms)) {
+ return count(array_diff($from_terms, $to_terms)) == 0;
+ }
// XXX: better compatibility check needed here!
+ // Should at least normalise URIs
return ($from == $to);
}