Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -385,23 +385,20 @@ |
386 | 386 | Best wishes, and thank you, |
387 | 387 | The {{SITENAME}} team', |
388 | 388 | |
389 | | - 'articlefeedbackv5-emailcapture-request-oversight' => 'Hello! |
| 389 | + 'articlefeedbackv5-email-request-oversight-subject' => '$1 has requested oversight on $2', |
| 390 | + 'articlefeedbackv5-email-request-oversight-body' => 'Hello! |
390 | 391 | |
391 | 392 | A request for oversight has been made by |
392 | 393 | |
393 | | -$1 : $2 |
| 394 | +$4 : $1 |
394 | 395 | |
395 | | -on feedback item |
396 | | - |
397 | | -$3 : $4 |
398 | | - |
399 | 396 | for page |
400 | 397 | |
401 | | -$5 : $6 |
| 398 | +$5 : $2 |
402 | 399 | |
403 | | -Please visit |
| 400 | +Please visit feedback item |
404 | 401 | |
405 | | -$7 |
| 402 | +$3 |
406 | 403 | |
407 | 404 | to decline or approve this oversight request. |
408 | 405 | |
— | — | @@ -666,6 +663,15 @@ |
667 | 664 | * <code>$1</code> – URL of the confirmation link |
668 | 665 | * <code>$2</code> – URL to type in the confirmation code manually. |
669 | 666 | * <code>$3</code> – Confirmation code for the user to type in', |
| 667 | + 'articlefeedbackv5-email-request-oversight-subject' => 'Subject line for email sent to oversight mailing list when an oversight request has been made. |
| 668 | +* <code>$1</code> – User name of requestor |
| 669 | +* <code>$2</code> – Page name of item with feedback requiring oversight.', |
| 670 | + 'articlefeedbackv5-email-request-oversight-body' => 'Body of an email sent to the oversight mailing list when an oversight request has been made. |
| 671 | +* <code>$1</code> – URL of user who requested oversight |
| 672 | +* <code>$2</code> – URL of page with feedback requiring oversight |
| 673 | +* <code>$3</code> – URL directly to feedback location |
| 674 | +* <code>$4</code> – User name of requestor |
| 675 | +* <code>$5</code> – Page name of item with feedback requiring oversight.', |
670 | 676 | ); |
671 | 677 | |
672 | 678 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php |
— | — | @@ -12,6 +12,15 @@ |
13 | 13 | |
14 | 14 | /* Configuration */ |
15 | 15 | |
| 16 | +// Email address to send oversight request emails to, if set to null no emails are sent |
| 17 | +$wgArticleFeedbackv5OversightEmails = null; |
| 18 | + |
| 19 | +// Should eventually be this, let's NOT flood that list with bogus emails |
| 20 | +// $wgArticleFeedbackv5OversightEmails = 'stewards@wikimedia.org'; |
| 21 | + |
| 22 | +// Name to send oversight request emails to |
| 23 | +$wgArticleFeedbackv5OversightEmailName = 'Oversighters'; |
| 24 | + |
16 | 25 | // How long text-based feedback is allowed to be before returning an error. |
17 | 26 | // Set to 0 to disable length checking entirely. |
18 | 27 | $wgArticleFeedbackv5MaxCommentLength = 0; |
— | — | @@ -272,6 +281,7 @@ |
273 | 282 | $wgAutoloadClasses['ApiFlagFeedbackArticleFeedbackv5'] = $dir . 'api/ApiFlagFeedbackArticleFeedbackv5.php'; |
274 | 283 | $wgAutoloadClasses['ApiViewActivityArticleFeedbackv5'] = $dir . 'api/ApiViewActivityArticleFeedbackv5.php'; |
275 | 284 | $wgAutoloadClasses['ArticleFeedbackv5Hooks'] = $dir . 'ArticleFeedbackv5.hooks.php'; |
| 285 | +$wgAutoloadClasses['ArticleFeedbackv5MailerJob'] = $dir . 'ArticleFeedbackv5MailerJob.php'; |
276 | 286 | $wgAutoloadClasses['SpecialArticleFeedbackv5'] = $dir . 'SpecialArticleFeedbackv5.php'; |
277 | 287 | $wgExtensionMessagesFiles['ArticleFeedbackv5'] = $dir . 'ArticleFeedbackv5.i18n.php'; |
278 | 288 | $wgExtensionMessagesFiles['ArticleFeedbackv5Alias'] = $dir . 'ArticleFeedbackv5.alias.php'; |
— | — | @@ -303,6 +313,9 @@ |
304 | 314 | $wgAvailableRights[] = 'aftv5-see-deleted-feedback'; |
305 | 315 | $wgAvailableRights[] = 'aftv5-see-hidden-feedback'; |
306 | 316 | |
| 317 | +// Jobs |
| 318 | +$wgJobClasses['ArticleFeedbackv5MailerJob'] = 'ArticleFeedbackv5MailerJob'; |
| 319 | + |
307 | 320 | // Logging |
308 | 321 | $wgLogTypes[] = 'articlefeedbackv5'; |
309 | 322 | $wgLogNames['articlefeedbackv5'] = 'articlefeedbackv5-log-name'; |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -253,6 +253,13 @@ |
254 | 254 | $results['hide_user'] = 0; |
255 | 255 | $results['hide_timestamp'] = $timestamp; |
256 | 256 | } |
| 257 | + |
| 258 | + // IF the previous setting was 0, send an email |
| 259 | + if ( $record->af_oversight_count < 1) { |
| 260 | + |
| 261 | + $this->sendOversightEmail( $record->af_page_id , $feedbackId ); |
| 262 | + |
| 263 | + } |
257 | 264 | } elseif($direction == 'decrease') { |
258 | 265 | $activity = 'unrequest'; |
259 | 266 | $filters['needsoversight'] = -1; |
— | — | @@ -429,6 +436,7 @@ |
430 | 437 | 'aft_article_feedback', |
431 | 438 | array( |
432 | 439 | 'af_id', |
| 440 | + 'af_page_id', |
433 | 441 | 'af_abuse_count', |
434 | 442 | 'af_is_hidden', |
435 | 443 | 'af_helpful_count', |
— | — | @@ -598,4 +606,51 @@ |
599 | 607 | |
600 | 608 | public function isWriteMode() { return true; } |
601 | 609 | public function mustBePosted() { return true; } |
| 610 | + |
| 611 | + /** |
| 612 | + * Helper function to dig out page url and title, feedback permalink, and |
| 613 | + * requestor page url and name - if all this data can be retrieved properly |
| 614 | + * it shoves an email job into the queue for sending ot the oversightor's |
| 615 | + * mailing list - only works on NEW oversight requests |
| 616 | + * |
| 617 | + * @param int $page_id page id to grab info on |
| 618 | + * @param int $feedback_id identifier for the feedback item |
| 619 | + */ |
| 620 | + protected function sendOversightEmail( $page_id, $feedback_id) { |
| 621 | + global $wgUser; |
| 622 | + |
| 623 | + // jobs need a title object |
| 624 | + $title_object = Title::newFromID( $page_id ); |
| 625 | + |
| 626 | + if ( !$title_object ) { |
| 627 | + return; // no title object, no mail |
| 628 | + } |
| 629 | + |
| 630 | + // get the string name of the page |
| 631 | + $page_name = $title_object->getDBKey(); |
| 632 | + |
| 633 | + // make a title out of our user (sigh) |
| 634 | + $user_page = Title::makeTitle( NS_USER, $wgUser->getName() ); |
| 635 | + |
| 636 | + if ( !$user_page ) { |
| 637 | + return; // no user title object, no mail |
| 638 | + } |
| 639 | + |
| 640 | + // to build our permalink, use the feedback entry key + the page name (isn't page name a title? but title is an object? confusing) |
| 641 | + $permalink = SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$page_name/$feedback_id" ); |
| 642 | + |
| 643 | + if ( !$permalink ) { |
| 644 | + return; // no proper permalink? no mail |
| 645 | + } |
| 646 | + |
| 647 | + // build our params |
| 648 | + $params = array( 'user_name' => $wgUser->getName(), |
| 649 | + 'user_url' => $user_page->getCanonicalUrl(), |
| 650 | + 'page_name' => $title_object->getText(), |
| 651 | + 'page_url' => $title_object->getCanonicalUrl(), |
| 652 | + 'permalink' => $permalink->getCanonicalUrl()); |
| 653 | + |
| 654 | + $job = new ArticleFeedbackv5MailerJob( $title_object, $params ); |
| 655 | + $job->insert(); |
| 656 | + } |
602 | 657 | } |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5MailerJob.php |
— | — | @@ -0,0 +1,103 @@ |
| 2 | +<?php
|
| 3 | +/**
|
| 4 | + * SpecialArticleFeedbackv5 class
|
| 5 | + *
|
| 6 | + * @package ArticleFeedback
|
| 7 | + * @subpackage Job
|
| 8 | + * @author Elizabeth M Smith <elizabeth@omniti.com>
|
| 9 | + * @version $Id$
|
| 10 | + */
|
| 11 | +
|
| 12 | +/**
|
| 13 | + * This is a job to do mailings for oversight requests
|
| 14 | + *
|
| 15 | + * @package ArticleFeedback
|
| 16 | + * @subpackage Job
|
| 17 | + */
|
| 18 | +class ArticleFeedbackv5MailerJob extends Job {
|
| 19 | +
|
| 20 | + /**
|
| 21 | + * Passthrough that sends the name of the class as the name of the job
|
| 22 | + *
|
| 23 | + * @param $command
|
| 24 | + * @param $title
|
| 25 | + * @param $params array
|
| 26 | + * @param int $id
|
| 27 | + */
|
| 28 | + function __construct( $title, $params, $id = 0 ) {
|
| 29 | + parent::__construct( __CLASS__, $title, $params, $id );
|
| 30 | + }
|
| 31 | +
|
| 32 | + /**
|
| 33 | + * Run the job
|
| 34 | + * @return boolean success
|
| 35 | + */
|
| 36 | + function run() {
|
| 37 | + global $wgArticleFeedbackv5OversightEmails, $wgArticleFeedbackv5OversightEmailName;
|
| 38 | + global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress;
|
| 39 | +
|
| 40 | + $params = $this->params;
|
| 41 | +
|
| 42 | + // if the oversight email address is empty we're going to just skip all this, but return true
|
| 43 | + if ( null === $wgArticleFeedbackv5OversightEmails ) {
|
| 44 | + return true;
|
| 45 | + }
|
| 46 | +
|
| 47 | + // if we don't have the right params set return false, job can't run
|
| 48 | + if ( !array_key_exists( 'user_name', $params)
|
| 49 | + || !array_key_exists( 'user_url', $params)
|
| 50 | + || !array_key_exists( 'page_name', $params)
|
| 51 | + || !array_key_exists( 'page_url', $params)
|
| 52 | + || !array_key_exists( 'permalink', $params)) {
|
| 53 | + return false;
|
| 54 | + }
|
| 55 | +
|
| 56 | + // get our addresses
|
| 57 | + $to = new MailAddress( $wgArticleFeedbackv5OversightEmails, $wgArticleFeedbackv5OversightEmailName );
|
| 58 | + $from = new MailAddress( $wgPasswordSender, $wgPasswordSenderName );
|
| 59 | + $replyto = new MailAddress( $wgNoReplyAddress );
|
| 60 | +
|
| 61 | + // get our text
|
| 62 | + list($subject, $body) = $this->composeMail($params['user_name'],
|
| 63 | + $params['user_url'],
|
| 64 | + $params['page_name'],
|
| 65 | + $params['page_url'],
|
| 66 | + $params['permalink']);
|
| 67 | +
|
| 68 | + return UserMailer::send( $to, $from, $subject,
|
| 69 | + $body, $replyto );
|
| 70 | + }
|
| 71 | +
|
| 72 | + /**
|
| 73 | + * Generate the "an oversight request has been made" email for sending
|
| 74 | + * to the mailing list
|
| 75 | + *
|
| 76 | + * @param string $requestor_name user name
|
| 77 | + * @param string $requestor_url link to user page
|
| 78 | + * @param string $page_name page title
|
| 79 | + * @param string $page_url page url
|
| 80 | + * @param string $feedback_permalink permalink url to feedback
|
| 81 | + */
|
| 82 | + protected function composeMail( $requestor_name, $requestor_url, $page_name, $page_url, $feedback_permalink ) {
|
| 83 | + global $wgPasswordSender, $wgPasswordSenderName, $wgNoReplyAddress, $wgRequest;
|
| 84 | +
|
| 85 | + // build the subject
|
| 86 | + $subject = wfMessage( 'articlefeedbackv5-email-request-oversight-subject' )->params(
|
| 87 | + $requestor_name,
|
| 88 | + $page_name )->escaped();
|
| 89 | +
|
| 90 | + //text version, no need to escape since client will interpret it as plain text
|
| 91 | + $body = wfMessage( 'articlefeedbackv5-email-request-oversight-body' )
|
| 92 | + ->rawParams(
|
| 93 | + $requestor_url,
|
| 94 | + $page_url,
|
| 95 | + $feedback_permalink)
|
| 96 | + ->params(
|
| 97 | + $requestor_name,
|
| 98 | + $page_name)
|
| 99 | + ->text();
|
| 100 | +
|
| 101 | + return array($subject, $body);
|
| 102 | + }
|
| 103 | +
|
| 104 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5MailerJob.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 105 | + Id |