Pwirth has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/349383 )

Change subject: BSFoundation: Removed deprecated BSMailer
......................................................................

BSFoundation: Removed deprecated BSMailer

Change-Id: Ib0d934f200941a0a95bc1be40d6c9de2f70ee570
---
M extension.json
M i18n/core/qqq.json
D includes/Mailer.class.php
M maintenance/TestMail.php
4 files changed, 6 insertions(+), 246 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/83/349383/1

diff --git a/extension.json b/extension.json
index 12e9ff0..a039df9 100644
--- a/extension.json
+++ b/extension.json
@@ -459,7 +459,6 @@
                "BSNamespaceListParam": 
"includes/paramdefinition/BSNamespaceListParam.php",
                "BSNamespaceParser": "includes/parser/BSNamespaceParser.php",
                "BSNamespaceValidator": 
"includes/validator/BSNamespaceValidator.php",
-               "BsMailer": "includes/Mailer.class.php",
                "BsExtJSStoreParams": "includes/ExtJSStoreParams.php",
                "BsExtJSSortParam": "includes/ExtJSStoreParams.php",
                "BSNotifications": "includes/Notifications.class.php",
diff --git a/i18n/core/qqq.json b/i18n/core/qqq.json
index e240f1e..8710f12 100644
--- a/i18n/core/qqq.json
+++ b/i18n/core/qqq.json
@@ -30,7 +30,6 @@
        "bs-one-unit-ago": "Text shown when indicating how long ago an event 
was\n\nParameters:\n* $1 - a duration; any one of the following messages:\n** 
{{msg-mw|Bs-years-duration}}\n** {{msg-mw|Bs-months-duration}}\n** 
{{msg-mw|Bs-weeks-duration}}\n** {{msg-mw|Bs-days-duration}}\n** 
{{msg-mw|Bs-hours-duration}}\n** {{msg-mw|Bs-mins-duration}}\n** 
{{msg-mw|Bs-secs-duration}}\n{{Identical|Ago}}",
        "bs-now": "Text shown for \"now\" when indicating how long ago an event 
was.\n{{Identical|Now}}",
        "bs-email-greeting-receiver": "Used in emails as first line in body to 
greet the receiver.\n\nParameters:\n* $1 is the username of the receiver - use 
for GENDER distinction \n*$2 is real name of the receiver, if the receiver has 
not set a real name it is the username",
-       "bs-email-greeting-no-receiver": "Used in emails as first line in body 
to greet the reveiver\n{{Identical|Hello}}",
        "bs-email-footer": "Used in mails as last line\n* $1 is the site name 
($wgSitename)",
        "bs-userpagesettings-legend": "Label for section with links to special 
user related settings",
        "bs-userpreferences-link-text": "Label for link to user preferences on 
