r75773 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75772‎ | r75773 | r75774 >
Date:02:20, 1 November 2010
Author:nad
Status:deferred
Tags:
Comment:
add global for the email splitting regex
Modified paths:
  • /trunk/extensions/EmailPage/EmailPage.php (modified) (history)
  • /trunk/extensions/EmailPage/EmailPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EmailPage/EmailPage_body.php
@@ -38,16 +38,16 @@
3939 $this->from = $wgRequest->getText( 'ea-from' );
4040 $this->subject = $wgRequest->getText( 'ea-subject', wfMsg( 'ea-pagesend', $this->title, $wgSitename ) );
4141 $this->message = $wgRequest->getText( 'ea-message' );
42 - $this->message = $wgRequest->getText( 'ea-message' );
4342 $this->group = $wgRequest->getText( 'ea-group' );
44 - $this->to = $wgRequest->getText( 'ea-to' ) . ";" . $wgRequest->getText( 'ea-cc' );
 43+ $this->to = $wgRequest->getText( 'ea-to' );
 44+ $this->cc = $wgRequest->getText( 'ea-cc' );
4545 $this->textonly = $wgRequest->getText( 'ea-textonly', false );
4646 $this->css = $wgRequest->getText( 'ea-css', $wgEmailPageCss );
4747 $this->record = $wgRequest->getText( 'ea-record', false );
4848 $this->db = $db;
4949
5050 # Bail if no page title to send has been specified
51 - if( $this->title ) $wgOut->addWikiText( wfMsg( 'ea-heading', $this->title ) );
 51+ if( $this->title ) $wgOut->addWikiText( "===" . wfMsg( 'ea-heading', $this->title ) . "===" );
5252 else return $wgOut->addWikiText( wfMsg( 'ea-nopage' ) );
5353
5454 # If the send button was clicked, attempt to send and exit
@@ -71,7 +71,7 @@
7272
7373 # To
7474 $wgOut->addHTML( "<tr id=\"ea-to\"><th align=\"right\" valign=\"top\">" . wfMsg( 'ea-to' ) . ":</th>" );
75 - $wgOut->addHTML( "<td><textarea name=\"ea-to\" rows=\"2\" style=\"width:100%\"></textarea>" );
 75+ $wgOut->addHTML( "<td><textarea name=\"ea-to\" rows=\"2\" style=\"width:100%\">{$this->to}</textarea>" );
7676 $wgOut->addHTML( "<br /><small><i>(" . wfMsg( 'ea-to-info' ) . ")</i></small>" );
7777
7878 # To group
@@ -95,7 +95,7 @@
9696 Xml::element( 'input', array(
9797 'type' => 'text',
9898 'name' => 'ea-cc',
99 - 'value' => $ue,
 99+ 'value' => $this->cc ? $this->cc : $ue,
100100 'style' => "width:100%"
101101 ) )
102102 . "</td></tr>" );
@@ -113,7 +113,7 @@
114114
115115 # Message
116116 $wgOut->addHTML( "<tr id=\"ea-message\"><th align=\"right\" valign=\"top\">" . wfMsg( 'ea-message' ) . ":</th>" );
117 - $wgOut->addHTML( "<td><textarea name=\"ea-header\" rows=\"3\" style=\"width:100%\">{$this->message}</textarea>" );
 117+ $wgOut->addHTML( "<td><textarea name=\"ea-message\" rows=\"3\" style=\"width:100%\">{$this->message}</textarea>" );
