[cc-commits] [CC SVN] r12719 - in cchost/trunk: cchost_lib ccskins/shared/js
webmaster at creativecommons.org
webmaster at creativecommons.org
Thu Jun 4 04:09:04 EDT 2009
Author: fourstones
Date: 2009-06-04 08:09:04 +0000 (Thu, 04 Jun 2009)
New Revision: 12719
Added:
cchost/trunk/cchost_lib/cc-lic-waiver-opts.php
Modified:
cchost/trunk/cchost_lib/cc-handlers.inc
cchost/trunk/cchost_lib/cc-lics-chart.inc
cchost/trunk/cchost_lib/cc-remix.php
cchost/trunk/ccskins/shared/js/cchost.js
cchost/trunk/ccskins/shared/js/remix_search.js
Log:
offer more restrictive lics on remix (admin controlled)
Modified: cchost/trunk/cchost_lib/cc-handlers.inc
===================================================================
--- cchost/trunk/cchost_lib/cc-handlers.inc 2009-06-04 07:21:54 UTC (rev 12718)
+++ cchost/trunk/cchost_lib/cc-handlers.inc 2009-06-04 08:09:04 UTC (rev 12719)
@@ -88,6 +88,8 @@
CCEvents::AddHandler(CC_EVENT_MAP_URLS, array( 'CCLicense', 'OnMapUrls'), 'cchost_lib/cc-license.inc' );
CCEvents::AddHandler(CC_EVENT_FILTER_UPLOAD_PAGE, array( 'CCLicenseHV', 'OnFilterUploadPage'),'cchost_lib/cc-license.php' );
+CCEvents::AddHandler(CC_EVENT_MAP_URLS, array( 'CCLicWaiver', 'OnMapUrls'), 'cchost_lib/cc-lic-waiver-opts.php' );
+
CCEvents::AddHandler(CC_EVENT_GET_CONFIG_FIELDS, array( 'CCLogin' , 'OnGetConfigFields'), 'cchost_lib/cc-login.php' );
CCEvents::AddHandler(CC_EVENT_MAIN_MENU, array( 'CCLogin', 'OnBuildMenu'), 'cchost_lib/cc-login.php' );
CCEvents::AddHandler(CC_EVENT_MAP_URLS, array( 'CCLogin', 'OnMapUrls'), 'cchost_lib/cc-login.php' );
Added: cchost/trunk/cchost_lib/cc-lic-waiver-opts.php
===================================================================
--- cchost/trunk/cchost_lib/cc-lic-waiver-opts.php (rev 0)
+++ cchost/trunk/cchost_lib/cc-lic-waiver-opts.php 2009-06-04 08:09:04 UTC (rev 12719)
@@ -0,0 +1,95 @@
+<?php
+/*
+* Creative Commons has made the contents of this file
+* available under a CC-GNU-GPL license:
+*
+* http://creativecommons.org/licenses/GPL/2.0/
+*
+* A copy of the full license can be found as part of this
+* distribution in the file LICENSE.TXT.
+*
+* You may use the ccHost software in accordance with the
+* terms of that license. You agree that you are solely
+* responsible for your use of the ccHost software and you
+* represent and warrant to Creative Commons that your use
+* of the ccHost software will comply with the CC-GNU-GPL.
+*
+* $id$
+*
+*/
+
+/**
+* @package cchost
+* @subpackage upload
+*/
+if( !defined('IN_CC_HOST') )
+ die('Welcome to CC Host');
+
+require_once('cchost_lib/cc-admin.php');
+
+class CCAdminLicWaiverForm extends CCEditConfigForm
+{
+ function CCAdminLicWaiverForm()
+ {
+ $this->CCEditConfigForm('lic-waiver',CC_GLOBAL_SCOPE);
+ $this->SetModule(ccs(__FILE__));
+
+ $lics = CCDatabase::QueryRows('SELECT license_id,license_name FROM cc_tbl_licenses ORDER by license_name');
+ $licx = array();
+ foreach( $lics as $L )
+ $licx[$L['license_id']] = $L['license_name'];
+
+ $fields = array(
+ 'waivers' =>
+ array(
+ 'label' => _('Waivers'),
+ 'form_tip' => _('When a remix would default to one of these...') ,
+ 'formatter' => 'template',
+ 'macro' => 'multi_checkbox',
+ 'options' => $licx,
+ 'cols' => 2,
+ 'flags' => CCFF_POPULATE ),
+ 'licenses' =>
+ array(
+ 'label' => _('Alternatives'),
+ 'form_tip' => _('...then offer one of these...') ,
+ 'formatter' => 'template',
+ 'macro' => 'multi_checkbox',
+ 'options' => $licx,
+ 'cols' => 2,
+ 'flags' => CCFF_POPULATE ),
+ );
+
+ $this->AddFormFields($fields);
+ }
+
+ function PopulateValues(&$vals)
+ {
+ $vals['licenses'] = join(',',array_keys( $vals['licenses']));
+ $vals['waivers'] = join(',',array_keys( $vals['waivers']));
+ parent::PopulateValues($vals);
+ }
+}
+
+class CCLicWaiver
+{
+ function Admin()
+ {
+ require_once('cchost_lib/cc-page.php');
+ require_once('cchost_lib/cc-admin.php');
+ $title = _('Configure Waiver Alternatives');
+ CCAdmin::BreadCrumbs(true,array('url'=>'','text'=>$title));
+ CCPage::SetTitle($title);
+ $form = new CCAdminLicWaiverForm();
+ CCPage::AddForm( $form->GenerateForm() );
+ }
+
+ function OnMapUrls()
+ {
+ CCEvents::MapUrl( ccp('admin','waiver'), array('CCLicWaiver','Admin'),
+ CC_ADMIN_ONLY, ccs(__FILE__), '',
+ _('Manage license waiver alternatives') , CC_AG_UPLOAD );
+ }
+}
+
+?>
Property changes on: cchost/trunk/cchost_lib/cc-lic-waiver-opts.php
___________________________________________________________________
Added: keywords
+ id
Modified: cchost/trunk/cchost_lib/cc-lics-chart.inc
===================================================================
--- cchost/trunk/cchost_lib/cc-lics-chart.inc 2009-06-04 07:21:54 UTC (rev 12718)
+++ cchost/trunk/cchost_lib/cc-lics-chart.inc 2009-06-04 08:09:04 UTC (rev 12719)
@@ -36,6 +36,7 @@
'noncommercial_3' => 'nc-sampling+',
'attribution_3' => 'nc-sampling+',
'publicdomain' => 'nc-sampling+',
+ 'cczero' => 'nc-sampling+',
),
'sampling+' => array
@@ -48,6 +49,7 @@
'noncommercial_3' => 'nc-sampling+' ,
'attribution_3' => 'sampling+',
'publicdomain' => 'sampling+',
+ 'cczero' => 'sampling+',
),
'sampling' => array
@@ -60,6 +62,7 @@
'noncommercial_3' => 'nc-sampling+',
'attribution_3' => 'sampling',
'publicdomain' => 'sampling',
+ 'cczero' => 'sampling',
),
'share-alike_3' => array
@@ -72,6 +75,7 @@
'noncommercial_3' => 'by-nc-sa_3' ,
'attribution_3' => 'share-alike_3',
'publicdomain' => 'share-alike_3' ,
+ 'cczero' => 'share-alike_3',
),
'by-nc-sa_3' => array
@@ -84,6 +88,7 @@
'noncommercial_3' => 'by-nc-sa_3' ,
'attribution_3' => 'by-nc-sa_3' ,
'publicdomain' => 'by-nc-sa_3',
+ 'cczero' => 'by-nc-sa_3',
),
'noncommercial_3' => array
@@ -96,6 +101,7 @@
'noncommercial_3' => 'noncommercial_3' ,
'attribution_3' => 'noncommercial_3',
'publicdomain' => 'noncommercial_3',
+ 'cczero' => 'noncommercial_3',
),
'attribution_3' => array
@@ -108,6 +114,7 @@
'noncommercial_3' => 'noncommercial_3' ,
'attribution_3' => 'attribution_3',
'publicdomain' => 'attribution_3',
+ 'cczero' => 'attribution_3',
),
'publicdomain' => array
@@ -120,6 +127,7 @@
'noncommercial_3' => 'noncommercial_3' ,
'attribution_3' => 'attribution_3',
'publicdomain' => 'publicdomain' ,
+ 'cczero' => 'cczero',
),
'cc_zero' => array
@@ -131,7 +139,8 @@
'by-nc-sa_3' => 'by-nc-sa_3' ,
'noncommercial_3' => 'noncommercial_3' ,
'attribution_3' => 'attribution_3',
- 'publicdomain' => 'publicdomain' ,
+ 'publicdomain' => 'cc_zero' ,
+ 'cczero' => 'cczero',
),
);
@@ -147,7 +156,7 @@
'share-alike' => 'share-alike_3' ,
'by-nc-sa' => 'by-nc-sa_3' ,
'noncommercial' => 'noncommercial_3' ,
- 'attribution' => 'attribution_3',
+ 'attribution' => 'attribution_3',
);
if( array_key_exists($lic1,$update) )
Modified: cchost/trunk/cchost_lib/cc-remix.php
===================================================================
--- cchost/trunk/cchost_lib/cc-remix.php 2009-06-04 07:21:54 UTC (rev 12718)
+++ cchost/trunk/cchost_lib/cc-remix.php 2009-06-04 08:09:04 UTC (rev 12719)
@@ -274,12 +274,31 @@
/**
* Calculate the strictest license given a set of uploads
*
- * @param object &$form CCForm object
- * @param array &$rows Array of upload rows
*/
function RemixLicenses()
{
- $row = CCRemix::GetStrictestLicense($_GET['remix_sources'],$_GET['pool_sources']);
+ global $CC_GLOBALS;
+ $rowx = CCRemix::GetStrictestLicense($_GET['remix_sources'],$_GET['pool_sources']);
+ $row = array();
+ foreach( array('license_id','license_url','license_name') as $K )
+ $row[$K] = $rowx[$K];
+ $configs =& CCConfigs::GetTable();
+ $lic_waiver = $configs->GetConfig('lic-waiver');
+
+ if( !empty($lic_waiver) )
+ {
+ $waivers = array_keys($lic_waiver['waivers']);
+ if( in_array($row['license_id'],$waivers) )
+ {
+ $lics = array_keys($lic_waiver['licenses']);
+ if( !in_array($row['license_id'],$lics) )
+ $lics[] = $row['license_id'];
+ $lics = "'" . join("','",$lics) . "'";
+ $lics = CCDatabase::QueryRows('SELECT license_id,license_name,license_url FROM cc_tbl_licenses WHERE ' .
+ " license_id IN ({$lics}) ");
+ $row['options'] = $lics;
+ }
+ }
CCUtil::ReturnAjaxData($row);
}
Modified: cchost/trunk/ccskins/shared/js/cchost.js
===================================================================
--- cchost/trunk/ccskins/shared/js/cchost.js 2009-06-04 07:21:54 UTC (rev 12718)
+++ cchost/trunk/ccskins/shared/js/cchost.js 2009-06-04 08:09:04 UTC (rev 12719)
@@ -34,7 +34,7 @@
if( url.match(/\?/) )
_q_ = '&';
url += _q_ + '_cache_buster=' + new Date().getTime();
- //ajax_debug(url);
+ ajax_debug(url);
this._old_request_init(url,options);
};
Modified: cchost/trunk/ccskins/shared/js/remix_search.js
===================================================================
--- cchost/trunk/ccskins/shared/js/remix_search.js 2009-06-04 07:21:54 UTC (rev 12718)
+++ cchost/trunk/ccskins/shared/js/remix_search.js 2009-06-04 08:09:04 UTC (rev 12719)
@@ -98,12 +98,35 @@
},
onLicenseResults: function(resp,json) {
- $('license_info').innerHTML = str_remix_lic.replace('%s','<a href="' + json.license_url
- + '">' + json.license_name + '</a>' );
+ if( json.options )
+ {
+ var html = '<select id="licpicker">';
+ json.options.each( function(lic) {
+ html += '<option value="' + lic.license_id + '"';
+ if( lic.license_id == json.license_id )
+ {
+ html += ' selected="selected" ';
+ }
+ html += '>' + lic.license_name + '</option>';
+ } );
+ html += '</select>';
+ $('license_info').innerHTML = 'Your remix will be licensed as: ' + html;
+ Event.observe( 'licpicker', 'change', this.onLicenseChange.bind(this) );
+ }
+ else
+ {
+ $('license_info').innerHTML = str_remix_lic.replace('%s','<a href="' + json.license_url
+ + '">' + json.license_name + '</a>' );
+ }
$('license_info_container').style.display = 'block';
$('upload_license').value = json.license_id;
},
+ onLicenseChange: function(ev) {
+ var box = $('licpicker');
+ $('upload_license').value = box.options[ box.selectedIndex ].value;
+ },
+
onToggleBox: function(ev){
this._toggle_open();
},
More information about the cc-commits
mailing list