]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Better license check.
authorStephen Paul Weber <singpolyma@singpolyma.net>
Thu, 16 Apr 2009 14:57:35 +0000 (10:57 -0400)
committerStephen Paul Weber <singpolyma@singpolyma.net>
Sat, 24 Oct 2009 01:22:26 +0000 (21:22 -0400)
Tokenise CC license parts and check for compatability.
Fallback is old directly-equal test.

lib/util.php

index b6e89f0bd9cd8fb364083a28cb90716e3f4ce160..00696583eea7b1d14dcd24fb0332110dd8aa877a 100644 (file)
@@ -1360,9 +1360,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);
 }