Index: trunk/extensions/UploadWizard/UploadWizard.php |
— | — | @@ -86,6 +86,8 @@ |
87 | 87 | $wgRemoveGroups['sysop'][] = 'upwizcampeditors'; |
88 | 88 | |
89 | 89 | $wgDefaultUserOptions['upwiz_deflicense'] = 'default'; |
| 90 | +$wgDefaultUserOptions['upwiz_def3rdparty'] = 'default'; |
| 91 | +$wgDefaultUserOptions['upwiz_deflicensetype'] = 'default'; |
90 | 92 | |
91 | 93 | // Init the upload wizard config array |
92 | 94 | // UploadWizard.config.php includes default configuration |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -500,16 +500,29 @@ |
501 | 501 | */ |
502 | 502 | public static function onGetPreferences( User $user, array &$preferences ) { |
503 | 503 | if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) { |
504 | | - $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' ); |
505 | 504 | $licenseConfig = UploadWizardConfig::getSetting( 'licenses' ); |
506 | 505 | |
| 506 | + $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' ); |
| 507 | + |
| 508 | + $preferences['upwiz_deflicensetype'] = array( |
| 509 | + 'type' => 'radio', |
| 510 | + 'label-message' => 'mwe-upwiz-prefs-def-licensetype', |
| 511 | + 'section' => 'uploads', |
| 512 | + 'options' => array( |
| 513 | + $defOption, |
| 514 | + wfMsg( 'mwe-upwiz-prefs-def-license-ownwork' ) => 'ownwork', |
| 515 | + wfMsg( 'mwe-upwiz-prefs-def-license-3rdparty' ) => 'thirdparty', |
| 516 | + ) |
| 517 | + ); |
| 518 | + |
| 519 | + $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' ); |
| 520 | + |
507 | 521 | $licenses = array(); |
508 | 522 | |
509 | 523 | foreach ( $ownWork['licenses'] as $license ) { |
510 | 524 | $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license; |
511 | 525 | } |
512 | 526 | |
513 | | - $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' ); |
514 | 527 | $licenses = array_merge( $defOption, $licenses ); |
515 | 528 | |
516 | 529 | $preferences['upwiz_deflicense'] = array( |
— | — | @@ -518,6 +531,23 @@ |
519 | 532 | 'section' => 'uploads', |
520 | 533 | 'options' => $licenses |
521 | 534 | ); |
| 535 | + |
| 536 | + $thirdParty = UploadWizardConfig::getSetting( 'licensesThirdParty' ); |
| 537 | + |
| 538 | + $licenses = array(); |
| 539 | + |
| 540 | + foreach ( UploadWizardConfig::getThirdPartyLicenses() as $license ) { |
| 541 | + $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license; |
| 542 | + } |
| 543 | + |
| 544 | + $licenses = array_merge( $defOption, $licenses ); |
| 545 | + |
| 546 | + $preferences['upwiz_def3rdparty'] = array( |
| 547 | + 'type' => 'radio', |
| 548 | + 'label-message' => 'mwe-upwiz-prefs-def-3rdparty', |
| 549 | + 'section' => 'uploads', |
| 550 | + 'options' => $licenses |
| 551 | + ); |
522 | 552 | } |
523 | 553 | |
524 | 554 | return true; |
Index: trunk/extensions/UploadWizard/includes/UploadWizardConfig.php |
— | — | @@ -111,4 +111,22 @@ |
112 | 112 | return array(); |
113 | 113 | } |
114 | 114 | |
| 115 | + /** |
| 116 | + * Get a list of available third party licenses from the config. |
| 117 | + * |
| 118 | + * @since 1.2 |
| 119 | + * |
| 120 | + * @return array |
| 121 | + */ |
| 122 | + public static function getThirdPartyLicenses() { |
| 123 | + $thirdParty = self::getSetting( 'licensesThirdParty' ); |
| 124 | + $licenses = array(); |
| 125 | + |
| 126 | + foreach ( $thirdParty['licenseGroups'] as $group ) { |
| 127 | + $licenses = array_merge( $licenses, $group['licenses'] ); |
| 128 | + } |
| 129 | + |
| 130 | + return $licenses; |
| 131 | + } |
| 132 | + |
115 | 133 | } |
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php |
— | — | @@ -148,6 +148,18 @@ |
149 | 149 | $config['licensesOwnWork']['defaults'] = array( $defaultLicense ); |
150 | 150 | } |
151 | 151 | |
| 152 | + $thirdPartyDefault = $this->getUser()->getOption( 'upwiz_def3rdparty' ); |
| 153 | + |
| 154 | + if ( $thirdPartyDefault !== 'default' && in_array( $thirdPartyDefault, UploadWizardConfig::getThirdPartyLicenses() ) ) { |
| 155 | + $config['licensesThirdParty']['defaults'] = array( $thirdPartyDefault ); |
| 156 | + } |
| 157 | + |
| 158 | + $licenseTypeDefault = $this->getUser()->getOption( 'upwiz_deflicensetype' ); |
| 159 | + |
| 160 | + if ( $licenseTypeDefault !== 'default' && $config['ownWorkOption'] === 'choice' ) { |
| 161 | + $config['ownWorkOption'] = $licenseTypeDefault === 'ownwork' ? 'own' : 'notown'; |
| 162 | + } |
| 163 | + |
152 | 164 | $this->getOutput()->addScript( |
153 | 165 | Skin::makeVariablesScript( |
154 | 166 | array( |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -366,6 +366,10 @@ |
367 | 367 | 'prefs-uploads' => 'Uploads', |
368 | 368 | 'mwe-upwiz-prefs-def-license' => 'Default own work license', |
369 | 369 | 'mwe-upwiz-prefs-def-license-def' => 'Use whatever the default is', |
| 370 | + 'mwe-upwiz-prefs-def-licensetype' => 'Default license type', |
| 371 | + 'mwe-upwiz-prefs-def-3rdparty' => 'Default third party license', |
| 372 | + 'mwe-upwiz-prefs-def-license-ownwork' => 'Own work', |
| 373 | + 'mwe-upwiz-prefs-def-license-3rdparty' => 'Third party', |
370 | 374 | ); |
371 | 375 | |
372 | 376 | /** Message documentation (Message documentation) |