user page",
diff --git a/includes/Mailer.class.php b/includes/Mailer.class.php
deleted file mode 100644
index 81d507f..0000000
--- a/includes/Mailer.class.php
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-/**
- * DEPRECATED!
- * This file is part of BlueSpice for MediaWiki.
- *
- * @copyright Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
- * @author Sebastian Ulbricht, Robert Vogel
- * @version 1.1.0
- *
- * $LastChangedDate: 2013-06-13 10:32:52 +0200 (Do, 13 Jun 2013) $
- * $LastChangedBy: rvogel $
- * $Rev: 9719 $
-
- */
-
-/**
- * BlueSpice Mailer Component
- * @deprecated since 2.23.2
- * @package BlueSpice_Core
- * @subpackage Mailer
- */
-class BsMailer {
-
-       protected static $prInstances = array();
-       protected $oI18N;
-       protected $bSendHTML = true;
-
-       function __construct() {}
-
-       /**
-        * @deprecated since 2.23.2
-        * N-glton implementation for BsMailer
-        * @param string $name
-        * @param mixed $path Not used.
-        * @return BsMailer The BsMailer instance for the provided 'name'
-        */
-       public static function &getInstance( $name, $path = false ) {
-               if ( !isset( self::$prInstances[$name] ) || 
self::$prInstances[$name] === null ) {
-                       self::$prInstances[$name] = new BsMailer();
-               }
-               return self::$prInstances[$name];
-       }
-
-       /**
-        * Sends mail(s). It makes sure that all mails sent by BlueSpice are 
formatted in similar matter.
-        * @deprecated since 2.23.2
-        * @param mixed $vTo Either a Username, an email address or a User 
object. Or an array of those.
-        * @param string $sSubject The plain subject. Will be prepended with 
sitename.
-        * @param string $sMsg The plain message. Will be surrounded with 
salutation and complementary close.
-        * @param User $oFrom (Optional) a user object that will be used as 
"reply to" information.
-        * @return Status
-        */
-       public function send( $vTo, $sSubject, $sMsg, $oFrom = null ) {
-               wfProfileIn( 'BS::'.__METHOD__ );
-               wfDeprecated( __METHOD__, '2.23.2' );
-               $oStatus = Status::newGood(); // TODO RBV (01.03.12 12:59): Use 
fatal...?
-               # found in mw 1.23 UserMailer.php ln 250
-               # Line endings need to be different on Unix and Windows due to
-               # the bug described at http://trac.wordpress.org/ticket/2603
-               if ( wfIsWindows() ) {
-                       $sEndl = "\r\n";
-               } else {
-                       $sEndl = "\n";
-               }
-
-               $sCurLF = $sEndl;
-               $sReplLF = '<br />' . $sEndl;
-               $sHeaders = null;
-
-               if ( $this->bSendHTML ) {
-                       $sCurLF = '<br/>' . $sEndl;
-                       $sReplLF = $sEndl;
-                       $sHeaders = 'text/html; charset=utf-8';
-               }
-
-               global $wgSitename, $wgPasswordSender,$wgUserEmailUseReplyTo;
-
-               $oFromAddress = new MailAddress( $wgPasswordSender, 
$wgSitename, $wgSitename );
-               $oReplyToAddress = null;
-               if ( $oFrom instanceof User ) {
-                       $oFromAddress = new MailAddress( $oFrom );
-                       if( $wgUserEmailUseReplyTo ) $oReplyToAddress = 
$oFromAddress;
-               }
-
-               // Perpare recipients
-               $aEmailTo = array();
-               if ( !is_array($vTo) ) $vTo = array( $vTo );
-
-               foreach ( $vTo as $vReceiver ) {
-                       if ( $vReceiver instanceof User ) {
-                               if ( $vReceiver->getEmail() ) {
-                                       $aEmailTo[] = array(
-                                               'mail' => new 
MailAddress($vReceiver),
-                                               'greeting' => 
$vReceiver->getName(),
-                                       );
-                               }
-                       } elseif ( strpos( $vReceiver, '@' ) !== false ) {
-                               $aEmailTo[] = array(
-                                       'mail' => new MailAddress( $vReceiver ),
-                                       'greeting' => false
-                               );
-                       } else {
-                               $oUser = User::newFromName( $vReceiver );
-                               if ( !( $oUser instanceof User ) ) {
-                                       //TODO: STM (01.08.2012) Set $oStatus
-                                       wfDebugLog( 'BS::Mailer', 'No User 
Object' . var_export( $vTo, true ) );
-                                       continue;
-                               }
-
-                               if ( $oUser->getEmail() ) {
-                                       $aEmailTo[] = array(
-                                               'mail' => new MailAddress( 
$oUser ),
-                                               'greeting' => 
$vReceiver->getName(),
-                                       );
-                               }
-                       }
-               }
-
-               //Prepare subject
-               $sCombinedSubject = '['.$wgSitename.'] '.$sSubject;
-
-               //Prepare message
-               if ( $this->bSendHTML ) {
-                       //http(s)://link -> <a 
href="http(s)://link>http(s)://link</a>"
-                       //! already followed by </a>
-                       //last char ! "."
-                       $sMsg = preg_replace(
-                               "#(\s|/>)(https?://[^\s]+?)\.?([\s|<])#",
-                               '<a href="$2">$2</a>',
-                               $sMsg
-                       );
-               }
-
-               //Note that this is system lang!
-               $sNL = $this->bSendHTML ? "<br />" : $sEndl;
-               $sFooter =
-                       "$sNL$sNL---------------------$sNL$sNL"
-                       .wfMessage( 'bs-email-footer', $wgSitename )->text()
-                       ."$sNL$sNL---------------------"
-               ;
-
-               $sCombinedMsg = $sMsg.$sFooter;
-
-               foreach ( $aEmailTo as $aReceiver ) {
-                       global $wgVersion;
-                       //Prepare message
-                       if ( $aReceiver['greeting'] ) {
-                               $oUser = User::newFromName( 
$aReceiver['greeting'] );
-                               $sRealname = BsCore::getUserDisplayName( $oUser 
);
-                               $sGreeting = wfMessage( 
'bs-email-greeting-receiver', $aReceiver['greeting'], $sRealname )
-                                       ->inLanguage( $oUser->getOption( 
'language' ) )
-                                       ->text();
-                       } else {
-                               $sGreeting = wfMessage( 
'bs-email-greeting-no-receiver' )->text();
-                       }
-                       //double new line
-                       $sGreeting .= $sNL.$sNL;
-
-                       $sLocalCombinedMsg = $sGreeting.$sCombinedMsg;
-                       $sLocalCombinedMsg = str_replace( $sReplLF, $sCurLF, 
$sLocalCombinedMsg );
-
-                       if ( BsConfig::get( 'MW::TestMode' ) ) {
-                               $sLog = var_export(
-                                       array(
-                                               'to' => 
$aReceiver['mail']->toString(),
-                                               'subject' => $sCombinedSubject,
-                                               'body' => $sLocalCombinedMsg,
-                                               'replyto' => $oReplyToAddress,
-                                               'from' => 
$oFromAddress->toString()
-                                       ),
-                                       true
-                               );
-                               wfDebugLog( 'BS::Mailer', $sLog );
-                       } else {
-                               if( version_compare( $wgVersion, "1.25", '<=')){
-                                       $oStatus = UserMailer::send(
-                                               $aReceiver['mail'],
-                                               $oFromAddress,
-                                               $sCombinedSubject,
-                                               $sLocalCombinedMsg,
-                                               $oReplyToAddress,
-                                               $sHeaders
-                                       );
-                               } else {
-                                       $oStatus = UserMailer::send(
-                                       $aReceiver['mail'],
-                                       $oFromAddress,
-                                       $sCombinedSubject,
-                                       $sLocalCombinedMsg,
-                                       array(
-                                               'replyTo' => $oReplyToAddress,
-                                               'headers' => $sHeaders
-                                       ));
-                               }
-                       }
-               }
-               wfProfileOut( 'BS::'.__METHOD__ );
-               return $oStatus;
-       }
-
-       /*
-        * @deprecated since 2.23.2
-        */
-       public function getSendHTML() {
-               return $this->bSendHTML;
-       }
-
-       /*
-        * @deprecated since 2.23.2
-        */
-       public function setSendHTML( $bSendHTML ) {
-               $this->bSendHTML = $bSendHTML;
-       }
-
-}
diff --git a/maintenance/TestMail.php b/maintenance/TestMail.php
index ade4fa5..0c0a899 100644
--- a/maintenance/TestMail.php
+++ b/maintenance/TestMail.php
@@ -20,23 +20,17 @@
                parent::__construct();
 
                $this->addOption('recipient', 'Valid user name or e-mail 
address to send the mail to', true, true);
-               $this->addOption('framework', '[MW|BS] - To choose UserMailer 
or BsMailer for sending. Default is "MW".', false, true);
                $this->addOption('subject', 'An optional subject', false, true);
                $this->addOption('text', 'An optional text', false, true);
-               $this->addOption('testmode', '[true|false] - Optional for 
framework "BS". Temporarily enables "Core::TestMode". Default is "false".', 
false, true);
-               $this->addOption('html', '[true|false] - Optional for framework 
"BS". Default is "false".', false, true);
        }
 
        public function execute() {
                global $wgPasswordSender;
-               
+
                $sRecipient = $this->getOption( 'recipient' );
-               $sFramework = strtoupper( $this->getOption( 'framework', 'MW' ) 
);
                $sSubject   = $this->getOption( 'subject', 
$this->defaultSubject );
                $sText      = $this->getOption( 'text', $this->defaultText );
-               $sTestMode  = strtolower( $this->getOption( 'testmode', 'false' 
) );
-               $sHTML      = strtolower( $this->getOption( 'html', 'false' ) );
-               
+
                //We asume that the given recipient is a user name
                $oRecipient = User::newFromName($sRecipient);
                $oRecipientAddress = null;
@@ -50,35 +44,18 @@
                else if ( $oRecipient->getEmail() ) { //not empty, false or 
things like this
                        $oRecipientAddress = new MailAddress( 
$oRecipient->getEmail() );
                }
-               
+
                if( $oRecipientAddress == null ) {
                        $this->error( 'Not a valid user name or e-mail address 
or user has no e-mail address set.');
                        return;
                }
-               
+
                $this->output( "Sending mail to 
'{$oRecipientAddress->toString()}'\n" );
 
-               if( $sFramework == 'BS' ) {
-                       if( $sTestMode == 'true' ) {
-                               BsConfig::set( 'MW::TestMode', true ); //is not 
saved so it doesn't need to be reverted
-                       }
 
-                       $vTo = $oRecipient; //BsMailer needs User object or 
String, but not MailAddress object.
-                       if( $oRecipient->getId() == 0 ) $vTo = 
$oRecipientAddress->toString ();
-                       
-                       $this->output( "Using BsMailer with 'Core::TestMode' == 
$sTestMode and 'HTML' == $sHTML\n" );
+               $this->output( "Using UserMailer\n" );
+               $oStatus = UserMailer::send( $oRecipientAddress, new 
MailAddress( $wgPasswordSender ), $sSubject, $sText );
 
-                       $bHTML = false;
-                       if( $sHTML == 'true' ) $bHTML = true;
-
-                       BsMailer::getInstance('MW')->setSendHTML($bHTML); //is 
not saved so it doesn't need to be reverted
-                       $oStatus = BsMailer::getInstance('MW')->send( $vTo, 
$sSubject, $sText );
-               }
-               else { 
-                       $this->output( "Using UserMailer\n" );
-                       $oStatus = UserMailer::send( $oRecipientAddress, new 
MailAddress( $wgPasswordSender ), $sSubject, $sText );
-               }
-               
                if( $oStatus->isGood() ) {
                        $this->output( "Mail send\n" );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/349383
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0d934f200941a0a95bc1be40d6c9de2f70ee570
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Pwirth <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to