JGirault has uploaded a new change for review. https://gerrit.wikimedia.org/r/254328
Change subject: Make privacy policy an optional parameter for internal and external surveys. ...................................................................... Make privacy policy an optional parameter for internal and external surveys. Bug: T119149 Change-Id: I3963c779c6efe12f8d60062a078b3139b9dedd4b --- M includes/ExternalSurvey.php M includes/InternalSurvey.php M includes/Survey.php M includes/SurveyFactory.php M resources/ext.quicksurveys.views/ExternalSurvey.js M resources/ext.quicksurveys.views/QuickSurvey.js 6 files changed, 27 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys refs/changes/28/254328/1 diff --git a/includes/ExternalSurvey.php b/includes/ExternalSurvey.php index be66bb7..e313fd1 100644 --- a/includes/ExternalSurvey.php +++ b/includes/ExternalSurvey.php @@ -19,30 +19,24 @@ */ private $link; - /** - * @var string The description of the privacy policy of the website that hosts the external survey. - */ - private $privacyPolicy; - public function __construct( $name, $question, $description, $isEnabled, $coverage, - $link, - $privacyPolicy + $privacyPolicy, + $link ) { - parent::__construct( $name, $question, $description, $isEnabled, $coverage ); + parent::__construct( $name, $question, $description, $isEnabled, $coverage, $privacyPolicy ); $this->name = $name; $this->link = $link; - $this->privacyPolicy = $privacyPolicy; $this->isInsecure = !preg_match( '/https/i', wfMessage( $this->link ) ) ? true : false; } public function getMessages() { - return array_merge( parent::getMessages(), array( $this->privacyPolicy, $this->link ) ); + return array_merge( parent::getMessages(), array( $this->link ) ); } public function toArray() { @@ -51,7 +45,6 @@ 'type' => 'external', 'link' => $this->link, 'isInsecure' => $this->isInsecure, - 'privacyPolicy' => $this->privacyPolicy, ); } } diff --git a/includes/InternalSurvey.php b/includes/InternalSurvey.php index 43b9619..584aad9 100644 --- a/includes/InternalSurvey.php +++ b/includes/InternalSurvey.php @@ -20,9 +20,10 @@ $description, $isEnabled, $coverage, + $privacyPolicy, array $answers ) { - parent::__construct( $name, $question, $description, $isEnabled, $coverage ); + parent::__construct( $name, $question, $description, $isEnabled, $coverage, $privacyPolicy ); $this->name = $name; $this->answers = $answers; diff --git a/includes/Survey.php b/includes/Survey.php index 06c413a..c1e3b74 100644 --- a/includes/Survey.php +++ b/includes/Survey.php @@ -29,18 +29,25 @@ */ private $coverage; + /** + * @var string The description of the privacy policy of the website that hosts the external survey. + */ + private $privacyPolicy; + public function __construct( $name, $question, $description, $isEnabled, - $coverage + $coverage, + $privacyPolicy ) { $this->name = $name; $this->question = $question; $this->description = $description; $this->isEnabled = $isEnabled; $this->coverage = $coverage; + $this->privacyPolicy = $privacyPolicy; } // -------- @@ -59,12 +66,15 @@ * @return [string] */ public function getMessages() { - return array( + $messages = array( $this->question, - // FIXME: Should description be optional? $this->description, ); + if (!empty($this->privacyPolicy)) { + $messages[] = $this->privacyPolicy; + } + return $messages; } // -------- @@ -80,6 +90,7 @@ 'description' => $this->description, 'module' => $this->getResourceLoaderModuleName(), 'coverage' => $this->coverage, + 'privacyPolicy' => $this->privacyPolicy, ); } diff --git a/includes/SurveyFactory.php b/includes/SurveyFactory.php index a546a39..dae09d3 100644 --- a/includes/SurveyFactory.php +++ b/includes/SurveyFactory.php @@ -79,8 +79,8 @@ $spec['description'], $spec['enabled'], $spec['coverage'], - $spec['link'], - $spec['privacyPolicy'] + $spec['privacyPolicy'], + $spec['link'] ); } @@ -99,6 +99,7 @@ $spec['description'], $spec['enabled'], $spec['coverage'], + $spec['privacyPolicy'], $spec['answers'] ); } diff --git a/resources/ext.quicksurveys.views/ExternalSurvey.js b/resources/ext.quicksurveys.views/ExternalSurvey.js index da00aa3..028a99c 100644 --- a/resources/ext.quicksurveys.views/ExternalSurvey.js +++ b/resources/ext.quicksurveys.views/ExternalSurvey.js @@ -14,13 +14,6 @@ /** * @inheritdoc */ - initialize: function ( config ) { - this.defaults.templateData.footer = mw.message( config.survey.privacyPolicy ).parse(); - QuickSurvey.prototype.initialize.call( this, config ); - }, - /** - * @inheritdoc - */ renderButtons: function () { var $btnContainer = this.initialPanel.$element.find( '.survey-button-container' ), buttons = [ diff --git a/resources/ext.quicksurveys.views/QuickSurvey.js b/resources/ext.quicksurveys.views/QuickSurvey.js index aaf8365..1a76784 100644 --- a/resources/ext.quicksurveys.views/QuickSurvey.js +++ b/resources/ext.quicksurveys.views/QuickSurvey.js @@ -46,6 +46,10 @@ this.config = config || {}; $.extend( true, this.config, this.defaults ); + if ( config.survey.privacyPolicy ) { + this.config.templateData.footer = mw.message( config.survey.privacyPolicy ).parse(); + } + // setup initial panel this.initialPanel = this.widget( 'PanelLayout', 'initialPanel' ); -- To view, visit https://gerrit.wikimedia.org/r/254328 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3963c779c6efe12f8d60062a078b3139b9dedd4b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/QuickSurveys Gerrit-Branch: dev Gerrit-Owner: JGirault <jgira...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits