r50166 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50165‎ | r50166 | r50167 >
Date:09:10, 4 May 2009
Author:nad
Status:deferred
Tags:
Comment:
$wgEmailPageAllowAllUsers was not working properly
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
@@ -88,10 +88,14 @@
8989
9090 # Allow selection of a group
9191 $groups = "<option />";
92 - foreach ( array_keys( $wgGroupPermissions ) as $group ) if ( $group != '*' ) {
 92+ foreach ( array_keys( $wgGroupPermissions ) as $group ) if ( $group != '*' && $group != 'user' ) {
9393 $selected = $group == $this->group ? ' selected' : '';
94 - if ( $wgEmailPageAllowAllUsers ) $groups .= "<option$selected>$group</option>";
 94+ $groups .= "<option$selected>$group</option>";
9595 }
 96+ if ( $wgEmailPageAllowAllUsers ) {
 97+ $selected = 'user' == $this->group ? ' selected' : '';
 98+ $groups .= "<option$selected value='user'>ALL USERS</option>";
 99+ }
96100 $wgOut->addHTML( "<tr><td>" . wfMsg( 'ea-fromgroup' ) . "</td><td><select name=\"ea-group\">$groups</select></td></tr>\n" );
97101 $wgOut->addHTML( "</table>" );
98102
Index: trunk/extensions/EmailPage/EmailPage.php
@@ -11,24 +11,24 @@
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
1414
15 -if (!defined('MEDIAWIKI')) die('Not an entry point.');
 15+if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
1616
17 -define('EMAILPAGE_VERSION', '1.3.3, 2009-04-19');
 17+define( 'EMAILPAGE_VERSION', '1.3.4, 2009-05-04' );
1818
19 -$wgEmailPageGroup = 'sysop'; # Users must belong to this group to send emails (empty string means anyone can send)
20 -$wgEmailPageContactsCat = ''; # This specifies the name of a category containing categories of contact pages
21 -$wgEmailPageCss = 'EmailPage.css'; # A minimal CSS page to embed in the email (eg. monobook/main.css without portlets, actions etc)
22 -$wgEmailPageAllowRemoteAddr = array('127.0.0.1'); # Allow anonymous sending from these addresses
23 -$wgEmailPageAllowAllUsers = false; # Whether to allow sending to all users (the "user" group)
24 -$wgEmailPageToolboxLink = true; # Add a link to the sidebar toolbox?
25 -$wgEmailPageActionLink = true; # Add a link to the actions links?
26 -$wgPhpMailerClass = dirname(__FILE__).'/phpMailer_v2.1.0beta2/class.phpmailer.php'; # From http://phpmailer.sourceforge.net/
 19+$wgEmailPageGroup = 'sysop'; # Users must belong to this group to send emails (empty string means anyone can send)
 20+$wgEmailPageContactsCat = ''; # This specifies the name of a category containing categories of contact pages
 21+$wgEmailPageCss = 'EmailPage.css'; # A minimal CSS page to embed in the email (eg. monobook/main.css without portlets, actions etc)
 22+$wgEmailPageAllowRemoteAddr = array( '127.0.0.1' ); # Allow anonymous sending from these addresses
 23+$wgEmailPageAllowAllUsers = false; # Whether to allow sending to all users (the "user" group)
 24+$wgEmailPageToolboxLink = true; # Add a link to the sidebar toolbox?
 25+$wgEmailPageActionLink = true; # Add a link to the actions links?
 26+$wgPhpMailerClass = dirname( __FILE__ ) . '/phpMailer_v2.1.0beta2/class.phpmailer.php'; # From http://phpmailer.sourceforge.net/
2727
28 -if ($wgEmailPageGroup) $wgGroupPermissions['sysop'][$wgEmailPageGroup] = true;
 28+if ( $wgEmailPageGroup ) $wgGroupPermissions['sysop'][$wgEmailPageGroup] = true;
2929
30 -if (isset($_SERVER['SERVER_ADDR'])) $wgEmailPageAllowRemoteAddr[] = $_SERVER['SERVER_ADDR'];
 30+if ( isset( $_SERVER['SERVER_ADDR'] ) ) $wgEmailPageAllowRemoteAddr[] = $_SERVER['SERVER_ADDR'];
3131
32 -$dir = dirname(__FILE__) . '/';
 32+$dir = dirname( __FILE__ ) . '/';
3333 $wgAutoloadClasses['SpecialEmailPage'] = $dir . 'EmailPage_body.php';
3434 $wgExtensionMessagesFiles['EmailPage'] = $dir . 'EmailPage.i18n.php';
3535 $wgExtensionAliasesFiles['EmailPage'] = $dir . 'EmailPage.alias.php';
@@ -45,26 +45,26 @@
4646 );
4747
4848 # If form has been posted, include the phpmailer class
49 -if (isset($_REQUEST['ea-send'])) require_once($wgPhpMailerClass);
 49+if ( isset( $_REQUEST['ea-send'] ) ) require_once( $wgPhpMailerClass );
