// error out if sending user cannot do this
$error = self::getPermissionsError(
$this->getUser(),
- $this->getRequest()->getVal( 'wpEditToken' )
+ $this->getRequest()->getVal( 'wpEditToken' ),
+ $this->getConfig()
);
switch ( $error ) {
*
* @param User $user
* @param string $editToken Edit token
+ * @param Config $config optional for backwards compatibility
* @return string|null Null on success or string on error
*/
- public static function getPermissionsError( $user, $editToken ) {
- global $wgEnableEmail, $wgEnableUserEmail;
-
- if ( !$wgEnableEmail || !$wgEnableUserEmail ) {
+ public static function getPermissionsError( $user, $editToken, Config $config = null ) {
+ if ( $config === null ) {
+ wfDebug( __METHOD__ . ' called without a Config instance passed to it' );
+ $config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ }
+ if ( !$config->get( 'EnableEmail' ) || !$config->get( 'EnableUserEmail' ) ) {
return 'usermaildisabled';
}
* @return string Form asking for user name.
*/
protected function userForm( $name ) {
- global $wgScript;
$string = Xml::openElement(
'form',
- array( 'method' => 'get', 'action' => $wgScript, 'id' => 'askusername' )
+ array( 'method' => 'get', 'action' => wfScript(), 'id' => 'askusername' )
) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
Xml::openElement( 'fieldset' ) .
* or maybe even true on success if anything uses the EmailUser hook.
*/
public static function submit( array $data, IContextSource $context ) {
- global $wgUserEmailUseReplyTo;
+ $config = $context->getConfig();
$target = self::getTarget( $data['Target'] );
if ( !$target instanceof User ) {
return $error;
}
- if ( $wgUserEmailUseReplyTo ) {
+ if ( $config->get( 'UserEmailUseReplyTo' ) ) {
// Put the generic wiki autogenerated address in the From:
// header and reserve the user for Reply-To.
//
// This is a bit ugly, but will serve to differentiate
// wiki-borne mails from direct mails and protects against
// SPF and bounce problems with some mailers (see below).
- global $wgPasswordSender;
-
- $mailFrom = new MailAddress( $wgPasswordSender,
+ $mailFrom = new MailAddress( $config->get( 'PasswordSender' ),
wfMessage( 'emailsender' )->inContentLanguage()->text() );
$replyTo = $from;
} else {