http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88968
Revision: 88968
Author: janpaul123
Date: 2011-05-27 11:57:37 +0000 (Fri, 27 May 2011)
Log Message:
-----------
Fixed logging:
* E-mail notifications are logged correctly now
* Errors are displayed correctly
* Raw message and not the final wikitext are logged. This is because the final
wikitext is not interesting, the actual message that was typed is much more
useful as we can do data mining on that.
Modified Paths:
--------------
trunk/extensions/WikiLove/WikiLove.api.php
trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
Modified: trunk/extensions/WikiLove/WikiLove.api.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.api.php 2011-05-27 11:43:33 UTC (rev
88967)
+++ trunk/extensions/WikiLove/WikiLove.api.php 2011-05-27 11:57:37 UTC (rev
88968)
@@ -16,7 +16,7 @@
}
if ( $wgWikiLoveLogging ) {
- $this->saveInDb( $talk, $params['subject'],
$params['text'], $params['type'], isset( $params['email'] ) ? 1 : 0 );
+ $this->saveInDb( $talk, $params['subject'],
$params['message'], $params['type'], isset( $params['email'] ) ? 1 : 0 );
}
$api = new ApiMain( new FauxRequest( array(
@@ -30,7 +30,7 @@
), false, array( 'wsEditToken' => $wgRequest->getSessionData(
'wsEditToken' ) ) ), true );
if ( isset( $params['email'] ) ) {
- $this->emailUser( $talk, $params['subject'],
$params['email'] );
+ $this->emailUser( $talk, $params['subject'],
$params['email'], $params['token'] );
}
$api->execute();
@@ -46,11 +46,12 @@
/**
* @param $talk Title
* @param $subject
- * @param $text
+ * @param $message
* @param $type
+ * @param $email
* @return void
*/
- private function saveInDb( $talk, $subject, $text, $type, $email ) {
+ private function saveInDb( $talk, $subject, $message, $type, $email ) {
global $wgUser;
$dbw = wfGetDB( DB_MASTER );
$values = array(
@@ -59,7 +60,7 @@
'wll_receiver' => User::newFromName(
$talk->getSubjectPage()->getBaseText() )->getId(),
'wll_type' => $type,
'wll_subject' => $subject,
- 'wll_message' => $text,
+ 'wll_message' => $message,
'wll_email' => $email,
);
try{
@@ -69,12 +70,14 @@
}
}
- private function emailUser( $talk, $subject, $text ) {
+ private function emailUser( $talk, $subject, $text, $token ) {
+ global $wgRequest;
$api = new ApiMain( new FauxRequest( array(
'action' => 'emailuser',
'target' => User::newFromName(
$talk->getSubjectPage()->getBaseText() )->getName(),
'subject' => $subject,
'text' => $text,
+ 'token' => $token,
), false, array( 'wsEditToken' => $wgRequest->getSessionData(
'wsEditToken' ) ) ), true );
try{
$api->execute();
@@ -93,6 +96,10 @@
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
),
+ 'message' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true,
+ ),
'token' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
@@ -114,6 +121,7 @@
return array(
'title' => 'Title of the user or user talk page to send
WikiLove to',
'text' => 'Raw wikitext to add in the new section',
+ 'message' => 'Actual message the user has entered, for
logging purposes',
'token' => 'Edit token. You can get one of these
through prop=info',
'subject' => 'Subject header of the new section',
'type' => array( 'Type of WikiLove (for statistics);
this corresponds with a type',
Modified: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
===================================================================
--- trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
2011-05-27 11:43:33 UTC (rev 88967)
+++ trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
2011-05-27 11:57:37 UTC (rev 88968)
@@ -240,9 +240,10 @@
$.wikiLove.showGallery(); // build gallery from
array of images
} else {
// gallery is a category
- $( '#mw-wikilove-gallery-label' ).show();
- $( '#mw-wikilove-gallery' ).show();
- $.wikiLove.makeGallery(); // build gallery from
category
+ // not supported right now
+ $( '#mw-wikilove-gallery-label' ).hide();
+ $( '#mw-wikilove-gallery' ).hide();
+ //$.wikiLove.makeGallery(); // build gallery
from category
}
}
else {
@@ -294,23 +295,24 @@
$.wikiLove.showError( 'wikilove-err-sig' ); return
false;
}
- var msg = $.wikiLove.prepareMsg(
+ var text = $.wikiLove.prepareMsg(
$.wikiLove.currentTypeOrSubtype.text ||
$.wikiLove.options.defaultText,
$.wikiLove.currentTypeOrSubtype.imageSize,
$.wikiLove.currentTypeOrSubtype.backgroundColor,
$.wikiLove.currentTypeOrSubtype.borderColor
);
- $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() +
"==\n" + msg );
+ $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() +
"==\n" + text );
$.wikiLove.previewData = {
'header': $( '#mw-wikilove-header' ).val(),
- 'msg': msg,
+ 'text': text,
+ 'message': $( '#mw-wikilove-message' ).val(),
'type': $.wikiLove.currentTypeId
+ ($.wikiLove.currentSubtypeId !== null ? '-' +
$.wikiLove.currentSubtypeId : '')
};
if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() &&
$.wikiLove.emailable ) {
- $.wikiLove.previewData.mail = $.wikiLove.prepareMsg(
$.wikiLove.currentTypeOrSubtype.mail );
+ $.wikiLove.previewData.email = $.wikiLove.prepareMsg(
$.wikiLove.currentTypeOrSubtype.email );
}
},
@@ -385,14 +387,14 @@
*/
submitSend: function( e ) {
e.preventDefault();
- $.wikiLove.doSend( $.wikiLove.previewData.header,
$.wikiLove.previewData.msg,
- $.wikiLove.previewData.type,
$.wikiLove.previewData.notify );
+ $.wikiLove.doSend( $.wikiLove.previewData.header,
$.wikiLove.previewData.text,
+ $.wikiLove.previewData.message,
$.wikiLove.previewData.type, $.wikiLove.previewData.email );
},
/*
* Fires the final AJAX request and then redirects to the talk page
where the content is added.
*/
- doSend: function( subject, wikitext, type, mail ) {
+ doSend: function( subject, wikitext, message, type, email ) {
$( '#mw-wikilove-send-spinner' ).fadeIn( 200 );
var sendData = {
@@ -401,12 +403,13 @@
'title': mw.config.get( 'wgPageName' ),
'type': type,
'text': wikitext,
+ 'message': message,
'subject': subject,
'token': mw.user.tokens.get( 'editToken' )
};
- if ( mail ) {
- sendData.email = mail;
+ if ( email ) {
+ sendData.email = email;
}
$.ajax({
@@ -418,7 +421,7 @@
$( '#mw-wikilove-send-spinner' ).fadeOut( 200 );
if ( typeof data.error !== 'undefined' ) {
- $( '#mw-wikilove-preview' ).append(
'<div class="wlError">' + mw.html.escape( data.error.info ) + '<div>' );
+ $( '#mw-wikilove-preview' ).append(
'<div class="mw-wikilove-error">' + mw.html.escape( data.error.info ) + '<div>'
);
return;
}
Modified:
trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
===================================================================
---
trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
2011-05-27 11:43:33 UTC (rev 88967)
+++
trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
2011-05-27 11:57:37 UTC (rev 88968)
@@ -26,7 +26,7 @@
header: 'A barnstar for you!', //
header that appears at the top of the talk page post (optional)
title: 'The Original Barnstar', //
title that appears inside the award box (optional)
image: 'Original Barnstar Hires.png',
// image for the award
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.' // message to use in email notification; $7 is replaced by the
recipient's username
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.' // message to use in eemail notification; $7 is replaced by the
recipient's username
},
'admins': {
fields: [ 'notify' ],
@@ -35,7 +35,7 @@
header: 'A barnstar for you!',
title: 'The Admin\'s Barnstar',
image: 'Administrator Barnstar
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'antivandalism': {
fields: [ 'notify' ],
@@ -44,7 +44,7 @@
header: 'A barnstar for you!',
title: 'The Anti-Vandalism Barnstar',
image: 'Barnstar of Reversion
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'diligence': {
fields: [ 'notify' ],
@@ -53,7 +53,7 @@
header: 'A barnstar for you!',
title: 'The Barnstar of Diligence',
image: 'Barnstar of Diligence
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'diplomacy': {
fields: [ 'notify' ],
@@ -62,7 +62,7 @@
header: 'A barnstar for you!',
title: 'The Barnstar of Diplomacy',
image: 'Peace Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'goodhumor': {
fields: [ 'notify' ],
@@ -71,7 +71,7 @@
header: 'A barnstar for you!',
title: 'The Barnstar of Good Humor',
image: 'Barnstar of Reversion
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'brilliant': {
fields: [ 'notify' ],
@@ -80,7 +80,7 @@
header: 'A barnstar for you!',
title: 'The Brilliant Idea Barnstar',
image: 'Brilliant Idea Barnstar
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'citation': {
fields: [ 'notify' ],
@@ -89,7 +89,7 @@
header: 'A barnstar for you!',
title: 'The Citation Barnstar',
image: 'Citation Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'civility': {
fields: [ 'notify' ],
@@ -98,7 +98,7 @@
header: 'A barnstar for you!',
title: 'The Civility Barnstar',
image: 'Civility Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'copyeditor': {
fields: [ 'notify' ],
@@ -107,7 +107,7 @@
header: 'A barnstar for you!',
title: 'The Copyeditor\'s Barnstar',
image: 'Copyeditor Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'defender': {
fields: [ 'notify' ],
@@ -116,7 +116,7 @@
header: 'A barnstar for you!',
title: 'The Defender of the Wiki
Barnstar',
image: 'WikiDefender Barnstar
Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'editors': {
fields: [ 'notify' ],
@@ -125,7 +125,7 @@
header: 'A barnstar for you!',
title: 'The Editor\'s Barnstar',
image: 'Editors Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'designers': {
fields: [ 'notify' ],
@@ -134,7 +134,7 @@
header: 'A barnstar for you!',
title: 'The Graphic Designer\'s
Barnstar',
image: 'Rosetta Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'half': {
fields: [ 'notify' ],
@@ -143,7 +143,7 @@
header: 'A barnstar for you!',
title: 'The Half Barnstar',
image: 'Halfstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'minor': {
fields: [ 'notify' ],
@@ -152,7 +152,7 @@
header: 'A barnstar for you!',
title: 'The Minor barnstar',
image: 'Minor Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'antispam': {
fields: [ 'notify' ],
@@ -161,7 +161,7 @@
header: 'A barnstar for you!',
title: 'The No Spam Barnstar',
image: 'No Spam Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'photographers': {
fields: [ 'notify' ],
@@ -170,7 +170,7 @@
header: 'A barnstar for you!',
title: 'The Photographer\'s Barnstar',
image: 'Camera Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'kindness': {
fields: [ 'notify' ],
@@ -179,7 +179,7 @@
header: 'A barnstar for you!',
title: 'The Random Acts of Kindness
barnstar',
image: 'Kindness Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'reallife': {
fields: [ 'notify' ],
@@ -188,7 +188,7 @@
header: 'A barnstar for you!',
title: 'The Real Life Barnstar',
image: 'Real Life Barnstar.jpg',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'resilient': {
fields: [ 'notify' ],
@@ -197,7 +197,7 @@
header: 'A barnstar for you!',
title: 'The Resilient Barnstar',
image: 'Resilient Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'rosetta': {
fields: [ 'notify' ],
@@ -206,7 +206,7 @@
header: 'A barnstar for you!',
title: 'The Rosetta Barnstar',
image: 'Rosetta Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'special': {
fields: [ 'notify' ],
@@ -215,7 +215,7 @@
header: 'A barnstar for you!',
title: 'The Special Barnstar',
image: 'Special Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'surreal': {
fields: [ 'notify' ],
@@ -224,7 +224,7 @@
header: 'A barnstar for you!',
title: 'The Surreal Barnstar',
image: 'Surreal Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'teamwork': {
fields: [ 'notify' ],
@@ -233,7 +233,7 @@
header: 'A barnstar for you!',
title: 'The Teamwork Barnstar',
image: 'Team Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'technical': {
fields: [ 'notify' ],
@@ -242,7 +242,7 @@
header: 'A barnstar for you!',
title: 'The Technical Barnstar',
image: 'Vitruvian Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'tireless': {
fields: [ 'notify' ],
@@ -251,7 +251,7 @@
header: 'A barnstar for you!',
title: 'The Tireless Contributor
Barnstar',
image: 'Tireless Contributor Barnstar
Hires.gif',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
},
'writers': {
fields: [ 'notify' ],
@@ -260,7 +260,7 @@
header: 'A barnstar for you!',
title: 'The Writer\'s Barnstar',
image: 'Writers Barnstar Hires.png',
- mail: 'Hello $7!\n\nI just awarded you
a barnstar.'
+ email: 'Hello $7!\n\nI just awarded you
a barnstar.'
}
},
icon: mw.config.get( 'wgServer' ) + mw.config.get(
'wgScriptPath' ) +
'/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-barnstar.png'
// icon for left-side menu
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs