Index: trunk/extensions/UploadWizard/UploadWizard.php |
— | — | @@ -70,6 +70,7 @@ |
71 | 71 | $wgHooks['ResourceLoaderRegisterModules'][] = 'UploadWizardHooks::resourceLoaderRegisterModules'; |
72 | 72 | $wgHooks['CanonicalNamespaces'][] = 'UploadWizardHooks::canonicalNamespaces'; |
73 | 73 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'UploadWizardHooks::onSchemaUpdate'; |
| 74 | +$wgHooks['GetPreferences'][] = 'UploadWizardHooks::onGetPreferences'; |
74 | 75 | |
75 | 76 | $wgAvailableRights[] = 'upwizcampaigns'; |
76 | 77 | |
— | — | @@ -84,6 +85,8 @@ |
85 | 86 | $wgAddGroups['sysop'][] = 'upwizcampeditors'; |
86 | 87 | $wgRemoveGroups['sysop'][] = 'upwizcampeditors'; |
87 | 88 | |
| 89 | +$wgDefaultUserOptions['upwiz_deflicense'] = 'default'; |
| 90 | + |
88 | 91 | // Init the upload wizard config array |
89 | 92 | // UploadWizard.config.php includes default configuration |
90 | 93 | // any value can be modified in localSettings.php by setting $wgUploadWizardConfig['name'] = 'value; |
Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -9,6 +9,9 @@ |
10 | 10 | // Upload wizard has an internal debug flag |
11 | 11 | 'debug' => false, |
12 | 12 | |
| 13 | + // Enable or disable the default upload license user preference |
| 14 | + 'enableLicensePreference' => true, |
| 15 | + |
13 | 16 | // File extensions acceptable in this wiki |
14 | 17 | 'fileExtensions' => $wgFileExtensions, |
15 | 18 | |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -486,5 +486,41 @@ |
487 | 487 | |
488 | 488 | return true; |
489 | 489 | } |
| 490 | + |
| 491 | + /** |
| 492 | + * Adds the preferences of UploadWizard to the list of available ones. |
| 493 | + * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences |
| 494 | + * |
| 495 | + * @since 1.2 |
| 496 | + * |
| 497 | + * @param User $user |
| 498 | + * @param array $preferences |
| 499 | + * |
| 500 | + * @return true |
| 501 | + */ |
| 502 | + public static function onGetPreferences( User $user, array &$preferences ) { |
| 503 | + if ( UploadWizardConfig::getSetting( 'enableLicensePreference' ) ) { |
| 504 | + $ownWork = UploadWizardConfig::getSetting( 'licensesOwnWork' ); |
| 505 | + $licenseConfig = UploadWizardConfig::getSetting( 'licenses' ); |
| 506 | + |
| 507 | + $licenses = array(); |
| 508 | + |
| 509 | + foreach ( $ownWork['licenses'] as $license ) { |
| 510 | + $licenses[wfMsg( $licenseConfig[$license]['msg'] )] = $license; |
| 511 | + } |
| 512 | + |
| 513 | + $defOption = array( wfMsg( 'mwe-upwiz-prefs-def-license-def' ) => 'default' ); |
| 514 | + $licenses = array_merge( $defOption, $licenses ); |
| 515 | + |
| 516 | + $preferences['upwiz_deflicense'] = array( |
| 517 | + 'type' => 'radio', |
| 518 | + 'label-message' => 'mwe-upwiz-prefs-def-license', |
| 519 | + 'section' => 'uploads', |
| 520 | + 'options' => $licenses |
| 521 | + ); |
| 522 | + } |
490 | 523 | |
| 524 | + return true; |
| 525 | + } |
| 526 | + |
491 | 527 | } |
Index: trunk/extensions/UploadWizard/includes/specials/SpecialUploadWizard.php |
— | — | @@ -142,6 +142,12 @@ |
143 | 143 | |
144 | 144 | $config['thanksLabel'] = $this->getPageContent( $config['thanksLabelPage'], true ); |
145 | 145 | |
| 146 | + $defaultLicense = $this->getUser()->getOption( 'upwiz_deflicense' ); |
| 147 | + |
| 148 | + if ( $defaultLicense !== 'default' ) { |
| 149 | + $config['licensesOwnWork']['defaults'] = array( $defaultLicense ); |
| 150 | + } |
| 151 | + |
146 | 152 | $this->getOutput()->addScript( |
147 | 153 | Skin::makeVariablesScript( |
148 | 154 | array( |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -360,8 +360,12 @@ |
361 | 361 | 'mw-coolcats-confirm-new-title' => 'Confirm new category', |
362 | 362 | 'mw-coolcats-confirm-new' => 'It looks like you are trying to add a new category, "$1". Be aware:<ul><li>Categories should usually be in English.</li><li>Most new categories should be a subcategory of an existing category.</li></ul>Generally, only experts should create a category.', |
363 | 363 | 'mw-coolcats-confirm-new-ok' => 'Add this category anyway', |
364 | | - 'mw-coolcats-confirm-new-cancel' => 'Never mind' |
| 364 | + 'mw-coolcats-confirm-new-cancel' => 'Never mind', |
365 | 365 | |
| 366 | + // Preferences |
| 367 | + 'prefs-uploads' => 'Uploads', |
| 368 | + 'mwe-upwiz-prefs-def-license' => 'Default own work license', |
| 369 | + 'mwe-upwiz-prefs-def-license-def' => 'Use whatever the default is', |
366 | 370 | ); |
367 | 371 | |
368 | 372 | /** Message documentation (Message documentation) |