1
|
|
|
<?php |
2
|
|
|
/****************************************************************************** |
3
|
|
|
* Wikipedia Account Creation Assistance tool * |
4
|
|
|
* * |
5
|
|
|
* All code in this file is released into the public domain by the ACC * |
6
|
|
|
* Development Team. Please see team.json for a list of contributors. * |
7
|
|
|
******************************************************************************/ |
8
|
|
|
|
9
|
|
|
namespace Waca\Helpers; |
10
|
|
|
|
11
|
|
|
use Waca\DataObjects\Request; |
12
|
|
|
use Waca\DataObjects\User; |
13
|
|
|
use Waca\Helpers\Interfaces\IEmailHelper; |
14
|
|
|
|
15
|
|
|
class RequestEmailHelper |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var IEmailHelper |
19
|
|
|
*/ |
20
|
|
|
private $emailHelper; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* RequestEmailHelper constructor. |
24
|
|
|
* |
25
|
|
|
* @param IEmailHelper $emailHelper |
26
|
|
|
*/ |
27
|
|
|
public function __construct(IEmailHelper $emailHelper) |
28
|
|
|
{ |
29
|
|
|
$this->emailHelper = $emailHelper; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param Request $request |
34
|
|
|
* @param string $mailText |
35
|
|
|
* @param User $currentUser |
36
|
|
|
* @param boolean $ccMailingList |
37
|
|
|
*/ |
38
|
|
|
public function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
39
|
|
|
{ |
40
|
|
|
$headers = array( |
41
|
|
|
'X-ACC-Request' => $request->getId(), |
42
|
|
|
'X-ACC-UserID' => $currentUser->getId(), |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
if ($ccMailingList) { |
46
|
|
|
$headers['Cc'] = '[email protected]'; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
$helper = $this->emailHelper; |
50
|
|
|
|
51
|
|
|
$emailSig = $currentUser->getEmailSig(); |
52
|
|
|
if ($emailSig !== '' || $emailSig !== null) { |
53
|
|
|
$emailSig = "\n\n" . $emailSig; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
57
|
|
|
$content = $mailText . $emailSig; |
58
|
|
|
|
59
|
|
|
$helper->sendMail($request->getEmail(), $subject, $content, $headers); |
60
|
|
|
|
61
|
|
|
$request->setEmailSent(true); |
62
|
|
|
} |
63
|
|
|
} |