summaryrefslogtreecommitdiff
blob: 1496bfdaf9c79232cf470d9820a45e2258fbb62c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class TranslateSandboxEmailJob extends Job {
	public static function newJob( array $params ) {
		return new self( Title::newMainPage(), $params );
	}

	function __construct( $title, $params, $id = 0 ) {
		parent::__construct( __CLASS__, $title, $params, $id );
	}

	function run() {
		$status = UserMailer::send(
			$this->params['to'],
			$this->params['from'],
			$this->params['subj'],
			$this->params['body'],
			$this->params['replyto']
		);

		$isOK = $status->isOK();

		if ( $isOK && $this->params['emailType'] === 'reminder' ) {
			$user = User::newFromId( $this->params['user'] );

			$reminders = $user->getOption( 'translate-sandbox-reminders' );
			$reminders = $reminders ? explode( '|', $reminders ) : array();
			$reminders[] = wfTimestamp();
			$user->setOption( 'translate-sandbox-reminders', implode( '|', $reminders ) );

			$reminders = $user->getOption( 'translate-sandbox-reminders' );
			$user->setOption( 'translate-sandbox-reminders', $reminders );
			$user->saveSettings();
		}

		return $isOK;
	}
}