Reedy has uploaded a new change for review.
https://gerrit.wikimedia.org/r/68738
Change subject: Add updated scripts for bv2013
......................................................................
Add updated scripts for bv2013
Change-Id: I0492c860636120c582980ab2460d484e60a5594d
---
A cli/wm-scripts/bv2013/buildSpamTranslations.php
A cli/wm-scripts/bv2013/get-voter-list.sh
A cli/wm-scripts/bv2013/sendMails.php
3 files changed, 112 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SecurePoll
refs/changes/38/68738/1
diff --git a/cli/wm-scripts/bv2013/buildSpamTranslations.php
b/cli/wm-scripts/bv2013/buildSpamTranslations.php
new file mode 100644
index 0000000..e14d814
--- /dev/null
+++ b/cli/wm-scripts/bv2013/buildSpamTranslations.php
@@ -0,0 +1,46 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../../../../..';
+}
+require_once( "$IP/maintenance/commandLine.inc" );
+
+$wgDebugLogFile = '/dev/stderr';
+
+$dbr = wfGetDB( DB_SLAVE );
+$dbr->debug( true );
+$prefix = "Board_elections/2013/Email/";
+
+$textPrefix = '<div style="{{quote style}}">';
+$textSuffix = "</div>\n[[Category:Board elections 2011]]";
+
+$res = $dbr->select(
+ 'page',
+ 'page_id',
+ array( 'page_namespace' => 0, 'page_title ' . $dbr->buildLike( $prefix,
$dbr->anyString() ) ),
+ 'boardelection-spam-translation'
+);
+
+foreach( $res as $row ) {
+ $page = Article::newFromID( $row->page_id );
+
+ print "Got article " . $row->page_id . "\n";
+
+ $content = $page->getContent();
+
+ $len = strlen( $textPrefix );
+ if ( substr( $content, 0, $len ) == $textPrefix ) {
+ $content = substr( $content, $len );
+ }
+
+ if ( substr( $content, - $len ) == $textSuffix ) {
+ $content = substr( $content, 0, - $len );
+ }
+
+ $content = trim( $content ) . "\n";
+
+ $lang = substr( $page->getTitle()->getText(), strlen( $prefix ) );
+ $file = dirname( __FILE__ ) . "/email-translations/" . $lang;
+ file_put_contents( $file, $content );
+}
diff --git a/cli/wm-scripts/bv2013/get-voter-list.sh
b/cli/wm-scripts/bv2013/get-voter-list.sh
new file mode 100755
index 0000000..becd9c9
--- /dev/null
+++ b/cli/wm-scripts/bv2013/get-voter-list.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for wiki in `</a/common/all.dblist`; do
+ echo $wiki;
+ echo "SELECT '$wiki', user_name,user_email,up_value FROM
securepoll_lists JOIN user ON li_member=user_id JOIN user_properties ON
up_property='language' AND up_user=user_id WHERE li_name='board-vote-2011' AND
user_email_authenticated IS NOT NULL;" \
+ | sql $wiki | tail -n +2 >>
/a/common/elections-2013-spam/users-by-wiki;
+done
diff --git a/cli/wm-scripts/bv2013/sendMails.php
b/cli/wm-scripts/bv2013/sendMails.php
new file mode 100644
index 0000000..9d2fb31
--- /dev/null
+++ b/cli/wm-scripts/bv2013/sendMails.php
@@ -0,0 +1,59 @@
+<?php
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../../../../..';
+}
+require_once( "$IP/maintenance/commandLine.inc" );
+
+ini_set( 'display_errors', 1 );
+$err = fopen( 'php://stderr', 'w' );
+$in = fopen( 'php://stdin', 'r' );
+
+$sender = new MailAddress( '[email protected]', 'Wikimedia
Board Elections Committee' );
+
+// Pull templates
+$langs = explode( ' ', 'bar be-tarask bg bn bs ca cy da de diq el en eo es fa
fi fr gl he hi hy id ' .
+ 'is it ja lb mr ms nb nl pl pt ro ru si sk sq sv tr uk vi yi yue
zh-hans zh-hant'
+);
+
+$transTemplates = array();
+
+foreach ( $langs as $lang ) {
+ $transTemplates[$lang] = file_get_contents( 'email-translations/' .
$lang );
+}
+
+while ( !is_null( $line = fgets( $in ) ) ) {
+ if ( !$line ) {
+ continue;
+ }
+ list( $address, $lang, $site, $name ) = explode( "\t", trim( $line ) );
+
+ if ( !( $name && $lang && $address && $site ) ) {
+ print "invalid line $line $name $lang $address $site\n";
+ continue;
+ }
+
+ $content = $transTemplates[$lang];
+
+ if ( !$content ) {
+ $content = $transTemplates['en'];
+ $lang = 'en';
+ }
+
+ $content = strtr( $content,
+ array(
+ '$username' => $name,
+ '$activeproject' => $wgLang->ucfirst( $site ),
+ )
+ );
+
+ $address = new MailAddress( $address, $name );
+
+ $subject = 'Wikimedia Foundation Elections 2013';
+
+ UserMailer::send( $address, $sender, $subject, $content );
+ print "Sent to $name <$address> in $lang\n";
+
+ sleep( 0.1 );
+}
--
To view, visit https://gerrit.wikimedia.org/r/68738
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0492c860636120c582980ab2460d484e60a5594d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SecurePoll
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits