|
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\Domain; |
|
12
|
|
|
use Waca\DataObjects\Request; |
|
13
|
|
|
use Waca\DataObjects\User; |
|
14
|
|
|
use Waca\Helpers\Interfaces\IEmailHelper; |
|
15
|
|
|
|
|
16
|
|
|
class RequestEmailHelper |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var IEmailHelper |
|
20
|
|
|
*/ |
|
21
|
|
|
private $emailHelper; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* RequestEmailHelper constructor. |
|
25
|
|
|
* |
|
26
|
|
|
* @param IEmailHelper $emailHelper |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(IEmailHelper $emailHelper) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->emailHelper = $emailHelper; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param Request $request |
|
35
|
|
|
* @param string $mailText |
|
36
|
|
|
* @param User $currentUser |
|
37
|
|
|
* @param boolean $ccMailingList |
|
38
|
|
|
*/ |
|
39
|
|
|
public function sendMail(Request $request, $mailText, User $currentUser, $ccMailingList) |
|
40
|
|
|
{ |
|
41
|
|
|
$headers = array( |
|
42
|
|
|
'X-ACC-Request' => $request->getId(), |
|
43
|
|
|
'X-ACC-UserID' => $currentUser->getId(), |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
// FIXME: domains! |
|
47
|
|
|
/** @var Domain $domain */ |
|
48
|
|
|
$domain = Domain::getById(1, $request->getDatabase()); |
|
49
|
|
|
|
|
50
|
|
|
if ($ccMailingList) { |
|
51
|
|
|
$headers['Cc'] = $domain->getEmailReplyAddress(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$helper = $this->emailHelper; |
|
55
|
|
|
|
|
56
|
|
|
$emailSig = $currentUser->getEmailSig(); |
|
57
|
|
|
if ($emailSig !== '' || $emailSig !== null) { |
|
|
|
|
|
|
58
|
|
|
$emailSig = "\n\n" . $emailSig; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$subject = "RE: [ACC #{$request->getId()}] English Wikipedia Account Request"; |
|
62
|
|
|
$content = $mailText . $emailSig; |
|
63
|
|
|
|
|
64
|
|
|
$helper->sendMail($domain->getEmailReplyAddress(), $request->getEmail(), $subject, $content, $headers); |
|
65
|
|
|
|
|
66
|
|
|
$request->setEmailSent(true); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|