[MediaWiki-commits] [Gerrit] Campaigns are only for logged in users - change (mediawiki...ContentTranslation)

2015-05-25 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Campaigns are only for logged in users
..


Campaigns are only for logged in users

Bug: T100014
Change-Id: I0365d1366fcf5c62193f878c1e73435d9b4c0b98
---
M modules/stats/ext.cx.stats.js
M specials/SpecialContentTranslation.php
2 files changed, 18 insertions(+), 8 deletions(-)

Approvals:
  KartikMistry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/stats/ext.cx.stats.js b/modules/stats/ext.cx.stats.js
index 234ea4f..1e1e2c9 100644
--- a/modules/stats/ext.cx.stats.js
+++ b/modules/stats/ext.cx.stats.js
@@ -269,15 +269,21 @@
);
$header.cxHeader( mw.cx.siteMapper );
 
-   if ( mw.user.options.get( 'cx' ) !== '1' ) {
-   cxLink = mw.util.getUrl( 'Special:ContentTranslation', {
-   campaign: 'cxstats',
-   targettitle: mw.config.get( 'wgPageName' ),
-   to: mw.config.get( 'wgContentLanguage' )
-   } );
-
+   if ( mw.user.isAnon() ) {
$( '.cx-header__bar' ).hide();
-   mw.hook( 'mw.cx.error' ).fire( mw.message( 
'cx-stats-try-contenttranslation', cxLink ) );
+   }
+
+   if ( !mw.user.isAnon() && mw.user.options.get( 'cx' ) !== '1' ) 
{
+   if ( !mw.user.isAnon() ) {
+   cxLink = mw.util.getUrl( 
'Special:ContentTranslation', {
+   campaign: 'cxstats',
+   targettitle: mw.config.get( 
'wgPageName' ),
+   to: mw.config.get( 'wgContentLanguage' )
+   } );
+
+   $( '.cx-header__bar' ).hide();
+   mw.hook( 'mw.cx.error' ).fire( mw.message( 
'cx-stats-try-contenttranslation', cxLink ) );
+   }
} else {
$header.find( '.cx-header__translation-center a' 
).text( mw.msg( 'cx-header-new-translation' ) );
}
diff --git a/specials/SpecialContentTranslation.php 
b/specials/SpecialContentTranslation.php
index 5163566..c65850a 100644
--- a/specials/SpecialContentTranslation.php
+++ b/specials/SpecialContentTranslation.php
@@ -36,6 +36,10 @@
public function isValidCampaign( $campaign ) {
global $wgContentTranslationCampaigns;
 
+   if (  $this->getUser()->isAnon() ) {
+   // Campigns are only for logged in users.
+   return false;
+   }
return $campaign !== null && in_array( $campaign, 
$wgContentTranslationCampaigns );
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I0365d1366fcf5c62193f878c1e73435d9b4c0b98
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh 
Gerrit-Reviewer: KartikMistry 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] Campaigns are only for logged in users - change (mediawiki...ContentTranslation)

2015-05-22 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/212780

Change subject: Campaigns are only for logged in users
..

Campaigns are only for logged in users

Change-Id: I0365d1366fcf5c62193f878c1e73435d9b4c0b98
---
M modules/stats/ext.cx.stats.js
M specials/SpecialContentTranslation.php
2 files changed, 18 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/80/212780/1

diff --git a/modules/stats/ext.cx.stats.js b/modules/stats/ext.cx.stats.js
index 234ea4f..1e1e2c9 100644
--- a/modules/stats/ext.cx.stats.js
+++ b/modules/stats/ext.cx.stats.js
@@ -269,15 +269,21 @@
);
$header.cxHeader( mw.cx.siteMapper );
 
-   if ( mw.user.options.get( 'cx' ) !== '1' ) {
-   cxLink = mw.util.getUrl( 'Special:ContentTranslation', {
-   campaign: 'cxstats',
-   targettitle: mw.config.get( 'wgPageName' ),
-   to: mw.config.get( 'wgContentLanguage' )
-   } );
-
+   if ( mw.user.isAnon() ) {
$( '.cx-header__bar' ).hide();
-   mw.hook( 'mw.cx.error' ).fire( mw.message( 
'cx-stats-try-contenttranslation', cxLink ) );
+   }
+
+   if ( !mw.user.isAnon() && mw.user.options.get( 'cx' ) !== '1' ) 
{
+   if ( !mw.user.isAnon() ) {
+   cxLink = mw.util.getUrl( 
'Special:ContentTranslation', {
+   campaign: 'cxstats',
+   targettitle: mw.config.get( 
'wgPageName' ),
+   to: mw.config.get( 'wgContentLanguage' )
+   } );
+
+   $( '.cx-header__bar' ).hide();
+   mw.hook( 'mw.cx.error' ).fire( mw.message( 
'cx-stats-try-contenttranslation', cxLink ) );
+   }
} else {
$header.find( '.cx-header__translation-center a' 
).text( mw.msg( 'cx-header-new-translation' ) );
}
diff --git a/specials/SpecialContentTranslation.php 
b/specials/SpecialContentTranslation.php
index 5163566..c65850a 100644
--- a/specials/SpecialContentTranslation.php
+++ b/specials/SpecialContentTranslation.php
@@ -36,6 +36,10 @@
public function isValidCampaign( $campaign ) {
global $wgContentTranslationCampaigns;
 
+   if (  $this->getUser()->isAnon() ) {
+   // Campigns are only for logged in users.
+   return false;
+   }
return $campaign !== null && in_array( $campaign, 
$wgContentTranslationCampaigns );
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0365d1366fcf5c62193f878c1e73435d9b4c0b98
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh 

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