Nischayn22 has submitted this change and it was merged.

Change subject: Check protection status of titles in details step
......................................................................


Check protection status of titles in details step

Improved version of I3d8e170f90e03a9. Thanks to TheDJ for that patch.

Bug: 37107
Change-Id: Ic951851ddb46b5a80af0ef4ce248a3fdb46ea1b4
---
M resources/mw.DestinationChecker.js
M resources/mw.UploadWizardDetails.js
2 files changed, 23 insertions(+), 11 deletions(-)

Approvals:
  Rasel160: Looks good to me, but someone else must approve
  Nischayn22: Verified; Looks good to me, approved
  TheDJ: Verified; Looks good to me, but someone else must approve



diff --git a/resources/mw.DestinationChecker.js 
b/resources/mw.DestinationChecker.js
index 38a43ba..a49d844 100644
--- a/resources/mw.DestinationChecker.js
+++ b/resources/mw.DestinationChecker.js
@@ -208,7 +208,8 @@
                // XXX do not use iiurlwidth as it will create a thumbnail
                var params = {
                        'titles': title,
-                       'prop':  'imageinfo',
+                       'prop':  'info|imageinfo',
+                       'inprop': 'protection',
                        'iiprop': 'url|mime|size',
                        'iiurlwidth': 150
                };
@@ -236,9 +237,20 @@
                        // If file found on another repository, such as when 
the wiki is using InstantCommons: page with a key of -1, plus imageinfo
                        // If file found on this repository: page with some 
positive numeric key
                        if ( data.query.pages[-1] && 
!data.query.pages[-1].imageinfo ) {
-                               // No conflict found on any repository this 
wiki uses
-                               result = { isUnique: true };
-
+                               var protection = 
data.query.pages[-1].protection;
+                               if ( protection && protection.length > 0 ) {
+                                       $.each( protection, function( i, val ) {
+                                               if ( $.inArray( val.level, 
mw.config.get( 'wgUserGroups' ) ) === -1 ) {
+                                                       result = {
+                                                               isUnique: true,
+                                                               isProtected: 
true
+                                                       };
+                                               }
+                                       } );
+                               } else {
+                                       // No conflict found on any repository 
this wiki uses
+                                       result = { isUnique: true };
+                               }
                        } else {
 
                                for ( var page_id in data.query.pages ) {
@@ -275,7 +287,6 @@
                                        break;
                                }
                        }
-
                        _this.cachedResult[title] = result;
                        callback( { 'unique': result } );
                };
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index e1859bf..921c87d 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -739,7 +739,7 @@
                var _this = this;
                var $errorEl = _this.$form.find( 'label[for=' + _this.titleId + 
'].errorTitleUnique' );
 
-               if ( result.unique.isUnique && result.blacklist.notBlacklisted 
) {
+               if ( result.unique.isUnique && result.blacklist.notBlacklisted 
&& !result.unique.isProtected ) {
                        $j( _this.titleInput ).data( 'valid', true );
                        $errorEl.hide().empty();
                        _this.ignoreWarningsInput = undefined;
@@ -767,11 +767,13 @@
                                errHtml = mw.msg( 
'mwe-upwiz-fileexists-replace-no-link', titleString );
                        }
 
-                       $errorEl.html( errHtml ).show();
+                       $errorEl.text( errHtml );
+               } else if ( result.unique.isProtected ) {
+                       errHtml = mw.msg( 'mwe-upwiz-error-title-protected' );
+                       $errorEl.text( errHtml );
                } else {
                        errHtml = mw.msg( 'mwe-upwiz-blacklisted', titleString 
);
-
-                       $errorEl.html( errHtml );
+                       $errorEl.text( errHtml );
 
                        var completeErrorLink = $j( '<span 
class="contentSubLink"></span>' ).msg(
                                'mwe-upwiz-feedback-blacklist-info-prompt',
@@ -805,9 +807,8 @@
 
                                $errorEl.append( '&nbsp;&middot;&nbsp;' 
).append( feedbackLink );
                        }
-
-                       $errorEl.show();
                }
+               $errorEl.show();
        },
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/56371
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic951851ddb46b5a80af0ef4ce248a3fdb46ea1b4
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Nischayn22 <nischay...@gmail.com>
Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org>
Gerrit-Reviewer: Nischayn22 <nischay...@gmail.com>
Gerrit-Reviewer: Rasel160 <rasel...@gmail.com>
Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to