5050
5151 # Add toolbox and action links
52 -if ($wgEmailPageToolboxLink) $wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfEmailPageToolboxLink';
53 -if ($wgEmailPageActionLink) $wgHooks['SkinTemplateTabs'][] = 'wfEmailPageActionLink';
 52+if ( $wgEmailPageToolboxLink ) $wgHooks['MonoBookTemplateToolboxEnd'][] = 'wfEmailPageToolboxLink';
 53+if ( $wgEmailPageActionLink ) $wgHooks['SkinTemplateTabs'][] = 'wfEmailPageActionLink';
5454
5555 function wfEmailPageToolboxLink() {
5656 global $wgTitle, $wgUser, $wgEmailPageGroup;
57 - if (is_object($wgTitle) && (empty($wgEmailPageGroup) || in_array($wgEmailPageGroup, $wgUser->getEffectiveGroups()))) {
58 - $url = Title::makeTitle(NS_SPECIAL, 'EmailPage')->getLocalURL('ea-title='.$wgTitle->getPrefixedText());
59 - echo("<li><a href=\"$url\">".wfMsg('emailpage')."</a></li>");
60 - }
 57+ if ( is_object( $wgTitle ) && ( empty($wgEmailPageGroup) || in_array( $wgEmailPageGroup, $wgUser->getEffectiveGroups() ) ) ) {
 58+ $url = Title::makeTitle( NS_SPECIAL, 'EmailPage' )->getLocalURL( 'ea-title='.$wgTitle->getPrefixedText() );
 59+ echo( "<li><a href=\"$url\">" . wfMsg( 'emailpage' ) . "</a></li>" );
 60+ }
6161 return true;
6262 }
6363
64 -function wfEmailPageActionLink(&$skin, &$actions) {
 64+function wfEmailPageActionLink( &$skin, &$actions ) {
6565 global $wgTitle, $wgUser, $wgEmailPageGroup;
66 - if (is_object($wgTitle) && (empty($wgEmailPageGroup) || in_array($wgEmailPageGroup, $wgUser->getEffectiveGroups()))) {
67 - $url = Title::makeTitle(NS_SPECIAL, 'EmailPage')->getLocalURL('ea-title='.$wgTitle->getPrefixedText());
68 - $actions['email'] = array('text' => wfMsg('email'), 'class' => false, 'href' => $url);
 66+ if ( is_object( $wgTitle ) && ( empty( $wgEmailPageGroup ) || in_array( $wgEmailPageGroup, $wgUser->getEffectiveGroups() ) ) ) {
 67+ $url = Title::makeTitle( NS_SPECIAL, 'EmailPage' )->getLocalURL('ea-title='.$wgTitle->getPrefixedText() );
 68+ $actions['email'] = array( 'text' => wfMsg( 'email' ), 'class' => false, 'href' => $url );
6969 }
7070 return true;
7171 }

Status & tagging log