118118 $wgOut->addHTML( "<br /><i><small>(" . wfMsg( 'ea-message-info' ) . ")</small></i></td></tr>" );
119119
120120 # CSS
@@ -175,7 +175,7 @@
176176 */
177177 function send( $send = true ) {
178178 global $wgOut, $wgUser, $wgParser, $wgServer, $wgScript, $wgArticlePath, $wgScriptPath, $wgEmergencyContact,
179 - $wgEmailPageCss, $wgEmailPageGroup, $wgEmailPageAllowRemoteAddr, $wgEmailPageAllowAllUsers;
 179+ $wgEmailPageCss, $wgEmailPageGroup, $wgEmailPageAllowRemoteAddr, $wgEmailPageAllowAllUsers, $wgEmailPageSepPattern;
180180
181181 # Set error and bail if user not in postmaster group, and request not from trusted address
182182 if( $wgEmailPageGroup && !in_array( $wgEmailPageGroup, $wgUser->getGroups() )
@@ -196,8 +196,9 @@
197197 $db->freeResult( $res );
198198 }
199199
200 - # Recipients from the "to" field
201 - foreach( preg_split( "|[\\x00-\\x1f,;*]+|", $this->to ) as $item ) $this->addRecipient( $item );
 200+ # Recipients from the "to" and "cc" fields
 201+ foreach( preg_split( $wgEmailPageSepPattern, $this->to ) as $item ) $this->addRecipient( $item );
 202+ foreach( preg_split( $wgEmailPageSepPattern, $this->cc ) as $item ) $this->addRecipient( $item );
202203
203204 # Compose the wikitext content of the page to send
204205 $title = Title::newFromText( $this->title );
@@ -242,7 +243,7 @@
243244 $mail->Body = $message;
244245 $mail->IsHTML( !$this->textonly );
245246 }
246 - else $msg = wfMsg( 'ea-listrecipients', $count );
 247+ else $msg = "===" . wfMsg( 'ea-listrecipients', $count ) . "===";
247248
248249 # Loop through recipients sending or adding to list
249250 foreach( $this->recipients as $recipient ) {
Index: trunk/extensions/EmailPage/EmailPage.php
@@ -13,15 +13,15 @@
1414 */
1515 if( !defined( 'MEDIAWIKI' ) ) die( "Not an entry point." );
1616
17 -define( 'EMAILPAGE_VERSION', "2.1.0, 2010-11-01" );
 17+define( 'EMAILPAGE_VERSION', "2.1.1, 2010-11-01" );
1818
19 -$wgEmailPageGroup = "sysop"; # Users must belong to this group to send emails (empty string means anyone can send)
20 -$wgEmailPageCss = false; # A minimal CSS page to embed in the email (eg. monobook/main.css without portlets, actions etc)
21 -$wgEmailPageAllowRemoteAddr = array( "127.0.0.1" ); # Allow anonymous sending from these addresses
22 -$wgEmailPageAllowAllUsers = false; # Whether to allow sending to all users (the "user" group)
23 -$wgEmailPageToolboxLink = true; # Add a link to the sidebar toolbox?
24 -$wgEmailPageActionLink = true; # Add a link to the actions links?
25 -
 19+$wgEmailPageGroup = "sysop"; # Users must belong to this group to send emails (empty string means anyone can send)
 20+$wgEmailPageCss = false; # A minimal CSS page to embed in the email (eg. monobook/main.css without portlets, actions etc)
 21+$wgEmailPageAllowRemoteAddr = array( "127.0.0.1" ); # Allow anonymous sending from these addresses
 22+$wgEmailPageAllowAllUsers = false; # Whether to allow sending to all users (the "user" group)
 23+$wgEmailPageToolboxLink = true; # Add a link to the sidebar toolbox?
 24+$wgEmailPageActionLink = true; # Add a link to the actions links?
 25+$wgEmailPageSepPattern = "|[\\x00-\\x20,;*]+|"; # Regular expression for splitting emails
2626 if( $wgEmailPageGroup ) $wgGroupPermissions['sysop'][$wgEmailPageGroup] = true;
2727
2828 if( isset( $_SERVER['SERVER_ADDR'] ) ) $wgEmailPageAllowRemoteAddr[] = $_SERVER['SERVER_ADDR'];

Status & tagging log